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
108 THREAD_ID numThreads() const;
109
115 void applyScalingFactors(const std::vector<Real> & inverse_scaling_factors);
116
120 bool computingScalingJacobian() const;
121
126 bool automaticScaling() const { return _automatic_scaling; }
127
132 void automaticScaling(bool automatic_scaling) { _automatic_scaling = automatic_scaling; }
133
138 void setVerboseFlag(const bool & verbose) { _verbose = verbose; }
139
143 virtual libMesh::DofMap & dofMap();
144
148 virtual const libMesh::DofMap & dofMap() const;
149
153 virtual libMesh::System & system() = 0;
154 virtual const libMesh::System & system() const = 0;
155
160 virtual void preInit() {}
161
162 /*
163 * This is called after the libMesh system has been init'd. This can be used to initialize MOOSE
164 * system data that relies on the libMesh system data already being initialized
165 */
166 virtual void postInit() {}
167
172 virtual void reinit() {}
173
177 virtual void initializeObjects() {}
178
182 void update();
183
187 virtual void solve();
188
192 void copyOldSolutions();
193
198
202 void copyPreviousSolutions(const Moose::SolutionIterationType iteration_type);
203
205 void restoreStateHistory();
206
207 virtual void restoreSolutions();
208
213 virtual const NumericVector<Number> * const & currentSolution() const = 0;
214
215 NumericVector<Number> & solution() { return solutionState(0); }
216 NumericVector<Number> & solutionOld() { return solutionState(1); }
217 NumericVector<Number> & solutionOlder() { return solutionState(2); }
218 const NumericVector<Number> & solution() const { return solutionState(0); }
219 const NumericVector<Number> & solutionOld() const { return solutionState(1); }
220 const NumericVector<Number> & solutionOlder() const { return solutionState(2); }
221
222 virtual const NumericVector<Number> * solutionPreviousNewton() const;
223 virtual NumericVector<Number> * solutionPreviousNewton();
224
228 virtual void initSolutionState();
229
233 const std::vector<NumericVector<Number> *> &
234 getSolutionStates(const Moose::SolutionIterationType iteration_type) const;
235
240 std::size_t getNumSolutionStates(const Moose::SolutionIterationType iteration_type) const;
241
248 virtual NumericVector<Number> &
249 solutionState(const unsigned int state,
251
255 virtual const NumericVector<Number> & solutionState(
256 const unsigned int state,
258
263 solutionStateParallelType(const unsigned int state,
264 const Moose::SolutionIterationType iteration_type) const;
265
269 virtual void needSolutionState(
270 const unsigned int state,
272 libMesh::ParallelType parallel_type = GHOSTED);
273
277 virtual bool hasSolutionState(
278 const unsigned int state,
280
285 virtual void addDotVectors();
286
287 virtual std::vector<Number> & duDotDus() { return _du_dot_du; }
288 virtual Number & duDotDotDu() { return _du_dotdot_du; }
289 virtual const Number & duDotDu(unsigned int var_num = 0) const;
290 virtual const Number & duDotDotDu() const { return _du_dotdot_du; }
291
292 virtual NumericVector<Number> * solutionUDot() { return _u_dot; }
293 virtual NumericVector<Number> * solutionUDotDot() { return _u_dotdot; }
294 virtual NumericVector<Number> * solutionUDotOld() { return _u_dot_old; }
295 virtual NumericVector<Number> * solutionUDotDotOld() { return _u_dotdot_old; }
296 virtual const NumericVector<Number> * solutionUDot() const { return _u_dot; }
297 virtual const NumericVector<Number> * solutionUDotDot() const { return _u_dotdot; }
298 virtual const NumericVector<Number> * solutionUDotOld() const { return _u_dot_old; }
299 virtual const NumericVector<Number> * solutionUDotDotOld() const { return _u_dotdot_old; }
300
301 virtual void saveOldSolutions();
302 virtual void restoreOldSolutions();
303
307 bool hasVector(const std::string & tag_name) const;
308
312 virtual bool hasVector(TagID tag_id) const
313 {
314 return tag_id < _tagged_vectors.size() && _tagged_vectors[tag_id];
315 }
316
323 virtual TagID timeVectorTag() const { mooseError("Not implemented yet"); }
324
328 virtual TagID systemMatrixTag() const { mooseError("Not implemented yet"); }
329
330 /*
331 * Return TagID for nontime
332 */
333 virtual TagID nonTimeVectorTag() const { mooseError("Not implemented yet"); }
334
335 /*
336 * Return TagID for nontime
337 */
338 virtual TagID residualVectorTag() const { mooseError("Not implemented yet"); }
339
343 virtual std::set<TagID> defaultVectorTags() const
344 {
346 }
350 virtual std::set<TagID> defaultMatrixTags() const { return {systemMatrixTag()}; }
351
356 virtual NumericVector<Number> & getVector(const std::string & name);
357 virtual const NumericVector<Number> & getVector(const std::string & name) const;
359
364 virtual NumericVector<Number> & getVector(TagID tag);
365 virtual const NumericVector<Number> & getVector(TagID tag) const;
367
371 virtual void associateVectorToTag(NumericVector<Number> & vec, TagID tag);
372
376 virtual void disassociateVectorFromTag(NumericVector<Number> & vec, TagID tag);
377
381 virtual void disassociateVectorFromTag(TagID tag);
382
386 virtual void disassociateDefaultVectorTags();
387
391 virtual bool hasMatrix(TagID tag) const
392 {
393 return tag < _tagged_matrices.size() && _tagged_matrices[tag];
394 }
395
400
404 virtual const libMesh::SparseMatrix<Number> & getMatrix(TagID tag) const;
405
409 virtual void activateAllMatrixTags();
410
414 virtual bool matrixTagActive(TagID tag) const;
415
419 virtual void deactivateAllMatrixTags();
420
424 void closeTaggedMatrices(const std::set<TagID> & tags);
425
430 void flushTaggedMatrices(const std::set<TagID> & tags);
431
435 virtual void associateMatrixToTag(libMesh::SparseMatrix<Number> & matrix, TagID tag);
436
441
445 virtual void disassociateMatrixFromTag(TagID tag);
446
450 virtual void disassociateDefaultMatrixTags();
451
455 virtual NumericVector<Number> & serializedSolution();
456
457 virtual NumericVector<Number> & residualCopy()
458 {
459 mooseError("This system does not support getting a copy of the residual");
460 }
461 virtual NumericVector<Number> & residualGhosted()
462 {
463 mooseError("This system does not support getting a ghosted copy of the residual");
464 }
465
469 virtual void augmentSendList(std::vector<dof_id_type> & send_list);
470
475 std::vector<dof_id_type> & n_nz,
476 std::vector<dof_id_type> & n_oz) = 0;
477
484 virtual void addVariable(const std::string & var_type,
485 const std::string & var_name,
486 InputParameters & parameters);
487
491 virtual bool isArrayVariable(const std::string & var_name) const;
492
494
500 virtual bool hasVariable(const std::string & var_name) const;
501 virtual bool hasScalarVariable(const std::string & var_name) const;
503
504 virtual bool isScalarVariable(unsigned int var_name) const;
505
513 MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string & var_name) const;
514
522 MooseVariableFieldBase & getVariable(THREAD_ID tid, unsigned int var_number) const;
523
533 template <typename T>
534 MooseVariableFE<T> & getFieldVariable(THREAD_ID tid, const std::string & var_name);
535
539 template <typename T>
540 MooseVariableField<T> & getActualFieldVariable(THREAD_ID tid, const std::string & var_name);
541
551 template <typename T>
552 MooseVariableFE<T> & getFieldVariable(THREAD_ID tid, unsigned int var_number);
553
557 template <typename T>
558 MooseVariableField<T> & getActualFieldVariable(THREAD_ID tid, unsigned int var_number);
559
563 template <typename T>
564 MooseVariableFV<T> & getFVVariable(THREAD_ID tid, const std::string & var_name);
565
574 const std::string & var_name) const;
575
583 virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, unsigned int var_number) const;
584
591 virtual const std::set<SubdomainID> * getVariableBlocks(unsigned int var_number);
592
597 virtual unsigned int nVariables() const;
598
603 unsigned int nFieldVariables() const;
604
609 unsigned int nFVVariables() const;
610
616 std::size_t getMaxVarNDofsPerElem() const { return _max_var_n_dofs_per_elem; }
617
623 std::size_t getMaxVarNDofsPerNode() const { return _max_var_n_dofs_per_node; }
624
628 void assignMaxVarNDofsPerElem(std::size_t max_dofs) { _max_var_n_dofs_per_elem = max_dofs; }
629
633 void assignMaxVarNDofsPerNode(std::size_t max_dofs) { _max_var_n_dofs_per_node = max_dofs; }
634
639 virtual void addVariableToZeroOnResidual(std::string var_name);
640
645 virtual void addVariableToZeroOnJacobian(std::string var_name);
646
653 virtual void zeroVariables(std::vector<std::string> & vars_to_be_zeroed);
654
659 virtual void zeroVariablesForResidual();
660
665 virtual void zeroVariablesForJacobian();
666
672
677 virtual void prepare(THREAD_ID tid);
678
688 virtual void prepareFace(THREAD_ID tid, bool resize_data);
689
694 virtual void prepareNeighbor(THREAD_ID tid);
695
700 virtual void prepareLowerD(THREAD_ID tid);
701
707 virtual void reinitElem(const Elem * elem, THREAD_ID tid);
708
715 virtual void reinitElemFace(const Elem * elem, unsigned int side, THREAD_ID tid);
716
720 virtual void reinitNeighborFace(const Elem * elem, unsigned int side, THREAD_ID tid);
721
725 virtual void reinitNeighbor(const Elem * elem, THREAD_ID tid);
726
730 virtual void reinitLowerD(THREAD_ID tid);
731
737 virtual void reinitNode(const Node * node, THREAD_ID tid);
738
745 virtual void reinitNodeFace(const Node * node, BoundaryID bnd_id, THREAD_ID tid);
746
752 virtual void reinitNodes(const std::vector<dof_id_type> & nodes, THREAD_ID tid);
753
759 virtual void reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, THREAD_ID tid);
760
767 virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering = false);
768
778 virtual void addVariableToCopy(const std::string & dest_name,
779 const std::string & source_name,
780 const std::string & timestep);
781
782 const std::vector<MooseVariableFieldBase *> & getVariables(THREAD_ID tid)
783 {
784 return _vars[tid].fieldVariables();
785 }
786
787 const VariableWarehouse & variableWarehouse(THREAD_ID tid = 0) const { return _vars[tid]; }
788
789 const std::vector<MooseVariableScalar *> & getScalarVariables(THREAD_ID tid)
790 {
791 return _vars[tid].scalars();
792 }
793
794 const std::set<SubdomainID> & getSubdomainsForVar(unsigned int var_number) const
795 {
796 return _var_map.at(var_number);
797 }
798
805 const std::set<SubdomainID> & getSubdomainsForVar(const std::string & var_name) const;
806
810 void removeVector(const std::string & name);
811
825 NumericVector<Number> &
826 addVector(const std::string & vector_name, const bool project, const libMesh::ParallelType type);
827
841 NumericVector<Number> &
842 addVector(TagID tag, const bool project, const libMesh::ParallelType type);
843
847 void closeTaggedVector(const TagID tag);
851 void closeTaggedVectors(const std::set<TagID> & tags);
852
856 void zeroTaggedVector(const TagID tag);
860 void zeroTaggedVectors(const std::set<TagID> & tags);
861
867 void removeVector(TagID tag_id);
868
871 void setVariableGlobalDoFs(const std::string & var_name);
872
875 const std::vector<dof_id_type> & getVariableGlobalDoFs() { return _var_all_dof_indices; }
876
883
889 void removeMatrix(TagID tag);
890
891 virtual const std::string & name() const;
892
893 const std::vector<VariableName> & getVariableNames() const { return _vars[0].names(); }
894
895 void getStandardFieldVariableNames(std::vector<VariableName> & std_field_variables) const;
896
900 unsigned int getMaxVariableNumber() const { return _max_var_number; }
901
902 virtual void computeVariables(const NumericVector<Number> & /*soln*/) {}
903
905
909 virtual void copySolutionsBackwards();
910
915
916 void addTimeIntegrator(const std::string & type,
917 const std::string & name,
918 InputParameters & parameters);
919
921 bool hasVarCopy() const { return _var_to_copy.size() > 0; }
922
930
932 virtual void initialSetup();
933 virtual void timestepSetup();
934 virtual void customSetup(const ExecFlagType & exec_type);
935 virtual void subdomainSetup();
936 virtual void residualSetup();
937 virtual void jacobianSetup();
938
942 void clearAllDofIndices();
943
947 void setActiveVariableCoupleableVectorTags(const std::set<TagID> & vtags, THREAD_ID tid);
948
952 void setActiveScalarVariableCoupleableVectorTags(const std::set<TagID> & vtags, THREAD_ID tid);
953
958
963 virtual void compute(ExecFlagType type) = 0;
964
968 void copyTimeIntegrators(const SystemBase & other_sys);
969
973 const TimeIntegrator & getTimeIntegrator(const unsigned int var_num) const;
974
980 const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const;
981
985 const std::vector<std::shared_ptr<TimeIntegrator>> & getTimeIntegrators();
986
992 std::string prefix() const;
993
998
1004
1005protected:
1014
1019 virtual void restoreAdditionalStates() {}
1020
1024 virtual NumericVector<Number> & solutionInternal() const = 0;
1025
1029
1032
1035
1038 std::string _name;
1039
1041 std::vector<VariableWarehouse> _vars;
1043 std::map<unsigned int, std::set<SubdomainID>> _var_map;
1045 unsigned int _max_var_number;
1046
1047 std::vector<std::string> _vars_to_be_zeroed_on_residual;
1048 std::vector<std::string> _vars_to_be_zeroed_on_jacobian;
1049
1051 NumericVector<Number> * _u_dot;
1053 NumericVector<Number> * _u_dotdot;
1054
1056 NumericVector<Number> * _u_dot_old;
1058 NumericVector<Number> * _u_dotdot_old;
1059
1062 std::vector<Real> _du_dot_du;
1064
1066 std::vector<NumericVector<Number> *> _tagged_vectors;
1068 std::vector<libMesh::SparseMatrix<Number> *> _tagged_matrices;
1070 std::unordered_map<TagID, libMesh::SparseMatrix<Number> *> _active_tagged_matrices;
1072 std::vector<bool> _matrix_tag_active_flags;
1073
1074 // Used for saving old solutions so that they wont be accidentally changed
1075 NumericVector<Real> * _saved_old;
1076 NumericVector<Real> * _saved_older;
1077
1078 // Used for saving old u_dot and u_dotdot so that they wont be accidentally changed
1079 NumericVector<Real> * _saved_dot_old;
1080 NumericVector<Real> * _saved_dotdot_old;
1081
1084
1085 std::vector<VarCopyInfo> _var_to_copy;
1086
1089
1092
1094 std::vector<std::shared_ptr<TimeIntegrator>> _time_integrators;
1095
1097 std::vector<std::vector<MooseVariableFieldBase *>> _numbered_vars;
1098
1101
1104
1107
1109 std::vector<dof_id_type> _var_all_dof_indices;
1110
1113 std::unique_ptr<NumericVector<Number>> _serialized_solution;
1114
1115private:
1119 TagName oldSolutionStateVectorName(const unsigned int,
1120 Moose::SolutionIterationType iteration_type) const;
1121
1125 std::vector<NumericVector<Number> *> &
1127 {
1128 return const_cast<std::vector<NumericVector<Number> *> &>(
1129 cast_ptr<const SystemBase *>(this)->getSolutionStates(iteration_type));
1130 }
1131
1141 std::array<std::vector<NumericVector<Number> *>,
1142 static_cast<size_t>(Moose::SolutionIterationType::Count)>
1145 std::vector<NumericVector<Number> *> _saved_solution_states;
1148};
1149
1150inline const std::vector<NumericVector<Number> *> &
1152{
1153 const auto iteration_type_index = static_cast<std::size_t>(iteration_type);
1154 mooseAssert(iteration_type_index < static_cast<std::size_t>(Moose::SolutionIterationType::Count),
1155 "Invalid solution iteration type");
1156 mooseAssert(iteration_type_index < _solution_states.size(), "_solution_states sized incorrectly");
1157 return _solution_states[iteration_type_index];
1158}
1159
1160inline std::size_t
1162{
1163 return getSolutionStates(iteration_type).size();
1164}
1165
1166inline bool
1167SystemBase::hasSolutionState(const unsigned int state,
1168 const Moose::SolutionIterationType iteration_type) const
1169{
1170 return getNumSolutionStates(iteration_type) > state;
1171}
1172
1173#define PARALLEL_TRY
1174
1175#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:457
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition SystemBase.C:695
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:182
void zeroTaggedVector(const TagID tag)
Zero vector with the given tag.
Definition SystemBase.C:676
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:202
NumericVector< Number > * _u_dot
solution vector for u^dot
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:326
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:400
virtual void postInit()
Definition SystemBase.h:166
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:176
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:237
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:126
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
MooseApp & _app
virtual const NumericVector< Number > * solutionUDotDotOld() const
Definition SystemBase.h:299
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
Definition SystemBase.h:350
virtual void deactivateAllMatrixTags()
Make matrices inactive.
virtual const Number & duDotDotDu() const
Definition SystemBase.h:290
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:342
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
Definition SystemBase.C:424
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:902
virtual void reinitNeighbor(const Elem *elem, THREAD_ID tid)
Compute the values of the variables at all the current points.
Definition SystemBase.C:384
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:794
virtual void subdomainSetup()
void setVerboseFlag(const bool &verbose)
Sets the verbose flag.
Definition SystemBase.h:138
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:376
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:875
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:924
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:891
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a variable of with specified name.
Definition SystemBase.C:113
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition SystemBase.C:92
virtual NumericVector< Number > * solutionUDot()
Definition SystemBase.h:292
virtual bool hasVector(TagID tag_id) const
Check if the tagged vector exists in the system.
Definition SystemBase.h:312
virtual bool isArrayVariable(const std::string &var_name) const
If a variable is an array variable.
Definition SystemBase.C:864
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:454
virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false)
Reinit scalar varaibles.
Definition SystemBase.C:446
unsigned int number() const
Gets the number of this system.
virtual void saveOldSolutions()
Save the old and older solutions.
Definition SystemBase.C:512
virtual const libMesh::System & system() const =0
virtual void restoreOldSolutions()
Restore the old and older solutions when the saved solutions present.
Definition SystemBase.C:543
bool hasVarCopy() const
Whether or not there are variables to be restarted from an Exodus mesh file.
Definition SystemBase.h:921
bool solutionStatesInitialized() const
Whether or not the solution states have been initialized via initSolutionState()
Definition SystemBase.h:929
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:885
Factory & _factory
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
const NumericVector< Number > & solutionOlder() const
Definition SystemBase.h:220
Moose::VarKindType varKind() const
Definition SystemBase.h:957
virtual TagID residualVectorTag() const
Definition SystemBase.h:338
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:900
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:893
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:231
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters &parameters)
Canonical method for adding a variable.
Definition SystemBase.C:720
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:127
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:933
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:782
virtual void initializeObjects()
Called only once, just before the solve begins so objects can do some precalculations.
Definition SystemBase.h:177
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:216
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:910
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:188
virtual void initialSetup()
Setup Functions.
virtual NumericVector< Number > & residualGhosted()
Definition SystemBase.h:461
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:981
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:120
void automaticScaling(bool automatic_scaling)
Setter for whether we are performing automatic scaling.
Definition SystemBase.h:132
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:435
const NumericVector< Number > & solutionOld() const
Definition SystemBase.h:219
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:160
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:392
void getStandardFieldVariableNames(std::vector< VariableName > &std_field_variables) const
virtual NumericVector< Number > * solutionUDotOld()
Definition SystemBase.h:294
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
Definition SystemBase.C:993
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:258
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition SystemBase.C:669
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:166
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:147
virtual bool hasScalarVariable(const std::string &var_name) const
Definition SystemBase.C:876
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Reinit assembly info for a side of an element.
Definition SystemBase.C:368
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
Definition SystemBase.C:412
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).
THREAD_ID numThreads() const
Definition SystemBase.C:89
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition SystemBase.C:851
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:900
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:298
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:296
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:570
void clearAllDofIndices()
Clear all dof indices from moose variables.
NumericVector< Number > & solutionOlder()
Definition SystemBase.h:217
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:391
virtual TagID timeVectorTag() const
Ideally, we should not need this API.
Definition SystemBase.h:323
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:616
virtual std::vector< Number > & duDotDus()
Definition SystemBase.h:287
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:328
void removeMatrix(TagID tag)
Removes a matrix with a given tag.
Definition SystemBase.C:590
void assignMaxVarNDofsPerElem(std::size_t max_dofs)
assign the maximum element dofs
Definition SystemBase.h:628
const VariableWarehouse & variableWarehouse(THREAD_ID tid=0) const
Definition SystemBase.h:787
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:215
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:623
NumericVector< Real > * _saved_older
virtual NumericVector< Number > * solutionUDotDotOld()
Definition SystemBase.h:295
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:288
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:789
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:608
virtual libMesh::Order getMinQuadratureOrder()
Get minimal quadrature order needed for integrating variables in this system.
Definition SystemBase.C:243
void update()
Update the system (doing libMesh magic)
virtual const NumericVector< Number > * solutionUDotDot() const
Definition SystemBase.h:297
virtual void prepareFace(THREAD_ID tid, bool resize_data)
Prepare the system for use on sides.
Definition SystemBase.C:281
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
Definition SystemBase.h:343
void closeTaggedVector(const TagID tag)
Close vector with the given tag.
Definition SystemBase.C:651
const NumericVector< Number > & solution() const
Definition SystemBase.h:218
virtual void solve()
Solve the system (using libMesh magic)
void assignMaxVarNDofsPerNode(std::size_t max_dofs)
assign the maximum node dofs
Definition SystemBase.h:633
virtual void reinit()
Reinitialize the system when the degrees of freedom in this system have changed.
Definition SystemBase.h:172
Real _du_dotdot_du
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > * solutionUDotDot()
Definition SystemBase.h:293
virtual TagID nonTimeVectorTag() const
Definition SystemBase.h:333
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:334
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