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();
190
195
199 void copyPreviousSolutions(const Moose::SolutionIterationType iteration_type);
200
202 void restoreStateHistory();
203
204 virtual void restoreSolutions();
205
210 virtual const NumericVector<Number> * const & currentSolution() const = 0;
211
212 NumericVector<Number> & solution() { return solutionState(0); }
213 NumericVector<Number> & solutionOld() { return solutionState(1); }
214 NumericVector<Number> & solutionOlder() { return solutionState(2); }
215 const NumericVector<Number> & solution() const { return solutionState(0); }
216 const NumericVector<Number> & solutionOld() const { return solutionState(1); }
217 const NumericVector<Number> & solutionOlder() const { return solutionState(2); }
218
219 virtual const NumericVector<Number> * solutionPreviousNewton() const;
220 virtual NumericVector<Number> * solutionPreviousNewton();
221
225 virtual void initSolutionState();
226
230 const std::vector<NumericVector<Number> *> &
231 getSolutionStates(const Moose::SolutionIterationType iteration_type) const;
232
237 std::size_t getNumSolutionStates(const Moose::SolutionIterationType iteration_type) const;
238
245 virtual NumericVector<Number> &
246 solutionState(const unsigned int state,
248
252 virtual const NumericVector<Number> & solutionState(
253 const unsigned int state,
255
260 solutionStateParallelType(const unsigned int state,
261 const Moose::SolutionIterationType iteration_type) const;
262
266 virtual void needSolutionState(
267 const unsigned int state,
269 libMesh::ParallelType parallel_type = GHOSTED);
270
274 virtual bool hasSolutionState(
275 const unsigned int state,
277
282 virtual void addDotVectors();
283
284 virtual std::vector<Number> & duDotDus() { return _du_dot_du; }
285 virtual Number & duDotDotDu() { return _du_dotdot_du; }
286 virtual const Number & duDotDu(unsigned int var_num = 0) const;
287 virtual const Number & duDotDotDu() const { return _du_dotdot_du; }
288
289 virtual NumericVector<Number> * solutionUDot() { return _u_dot; }
290 virtual NumericVector<Number> * solutionUDotDot() { return _u_dotdot; }
291 virtual NumericVector<Number> * solutionUDotOld() { return _u_dot_old; }
292 virtual NumericVector<Number> * solutionUDotDotOld() { return _u_dotdot_old; }
293 virtual const NumericVector<Number> * solutionUDot() const { return _u_dot; }
294 virtual const NumericVector<Number> * solutionUDotDot() const { return _u_dotdot; }
295 virtual const NumericVector<Number> * solutionUDotOld() const { return _u_dot_old; }
296 virtual const NumericVector<Number> * solutionUDotDotOld() const { return _u_dotdot_old; }
297
298 virtual void saveOldSolutions();
299 virtual void restoreOldSolutions();
300
304 bool hasVector(const std::string & tag_name) const;
305
309 virtual bool hasVector(TagID tag_id) const
310 {
311 return tag_id < _tagged_vectors.size() && _tagged_vectors[tag_id];
312 }
313
320 virtual TagID timeVectorTag() const { mooseError("Not implemented yet"); }
321
325 virtual TagID systemMatrixTag() const { mooseError("Not implemented yet"); }
326
327 /*
328 * Return TagID for nontime
329 */
330 virtual TagID nonTimeVectorTag() const { mooseError("Not implemented yet"); }
331
332 /*
333 * Return TagID for nontime
334 */
335 virtual TagID residualVectorTag() const { mooseError("Not implemented yet"); }
336
340 virtual std::set<TagID> defaultVectorTags() const
341 {
343 }
347 virtual std::set<TagID> defaultMatrixTags() const { return {systemMatrixTag()}; }
348
353 virtual NumericVector<Number> & getVector(const std::string & name);
354 virtual const NumericVector<Number> & getVector(const std::string & name) const;
356
361 virtual NumericVector<Number> & getVector(TagID tag);
362 virtual const NumericVector<Number> & getVector(TagID tag) const;
364
368 virtual void associateVectorToTag(NumericVector<Number> & vec, TagID tag);
369
373 virtual void disassociateVectorFromTag(NumericVector<Number> & vec, TagID tag);
374
378 virtual void disassociateVectorFromTag(TagID tag);
379
383 virtual void disassociateDefaultVectorTags();
384
388 virtual bool hasMatrix(TagID tag) const
389 {
390 return tag < _tagged_matrices.size() && _tagged_matrices[tag];
391 }
392
397
401 virtual const libMesh::SparseMatrix<Number> & getMatrix(TagID tag) const;
402
406 virtual void activateAllMatrixTags();
407
411 virtual bool matrixTagActive(TagID tag) const;
412
416 virtual void deactivateAllMatrixTags();
417
421 void closeTaggedMatrices(const std::set<TagID> & tags);
422
427 void flushTaggedMatrices(const std::set<TagID> & tags);
428
432 virtual void associateMatrixToTag(libMesh::SparseMatrix<Number> & matrix, TagID tag);
433
438
442 virtual void disassociateMatrixFromTag(TagID tag);
443
447 virtual void disassociateDefaultMatrixTags();
448
452 virtual NumericVector<Number> & serializedSolution();
453
454 virtual NumericVector<Number> & residualCopy()
455 {
456 mooseError("This system does not support getting a copy of the residual");
457 }
458 virtual NumericVector<Number> & residualGhosted()
459 {
460 mooseError("This system does not support getting a ghosted copy of the residual");
461 }
462
466 virtual void augmentSendList(std::vector<dof_id_type> & send_list);
467
472 std::vector<dof_id_type> & n_nz,
473 std::vector<dof_id_type> & n_oz) = 0;
474
481 virtual void addVariable(const std::string & var_type,
482 const std::string & var_name,
483 InputParameters & parameters);
484
488 virtual bool isArrayVariable(const std::string & var_name) const;
489
491
497 virtual bool hasVariable(const std::string & var_name) const;
498 virtual bool hasScalarVariable(const std::string & var_name) const;
500
501 virtual bool isScalarVariable(unsigned int var_name) const;
502
510 MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string & var_name) const;
511
519 MooseVariableFieldBase & getVariable(THREAD_ID tid, unsigned int var_number) const;
520
530 template <typename T>
531 MooseVariableFE<T> & getFieldVariable(THREAD_ID tid, const std::string & var_name);
532
536 template <typename T>
537 MooseVariableField<T> & getActualFieldVariable(THREAD_ID tid, const std::string & var_name);
538
548 template <typename T>
549 MooseVariableFE<T> & getFieldVariable(THREAD_ID tid, unsigned int var_number);
550
554 template <typename T>
555 MooseVariableField<T> & getActualFieldVariable(THREAD_ID tid, unsigned int var_number);
556
560 template <typename T>
561 MooseVariableFV<T> & getFVVariable(THREAD_ID tid, const std::string & var_name);
562
571 const std::string & var_name) const;
572
580 virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, unsigned int var_number) const;
581
588 virtual const std::set<SubdomainID> * getVariableBlocks(unsigned int var_number);
589
594 virtual unsigned int nVariables() const;
595
600 unsigned int nFieldVariables() const;
601
606 unsigned int nFVVariables() const;
607
613 std::size_t getMaxVarNDofsPerElem() const { return _max_var_n_dofs_per_elem; }
614
620 std::size_t getMaxVarNDofsPerNode() const { return _max_var_n_dofs_per_node; }
621
625 void assignMaxVarNDofsPerElem(std::size_t max_dofs) { _max_var_n_dofs_per_elem = max_dofs; }
626
630 void assignMaxVarNDofsPerNode(std::size_t max_dofs) { _max_var_n_dofs_per_node = max_dofs; }
631
636 virtual void addVariableToZeroOnResidual(std::string var_name);
637
642 virtual void addVariableToZeroOnJacobian(std::string var_name);
643
650 virtual void zeroVariables(std::vector<std::string> & vars_to_be_zeroed);
651
656 virtual void zeroVariablesForResidual();
657
662 virtual void zeroVariablesForJacobian();
663
669
674 virtual void prepare(THREAD_ID tid);
675
685 virtual void prepareFace(THREAD_ID tid, bool resize_data);
686
691 virtual void prepareNeighbor(THREAD_ID tid);
692
697 virtual void prepareLowerD(THREAD_ID tid);
698
704 virtual void reinitElem(const Elem * elem, THREAD_ID tid);
705
712 virtual void reinitElemFace(const Elem * elem, unsigned int side, THREAD_ID tid);
713
717 virtual void reinitNeighborFace(const Elem * elem, unsigned int side, THREAD_ID tid);
718
722 virtual void reinitNeighbor(const Elem * elem, THREAD_ID tid);
723
727 virtual void reinitLowerD(THREAD_ID tid);
728
734 virtual void reinitNode(const Node * node, THREAD_ID tid);
735
742 virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, THREAD_ID tid);
743
749 virtual void reinitNodes(const std::vector<dof_id_type> & nodes, THREAD_ID tid);
750
756 virtual void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, THREAD_ID tid);
757
764 virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering = false);
765
775 virtual void addVariableToCopy(const std::string & dest_name,
776 const std::string & source_name,
777 const std::string & timestep);
778
779 const std::vector<MooseVariableFieldBase *> & getVariables(THREAD_ID tid)
780 {
781 return _vars[tid].fieldVariables();
782 }
783
784 const VariableWarehouse & variableWarehouse(THREAD_ID tid = 0) const { return _vars[tid]; }
785
786 const std::vector<MooseVariableScalar *> & getScalarVariables(THREAD_ID tid)
787 {
788 return _vars[tid].scalars();
789 }
790
791 const std::set<SubdomainID> & getSubdomainsForVar(unsigned int var_number) const
792 {
793 return _var_map.at(var_number);
794 }
795
802 const std::set<SubdomainID> & getSubdomainsForVar(const std::string & var_name) const;
803
807 void removeVector(const std::string & name);
808
822 NumericVector<Number> &
823 addVector(const std::string & vector_name, const bool project, const libMesh::ParallelType type);
824
838 NumericVector<Number> &
839 addVector(TagID tag, const bool project, const libMesh::ParallelType type);
840
844 void closeTaggedVector(const TagID tag);
848 void closeTaggedVectors(const std::set<TagID> & tags);
849
853 void zeroTaggedVector(const TagID tag);
857 void zeroTaggedVectors(const std::set<TagID> & tags);
858
864 void removeVector(TagID tag_id);
865
868 void setVariableGlobalDoFs(const std::string & var_name);
869
872 const std::vector<dof_id_type> & getVariableGlobalDoFs() { return _var_all_dof_indices; }
873
880
886 void removeMatrix(TagID tag);
887
888 virtual const std::string & name() const;
889
890 const std::vector<VariableName> & getVariableNames() const { return _vars[0].names(); }
891
892 void getStandardFieldVariableNames(std::vector<VariableName> & std_field_variables) const;
893
897 unsigned int getMaxVariableNumber() const { return _max_var_number; }
898
899 virtual void computeVariables(const NumericVector<Number> & /*soln*/) {}
900
902
906 virtual void copySolutionsBackwards();
907
912
913 void addTimeIntegrator(const std::string & type,
914 const std::string & name,
915 InputParameters & parameters);
916
918 bool hasVarCopy() const { return _var_to_copy.size() > 0; }
919
923 void addScalingVector();
924
932
934 virtual void initialSetup();
935 virtual void timestepSetup();
936 virtual void customSetup(const ExecFlagType & exec_type);
937 virtual void subdomainSetup();
938 virtual void residualSetup();
939 virtual void jacobianSetup();
940
944 void clearAllDofIndices();
945
949 void setActiveVariableCoupleableVectorTags(const std::set<TagID> & vtags, THREAD_ID tid);
950
954 void setActiveScalarVariableCoupleableVectorTags(const std::set<TagID> & vtags, THREAD_ID tid);
955
960
965 virtual void compute(ExecFlagType type) = 0;
966
970 void copyTimeIntegrators(const SystemBase & other_sys);
971
975 const TimeIntegrator & getTimeIntegrator(const unsigned int var_num) const;
976
982 const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const;
983
987 const std::vector<std::shared_ptr<TimeIntegrator>> & getTimeIntegrators();
988
994 std::string prefix() const;
995
1000
1006
1007protected:
1016
1021 virtual void restoreAdditionalStates() {}
1022
1026 virtual NumericVector<Number> & solutionInternal() const = 0;
1027
1031
1034
1037
1040 std::string _name;
1041
1043 std::vector<VariableWarehouse> _vars;
1045 std::map<unsigned int, std::set<SubdomainID>> _var_map;
1047 unsigned int _max_var_number;
1048
1049 std::vector<std::string> _vars_to_be_zeroed_on_residual;
1050 std::vector<std::string> _vars_to_be_zeroed_on_jacobian;
1051
1053 NumericVector<Number> * _u_dot;
1055 NumericVector<Number> * _u_dotdot;
1056
1058 NumericVector<Number> * _u_dot_old;
1060 NumericVector<Number> * _u_dotdot_old;
1061
1064 std::vector<Real> _du_dot_du;
1066
1068 std::vector<NumericVector<Number> *> _tagged_vectors;
1070 std::vector<libMesh::SparseMatrix<Number> *> _tagged_matrices;
1072 std::unordered_map<TagID, libMesh::SparseMatrix<Number> *> _active_tagged_matrices;
1074 std::vector<bool> _matrix_tag_active_flags;
1075
1076 // Used for saving old solutions so that they wont be accidentally changed
1077 NumericVector<Real> * _saved_old;
1078 NumericVector<Real> * _saved_older;
1079
1080 // Used for saving old u_dot and u_dotdot so that they wont be accidentally changed
1081 NumericVector<Real> * _saved_dot_old;
1082 NumericVector<Real> * _saved_dotdot_old;
1083
1086
1087 std::vector<VarCopyInfo> _var_to_copy;
1088
1091
1094
1096 std::vector<std::shared_ptr<TimeIntegrator>> _time_integrators;
1097
1099 std::vector<std::vector<MooseVariableFieldBase *>> _numbered_vars;
1100
1103
1106
1109
1111 std::vector<dof_id_type> _var_all_dof_indices;
1112
1115 std::unique_ptr<NumericVector<Number>> _serialized_solution;
1116
1117private:
1121 TagName oldSolutionStateVectorName(const unsigned int,
1122 Moose::SolutionIterationType iteration_type) const;
1123
1127 std::vector<NumericVector<Number> *> &
1129 {
1130 return const_cast<std::vector<NumericVector<Number> *> &>(
1131 cast_ptr<const SystemBase *>(this)->getSolutionStates(iteration_type));
1132 }
1133
1143 std::array<std::vector<NumericVector<Number> *>,
1144 static_cast<size_t>(Moose::SolutionIterationType::Count)>
1147 std::vector<NumericVector<Number> *> _saved_solution_states;
1150};
1151
1152inline const std::vector<NumericVector<Number> *> &
1154{
1155 const auto iteration_type_index = static_cast<std::size_t>(iteration_type);
1156 mooseAssert(iteration_type_index < static_cast<std::size_t>(Moose::SolutionIterationType::Count),
1157 "Invalid solution iteration type");
1158 mooseAssert(iteration_type_index < _solution_states.size(), "_solution_states sized incorrectly");
1159 return _solution_states[iteration_type_index];
1160}
1161
1162inline std::size_t
1164{
1165 return getSolutionStates(iteration_type).size();
1166}
1167
1168inline bool
1169SystemBase::hasSolutionState(const unsigned int state,
1170 const Moose::SolutionIterationType iteration_type) const
1171{
1172 return getNumSolutionStates(iteration_type) > state;
1173}
1174
1175#define PARALLEL_TRY
1176
1177#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
Definition SystemBase.C:38
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.
Definition SystemBase.C:46
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:454
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:179
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:199
NumericVector< Number > * _u_dot
solution vector for u^dot
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:323
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:397
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:173
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:234
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:296
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
Definition SystemBase.h:347
virtual void deactivateAllMatrixTags()
Make matrices inactive.
virtual const Number & duDotDotDu() const
Definition SystemBase.h:287
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:339
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
Definition SystemBase.C:421
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:899
virtual void reinitNeighbor(const Elem *elem, THREAD_ID tid)
Compute the values of the variables at all the current points.
Definition SystemBase.C:381
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:791
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:373
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:872
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:110
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition SystemBase.C:89
virtual NumericVector< Number > * solutionUDot()
Definition SystemBase.h:289
virtual bool hasVector(TagID tag_id) const
Check if the tagged vector exists in the system.
Definition SystemBase.h:309
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:451
virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false)
Reinit scalar varaibles.
Definition SystemBase.C:443
unsigned int number() const
Gets the number of this system.
virtual void saveOldSolutions()
Save the old and older solutions.
Definition SystemBase.C:509
virtual const libMesh::System & system() const =0
virtual void restoreOldSolutions()
Restore the old and older solutions when the saved solutions present.
Definition SystemBase.C:540
bool hasVarCopy() const
Whether or not there are variables to be restarted from an Exodus mesh file.
Definition SystemBase.h:918
bool solutionStatesInitialized() const
Whether or not the solution states have been initialized via initSolutionState()
Definition SystemBase.h:931
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:217
Moose::VarKindType varKind() const
Definition SystemBase.h:959
virtual TagID residualVectorTag() const
Definition SystemBase.h:335
void restoreStateHistory()
Restore solution vectors and additional system-owned state together.
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
void advanceStateHistory(Moose::SolutionIterationType iteration_type)
Advance solution vectors and additional system-owned state together.
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:890
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:228
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:124
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:779
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:213
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 copyStateHistoryBackwards()
Copy solution vectors and additional system-owned state into older states.
void setVariableGlobalDoFs(const std::string &var_name)
set all the global dof indices for a variable
Definition SystemBase.C:185
virtual void initialSetup()
Setup Functions.
virtual NumericVector< Number > & residualGhosted()
Definition SystemBase.h:458
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:117
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:432
const NumericVector< Number > & solutionOld() const
Definition SystemBase.h:216
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:389
void getStandardFieldVariableNames(std::vector< VariableName > &std_field_variables) const
virtual NumericVector< Number > * solutionUDotOld()
Definition SystemBase.h:291
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:255
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:163
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:144
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:365
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
Definition SystemBase.C:409
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 (current -> old -> older, 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...
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:897
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:295
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:293
Moose::VarKindType _var_kind
default kind of variables in this system
virtual void restoreAdditionalStates()
Restore system-owned state not represented by solution vectors.
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:567
void clearAllDofIndices()
Clear all dof indices from moose variables.
NumericVector< Number > & solutionOlder()
Definition SystemBase.h:214
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:388
void addScalingVector()
Add the scaling factor vector to the system.
virtual TagID timeVectorTag() const
Ideally, we should not need this API.
Definition SystemBase.h:320
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:613
virtual std::vector< Number > & duDotDus()
Definition SystemBase.h:284
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:325
void removeMatrix(TagID tag)
Removes a matrix with a given tag.
Definition SystemBase.C:587
void assignMaxVarNDofsPerElem(std::size_t max_dofs)
assign the maximum element dofs
Definition SystemBase.h:625
const VariableWarehouse & variableWarehouse(THREAD_ID tid=0) const
Definition SystemBase.h:784
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:212
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:620
NumericVector< Real > * _saved_older
virtual NumericVector< Number > * solutionUDotDotOld()
Definition SystemBase.h:292
void sizeVariableMatrixData()
size the matrix data for each variable for the number of matrix tags we have
virtual void copyAdditionalStateBackwards(Moose::SolutionIterationType, bool)
Copy system-owned state not represented by solution vectors.
virtual Number & duDotDotDu()
Definition SystemBase.h:285
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:786
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:605
virtual libMesh::Order getMinQuadratureOrder()
Get minimal quadrature order needed for integrating variables in this system.
Definition SystemBase.C:240
void update()
Update the system (doing libMesh magic)
virtual const NumericVector< Number > * solutionUDotDot() const
Definition SystemBase.h:294
virtual void prepareFace(THREAD_ID tid, bool resize_data)
Prepare the system for use on sides.
Definition SystemBase.C:278
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
Definition SystemBase.h:340
void closeTaggedVector(const TagID tag)
Close vector with the given tag.
Definition SystemBase.C:648
const NumericVector< Number > & solution() const
Definition SystemBase.h:215
virtual void solve()
Solve the system (using libMesh magic)
void assignMaxVarNDofsPerNode(std::size_t max_dofs)
assign the maximum node dofs
Definition SystemBase.h:630
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:290
virtual TagID nonTimeVectorTag() const
Definition SystemBase.h:330
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:331
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