22 #include "libmesh/exodusII_io.h" 23 #include "libmesh/parallel_object.h" 24 #include "libmesh/numeric_vector.h" 25 #include "libmesh/sparse_matrix.h" 53 void extraSendList(std::vector<dof_id_type> & send_list,
void * context);
59 std::vector<dof_id_type> & n_nz,
60 std::vector<dof_id_type> & n_oz,
69 const std::string & source_name,
70 const std::string & timestep)
90 const std::string &
name,
98 unsigned int number()
const;
183 virtual void solve();
224 const unsigned int state,
231 const unsigned int state,
238 const unsigned int state,
249 virtual const Number &
duDotDu(
unsigned int var_num = 0)
const;
267 bool hasVector(
const std::string & tag_name)
const;
429 mooseError(
"This system does not support getting a copy of the residual");
433 mooseError(
"This system does not support getting a ghosted copy of the residual");
445 std::vector<dof_id_type> & n_nz,
446 std::vector<dof_id_type> & n_oz) = 0;
454 virtual void addVariable(
const std::string & var_type,
455 const std::string & var_name,
470 virtual bool hasVariable(
const std::string & var_name)
const;
503 template <
typename T>
509 template <
typename T>
521 template <
typename T>
527 template <
typename T>
533 template <
typename T>
544 const std::string & var_name)
const;
561 virtual const std::set<SubdomainID> *
getVariableBlocks(
unsigned int var_number);
623 virtual void zeroVariables(std::vector<std::string> & vars_to_be_zeroed);
749 const std::string & source_name,
750 const std::string & timestep);
754 return _vars[tid].fieldVariables();
759 return _vars[tid].scalars();
859 virtual const std::string &
name()
const;
880 const std::string &
name,
967 std::string
prefix()
const;
990 std::vector<VariableWarehouse>
_vars;
992 std::map<unsigned int, std::set<SubdomainID>>
_var_map;
1084 return _solution_states[
static_cast<unsigned short>(iteration_type)].size() > state;
1087 #define PARALLEL_TRY 1089 #define PARALLEL_CATCH _fe_problem.checkExceptionAndStopSolve(); void zeroTaggedVector(const TagID tag)
Zero vector with the given tag.
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
virtual const std::set< SubdomainID > * getVariableBlocks(unsigned int var_number)
Get the block where a variable of this system is defined.
virtual void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Registers that the solution state state is needed.
virtual void reinitNode(const Node *node, THREAD_ID tid)
Reinit nodal assembly info.
virtual bool hasVector(TagID tag_id) const
Check if the tagged vector exists in the system.
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
void closeTaggedVector(const TagID tag)
Close vector with the given tag.
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
const NumericVector< Number > & solution() const
virtual void initializeObjects()
Called only once, just before the solve begins so objects can do some precalculations.
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
Map variable number to its pointer.
std::vector< dof_id_type > _var_all_dof_indices
Container for the dof indices of a given variable.
std::vector< Real > _du_dot_du
Derivative of time derivative of u with respect to uj.
virtual NumericVector< Number > & solutionInternal() const =0
Internal getter for solution owned by libMesh.
void extraSparsity(libMesh::SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *context)
Free function used for a libMesh callback.
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
virtual const NumericVector< Number > * solutionUDotDotOld() const
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
void applyScalingFactors(const std::vector< Real > &inverse_scaling_factors)
Applies scaling factors to the system's variables.
virtual void augmentSparsity(libMesh::SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz)=0
Will modify the sparsity pattern to add logical geometric connections.
Class for stuff related to variables.
virtual void copyOldSolutions()
Shifts the solutions backwards in time.
virtual NumericVector< Number > & residualCopy()
const MooseMesh & mesh() const
bool _solution_states_initialized
Whether or not the solution states have been initialized.
NumericVector< Number > & solution()
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters ¶meters)
Canonical method for adding a variable.
Generic factory class for build all sorts of objects.
void automaticScaling(bool automatic_scaling)
Setter for whether we are performing automatic scaling.
virtual const NumericVector< Number > * solutionUDot() const
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
const std::vector< std::unique_ptr< NumericVector< Number > > > & gradientContainer() const
Reference to the container vector which hold gradients at dofs (if it can be interpreted).
std::vector< std::string > _vars_to_be_zeroed_on_residual
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
virtual void initSolutionState()
Initializes the solution state.
virtual void disassociateDefaultVectorTags()
Disassociate the vectors associated with the default vector tags of this system.
virtual void reinitElem(const Elem *elem, THREAD_ID tid)
Reinit an element assembly info.
virtual void reinitLowerD(THREAD_ID tid)
Compute the values of the variables on the lower dimensional element.
const TimeIntegrator & getTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable's equation.
size_t _max_var_n_dofs_per_node
Maximum number of dofs for any one variable on any one node.
bool hasVarCopy() const
Whether or not there are variables to be restarted from an Exodus mesh file.
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
virtual libMesh::Order getMinQuadratureOrder()
Get minimal quadrature order needed for integrating variables in this system.
virtual const Number & duDotDotDu() const
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Base class for MOOSE-based applications.
bool computingScalingJacobian() const
Whether we are computing an initial Jacobian for automatic variable scaling.
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
void setVerboseFlag(const bool &verbose)
Sets the verbose flag.
virtual void addVariableToCopy(const std::string &dest_name, const std::string &source_name, const std::string ×tep)
Add info about variable that will be copied.
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
virtual NumericVector< Number > * solutionUDotDotOld()
void removeMatrix(TagID tag)
Removes a matrix with a given tag.
virtual void associateMatrixToTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
This class provides an interface for common operations on field variables of both FE and FV types wit...
NumericVector< Number > & solutionOlder()
virtual void prepareFace(THREAD_ID tid, bool resize_data)
Prepare the system for use on sides.
void addScalingVector()
Add the scaling factor vector to the system.
bool solutionStatesInitialized() const
Whether or not the solution states have been initialized via initSolutionState()
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters ¶meters)
void setActiveVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the variables.
Base class for a system (of equations)
std::vector< std::unique_ptr< NumericVector< Number > > > _raw_grad_container
A cache for storing gradients at dof locations.
virtual void copyPreviousNonlinearSolutions()
Shifts the solutions backwards in nonlinear iteration history.
virtual bool isArrayVariable(const std::string &var_name) const
If a variable is an array variable.
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed...
size_t _max_var_n_dofs_per_elem
Maximum number of dofs for any one variable on any one element.
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of neighbor nodes.
NumericVector< Real > * _saved_older
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
MooseVariableFV< T > & getFVVariable(THREAD_ID tid, const std::string &var_name)
Return a finite volume variable.
virtual void disassociateMatrixFromTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
virtual void compute(ExecFlagType type)=0
Compute time derivatives, auxiliary variables, etc.
void update()
Update the system (doing libMesh magic)
virtual unsigned int nVariables() const
Get the number of variables in this system.
void setActiveScalarVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the scalar variables.
virtual const std::string & name() const
virtual void jacobianSetup()
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
virtual void deactiveAllMatrixTags()
Make matrices inactive.
std::vector< VarCopyInfo > _var_to_copy
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
FEProblemBase & feProblem()
void copyTimeIntegrators(const SystemBase &other_sys)
Copy time integrators from another system.
virtual NumericVector< Number > & serializedSolution()
Returns a reference to a serialized version of the solution vector for this subproblem.
bool automaticScaling() const
Getter for whether we are performing automatic scaling.
virtual Number & duDotDotDu()
void copyVars(libMesh::ExodusII_IO &io)
virtual const Number & duDotDu(unsigned int var_num=0) const
virtual void zeroVariablesForResidual()
Zero out the solution for the variables that were registered as needing to have their solutions zeroe...
void extraSendList(std::vector< dof_id_type > &send_list, void *context)
///< Type of coordinate system
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
boundary_id_type BoundaryID
bool _automatic_scaling
Whether to automatically scale the variables.
Information about variables that will be copied.
virtual NumericVector< Number > * solutionUDot()
VarKindType
Framework-wide stuff.
SubProblem & subproblem()
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
An inteface for the _console for outputting to the Console object.
virtual NumericVector< Number > * solutionUDotOld()
void assignMaxVarNDofsPerNode(std::size_t max_dofs)
assign the maximum node dofs
virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false)
Reinit scalar varaibles.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
virtual TagID timeVectorTag() const
Ideally, we should not need this API.
Moose::VarKindType _var_kind
default kind of variables in this system
virtual bool matrixTagActive(TagID tag) const
If or not a matrix tag is active.
virtual TagID nonTimeVectorTag() const
virtual void reinitNeighborFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Compute the values of the variables at all the current points.
std::size_t getMaxVarNDofsPerNode() const
Gets the maximum number of dofs used by any one variable on any one node.
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
libMesh::SparseMatrix< Number > & addMatrix(TagID tag)
Adds a matrix with a given tag.
virtual void addDotVectors()
Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator.
NumericVector< Real > * _saved_dot_old
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 ...
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
virtual void activeAllMatrixTags()
Make all exsiting matrices ative.
unsigned int number() const
Gets the number of this system.
VarCopyInfo(const std::string &dest_name, const std::string &source_name, const std::string ×tep)
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
virtual void reinitNeighbor(const Elem *elem, THREAD_ID tid)
Compute the values of the variables at all the current points.
const std::vector< std::shared_ptr< TimeIntegrator > > & getTimeIntegrators()
const FEProblemBase & feProblem() const
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
std::size_t getMaxVarNDofsPerElem() const
Gets the maximum number of dofs used by any one variable on any one element.
virtual TagID systemMatrixTag() const
Return the Matrix Tag ID for System.
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
virtual void copySolutionsBackwards()
Copy current solution into old and older.
virtual TagID residualVectorTag() const
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
virtual void solve()
Solve the system (using libMesh magic)
void assignMaxVarNDofsPerElem(std::size_t max_dofs)
assign the maximum element dofs
std::string _name
The name of this system.
FEProblemBase & _fe_problem
the governing finite element/volume problem
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a scalar variable with specified number.
virtual void activeMatrixTag(TagID tag)
Active a matrix for tag.
virtual void saveOldSolutions()
Save the old and older solutions.
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Base class for time integrators.
virtual void subdomainSetup()
Generic class for solving transient nonlinear problems.
bool _verbose
True if printing out additional information.
void removeVector(const std::string &name)
Remove a vector from the system with the given name.
Class for containing MooseEnum item information.
unsigned int nFVVariables() const
Get the number of finite volume variables in this system.
NumericVector< Number > * _u_dot
solution vector for u^dot
virtual void addVariableToZeroOnResidual(std::string var_name)
Adds this variable to the list of variables to be zeroed during each residual evaluation.
virtual void preInit()
This is called prior to the libMesh system has been init'd.
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a variable of with specified name.
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
const NumericVector< Number > & solutionOld() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
virtual void zeroVariablesForJacobian()
Zero out the solution for the variables that were registered as needing to have their solutions zeroe...
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
TagName oldSolutionStateVectorName(const unsigned int, Moose::SolutionIterationType iteration_type) const
Gets the vector name used for an old (not current) solution state.
NumericVector< Real > * _saved_old
std::array< std::vector< NumericVector< Number > * >, 2 > _solution_states
The solution states (0 = current, 1 = old, 2 = older, etc)
Class for scalar variables (they are different).
std::string prefix() const
NumericVector< Real > * _saved_dotdot_old
virtual void reinit()
Reinitialize the system when the degrees of freedom in this system have changed.
const std::vector< VariableName > & getVariableNames() const
virtual std::vector< Number > & duDotDus()
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
virtual void addVariableToZeroOnJacobian(std::string var_name)
Adds this variable to the list of variables to be zeroed during each Jacobian evaluation.
virtual const NumericVector< Number > * solutionPreviousNewton() const
virtual void customSetup(const ExecFlagType &exec_type)
const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable's equation.
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
unsigned int getMaxVariableNumber() const
Returns the maximum number of all variables on the system.
virtual bool isScalarVariable(unsigned int var_name) const
unsigned int nFieldVariables() const
Get the number of field variables in this system.
void getStandardFieldVariableNames(std::vector< VariableName > &std_field_variables) const
virtual void computeVariables(const NumericVector< Number > &)
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Reinit assembly info for a side of an element.
virtual void prepareLowerD(THREAD_ID tid)
Prepare the system for use for lower dimensional elements.
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
virtual const NumericVector< Number > * solutionUDotDot() const
virtual void deactiveMatrixTag(TagID tag)
deactive a matrix for tag
virtual NumericVector< Number > * solutionUDotDot()
virtual const NumericVector< Number > * solutionUDotOld() const
void setVariableGlobalDoFs(const std::string &var_name)
set all the global dof indices for a variable
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
NumericVector< Number > & solutionOld()
SystemBase(SubProblem &subproblem, FEProblemBase &fe_problem, const std::string &name, Moose::VarKindType var_kind)
virtual bool hasScalarVariable(const std::string &var_name) const
MooseVariableFE< VectorValue< Real > > VectorMooseVariable
Moose::VarKindType varKind() const
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.
virtual NumericVector< Number > & residualGhosted()
MooseVariableFE< Real > MooseVariable
virtual void initialSetup()
Setup Functions.
virtual void restoreSolutions()
Restore current solutions (call after your solve failed)
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
virtual void residualSetup()
const SubProblem & subproblem() const
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)
virtual void disassociateDefaultMatrixTags()
Disassociate the matrices associated with the default matrix tags of this system. ...
void clearAllDofIndices()
Clear all dof indices from moose variables.
unsigned int _max_var_number
Maximum variable number.
virtual void zeroVariables(std::vector< std::string > &vars_to_be_zeroed)
Zero out the solution for the list of variables passed in.
virtual void restoreOldSolutions()
Restore the old and older solutions when the saved solutions present.
void flushTaggedMatrices(const std::set< TagID > &tags)
flushes all matrices associated to tags.
const NumericVector< Number > & solutionOlder() const
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
virtual void timestepSetup()
MooseVariableField< T > & getActualFieldVariable(THREAD_ID tid, const std::string &var_name)
Returns a field variable pointer - this includes finite volume variables.