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 
77 class System : public ReferenceCountedObject<System>,
78  public ParallelObject
79 {
80 public:
81 
86  System (EquationSystems & es,
87  const std::string & name,
88  const unsigned int number);
89 
97  {
98  public:
102  virtual ~Initialization () {}
103 
109  virtual void initialize () = 0;
110  };
111 
112 
113 
120  class Assembly
121  {
122  public:
126  virtual ~Assembly () {}
127 
133  virtual void assemble () = 0;
134  };
135 
136 
137 
145  {
146  public:
150  virtual ~Constraint () {}
151 
157  virtual void constrain () = 0;
158  };
159 
160 
161 
168  class QOI
169  {
170  public:
174  virtual ~QOI () {}
175 
181  virtual void qoi (const QoISet & qoi_indices) = 0;
182  };
183 
184 
185 
193  {
194  public:
198  virtual ~QOIDerivative () {}
199 
205  virtual void qoi_derivative (const QoISet & qoi_indices,
206  bool include_liftfunc,
207  bool apply_constraints) = 0;
208  };
209 
210 
211 
215  virtual ~System ();
216 
220  typedef System sys_type;
221 
225  sys_type & system () { return *this; }
226 
231  virtual void clear ();
232 
237  void init ();
238 
245  virtual void reinit ();
246 
250  virtual void reinit_constraints ();
251 
255  bool is_initialized();
256 
261  virtual void update ();
262 
269  virtual void assemble ();
270 
275  virtual void assemble_qoi (const QoISet & qoi_indices = QoISet());
276 
281  virtual void assemble_qoi_derivative (const QoISet & qoi_indices = QoISet(),
282  bool include_liftfunc = true,
283  bool apply_constraints = true);
284 
296  virtual void assemble_residual_derivatives (const ParameterVector & parameters);
297 
303  virtual void restrict_solve_to (const SystemSubset * subset,
304  const SubsetSolveMode subset_solve_mode=SUBSET_ZERO);
305 
309  virtual void solve () {}
310 
320  virtual std::pair<unsigned int, Real>
321  sensitivity_solve (const ParameterVector & parameters);
322 
333  virtual std::pair<unsigned int, Real>
334  weighted_sensitivity_solve (const ParameterVector & parameters,
335  const ParameterVector & weights);
336 
347  virtual std::pair<unsigned int, Real>
348  adjoint_solve (const QoISet & qoi_indices = QoISet());
349 
364  virtual std::pair<unsigned int, Real>
366  const ParameterVector & weights,
367  const QoISet & qoi_indices = QoISet());
372  { return adjoint_already_solved;}
373 
377  void set_adjoint_already_solved(bool setting)
378  { adjoint_already_solved = setting;}
379 
380 
398  virtual void qoi_parameter_sensitivity (const QoISet & qoi_indices,
399  const ParameterVector & parameters,
400  SensitivityData & sensitivities);
401 
407  virtual void adjoint_qoi_parameter_sensitivity (const QoISet & qoi_indices,
408  const ParameterVector & parameters,
409  SensitivityData & sensitivities);
410 
416  virtual void forward_qoi_parameter_sensitivity (const QoISet & qoi_indices,
417  const ParameterVector & parameters,
418  SensitivityData & sensitivities);
419 
430  virtual void qoi_parameter_hessian(const QoISet & qoi_indices,
431  const ParameterVector & parameters,
432  SensitivityData & hessian);
433 
446  virtual void qoi_parameter_hessian_vector_product(const QoISet & qoi_indices,
447  const ParameterVector & parameters,
448  const ParameterVector & vector,
449  SensitivityData & product);
450 
456  virtual bool compare (const System & other_system,
457  const Real threshold,
458  const bool verbose) const;
459 
463  const std::string & name () const;
464 
470  virtual std::string system_type () const { return "Basic"; }
471 
483 
495 
503  void project_solution (Number fptr(const Point & p,
504  const Parameters & parameters,
505  const std::string & sys_name,
506  const std::string & unknown_name),
507  Gradient gptr(const Point & p,
508  const Parameters & parameters,
509  const std::string & sys_name,
510  const std::string & unknown_name),
511  const Parameters & parameters) const;
512 
526  void project_vector (NumericVector<Number> & new_vector,
529  int is_adjoint = -1) const;
530 
544  void project_vector (NumericVector<Number> & new_vector,
547  int is_adjoint = -1) const;
548 
560  void project_vector (Number fptr(const Point & p,
561  const Parameters & parameters,
562  const std::string & sys_name,
563  const std::string & unknown_name),
564  Gradient gptr(const Point & p,
565  const Parameters & parameters,
566  const std::string & sys_name,
567  const std::string & unknown_name),
568  const Parameters & parameters,
569  NumericVector<Number> & new_vector,
570  int is_adjoint = -1) const;
571 
586  void boundary_project_solution (const std::set<boundary_id_type> & b,
587  const std::vector<unsigned int> & variables,
590 
603  void boundary_project_solution (const std::set<boundary_id_type> & b,
604  const std::vector<unsigned int> & variables,
605  Number fptr(const Point & p,
606  const Parameters & parameters,
607  const std::string & sys_name,
608  const std::string & unknown_name),
609  Gradient gptr(const Point & p,
610  const Parameters & parameters,
611  const std::string & sys_name,
612  const std::string & unknown_name),
613  const Parameters & parameters);
614 
632  void boundary_project_vector (const std::set<boundary_id_type> & b,
633  const std::vector<unsigned int> & variables,
634  NumericVector<Number> & new_vector,
637  int is_adjoint = -1) const;
638 
654  void boundary_project_vector (const std::set<boundary_id_type> & b,
655  const std::vector<unsigned int> & variables,
656  Number fptr(const Point & p,
657  const Parameters & parameters,
658  const std::string & sys_name,
659  const std::string & unknown_name),
660  Gradient gptr(const Point & p,
661  const Parameters & parameters,
662  const std::string & sys_name,
663  const std::string & unknown_name),
664  const Parameters & parameters,
665  NumericVector<Number> & new_vector,
666  int is_adjoint = -1) const;
667 
671  unsigned int number () const;
672 
678  void update_global_solution (std::vector<Number> & global_soln) const;
679 
685  void update_global_solution (std::vector<Number> & global_soln,
686  const processor_id_type dest_proc) const;
687 
691  const MeshBase & get_mesh() const;
692 
696  MeshBase & get_mesh();
697 
701  const DofMap & get_dof_map() const;
702 
706  DofMap & get_dof_map();
707 
712 
717 
722  bool active () const;
723 
727  void activate ();
728 
732  void deactivate ();
733 
742  void set_basic_system_only ();
743 
747  typedef std::map<std::string, NumericVector<Number> *>::iterator vectors_iterator;
748  typedef std::map<std::string, NumericVector<Number> *>::const_iterator const_vectors_iterator;
749 
753  vectors_iterator vectors_begin ();
754 
758  const_vectors_iterator vectors_begin () const;
759 
763  vectors_iterator vectors_end ();
764 
768  const_vectors_iterator vectors_end () const;
769 
779  NumericVector<Number> & add_vector (const std::string & vec_name,
780  const bool projections=true,
781  const ParallelType type = PARALLEL);
782 
786  void remove_vector(const std::string & vec_name);
787 
794  { return _solution_projection; }
795 
800  bool have_vector (const std::string & vec_name) const;
801 
806  const NumericVector<Number> * request_vector (const std::string & vec_name) const;
807 
812  NumericVector<Number> * request_vector (const std::string & vec_name);
813 
819  const NumericVector<Number> * request_vector (const unsigned int vec_num) const;
820 
826  NumericVector<Number> * request_vector (const unsigned int vec_num);
827 
833  const NumericVector<Number> & get_vector (const std::string & vec_name) const;
834 
840  NumericVector<Number> & get_vector (const std::string & vec_name);
841 
847  const NumericVector<Number> & get_vector (const unsigned int vec_num) const;
848 
854  NumericVector<Number> & get_vector (const unsigned int vec_num);
855 
860  const std::string & vector_name (const unsigned int vec_num) const;
861 
865  const std::string & vector_name (const NumericVector<Number> & vec_reference) const;
866 
877  void set_vector_as_adjoint (const std::string & vec_name, int qoi_num);
878 
884  int vector_is_adjoint (const std::string & vec_name) const;
885 
891  void set_vector_preservation (const std::string & vec_name, bool preserve);
892 
898  bool vector_preservation (const std::string & vec_name) const;
899 
905  NumericVector<Number> & add_adjoint_solution(unsigned int i=0);
906 
911  NumericVector<Number> & get_adjoint_solution(unsigned int i=0);
912 
917  const NumericVector<Number> & get_adjoint_solution(unsigned int i=0) const;
918 
925 
931 
936  const NumericVector<Number> & get_sensitivity_solution(unsigned int i=0) const;
937 
945 
952 
959 
966 
972 
978 
984  NumericVector<Number> & add_adjoint_rhs(unsigned int i=0);
985 
992  NumericVector<Number> & get_adjoint_rhs(unsigned int i=0);
993 
998  const NumericVector<Number> & get_adjoint_rhs(unsigned int i=0) const;
999 
1005  NumericVector<Number> & add_sensitivity_rhs(unsigned int i=0);
1006 
1016  NumericVector<Number> & get_sensitivity_rhs(unsigned int i=0);
1017 
1022  const NumericVector<Number> & get_sensitivity_rhs(unsigned int i=0) const;
1023 
1029  unsigned int n_vectors () const;
1030 
1037  virtual unsigned int n_matrices () const;
1038 
1042  unsigned int n_vars() const;
1043 
1047  unsigned int n_variable_groups() const;
1048 
1054  unsigned int n_components() const;
1055 
1059  dof_id_type n_dofs() const;
1060 
1065  dof_id_type n_active_dofs() const;
1066 
1072 
1078 
1083  dof_id_type n_local_dofs() const;
1084 
1089  unsigned int add_variable (const std::string & var,
1090  const FEType & type,
1091  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1092 
1098  unsigned int add_variable (const std::string & var,
1099  const Order order = FIRST,
1100  const FEFamily = LAGRANGE,
1101  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1102 
1107  unsigned int add_variables (const std::vector<std::string> & vars,
1108  const FEType & type,
1109  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1110 
1116  unsigned int add_variables (const std::vector<std::string> & vars,
1117  const Order order = FIRST,
1118  const FEFamily = LAGRANGE,
1119  const std::set<subdomain_id_type> * const active_subdomains = libmesh_nullptr);
1120 
1124  const Variable & variable (unsigned int var) const;
1125 
1129  const VariableGroup & variable_group (unsigned int vg) const;
1130 
1134  bool has_variable(const std::string & var) const;
1135 
1139  const std::string & variable_name(const unsigned int i) const;
1140 
1145  unsigned short int variable_number (const std::string & var) const;
1146 
1151  void get_all_variable_numbers(std::vector<unsigned int> & all_variable_numbers) const;
1152 
1163  unsigned int variable_scalar_number (const std::string & var,
1164  unsigned int component) const;
1165 
1176  unsigned int variable_scalar_number (unsigned int var_num,
1177  unsigned int component) const;
1178 
1179 
1183  const FEType & variable_type (const unsigned int i) const;
1184 
1188  const FEType & variable_type (const std::string & var) const;
1189 
1194  bool identify_variable_groups () const;
1195 
1199  void identify_variable_groups (const bool);
1200 
1206  unsigned int var,
1207  FEMNormType norm_type,
1208  std::set<unsigned int> * skip_dimensions=libmesh_nullptr) const;
1209 
1215  const SystemNorm & norm,
1216  std::set<unsigned int> * skip_dimensions=libmesh_nullptr) const;
1217 
1221  void read_header (Xdr & io,
1222  const std::string & version,
1223  const bool read_header=true,
1224  const bool read_additional_data=true,
1225  const bool read_legacy_format=false);
1226 
1230  void read_legacy_data (Xdr & io,
1231  const bool read_additional_data=true);
1232 
1237  template <typename ValType>
1238  void read_serialized_data (Xdr & io,
1239  const bool read_additional_data=true);
1247  const bool read_additional_data=true)
1248  { read_serialized_data<Number>(io, read_additional_data); }
1249 
1255  template <typename InValType>
1256  std::size_t read_serialized_vectors (Xdr & io,
1257  const std::vector<NumericVector<Number> *> & vectors) const;
1258 
1266  std::size_t read_serialized_vectors (Xdr & io,
1267  const std::vector<NumericVector<Number> *> & vectors) const
1268  { return read_serialized_vectors<Number>(io, vectors); }
1269 
1276  template <typename InValType>
1277  void read_parallel_data (Xdr & io,
1278  const bool read_additional_data);
1279 
1289  const bool read_additional_data)
1290  { read_parallel_data<Number>(io, read_additional_data); }
1291 
1295  void write_header (Xdr & io,
1296  const std::string & version,
1297  const bool write_additional_data) const;
1298 
1303  void write_serialized_data (Xdr & io,
1304  const bool write_additional_data = true) const;
1305 
1311  std::size_t write_serialized_vectors (Xdr & io,
1312  const std::vector<const NumericVector<Number> *> & vectors) const;
1313 
1320  void write_parallel_data (Xdr & io,
1321  const bool write_additional_data) const;
1322 
1327  std::string get_info () const;
1328 
1332  void attach_init_function (void fptr(EquationSystems & es,
1333  const std::string & name));
1334 
1339  void attach_init_object (Initialization & init);
1340 
1345  void attach_assemble_function (void fptr(EquationSystems & es,
1346  const std::string & name));
1347 
1352  void attach_assemble_object (Assembly & assemble);
1353 
1357  void attach_constraint_function (void fptr(EquationSystems & es,
1358  const std::string & name));
1359 
1363  void attach_constraint_object (Constraint & constrain);
1364 
1369  void attach_QOI_function (void fptr(EquationSystems & es,
1370  const std::string & name,
1371  const QoISet & qoi_indices));
1372 
1377  void attach_QOI_object (QOI & qoi);
1378 
1384  void attach_QOI_derivative (void fptr(EquationSystems & es,
1385  const std::string & name,
1386  const QoISet & qoi_indices,
1387  bool include_liftfunc,
1388  bool apply_constraints));
1389 
1395  void attach_QOI_derivative_object (QOIDerivative & qoi_derivative);
1396 
1401  virtual void user_initialization ();
1402 
1407  virtual void user_assembly ();
1408 
1413  virtual void user_constrain ();
1414 
1419  virtual void user_QOI (const QoISet & qoi_indices);
1420 
1425  virtual void user_QOI_derivative (const QoISet & qoi_indices = QoISet(),
1426  bool include_liftfunc = true,
1427  bool apply_constraints = true);
1428 
1434  virtual void re_update ();
1435 
1439  virtual void restrict_vectors ();
1440 
1444  virtual void prolong_vectors ();
1445 
1466 
1471  virtual void disable_cache ();
1472 
1483 
1498 
1499 
1500  //--------------------------------------------------
1501  // The solution and solution access members
1502 
1507  Number current_solution (const dof_id_type global_dof_number) const;
1508 
1513 
1525 
1536 
1543  std::vector<Number> qoi;
1544 
1565  Number point_value(unsigned int var, const Point & p,
1566  const bool insist_on_success = true) const;
1567 
1575  Number point_value(unsigned int var, const Point & p, const Elem & e) const;
1576 
1583  Number point_value(unsigned int var, const Point & p, const Elem * e) const;
1584 
1589  Gradient point_gradient(unsigned int var, const Point & p,
1590  const bool insist_on_success = true) const;
1591 
1596  Gradient point_gradient(unsigned int var, const Point & p, const Elem & e) const;
1597 
1604  Gradient point_gradient(unsigned int var, const Point & p, const Elem * e) const;
1605 
1610  Tensor point_hessian(unsigned int var, const Point & p,
1611  const bool insist_on_success = true) const;
1612 
1618  Tensor point_hessian(unsigned int var, const Point & p, const Elem & e) const;
1619 
1626  Tensor point_hessian(unsigned int var, const Point & p, const Elem * e) const;
1627 
1632  void local_dof_indices (const unsigned int var,
1633  std::set<dof_id_type> & var_indices) const;
1634 
1639  void zero_variable (NumericVector<Number> & v, unsigned int var_num) const;
1640 
1641 
1647  bool & hide_output() { return _hide_output; }
1648 
1649 protected:
1650 
1656  virtual void init_data ();
1657 
1666  int is_adjoint = -1) const;
1667 
1676  void project_vector (const NumericVector<Number> &,
1678  int is_adjoint = -1) const;
1679 
1680 private:
1687  System (const System &);
1688 
1695  System & operator=(const System &);
1696 
1702  unsigned int var,
1703  FEMNormType norm_type) const;
1704 
1714  template <typename iterator_type, typename InValType>
1716  const iterator_type begin,
1717  const iterator_type end,
1718  const InValType dummy,
1719  Xdr & io,
1720  const std::vector<NumericVector<Number> *> & vecs,
1721  const unsigned int var_to_read=libMesh::invalid_uint) const;
1722 
1731  unsigned int read_SCALAR_dofs (const unsigned int var,
1732  Xdr & io,
1733  NumericVector<Number> * vec) const;
1734 
1743  template <typename InValType>
1745  NumericVector<Number> * vec);
1746 
1756  NumericVector<Number> & vec)
1757  { return read_serialized_vector<Number>(io, &vec); }
1758 
1765  template <typename iterator_type>
1766  std::size_t write_serialized_blocked_dof_objects (const std::vector<const NumericVector<Number> *> & vecs,
1767  const dof_id_type n_objects,
1768  const iterator_type begin,
1769  const iterator_type end,
1770  Xdr & io,
1771  const unsigned int var_to_write=libMesh::invalid_uint) const;
1772 
1778  unsigned int write_SCALAR_dofs (const NumericVector<Number> & vec,
1779  const unsigned int var,
1780  Xdr & io) const;
1781 
1789  const NumericVector<Number> & vec) const;
1790 
1795  const std::string & name);
1796 
1801 
1806  const std::string & name);
1807 
1812 
1817  const std::string & name);
1818 
1823 
1828  const std::string & name,
1829  const QoISet & qoi_indices);
1830 
1835 
1840  const std::string & name,
1841  const QoISet & qoi_indices,
1842  bool include_liftfunc,
1843  bool apply_constraints);
1844 
1849 
1855 
1861 
1867 
1871  const std::string _sys_name;
1872 
1876  const unsigned int _sys_number;
1877 
1881  std::vector<Variable> _variables;
1882 
1886  std::vector<VariableGroup> _variable_groups;
1887 
1892  std::map<std::string, unsigned short int> _variable_numbers;
1893 
1897  bool _active;
1898 
1905  std::map<std::string, NumericVector<Number> * > _vectors;
1906 
1911  std::map<std::string, bool> _vector_projections;
1912 
1917  std::map<std::string, int> _vector_is_adjoint;
1918 
1922  std::map<std::string, ParallelType> _vector_types;
1923 
1930 
1936 
1942 
1948 
1955 
1966  std::vector<unsigned int> _written_var_indices;
1967 
1974 
1980 };
1981 
1982 
1983 
1984 // ------------------------------------------------------------
1985 // System inline methods
1986 inline
1987 const std::string & System::name() const
1988 {
1989  return _sys_name;
1990 }
1991 
1992 
1993 
1994 inline
1995 unsigned int System::number() const
1996 {
1997  return _sys_number;
1998 }
1999 
2000 
2001 
2002 inline
2004 {
2005  return _mesh;
2006 }
2007 
2008 
2009 
2010 inline
2012 {
2013  return _mesh;
2014 }
2015 
2016 
2017 
2018 inline
2020 {
2021  return *_dof_map;
2022 }
2023 
2024 
2025 
2026 inline
2028 {
2029  return *_dof_map;
2030 }
2031 
2032 
2033 
2034 inline
2035 bool System::active() const
2036 {
2037  return _active;
2038 }
2039 
2040 
2041 
2042 inline
2044 {
2045  _active = true;
2046 }
2047 
2048 
2049 
2050 inline
2052 {
2053  _active = false;
2054 }
2055 
2056 
2057 
2058 inline
2060 {
2061  return _is_initialized;
2062 }
2063 
2064 
2065 
2066 inline
2068 {
2069  _basic_system_only = true;
2070 }
2071 
2072 
2073 
2074 inline
2075 unsigned int System::n_vars() const
2076 {
2077  return cast_int<unsigned int>(_variables.size());
2078 }
2079 
2080 
2081 
2082 inline
2083 unsigned int System::n_variable_groups() const
2084 {
2085  return cast_int<unsigned int>(_variable_groups.size());
2086 }
2087 
2088 
2089 
2090 inline
2091 unsigned int System::n_components() const
2092 {
2093  if (_variables.empty())
2094  return 0;
2095 
2096  const Variable & last = _variables.back();
2097  return last.first_scalar_number() + last.n_components();
2098 }
2099 
2100 
2101 
2102 inline
2103 const Variable & System::variable (const unsigned int i) const
2104 {
2105  libmesh_assert_less (i, _variables.size());
2106 
2107  return _variables[i];
2108 }
2109 
2110 
2111 
2112 inline
2113 const VariableGroup & System::variable_group (const unsigned int vg) const
2114 {
2115  libmesh_assert_less (vg, _variable_groups.size());
2116 
2117  return _variable_groups[vg];
2118 }
2119 
2120 
2121 
2122 inline
2123 const std::string & System::variable_name (const unsigned int i) const
2124 {
2125  libmesh_assert_less (i, _variables.size());
2126 
2127  return _variables[i].name();
2128 }
2129 
2130 
2131 
2132 inline
2133 unsigned int
2134 System::variable_scalar_number (const std::string & var,
2135  unsigned int component) const
2136 {
2137  return variable_scalar_number(this->variable_number(var), component);
2138 }
2139 
2140 
2141 
2142 inline
2143 unsigned int
2144 System::variable_scalar_number (unsigned int var_num,
2145  unsigned int component) const
2146 {
2147  return _variables[var_num].first_scalar_number() + component;
2148 }
2149 
2150 
2151 
2152 inline
2153 const FEType & System::variable_type (const unsigned int i) const
2154 {
2155  libmesh_assert_less (i, _variables.size());
2156 
2157  return _variables[i].type();
2158 }
2159 
2160 
2161 
2162 inline
2163 const FEType & System::variable_type (const std::string & var) const
2164 {
2165  return _variables[this->variable_number(var)].type();
2166 }
2167 
2168 
2169 
2170 inline
2172 {
2174 }
2175 
2176 
2177 
2178 inline
2180 {
2182 }
2183 
2184 
2185 
2186 inline
2188 {
2189  return this->n_dofs() - this->n_constrained_dofs();
2190 }
2191 
2192 
2193 
2194 inline
2195 bool System::have_vector (const std::string & vec_name) const
2196 {
2197  return (_vectors.count(vec_name));
2198 }
2199 
2200 
2201 
2202 inline
2203 unsigned int System::n_vectors () const
2204 {
2205  return cast_int<unsigned int>(_vectors.size());
2206 }
2207 
2208 inline
2209 unsigned int System::n_matrices () const
2210 {
2211  return 0;
2212 }
2213 
2214 inline
2216 {
2217  return _vectors.begin();
2218 }
2219 
2220 inline
2222 {
2223  return _vectors.begin();
2224 }
2225 
2226 inline
2228 {
2229  return _vectors.end();
2230 }
2231 
2232 inline
2234 {
2235  return _vectors.end();
2236 }
2237 
2238 inline
2240 {
2241  libmesh_not_implemented();
2242 }
2243 
2244 inline
2246 
2247 inline
2248 std::pair<unsigned int, Real>
2250 {
2251  libmesh_not_implemented();
2252 }
2253 
2254 inline
2255 std::pair<unsigned int, Real>
2257  const ParameterVector &)
2258 {
2259  libmesh_not_implemented();
2260 }
2261 
2262 inline
2263 std::pair<unsigned int, Real>
2265 {
2266  libmesh_not_implemented();
2267 }
2268 
2269 inline
2270 std::pair<unsigned int, Real>
2272  const ParameterVector &,
2273  const QoISet &)
2274 {
2275  libmesh_not_implemented();
2276 }
2277 
2278 inline
2279 void
2281  const ParameterVector &,
2282  SensitivityData &)
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  const ParameterVector &,
2310  SensitivityData &)
2311 {
2312  libmesh_not_implemented();
2313 }
2314 
2315 
2316 } // namespace libMesh
2317 
2318 #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:2227
dof_id_type n_constrained_dofs() const
Definition: system.C:150
std::map< std::string, unsigned short int > _variable_numbers
Definition: system.h:1892
Manages multiples systems of equations.
static unsigned int n_objects()
virtual void clear()
Definition: system.C:198
Assembly * _assemble_system_object
Definition: system.h:1811
bool _basic_system_only
Definition: system.h:1935
const unsigned int invalid_uint
Definition: libmesh.h:184
const std::string & variable_name(const unsigned int i) const
Definition: system.h:2123
std::map< std::string, ParallelType > _vector_types
Definition: system.h:1922
bool _is_initialized
Definition: system.h:1941
void(* _constrain_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1816
void set_adjoint_already_solved(bool setting)
Definition: system.h:377
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:2289
Specifies parameters for parameter sensitivity calculations.
virtual void assemble_residual_derivatives(const ParameterVector &parameters)
Definition: system.h:2239
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:1288
virtual void reinit()
Definition: system.C:380
virtual void disable_cache()
Definition: system.h:2245
Set dofs outside the subset to zero.
int extra_quadrature_order
Definition: system.h:1497
sys_type & system()
Definition: system.h:225
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:1876
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:1822
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:1524
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:1266
std::map< std::string, NumericVector< Number > * >::const_iterator const_vectors_iterator
Definition: system.h:748
virtual void user_initialization()
Definition: system.C:1942
std::vector< Variable > _variables
Definition: system.h:1881
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:2215
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:2280
const VariableGroup & variable_group(unsigned int vg) const
Definition: system.h:2113
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:2153
void(* _qoi_evaluate_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)
Definition: system.h:1827
System sys_type
Definition: system.h:220
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:1854
const std::string & name() const
Definition: system.h:1987
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:1973
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:1848
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:2298
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:2067
void update_global_solution(std::vector< Number > &global_soln) const
Definition: system.C:657
unsigned int n_variable_groups() const
Definition: system.h:2083
const MeshBase & get_mesh() const
Definition: system.h:2003
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:2019
unsigned int n_components() const
Definition: system.h:2091
virtual void qoi_parameter_hessian_vector_product(const QoISet &qoi_indices, const ParameterVector &parameters, const ParameterVector &vector, SensitivityData &product)
Definition: system.h:2307
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:2195
std::vector< Number > qoi
Definition: system.h:1543
void deactivate()
Definition: system.h:2051
const Variable & variable(unsigned int var) const
Definition: system.h:2103
void read_serialized_data(Xdr &io, const bool read_additional_data=true)
Definition: system.h:1246
std::vector< VariableGroup > _variable_groups
Definition: system.h:1886
bool is_initialized()
Definition: system.h:2059
bool use_fixed_solution
Definition: system.h:1482
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:1647
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:1834
virtual std::pair< unsigned int, Real > sensitivity_solve(const ParameterVector &parameters)
Definition: system.h:2249
Initialization * _init_system_object
Definition: system.h:1800
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet())
Definition: system.h:2264
System & operator=(const System &)
Definition: system.C:110
bool active() const
Definition: system.h:2035
bool _hide_output
Definition: system.h:1979
unsigned int _additional_data_written
Definition: system.h:1954
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:1512
void(* _init_system_function)(EquationSystems &es, const std::string &name)
Definition: system.h:1794
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:1917
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:2043
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:371
virtual void reinit_constraints()
Definition: system.C:409
virtual unsigned int n_matrices() const
Definition: system.h:2209
virtual void solve()
Definition: system.h:309
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:716
void attach_assemble_object(Assembly &assemble)
Definition: system.C:1820
std::map< std::string, NumericVector< Number > * >::iterator vectors_iterator
Definition: system.h:747
bool _solution_projection
Definition: system.h:1929
EquationSystems & _equation_systems
Definition: system.h:1860
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:470
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:1947
bool identify_variable_groups() const
Definition: system.h:2171
unsigned int number() const
Definition: system.h:1995
unsigned int n_components() const
Definition: variable.h:125
std::map< std::string, NumericVector< Number > * > _vectors
Definition: system.h:1905
virtual std::pair< unsigned int, Real > weighted_sensitivity_solve(const ParameterVector &parameters, const ParameterVector &weights)
Definition: system.h:2256
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:1871
bool & project_solution_on_reinit(void)
Definition: system.h:793
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:1911
virtual ~QOI()
Definition: system.h:174
const EquationSystems & get_equation_systems() const
Definition: system.h:711
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:2271
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:2134
dof_id_type n_dofs() const
Definition: system.C:143
unsigned int n_vars() const
Definition: system.h:2075
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:1805
virtual ~System()
Definition: system.C:116
numeric_index_type read_serialized_vector(Xdr &io, NumericVector< Number > &vec)
Definition: system.h:1755
bool assemble_before_solve
Definition: system.h:1465
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:1866
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:2187
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:1966
uint8_t dof_id_type
Definition: id_types.h:64
unsigned int n_vectors() const
Definition: system.h:2203
void(* _qoi_evaluate_derivative_function)(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)
Definition: system.h:1839
NumericVector< Number > & get_adjoint_rhs(unsigned int i=0)
Definition: system.C:1045