https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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"
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
29class Factory;
30class MooseApp;
32template <typename>
33class MooseVariableFE;
36class MooseMesh;
37class SubProblem;
38class SystemBase;
39class TimeIntegrator;
40class InputParameters;
41class FEProblemBase;
42
43// libMesh forward declarations
44namespace libMesh
45{
46class System;
47class DofMap;
48class FEType;
49}
50
54void 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{
88public:
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
189 void copyOldSolutions();
193 void copyPreviousSolutions(const Moose::SolutionIterationType iteration_type);
194
195 virtual void restoreSolutions();
196
201 virtual const NumericVector<Number> * const & currentSolution() const = 0;
202
203 NumericVector<Number> & solution() { return solutionState(0); }
204 NumericVector<Number> & solutionOld() { return solutionState(1); }
205 NumericVector<Number> & solutionOlder() { return solutionState(2); }
206 const NumericVector<Number> & solution() const { return solutionState(0); }
207 const NumericVector<Number> & solutionOld() const { return solutionState(1); }
208 const NumericVector<Number> & solutionOlder() const { return solutionState(2); }
209
210 virtual const NumericVector<Number> * solutionPreviousNewton() const;
211 virtual NumericVector<Number> * solutionPreviousNewton();
212
216 virtual void initSolutionState();
217
221 const std::vector<NumericVector<Number> *> &
222 getSolutionStates(const Moose::SolutionIterationType iteration_type) const;
223
228 std::size_t getNumSolutionStates(const Moose::SolutionIterationType iteration_type) const;
229
236 virtual NumericVector<Number> &
237 solutionState(const unsigned int state,
239
243 virtual const NumericVector<Number> & solutionState(
244 const unsigned int state,
246
251 solutionStateParallelType(const unsigned int state,
252 const Moose::SolutionIterationType iteration_type) const;
253
257 virtual void needSolutionState(
258 const unsigned int state,
260 libMesh::ParallelType parallel_type = GHOSTED);
261
265 virtual bool hasSolutionState(
266 const unsigned int state,
268
273 virtual void addDotVectors();
274
275 virtual std::vector<Number> & duDotDus() { return _du_dot_du; }
276 virtual Number & duDotDotDu() { return _du_dotdot_du; }
277 virtual const Number & duDotDu(unsigned int var_num = 0) const;
278 virtual const Number & duDotDotDu() const { return _du_dotdot_du; }
279
280 virtual NumericVector<Number> * solutionUDot() { return _u_dot; }
281 virtual NumericVector<Number> * solutionUDotDot() { return _u_dotdot; }
282 virtual NumericVector<Number> * solutionUDotOld() { return _u_dot_old; }
283 virtual NumericVector<Number> * solutionUDotDotOld() { return _u_dotdot_old; }
284 virtual const NumericVector<Number> * solutionUDot() const { return _u_dot; }
285 virtual const NumericVector<Number> * solutionUDotDot() const { return _u_dotdot; }
286 virtual const NumericVector<Number> * solutionUDotOld() const { return _u_dot_old; }
287 virtual const NumericVector<Number> * solutionUDotDotOld() const { return _u_dotdot_old; }
288
289 virtual void saveOldSolutions();
290 virtual void restoreOldSolutions();
291
295 bool hasVector(const std::string & tag_name) const;
296
300 virtual bool hasVector(TagID tag_id) const
301 {
302 return tag_id < _tagged_vectors.size() && _tagged_vectors[tag_id];
303 }
304
311 virtual TagID timeVectorTag() const { mooseError("Not implemented yet"); }
312
316 virtual TagID systemMatrixTag() const { mooseError("Not implemented yet"); }
317
318 /*
319 * Return TagID for nontime
320 */
321 virtual TagID nonTimeVectorTag() const { mooseError("Not implemented yet"); }
322
323 /*
324 * Return TagID for nontime
325 */
326 virtual TagID residualVectorTag() const { mooseError("Not implemented yet"); }
327
331 virtual std::set<TagID> defaultVectorTags() const
332 {
334 }
338 virtual std::set<TagID> defaultMatrixTags() const { return {systemMatrixTag()}; }
339
344 virtual NumericVector<Number> & getVector(const std::string & name);
345 virtual const NumericVector<Number> & getVector(const std::string & name) const;
347
352 virtual NumericVector<Number> & getVector(TagID tag);
353 virtual const NumericVector<Number> & getVector(TagID tag) const;
355
359 virtual void associateVectorToTag(NumericVector<Number> & vec, TagID tag);
360
364 virtual void disassociateVectorFromTag(NumericVector<Number> & vec, TagID tag);
365
369 virtual void disassociateVectorFromTag(TagID tag);
370
374 virtual void disassociateDefaultVectorTags();
375
379 virtual bool hasMatrix(TagID tag) const
380 {
381 return tag < _tagged_matrices.size() && _tagged_matrices[tag];
382 }
383
388
392 virtual const libMesh::SparseMatrix<Number> & getMatrix(TagID tag) const;
393
397 virtual void activateAllMatrixTags();
398
402 virtual bool matrixTagActive(TagID tag) const;
403
407 virtual void deactivateAllMatrixTags();
408
412 void closeTaggedMatrices(const std::set<TagID> & tags);
413
418 void flushTaggedMatrices(const std::set<TagID> & tags);
419
423 virtual void associateMatrixToTag(libMesh::SparseMatrix<Number> & matrix, TagID tag);
424
429
433 virtual void disassociateMatrixFromTag(TagID tag);
434
438 virtual void disassociateDefaultMatrixTags();
439
443 virtual NumericVector<Number> & serializedSolution();
444
445 virtual NumericVector<Number> & residualCopy()
446 {
447 mooseError("This system does not support getting a copy of the residual");
448 }
449 virtual NumericVector<Number> & residualGhosted()
450 {
451 mooseError("This system does not support getting a ghosted copy of the residual");
452 }
453
457 virtual void augmentSendList(std::vector<dof_id_type> & send_list);
458
463 std::vector<dof_id_type> & n_nz,
464 std::vector<dof_id_type> & n_oz) = 0;
465
472 virtual void addVariable(const std::string & var_type,
473 const std::string & var_name,
474 InputParameters & parameters);
475
479 virtual bool isArrayVariable(const std::string & var_name) const;
480
482
488 virtual bool hasVariable(const std::string & var_name) const;
489 virtual bool hasScalarVariable(const std::string & var_name) const;
491
492 virtual bool isScalarVariable(unsigned int var_name) const;
493
501 MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string & var_name) const;
502
510 MooseVariableFieldBase & getVariable(THREAD_ID tid, unsigned int var_number) const;
511
521 template <typename T>
522 MooseVariableFE<T> & getFieldVariable(THREAD_ID tid, const std::string & var_name);
523
527 template <typename T>
528 MooseVariableField<T> & getActualFieldVariable(THREAD_ID tid, const std::string & var_name);
529
539 template <typename T>
540 MooseVariableFE<T> & getFieldVariable(THREAD_ID tid, unsigned int var_number);
541
545 template <typename T>
546 MooseVariableField<T> & getActualFieldVariable(THREAD_ID tid, unsigned int var_number);
547
551 template <typename T>
552 MooseVariableFV<T> & getFVVariable(THREAD_ID tid, const std::string & var_name);
553
562 const std::string & var_name) const;
563
571 virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, unsigned int var_number) const;
572
579 virtual const std::set<SubdomainID> * getVariableBlocks(unsigned int var_number);
580
585 virtual unsigned int nVariables() const;
586
591 unsigned int nFieldVariables() const;
592
597 unsigned int nFVVariables() const;
598
604 std::size_t getMaxVarNDofsPerElem() const { return _max_var_n_dofs_per_elem; }
605
611 std::size_t getMaxVarNDofsPerNode() const { return _max_var_n_dofs_per_node; }
612
616 void assignMaxVarNDofsPerElem(std::size_t max_dofs) { _max_var_n_dofs_per_elem = max_dofs; }
617
621 void assignMaxVarNDofsPerNode(std::size_t max_dofs) { _max_var_n_dofs_per_node = max_dofs; }
622
627 virtual void addVariableToZeroOnResidual(std::string var_name);
628
633 virtual void addVariableToZeroOnJacobian(std::string var_name);
634
641 virtual void zeroVariables(std::vector<std::string> & vars_to_be_zeroed);
642
647 virtual void zeroVariablesForResidual();
648
653 virtual void zeroVariablesForJacobian();
654
660
665 virtual void prepare(THREAD_ID tid);
666
676 virtual void prepareFace(THREAD_ID tid, bool resize_data);
677
682 virtual void prepareNeighbor(THREAD_ID tid);
683
688 virtual void prepareLowerD(THREAD_ID tid);
689
695 virtual void reinitElem(const Elem * elem, THREAD_ID tid);
696
703 virtual void reinitElemFace(const Elem * elem, unsigned int side, THREAD_ID tid);
704
708 virtual void reinitNeighborFace(const Elem * elem, unsigned int side, THREAD_ID tid);
709
713 virtual void reinitNeighbor(const Elem * elem, THREAD_ID tid);
714
718 virtual void reinitLowerD(THREAD_ID tid);
719
725 virtual void reinitNode(const Node * node, THREAD_ID tid);
726
733 virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, THREAD_ID tid);
734
740 virtual void reinitNodes(const std::vector<dof_id_type> & nodes, THREAD_ID tid);
741
747 virtual void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, THREAD_ID tid);
748
755 virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering = false);
756
766 virtual void addVariableToCopy(const std::string & dest_name,
767 const std::string & source_name,
768 const std::string & timestep);
769
770 const std::vector<MooseVariableFieldBase *> & getVariables(THREAD_ID tid)
771 {
772 return _vars[tid].fieldVariables();
773 }
774
775 const VariableWarehouse & variableWarehouse(THREAD_ID tid = 0) const { return _vars[tid]; }
776
777 const std::vector<MooseVariableScalar *> & getScalarVariables(THREAD_ID tid)
778 {
779 return _vars[tid].scalars();
780 }
781
782 const std::set<SubdomainID> & getSubdomainsForVar(unsigned int var_number) const
783 {
784 return _var_map.at(var_number);
785 }
786
793 const std::set<SubdomainID> & getSubdomainsForVar(const std::string & var_name) const;
794
798 void removeVector(const std::string & name);
799
813 NumericVector<Number> &
814 addVector(const std::string & vector_name, const bool project, const libMesh::ParallelType type);
815
829 NumericVector<Number> &
830 addVector(TagID tag, const bool project, const libMesh::ParallelType type);
831
835 void closeTaggedVector(const TagID tag);
839 void closeTaggedVectors(const std::set<TagID> & tags);
840
844 void zeroTaggedVector(const TagID tag);
848 void zeroTaggedVectors(const std::set<TagID> & tags);
849
855 void removeVector(TagID tag_id);
856
859 void setVariableGlobalDoFs(const std::string & var_name);
860
863 const std::vector<dof_id_type> & getVariableGlobalDoFs() { return _var_all_dof_indices; }
864
871
877 void removeMatrix(TagID tag);
878
879 virtual const std::string & name() const;
880
881 const std::vector<VariableName> & getVariableNames() const { return _vars[0].names(); }
882
883 void getStandardFieldVariableNames(std::vector<VariableName> & std_field_variables) const;
884
888 unsigned int getMaxVariableNumber() const { return _max_var_number; }
889
890 virtual void computeVariables(const NumericVector<Number> & /*soln*/) {}
891
893
897 virtual void copySolutionsBackwards();
898
899 void addTimeIntegrator(const std::string & type,
900 const std::string & name,
901 InputParameters & parameters);
902
904 bool hasVarCopy() const { return _var_to_copy.size() > 0; }
905
909 void addScalingVector();
910
918
920 virtual void initialSetup();
921 virtual void timestepSetup();
922 virtual void customSetup(const ExecFlagType & exec_type);
923 virtual void subdomainSetup();
924 virtual void residualSetup();
925 virtual void jacobianSetup();
926
930 void clearAllDofIndices();
931
935 void setActiveVariableCoupleableVectorTags(const std::set<TagID> & vtags, THREAD_ID tid);
936
940 void setActiveScalarVariableCoupleableVectorTags(const std::set<TagID> & vtags, THREAD_ID tid);
941
946
951 virtual void compute(ExecFlagType type) = 0;
952
956 void copyTimeIntegrators(const SystemBase & other_sys);
957
961 const TimeIntegrator & getTimeIntegrator(const unsigned int var_num) const;
962
968 const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const;
969
973 const std::vector<std::shared_ptr<TimeIntegrator>> & getTimeIntegrators();
974
980 std::string prefix() const;
981
986
992
993protected:
997 virtual NumericVector<Number> & solutionInternal() const = 0;
998
1002
1005
1008
1011 std::string _name;
1012
1014 std::vector<VariableWarehouse> _vars;
1016 std::map<unsigned int, std::set<SubdomainID>> _var_map;
1018 unsigned int _max_var_number;
1019
1020 std::vector<std::string> _vars_to_be_zeroed_on_residual;
1021 std::vector<std::string> _vars_to_be_zeroed_on_jacobian;
1022
1024 NumericVector<Number> * _u_dot;
1026 NumericVector<Number> * _u_dotdot;
1027
1029 NumericVector<Number> * _u_dot_old;
1031 NumericVector<Number> * _u_dotdot_old;
1032
1035 std::vector<Real> _du_dot_du;
1037
1039 std::vector<NumericVector<Number> *> _tagged_vectors;
1041 std::vector<libMesh::SparseMatrix<Number> *> _tagged_matrices;
1043 std::unordered_map<TagID, libMesh::SparseMatrix<Number> *> _active_tagged_matrices;
1045 std::vector<bool> _matrix_tag_active_flags;
1046
1047 // Used for saving old solutions so that they wont be accidentally changed
1048 NumericVector<Real> * _saved_old;
1049 NumericVector<Real> * _saved_older;
1050
1051 // Used for saving old u_dot and u_dotdot so that they wont be accidentally changed
1052 NumericVector<Real> * _saved_dot_old;
1053 NumericVector<Real> * _saved_dotdot_old;
1054
1057
1058 std::vector<VarCopyInfo> _var_to_copy;
1059
1062
1065
1067 std::vector<std::shared_ptr<TimeIntegrator>> _time_integrators;
1068
1070 std::vector<std::vector<MooseVariableFieldBase *>> _numbered_vars;
1071
1074
1077
1080
1082 std::vector<dof_id_type> _var_all_dof_indices;
1083
1086 std::unique_ptr<NumericVector<Number>> _serialized_solution;
1087
1088private:
1092 TagName oldSolutionStateVectorName(const unsigned int,
1093 Moose::SolutionIterationType iteration_type) const;
1094
1098 std::vector<NumericVector<Number> *> &
1100 {
1101 return const_cast<std::vector<NumericVector<Number> *> &>(
1102 static_cast<const SystemBase *>(this)->getSolutionStates(iteration_type));
1103 }
1104
1114 std::array<std::vector<NumericVector<Number> *>,
1115 static_cast<size_t>(Moose::SolutionIterationType::Count)>
1118 std::vector<NumericVector<Number> *> _saved_solution_states;
1121};
1122
1123inline const std::vector<NumericVector<Number> *> &
1125{
1126 const auto iteration_type_index = static_cast<std::size_t>(iteration_type);
1127 mooseAssert(iteration_type_index < static_cast<std::size_t>(Moose::SolutionIterationType::Count),
1128 "Invalid solution iteration type");
1129 mooseAssert(iteration_type_index < _solution_states.size(), "_solution_states sized incorrectly");
1130 return _solution_states[iteration_type_index];
1131}
1132
1133inline std::size_t
1135{
1136 return getSolutionStates(iteration_type).size();
1137}
1138
1139inline bool
1140SystemBase::hasSolutionState(const unsigned int state,
1141 const Moose::SolutionIterationType iteration_type) const
1142{
1143 return getNumSolutionStates(iteration_type) > state;
1144}
1145
1146#define PARALLEL_TRY
1147
1148#define PARALLEL_CATCH _fe_problem.checkExceptionAndStopSolve();
boundary_id_type BoundaryID
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
unsigned int TagID
Definition MooseTypes.h:238
unsigned int THREAD_ID
Definition MooseTypes.h:237
void extraSendList(std::vector< dof_id_type > &send_list, void *context)
///< Type of coordinate system
MooseVariableFE< Real > MooseVariable
Definition SystemBase.h:34
MooseVariableFE< VectorValue< Real > > VectorMooseVariable
Definition SystemBase.h:35
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.
An inteface for the _console for outputting to the Console object.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Generic factory class for build all sorts of objects.
Definition Factory.h:29
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Base class for MOOSE-based applications.
Definition MooseApp.h:110
Class for containing MooseEnum item information.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
Class for stuff related to variables.
This class provides variable solution values for other classes/objects to bind to when looping over f...
This class provides an interface for common operations on field variables of both FE and FV types wit...
Class for stuff related to variables.
Class for scalar variables (they are different).
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
Base class for a system (of equations)
Definition SystemBase.h:87
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed.
virtual NumericVector< Number > & residualCopy()
Definition SystemBase.h:445
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition SystemBase.C:692
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
void zeroTaggedVector(const TagID tag)
Zero vector with the given tag.
Definition SystemBase.C:673
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
NumericVector< Number > * _u_dot
solution vector for u^dot
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:325
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
virtual void reinitNode(const Node *node, THREAD_ID tid)
Reinit nodal assembly info.
Definition SystemBase.C:399
virtual void postInit()
Definition SystemBase.h:163
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 copySolutionsBackwards()
Copy current solution into old and older.
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 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.
bool _solution_states_initialized
Whether or not the solution states have been initialized.
virtual ~SystemBase()
Definition SystemBase.h:93
bool automaticScaling() const
Getter for whether we are performing automatic scaling.
Definition SystemBase.h:123
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
MooseApp & _app
virtual const NumericVector< Number > * solutionUDotDotOld() const
Definition SystemBase.h:287
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
Definition SystemBase.h:338
virtual void deactivateAllMatrixTags()
Make matrices inactive.
virtual const Number & duDotDotDu() const
Definition SystemBase.h:278
virtual NumericVector< Number > & solutionInternal() const =0
Internal getter for solution owned by libMesh.
virtual void reinitElem(const Elem *elem, THREAD_ID tid)
Reinit an element assembly info.
Definition SystemBase.C:341
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
Definition SystemBase.C:423
bool _verbose
True if printing out additional information.
void copyOldSolutions()
Copy the solution back in time (older -> old, etc).
FEProblemBase & _fe_problem
the governing finite element/volume problem
virtual void computeVariables(const NumericVector< Number > &)
Definition SystemBase.h:890
virtual void reinitNeighbor(const Elem *elem, THREAD_ID tid)
Compute the values of the variables at all the current points.
Definition SystemBase.C:383
TagName oldSolutionStateVectorName(const unsigned int, Moose::SolutionIterationType iteration_type) const
Gets the vector name used for an old (not current) solution state.
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
Definition SystemBase.h:782
virtual void subdomainSetup()
void setVerboseFlag(const bool &verbose)
Sets the verbose flag.
Definition SystemBase.h:135
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::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
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:863
void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters &parameters)
std::string prefix() const
std::vector< std::string > _vars_to_be_zeroed_on_residual
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition SystemBase.C:923
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
virtual unsigned int nVariables() const
Get the number of variables in this system.
Definition SystemBase.C:890
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
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 NumericVector< Number > * solutionUDot()
Definition SystemBase.h:280
virtual bool hasVector(TagID tag_id) const
Check if the tagged vector exists in the system.
Definition SystemBase.h:300
virtual bool isArrayVariable(const std::string &var_name) const
If a variable is an array variable.
Definition SystemBase.C:863
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 void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false)
Reinit scalar varaibles.
Definition SystemBase.C:445
unsigned int number() const
Gets the number of this system.
virtual void saveOldSolutions()
Save the old and older solutions.
Definition SystemBase.C:511
virtual const libMesh::System & system() const =0
virtual void restoreOldSolutions()
Restore the old and older solutions when the saved solutions present.
Definition SystemBase.C:542
bool hasVarCopy() const
Whether or not there are variables to be restarted from an Exodus mesh file.
Definition SystemBase.h:904
bool solutionStatesInitialized() const
Whether or not the solution states have been initialized via initSolutionState()
Definition SystemBase.h:917
size_t _max_var_n_dofs_per_node
Maximum number of dofs for any one variable on any one node.
virtual bool isScalarVariable(unsigned int var_name) const
Definition SystemBase.C:884
Factory & _factory
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
const NumericVector< Number > & solutionOlder() const
Definition SystemBase.h:208
Moose::VarKindType varKind() const
Definition SystemBase.h:945
virtual TagID residualVectorTag() const
Definition SystemBase.h:326
virtual void activateAllMatrixTags()
Make all existing matrices active.
unsigned int nFieldVariables() const
Get the number of field variables in this system.
Definition SystemBase.C:899
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.
virtual void compute(ExecFlagType type)=0
Compute time derivatives, auxiliary variables, etc.
const std::vector< VariableName > & getVariableNames() const
Definition SystemBase.h:881
void removeVector(const std::string &name)
Remove a vector from the system with the given name.
virtual void zeroVariablesForResidual()
Zero out the solution for the variables that were registered as needing to have their solutions zeroe...
Definition SystemBase.C:230
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters &parameters)
Canonical method for adding a variable.
Definition SystemBase.C:717
const SubProblem & subproblem() const
Definition SystemBase.h:103
MooseVariableFV< T > & getFVVariable(THREAD_ID tid, const std::string &var_name)
Return a finite volume variable.
Definition SystemBase.C:126
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....
std::string _name
The name of this system.
virtual void addDotVectors()
Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition SystemBase.C:932
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.
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
Definition SystemBase.h:770
virtual void initializeObjects()
Called only once, just before the solve begins so objects can do some precalculations.
Definition SystemBase.h:174
virtual bool matrixTagActive(TagID tag) const
If or not a matrix tag is active.
virtual void customSetup(const ExecFlagType &exec_type)
NumericVector< Number > & solutionOld()
Definition SystemBase.h:204
const TimeIntegrator & getTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable's equation.
unsigned int nFVVariables() const
Get the number of finite volume variables in this system.
Definition SystemBase.C:909
virtual void disassociateMatrixFromTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
void setActiveScalarVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the scalar variables.
NumericVector< Real > * _saved_dotdot_old
SubProblem & subproblem()
Definition SystemBase.h:102
void setVariableGlobalDoFs(const std::string &var_name)
set all the global dof indices for a variable
Definition SystemBase.C:187
virtual void initialSetup()
Setup Functions.
virtual NumericVector< Number > & residualGhosted()
Definition SystemBase.h:449
virtual void initSolutionState()
Initializes the solution state.
virtual void timestepSetup()
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition SystemBase.C:980
virtual void jacobianSetup()
virtual void residualSetup()
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
void automaticScaling(bool automatic_scaling)
Setter for whether we are performing automatic scaling.
Definition SystemBase.h:129
bool computingScalingJacobian() const
Whether we are computing an initial Jacobian for automatic variable scaling.
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
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
const NumericVector< Number > & solutionOld() const
Definition SystemBase.h:207
std::vector< Real > _du_dot_du
Derivative of time derivative of u with respect to uj.
virtual void preInit()
This is called prior to the libMesh system has been init'd.
Definition SystemBase.h:157
virtual void disassociateDefaultVectorTags()
Disassociate the vectors associated with the default vector tags of this system.
virtual void restoreSolutions()
Restore current solutions (call after your solve failed)
std::array< std::vector< NumericVector< Number > * >, static_cast< size_t >(Moose::SolutionIterationType::Count)> _solution_states
2D array of solution state vector pointers.
libMesh::ParallelType solutionStateParallelType(const unsigned int state, const Moose::SolutionIterationType iteration_type) const
Returns the parallel type of the given solution state.
virtual void reinitLowerD(THREAD_ID tid)
Compute the values of the variables on the lower dimensional element.
Definition SystemBase.C:391
void getStandardFieldVariableNames(std::vector< VariableName > &std_field_variables) const
virtual NumericVector< Number > * solutionUDotOld()
Definition SystemBase.h:282
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
Definition SystemBase.C:992
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:257
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition SystemBase.C:666
std::size_t getNumSolutionStates(const Moose::SolutionIterationType iteration_type) const
Get the number of solution states (0 = current, 1 = current + old, ...) for the given iteration type.
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
std::vector< NumericVector< Number > * > & getSolutionStates(const Moose::SolutionIterationType iteration_type)
Get all of the solution states (current, old, ...) for the given iteration type.
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 bool hasScalarVariable(const std::string &var_name) const
Definition SystemBase.C:875
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 reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
Definition SystemBase.C:411
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
void copyPreviousSolutions(const Moose::SolutionIterationType iteration_type)
Copy a specific type of solution back in time (older -> old, etc).
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition SystemBase.C:850
void skipNextSolutionToOldCopy()
Skip the next copy from the solution vector to the old solution vector old -> older is still performe...
Definition SystemBase.h:991
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
unsigned int getMaxVariableNumber() const
Returns the maximum number of all variables on the system.
Definition SystemBase.h:888
virtual const NumericVector< Number > * solutionPreviousNewton() const
const FEProblemBase & feProblem() const
Definition SystemBase.h:105
const std::vector< std::shared_ptr< TimeIntegrator > > & getTimeIntegrators()
const std::vector< NumericVector< Number > * > & getSolutionStates(const Moose::SolutionIterationType iteration_type) const
Get all of the solution states (current, old, ...) for the given iteration type.
virtual const Number & duDotDu(unsigned int var_num=0) const
void flushTaggedMatrices(const std::set< TagID > &tags)
flushes all matrices associated to tags.
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
FEProblemBase & feProblem()
Definition SystemBase.h:104
virtual const NumericVector< Number > * solutionUDotOld() const
Definition SystemBase.h:286
void applyScalingFactors(const std::vector< Real > &inverse_scaling_factors)
Applies scaling factors to the system's variables.
NumericVector< Real > * _saved_dot_old
virtual const NumericVector< Number > * solutionUDot() const
Definition SystemBase.h:284
Moose::VarKindType _var_kind
default kind of variables in this system
virtual void associateMatrixToTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
libMesh::SparseMatrix< Number > & addMatrix(TagID tag)
Adds a matrix with a given tag.
Definition SystemBase.C:569
void clearAllDofIndices()
Clear all dof indices from moose variables.
NumericVector< Number > & solutionOlder()
Definition SystemBase.h:205
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
virtual const std::string & name() const
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition SystemBase.h:379
void addScalingVector()
Add the scaling factor vector to the system.
virtual TagID timeVectorTag() const
Ideally, we should not need this API.
Definition SystemBase.h:311
void copyTimeIntegrators(const SystemBase &other_sys)
Copy time integrators from another 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).
unsigned int _max_var_number
Maximum variable number.
std::size_t getMaxVarNDofsPerElem() const
Gets the maximum number of dofs used by any one variable on any one element.
Definition SystemBase.h:604
virtual std::vector< Number > & duDotDus()
Definition SystemBase.h:275
virtual void disassociateDefaultMatrixTags()
Disassociate the matrices associated with the default matrix tags of this system.
void copyVars(libMesh::ExodusII_IO &io)
virtual TagID systemMatrixTag() const
Return the Matrix Tag ID for System.
Definition SystemBase.h:316
void removeMatrix(TagID tag)
Removes a matrix with a given tag.
Definition SystemBase.C:589
void assignMaxVarNDofsPerElem(std::size_t max_dofs)
assign the maximum element dofs
Definition SystemBase.h:616
const VariableWarehouse & variableWarehouse(THREAD_ID tid=0) const
Definition SystemBase.h:775
void setActiveVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the variables.
MooseMesh & mesh()
Definition SystemBase.h:100
bool _skip_next_solution_to_old_copy
Whether to skip the next copy from the solution to the old vector.
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
size_t _max_var_n_dofs_per_elem
Maximum number of dofs for any one variable on any one element.
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
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,...
std::vector< VarCopyInfo > _var_to_copy
NumericVector< Number > & solution()
Definition SystemBase.h:203
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
bool _automatic_scaling
Whether to automatically scale the variables.
NumericVector< Real > * _saved_old
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)
std::size_t getMaxVarNDofsPerNode() const
Gets the maximum number of dofs used by any one variable on any one node.
Definition SystemBase.h:611
NumericVector< Real > * _saved_older
virtual NumericVector< Number > * solutionUDotDotOld()
Definition SystemBase.h:283
void sizeVariableMatrixData()
size the matrix data for each variable for the number of matrix tags we have
virtual Number & duDotDotDu()
Definition SystemBase.h:276
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
std::vector< dof_id_type > _var_all_dof_indices
Container for the dof indices of a given variable.
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
Definition SystemBase.h:777
const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable's equation.
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
Definition SystemBase.C:607
virtual libMesh::Order getMinQuadratureOrder()
Get minimal quadrature order needed for integrating variables in this system.
Definition SystemBase.C:242
void update()
Update the system (doing libMesh magic)
virtual const NumericVector< Number > * solutionUDotDot() const
Definition SystemBase.h:285
virtual void prepareFace(THREAD_ID tid, bool resize_data)
Prepare the system for use on sides.
Definition SystemBase.C:280
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
Definition SystemBase.h:331
void closeTaggedVector(const TagID tag)
Close vector with the given tag.
Definition SystemBase.C:648
const NumericVector< Number > & solution() const
Definition SystemBase.h:206
virtual void solve()
Solve the system (using libMesh magic)
void assignMaxVarNDofsPerNode(std::size_t max_dofs)
assign the maximum node dofs
Definition SystemBase.h:621
virtual void reinit()
Reinitialize the system when the degrees of freedom in this system have changed.
Definition SystemBase.h:169
Real _du_dotdot_du
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > * solutionUDotDot()
Definition SystemBase.h:281
virtual TagID nonTimeVectorTag() const
Definition SystemBase.h:321
MooseMesh & _mesh
const MooseMesh & mesh() const
Definition SystemBase.h:101
virtual NumericVector< Number > & serializedSolution()
Returns a reference to a serialized version of the solution vector for this subproblem.
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
Map variable number to its pointer.
virtual void prepareLowerD(THREAD_ID tid)
Prepare the system for use for lower dimensional elements.
Definition SystemBase.C:333
Base class for time integrators.
Holds variables and provides some services.
SolutionIterationType
Definition MooseTypes.h:270
VarKindType
Framework-wide stuff.
Definition MooseTypes.h:769
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Information about variables that will be copied.
Definition SystemBase.h:68
std::string _dest_name
Definition SystemBase.h:76
std::string _source_name
Definition SystemBase.h:77
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