system.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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" // deprecated
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 #include <memory>
43 
44 namespace libMesh
45 {
46 
47 // Forward Declarations
48 class System;
49 class EquationSystems;
50 class MeshBase;
51 class Xdr;
52 class DofMap;
53 template <typename Output> class FunctionBase;
54 class Parameters;
55 class ParameterVector;
56 class Point;
57 class SensitivityData;
58 template <typename T> class NumericVector;
59 template <typename T> class SparseMatrix;
60 template <typename T> class VectorValue;
61 typedef VectorValue<Number> NumberVectorValue;
62 typedef NumberVectorValue Gradient;
63 class SystemSubset;
64 class FEType;
65 class SystemNorm;
66 
78 class System : public ReferenceCountedObject<System>,
79  public ParallelObject
80 {
81 public:
82 
87  System (EquationSystems & es,
88  const std::string & name,
89  const unsigned int number);
90 
98  {
99  public:
103  virtual ~Initialization () {}
104 
110  virtual void initialize () = 0;
111  };
112 
113 
114 
121  class Assembly
122  {
123  public:
127  virtual ~Assembly () {}
128 
134  virtual void assemble () = 0;
135  };
136 
137 
138 
146  {
147  public:
151  virtual ~Constraint () {}
152 
158  virtual void constrain () = 0;
159  };
160 
161 
162 
169  class QOI
170  {
171  public:
175  virtual ~QOI () {}
176 
182  virtual void qoi (const QoISet & qoi_indices) = 0;
183  };
184 
185 
186 
194  {
195  public:
199  virtual ~QOIDerivative () {}
200 
206  virtual void qoi_derivative (const QoISet & qoi_indices,
207  bool include_liftfunc,
208  bool apply_constraints) = 0;
209  };
210 
211 
212 
216  virtual ~System ();
217 
221  typedef System sys_type;
222 
226  sys_type & system () { return *this; }
227 
232  virtual void clear ();
233 
238  void init ();
239 
248  virtual void reinit ();
249 
253  virtual void reinit_constraints ();
254 
258  bool is_initialized();
259 
264  virtual void update ();
265 
272  virtual void assemble ();
273 
278  virtual void assemble_qoi (const QoISet & qoi_indices = QoISet());
279 
284  virtual void assemble_qoi_derivative (const QoISet & qoi_indices = QoISet(),
285  bool include_liftfunc = true,
286  bool apply_constraints = true);
287 
299  virtual void assemble_residual_derivatives (const ParameterVector & parameters);
300 
306  virtual void restrict_solve_to (const SystemSubset * subset,
307  const SubsetSolveMode subset_solve_mode=SUBSET_ZERO);
308 
312  virtual void solve () {}
313 
323  virtual std::pair<unsigned int, Real>
324  sensitivity_solve (const ParameterVector & parameters);
325 
336  virtual std::pair<unsigned int, Real>
337  weighted_sensitivity_solve (const ParameterVector & parameters,
338  const ParameterVector & weights);
339 
350  virtual std::pair<unsigned int, Real>
351  adjoint_solve (const QoISet & qoi_indices = QoISet());
352 
367  virtual std::pair<unsigned int, Real>
369  const ParameterVector & weights,
370  const QoISet & qoi_indices = QoISet());
375  { return adjoint_already_solved;}
376 
380  void set_adjoint_already_solved(bool setting)
381  { adjoint_already_solved = setting;}
382 
383 
401  virtual void qoi_parameter_sensitivity (const QoISet & qoi_indices,
402  const ParameterVector & parameters,
403  SensitivityData & sensitivities);
404 
410  virtual void adjoint_qoi_parameter_sensitivity (const QoISet & qoi_indices,
411  const ParameterVector & parameters,
412  SensitivityData & sensitivities);
413 
419  virtual void forward_qoi_parameter_sensitivity (const QoISet & qoi_indices,
420  const ParameterVector & parameters,
421  SensitivityData & sensitivities);
422 
433  virtual void qoi_parameter_hessian(const QoISet & qoi_indices,
434  const ParameterVector & parameters,
435  SensitivityData & hessian);
436 
449  virtual void qoi_parameter_hessian_vector_product(const QoISet & qoi_indices,
450  const ParameterVector & parameters,
451  const ParameterVector & vector,
452  SensitivityData & product);
453 
459  virtual bool compare (const System & other_system,
460  const Real threshold,
461  const bool verbose) const;
462 
466  const std::string & name () const;
467 
473  virtual std::string system_type () const { return "Basic"; }
474 
486 
498 
506  typedef Number (*ValueFunctionPointer)(const Point & p,
507  const Parameters & Parameters,
508  const std::string & sys_name,
509  const std::string & unknown_name);
510  typedef Gradient (*GradientFunctionPointer)(const Point & p,
511  const Parameters & parameters,
512  const std::string & sys_name,
513  const std::string & unknown_name);
516  const Parameters & parameters) const;
517 
531  void project_vector (NumericVector<Number> & new_vector,
534  int is_adjoint = -1) const;
535 
549  void project_vector (NumericVector<Number> & new_vector,
552  int is_adjoint = -1) const;
553 
567  const Parameters & parameters,
568  NumericVector<Number> & new_vector,
569  int is_adjoint = -1) const;
570 
585  void boundary_project_solution (const std::set<boundary_id_type> & b,
586  const std::vector<unsigned int> & variables,
589 
602  void boundary_project_solution (const std::set<boundary_id_type> & b,
603  const std::vector<unsigned int> & variables,
606  const Parameters & parameters);
607 
625  void boundary_project_vector (const std::set<boundary_id_type> & b,
626  const std::vector<unsigned int> & variables,
627  NumericVector<Number> & new_vector,
630  int is_adjoint = -1) const;
631 
647  void boundary_project_vector (const std::set<boundary_id_type> & b,
648  const std::vector<unsigned int> & variables,
651  const Parameters & parameters,
652  NumericVector<Number> & new_vector,
653  int is_adjoint = -1) const;
654 
658  unsigned int number () const;
659 
665  void update_global_solution (std::vector<Number> & global_soln) const;
666 
672  void update_global_solution (std::vector<Number> & global_soln,
673  const processor_id_type dest_proc) const;
674 
678  const MeshBase & get_mesh() const;
679 
683  MeshBase & get_mesh();
684 
688  const DofMap & get_dof_map() const;
689 
693  DofMap & get_dof_map();
694 
699 
704 
709  bool active () const;
710 
714  void activate ();
715 
719  void deactivate ();
720 
729  void set_basic_system_only ();
730 
734  typedef std::map<std::string, NumericVector<Number> *>::iterator vectors_iterator;
735  typedef std::map<std::string, NumericVector<Number> *>::const_iterator const_vectors_iterator;
736 
740  vectors_iterator vectors_begin ();
741 
745  const_vectors_iterator vectors_begin () const;
746 
750  vectors_iterator vectors_end ();
751 
755  const_vectors_iterator vectors_end () const;
756 
766  NumericVector<Number> & add_vector (const std::string & vec_name,
767  const bool projections=true,
768  const ParallelType type = PARALLEL);
769 
773  void remove_vector(const std::string & vec_name);
774 
781  { return _solution_projection; }
782 
787  bool have_vector (const std::string & vec_name) const;
788 
793  const NumericVector<Number> * request_vector (const std::string & vec_name) const;
794 
799  NumericVector<Number> * request_vector (const std::string & vec_name);
800 
806  const NumericVector<Number> * request_vector (const unsigned int vec_num) const;
807 
813  NumericVector<Number> * request_vector (const unsigned int vec_num);
814 
820  const NumericVector<Number> & get_vector (const std::string & vec_name) const;
821 
827  NumericVector<Number> & get_vector (const std::string & vec_name);
828 
834  const NumericVector<Number> & get_vector (const unsigned int vec_num) const;
835 
841  NumericVector<Number> & get_vector (const unsigned int vec_num);
842 
847  const std::string & vector_name (const unsigned int vec_num) const;
848 
852  const std::string & vector_name (const NumericVector<Number> & vec_reference) const;
853 
864  void set_vector_as_adjoint (const std::string & vec_name, int qoi_num);
865 
871  int vector_is_adjoint (const std::string & vec_name) const;
872 
878  void set_vector_preservation (const std::string & vec_name, bool preserve);
879 
885  bool vector_preservation (const std::string & vec_name) const;
886 
892  NumericVector<Number> & add_adjoint_solution(unsigned int i=0);
893 
898  NumericVector<Number> & get_adjoint_solution(unsigned int i=0);
899 
904  const NumericVector<Number> & get_adjoint_solution(unsigned int i=0) const;
905 
912 
918 
923  const NumericVector<Number> & get_sensitivity_solution(unsigned int i=0) const;
924 
932 
939 
946 
953 
959 
965 
971  NumericVector<Number> & add_adjoint_rhs(unsigned int i=0);
972 
979  NumericVector<Number> & get_adjoint_rhs(unsigned int i=0);
980 
985  const NumericVector<Number> & get_adjoint_rhs(unsigned int i=0) const;
986 
992  NumericVector<Number> & add_sensitivity_rhs(unsigned int i=0);
993 
1003  NumericVector<Number> & get_sensitivity_rhs(unsigned int i=0);
1004 
1009  const NumericVector<Number> & get_sensitivity_rhs(unsigned int i=0) const;
1010 
1016  unsigned int n_vectors () const;
1017 
1024  virtual unsigned int n_matrices () const;
1025 
1029  unsigned int n_vars() const;
1030 
1034  unsigned int n_variable_groups() const;
1035 
1041  unsigned int n_components() const;
1042 
1046  dof_id_type n_dofs() const;
1047 
1052  dof_id_type n_active_dofs() const;
1053 
1059 
1065 
1070  dof_id_type n_local_dofs() const;
1071 
1078  unsigned int add_variable (const std::string & var,
1079  const FEType & type,
1080  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1081 
1087  unsigned int add_variable (const std::string & var,
1088  const Order order = FIRST,
1089  const FEFamily = LAGRANGE,
1090  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1091 
1098  unsigned int add_variables (const std::vector<std::string> & vars,
1099  const FEType & type,
1100  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1101 
1107  unsigned int add_variables (const std::vector<std::string> & vars,
1108  const Order order = FIRST,
1109  const FEFamily = LAGRANGE,
1110  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1111 
1115  const Variable & variable (unsigned int var) const;
1116 
1120  const VariableGroup & variable_group (unsigned int vg) const;
1121 
1125  bool has_variable(const std::string & var) const;
1126 
1130  const std::string & variable_name(const unsigned int i) const;
1131 
1136  unsigned short int variable_number (const std::string & var) const;
1137 
1142  void get_all_variable_numbers(std::vector<unsigned int> & all_variable_numbers) const;
1143 
1154  unsigned int variable_scalar_number (const std::string & var,
1155  unsigned int component) const;
1156 
1167  unsigned int variable_scalar_number (unsigned int var_num,
1168  unsigned int component) const;
1169 
1170 
1174  const FEType & variable_type (const unsigned int i) const;
1175 
1179  const FEType & variable_type (const std::string & var) const;
1180 
1185  bool identify_variable_groups () const;
1186 
1190  void identify_variable_groups (const bool);
1191 
1197  unsigned int var,
1198  FEMNormType norm_type,
1199  std::set<unsigned int> * skip_dimensions=libmesh_nullptr) const;
1200 
1206  const SystemNorm & norm,
1207  std::set<unsigned int> * skip_dimensions=libmesh_nullptr) const;
1208 
1212  void read_header (Xdr & io,
1213  const std::string & version,
1214  const bool read_header=true,
1215  const bool read_additional_data=true,
1216  const bool read_legacy_format=false);
1217 
1225 #ifdef LIBMESH_ENABLE_DEPRECATED
1226  void read_legacy_data (Xdr & io,
1227  const bool read_additional_data=true);
1228 #endif
1229 
1234  template <typename ValType>
1235  void read_serialized_data (Xdr & io,
1236  const bool read_additional_data=true);
1244  const bool read_additional_data=true)
1245  { read_serialized_data<Number>(io, read_additional_data); }
1246 
1252  template <typename InValType>
1253  std::size_t read_serialized_vectors (Xdr & io,
1254  const std::vector<NumericVector<Number> *> & vectors) const;
1255 
1263  std::size_t read_serialized_vectors (Xdr & io,
1264  const std::vector<NumericVector<Number> *> & vectors) const
1265  { return read_serialized_vectors<Number>(io, vectors); }
1266 
1273  template <typename InValType>
1274  void read_parallel_data (Xdr & io,
1275  const bool read_additional_data);
1276 
1286  const bool read_additional_data)
1287  { read_parallel_data<Number>(io, read_additional_data); }
1288 
1292  void write_header (Xdr & io,
1293  const std::string & version,
1294  const bool write_additional_data) const;
1295 
1300  void write_serialized_data (Xdr & io,
1301  const bool write_additional_data = true) const;
1302 
1308  std::size_t write_serialized_vectors (Xdr & io,
1309  const std::vector<const NumericVector<Number> *> & vectors) const;
1310 
1317  void write_parallel_data (Xdr & io,
1318  const bool write_additional_data) const;
1319 
1324  std::string get_info () const;
1325 
1329  void attach_init_function (void fptr(EquationSystems & es,
1330  const std::string & name));
1331 
1337  void attach_init_object (Initialization & init);
1338 
1343  void attach_assemble_function (void fptr(EquationSystems & es,
1344  const std::string & name));
1345 
1350  void attach_assemble_object (Assembly & assemble);
1351 
1355  void attach_constraint_function (void fptr(EquationSystems & es,
1356  const std::string & name));
1357 
1361  void attach_constraint_object (Constraint & constrain);
1362 
1367  void attach_QOI_function (void fptr(EquationSystems & es,
1368  const std::string & name,
1369  const QoISet & qoi_indices));
1370 
1375  void attach_QOI_object (QOI & qoi);
1376 
1382  void attach_QOI_derivative (void fptr(EquationSystems & es,
1383  const std::string & name,
1384  const QoISet & qoi_indices,
1385  bool include_liftfunc,
1386  bool apply_constraints));
1387 
1393  void attach_QOI_derivative_object (QOIDerivative & qoi_derivative);
1394 
1399  virtual void user_initialization ();
1400 
1405  virtual void user_assembly ();
1406 
1411  virtual void user_constrain ();
1412 
1417  virtual void user_QOI (const QoISet & qoi_indices);
1418 
1423  virtual void user_QOI_derivative (const QoISet & qoi_indices = QoISet(),
1424  bool include_liftfunc = true,
1425  bool apply_constraints = true);
1426 
1432  virtual void re_update ();
1433 
1437  virtual void restrict_vectors ();
1438 
1442  virtual void prolong_vectors ();
1443 
1464 
1469  virtual void disable_cache ();
1470 
1480 
1495 
1496 
1497  //--------------------------------------------------
1498  // The solution and solution access members
1499 
1504  Number current_solution (const dof_id_type global_dof_number) const;
1505 
1509  std::unique_ptr<NumericVector<Number>> solution;
1510 
1521  std::unique_ptr<NumericVector<Number>> current_local_solution;
1522 
1532 
1539  std::vector<Number> qoi;
1540 
1561  Number point_value(unsigned int var, const Point & p,
1562  const bool insist_on_success = true) const;
1563 
1571  Number point_value(unsigned int var, const Point & p, const Elem & e) const;
1572 
1579  Number point_value(unsigned int var, const Point & p, const Elem * e) const;
1580 
1585  Gradient point_gradient(unsigned int var, const Point & p,
1586  const bool insist_on_success = true) const;
1587 
1592  Gradient point_gradient(unsigned int var, const Point & p, const Elem & e) const;
1593 
1600  Gradient point_gradient(unsigned int var, const Point & p, const Elem * e) const;
1601 
1606  Tensor point_hessian(unsigned int var, const Point & p,
1607  const bool insist_on_success = true) const;
1608 
1614  Tensor point_hessian(unsigned int var, const Point & p, const Elem & e) const;
1615 
1622  Tensor point_hessian(unsigned int var, const Point & p, const Elem * e) const;
1623 
1628  void local_dof_indices (const unsigned int var,
1629  std::set<dof_id_type> & var_indices) const;
1630 
1635  void zero_variable (NumericVector<Number> & v, unsigned int var_num) const;
1636 
1637 
1643  bool & hide_output() { return _hide_output; }
1644 
1645 #ifdef LIBMESH_HAVE_METAPHYSICL
1646 
1656  void projection_matrix (SparseMatrix<Number> & proj_mat) const;
1657 #endif // LIBMESH_HAVE_METAPHYSICL
1658 
1659 protected:
1660 
1667  virtual void init_data ();
1668 
1677  int is_adjoint = -1) const;
1678 
1687  void project_vector (const NumericVector<Number> &,
1689  int is_adjoint = -1) const;
1690 
1691 private:
1698  System (const System &);
1699 
1706  System & operator=(const System &);
1707 
1713  unsigned int var,
1714  FEMNormType norm_type) const;
1715 
1725  template <typename iterator_type, typename InValType>
1727  const iterator_type begin,
1728  const iterator_type end,
1729  const InValType dummy,
1730  Xdr & io,
1731  const std::vector<NumericVector<Number> *> & vecs,
1732  const unsigned int var_to_read=libMesh::invalid_uint) const;
1733 
1742  unsigned int read_SCALAR_dofs (const unsigned int var,
1743  Xdr & io,
1744  NumericVector<Number> * vec) const;
1745 
1754  template <typename InValType>
1756  NumericVector<Number> * vec);
1757 
1767  NumericVector<Number> & vec)
1768  { return read_serialized_vector<Number>(io, &vec); }
1769 
1776  template <typename iterator_type>
1777  std::size_t write_serialized_blocked_dof_objects (const std::vector<const NumericVector<Number> *> & vecs,
1778  const dof_id_type n_objects,
1779  const iterator_type begin,
1780  const iterator_type end,
1781  Xdr & io,
1782  const unsigned int var_to_write=libMesh::invalid_uint) const;
1783 
1789  unsigned int write_SCALAR_dofs (const NumericVector<Number> & vec,
1790  const unsigned int var,
1791  Xdr & io) const;
1792 
1800  const NumericVector<Number> & vec) const;
1801 
1806  const std::string & name);
1807 
1812 
1817  const std::string & name);
1818 
1823 
1828  const std::string & name);
1829 
1834 
1839  const std::string & name,
1840  const QoISet & qoi_indices);
1841 
1846 
1851  const std::string & name,
1852  const QoISet & qoi_indices,
1853  bool include_liftfunc,
1854  bool apply_constraints);
1855 
1860 
1865  std::unique_ptr<DofMap> _dof_map;
1866 
1872 
1878 
1882  const std::string _sys_name;
1883 
1887  const unsigned int _sys_number;
1888 
1892  std::vector<Variable> _variables;
1893 
1897  std::vector<VariableGroup> _variable_groups;
1898 
1903  std::map<std::string, unsigned short int> _variable_numbers;
1904 
1908  bool _active;
1909 
1916  std::map<std::string, NumericVector<Number> * > _vectors;
1917 
1922  std::map<std::string, bool> _vector_projections;
1923 
1928  std::map<std::string, int> _vector_is_adjoint;
1929 
1933  std::map<std::string, ParallelType> _vector_types;
1934 
1941 
1947 
1953 
1959 
1966 
1977  std::vector<unsigned int> _written_var_indices;
1978 
1985 
1991 };
1992 
1993 
1994 
1995 // ------------------------------------------------------------
1996 // System inline methods
1997 inline
1998 const std::string & System::name() const
1999 {
2000  return _sys_name;
2001 }
2002 
2003 
2004 
2005 inline
2006 unsigned int System::number() const
2007 {
2008  return _sys_number;
2009 }
2010 
2011 
2012 
2013 inline
2015 {
2016  return _mesh;
2017 }
2018 
2019 
2020 
2021 inline
2023 {
2024  return _mesh;
2025 }
2026 
2027 
2028 
2029 inline
2031 {
2032  return *_dof_map;
2033 }
2034 
2035 
2036 
2037 inline
2039 {
2040  return *_dof_map;
2041 }
2042 
2043 
2044 
2045 inline
2046 bool System::active() const
2047 {
2048  return _active;
2049 }
2050 
2051 
2052 
2053 inline
2055 {
2056  _active = true;
2057 }
2058 
2059 
2060 
2061 inline
2063 {
2064  _active = false;
2065 }
2066 
2067 
2068 
2069 inline
2071 {
2072  return _is_initialized;
2073 }
2074 
2075 
2076 
2077 inline
2079 {
2080  _basic_system_only = true;
2081 }
2082 
2083 
2084 
2085 inline
2086 unsigned int System::n_vars() const
2087 {
2088  return cast_int<unsigned int>(_variables.size());
2089 }
2090 
2091 
2092 
2093 inline
2094 unsigned int System::n_variable_groups() const
2095 {
2096  return cast_int<unsigned int>(_variable_groups.size());
2097 }
2098 
2099 
2100 
2101 inline
2102 unsigned int System::n_components() const
2103 {
2104  if (_variables.empty())
2105  return 0;
2106 
2107  const Variable & last = _variables.back();
2108  return last.first_scalar_number() + last.n_components();
2109 }
2110 
2111 
2112 
2113 inline
2114 const Variable & System::variable (const unsigned int i) const
2115 {
2116  libmesh_assert_less (i, _variables.size());
2117 
2118  return _variables[i];
2119 }
2120 
2121 
2122 
2123 inline
2124 const VariableGroup & System::variable_group (const unsigned int vg) const
2125 {
2126  libmesh_assert_less (vg, _variable_groups.size());
2127 
2128  return _variable_groups[vg];
2129 }
2130 
2131 
2132 
2133 inline
2134 const std::string & System::variable_name (const unsigned int i) const
2135 {
2136  libmesh_assert_less (i, _variables.size());
2137 
2138  return _variables[i].name();
2139 }
2140 
2141 
2142 
2143 inline
2144 unsigned int
2145 System::variable_scalar_number (const std::string & var,
2146  unsigned int component) const
2147 {
2148  return variable_scalar_number(this->variable_number(var), component);
2149 }
2150 
2151 
2152 
2153 inline
2154 unsigned int
2155 System::variable_scalar_number (unsigned int var_num,
2156  unsigned int component) const
2157 {
2158  return _variables[var_num].first_scalar_number() + component;
2159 }
2160 
2161 
2162 
2163 inline
2164 const FEType & System::variable_type (const unsigned int i) const
2165 {
2166  libmesh_assert_less (i, _variables.size());
2167 
2168  return _variables[i].type();
2169 }
2170 
2171 
2172 
2173 inline
2174 const FEType & System::variable_type (const std::string & var) const
2175 {
2176  return _variables[this->variable_number(var)].type();
2177 }
2178 
2179 
2180 
2181 inline
2183 {
2185 }
2186 
2187 
2188 
2189 inline
2191 {
2193 }
2194 
2195 
2196 
2197 inline
2199 {
2200  return this->n_dofs() - this->n_constrained_dofs();
2201 }
2202 
2203 
2204 
2205 inline
2206 bool System::have_vector (const std::string & vec_name) const
2207 {
2208  return (_vectors.count(vec_name));
2209 }
2210 
2211 
2212 
2213 inline
2214 unsigned int System::n_vectors () const
2215 {
2216  return cast_int<unsigned int>(_vectors.size());
2217 }
2218 
2219 inline
2220 unsigned int System::n_matrices () const
2221 {
2222  return 0;
2223 }
2224 
2225 inline
2227 {
2228  return _vectors.begin();
2229 }
2230 
2231 inline
2233 {
2234  return _vectors.begin();
2235 }
2236 
2237 inline
2239 {
2240  return _vectors.end();
2241 }
2242 
2243 inline
2245 {
2246  return _vectors.end();
2247 }
2248 
2249 inline
2251 {
2252  libmesh_not_implemented();
2253 }
2254 
2255 inline
2257 
2258 inline
2259 std::pair<unsigned int, Real>
2261 {
2262  libmesh_not_implemented();
2263 }
2264 
2265 inline
2266 std::pair<unsigned int, Real>
2268  const ParameterVector &)
2269 {
2270  libmesh_not_implemented();
2271 }
2272 
2273 inline
2274 std::pair<unsigned int, Real>
2276 {
2277  libmesh_not_implemented();
2278 }
2279 
2280 inline
2281 std::pair<unsigned int, Real>
2283  const ParameterVector &,
2284  const QoISet &)
2285 {
2286  libmesh_not_implemented();
2287 }
2288 
2289 inline
2290 void
2292  const ParameterVector &,
2293  SensitivityData &)
2294 {
2295  libmesh_not_implemented();
2296 }
2297 
2298 inline
2299 void
2301  const ParameterVector &,
2302  SensitivityData &)
2303 {
2304  libmesh_not_implemented();
2305 }
2306 
2307 inline
2308 void
2310  const ParameterVector &,
2311  SensitivityData &)
2312 {
2313  libmesh_not_implemented();
2314 }
2315 
2316 inline
2317 void
2319  const ParameterVector &,
2320  const ParameterVector &,
2321  SensitivityData &)
2322 {
2323  libmesh_not_implemented();
2324 }
2325 
2326 
2327 } // namespace libMesh
2328 
2329 #endif // LIBMESH_SYSTEM_H
void set_vector_as_adjoint(const std::string &vec_name, int qoi_num)
Definition: system.C:886
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:1980
Manages the family, order, etc. parameters for a given FE.
Definition: fe_type.h:179
vectors_iterator vectors_end()
Definition: system.h:2238
dof_id_type n_constrained_dofs() const
Definition: system.C:155
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1903
Manages multiples systems of equations.
static unsigned int n_objects()
virtual void clear()
Definition: system.C:203
void projection_matrix(SparseMatrix< Number > &proj_mat) const
Assembly * _assemble_system_object
Definition: system.h:1822
bool _basic_system_only
Definition: system.h:1946
const unsigned int invalid_uint
Definition: libmesh.h:184
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2134
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1933
bool _is_initialized
Definition: system.h:1952
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1827
void set_adjoint_already_solved(bool setting)
Definition: system.h:380
void write_serialized_data(Xdr &io, const bool write_additional_data=true) const
Definition: system_io.C:1728
NumericVector< Number > & add_adjoint_solution(unsigned int i=0)
Definition: system.C:958
virtual void forward_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.h:2300
Specifies parameters for parameter sensitivity calculations.
virtual void assemble_residual_derivatives(const ParameterVector &parameters)
Definition: system.h:2250
int vector_is_adjoint(const std::string &vec_name) const
Definition: system.C:897
void write_parallel_data(Xdr &io, const bool write_additional_data) const
Definition: system_io.C:1521
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:1285
virtual void reinit()
Definition: system.C:388
virtual void disable_cache()
Definition: system.h:2256
Set dofs outside the subset to zero.
int extra_quadrature_order
Definition: system.h:1494
sys_type & system()
Definition: system.h:226
NumericVector< Number > & get_sensitivity_solution(unsigned int i=0)
Definition: system.C:917
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:1082
bool has_variable(const std::string &var) const
Definition: system.C:1237
const unsigned int _sys_number
Definition: system.h:1887
virtual void assemble_qoi_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Definition: system.C:482
NumericVector< Number > & get_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1062
Constraint * _constrain_system_object
Definition: system.h:1833
virtual void assemble()
Definition: system.C:460
virtual void init_data()
Definition: system.C:260
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:1308
The base class for all geometric element types.
Definition: elem.h:90
uint8_t processor_id_type
Definition: id_types.h:99
const class libmesh_nullptr_t libmesh_nullptr
bool vector_preservation(const std::string &vec_name) const
Definition: system.C:876
std::unique_ptr< DofMap > _dof_map
Definition: system.h:1865
std::size_t read_serialized_vectors(Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
Definition: system.h:1263
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:735
virtual void user_initialization()
Definition: system.C:1905
std::vector< Variable > _variables
Definition: system.h:1892
NumericVector< Number > & add_sensitivity_rhs(unsigned int i=0)
Definition: system.C:1052
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:1870
IterBase * end
void read_legacy_data(Xdr &io, const bool read_additional_data=true)
Definition: system_io.C:310
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr) const
vectors_iterator vectors_begin()
Definition: system.h:2226
void attach_QOI_derivative_object(QOIDerivative &qoi_derivative)
Definition: system.C:1889
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.h:2291
const VariableGroup & variable_group(unsigned int vg) const
Definition: system.h:2124
std::size_t write_serialized_vectors(Xdr &io, const std::vector< const NumericVector< Number > * > &vectors) const
Definition: system_io.C:2330
NumericVector< Number > & add_weighted_sensitivity_solution()
Definition: system.C:937
const FEType & variable_type(const unsigned int i) const
Definition: system.h:2164
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1838
System sys_type
Definition: system.h:221
void init()
Definition: system.C:235
unsigned int write_SCALAR_dofs(const NumericVector< Number > &vec, const unsigned int var, Xdr &io) const
Definition: system_io.C:2134
const std::string & name() const
Definition: system.h:1998
NumericVector< Number > & get_weighted_sensitivity_solution()
Definition: system.C:944
unsigned int first_scalar_number() const
Definition: variable.h:113
std::string get_info() const
Definition: system.C:1645
bool adjoint_already_solved
Definition: system.h:1984
Base class for Mesh.
Definition: mesh_base.h:69
virtual void prolong_vectors()
Definition: system.C:378
virtual void user_QOI(const QoISet &qoi_indices)
Definition: system.C:1947
void attach_QOI_function(void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices))
Definition: system.C:1834
QOIDerivative * _qoi_evaluate_derivative_object
Definition: system.h:1859
void remove_vector(const std::string &vec_name)
Definition: system.C:700
NumericVector< Number > & add_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:990
virtual void qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &sensitivities)
Definition: system.C:496
virtual void qoi_parameter_hessian(const QoISet &qoi_indices, const ParameterVector &parameters, SensitivityData &hessian)
Definition: system.h:2309
void attach_constraint_object(Constraint &constrain)
Definition: system.C:1818
Manages the degrees of freedom (DOFs) in a simulation.
Definition: dof_map.h:168
const NumericVector< Number > * request_vector(const std::string &vec_name) const
Definition: system.C:717
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:815
unsigned short int variable_number(const std::string &var) const
Definition: system.C:1244
void attach_init_object(Initialization &init)
Definition: system.C:1748
void set_basic_system_only()
Definition: system.h:2078
void update_global_solution(std::vector< Number > &global_soln) const
Definition: system.C:643
unsigned int n_variable_groups() const
Definition: system.h:2094
const MeshBase & get_mesh() const
Definition: system.h:2014
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Definition: system.C:662
void write_header(Xdr &io, const std::string &version, const bool write_additional_data) const
Definition: system_io.C:1313
A variable which is solved for in a System of equations.
Definition: variable.h:49
const DofMap & get_dof_map() const
Definition: system.h:2030
unsigned int n_components() const
Definition: system.h:2102
virtual void qoi_parameter_hessian_vector_product(const QoISet &qoi_indices, const ParameterVector &parameters, const ParameterVector &vector, SensitivityData &product)
Definition: system.h:2318
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:2206
std::vector< Number > qoi
Definition: system.h:1539
void deactivate()
Definition: system.h:2062
const Variable & variable(unsigned int var) const
Definition: system.h:2114
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Definition: system.h:1243
std::vector< VariableGroup > _variable_groups
Definition: system.h:1897
bool is_initialized()
Definition: system.h:2070
bool use_fixed_solution
Definition: system.h:1479
void attach_assemble_function(void fptr(EquationSystems &es, const std::string &name))
Definition: system.C:1764
void attach_constraint_function(void fptr(EquationSystems &es, const std::string &name))
Definition: system.C:1799
bool & hide_output()
Definition: system.h:1643
numeric_index_type read_serialized_vector(Xdr &io, NumericVector< Number > *vec)
Definition: system_io.C:1182
NumberVectorValue Gradient
std::unique_ptr< NumericVector< Number > > solution
Definition: system.h:1509
QOI * _qoi_evaluate_object
Definition: system.h:1845
virtual std::pair< unsigned int, Real > sensitivity_solve(const ParameterVector &parameters)
Definition: system.h:2260
Initialization * _init_system_object
Definition: system.h:1811
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet())
Definition: system.h:2275
System & operator=(const System &)
Definition: system.C:112
bool active() const
Definition: system.h:2046
bool _hide_output
Definition: system.h:1990
unsigned int _additional_data_written
Definition: system.h:1965
Tensor point_hessian(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2207
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1805
virtual void restrict_vectors()
Definition: system.C:322
void attach_init_function(void fptr(EquationSystems &es, const std::string &name))
Definition: system.C:1729
std::map< std::string, int > _vector_is_adjoint
Definition: system.h:1928
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:775
dof_id_type write_serialized_vector(Xdr &io, const NumericVector< Number > &vec) const
Definition: system_io.C:2189
void activate()
Definition: system.h:2054
NumericVector< Number > & add_adjoint_rhs(unsigned int i=0)
Definition: system.C:1022
virtual void restrict_solve_to(const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO)
Definition: system.C:451
virtual void user_QOI_derivative(const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true)
Definition: system.C:1961
bool is_adjoint_already_solved() const
Definition: system.h:374
virtual void reinit_constraints()
Definition: system.C:395
virtual unsigned int n_matrices() const
Definition: system.h:2220
virtual void solve()
Definition: system.h:312
C++ interface for the XDR (eXternal Data Representation) format.
Definition: xdr_cxx.h:69
Gradient point_gradient(unsigned int var, const Point &p, const bool insist_on_success=true) const
Definition: system.C:2087
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:1364
EquationSystems & get_equation_systems()
Definition: system.h:703
void attach_assemble_object(Assembly &assemble)
Definition: system.C:1783
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:734
bool _solution_projection
Definition: system.h:1940
EquationSystems & _equation_systems
Definition: system.h:1871
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
Definition: system.C:1278
dof_id_type n_local_dofs() const
Definition: system.C:185
virtual bool compare(const System &other_system, const Real threshold, const bool verbose) const
Definition: system.C:512
void read_parallel_data(Xdr &io, const bool read_additional_data)
Definition: system_io.C:493
void attach_QOI_object(QOI &qoi)
Definition: system.C:1854
virtual void user_assembly()
Definition: system.C:1919
virtual std::string system_type() const
Definition: system.h:473
dof_id_type n_local_constrained_dofs() const
Definition: system.C:170
virtual void update()
Definition: system.C:406
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:868
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:192
Number(* ValueFunctionPointer)(const Point &p, const Parameters &Parameters, const std::string &sys_name, const std::string &unknown_name)
Definition: system.h:506
bool _identify_variable_groups
Definition: system.h:1958
bool identify_variable_groups() const
Definition: system.h:2182
unsigned int number() const
Definition: system.h:2006
unsigned int n_components() const
Definition: variable.h:125
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1916
virtual std::pair< unsigned int, Real > weighted_sensitivity_solve(const ParameterVector &parameters, const ParameterVector &weights)
Definition: system.h:2267
unsigned int read_SCALAR_dofs(const unsigned int var, Xdr &io, NumericVector< Number > *vec) const
Definition: system_io.C:1133
const std::string _sys_name
Definition: system.h:1882
bool & project_solution_on_reinit(void)
Definition: system.h:780
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:1172
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:970
virtual void re_update()
Definition: system.C:427
std::map< std::string, bool > _vector_projections
Definition: system.h:1922
virtual ~QOI()
Definition: system.h:175
const EquationSystems & get_equation_systems() const
Definition: system.h:698
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)
std::unique_ptr< NumericVector< Number > > current_local_solution
Definition: system.h:1521
virtual std::pair< unsigned int, Real > weighted_sensitivity_adjoint_solve(const ParameterVector &parameters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet())
Definition: system.h:2282
std::size_t read_serialized_vectors(Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const
Definition: system_io.C:2236
unsigned int variable_scalar_number(const std::string &var, unsigned int component) const
Definition: system.h:2145
dof_id_type n_dofs() const
Definition: system.C:148
unsigned int n_vars() const
Definition: system.h:2086
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
Gradient(* GradientFunctionPointer)(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name)
Definition: system.h:510
virtual void user_constrain()
Definition: system.C:1933
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet())
Definition: system.C:471
NumericVector< Number > & add_sensitivity_solution(unsigned int i=0)
Definition: system.C:907
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:1839
VectorValue< Number > NumberVectorValue
void(* _assemble_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1816
virtual ~System()
Definition: system.C:118
numeric_index_type read_serialized_vector(Xdr &io, NumericVector< Number > &vec)
Definition: system.h:1766
bool assemble_before_solve
Definition: system.h:1463
System(EquationSystems &es, const std::string &name, const unsigned int number)
Definition: system.C:59
void get_all_variable_numbers(std::vector< unsigned int > &all_variable_numbers) const
Definition: system.C:1259
A geometric point in (x,y,z) space.
Definition: point.h:38
MeshBase & _mesh
Definition: system.h:1877
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Definition: system_io.C:729
Real discrete_var_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const
Definition: system.C:1345
const std::string & vector_name(const unsigned int vec_num) const
Definition: system.C:833
dof_id_type n_active_dofs() const
Definition: system.h:2198
NumericVector< Number > & get_weighted_sensitivity_adjoint_solution(unsigned int i=0)
Definition: system.C:1002
std::vector< unsigned int > _written_var_indices
Definition: system.h:1977
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int n_vectors() const
Definition: system.h:2214
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1850
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1032