https://mooseframework.inl.gov
SystemBase.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include <map>
13 #include <set>
14 #include <vector>
15 
16 #include "DataIO.h"
17 #include "MooseTypes.h"
18 #include "VariableWarehouse.h"
19 #include "InputParameters.h"
20 #include "MooseVariableBase.h"
21 #include "ConsoleStreamInterface.h"
22 // libMesh
23 #include "libmesh/exodusII_io.h"
24 #include "libmesh/parallel_object.h"
25 #include "libmesh/numeric_vector.h"
26 #include "libmesh/sparse_matrix.h"
27 
28 // Forward declarations
29 class Factory;
30 class MooseApp;
32 template <typename>
36 class MooseMesh;
37 class SubProblem;
38 class SystemBase;
39 class TimeIntegrator;
40 class InputParameters;
41 class FEProblemBase;
42 
43 // libMesh forward declarations
44 namespace libMesh
45 {
46 class System;
47 class DofMap;
48 class FEType;
49 }
50 
54 void extraSendList(std::vector<dof_id_type> & send_list, void * context);
55 
60  std::vector<dof_id_type> & n_nz,
61  std::vector<dof_id_type> & n_oz,
62  void * context);
63 
68 {
69  VarCopyInfo(const std::string & dest_name,
70  const std::string & source_name,
71  const std::string & timestep)
72  : _dest_name(dest_name), _source_name(source_name), _timestep(timestep)
73  {
74  }
75 
76  std::string _dest_name;
77  std::string _source_name;
78  std::string _timestep;
79 };
80 
86 
87 {
88 public:
90  FEProblemBase & fe_problem,
91  const std::string & name,
92  Moose::VarKindType var_kind);
93  virtual ~SystemBase() {}
94 
99  unsigned int number() const;
100  MooseMesh & mesh() { return _mesh; }
101  const MooseMesh & mesh() const { return _mesh; }
103  const SubProblem & subproblem() const { return _subproblem; }
105  const FEProblemBase & feProblem() const { return _fe_problem; }
106 
112  void applyScalingFactors(const std::vector<Real> & inverse_scaling_factors);
113 
117  bool computingScalingJacobian() const;
118 
123  bool automaticScaling() const { return _automatic_scaling; }
124 
129  void automaticScaling(bool automatic_scaling) { _automatic_scaling = automatic_scaling; }
130 
135  void setVerboseFlag(const bool & verbose) { _verbose = verbose; }
136 
140  virtual libMesh::DofMap & dofMap();
141 
145  virtual const libMesh::DofMap & dofMap() const;
146 
150  virtual libMesh::System & system() = 0;
151  virtual const libMesh::System & system() const = 0;
152 
157  virtual void preInit() {}
158 
159  /*
160  * This is called after the libMesh system has been init'd. This can be used to initialize MOOSE
161  * system data that relies on the libMesh system data already being initialized
162  */
163  virtual void postInit() {}
164 
169  virtual void reinit() {}
170 
174  virtual void initializeObjects() {}
175 
179  void update();
180 
184  virtual void solve();
185 
186  virtual void copyOldSolutions();
187  virtual void copyPreviousNonlinearSolutions();
188  virtual void copyPreviousFixedPointSolutions();
189  virtual void restoreSolutions();
190 
195  virtual const NumericVector<Number> * const & currentSolution() const = 0;
196 
200  const NumericVector<Number> & solution() const { return solutionState(0); }
201  const NumericVector<Number> & solutionOld() const { return solutionState(1); }
202  const NumericVector<Number> & solutionOlder() const { return solutionState(2); }
203 
204  virtual const NumericVector<Number> * solutionPreviousNewton() const;
206 
210  virtual void initSolutionState();
211 
218  virtual NumericVector<Number> &
219  solutionState(const unsigned int state,
221 
225  virtual const NumericVector<Number> & solutionState(
226  const unsigned int state,
228 
233  solutionStateParallelType(const unsigned int state,
234  const Moose::SolutionIterationType iteration_type) const;
235 
239  virtual void needSolutionState(
240  const unsigned int state,
242  libMesh::ParallelType parallel_type = GHOSTED);
243 
247  virtual bool hasSolutionState(
248  const unsigned int state,
250 
255  virtual void addDotVectors();
256 
257  virtual std::vector<Number> & duDotDus() { return _du_dot_du; }
258  virtual Number & duDotDotDu() { return _du_dotdot_du; }
259  virtual const Number & duDotDu(unsigned int var_num = 0) const;
260  virtual const Number & duDotDotDu() const { return _du_dotdot_du; }
261 
262  virtual NumericVector<Number> * solutionUDot() { return _u_dot; }
266  virtual const NumericVector<Number> * solutionUDot() const { return _u_dot; }
267  virtual const NumericVector<Number> * solutionUDotDot() const { return _u_dotdot; }
268  virtual const NumericVector<Number> * solutionUDotOld() const { return _u_dot_old; }
269  virtual const NumericVector<Number> * solutionUDotDotOld() const { return _u_dotdot_old; }
270 
271  virtual void saveOldSolutions();
272  virtual void restoreOldSolutions();
273 
277  bool hasVector(const std::string & tag_name) const;
278 
282  virtual bool hasVector(TagID tag_id) const
283  {
284  return tag_id < _tagged_vectors.size() && _tagged_vectors[tag_id];
285  }
286 
293  virtual TagID timeVectorTag() const { mooseError("Not implemented yet"); }
294 
298  virtual TagID systemMatrixTag() const { mooseError("Not implemented yet"); }
299 
300  /*
301  * Return TagID for nontime
302  */
303  virtual TagID nonTimeVectorTag() const { mooseError("Not implemented yet"); }
304 
305  /*
306  * Return TagID for nontime
307  */
308  virtual TagID residualVectorTag() const { mooseError("Not implemented yet"); }
309 
313  virtual std::set<TagID> defaultVectorTags() const
314  {
316  }
320  virtual std::set<TagID> defaultMatrixTags() const { return {systemMatrixTag()}; }
321 
325  virtual NumericVector<Number> & getVector(const std::string & name);
327  virtual const NumericVector<Number> & getVector(const std::string & name) const;
329 
333  virtual NumericVector<Number> & getVector(TagID tag);
335  virtual const NumericVector<Number> & getVector(TagID tag) const;
337 
341  virtual void associateVectorToTag(NumericVector<Number> & vec, TagID tag);
342 
346  virtual void disassociateVectorFromTag(NumericVector<Number> & vec, TagID tag);
347 
351  virtual void disassociateVectorFromTag(TagID tag);
352 
356  virtual void disassociateDefaultVectorTags();
357 
361  virtual bool hasMatrix(TagID tag) const
362  {
363  return tag < _tagged_matrices.size() && _tagged_matrices[tag];
364  }
365 
370 
374  virtual const libMesh::SparseMatrix<Number> & getMatrix(TagID tag) const;
375 
379  virtual void activateAllMatrixTags();
380 
384  virtual bool matrixTagActive(TagID tag) const;
385 
389  virtual void deactivateAllMatrixTags();
390 
394  void closeTaggedMatrices(const std::set<TagID> & tags);
395 
400  void flushTaggedMatrices(const std::set<TagID> & tags);
401 
405  virtual void associateMatrixToTag(libMesh::SparseMatrix<Number> & matrix, TagID tag);
406 
411 
415  virtual void disassociateMatrixFromTag(TagID tag);
416 
420  virtual void disassociateDefaultMatrixTags();
421 
426 
428  {
429  mooseError("This system does not support getting a copy of the residual");
430  }
432  {
433  mooseError("This system does not support getting a ghosted copy of the residual");
434  }
435 
439  virtual void augmentSendList(std::vector<dof_id_type> & send_list);
440 
444  virtual void augmentSparsity(libMesh::SparsityPattern::Graph & sparsity,
445  std::vector<dof_id_type> & n_nz,
446  std::vector<dof_id_type> & n_oz) = 0;
447 
454  virtual void addVariable(const std::string & var_type,
455  const std::string & var_name,
456  InputParameters & parameters);
457 
461  virtual bool isArrayVariable(const std::string & var_name) const;
462 
464 
470  virtual bool hasVariable(const std::string & var_name) const;
471  virtual bool hasScalarVariable(const std::string & var_name) const;
473 
474  virtual bool isScalarVariable(unsigned int var_name) const;
475 
483  MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string & var_name) const;
484 
492  MooseVariableFieldBase & getVariable(THREAD_ID tid, unsigned int var_number) const;
493 
503  template <typename T>
504  MooseVariableFE<T> & getFieldVariable(THREAD_ID tid, const std::string & var_name);
505 
509  template <typename T>
510  MooseVariableField<T> & getActualFieldVariable(THREAD_ID tid, const std::string & var_name);
511 
521  template <typename T>
522  MooseVariableFE<T> & getFieldVariable(THREAD_ID tid, unsigned int var_number);
523 
527  template <typename T>
528  MooseVariableField<T> & getActualFieldVariable(THREAD_ID tid, unsigned int var_number);
529 
533  template <typename T>
534  MooseVariableFV<T> & getFVVariable(THREAD_ID tid, const std::string & var_name);
535 
544  const std::string & var_name) const;
545 
553  virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, unsigned int var_number) const;
554 
561  virtual const std::set<SubdomainID> * getVariableBlocks(unsigned int var_number);
562 
567  virtual unsigned int nVariables() const;
568 
573  unsigned int nFieldVariables() const;
574 
579  unsigned int nFVVariables() const;
580 
586  std::size_t getMaxVarNDofsPerElem() const { return _max_var_n_dofs_per_elem; }
587 
593  std::size_t getMaxVarNDofsPerNode() const { return _max_var_n_dofs_per_node; }
594 
598  void assignMaxVarNDofsPerElem(std::size_t max_dofs) { _max_var_n_dofs_per_elem = max_dofs; }
599 
603  void assignMaxVarNDofsPerNode(std::size_t max_dofs) { _max_var_n_dofs_per_node = max_dofs; }
604 
609  virtual void addVariableToZeroOnResidual(std::string var_name);
610 
615  virtual void addVariableToZeroOnJacobian(std::string var_name);
616 
623  virtual void zeroVariables(std::vector<std::string> & vars_to_be_zeroed);
624 
629  virtual void zeroVariablesForResidual();
630 
635  virtual void zeroVariablesForJacobian();
636 
642 
647  virtual void prepare(THREAD_ID tid);
648 
658  virtual void prepareFace(THREAD_ID tid, bool resize_data);
659 
664  virtual void prepareNeighbor(THREAD_ID tid);
665 
670  virtual void prepareLowerD(THREAD_ID tid);
671 
677  virtual void reinitElem(const Elem * elem, THREAD_ID tid);
678 
685  virtual void reinitElemFace(const Elem * elem, unsigned int side, THREAD_ID tid);
686 
690  virtual void reinitNeighborFace(const Elem * elem, unsigned int side, THREAD_ID tid);
691 
695  virtual void reinitNeighbor(const Elem * elem, THREAD_ID tid);
696 
700  virtual void reinitLowerD(THREAD_ID tid);
701 
707  virtual void reinitNode(const Node * node, THREAD_ID tid);
708 
715  virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, THREAD_ID tid);
716 
722  virtual void reinitNodes(const std::vector<dof_id_type> & nodes, THREAD_ID tid);
723 
729  virtual void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, THREAD_ID tid);
730 
737  virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering = false);
738 
748  virtual void addVariableToCopy(const std::string & dest_name,
749  const std::string & source_name,
750  const std::string & timestep);
751 
752  const std::vector<MooseVariableFieldBase *> & getVariables(THREAD_ID tid)
753  {
754  return _vars[tid].fieldVariables();
755  }
756 
757  const VariableWarehouse & variableWarehouse(THREAD_ID tid = 0) const { return _vars[tid]; }
758 
759  const std::vector<MooseVariableScalar *> & getScalarVariables(THREAD_ID tid)
760  {
761  return _vars[tid].scalars();
762  }
763 
764  const std::set<SubdomainID> & getSubdomainsForVar(unsigned int var_number) const
765  {
766  return _var_map.at(var_number);
767  }
768 
775  const std::set<SubdomainID> & getSubdomainsForVar(const std::string & var_name) const;
776 
780  void removeVector(const std::string & name);
781 
796  addVector(const std::string & vector_name, const bool project, const libMesh::ParallelType type);
797 
812  addVector(TagID tag, const bool project, const libMesh::ParallelType type);
813 
817  void closeTaggedVector(const TagID tag);
821  void closeTaggedVectors(const std::set<TagID> & tags);
822 
826  void zeroTaggedVector(const TagID tag);
830  void zeroTaggedVectors(const std::set<TagID> & tags);
831 
837  void removeVector(TagID tag_id);
838 
841  void setVariableGlobalDoFs(const std::string & var_name);
842 
845  const std::vector<dof_id_type> & getVariableGlobalDoFs() { return _var_all_dof_indices; }
846 
853 
859  void removeMatrix(TagID tag);
860 
861  virtual const std::string & name() const;
862 
863  const std::vector<VariableName> & getVariableNames() const { return _vars[0].names(); }
864 
865  void getStandardFieldVariableNames(std::vector<VariableName> & std_field_variables) const;
866 
870  unsigned int getMaxVariableNumber() const { return _max_var_number; }
871 
872  virtual void computeVariables(const NumericVector<Number> & /*soln*/) {}
873 
874  void copyVars(libMesh::ExodusII_IO & io);
875 
879  virtual void copySolutionsBackwards();
880 
881  void addTimeIntegrator(const std::string & type,
882  const std::string & name,
883  InputParameters & parameters);
884 
886  bool hasVarCopy() const { return _var_to_copy.size() > 0; }
887 
891  void addScalingVector();
892 
900 
902  virtual void initialSetup();
903  virtual void timestepSetup();
904  virtual void customSetup(const ExecFlagType & exec_type);
905  virtual void subdomainSetup();
906  virtual void residualSetup();
907  virtual void jacobianSetup();
908 
912  void clearAllDofIndices();
913 
917  void setActiveVariableCoupleableVectorTags(const std::set<TagID> & vtags, THREAD_ID tid);
918 
922  void setActiveScalarVariableCoupleableVectorTags(const std::set<TagID> & vtags, THREAD_ID tid);
923 
928 
933  virtual void compute(ExecFlagType type) = 0;
934 
938  void copyTimeIntegrators(const SystemBase & other_sys);
939 
943  const TimeIntegrator & getTimeIntegrator(const unsigned int var_num) const;
944 
950  const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const;
951 
955  const std::vector<std::shared_ptr<TimeIntegrator>> & getTimeIntegrators();
956 
962  std::string prefix() const;
963 
967  void sizeVariableMatrixData();
968 
974 
975 protected:
979  virtual NumericVector<Number> & solutionInternal() const = 0;
980 
984 
987 
990 
993  std::string _name;
994 
996  std::vector<VariableWarehouse> _vars;
998  std::map<unsigned int, std::set<SubdomainID>> _var_map;
1000  unsigned int _max_var_number;
1001 
1002  std::vector<std::string> _vars_to_be_zeroed_on_residual;
1003  std::vector<std::string> _vars_to_be_zeroed_on_jacobian;
1004 
1009 
1014 
1017  std::vector<Real> _du_dot_du;
1019 
1021  std::vector<NumericVector<Number> *> _tagged_vectors;
1023  std::vector<libMesh::SparseMatrix<Number> *> _tagged_matrices;
1025  std::unordered_map<TagID, libMesh::SparseMatrix<Number> *> _active_tagged_matrices;
1027  std::vector<bool> _matrix_tag_active_flags;
1028 
1029  // Used for saving old solutions so that they wont be accidentally changed
1030  NumericVector<Real> * _saved_old;
1031  NumericVector<Real> * _saved_older;
1032 
1033  // Used for saving old u_dot and u_dotdot so that they wont be accidentally changed
1034  NumericVector<Real> * _saved_dot_old;
1035  NumericVector<Real> * _saved_dotdot_old;
1036 
1039 
1040  std::vector<VarCopyInfo> _var_to_copy;
1041 
1044 
1047 
1049  std::vector<std::shared_ptr<TimeIntegrator>> _time_integrators;
1050 
1052  std::vector<std::vector<MooseVariableFieldBase *>> _numbered_vars;
1053 
1056 
1058  bool _verbose;
1059 
1062 
1064  std::vector<dof_id_type> _var_all_dof_indices;
1065 
1068  std::unique_ptr<NumericVector<Number>> _serialized_solution;
1069 
1070 private:
1074  TagName oldSolutionStateVectorName(const unsigned int,
1075  Moose::SolutionIterationType iteration_type) const;
1076 
1079  std::array<std::vector<NumericVector<Number> *>, 3> _solution_states;
1081  std::vector<NumericVector<Number> *> _saved_solution_states;
1084 };
1085 
1086 inline bool
1087 SystemBase::hasSolutionState(const unsigned int state,
1088  const Moose::SolutionIterationType iteration_type) const
1089 {
1090  return _solution_states[static_cast<unsigned short>(iteration_type)].size() > state;
1091 }
1092 
1093 #define PARALLEL_TRY
1094 
1095 #define PARALLEL_CATCH _fe_problem.checkExceptionAndStopSolve();
void zeroTaggedVector(const TagID tag)
Zero vector with the given tag.
Definition: SystemBase.C:675
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
Definition: SystemBase.h:1049
virtual const std::set< SubdomainID > * getVariableBlocks(unsigned int var_number)
Get the block where a variable of this system is defined.
Definition: SystemBase.C:165
virtual void reinitNode(const Node *node, THREAD_ID tid)
Reinit nodal assembly info.
Definition: SystemBase.C:399
virtual bool hasVector(TagID tag_id) const
Check if the tagged vector exists in the system.
Definition: SystemBase.h:282
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
Definition: SystemBase.h:752
void closeTaggedVector(const TagID tag)
Close vector with the given tag.
Definition: SystemBase.C:650
MooseMesh & mesh()
Definition: SystemBase.h:100
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
const NumericVector< Number > & solution() const
Definition: SystemBase.h:200
virtual void initializeObjects()
Called only once, just before the solve begins so objects can do some precalculations.
Definition: SystemBase.h:174
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
Map variable number to its pointer.
Definition: SystemBase.h:1052
std::vector< dof_id_type > _var_all_dof_indices
Container for the dof indices of a given variable.
Definition: SystemBase.h:1064
std::vector< Real > _du_dot_du
Derivative of time derivative of u with respect to uj.
Definition: SystemBase.h:1017
virtual NumericVector< Number > & solutionInternal() const =0
Internal getter for solution owned by libMesh.
void extraSparsity(libMesh::SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *context)
Free function used for a libMesh callback.
Definition: SystemBase.C:48
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:1023
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
Definition: SystemBase.h:759
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition: SystemBase.C:694
virtual const NumericVector< Number > * solutionUDotDotOld() const
Definition: SystemBase.h:269
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:925
void applyScalingFactors(const std::vector< Real > &inverse_scaling_factors)
Applies scaling factors to the system&#39;s variables.
Definition: SystemBase.C:1497
std::string _source_name
Definition: SystemBase.h:77
virtual void augmentSparsity(libMesh::SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz)=0
Will modify the sparsity pattern to add logical geometric connections.
Class for stuff related to variables.
Definition: Adaptivity.h:33
virtual void copyOldSolutions()
Shifts the solutions backwards in time.
Definition: SystemBase.C:1287
virtual NumericVector< Number > & residualCopy()
Definition: SystemBase.h:427
const MooseMesh & mesh() const
Definition: SystemBase.h:101
bool _solution_states_initialized
Whether or not the solution states have been initialized.
Definition: SystemBase.h:1061
unsigned int TagID
Definition: MooseTypes.h:238
std::unordered_map< TagID, libMesh::SparseMatrix< Number > * > _active_tagged_matrices
Active tagged matrices. A matrix is active if its tag-matrix pair is present in the map...
Definition: SystemBase.h:1025
NumericVector< Number > & solution()
Definition: SystemBase.h:197
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters &parameters)
Canonical method for adding a variable.
Definition: SystemBase.C:719
Generic factory class for build all sorts of objects.
Definition: Factory.h:28
void automaticScaling(bool automatic_scaling)
Setter for whether we are performing automatic scaling.
Definition: SystemBase.h:129
virtual const NumericVector< Number > * solutionUDot() const
Definition: SystemBase.h:266
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::vector< std::string > _vars_to_be_zeroed_on_residual
Definition: SystemBase.h:1002
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
Definition: SystemBase.h:1011
virtual void initSolutionState()
Initializes the solution state.
Definition: SystemBase.C:1366
virtual void disassociateDefaultVectorTags()
Disassociate the vectors associated with the default vector tags of this system.
Definition: SystemBase.C:1016
virtual void reinitElem(const Elem *elem, THREAD_ID tid)
Reinit an element assembly info.
Definition: SystemBase.C:341
virtual void reinitLowerD(THREAD_ID tid)
Compute the values of the variables on the lower dimensional element.
Definition: SystemBase.C:391
const TimeIntegrator & getTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable&#39;s equation.
Definition: SystemBase.C:1672
size_t _max_var_n_dofs_per_node
Maximum number of dofs for any one variable on any one node.
Definition: SystemBase.h:1046
bool hasVarCopy() const
Whether or not there are variables to be restarted from an Exodus mesh file.
Definition: SystemBase.h:886
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:982
virtual libMesh::Order getMinQuadratureOrder()
Get minimal quadrature order needed for integrating variables in this system.
Definition: SystemBase.C:242
virtual const Number & duDotDotDu() const
Definition: SystemBase.h:260
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.C:1433
Factory & _factory
Definition: SystemBase.h:989
Base class for MOOSE-based applications.
Definition: MooseApp.h:107
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
bool computingScalingJacobian() const
Whether we are computing an initial Jacobian for automatic variable scaling.
Definition: SystemBase.C:1554
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
Definition: SystemBase.h:1008
void setVerboseFlag(const bool &verbose)
Sets the verbose flag.
Definition: SystemBase.h:135
virtual void addVariableToCopy(const std::string &dest_name, const std::string &source_name, const std::string &timestep)
Add info about variable that will be copied.
Definition: SystemBase.C:1176
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:361
virtual NumericVector< Number > * solutionUDotDotOld()
Definition: SystemBase.h:265
void removeMatrix(TagID tag)
Removes a matrix with a given tag.
Definition: SystemBase.C:591
virtual void associateMatrixToTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
Definition: SystemBase.C:1077
This class provides an interface for common operations on field variables of both FE and FV types wit...
NumericVector< Number > & solutionOlder()
Definition: SystemBase.h:199
virtual void prepareFace(THREAD_ID tid, bool resize_data)
Prepare the system for use on sides.
Definition: SystemBase.C:280
void addScalingVector()
Add the scaling factor vector to the system.
Definition: SystemBase.C:1547
bool solutionStatesInitialized() const
Whether or not the solution states have been initialized via initSolutionState()
Definition: SystemBase.h:899
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters &parameters)
Definition: SystemBase.C:1647
void setActiveVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the variables.
Definition: SystemBase.C:1609
Base class for a system (of equations)
Definition: SystemBase.h:85
virtual void copyPreviousNonlinearSolutions()
Shifts the solutions backwards in nonlinear iteration history.
Definition: SystemBase.C:1270
virtual bool isArrayVariable(const std::string &var_name) const
If a variable is an array variable.
Definition: SystemBase.C:865
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
Definition: SystemBase.C:423
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed...
Definition: SystemBase.h:1068
size_t _max_var_n_dofs_per_elem
Maximum number of dofs for any one variable on any one element.
Definition: SystemBase.h:1043
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of neighbor nodes.
Definition: SystemBase.C:434
NumericVector< Real > * _saved_older
Definition: SystemBase.h:1031
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
MooseVariableFV< T > & getFVVariable(THREAD_ID tid, const std::string &var_name)
Return a finite volume variable.
Definition: SystemBase.C:126
virtual void disassociateMatrixFromTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
Definition: SystemBase.C:1089
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
virtual void compute(ExecFlagType type)=0
Compute time derivatives, auxiliary variables, etc.
void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:1244
virtual unsigned int nVariables() const
Get the number of variables in this system.
Definition: SystemBase.C:892
void setActiveScalarVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the scalar variables.
Definition: SystemBase.C:1615
virtual void activateAllMatrixTags()
Make all existing matrices active.
Definition: SystemBase.C:1132
virtual const std::string & name() const
Definition: SystemBase.C:1342
virtual void jacobianSetup()
Definition: SystemBase.C:1595
const VariableWarehouse & variableWarehouse(THREAD_ID tid=0) const
Definition: SystemBase.h:757
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
Definition: SystemBase.C:1061
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:1040
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
Definition: SystemBase.C:1164
void sizeVariableMatrixData()
size the matrix data for each variable for the number of matrix tags we have
Definition: SystemBase.C:1708
virtual void deactivateAllMatrixTags()
Make matrices inactive.
Definition: SystemBase.C:1120
FEProblemBase & feProblem()
Definition: SystemBase.h:104
void copyTimeIntegrators(const SystemBase &other_sys)
Copy time integrators from another system.
Definition: SystemBase.C:1656
virtual NumericVector< Number > & serializedSolution()
Returns a reference to a serialized version of the solution vector for this subproblem.
Definition: SystemBase.C:1635
bool _skip_next_solution_to_old_copy
Whether to skip the next copy from the solution to the old vector.
Definition: SystemBase.h:1083
bool automaticScaling() const
Getter for whether we are performing automatic scaling.
Definition: SystemBase.h:123
virtual Number & duDotDotDu()
Definition: SystemBase.h:258
void copyVars(libMesh::ExodusII_IO &io)
Definition: SystemBase.C:1184
virtual const Number & duDotDu(unsigned int var_num=0) const
Definition: SystemBase.C:1690
Real _du_dotdot_du
Definition: SystemBase.h:1018
Holds variables and provides some services.
virtual void zeroVariablesForResidual()
Zero out the solution for the variables that were registered as needing to have their solutions zeroe...
Definition: SystemBase.C:230
void extraSendList(std::vector< dof_id_type > &send_list, void *context)
///< Type of coordinate system
Definition: SystemBase.C:40
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:1027
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
Definition: SystemBase.h:1003
boundary_id_type BoundaryID
bool _automatic_scaling
Whether to automatically scale the variables.
Definition: SystemBase.h:1055
Information about variables that will be copied.
Definition: SystemBase.h:67
virtual NumericVector< Number > * solutionUDot()
Definition: SystemBase.h:262
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:763
SubProblem & subproblem()
Definition: SystemBase.h:102
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
Definition: SystemBase.C:325
virtual ~SystemBase()
Definition: SystemBase.h:93
An inteface for the _console for outputting to the Console object.
virtual NumericVector< Number > * solutionUDotOld()
Definition: SystemBase.h:264
void assignMaxVarNDofsPerNode(std::size_t max_dofs)
assign the maximum node dofs
Definition: SystemBase.h:603
virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false)
Reinit scalar varaibles.
Definition: SystemBase.C:445
std::string _dest_name
Definition: SystemBase.h:76
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:93
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual TagID timeVectorTag() const
Ideally, we should not need this API.
Definition: SystemBase.h:293
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:1038
virtual bool matrixTagActive(TagID tag) const
If or not a matrix tag is active.
Definition: SystemBase.C:1150
virtual TagID nonTimeVectorTag() const
Definition: SystemBase.h:303
virtual void reinitNeighborFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Compute the values of the variables at all the current points.
Definition: SystemBase.C:375
std::size_t getMaxVarNDofsPerNode() const
Gets the maximum number of dofs used by any one variable on any one node.
Definition: SystemBase.h:593
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
libMesh::SparseMatrix< Number > & addMatrix(TagID tag)
Adds a matrix with a given tag.
Definition: SystemBase.C:571
virtual void addDotVectors()
Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator.
Definition: SystemBase.C:1622
NumericVector< Real > * _saved_dot_old
Definition: SystemBase.h:1034
const std::vector< dof_id_type > & getVariableGlobalDoFs()
Get the global dof indices of a variable, this needs to be called after the indices have been set by ...
Definition: SystemBase.h:845
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.h:1087
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1158
std::string _timestep
Definition: SystemBase.h:78
VarCopyInfo(const std::string &dest_name, const std::string &source_name, const std::string &timestep)
Definition: SystemBase.h:69
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition: SystemBase.C:668
virtual void reinitNeighbor(const Elem *elem, THREAD_ID tid)
Compute the values of the variables at all the current points.
Definition: SystemBase.C:383
virtual void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time, libMesh::ParallelType parallel_type=GHOSTED)
Registers that the solution state state is needed.
Definition: SystemBase.C:1452
const std::vector< std::shared_ptr< TimeIntegrator > > & getTimeIntegrators()
Definition: SystemBase.C:1684
const FEProblemBase & feProblem() const
Definition: SystemBase.h:105
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition: SystemBase.C:852
std::size_t getMaxVarNDofsPerElem() const
Gets the maximum number of dofs used by any one variable on any one element.
Definition: SystemBase.h:586
virtual TagID systemMatrixTag() const
Return the Matrix Tag ID for System.
Definition: SystemBase.h:298
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
Definition: SystemBase.h:998
virtual void copySolutionsBackwards()
Copy current solution into old and older.
Definition: SystemBase.C:1259
virtual TagID residualVectorTag() const
Definition: SystemBase.h:308
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
Definition: SystemBase.h:320
virtual void postInit()
Definition: SystemBase.h:163
virtual void solve()
Solve the system (using libMesh magic)
Definition: SystemBase.C:1250
void assignMaxVarNDofsPerElem(std::size_t max_dofs)
assign the maximum element dofs
Definition: SystemBase.h:598
std::string _name
The name of this system.
Definition: SystemBase.h:993
MooseApp & _app
Definition: SystemBase.h:988
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a scalar variable with specified number.
Definition: SystemBase.C:146
virtual void saveOldSolutions()
Save the old and older solutions.
Definition: SystemBase.C:511
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Base class for time integrators.
virtual void subdomainSetup()
Definition: SystemBase.C:1581
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
bool _verbose
True if printing out additional information.
Definition: SystemBase.h:1058
void removeVector(const std::string &name)
Remove a vector from the system with the given name.
Definition: SystemBase.C:1336
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
unsigned int nFVVariables() const
Get the number of finite volume variables in this system.
Definition: SystemBase.C:911
MooseMesh & _mesh
Definition: SystemBase.h:991
NumericVector< Number > * _u_dot
solution vector for u^dot
Definition: SystemBase.h:1006
virtual void addVariableToZeroOnResidual(std::string var_name)
Adds this variable to the list of variables to be zeroed during each residual evaluation.
Definition: SystemBase.C:175
virtual void preInit()
This is called prior to the libMesh system has been init&#39;d.
Definition: SystemBase.h:157
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:112
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1025
const NumericVector< Number > & solutionOld() const
Definition: SystemBase.h:201
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
Definition: SystemBase.C:411
virtual void zeroVariablesForJacobian()
Zero out the solution for the variables that were registered as needing to have their solutions zeroe...
Definition: SystemBase.C:236
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
Definition: SystemBase.h:313
TagName oldSolutionStateVectorName(const unsigned int, Moose::SolutionIterationType iteration_type) const
Gets the vector name used for an old (not current) solution state.
Definition: SystemBase.C:1383
NumericVector< Real > * _saved_old
Definition: SystemBase.h:1030
Class for scalar variables (they are different).
std::string prefix() const
Definition: SystemBase.C:1702
libMesh::ParallelType solutionStateParallelType(const unsigned int state, const Moose::SolutionIterationType iteration_type) const
Returns the parallel type of the given solution state.
Definition: SystemBase.C:1442
NumericVector< Real > * _saved_dotdot_old
Definition: SystemBase.h:1035
virtual void reinit()
Reinitialize the system when the degrees of freedom in this system have changed.
Definition: SystemBase.h:169
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:863
virtual std::vector< Number > & duDotDus()
Definition: SystemBase.h:257
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
Definition: SystemBase.C:257
virtual void copyPreviousFixedPointSolutions()
Definition: SystemBase.C:1304
virtual void addVariableToZeroOnJacobian(std::string var_name)
Adds this variable to the list of variables to be zeroed during each Jacobian evaluation.
Definition: SystemBase.C:181
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1079
virtual const NumericVector< Number > * solutionPreviousNewton() const
Definition: SystemBase.C:1357
virtual void customSetup(const ExecFlagType &exec_type)
Definition: SystemBase.C:1574
const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable&#39;s equation.
Definition: SystemBase.C:1662
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
Definition: SystemBase.h:764
unsigned int getMaxVariableNumber() const
Returns the maximum number of all variables on the system.
Definition: SystemBase.h:870
virtual bool isScalarVariable(unsigned int var_name) const
Definition: SystemBase.C:886
unsigned int nFieldVariables() const
Get the number of field variables in this system.
Definition: SystemBase.C:901
void getStandardFieldVariableNames(std::vector< VariableName > &std_field_variables) const
virtual void computeVariables(const NumericVector< Number > &)
Definition: SystemBase.h:872
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Reinit assembly info for a side of an element.
Definition: SystemBase.C:367
virtual void prepareLowerD(THREAD_ID tid)
Prepare the system for use for lower dimensional elements.
Definition: SystemBase.C:333
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:91
virtual const NumericVector< Number > * solutionUDotDot() const
Definition: SystemBase.h:267
Real Number
virtual NumericVector< Number > * solutionUDotDot()
Definition: SystemBase.h:263
virtual const NumericVector< Number > * solutionUDotOld() const
Definition: SystemBase.h:268
void setVariableGlobalDoFs(const std::string &var_name)
set all the global dof indices for a variable
Definition: SystemBase.C:187
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:1021
NumericVector< Number > & solutionOld()
Definition: SystemBase.h:198
SystemBase(SubProblem &subproblem, FEProblemBase &fe_problem, const std::string &name, Moose::VarKindType var_kind)
Definition: SystemBase.C:57
virtual bool hasScalarVariable(const std::string &var_name) const
Definition: SystemBase.C:877
MooseVariableFE< VectorValue< Real > > VectorMooseVariable
Definition: SystemBase.h:35
Moose::VarKindType varKind() const
Definition: SystemBase.h:927
virtual void augmentSendList(std::vector< dof_id_type > &send_list)
Will modify the send_list to add all of the extra ghosted dofs for this system.
Definition: SystemBase.C:453
virtual NumericVector< Number > & residualGhosted()
Definition: SystemBase.h:431
MooseVariableFE< Real > MooseVariable
Definition: SystemBase.h:33
virtual void initialSetup()
Setup Functions.
Definition: SystemBase.C:1560
virtual void restoreSolutions()
Restore current solutions (call after your solve failed)
Definition: SystemBase.C:1319
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:934
virtual void residualSetup()
Definition: SystemBase.C:1588
const SubProblem & subproblem() const
Definition: SystemBase.h:103
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1081
virtual void disassociateDefaultMatrixTags()
Disassociate the matrices associated with the default matrix tags of this system. ...
Definition: SystemBase.C:1111
void skipNextSolutionToOldCopy()
Skip the next copy from the solution vector to the old solution vector old -> older is still performe...
Definition: SystemBase.h:973
void clearAllDofIndices()
Clear all dof indices from moose variables.
Definition: SystemBase.C:1602
unsigned int _max_var_number
Maximum variable number.
Definition: SystemBase.h:1000
virtual void zeroVariables(std::vector< std::string > &vars_to_be_zeroed)
Zero out the solution for the list of variables passed in.
Definition: SystemBase.C:201
virtual void restoreOldSolutions()
Restore the old and older solutions when the saved solutions present.
Definition: SystemBase.C:543
void flushTaggedMatrices(const std::set< TagID > &tags)
flushes all matrices associated to tags.
Definition: SystemBase.C:1069
const NumericVector< Number > & solutionOlder() const
Definition: SystemBase.h:202
SolutionIterationType
Definition: MooseTypes.h:269
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
Definition: SystemBase.h:1013
unsigned int THREAD_ID
Definition: MooseTypes.h:237
virtual void timestepSetup()
Definition: SystemBase.C:1567
MooseVariableField< T > & getActualFieldVariable(THREAD_ID tid, const std::string &var_name)
Returns a field variable pointer - this includes finite volume variables.
Definition: SystemBase.C:119