23#include "libmesh/exodusII_io.h"
24#include "libmesh/parallel_object.h"
25#include "libmesh/numeric_vector.h"
26#include "libmesh/sparse_matrix.h"
54void extraSendList(std::vector<dof_id_type> & send_list,
void * context);
60 std::vector<dof_id_type> & n_nz,
61 std::vector<dof_id_type> & n_oz,
70 const std::string & source_name,
71 const std::string & timestep)
91 const std::string &
name,
99 unsigned int number()
const;
184 virtual void solve();
221 const std::vector<NumericVector<Number> *> &
236 virtual NumericVector<Number> &
244 const unsigned int state,
258 const unsigned int state,
266 const unsigned int state,
277 virtual const Number &
duDotDu(
unsigned int var_num = 0)
const;
295 bool hasVector(
const std::string & tag_name)
const;
344 virtual NumericVector<Number> &
getVector(
const std::string &
name);
345 virtual const NumericVector<Number> &
getVector(
const std::string &
name)
const;
447 mooseError(
"This system does not support getting a copy of the residual");
451 mooseError(
"This system does not support getting a ghosted copy of the residual");
463 std::vector<dof_id_type> & n_nz,
464 std::vector<dof_id_type> & n_oz) = 0;
472 virtual void addVariable(
const std::string & var_type,
473 const std::string & var_name,
488 virtual bool hasVariable(
const std::string & var_name)
const;
521 template <
typename T>
527 template <
typename T>
539 template <
typename T>
545 template <
typename T>
551 template <
typename T>
562 const std::string & var_name)
const;
579 virtual const std::set<SubdomainID> *
getVariableBlocks(
unsigned int var_number);
641 virtual void zeroVariables(std::vector<std::string> & vars_to_be_zeroed);
767 const std::string & source_name,
768 const std::string & timestep);
772 return _vars[tid].fieldVariables();
779 return _vars[tid].scalars();
813 NumericVector<Number> &
829 NumericVector<Number> &
879 virtual const std::string &
name()
const;
900 const std::string &
name,
980 std::string
prefix()
const;
1016 std::map<unsigned int, std::set<SubdomainID>>
_var_map;
1098 std::vector<NumericVector<Number> *> &
1101 return const_cast<std::vector<NumericVector<Number> *
> &>(
1114 std::array<std::vector<NumericVector<Number> *>,
1123inline const std::vector<NumericVector<Number> *> &
1126 const auto iteration_type_index =
static_cast<std::size_t
>(iteration_type);
1128 "Invalid solution iteration type");
1129 mooseAssert(iteration_type_index <
_solution_states.size(),
"_solution_states sized incorrectly");
1148#define PARALLEL_CATCH _fe_problem.checkExceptionAndStopSolve();
boundary_id_type BoundaryID
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
void extraSendList(std::vector< dof_id_type > &send_list, void *context)
///< Type of coordinate system
MooseVariableFE< Real > MooseVariable
MooseVariableFE< VectorValue< Real > > VectorMooseVariable
void extraSparsity(libMesh::SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *context)
Free function used for a libMesh callback.
An inteface for the _console for outputting to the Console object.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Generic factory class for build all sorts of objects.
Base class for MOOSE-based applications.
Class for containing MooseEnum item information.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
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.
Base class for a system (of equations)
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()
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
virtual void addVariableToZeroOnJacobian(std::string var_name)
Adds this variable to the list of variables to be zeroed during each Jacobian evaluation.
void zeroTaggedVector(const TagID tag)
Zero vector with the given tag.
virtual void zeroVariables(std::vector< std::string > &vars_to_be_zeroed)
Zero out the solution for the list of variables passed in.
NumericVector< Number > * _u_dot
solution vector for u^dot
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
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.
virtual void addVariableToZeroOnResidual(std::string var_name)
Adds this variable to the list of variables to be zeroed during each residual evaluation.
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...
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.
bool automaticScaling() const
Getter for whether we are performing automatic scaling.
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
virtual const NumericVector< Number > * solutionUDotDotOld() const
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
virtual void deactivateAllMatrixTags()
Make matrices inactive.
virtual const Number & duDotDotDu() const
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.
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
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 > &)
virtual void reinitNeighbor(const Elem *elem, THREAD_ID tid)
Compute the values of the variables at all the current points.
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
virtual void subdomainSetup()
void setVerboseFlag(const bool &verbose)
Sets the verbose flag.
virtual void reinitNeighborFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Compute the values of the variables at all the current points.
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 ...
void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters ¶meters)
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.
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
virtual unsigned int nVariables() const
Get the number of variables in this system.
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a variable of with specified name.
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
virtual NumericVector< Number > * solutionUDot()
virtual bool hasVector(TagID tag_id) const
Check if the tagged vector exists in the system.
virtual bool isArrayVariable(const std::string &var_name) const
If a variable is an array variable.
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 void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false)
Reinit scalar varaibles.
unsigned int number() const
Gets the number of this system.
virtual void saveOldSolutions()
Save the old and older solutions.
virtual const libMesh::System & system() const =0
virtual void restoreOldSolutions()
Restore the old and older solutions when the saved solutions present.
bool hasVarCopy() const
Whether or not there are variables to be restarted from an Exodus mesh file.
bool solutionStatesInitialized() const
Whether or not the solution states have been initialized via initSolutionState()
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
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
const NumericVector< Number > & solutionOlder() const
Moose::VarKindType varKind() const
virtual TagID residualVectorTag() const
virtual void activateAllMatrixTags()
Make all existing matrices active.
unsigned int nFieldVariables() const
Get the number of field variables in this system.
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 void compute(ExecFlagType type)=0
Compute time derivatives, auxiliary variables, etc.
const std::vector< VariableName > & getVariableNames() const
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...
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters ¶meters)
Canonical method for adding a variable.
const SubProblem & subproblem() const
MooseVariableFV< T > & getFVVariable(THREAD_ID tid, const std::string &var_name)
Return a finite volume variable.
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.
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)
virtual void initializeObjects()
Called only once, just before the solve begins so objects can do some precalculations.
virtual bool matrixTagActive(TagID tag) const
If or not a matrix tag is active.
virtual void customSetup(const ExecFlagType &exec_type)
NumericVector< Number > & solutionOld()
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.
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()
void setVariableGlobalDoFs(const std::string &var_name)
set all the global dof indices for a variable
virtual void initialSetup()
Setup Functions.
virtual NumericVector< Number > & residualGhosted()
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.
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.
void automaticScaling(bool automatic_scaling)
Setter for whether we are performing automatic scaling.
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.
const NumericVector< Number > & solutionOld() const
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.
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.
void getStandardFieldVariableNames(std::vector< VariableName > &std_field_variables) const
virtual NumericVector< Number > * solutionUDotOld()
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
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.
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.
virtual bool hasScalarVariable(const std::string &var_name) const
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Reinit assembly info for a side of an element.
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
void copyPreviousSolutions(const Moose::SolutionIterationType iteration_type)
Copy a specific type of solution back in time (older -> old, etc).
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
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.
virtual const NumericVector< Number > * solutionPreviousNewton() const
const FEProblemBase & feProblem() const
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()
virtual const NumericVector< Number > * solutionUDotOld() const
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
Moose::VarKindType _var_kind
default kind of variables in this system
virtual void associateMatrixToTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
libMesh::SparseMatrix< Number > & addMatrix(TagID tag)
Adds a matrix with a given tag.
void clearAllDofIndices()
Clear all dof indices from moose variables.
NumericVector< Number > & solutionOlder()
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.
void addScalingVector()
Add the scaling factor vector to the system.
virtual TagID timeVectorTag() const
Ideally, we should not need this API.
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.
virtual std::vector< Number > & duDotDus()
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.
void removeMatrix(TagID tag)
Removes a matrix with a given tag.
void assignMaxVarNDofsPerElem(std::size_t max_dofs)
assign the maximum element dofs
const VariableWarehouse & variableWarehouse(THREAD_ID tid=0) const
void setActiveVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the variables.
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()
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.
NumericVector< Real > * _saved_older
virtual NumericVector< Number > * solutionUDotDotOld()
void sizeVariableMatrixData()
size the matrix data for each variable for the number of matrix tags we have
virtual Number & duDotDotDu()
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)
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.
virtual libMesh::Order getMinQuadratureOrder()
Get minimal quadrature order needed for integrating variables in this system.
void update()
Update the system (doing libMesh magic)
virtual const NumericVector< Number > * solutionUDotDot() const
virtual void prepareFace(THREAD_ID tid, bool resize_data)
Prepare the system for use on sides.
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
void closeTaggedVector(const TagID tag)
Close vector with the given tag.
const NumericVector< Number > & solution() const
virtual void solve()
Solve the system (using libMesh magic)
void assignMaxVarNDofsPerNode(std::size_t max_dofs)
assign the maximum node dofs
virtual void reinit()
Reinitialize the system when the degrees of freedom in this system have changed.
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > * solutionUDotDot()
virtual TagID nonTimeVectorTag() const
const MooseMesh & mesh() const
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.
Base class for time integrators.
Holds variables and provides some services.
VarKindType
Framework-wide stuff.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
Information about variables that will be copied.
VarCopyInfo(const std::string &dest_name, const std::string &source_name, const std::string ×tep)