system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_SYSTEM_H
21 #define LIBMESH_SYSTEM_H
22 
23 // Local Includes
24 #include "libmesh/auto_ptr.h"
25 #include "libmesh/elem_range.h"
26 #include "libmesh/enum_norm_type.h"
27 #include "libmesh/enum_xdr_mode.h"
31 #include "libmesh/libmesh_common.h"
33 #include "libmesh/qoi_set.h"
35 #include "libmesh/tensor_value.h" // For point_hessian
36 #include "libmesh/variable.h"
37 
38 // C++ includes
39 #include <cstddef>
40 #include <set>
41 #include <vector>
42 
43 namespace libMesh
44 {
45 
46 // Forward Declarations
47 class System;
48 class EquationSystems;
49 class MeshBase;
50 class Xdr;
51 class DofMap;
52 template <typename Output> class FunctionBase;
53 class Parameters;
54 class ParameterVector;
55 class Point;
56 class SensitivityData;
57 template <typename T> class NumericVector;
58 template <typename T> class VectorValue;
59 typedef VectorValue<Number> NumberVectorValue;
60 typedef NumberVectorValue Gradient;
61 class SystemSubset;
62 class FEType;
63 class SystemNorm;
64 
76 class System : public ReferenceCountedObject<System>,
77  public ParallelObject
78 {
79 public:
80 
85  System (EquationSystems & es,
86  const std::string & name,
87  const unsigned int number);
88 
96  {
97  public:
101  virtual ~Initialization () {}
102 
108  virtual void initialize () = 0;
109  };
110 
111 
112 
119  class Assembly
120  {
121  public:
125  virtual ~Assembly () {}
126 
132  virtual void assemble () = 0;
133  };
134 
135 
136 
144  {
145  public:
149  virtual ~Constraint () {}
150 
156  virtual void constrain () = 0;
157  };
158 
159 
160 
167  class QOI
168  {
169  public:
173  virtual ~QOI () {}
174 
180  virtual void qoi (const QoISet & qoi_indices) = 0;
181  };
182 
183 
184 
192  {
193  public:
197  virtual ~QOIDerivative () {}
198 
204  virtual void qoi_derivative (const QoISet & qoi_indices,
205  bool include_liftfunc,
206  bool apply_constraints) = 0;
207  };
208 
209 
210 
214  virtual ~System ();
215 
219  typedef System sys_type;
220 
224  sys_type & system () { return *this; }
225 
230  virtual void clear ();
231 
236  void init ();
237 
246  virtual void reinit ();
247 
251  virtual void reinit_constraints ();
252 
256  bool is_initialized();
257 
262  virtual void update ();
263 
270  virtual void assemble ();
271 
276  virtual void assemble_qoi (const QoISet & qoi_indices = QoISet());
277 
282  virtual void assemble_qoi_derivative (const QoISet & qoi_indices = QoISet(),
283  bool include_liftfunc = true,
284  bool apply_constraints = true);
285 
297  virtual void assemble_residual_derivatives (const ParameterVector & parameters);
298 
304  virtual void restrict_solve_to (const SystemSubset * subset,
305  const SubsetSolveMode subset_solve_mode=SUBSET_ZERO);
306 
310  virtual void solve () {}
311 
321  virtual std::pair<unsigned int, Real>
322  sensitivity_solve (const ParameterVector & parameters);
323 
334  virtual std::pair<unsigned int, Real>
335  weighted_sensitivity_solve (const ParameterVector & parameters,
336  const ParameterVector & weights);
337 
348  virtual std::pair<unsigned int, Real>
349  adjoint_solve (const QoISet & qoi_indices = QoISet());
350 
365  virtual std::pair<unsigned int, Real>
367  const ParameterVector & weights,
368  const QoISet & qoi_indices = QoISet());
373  { return adjoint_already_solved;}
374 
378  void set_adjoint_already_solved(bool setting)
379  { adjoint_already_solved = setting;}
380 
381 
399  virtual void qoi_parameter_sensitivity (const QoISet & qoi_indices,
400  const ParameterVector & parameters,
401  SensitivityData & sensitivities);
402 
408  virtual void adjoint_qoi_parameter_sensitivity (const QoISet & qoi_indices,
409  const ParameterVector & parameters,
410  SensitivityData & sensitivities);
411 
417  virtual void forward_qoi_parameter_sensitivity (const QoISet & qoi_indices,
418  const ParameterVector & parameters,
419  SensitivityData & sensitivities);
420 
431  virtual void qoi_parameter_hessian(const QoISet & qoi_indices,
432  const ParameterVector & parameters,
433  SensitivityData & hessian);
434 
447  virtual void qoi_parameter_hessian_vector_product(const QoISet & qoi_indices,
448  const ParameterVector & parameters,
449  const ParameterVector & vector,
450  SensitivityData & product);
451 
457  virtual bool compare (const System & other_system,
458  const Real threshold,
459  const bool verbose) const;
460 
464  const std::string & name () const;
465 
471  virtual std::string system_type () const { return "Basic"; }
472 
484 
496 
504  void project_solution (Number fptr(const Point & p,
505  const Parameters & parameters,
506  const std::string & sys_name,
507  const std::string & unknown_name),
508  Gradient gptr(const Point & p,
509  const Parameters & parameters,
510  const std::string & sys_name,
511  const std::string & unknown_name),
512  const Parameters & parameters) const;
513 
527  void project_vector (NumericVector<Number> & new_vector,
530  int is_adjoint = -1) const;
531 
545  void project_vector (NumericVector<Number> & new_vector,
548  int is_adjoint = -1) const;
549 
561  void project_vector (Number fptr(const Point & p,
562  const Parameters & parameters,
563  const std::string & sys_name,
564  const std::string & unknown_name),
565  Gradient gptr(const Point & p,
566  const Parameters & parameters,
567  const std::string & sys_name,
568  const std::string & unknown_name),
569  const Parameters & parameters,
570  NumericVector<Number> & new_vector,
571  int is_adjoint = -1) const;
572 
587  void boundary_project_solution (const std::set<boundary_id_type> & b,
588  const std::vector<unsigned int> & variables,
591 
604  void boundary_project_solution (const std::set<boundary_id_type> & b,
605  const std::vector<unsigned int> & variables,
606  Number fptr(const Point & p,
607  const Parameters & parameters,
608  const std::string & sys_name,
609  const std::string & unknown_name),
610  Gradient gptr(const Point & p,
611  const Parameters & parameters,
612  const std::string & sys_name,
613  const std::string & unknown_name),
614  const Parameters & parameters);
615 
633  void boundary_project_vector (const std::set<boundary_id_type> & b,
634  const std::vector<unsigned int> & variables,
635  NumericVector<Number> & new_vector,
638  int is_adjoint = -1) const;
639 
655  void boundary_project_vector (const std::set<boundary_id_type> & b,
656  const std::vector<unsigned int> & variables,
657  Number fptr(const Point & p,
658  const Parameters & parameters,
659  const std::string & sys_name,
660  const std::string & unknown_name),
661  Gradient gptr(const Point & p,
662  const Parameters & parameters,
663  const std::string & sys_name,
664  const std::string & unknown_name),
665  const Parameters & parameters,
666  NumericVector<Number> & new_vector,
667  int is_adjoint = -1) const;
668 
672  unsigned int number () const;
673 
679  void update_global_solution (std::vector<Number> & global_soln) const;
680 
686  void update_global_solution (std::vector<Number> & global_soln,
687  const processor_id_type dest_proc) const;
688 
692  const MeshBase & get_mesh() const;
693 
697  MeshBase & get_mesh();
698 
702  const DofMap & get_dof_map() const;
703 
707  DofMap & get_dof_map();
708 
713 
718 
723  bool active () const;
724 
728  void activate ();
729 
733  void deactivate ();
734 
743  void set_basic_system_only ();
744 
748  typedef std::map<std::string, NumericVector<Number> *>::iterator vectors_iterator;
749  typedef std::map<std::string, NumericVector<Number> *>::const_iterator const_vectors_iterator;
750 
754  vectors_iterator vectors_begin ();
755 
759  const_vectors_iterator vectors_begin () const;
760 
764  vectors_iterator vectors_end ();
765 
769  const_vectors_iterator vectors_end () const;
770 
780  NumericVector<Number> & add_vector (const std::string & vec_name,
781  const bool projections=true,
782  const ParallelType type = PARALLEL);
783 
787  void remove_vector(const std::string & vec_name);
788 
795  { return _solution_projection; }
796 
801  bool have_vector (const std::string & vec_name) const;
802 
807  const NumericVector<Number> * request_vector (const std::string & vec_name) const;
808 
813  NumericVector<Number> * request_vector (const std::string & vec_name);
814 
820  const NumericVector<Number> * request_vector (const unsigned int vec_num) const;
821 
827  NumericVector<Number> * request_vector (const unsigned int vec_num);
828 
834  const NumericVector<Number> & get_vector (const std::string & vec_name) const;
835 
841  NumericVector<Number> & get_vector (const std::string & vec_name);
842 
848  const NumericVector<Number> & get_vector (const unsigned int vec_num) const;
849 
855  NumericVector<Number> & get_vector (const unsigned int vec_num);
856 
861  const std::string & vector_name (const unsigned int vec_num) const;
862 
866  const std::string & vector_name (const NumericVector<Number> & vec_reference) const;
867 
878  void set_vector_as_adjoint (const std::string & vec_name, int qoi_num);
879 
885  int vector_is_adjoint (const std::string & vec_name) const;
886 
892  void set_vector_preservation (const std::string & vec_name, bool preserve);
893 
899  bool vector_preservation (const std::string & vec_name) const;
900 
906  NumericVector<Number> & add_adjoint_solution(unsigned int i=0);
907 
912  NumericVector<Number> & get_adjoint_solution(unsigned int i=0);
913 
918  const NumericVector<Number> & get_adjoint_solution(unsigned int i=0) const;
919 
926 
932 
937  const NumericVector<Number> & get_sensitivity_solution(unsigned int i=0) const;
938 
946 
953 
960 
967 
973 
979 
985  NumericVector<Number> & add_adjoint_rhs(unsigned int i=0);
986 
993  NumericVector<Number> & get_adjoint_rhs(unsigned int i=0);
994 
999  const NumericVector<Number> & get_adjoint_rhs(unsigned int i=0) const;
1000 
1006  NumericVector<Number> & add_sensitivity_rhs(unsigned int i=0);
1007 
1017  NumericVector<Number> & get_sensitivity_rhs(unsigned int i=0);
1018 
1023  const NumericVector<Number> & get_sensitivity_rhs(unsigned int i=0) const;
1024 
1030  unsigned int n_vectors () const;
1031 
1038  virtual unsigned int n_matrices () const;
1039 
1043  unsigned int n_vars() const;
1044 
1048  unsigned int n_variable_groups() const;
1049 
1055  unsigned int n_components() const;
1056 
1060  dof_id_type n_dofs() const;
1061 
1066  dof_id_type n_active_dofs() const;
1067 
1073 
1079 
1084  dof_id_type n_local_dofs() const;
1085 
1092  unsigned int add_variable (const std::string & var,
1093  const FEType & type,
1094  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1095 
1101  unsigned int add_variable (const std::string & var,
1102  const Order order = FIRST,
1103  const FEFamily = LAGRANGE,
1104  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1105 
1112  unsigned int add_variables (const std::vector<std::string> & vars,
1113  const FEType & type,
1114  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1115 
1121  unsigned int add_variables (const std::vector<std::string> & vars,
1122  const Order order = FIRST,
1123  const FEFamily = LAGRANGE,
1124  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1125 
1129  const Variable & variable (unsigned int var) const;
1130 
1134  const VariableGroup & variable_group (unsigned int vg) const;
1135 
1139  bool has_variable(const std::string & var) const;
1140 
1144  const std::string & variable_name(const unsigned int i) const;
1145 
1150  unsigned short int variable_number (const std::string & var) const;
1151 
1156  void get_all_variable_numbers(std::vector<unsigned int> & all_variable_numbers) const;
1157 
1168  unsigned int variable_scalar_number (const std::string & var,
1169  unsigned int component) const;
1170 
1181  unsigned int variable_scalar_number (unsigned int var_num,
1182  unsigned int component) const;
1183 
1184 
1188  const FEType & variable_type (const unsigned int i) const;
1189 
1193  const FEType & variable_type (const std::string & var) const;
1194 
1199  bool identify_variable_groups () const;
1200 
1204  void identify_variable_groups (const bool);
1205 
1211  unsigned int var,
1212  FEMNormType norm_type,
1213  std::set<unsigned int> * skip_dimensions=libmesh_nullptr) const;
1214 
1220  const SystemNorm & norm,
1221  std::set<unsigned int> * skip_dimensions=libmesh_nullptr) const;
1222 
1226  void read_header (Xdr & io,
1227  const std::string & version,
1228  const bool read_header=true,
1229  const bool read_additional_data=true,
1230  const bool read_legacy_format=false);
1231 
1239  void read_legacy_data (Xdr & io,
1240  const bool read_additional_data=true);
1241 
1246  template <typename ValType>
1247  void read_serialized_data (Xdr & io,
1248  const bool read_additional_data=true);
1256  const bool read_additional_data=true)
1257  { read_serialized_data<Number>(io, read_additional_data); }
1258 
1264  template <typename InValType>
1265  std::size_t read_serialized_vectors (Xdr & io,
1266  const std::vector<NumericVector<Number> *> & vectors) const;
1267 
1275  std::size_t read_serialized_vectors (Xdr & io,
1276  const std::vector<NumericVector<Number> *> & vectors) const
1277  { return read_serialized_vectors<Number>(io, vectors); }
1278 
1285  template <typename InValType>
1286  void read_parallel_data (Xdr & io,
1287  const bool read_additional_data);
1288 
1298  const bool read_additional_data)
1299  { read_parallel_data<Number>(io, read_additional_data); }
1300 
1304  void write_header (Xdr & io,
1305  const std::string & version,
1306  const bool write_additional_data) const;
1307 
1312  void write_serialized_data (Xdr & io,
1313  const bool write_additional_data = true) const;
1314 
1320  std::size_t write_serialized_vectors (Xdr & io,
1321  const std::vector<const NumericVector<Number> *> & vectors) const;
1322 
1329  void write_parallel_data (Xdr & io,
1330  const bool write_additional_data) const;
1331 
1336  std::string get_info () const;
1337 
1341  void attach_init_function (void fptr(EquationSystems & es,
1342  const std::string & name));
1343 
1349  void attach_init_object (Initialization & init);
1350 
1355  void attach_assemble_function (void fptr(EquationSystems & es,
1356  const std::string & name));
1357 
1362  void attach_assemble_object (Assembly & assemble);
1363 
1367  void attach_constraint_function (void fptr(EquationSystems & es,
1368  const std::string & name));
1369 
1373  void attach_constraint_object (Constraint & constrain);
1374 
1379  void attach_QOI_function (void fptr(EquationSystems & es,
1380  const std::string & name,
1381  const QoISet & qoi_indices));
1382 
1387  void attach_QOI_object (QOI & qoi);
1388 
1394  void attach_QOI_derivative (void fptr(EquationSystems & es,
1395  const std::string & name,
1396  const QoISet & qoi_indices,
1397  bool include_liftfunc,
1398  bool apply_constraints));
1399 
1405  void attach_QOI_derivative_object (QOIDerivative & qoi_derivative);
1406 
1411  virtual void user_initialization ();
1412 
1417  virtual void user_assembly ();
1418 
1423  virtual void user_constrain ();
1424 
1429  virtual void user_QOI (const QoISet & qoi_indices);
1430 
1435  virtual void user_QOI_derivative (const QoISet & qoi_indices = QoISet(),
1436  bool include_liftfunc = true,
1437  bool apply_constraints = true);
1438 
1444  virtual void re_update ();
1445 
1449  virtual void restrict_vectors ();
1450 
1454  virtual void prolong_vectors ();
1455 
1476 
1481  virtual void disable_cache ();
1482 
1492 
1507 
1508 
1509  //--------------------------------------------------
1510  // The solution and solution access members
1511 
1516  Number current_solution (const dof_id_type global_dof_number) const;
1517 
1522 
1534 
1544 
1551  std::vector<Number> qoi;
1552 
1573  Number point_value(unsigned int var, const Point & p,
1574  const bool insist_on_success = true) const;
1575 
1583  Number point_value(unsigned int var, const Point & p, const Elem & e) const;
1584 
1591  Number point_value(unsigned int var, const Point & p, const Elem * e) const;
1592 
1597  Gradient point_gradient(unsigned int var, const Point & p,
1598  const bool insist_on_success = true) const;
1599 
1604  Gradient point_gradient(unsigned int var, const Point & p, const Elem & e) const;
1605 
1612  Gradient point_gradient(unsigned int var, const Point & p, const Elem * e) const;
1613 
1618  Tensor point_hessian(unsigned int var, const Point & p,
1619  const bool insist_on_success = true) const;
1620 
1626  Tensor point_hessian(unsigned int var, const Point & p, const Elem & e) const;
1627 
1634  Tensor point_hessian(unsigned int var, const Point & p, const Elem * e) const;
1635 
1640  void local_dof_indices (const unsigned int var,
1641  std::set<dof_id_type> & var_indices) const;
1642 
1647  void zero_variable (NumericVector<Number> & v, unsigned int var_num) const;
1648 
1649 
1655  bool & hide_output() { return _hide_output; }
1656 
1657 protected:
1658 
1665  virtual void init_data ();
1666 
1675  int is_adjoint = -1) const;
1676 
1685  void project_vector (const NumericVector<Number> &,
1687  int is_adjoint = -1) const;
1688 
1689 private:
1696  System (const System &);
1697 
1704  System & operator=(const System &);
1705 
1711  unsigned int var,
1712  FEMNormType norm_type) const;
1713 
1723  template <typename iterator_type, typename InValType>
1725  const iterator_type begin,
1726  const iterator_type end,
1727  const InValType dummy,
1728  Xdr & io,
1729  const std::vector<NumericVector<Number> *> & vecs,
1730  const unsigned int var_to_read=libMesh::invalid_uint) const;
1731 
1740  unsigned int read_SCALAR_dofs (const unsigned int var,
1741  Xdr & io,
1742  NumericVector<Number> * vec) const;
1743 
1752  template <typename InValType>
1754  NumericVector<Number> * vec);
1755 
1765  NumericVector<Number> & vec)
1766  { return read_serialized_vector<Number>(io, &vec); }
1767 
1774  template <typename iterator_type>
1775  std::size_t write_serialized_blocked_dof_objects (const std::vector<const NumericVector<Number> *> & vecs,
1776  const dof_id_type n_objects,
1777  const iterator_type begin,
1778  const iterator_type end,
1779  Xdr & io,
1780  const unsigned int var_to_write=libMesh::invalid_uint) const;
1781 
1787  unsigned int write_SCALAR_dofs (const NumericVector<Number> & vec,
1788  const unsigned int var,
1789  Xdr & io) const;
1790 
1798  const NumericVector<Number> & vec) const;
1799 
1804  const std::string & name);
1805 
1810 
1815  const std::string & name);
1816 
1821 
1826  const std::string & name);
1827 
1832 
1837  const std::string & name,
1838  const QoISet & qoi_indices);
1839 
1844 
1849  const std::string & name,
1850  const QoISet & qoi_indices,
1851  bool include_liftfunc,
1852  bool apply_constraints);
1853 
1858 
1864 
1870 
1876 
1880  const std::string _sys_name;
1881 
1885  const unsigned int _sys_number;
1886 
1890  std::vector<Variable> _variables;
1891 
1895  std::vector<VariableGroup> _variable_groups;
1896 
1901  std::map<std::string, unsigned short int> _variable_numbers;
1902 
1906  bool _active;
1907 
1914  std::map<std::string, NumericVector<Number> * > _vectors;
1915 
1920  std::map<std::string, bool> _vector_projections;
1921 
1926  std::map<std::string, int> _vector_is_adjoint;
1927 
1931  std::map<std::string, ParallelType> _vector_types;
1932 
1939 
1945 
1951 
1957 
1964 
1975  std::vector<unsigned int> _written_var_indices;
1976 
1983 
1989 };
1990 
1991 
1992 
1993 // ------------------------------------------------------------
1994 // System inline methods
1995 inline
1996 const std::string & System::name() const
1997 {
1998  return _sys_name;
1999 }
2000 
2001 
2002 
2003 inline
2004 unsigned int System::number() const
2005 {
2006  return _sys_number;
2007 }
2008 
2009 
2010 
2011 inline
2013 {
2014  return _mesh;
2015 }
2016 
2017 
2018 
2019 inline
2021 {
2022  return _mesh;
2023 }
2024 
2025 
2026 
2027 inline
2029 {
2030  return *_dof_map;
2031 }
2032 
2033 
2034 
2035 inline
2037 {
2038  return *_dof_map;
2039 }
2040 
2041 
2042 
2043 inline
2044 bool System::active() const
2045 {
2046  return _active;
2047 }
2048 
2049 
2050 
2051 inline
2053 {
2054  _active = true;
2055 }
2056 
2057 
2058 
2059 inline
2061 {
2062  _active = false;
2063 }
2064 
2065 
2066 
2067 inline
2069 {
2070  return _is_initialized;
2071 }
2072 
2073 
2074 
2075 inline
2077 {
2078  _basic_system_only = true;
2079 }
2080 
2081 
2082 
2083 inline
2084 unsigned int System::n_vars() const
2085 {
2086  return cast_int<unsigned int>(_variables.size());
2087 }
2088 
2089 
2090 
2091 inline
2092 unsigned int System::n_variable_groups() const
2093 {
2094  return cast_int<unsigned int>(_variable_groups.size());
2095 }
2096 
2097 
2098 
2099 inline
2100 unsigned int System::n_components() const
2101 {
2102  if (_variables.empty())
2103  return 0;
2104 
2105  const Variable & last = _variables.back();
2106  return last.first_scalar_number() + last.n_components();
2107 }
2108 
2109 
2110 
2111 inline
2112 const Variable & System::variable (const unsigned int i) const
2113 {
2114  libmesh_assert_less (i, _variables.size());
2115 
2116  return _variables[i];
2117 }
2118 
2119 
2120 
2121 inline
2122 const VariableGroup & System::variable_group (const unsigned int vg) const
2123 {
2124  libmesh_assert_less (vg, _variable_groups.size());
2125 
2126  return _variable_groups[vg];
2127 }
2128 
2129 
2130 
2131 inline
2132 const std::string & System::variable_name (const unsigned int i) const
2133 {
2134  libmesh_assert_less (i, _variables.size());
2135 
2136  return _variables[i].name();
2137 }
2138 
2139 
2140 
2141 inline
2142 unsigned int
2143 System::variable_scalar_number (const std::string & var,
2144  unsigned int component) const
2145 {
2146  return variable_scalar_number(this->variable_number(var), component);
2147 }
2148 
2149 
2150 
2151 inline
2152 unsigned int
2153 System::variable_scalar_number (unsigned int var_num,
2154  unsigned int component) const
2155 {
2156  return _variables[var_num].first_scalar_number() + component;
2157 }
2158 
2159 
2160 
2161 inline
2162 const FEType & System::variable_type (const unsigned int i) const
2163 {
2164  libmesh_assert_less (i, _variables.size());
2165 
2166  return _variables[i].type();
2167 }
2168 
2169 
2170 
2171 inline
2172 const FEType & System::variable_type (const std::string & var) const
2173 {
2174  return _variables[this->variable_number(var)].type();
2175 }
2176 
2177 
2178 
2179 inline
2181 {
2183 }
2184 
2185 
2186 
2187 inline
2189 {
2191 }
2192 
2193 
2194 
2195 inline
2197 {
2198  return this->n_dofs() - this->n_constrained_dofs();
2199 }
2200 
2201 
2202 
2203 inline
2204 bool System::have_vector (const std::string & vec_name) const
2205 {
2206  return (_vectors.count(vec_name));
2207 }
2208 
2209 
2210 
2211 inline
2212 unsigned int System::n_vectors () const
2213 {
2214  return cast_int<unsigned int>(_vectors.size());
2215 }
2216 
2217 inline
2218 unsigned int System::n_matrices () const
2219 {
2220  return 0;
2221 }
2222 
2223 inline
2225 {
2226  return _vectors.begin();
2227 }
2228 
2229 inline
2231 {
2232  return _vectors.begin();
2233 }
2234 
2235 inline
2237 {
2238  return _vectors.end();
2239 }
2240 
2241 inline
2243 {
2244  return _vectors.end();
2245 }
2246 
2247 inline
2249 {
2250  libmesh_not_implemented();
2251 }
2252 
2253 inline
2255 
2256 inline
2257 std::pair<unsigned int, Real>
2259 {
2260  libmesh_not_implemented();
2261 }
2262 
2263 inline
2264 std::pair<unsigned int, Real>
2266  const ParameterVector &)
2267 {
2268  libmesh_not_implemented();
2269 }
2270 
2271 inline
2272 std::pair<unsigned int, Real>
2274 {
2275  libmesh_not_implemented();
2276 }
2277 
2278 inline
2279 std::pair<unsigned int, Real>
2281  const ParameterVector &,
2282  const QoISet &)
2283 {
2284  libmesh_not_implemented();
2285 }
2286 
2287 inline
2288 void
2290  const ParameterVector &,
2291  SensitivityData &)
2292 {
2293  libmesh_not_implemented();
2294 }
2295 
2296 inline
2297 void
2299  const ParameterVector &,
2300  SensitivityData &)
2301 {
2302  libmesh_not_implemented();
2303 }
2304 
2305 inline
2306 void
2308  const ParameterVector &,
2309  SensitivityData &)
2310 {
2311  libmesh_not_implemented();
2312 }
2313 
2314 inline
2315 void
2317  const ParameterVector &,
2318  const ParameterVector &,
2319  SensitivityData &)
2320 {
2321  libmesh_not_implemented();
2322 }
2323 
2324 
2325 } // namespace libMesh
2326 
2327 #endif // LIBMESH_SYSTEM_H
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Definition: system.C:899
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2017
Manages the family, order, etc. parameters for a given FE.
Definition: fe_type.h:178
vectors_iterator vectors_end()
Definition: system.h:2236
dof_id_type n_constrained_dofs() const
Definition: system.C:150
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1901
Manages multiples systems of equations.
static unsigned int n_objects()
virtual void clear()
Definition: system.C:198
Assembly * _assemble_system_object
Definition: system.h:1820
bool _basic_system_only
Definition: system.h:1944
const unsigned int invalid_uint
Definition: libmesh.h:184
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2132
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1931
bool _is_initialized
Definition: system.h:1950
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1825
void set_adjoint_already_solved(bool setting)
Definition: system.h:378
void write_serialized_data(Xdr &io, const bool write_additional_data=true) const
Definition: system_io.C:1750
NumericVector< Number > & add_adjoint_solution(unsigned int i=0)
Definition: system.C:971
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.h:2298
Specifies parameters for parameter sensitivity calculations.
virtual void assemble_residual_derivatives(const ParameterVector &parameters)
Definition: system.h:2248
int vector_is_adjoint(const std::string &vec_name) const
Definition: system.C:910
void write_parallel_data(Xdr &io, const bool write_additional_data) const
Definition: system_io.C:1543
Used to specify quantities of interest in a simulation.
Definition: qoi_set.h:45
void read_parallel_data(Xdr &io, const bool read_additional_data)
Definition: system.h:1297
virtual void reinit()
Definition: system.C:380
virtual void disable_cache()
Definition: system.h:2254
Set dofs outside the subset to zero.
int extra_quadrature_order
Definition: system.h:1506
sys_type & system()
Definition: system.h:224
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
Definition: system.C:930
unsigned int add_variable(const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Definition: system.C:1095
bool has_variable(const std::string &var) const
Definition: system.C:1250
const unsigned int _sys_number
Definition: system.h:1885
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Definition: system.C:496
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1075
Constraint * _constrain_system_object
Definition: system.h:1831
virtual void assemble()
Definition: system.C:474
virtual void init_data()
Definition: system.C:255
void boundary_project_vector(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
void zero_variable(NumericVector< Number > &v, unsigned int var_num) const
Definition: system.C:1327
The base class for all geometric element types.
Definition: elem.h:86
uint8_t processor_id_type
Definition: id_types.h:99
UniquePtr< NumericVector< Number > > current_local_solution
Definition: system.h:1533
const class libmesh_nullptr_t libmesh_nullptr
bool vector_preservation(const std::string &vec_name) const
Definition: system.C:889
std::size_t read_serialized_vectors(Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
Definition: system.h:1275
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:749
virtual void user_initialization()
Definition: system.C:1942
std::vector< Variable > _variables
Definition: system.h:1890
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1065
void attach_QOI_derivative(void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints))
Definition: system.C:1907
IterBase * end
void read_legacy_data(Xdr &io, const bool read_additional_data=true)
Definition: system_io.C:309
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr) const
vectors_iterator vectors_begin()
Definition: system.h:2224
void attach_QOI_derivative_object(QOIDerivative &qoi_derivative)
Definition: system.C:1926
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.h:2289
const VariableGroup & variable_group(unsigned int vg) const
Definition: system.h:2122
std::size_t write_serialized_vectors(Xdr &io, const std::vector< const NumericVector< Number > * > &vectors) const
Definition: system_io.C:2352
NumericVector< Number > & add_weighted_sensitivity_solution()
Definition: system.C:950
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2162
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1836
System sys_type
Definition: system.h:219
void init()
Definition: system.C:230
unsigned int write_SCALAR_dofs(const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
Definition: system_io.C:2156
UniquePtr< DofMap > _dof_map
Definition: system.h:1863
const std::string & name() const
Definition: system.h:1996
NumericVector< Number > & get_weighted_sensitivity_solution()
Definition: system.C:957
unsigned int first_scalar_number() const
Definition: variable.h:113
std::string get_info() const
Definition: system.C:1682
bool adjoint_already_solved
Definition: system.h:1982
Base class for Mesh.
Definition: mesh_base.h:67
virtual void prolong_vectors()
Definition: system.C:370
virtual void user_QOI(const QoISet &qoi_indices)
Definition: system.C:1984
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
void attach_QOI_function(void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
Definition: system.C:1871
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1857
void remove_vector(const std::string &vec_name)
Definition: system.C:714
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:1003
virtual void qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.C:510
virtual void qoi_parameter_hessian(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &hessian)
Definition: system.h:2307
void attach_constraint_object(Constraint &constrain)
Definition: system.C:1855
Manages the degrees of freedom (DOFs) in a simulation.
Definition: dof_map.h:167
const NumericVector< Number > * request_vector(const std::string &vec_name) const
Definition: system.C:730
std::size_t read_serialized_blocked_dof_objects(const dof_id_type n_objects, const iterator_type begin, const iterator_type end, const InValType dummy, Xdr &io, const std::vector< NumericVector< Number > * > &vecs, const unsigned int var_to_read=libMesh::invalid_uint) const
Definition: system_io.C:837
unsigned short int variable_number(const std::string &var) const
Definition: system.C:1257
void attach_init_object(Initialization &init)
Definition: system.C:1785
void set_basic_system_only()
Definition: system.h:2076
void update_global_solution(std::vector< Number > &global_soln) const
Definition: system.C:657
unsigned int n_variable_groups() const
Definition: system.h:2092
const MeshBase & get_mesh() const
Definition: system.h:2012
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:676
void write_header(Xdr &io, const std::string &version, const bool write_additional_data) const
Definition: system_io.C:1335
A variable which is solved for in a System of equations.
Definition: variable.h:49
const DofMap & get_dof_map() const
Definition: system.h:2028
unsigned int n_components() const
Definition: system.h:2100
virtual void qoi_parameter_hessian_vector_product(const QoISet &qoi_indices, const ParameterVector &parameters, const ParameterVector &vector, SensitivityData &product)
Definition: system.h:2316
Holds completed parameter sensitivity calculations.
dof_id_type numeric_index_type
Definition: id_types.h:92
void read_header(Xdr &io, const std::string &version, const bool read_header=true, const bool read_additional_data=true, const bool read_legacy_format=false)
Definition: system_io.C:115
bool have_vector(const std::string &vec_name) const
Definition: system.h:2204
std::vector< Number > qoi
Definition: system.h:1551
void deactivate()
Definition: system.h:2060
const Variable & variable(unsigned int var) const
Definition: system.h:2112
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Definition: system.h:1255
std::vector< VariableGroup > _variable_groups
Definition: system.h:1895
bool is_initialized()
Definition: system.h:2068
bool use_fixed_solution
Definition: system.h:1491
void attach_assemble_function(void fptr(EquationSystems &es, const std::string &name))
Definition: system.C:1801
void attach_constraint_function(void fptr(EquationSystems &es, const std::string &name))
Definition: system.C:1836
bool & hide_output()
Definition: system.h:1655
numeric_index_type read_serialized_vector(Xdr &io, NumericVector< Number > *vec)
Definition: system_io.C:1204
NumberVectorValue Gradient
QOI * _qoi_evaluate_object
Definition: system.h:1843
virtual std::pair< unsigned int, Real > sensitivity_solve(const ParameterVector &parameters)
Definition: system.h:2258
Initialization * _init_system_object
Definition: system.h:1809
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet())
Definition: system.h:2273
System & operator=(const System &)
Definition: system.C:110
bool active() const
Definition: system.h:2044
bool _hide_output
Definition: system.h:1988
unsigned int _additional_data_written
Definition: system.h:1963
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2244
UniquePtr< NumericVector< Number > > solution
Definition: system.h:1521
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1803
virtual void restrict_vectors()
Definition: system.C:317
void attach_init_function(void fptr(EquationSystems &es, const std::string &name))
Definition: system.C:1766
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1926
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:788
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Definition: system_io.C:2211
void activate()
Definition: system.h:2052
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
Definition: system.C:1035
virtual void restrict_solve_to(const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO)
Definition: system.C:465
virtual void user_QOI_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Definition: system.C:1998
bool is_adjoint_already_solved() const
Definition: system.h:372
virtual void reinit_constraints()
Definition: system.C:409
virtual unsigned int n_matrices() const
Definition: system.h:2218
virtual void solve()
Definition: system.h:310
C++ interface for the XDR (eXternal Data Representation) format.
Definition: xdr_cxx.h:68
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2129
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=libmesh_nullptr) const
Definition: system.C:1393
EquationSystems & get_equation_systems()
Definition: system.h:717
void attach_assemble_object(Assembly &assemble)
Definition: system.C:1820
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:748
bool _solution_projection
Definition: system.h:1938
EquationSystems & _equation_systems
Definition: system.h:1869
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
Definition: system.C:1291
dof_id_type n_local_dofs() const
Definition: system.C:180
virtual bool compare(const System &other_system, const Real threshold, const bool verbose) const
Definition: system.C:526
void read_parallel_data(Xdr &io, const bool read_additional_data)
Definition: system_io.C:515
void attach_QOI_object(QOI &qoi)
Definition: system.C:1891
virtual void user_assembly()
Definition: system.C:1956
virtual std::string system_type() const
Definition: system.h:471
dof_id_type n_local_constrained_dofs() const
Definition: system.C:165
virtual void update()
Definition: system.C:420
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void set_vector_preservation(const std::string &vec_name, bool preserve)
Definition: system.C:881
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:187
bool _identify_variable_groups
Definition: system.h:1956
bool identify_variable_groups() const
Definition: system.h:2180
unsigned int number() const
Definition: system.h:2004
unsigned int n_components() const
Definition: variable.h:125
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1914
virtual std::pair< unsigned int, Real > weighted_sensitivity_solve(const ParameterVector &parameters, const ParameterVector &weights)
Definition: system.h:2265
unsigned int read_SCALAR_dofs(const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
Definition: system_io.C:1155
const std::string _sys_name
Definition: system.h:1880
bool & project_solution_on_reinit(void)
Definition: system.h:794
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=libmesh_nullptr)
Definition: system.C:1185
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:983
virtual void re_update()
Definition: system.C:441
std::map< std::string, bool > _vector_projections
Definition: system.h:1920
virtual ~QOI()
Definition: system.h:173
const EquationSystems & get_equation_systems() const
Definition: system.h:712
void boundary_project_solution(const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr)
virtual std::pair< unsigned int, Real > weighted_sensitivity_adjoint_solve(const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet())
Definition: system.h:2280
std::size_t read_serialized_vectors(Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
Definition: system_io.C:2258
unsigned int variable_scalar_number(const std::string &var, unsigned int component) const
Definition: system.h:2143
dof_id_type n_dofs() const
Definition: system.C:143
unsigned int n_vars() const
Definition: system.h:2084
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
virtual void user_constrain()
Definition: system.C:1970
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet())
Definition: system.C:485
NumericVector< Number > & add_sensitivity_solution(unsigned int i=0)
Definition: system.C:920
std::size_t write_serialized_blocked_dof_objects(const std::vector< const NumericVector< Number > * > &vecs, const dof_id_type n_objects, const iterator_type begin, const iterator_type end, Xdr &io, const unsigned int var_to_write=libMesh::invalid_uint) const
Definition: system_io.C:1861
VectorValue< Number > NumberVectorValue
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1814
virtual ~System()
Definition: system.C:116
numeric_index_type read_serialized_vector(Xdr &io, NumericVector< Number > &vec)
Definition: system.h:1764
bool assemble_before_solve
Definition: system.h:1475
System(EquationSystems &es, const std::string &name, const unsigned int number)
Definition: system.C:57
void get_all_variable_numbers(std::vector< unsigned int > &all_variable_numbers) const
Definition: system.C:1272
A geometric point in (x,y,z) space.
Definition: point.h:38
MeshBase & _mesh
Definition: system.h:1875
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Definition: system_io.C:751
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Definition: system.C:1374
const std::string & vector_name(const unsigned int vec_num) const
Definition: system.C:846
dof_id_type n_active_dofs() const
Definition: system.h:2196
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:1015
std::vector< unsigned int > _written_var_indices
Definition: system.h:1975
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int n_vectors() const
Definition: system.h:2212
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1848
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1045