www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
SystemBase Class Referenceabstract

Base class for a system (of equations) More...

#include <SystemBase.h>

Inheritance diagram for SystemBase:
[legend]

Public Member Functions

 SystemBase (SubProblem &subproblem, const std::string &name, Moose::VarKindType var_kind)
 
virtual ~SystemBase ()
 
virtual unsigned int number () const
 Gets the number of this system. More...
 
virtual MooseMeshmesh ()
 
virtual SubProblemsubproblem ()
 
virtual DofMap & dofMap ()
 Gets the dof map. More...
 
virtual System & system ()=0
 Get the reference to the libMesh system. More...
 
virtual const System & system () const =0
 
virtual void init ()
 Initialize the system. More...
 
virtual void initializeObjects ()
 Called only once, just before the solve begins so objects can do some precalculations. More...
 
virtual void addExtraVectors ()
 Method called during initialSetup to add extra system vector if they are required by the simulation. More...
 
virtual void update ()
 Update the system (doing libMesh magic) More...
 
virtual void solve ()
 Solve the system (using libMesh magic) More...
 
virtual void copyOldSolutions ()
 Shifts the solutions backwards in time. More...
 
virtual void restoreSolutions ()
 Restore current solutions (call after your solve failed) More...
 
virtual const NumericVector< Number > *& currentSolution ()=0
 The solution vector that is currently being operated on. More...
 
virtual NumericVector< Number > & solution ()=0
 
virtual NumericVector< Number > & solutionOld ()=0
 
virtual NumericVector< Number > & solutionOlder ()=0
 
virtual NumericVector< Number > * solutionPreviousNewton ()=0
 
virtual Number & duDotDu ()
 
virtual Number & duDotDotDu ()
 
virtual NumericVector< Number > * solutionUDot ()=0
 
virtual NumericVector< Number > * solutionUDotOld ()=0
 
virtual NumericVector< Number > * solutionUDotDot ()=0
 
virtual NumericVector< Number > * solutionUDotDotOld ()=0
 
virtual void saveOldSolutions ()
 Save the old and older solutions. More...
 
virtual void restoreOldSolutions ()
 Restore the old and older solutions when the saved solutions present. More...
 
bool hasVector (const std::string &tag_name) const
 Check if the named vector exists in the system. More...
 
virtual bool hasVector (TagID tag_id)
 Check if the tagged vector exists in the system. More...
 
virtual TagID timeVectorTag ()
 Ideally, we should not need this API. More...
 
virtual TagID timeMatrixTag ()
 Return the Matrix Tag ID for Time. More...
 
virtual TagID systemMatrixTag ()
 Return the Matrix Tag ID for System. More...
 
virtual TagID nonTimeVectorTag ()
 
virtual TagID residualVectorTag ()
 
virtual NumericVector< Number > & getVector (const std::string &name)
 Get a raw NumericVector. More...
 
virtual NumericVector< Number > & getVector (TagID tag)
 Get a raw NumericVector. More...
 
virtual void associateVectorToTag (NumericVector< Number > &vec, TagID tag)
 Associate a vector for a given tag. More...
 
virtual void disassociateVectorFromTag (NumericVector< Number > &vec, TagID tag)
 Associate a vector for a given tag. More...
 
virtual void disassociateAllTaggedVectors ()
 Disassociate all vectors, and then hasVector() will return false. More...
 
virtual bool hasMatrix (TagID tag)
 Check if the tagged matrix exists in the system. More...
 
virtual SparseMatrix< Number > & getMatrix (TagID tag)
 Get a raw SparseMatrix. More...
 
virtual void activeAllMatrixTags ()
 Make all exsiting matrices ative. More...
 
virtual void activeMatrixTag (TagID tag)
 Active a matrix for tag. More...
 
virtual bool matrixTagActive (TagID tag)
 If or not a matrix tag is active. More...
 
virtual void deactiveMatrixTag (TagID tag)
 deactive a matrix for tag More...
 
virtual void deactiveAllMatrixTags ()
 Make matrices inactive. More...
 
void closeTaggedMatrices (const std::set< TagID > &tags)
 Close all matrices associated the tags. More...
 
virtual void associateMatrixToTag (SparseMatrix< Number > &matrix, TagID tag)
 associate a matirx to a tag More...
 
virtual void disassociateMatrixFromTag (SparseMatrix< Number > &matrix, TagID tag)
 disassociate a matirx from a tag More...
 
virtual void disassociateAllTaggedMatrices ()
 Clear all tagged matrices. More...
 
virtual NumericVector< Number > & serializedSolution ()=0
 Returns a reference to a serialized version of the solution vector for this subproblem. More...
 
virtual NumericVector< Number > & residualCopy ()
 
virtual NumericVector< Number > & residualGhosted ()
 
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. More...
 
virtual void augmentSparsity (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. More...
 
virtual void addVariable (const std::string &var_name, const FEType &type, Real scale_factor, const std::set< SubdomainID > *const active_subdomains=NULL)
 Adds a variable to the system. More...
 
virtual bool isScalarVariable (unsigned int var_name) const
 
MooseVariableFEBasegetVariable (THREAD_ID tid, const std::string &var_name)
 Gets a reference to a variable of with specified name. More...
 
MooseVariableFEBasegetVariable (THREAD_ID tid, unsigned int var_number)
 Gets a reference to a variable with specified number. More...
 
template<typename T >
MooseVariableFE< T > & getFieldVariable (THREAD_ID tid, const std::string &var_name)
 Gets a reference to a variable of with specified name. More...
 
template<typename T >
MooseVariableFE< T > & getFieldVariable (THREAD_ID tid, unsigned int var_number)
 Gets a reference to a variable with specified number. More...
 
virtual MooseVariableScalargetScalarVariable (THREAD_ID tid, const std::string &var_name)
 Gets a reference to a scalar variable with specified number. More...
 
virtual MooseVariableScalargetScalarVariable (THREAD_ID tid, unsigned int var_number)
 Gets a reference to a variable with specified number. More...
 
virtual const std::set< SubdomainID > * getVariableBlocks (unsigned int var_number)
 Get the block where a variable of this system is defined. More...
 
virtual unsigned int nVariables () const
 Get the number of variables in this system. More...
 
size_t getMaxVarNDofsPerElem ()
 Gets the maximum number of dofs used by any one variable on any one element. More...
 
virtual void addVariableToZeroOnResidual (std::string var_name)
 Adds this variable to the list of variables to be zeroed during each residual evaluation. More...
 
virtual void addVariableToZeroOnJacobian (std::string var_name)
 Adds this variable to the list of variables to be zeroed during each Jacobian evaluation. More...
 
virtual void zeroVariables (std::vector< std::string > &vars_to_be_zeroed)
 Zero out the solution for the list of variables passed in. More...
 
virtual void zeroVariablesForResidual ()
 Zero out the solution for the variables that were registered as needing to have their solutions zeroed on out on residual evaluation by a call to addVariableToZeroOnResidual() More...
 
virtual void zeroVariablesForJacobian ()
 Zero out the solution for the variables that were registered as needing to have their solutions zeroed on out on Jacobian evaluation by a call to addVariableToZeroOnResidual() More...
 
virtual Order getMinQuadratureOrder ()
 Get minimal quadrature order needed for integrating variables in this system. More...
 
virtual void prepare (THREAD_ID tid)
 Prepare the system for use. More...
 
virtual void prepareFace (THREAD_ID tid, bool resize_data)
 Prepare the system for use on sides. More...
 
virtual void prepareNeighbor (THREAD_ID tid)
 Prepare the system for use. More...
 
virtual void reinitElem (const Elem *elem, THREAD_ID tid)
 Reinit an element assembly info. More...
 
virtual void reinitElemFace (const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
 Reinit assembly info for a side of an element. More...
 
virtual void reinitNeighborFace (const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
 Compute the values of the variables at all the current points. More...
 
virtual void reinitNeighbor (const Elem *elem, THREAD_ID tid)
 Compute the values of the variables at all the current points. More...
 
virtual void reinitNode (const Node *node, THREAD_ID tid)
 Reinit nodal assembly info. More...
 
virtual void reinitNodeFace (const Node *node, BoundaryID bnd_id, THREAD_ID tid)
 Reinit nodal assembly info on a face. More...
 
virtual void reinitNodes (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of nodes. More...
 
virtual void reinitNodesNeighbor (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of neighbor nodes. More...
 
virtual void reinitScalars (THREAD_ID tid)
 Reinit scalar varaibles. More...
 
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. More...
 
const std::vector< MooseVariableFEBase * > & getVariables (THREAD_ID tid)
 
const std::vector< MooseVariableScalar * > & getScalarVariables (THREAD_ID tid)
 
const std::set< SubdomainID > & getSubdomainsForVar (unsigned int var_number) const
 
virtual void removeVector (const std::string &name)
 Remove a vector from the system with the given name. More...
 
virtual NumericVector< Number > & addVector (const std::string &vector_name, const bool project, const ParallelType type)
 Adds a solution length vector to the system. More...
 
NumericVector< Number > & addVector (TagID tag, const bool project, const ParallelType type)
 Adds a solution length vector to the system with the specified TagID. More...
 
virtual void closeTaggedVectors (const std::set< TagID > &tags)
 Close all vectors for given tags. More...
 
virtual void zeroTaggedVectors (const std::set< TagID > &tags)
 Zero all vectors for given tags. More...
 
virtual void removeVector (TagID tag_id)
 Remove a solution length vector from the system with the specified TagID. More...
 
virtual SparseMatrix< Number > & addMatrix (TagID)
 Adds a jacobian sized vector. More...
 
virtual void removeMatrix (TagID)
 Removes a jacobian sized vector. More...
 
virtual const std::string & name () const
 
virtual void addScalarVariable (const std::string &var_name, Order order, Real scale_factor, const std::set< SubdomainID > *const active_subdomains=NULL)
 Adds a scalar variable. More...
 
const std::vector< VariableName > & getVariableNames () const
 
virtual void computeVariables (const NumericVector< Number > &)
 
void copyVars (ExodusII_IO &io)
 
virtual void copySolutionsBackwards ()
 Copy current solution into old and older. More...
 
virtual bool hasVariable (const std::string &var_name) const
 Query a system for a variable. More...
 
virtual bool hasScalarVariable (const std::string &var_name) const
 

Protected Attributes

SubProblem_subproblem
 
MooseApp_app
 
Factory_factory
 
MooseMesh_mesh
 
std::string _name
 The name of this system. More...
 
std::vector< VariableWarehouse_vars
 Variable warehouses (one for each thread) More...
 
std::map< unsigned int, std::set< SubdomainID > > _var_map
 Map of variables (variable id -> array of subdomains where it lives) More...
 
std::vector< std::string > _vars_to_be_zeroed_on_residual
 
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
 
Real _du_dot_du
 
Real _du_dotdot_du
 
std::vector< NumericVector< Number > * > _tagged_vectors
 Tagged vectors (pointer) More...
 
std::vector< SparseMatrix< Number > * > _tagged_matrices
 Tagged matrices (pointer) More...
 
std::vector< bool > _matrix_tag_active_flags
 Active flags for tagged matrices. More...
 
NumericVector< Real > * _saved_old
 
NumericVector< Real > * _saved_older
 
NumericVector< Real > * _saved_dot_old
 
NumericVector< Real > * _saved_dotdot_old
 
Moose::VarKindType _var_kind
 default kind of variables in this system More...
 
std::vector< VarCopyInfo_var_to_copy
 
size_t _max_var_n_dofs_per_elem
 Maximum number of dofs for any one variable on any one element. More...
 

Detailed Description

Base class for a system (of equations)

Definition at line 91 of file SystemBase.h.

Constructor & Destructor Documentation

◆ SystemBase()

SystemBase::SystemBase ( SubProblem subproblem,
const std::string &  name,
Moose::VarKindType  var_kind 
)

Definition at line 80 of file SystemBase.C.

83  : libMesh::ParallelObject(subproblem),
88  _name(name),
89  _vars(libMesh::n_threads()),
90  _var_map(),
91  _saved_old(NULL),
92  _saved_older(NULL),
93  _saved_dot_old(NULL),
94  _saved_dotdot_old(NULL),
95  _var_kind(var_kind),
97 {
98 }
virtual MooseMesh & mesh()=0
virtual const std::string & name() const
Definition: SystemBase.h:638
Factory & _factory
Definition: SystemBase.h:666
size_t _max_var_n_dofs_per_elem
Maximum number of dofs for any one variable on any one element.
Definition: SystemBase.h:704
NumericVector< Real > * _saved_older
Definition: SystemBase.h:692
Factory & getFactory()
Retrieve the Factory associated with this App.
Definition: MooseApp.h:279
SubProblem & _subproblem
Definition: SystemBase.h:663
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:699
NumericVector< Real > * _saved_dot_old
Definition: SystemBase.h:695
virtual SubProblem & subproblem()
Definition: SystemBase.h:103
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
Definition: SystemBase.h:675
std::string _name
The name of this system.
Definition: SystemBase.h:670
MooseApp & _app
Definition: SystemBase.h:665
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673
MooseMesh & _mesh
Definition: SystemBase.h:668
NumericVector< Real > * _saved_old
Definition: SystemBase.h:691
NumericVector< Real > * _saved_dotdot_old
Definition: SystemBase.h:696
MooseApp & getMooseApp() const
Get the MooseApp this object is associated with.
Definition: MooseObject.h:86

◆ ~SystemBase()

virtual SystemBase::~SystemBase ( )
inlinevirtual

Definition at line 95 of file SystemBase.h.

95 {}

Member Function Documentation

◆ activeAllMatrixTags()

void SystemBase::activeAllMatrixTags ( )
virtual

Make all exsiting matrices ative.

Definition at line 850 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal(), and NonlinearSystemBase::computeResidualTags().

851 {
852  auto num_matrix_tags = _subproblem.numMatrixTags();
853 
854  _matrix_tag_active_flags.resize(num_matrix_tags);
855 
856  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
857  if (hasMatrix(tag))
858  _matrix_tag_active_flags[tag] = true;
859  else
860  _matrix_tag_active_flags[tag] = false;
861 }
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:766
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:688
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:145

◆ activeMatrixTag()

void SystemBase::activeMatrixTag ( TagID  tag)
virtual

Active a matrix for tag.

Definition at line 815 of file SystemBase.C.

816 {
817  mooseAssert(_subproblem.matrixTagExists(tag),
818  "Cannot active Matrix with matrix_tag : " << tag << "that does not exist");
819 
820  if (_matrix_tag_active_flags.size() < tag + 1)
821  _matrix_tag_active_flags.resize(tag + 1);
822 
823  _matrix_tag_active_flags[tag] = true;
824 }
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:118
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:688
SubProblem & _subproblem
Definition: SystemBase.h:663

◆ addExtraVectors()

void SystemBase::addExtraVectors ( )
virtual

Method called during initialSetup to add extra system vector if they are required by the simulation.

Reimplemented in NonlinearSystemBase, and AuxiliarySystem.

Definition at line 934 of file SystemBase.C.

935 {
936 }

◆ addMatrix()

virtual SparseMatrix<Number>& SystemBase::addMatrix ( TagID  )
inlinevirtual

Adds a jacobian sized vector.

Parameters
tag_nameThe name of the tag

Reimplemented in NonlinearSystem.

Definition at line 623 of file SystemBase.h.

624  {
625  mooseError("Adding a matrix is not supported for this type of system!");
626  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ addScalarVariable()

void SystemBase::addScalarVariable ( const std::string &  var_name,
Order  order,
Real  scale_factor,
const std::set< SubdomainID > *const  active_subdomains = NULL 
)
virtual

Adds a scalar variable.

Parameters
var_nameThe name of the variable
orderThe order of the variable
scale_factorThe scaling factor to be used with this scalar variable

Definition at line 613 of file SystemBase.C.

Referenced by DisplacedProblem::addAuxScalarVariable(), and DisplacedProblem::addScalarVariable().

617 {
618  FEType type(order, SCALAR);
619  unsigned int var_num = system().add_variable(var_name, type, active_subdomains);
620  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
621  {
622  // FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in
623  // MooseVariableBase.
624  MooseVariableScalar * var =
625  new MooseVariableScalar(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
626  var->scalingFactor(scale_factor);
627  _vars[tid].add(var_name, var);
628  }
629  if (active_subdomains == nullptr)
630  _var_map[var_num] = std::set<SubdomainID>();
631  else
632  for (const auto subdomain_id : *active_subdomains)
633  _var_map[var_num].insert(subdomain_id);
634 }
virtual Assembly & assembly(THREAD_ID tid)=0
SubProblem & _subproblem
Definition: SystemBase.h:663
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:699
virtual System & system()=0
Get the reference to the libMesh system.
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
Definition: SystemBase.h:675
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673
MatType type
Class for scalar variables (they are different).
unsigned int THREAD_ID
Definition: MooseTypes.h:97
void scalingFactor(Real factor)
Set the scaling factor for this variable.

◆ addVariable()

void SystemBase::addVariable ( const std::string &  var_name,
const FEType &  type,
Real  scale_factor,
const std::set< SubdomainID > *const  active_subdomains = NULL 
)
virtual

Adds a variable to the system.

Parameters
var_namename of the variable
typeFE type of the variable
scale_factorthe scaling factor for the variable
active_subdomainsa list of subdomain ids this variable is active on

Reimplemented in AuxiliarySystem.

Definition at line 582 of file SystemBase.C.

Referenced by DisplacedProblem::addAuxVariable(), AuxiliarySystem::addVariable(), and DisplacedProblem::addVariable().

586 {
587  unsigned int var_num = system().add_variable(var_name, type, active_subdomains);
588  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
589  {
590  // FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in
591  // MooseVariableBase.
592  MooseVariableBase * var;
593  if (type == FEType(0, MONOMIAL))
594  var = new MooseVariableConstMonomial(
595  var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
596  else if (type == FEType(FIRST, NEDELEC_ONE) || type.family == LAGRANGE_VEC)
597  var =
598  new VectorMooseVariable(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
599  else
600  var = new MooseVariable(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
601 
602  var->scalingFactor(scale_factor);
603  _vars[tid].add(var_name, var);
604  }
605  if (active_subdomains == nullptr)
606  _var_map[var_num] = std::set<SubdomainID>();
607  else
608  for (const auto subdomain_id : *active_subdomains)
609  _var_map[var_num].insert(subdomain_id);
610 }
virtual Assembly & assembly(THREAD_ID tid)=0
MooseVariableFE< Real > MooseVariable
Definition: Adaptivity.h:30
SubProblem & _subproblem
Definition: SystemBase.h:663
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:699
virtual System & system()=0
Get the reference to the libMesh system.
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
Definition: SystemBase.h:675
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673
MatType type
MooseVariableFE< VectorValue< Real > > VectorMooseVariable
Definition: Adaptivity.h:32
unsigned int THREAD_ID
Definition: MooseTypes.h:97
void scalingFactor(Real factor)
Set the scaling factor for this variable.

◆ addVariableToCopy()

void SystemBase::addVariableToCopy ( const std::string &  dest_name,
const std::string &  source_name,
const std::string &  timestep 
)
virtual

Add info about variable that will be copied.

Parameters
dest_nameName of the nodal variable being used for copying into (name is from the exodusII file)
source_nameName of the nodal variable being used for copying from (name is from the exodusII file)
timestepTimestep in the file being used

Definition at line 891 of file SystemBase.C.

894 {
895  _var_to_copy.push_back(VarCopyInfo(dest_name, source_name, timestep));
896 }
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:701
Information about variables that will be copied.
Definition: SystemBase.h:73

◆ addVariableToZeroOnJacobian()

void SystemBase::addVariableToZeroOnJacobian ( std::string  var_name)
virtual

Adds this variable to the list of variables to be zeroed during each Jacobian evaluation.

Parameters
var_nameThe name of the variable to be zeroed.

Reimplemented in DisplacedSystem.

Definition at line 169 of file SystemBase.C.

Referenced by DisplacedSystem::addVariableToZeroOnJacobian(), ADKernel< compute_stage >::ADKernel(), DGKernel::DGKernel(), IntegratedBC::IntegratedBC(), InterfaceKernel::InterfaceKernel(), Kernel::Kernel(), NodalBC::NodalBC(), and NodalKernel::NodalKernel().

170 {
171  _vars_to_be_zeroed_on_jacobian.push_back(var_name);
172 }
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
Definition: SystemBase.h:678

◆ addVariableToZeroOnResidual()

void SystemBase::addVariableToZeroOnResidual ( std::string  var_name)
virtual

Adds this variable to the list of variables to be zeroed during each residual evaluation.

Parameters
var_nameThe name of the variable to be zeroed.

Reimplemented in DisplacedSystem.

Definition at line 163 of file SystemBase.C.

Referenced by DisplacedSystem::addVariableToZeroOnResidual(), ADKernel< compute_stage >::ADKernel(), DGKernel::DGKernel(), IntegratedBC::IntegratedBC(), InterfaceKernel::InterfaceKernel(), Kernel::Kernel(), NodalBC::NodalBC(), and NodalKernel::NodalKernel().

164 {
165  _vars_to_be_zeroed_on_residual.push_back(var_name);
166 }
std::vector< std::string > _vars_to_be_zeroed_on_residual
Definition: SystemBase.h:677

◆ addVector() [1/2]

NumericVector< Number > & SystemBase::addVector ( const std::string &  vector_name,
const bool  project,
const ParallelType  type 
)
virtual

Adds a solution length vector to the system.

Parameters
vector_nameThe name of the vector.
projectWhether or not to project this vector when doing mesh refinement. If the vector is just going to be recomputed then there is no need to project it.
typeWhat type of parallel vector. This is usually either PARALLEL or GHOSTED. GHOSTED is needed if you are going to be accessing off-processor entries. The ghosting pattern is the same as the solution vector.

Reimplemented in AuxiliarySystem.

Definition at line 511 of file SystemBase.C.

Referenced by ActuallyExplicitEuler::ActuallyExplicitEuler(), NonlinearSystemBase::addDotVectors(), NonlinearSystemBase::addExtraVectors(), AStableDirk4::AStableDirk4(), NonlinearSystemBase::getResidualNonTimeVector(), NonlinearSystemBase::getResidualTimeVector(), FEProblemBase::initNullSpaceVectors(), LStableDirk3::LStableDirk3(), LStableDirk4::LStableDirk4(), NonlinearSystemBase::residualGhosted(), saveOldSolutions(), and Transient::Transient().

512 {
513  if (hasVector(vector_name))
514  return getVector(vector_name);
515 
516  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
517  return vec;
518 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:670
virtual System & system()=0
Get the reference to the libMesh system.
MatType type
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:720

◆ addVector() [2/2]

NumericVector< Number > & SystemBase::addVector ( TagID  tag,
const bool  project,
const ParallelType  type 
)

Adds a solution length vector to the system with the specified TagID.

Parameters
tag_nameThe name of the tag
projectWhether or not to project this vector when doing mesh refinement. If the vector is just going to be recomputed then there is no need to project it.
typeWhat type of parallel vector. This is usually either PARALLEL or GHOSTED. GHOSTED is needed if you are going to be accessing off-processor entries. The ghosting pattern is the same as the solution vector.

Definition at line 521 of file SystemBase.C.

522 {
523  if (!_subproblem.vectorTagExists(tag))
524  mooseError("Cannot add a tagged vector with vector_tag, ",
525  tag,
526  ", that tag does not exist in System ",
527  name());
528 
529  if (hasVector(tag))
530  return getVector(tag);
531 
532  auto vector_name = _subproblem.vectorTagName(tag);
533 
534  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
535 
536  if (_tagged_vectors.size() < tag + 1)
537  _tagged_vectors.resize(tag + 1);
538 
539  _tagged_vectors[tag] = &vec;
540 
541  return vec;
542 }
virtual const std::string & name() const
Definition: SystemBase.h:638
virtual TagName vectorTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:95
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:670
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:100
virtual System & system()=0
Get the reference to the libMesh system.
MatType type
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:684
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:720

◆ associateMatrixToTag()

void SystemBase::associateMatrixToTag ( SparseMatrix< Number > &  matrix,
TagID  tag 
)
virtual

associate a matirx to a tag

Reimplemented in DisplacedSystem.

Definition at line 788 of file SystemBase.C.

Referenced by DisplacedSystem::associateMatrixToTag(), and NonlinearSystemBase::computeJacobian().

789 {
790  mooseAssert(_subproblem.matrixTagExists(tag),
791  "Cannot associate Matrix with matrix_tag : " << tag << "that does not exist");
792 
793  if (_tagged_matrices.size() < tag + 1)
794  _tagged_matrices.resize(tag + 1);
795 
796  _tagged_matrices[tag] = &matrix;
797 }
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:686
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:118
SubProblem & _subproblem
Definition: SystemBase.h:663

◆ associateVectorToTag()

void SystemBase::associateVectorToTag ( NumericVector< Number > &  vec,
TagID  tag 
)
virtual

Associate a vector for a given tag.

Reimplemented in DisplacedSystem.

Definition at line 734 of file SystemBase.C.

Referenced by DisplacedSystem::associateVectorToTag(), NonlinearSystemBase::computeNodalBCs(), and NonlinearSystemBase::computeResidualTag().

735 {
736  mooseAssert(_subproblem.vectorTagExists(tag),
737  "You can't associate a tag that does not exist " << tag);
738  if (_tagged_vectors.size() < tag + 1)
739  _tagged_vectors.resize(tag + 1);
740 
741  _tagged_vectors[tag] = &vec;
742 }
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:100
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:684

◆ augmentSendList()

void SystemBase::augmentSendList ( std::vector< dof_id_type > &  send_list)
virtual

Will modify the send_list to add all of the extra ghosted dofs for this system.

Reimplemented in DisplacedSystem.

Definition at line 399 of file SystemBase.C.

Referenced by DisplacedSystem::augmentSendList(), and extraSendList().

400 {
401  std::set<dof_id_type> & ghosted_elems = _subproblem.ghostedElems();
402 
403  DofMap & dof_map = dofMap();
404 
405  std::vector<dof_id_type> dof_indices;
406 
407  System & sys = system();
408 
409  unsigned int sys_num = sys.number();
410 
411  unsigned int n_vars = sys.n_vars();
412 
413  for (const auto & elem_id : ghosted_elems)
414  {
415  Elem * elem = _mesh.elemPtr(elem_id);
416 
417  if (elem->active())
418  {
419  dof_map.dof_indices(elem, dof_indices);
420 
421  // Only need to ghost it if it's actually not on this processor
422  for (const auto & dof : dof_indices)
423  if (dof < dof_map.first_dof() || dof >= dof_map.end_dof())
424  send_list.push_back(dof);
425 
426  // Now add the DoFs from all of the nodes. This is necessary because of block
427  // restricted variables. A variable might not live _on_ this element but it
428  // might live on nodes connected to this element.
429  for (unsigned int n = 0; n < elem->n_nodes(); n++)
430  {
431  Node * node = elem->node_ptr(n);
432 
433  // Have to get each variable's dofs
434  for (unsigned int v = 0; v < n_vars; v++)
435  {
436  const Variable & var = sys.variable(v);
437  unsigned int var_num = var.number();
438  unsigned int n_comp = var.n_components();
439 
440  // See if this variable has any dofs at this node
441  if (node->n_dofs(sys_num, var_num) > 0)
442  {
443  // Loop over components of the variable
444  for (unsigned int c = 0; c < n_comp; c++)
445  send_list.push_back(node->dof_number(sys_num, var_num, c));
446  }
447  }
448  }
449  }
450  }
451 }
virtual Elem * elemPtr(const dof_id_type i)
Definition: MooseMesh.C:2219
virtual DofMap & dofMap()
Gets the dof map.
Definition: SystemBase.C:885
DofMap & dof_map
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
Definition: SubProblem.h:493
virtual System & system()=0
Get the reference to the libMesh system.
MooseMesh & _mesh
Definition: SystemBase.h:668
PetscInt n

◆ augmentSparsity()

virtual void SystemBase::augmentSparsity ( SparsityPattern::Graph &  sparsity,
std::vector< dof_id_type > &  n_nz,
std::vector< dof_id_type > &  n_oz 
)
pure virtual

Will modify the sparsity pattern to add logical geometric connections.

Implemented in NonlinearSystemBase, DisplacedSystem, and AuxiliarySystem.

Referenced by extraSparsity().

◆ closeTaggedMatrices()

void SystemBase::closeTaggedMatrices ( const std::set< TagID > &  tags)

Close all matrices associated the tags.

Definition at line 780 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

781 {
782  for (auto tag : tags)
783  if (hasMatrix(tag))
784  getMatrix(tag).close();
785 }
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:766
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:772

◆ closeTaggedVectors()

void SystemBase::closeTaggedVectors ( const std::set< TagID > &  tags)
virtual

Close all vectors for given tags.

Definition at line 545 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTags().

546 {
547  for (auto & tag : tags)
548  {
549  mooseAssert(_subproblem.vectorTagExists(tag), "Tag: " << tag << " does not exsit");
550  getVector(tag).close();
551  }
552 }
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:100
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:720

◆ computeVariables()

virtual void SystemBase::computeVariables ( const NumericVector< Number > &  )
inlinevirtual

Definition at line 653 of file SystemBase.h.

653 {};

◆ copyOldSolutions()

void SystemBase::copyOldSolutions ( )
virtual

Shifts the solutions backwards in time.

Definition at line 971 of file SystemBase.C.

Referenced by EigenExecutionerBase::inversePowerIteration().

972 {
975  if (solutionUDotOld())
977  if (solutionUDotDotOld())
981 }
virtual NumericVector< Number > * solutionUDot()=0
virtual NumericVector< Number > & solutionOld()=0
virtual NumericVector< Number > * solutionUDotDotOld()=0
virtual NumericVector< Number > * solutionPreviousNewton()=0
virtual NumericVector< Number > & solutionOlder()=0
virtual NumericVector< Number > * solutionUDotOld()=0
virtual NumericVector< Number > * solutionUDotDot()=0
virtual const NumericVector< Number > *& currentSolution()=0
The solution vector that is currently being operated on.

◆ copySolutionsBackwards()

void SystemBase::copySolutionsBackwards ( )
virtual

Copy current solution into old and older.

Definition at line 954 of file SystemBase.C.

955 {
956  system().update();
959  if (solutionUDotOld())
961  if (solutionUDotDotOld())
965 }
virtual NumericVector< Number > * solutionUDot()=0
virtual NumericVector< Number > & solutionOld()=0
virtual NumericVector< Number > * solutionUDotDotOld()=0
virtual NumericVector< Number > * solutionPreviousNewton()=0
virtual System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > & solutionOlder()=0
virtual NumericVector< Number > * solutionUDotOld()=0
virtual NumericVector< Number > * solutionUDotDot()=0
virtual const NumericVector< Number > *& currentSolution()=0
The solution vector that is currently being operated on.

◆ copyVars()

void SystemBase::copyVars ( ExodusII_IO &  io)

Definition at line 899 of file SystemBase.C.

900 {
901  int n_steps = io.get_num_time_steps();
902 
903  bool did_copy = false;
904  for (const auto & vci : _var_to_copy)
905  {
906  int timestep = -1;
907 
908  if (vci._timestep == "LATEST")
909  // Use the last time step in the file from which to retrieve the solution
910  timestep = n_steps;
911  else
912  {
913  timestep = MooseUtils::convert<int>(vci._timestep);
914  if (timestep > n_steps)
915  mooseError("Invalid value passed as \"initial_from_file_timestep\". Expected \"LATEST\" or "
916  "a valid integer between 1 and ",
917  n_steps,
918  " inclusive, received ",
919  vci._timestep);
920  }
921 
922  did_copy = true;
923  if (getVariable(0, vci._dest_name).isNodal())
924  io.copy_nodal_solution(system(), vci._dest_name, vci._source_name, timestep);
925  else
926  io.copy_elemental_solution(system(), vci._dest_name, vci._source_name, timestep);
927  }
928 
929  if (did_copy)
930  solution().close();
931 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
MooseVariableFEBase & getVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:101
virtual bool isNodal() const =0
Is this variable nodal.
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:701
int convert< int >(const std::string &str, bool throw_on_failure)
Definition: MooseUtils.C:667
virtual System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > & solution()=0

◆ currentSolution()

virtual const NumericVector<Number>*& SystemBase::currentSolution ( )
pure virtual

◆ deactiveAllMatrixTags()

void SystemBase::deactiveAllMatrixTags ( )
virtual

Make matrices inactive.

Definition at line 839 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTags(), and NonlinearSystemBase::setInitialSolution().

840 {
841  auto num_matrix_tags = _subproblem.numMatrixTags();
842 
843  _matrix_tag_active_flags.resize(num_matrix_tags);
844 
845  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
846  _matrix_tag_active_flags[tag] = false;
847 }
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:688
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:145

◆ deactiveMatrixTag()

void SystemBase::deactiveMatrixTag ( TagID  tag)
virtual

deactive a matrix for tag

Definition at line 827 of file SystemBase.C.

828 {
829  mooseAssert(_subproblem.matrixTagExists(tag),
830  "Cannot deactivate Matrix with matrix_tag : " << tag << "that does not exist");
831 
832  if (_matrix_tag_active_flags.size() < tag + 1)
833  _matrix_tag_active_flags.resize(tag + 1);
834 
835  _matrix_tag_active_flags[tag] = false;
836 }
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:118
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:688
SubProblem & _subproblem
Definition: SystemBase.h:663

◆ disassociateAllTaggedMatrices()

void SystemBase::disassociateAllTaggedMatrices ( )
virtual

Clear all tagged matrices.

Reimplemented in DisplacedSystem.

Definition at line 872 of file SystemBase.C.

Referenced by DisplacedSystem::disassociateAllTaggedMatrices().

873 {
874  for (auto & matrix : _tagged_matrices)
875  matrix = nullptr;
876 }
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:686

◆ disassociateAllTaggedVectors()

void SystemBase::disassociateAllTaggedVectors ( )
virtual

Disassociate all vectors, and then hasVector() will return false.

Reimplemented in DisplacedSystem.

Definition at line 759 of file SystemBase.C.

Referenced by DisplacedSystem::disassociateAllTaggedVectors().

760 {
761  for (auto & tagged_vector : _tagged_vectors)
762  tagged_vector = nullptr;
763 }
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:684

◆ disassociateMatrixFromTag()

void SystemBase::disassociateMatrixFromTag ( SparseMatrix< Number > &  matrix,
TagID  tag 
)
virtual

disassociate a matirx from a tag

Reimplemented in DisplacedSystem.

Definition at line 800 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeJacobian(), and DisplacedSystem::disassociateMatrixFromTag().

801 {
802  mooseAssert(_subproblem.matrixTagExists(tag),
803  "Cannot disassociate Matrix with matrix_tag : " << tag << "that does not exist");
804 
805  if (_tagged_matrices.size() < tag + 1)
806  _tagged_matrices.resize(tag + 1);
807 
808  if (_tagged_matrices[tag] != &matrix)
809  mooseError("You can not disassociate a matrix from a tag which it was not associated to");
810 
811  _tagged_matrices[tag] = nullptr;
812 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:686
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:118
SubProblem & _subproblem
Definition: SystemBase.h:663

◆ disassociateVectorFromTag()

void SystemBase::disassociateVectorFromTag ( NumericVector< Number > &  vec,
TagID  tag 
)
virtual

Associate a vector for a given tag.

Reimplemented in DisplacedSystem.

Definition at line 745 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeNodalBCs(), NonlinearSystemBase::computeResidualTag(), and DisplacedSystem::disassociateVectorFromTag().

746 {
747  mooseAssert(_subproblem.vectorTagExists(tag),
748  "You can't associate a tag that does not exist " << tag);
749  if (_tagged_vectors.size() < tag + 1)
750  _tagged_vectors.resize(tag + 1);
751 
752  if (_tagged_vectors[tag] != &vec)
753  mooseError("You can not disassociate a vector from a tag which it was not associated to");
754 
755  _tagged_vectors[tag] = nullptr;
756 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:100
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:684

◆ dofMap()

DofMap & SystemBase::dofMap ( )
virtual

◆ duDotDotDu()

virtual Number& SystemBase::duDotDotDu ( )
inlinevirtual

◆ duDotDu()

virtual Number& SystemBase::duDotDu ( )
inlinevirtual

◆ getFieldVariable() [1/2]

template<typename T >
MooseVariableFE< T > & SystemBase::getFieldVariable ( THREAD_ID  tid,
const std::string &  var_name 
)

Gets a reference to a variable of with specified name.

Parameters
tidThread id
var_namevariable name
Returns
reference the variable (class)

Definition at line 121 of file SystemBase.C.

Referenced by Assembly::copyFaceShapes(), Assembly::copyNeighborShapes(), Assembly::copyShapes(), DisplacedProblem::getStandardVariable(), and DisplacedProblem::getVectorVariable().

122 {
123  return *_vars[tid].getFieldVariable<T>(var_name);
124 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ getFieldVariable() [2/2]

template<typename T >
MooseVariableFE< T > & SystemBase::getFieldVariable ( THREAD_ID  tid,
unsigned int  var_number 
)

Gets a reference to a variable with specified number.

Parameters
tidThread id
var_numberlibMesh variable number
Returns
reference the variable (class)

Definition at line 128 of file SystemBase.C.

129 {
130  return *_vars[tid].getFieldVariable<T>(var_number);
131 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ getMatrix()

SparseMatrix< Number > & SystemBase::getMatrix ( TagID  tag)
virtual

◆ getMaxVarNDofsPerElem()

size_t SystemBase::getMaxVarNDofsPerElem ( )
inline

Gets the maximum number of dofs used by any one variable on any one element.

Returns
The max

Definition at line 411 of file SystemBase.h.

411 { return _max_var_n_dofs_per_elem; }
size_t _max_var_n_dofs_per_elem
Maximum number of dofs for any one variable on any one element.
Definition: SystemBase.h:704

◆ getMinQuadratureOrder()

Order SystemBase::getMinQuadratureOrder ( )
virtual

Get minimal quadrature order needed for integrating variables in this system.

Returns
The minimal order of quadrature

Reimplemented in AuxiliarySystem.

Definition at line 212 of file SystemBase.C.

213 {
214  Order order = CONSTANT;
215  const std::vector<MooseVariableFEBase *> & vars = _vars[0].fieldVariables();
216  for (const auto & var : vars)
217  {
218  FEType fe_type = var->feType();
219  if (fe_type.default_quadrature_order() > order)
220  order = fe_type.default_quadrature_order();
221  }
222 
223  return order;
224 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ getScalarVariable() [1/2]

MooseVariableScalar & SystemBase::getScalarVariable ( THREAD_ID  tid,
const std::string &  var_name 
)
virtual

Gets a reference to a scalar variable with specified number.

Parameters
tidThread id
var_nameA string which is the name of the variable to get.
Returns
reference the variable (class)

Definition at line 134 of file SystemBase.C.

Referenced by Assembly::addJacobianOffDiagScalar(), IntegratedBC::computeJacobianBlockScalar(), VectorIntegratedBC::computeJacobianBlockScalar(), ODEKernel::computeOffDiagJacobian(), Kernel::computeOffDiagJacobianScalar(), VectorKernel::computeOffDiagJacobianScalar(), DisplacedProblem::getScalarVariable(), and Assembly::init().

135 {
136  MooseVariableScalar * var = dynamic_cast<MooseVariableScalar *>(_vars[tid].getVariable(var_name));
137  if (!var)
138  mooseError("Scalar variable '" + var_name + "' does not exist in this system");
139  return *var;
140 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673
Class for scalar variables (they are different).

◆ getScalarVariable() [2/2]

MooseVariableScalar & SystemBase::getScalarVariable ( THREAD_ID  tid,
unsigned int  var_number 
)
virtual

Gets a reference to a variable with specified number.

Parameters
tidThread id
var_numberlibMesh variable number
Returns
reference the variable (class)

Definition at line 143 of file SystemBase.C.

144 {
145  MooseVariableScalar * var =
146  dynamic_cast<MooseVariableScalar *>(_vars[tid].getVariable(var_number));
147  if (!var)
148  mooseError("variable #" + Moose::stringify(var_number) + " does not exist in this system");
149  return *var;
150 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:58
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673
Class for scalar variables (they are different).

◆ getScalarVariables()

const std::vector<MooseVariableScalar *>& SystemBase::getScalarVariables ( THREAD_ID  tid)
inline

◆ getSubdomainsForVar()

const std::set<SubdomainID>& SystemBase::getSubdomainsForVar ( unsigned int  var_number) const
inline

Definition at line 560 of file SystemBase.h.

561  {
562  return _var_map.at(var_number);
563  }
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
Definition: SystemBase.h:675

◆ getVariable() [1/2]

MooseVariableFEBase & SystemBase::getVariable ( THREAD_ID  tid,
const std::string &  var_name 
)

Gets a reference to a variable of with specified name.

Parameters
tidThread id
var_namevariable name
Returns
reference the variable (class)

Definition at line 101 of file SystemBase.C.

Referenced by Assembly::addJacobianBlock(), Assembly::addJacobianBlockNonlocal(), Assembly::addJacobianNeighbor(), NonlocalIntegratedBC::computeJacobianBlock(), NonlocalIntegratedBC::computeNonlocalOffDiagJacobian(), NonlocalKernel::computeNonlocalOffDiagJacobian(), copyVars(), FieldSplitPreconditioner::FieldSplitPreconditioner(), FiniteDifferencePreconditioner::FiniteDifferencePreconditioner(), EqualValueEmbeddedConstraint::getConnectedDofIndices(), NodeElemConstraint::getConnectedDofIndices(), NodeFaceConstraint::getConnectedDofIndices(), Marker::getMarkerValue(), SubProblem::getVariableHelper(), Assembly::init(), NodalNormalsPreprocessor::initialize(), Assembly::initNonlocalCoupling(), PhysicsBasedPreconditioner::PhysicsBasedPreconditioner(), AddPeriodicBCAction::setPeriodicVars(), SingleMatrixPreconditioner::SingleMatrixPreconditioner(), and UpdateErrorVectorsThread::UpdateErrorVectorsThread().

102 {
103  MooseVariableFEBase * var = dynamic_cast<MooseVariableFEBase *>(_vars[tid].getVariable(var_name));
104  if (!var)
105  mooseError("Variable '" + var_name + "' does not exist in this system");
106  return *var;
107 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ getVariable() [2/2]

MooseVariableFEBase & SystemBase::getVariable ( THREAD_ID  tid,
unsigned int  var_number 
)

Gets a reference to a variable with specified number.

Parameters
tidThread id
var_numberlibMesh variable number
Returns
reference the variable (class)

Definition at line 110 of file SystemBase.C.

111 {
112  MooseVariableFEBase * var =
113  dynamic_cast<MooseVariableFEBase *>(_vars[tid].getVariable(var_number));
114  if (!var)
115  mooseError("variable #" + Moose::stringify(var_number) + " does not exist in this system");
116  return *var;
117 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:58
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ getVariableBlocks()

const std::set< SubdomainID > * SystemBase::getVariableBlocks ( unsigned int  var_number)
virtual

Get the block where a variable of this system is defined.

Parameters
var_numberThe number of the variable
Returns
the set of subdomain ids where the variable is active (defined)

Definition at line 153 of file SystemBase.C.

Referenced by PhysicsBasedPreconditioner::addSystem().

154 {
155  mooseAssert(_var_map.find(var_number) != _var_map.end(), "Variable does not exist.");
156  if (_var_map[var_number].empty())
157  return nullptr;
158  else
159  return &_var_map[var_number];
160 }
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
Definition: SystemBase.h:675

◆ getVariableNames()

const std::vector<VariableName>& SystemBase::getVariableNames ( ) const
inline

Definition at line 651 of file SystemBase.h.

Referenced by MooseEigenSystem::buildSystemDoFIndices(), NonlinearSystemBase::checkKernelCoverage(), and AddPeriodicBCAction::setPeriodicVars().

651 { return _vars[0].names(); };
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ getVariables()

const std::vector<MooseVariableFEBase *>& SystemBase::getVariables ( THREAD_ID  tid)
inline

◆ getVector() [1/2]

NumericVector< Number > & SystemBase::getVector ( const std::string &  name)
virtual

Get a raw NumericVector.

Get a raw NumericVector with the given name.

Reimplemented in DisplacedSystem.

Definition at line 720 of file SystemBase.C.

Referenced by Assembly::addCachedResiduals(), Assembly::addResidual(), Assembly::addResidualNeighbor(), Assembly::addResidualScalar(), AuxiliarySystem::addVector(), addVector(), closeTaggedVectors(), VectorNodalBC::computeResidual(), NodalBC::computeResidual(), NonlinearSystemBase::computeResidualTags(), DisplacedSystem::getVector(), MooseVariableScalar::reinit(), Transient::solveStep(), and zeroTaggedVectors().

721 {
722  return system().get_vector(name);
723 }
virtual const std::string & name() const
Definition: SystemBase.h:638
virtual System & system()=0
Get the reference to the libMesh system.

◆ getVector() [2/2]

NumericVector< Number > & SystemBase::getVector ( TagID  tag)
virtual

Get a raw NumericVector.

Reimplemented in DisplacedSystem.

Definition at line 726 of file SystemBase.C.

727 {
728  mooseAssert(hasVector(tag), "Cannot retrieve vector with residual_tag: " << tag);
729 
730  return *_tagged_vectors[tag];
731 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:670
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:684

◆ hasMatrix()

bool SystemBase::hasMatrix ( TagID  tag)
virtual

◆ hasScalarVariable()

bool SystemBase::hasScalarVariable ( const std::string &  var_name) const
virtual

Definition at line 646 of file SystemBase.C.

Referenced by ComputeFullJacobianThread::computeFaceJacobian(), ComputeFullJacobianThread::computeJacobian(), DisplacedProblem::getScalarVariable(), DisplacedProblem::hasScalarVariable(), and AddPeriodicBCAction::setPeriodicVars().

647 {
648  if (system().has_variable(var_name))
649  return system().variable_type(var_name).family == SCALAR;
650  else
651  return false;
652 }
virtual System & system()=0
Get the reference to the libMesh system.

◆ hasVariable()

bool SystemBase::hasVariable ( const std::string &  var_name) const
virtual

Query a system for a variable.

Parameters
var_namename of the variable
Returns
true if the variable exists

Definition at line 637 of file SystemBase.C.

Referenced by ADKernel< compute_stage >::ADKernel(), DGKernel::DGKernel(), FEProblemBase::duplicateVariableCheck(), DisplacedProblem::getStandardVariable(), DisplacedProblem::getSystem(), SubProblem::getVariableHelper(), DisplacedProblem::getVectorVariable(), DisplacedProblem::hasVariable(), InterfaceKernel::InterfaceKernel(), and Kernel::Kernel().

638 {
639  if (system().has_variable(var_name))
640  return system().variable_type(var_name).family != SCALAR;
641  else
642  return false;
643 }
virtual System & system()=0
Get the reference to the libMesh system.

◆ hasVector() [1/2]

bool SystemBase::hasVector ( const std::string &  tag_name) const

◆ hasVector() [2/2]

bool SystemBase::hasVector ( TagID  tag_id)
virtual

Check if the tagged vector exists in the system.

Reimplemented in DisplacedSystem.

Definition at line 711 of file SystemBase.C.

712 {
713  return tag < _tagged_vectors.size() && _tagged_vectors[tag];
714 }
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:684

◆ init()

virtual void SystemBase::init ( )
inlinevirtual

Initialize the system.

Reimplemented in NonlinearSystemBase, AuxiliarySystem, and DisplacedSystem.

Definition at line 119 of file SystemBase.h.

119 {};

◆ initializeObjects()

virtual void SystemBase::initializeObjects ( )
inlinevirtual

Called only once, just before the solve begins so objects can do some precalculations.

Definition at line 124 of file SystemBase.h.

124 {};

◆ isScalarVariable()

bool SystemBase::isScalarVariable ( unsigned int  var_name) const
virtual

Definition at line 655 of file SystemBase.C.

Referenced by ODEKernel::computeOffDiagJacobian(), Assembly::init(), and Assembly::initNonlocalCoupling().

656 {
657  return (system().variable(var_num).type().family == SCALAR);
658 }
virtual System & system()=0
Get the reference to the libMesh system.
MatType type

◆ matrixTagActive()

bool SystemBase::matrixTagActive ( TagID  tag)
virtual

If or not a matrix tag is active.

Definition at line 864 of file SystemBase.C.

865 {
866  mooseAssert(_subproblem.matrixTagExists(tag), "Matrix tag " << tag << " does not exist");
867 
868  return tag < _matrix_tag_active_flags.size() && _matrix_tag_active_flags[tag];
869 }
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:118
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:688
SubProblem & _subproblem
Definition: SystemBase.h:663

◆ mesh()

virtual MooseMesh& SystemBase::mesh ( )
inlinevirtual

◆ name()

virtual const std::string& SystemBase::name ( ) const
inlinevirtual

◆ nonTimeVectorTag()

TagID SystemBase::nonTimeVectorTag ( )
virtual

Reimplemented in NonlinearSystemBase, and DisplacedSystem.

Definition at line 697 of file SystemBase.C.

Referenced by DisplacedSystem::nonTimeVectorTag().

698 {
699  mooseError("Not implemented yet");
700  return 0;
701 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ number()

unsigned int SystemBase::number ( ) const
virtual

◆ nVariables()

unsigned int SystemBase::nVariables ( ) const
virtual

Get the number of variables in this system.

Returns
the number of variables

Definition at line 661 of file SystemBase.C.

Referenced by FieldSplitPreconditioner::FieldSplitPreconditioner(), FiniteDifferencePreconditioner::FiniteDifferencePreconditioner(), NonlinearSystemBase::getNodeDofs(), Assembly::init(), MaxVarNDofsPerElem::onElement(), PhysicsBasedPreconditioner::PhysicsBasedPreconditioner(), and SingleMatrixPreconditioner::SingleMatrixPreconditioner().

662 {
663  return _vars[0].names().size();
664 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ prepare()

void SystemBase::prepare ( THREAD_ID  tid)
virtual

Prepare the system for use.

Parameters
tidID of the thread

Definition at line 227 of file SystemBase.C.

Referenced by DisplacedProblem::prepare(), DisplacedProblem::reinitDirac(), and DisplacedProblem::reinitElemPhys().

228 {
230  {
231  const std::set<MooseVariableFEBase *> & active_elemental_moose_variables =
233  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
234  for (const auto & var : vars)
235  var->clearDofIndices();
236 
237  for (const auto & var : active_elemental_moose_variables)
238  if (&(var->sys()) == this)
239  var->prepare();
240  }
241  else
242  {
243  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
244  for (const auto & var : vars)
245  var->prepare();
246  }
247 }
virtual bool hasActiveElementalMooseVariables(THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition: SubProblem.C:242
virtual const std::set< MooseVariableFEBase * > & getActiveElementalMooseVariables(THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:236
SubProblem & _subproblem
Definition: SystemBase.h:663
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ prepareFace()

void SystemBase::prepareFace ( THREAD_ID  tid,
bool  resize_data 
)
virtual

Prepare the system for use on sides.

This will try to reuse the preparation done on the element.

Parameters
tidID of the thread
resize_dataPass True if this system needs to resize residual and jacobian datastructures based on preparing this face

Definition at line 250 of file SystemBase.C.

Referenced by DisplacedProblem::prepareFace().

251 {
252  // We only need to do something if the element prepare was restricted
254  {
255  const std::set<MooseVariableFEBase *> & active_elemental_moose_variables =
257 
258  std::vector<MooseVariableFEBase *> newly_prepared_vars;
259 
260  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
261  for (const auto & var : vars)
262  {
263  // If it wasn't in the active list, we need to prepare it
264  if (&(var->sys()) == this && !active_elemental_moose_variables.count(var))
265  {
266  var->prepare();
267  newly_prepared_vars.push_back(var);
268  }
269  }
270 
271  // Make sure to resize the residual and jacobian datastructures for all the new variables
272  if (resize_data)
273  for (const auto var_ptr : newly_prepared_vars)
274  {
275  _subproblem.assembly(tid).prepareVariable(var_ptr);
278  }
279  }
280 }
virtual bool hasActiveElementalMooseVariables(THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition: SubProblem.C:242
virtual Assembly & assembly(THREAD_ID tid)=0
virtual const std::set< MooseVariableFEBase * > & getActiveElementalMooseVariables(THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:236
void prepareVariableNonlocal(MooseVariableFEBase *var)
Definition: Assembly.C:1224
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual bool checkNonlocalCouplingRequirement()
Definition: SubProblem.h:62
void prepareVariable(MooseVariableFEBase *var)
Used for preparing the dense residual and jacobian blocks for one particular variable.
Definition: Assembly.C:1195
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ prepareNeighbor()

void SystemBase::prepareNeighbor ( THREAD_ID  tid)
virtual

Prepare the system for use.

Parameters
tidID of the thread

Definition at line 283 of file SystemBase.C.

Referenced by DisplacedProblem::reinitNeighbor(), and DisplacedProblem::reinitNeighborPhys().

284 {
285  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
286  for (const auto & var : vars)
287  var->prepareNeighbor();
288 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ reinitElem()

void SystemBase::reinitElem ( const Elem *  elem,
THREAD_ID  tid 
)
virtual

Reinit an element assembly info.

Parameters
elemWhich element we are reinitializing for
tidID of the thread

Reimplemented in AuxiliarySystem.

Definition at line 291 of file SystemBase.C.

Referenced by DisplacedProblem::reinitElem().

292 {
293 
295  {
296  const std::set<MooseVariableFEBase *> & active_elemental_moose_variables =
298  for (const auto & var : active_elemental_moose_variables)
299  if (&(var->sys()) == this)
300  var->computeElemValues();
301  }
302  else
303  {
304  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
305  for (const auto & var : vars)
306  var->computeElemValues();
307  }
308 }
virtual bool hasActiveElementalMooseVariables(THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition: SubProblem.C:242
virtual const std::set< MooseVariableFEBase * > & getActiveElementalMooseVariables(THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:236
SubProblem & _subproblem
Definition: SystemBase.h:663
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ reinitElemFace()

void SystemBase::reinitElemFace ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id,
THREAD_ID  tid 
)
virtual

Reinit assembly info for a side of an element.

Parameters
elemThe element
sideSide of of the element
bnd_idBoundary id on that side
tidThread ID

Reimplemented in AuxiliarySystem.

Definition at line 311 of file SystemBase.C.

Referenced by DisplacedProblem::reinitElemFace(), and DisplacedProblem::reinitNeighbor().

315 {
316  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
317  for (const auto & var : vars)
318  var->computeElemValuesFace();
319 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ reinitNeighbor()

void SystemBase::reinitNeighbor ( const Elem *  elem,
THREAD_ID  tid 
)
virtual

Compute the values of the variables at all the current points.

Definition at line 333 of file SystemBase.C.

Referenced by DisplacedProblem::reinitNeighborPhys().

334 {
335  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
336  for (const auto & var : vars)
337  var->computeNeighborValues();
338 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ reinitNeighborFace()

void SystemBase::reinitNeighborFace ( const Elem *  elem,
unsigned int  side,
BoundaryID  bnd_id,
THREAD_ID  tid 
)
virtual

Compute the values of the variables at all the current points.

Definition at line 322 of file SystemBase.C.

Referenced by DisplacedProblem::reinitNeighbor(), and DisplacedProblem::reinitNeighborPhys().

326 {
327  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
328  for (const auto & var : vars)
329  var->computeNeighborValuesFace();
330 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ reinitNode()

void SystemBase::reinitNode ( const Node *  node,
THREAD_ID  tid 
)
virtual

Reinit nodal assembly info.

Parameters
nodeNode to reinit for
tidThread ID

Definition at line 341 of file SystemBase.C.

Referenced by DisplacedProblem::reinitNode().

342 {
343  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
344  for (const auto & var : vars)
345  {
346  if (var->isNodal())
347  {
348  var->reinitNode();
349  var->computeNodalValues();
350  }
351  }
352 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ reinitNodeFace()

void SystemBase::reinitNodeFace ( const Node *  node,
BoundaryID  bnd_id,
THREAD_ID  tid 
)
virtual

Reinit nodal assembly info on a face.

Parameters
nodeNode to reinit
bnd_idBoundary ID
tidThread ID

Definition at line 355 of file SystemBase.C.

Referenced by DisplacedProblem::reinitNodeFace().

356 {
357  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
358  for (const auto & var : vars)
359  {
360  if (var->isNodal())
361  {
362  var->reinitNode();
363  var->computeNodalValues();
364  }
365  }
366 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ reinitNodes()

void SystemBase::reinitNodes ( const std::vector< dof_id_type > &  nodes,
THREAD_ID  tid 
)
virtual

Reinit variables at a set of nodes.

Parameters
nodesList of node ids to reinit
tidThread ID

Definition at line 369 of file SystemBase.C.

Referenced by DisplacedProblem::reinitNodes().

370 {
371  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
372  for (const auto & var : vars)
373  {
374  var->reinitNodes(nodes);
375  var->computeNodalValues();
376  }
377 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ reinitNodesNeighbor()

void SystemBase::reinitNodesNeighbor ( const std::vector< dof_id_type > &  nodes,
THREAD_ID  tid 
)
virtual

Reinit variables at a set of neighbor nodes.

Parameters
nodesList of node ids to reinit
tidThread ID

Definition at line 380 of file SystemBase.C.

Referenced by DisplacedProblem::reinitNodesNeighbor().

381 {
382  const std::vector<MooseVariableFEBase *> & vars = _vars[tid].fieldVariables();
383  for (const auto & var : vars)
384  {
385  var->reinitNodesNeighbor(nodes);
386  var->computeNodalNeighborValues();
387  }
388 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ reinitScalars()

void SystemBase::reinitScalars ( THREAD_ID  tid)
virtual

Reinit scalar varaibles.

Parameters
tidThread ID

Definition at line 391 of file SystemBase.C.

Referenced by DisplacedProblem::reinitScalars().

392 {
393  const std::vector<MooseVariableScalar *> & vars = _vars[tid].scalars();
394  for (const auto & var : vars)
395  var->reinit();
396 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673

◆ removeMatrix()

virtual void SystemBase::removeMatrix ( TagID  )
inlinevirtual

Removes a jacobian sized vector.

Parameters
tag_nameThe name of the tag

Definition at line 633 of file SystemBase.h.

634  {
635  mooseError("Removing a matrix is not supported for this type of system!");
636  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ removeVector() [1/2]

virtual void SystemBase::removeVector ( const std::string &  name)
inlinevirtual

Remove a vector from the system with the given name.

Definition at line 568 of file SystemBase.h.

Referenced by restoreOldSolutions().

568 { system().remove_vector(name); }
virtual const std::string & name() const
Definition: SystemBase.h:638
virtual System & system()=0
Get the reference to the libMesh system.

◆ removeVector() [2/2]

void SystemBase::removeVector ( TagID  tag_id)
virtual

Remove a solution length vector from the system with the specified TagID.

Parameters
tag_idTag ID

Definition at line 565 of file SystemBase.C.

566 {
567  if (!_subproblem.vectorTagExists(tag_id))
568  mooseError("Cannot remove an unexisting tag or its associated vector, ",
569  tag_id,
570  ", that tag does not exist in System ",
571  name());
572 
573  if (hasVector(tag_id))
574  {
575  auto vector_name = _subproblem.vectorTagName(tag_id);
576  system().remove_vector(vector_name);
577  _tagged_vectors[tag_id] = nullptr;
578  }
579 }
virtual const std::string & name() const
Definition: SystemBase.h:638
virtual TagName vectorTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:95
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:670
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:100
virtual System & system()=0
Get the reference to the libMesh system.
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:684

◆ residualCopy()

virtual NumericVector<Number>& SystemBase::residualCopy ( )
inlinevirtual

Reimplemented in NonlinearSystemBase, and DisplacedSystem.

Definition at line 289 of file SystemBase.h.

Referenced by DisplacedSystem::residualCopy().

290  {
291  mooseError("This system does not support getting a copy of the residual");
292  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ residualGhosted()

virtual NumericVector<Number>& SystemBase::residualGhosted ( )
inlinevirtual

Reimplemented in NonlinearSystemBase, and DisplacedSystem.

Definition at line 293 of file SystemBase.h.

Referenced by DisplacedSystem::residualGhosted().

294  {
295  mooseError("This system does not support getting a ghosted copy of the residual");
296  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ residualVectorTag()

TagID SystemBase::residualVectorTag ( )
virtual

Reimplemented in NonlinearSystemBase.

Definition at line 704 of file SystemBase.C.

705 {
706  mooseError("Not implemented yet");
707  return 0;
708 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ restoreOldSolutions()

void SystemBase::restoreOldSolutions ( )
virtual

Restore the old and older solutions when the saved solutions present.

Definition at line 482 of file SystemBase.C.

Referenced by DisplacedProblem::restoreOldSolutions().

483 {
484  if (_saved_old)
485  {
486  solutionOld() = *_saved_old;
487  removeVector("save_solution_old");
488  _saved_old = nullptr;
489  }
490  if (_saved_older)
491  {
493  removeVector("save_solution_older");
494  _saved_older = nullptr;
495  }
497  {
499  removeVector("save_solution_dot_old");
500  _saved_dot_old = NULL;
501  }
503  {
505  removeVector("save_solution_dotdot_old");
506  _saved_dotdot_old = NULL;
507  }
508 }
virtual NumericVector< Number > & solutionOld()=0
virtual NumericVector< Number > * solutionUDotDotOld()=0
virtual void removeVector(const std::string &name)
Remove a vector from the system with the given name.
Definition: SystemBase.h:568
NumericVector< Real > * _saved_older
Definition: SystemBase.h:692
NumericVector< Real > * _saved_dot_old
Definition: SystemBase.h:695
NumericVector< Real > * _saved_old
Definition: SystemBase.h:691
virtual NumericVector< Number > & solutionOlder()=0
NumericVector< Real > * _saved_dotdot_old
Definition: SystemBase.h:696
virtual NumericVector< Number > * solutionUDotOld()=0

◆ restoreSolutions()

void SystemBase::restoreSolutions ( )
virtual

Restore current solutions (call after your solve failed)

Reimplemented in NonlinearSystemBase.

Definition at line 987 of file SystemBase.C.

Referenced by NonlinearSystemBase::restoreSolutions().

988 {
989  *(const_cast<NumericVector<Number> *&>(currentSolution())) = solutionOld();
990  solution() = solutionOld();
991  if (solutionUDotOld())
993  if (solutionUDotDotOld())
997  system().update();
998 }
virtual NumericVector< Number > * solutionUDot()=0
virtual NumericVector< Number > & solutionOld()=0
virtual NumericVector< Number > * solutionUDotDotOld()=0
virtual NumericVector< Number > * solutionPreviousNewton()=0
virtual System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > & solution()=0
virtual NumericVector< Number > * solutionUDotOld()=0
virtual NumericVector< Number > * solutionUDotDot()=0
virtual const NumericVector< Number > *& currentSolution()=0
The solution vector that is currently being operated on.

◆ saveOldSolutions()

void SystemBase::saveOldSolutions ( )
virtual

Save the old and older solutions.

Definition at line 457 of file SystemBase.C.

Referenced by DisplacedProblem::saveOldSolutions().

458 {
459  if (!_saved_old)
460  _saved_old = &addVector("save_solution_old", false, PARALLEL);
461  if (!_saved_older)
462  _saved_older = &addVector("save_solution_older", false, PARALLEL);
464  _saved_dot_old = &addVector("save_solution_dot_old", false, PARALLEL);
466  _saved_dotdot_old = &addVector("save_solution_dotdot_old", false, PARALLEL);
467 
468  *_saved_old = solutionOld();
470 
471  if (solutionUDotOld())
473 
474  if (solutionUDotDotOld())
476 }
virtual NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type)
Adds a solution length vector to the system.
Definition: SystemBase.C:511
virtual NumericVector< Number > & solutionOld()=0
virtual NumericVector< Number > * solutionUDotDotOld()=0
NumericVector< Real > * _saved_older
Definition: SystemBase.h:692
NumericVector< Real > * _saved_dot_old
Definition: SystemBase.h:695
NumericVector< Real > * _saved_old
Definition: SystemBase.h:691
virtual NumericVector< Number > & solutionOlder()=0
NumericVector< Real > * _saved_dotdot_old
Definition: SystemBase.h:696
virtual NumericVector< Number > * solutionUDotOld()=0

◆ serializedSolution()

virtual NumericVector<Number>& SystemBase::serializedSolution ( )
pure virtual

Returns a reference to a serialized version of the solution vector for this subproblem.

Implemented in NonlinearSystemBase, AuxiliarySystem, and DisplacedSystem.

Referenced by DisplacedSystem::serializedSolution().

◆ solution()

virtual NumericVector<Number>& SystemBase::solution ( )
pure virtual

◆ solutionOld()

virtual NumericVector<Number>& SystemBase::solutionOld ( )
pure virtual

◆ solutionOlder()

virtual NumericVector<Number>& SystemBase::solutionOlder ( )
pure virtual

◆ solutionPreviousNewton()

virtual NumericVector<Number>* SystemBase::solutionPreviousNewton ( )
pure virtual

◆ solutionUDot()

virtual NumericVector<Number>* SystemBase::solutionUDot ( )
pure virtual

◆ solutionUDotDot()

virtual NumericVector<Number>* SystemBase::solutionUDotDot ( )
pure virtual

◆ solutionUDotDotOld()

virtual NumericVector<Number>* SystemBase::solutionUDotDotOld ( )
pure virtual

◆ solutionUDotOld()

virtual NumericVector<Number>* SystemBase::solutionUDotOld ( )
pure virtual

◆ solve()

void SystemBase::solve ( )
virtual

Solve the system (using libMesh magic)

Reimplemented in NonlinearSystemBase, NonlinearEigenSystem, DumpObjectsNonlinearSystem, and NonlinearSystem.

Definition at line 945 of file SystemBase.C.

946 {
947  system().solve();
948 }
virtual System & system()=0
Get the reference to the libMesh system.

◆ subproblem()

virtual SubProblem& SystemBase::subproblem ( )
inlinevirtual

◆ system() [1/2]

virtual System& SystemBase::system ( )
pure virtual

◆ system() [2/2]

virtual const System& SystemBase::system ( ) const
pure virtual

◆ systemMatrixTag()

TagID SystemBase::systemMatrixTag ( )
virtual

Return the Matrix Tag ID for System.

Reimplemented in NonlinearSystemBase.

Definition at line 690 of file SystemBase.C.

691 {
692  mooseError("Not implemented yet");
693  return 0;
694 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ timeMatrixTag()

TagID SystemBase::timeMatrixTag ( )
virtual

Return the Matrix Tag ID for Time.

Definition at line 683 of file SystemBase.C.

684 {
685  mooseError("Not implemented yet");
686  return 0;
687 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ timeVectorTag()

TagID SystemBase::timeVectorTag ( )
virtual

Ideally, we should not need this API.

There exists a really bad API "addCachedResidualDirectly " in FEProblem and DisplacedProblem This API should go away once addCachedResidualDirectly is removed in the future Return Tag ID for Time

Reimplemented in NonlinearSystemBase, and DisplacedSystem.

Definition at line 676 of file SystemBase.C.

Referenced by DisplacedSystem::timeVectorTag().

677 {
678  mooseError("Not implemented yet");
679  return 0;
680 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208

◆ update()

void SystemBase::update ( )
virtual

◆ zeroTaggedVectors()

void SystemBase::zeroTaggedVectors ( const std::set< TagID > &  tags)
virtual

Zero all vectors for given tags.

Definition at line 555 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTags().

556 {
557  for (auto & tag : tags)
558  {
559  mooseAssert(_subproblem.vectorTagExists(tag), "Tag: " << tag << " does not exsit");
560  getVector(tag).zero();
561  }
562 }
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:100
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:720

◆ zeroVariables()

void SystemBase::zeroVariables ( std::vector< std::string > &  vars_to_be_zeroed)
virtual

Zero out the solution for the list of variables passed in.

@ param vars_to_be_zeroed The variable names in this vector will have their solutions set to zero after this call

Reimplemented in DisplacedSystem.

Definition at line 175 of file SystemBase.C.

Referenced by DisplacedSystem::zeroVariables(), zeroVariablesForJacobian(), and zeroVariablesForResidual().

176 {
177  if (vars_to_be_zeroed.size() > 0)
178  {
179  NumericVector<Number> & solution = this->solution();
180 
181  AllLocalDofIndicesThread aldit(system(), vars_to_be_zeroed);
182  ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
183  Threads::parallel_reduce(elem_range, aldit);
184 
185  const std::set<dof_id_type> & dof_indices_to_zero = aldit._all_dof_indices;
186 
187  solution.close();
188 
189  for (const auto & dof : dof_indices_to_zero)
190  solution.set(dof, 0);
191 
192  solution.close();
193 
194  // Call update to update the current_local_solution for this system
195  system().update();
196  }
197 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:779
Grab all the local dof indices for the variables passed in, in the system passed in.
virtual System & system()=0
Get the reference to the libMesh system.
MooseMesh & _mesh
Definition: SystemBase.h:668
virtual NumericVector< Number > & solution()=0

◆ zeroVariablesForJacobian()

void SystemBase::zeroVariablesForJacobian ( )
virtual

Zero out the solution for the variables that were registered as needing to have their solutions zeroed on out on Jacobian evaluation by a call to addVariableToZeroOnResidual()

Definition at line 206 of file SystemBase.C.

207 {
209 }
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
Definition: SystemBase.h:678
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:175

◆ zeroVariablesForResidual()

void SystemBase::zeroVariablesForResidual ( )
virtual

Zero out the solution for the variables that were registered as needing to have their solutions zeroed on out on residual evaluation by a call to addVariableToZeroOnResidual()

Definition at line 200 of file SystemBase.C.

201 {
203 }
std::vector< std::string > _vars_to_be_zeroed_on_residual
Definition: SystemBase.h:677
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:175

Member Data Documentation

◆ _app

MooseApp& SystemBase::_app
protected

◆ _du_dot_du

Real SystemBase::_du_dot_du
protected

Definition at line 680 of file SystemBase.h.

Referenced by duDotDu().

◆ _du_dotdot_du

Real SystemBase::_du_dotdot_du
protected

Definition at line 681 of file SystemBase.h.

Referenced by duDotDotDu().

◆ _factory

Factory& SystemBase::_factory
protected

◆ _matrix_tag_active_flags

std::vector<bool> SystemBase::_matrix_tag_active_flags
protected

Active flags for tagged matrices.

Definition at line 688 of file SystemBase.h.

Referenced by activeAllMatrixTags(), activeMatrixTag(), deactiveAllMatrixTags(), deactiveMatrixTag(), and matrixTagActive().

◆ _max_var_n_dofs_per_elem

size_t SystemBase::_max_var_n_dofs_per_elem
protected

Maximum number of dofs for any one variable on any one element.

Definition at line 704 of file SystemBase.h.

Referenced by getMaxVarNDofsPerElem(), and NonlinearSystemBase::init().

◆ _mesh

MooseMesh& SystemBase::_mesh
protected

◆ _name

std::string SystemBase::_name
protected

The name of this system.

Definition at line 670 of file SystemBase.h.

◆ _saved_dot_old

NumericVector<Real>* SystemBase::_saved_dot_old
protected

Definition at line 695 of file SystemBase.h.

Referenced by restoreOldSolutions(), and saveOldSolutions().

◆ _saved_dotdot_old

NumericVector<Real>* SystemBase::_saved_dotdot_old
protected

Definition at line 696 of file SystemBase.h.

Referenced by restoreOldSolutions(), and saveOldSolutions().

◆ _saved_old

NumericVector<Real>* SystemBase::_saved_old
protected

Definition at line 691 of file SystemBase.h.

Referenced by restoreOldSolutions(), and saveOldSolutions().

◆ _saved_older

NumericVector<Real>* SystemBase::_saved_older
protected

Definition at line 692 of file SystemBase.h.

Referenced by restoreOldSolutions(), and saveOldSolutions().

◆ _subproblem

SubProblem& SystemBase::_subproblem
protected

◆ _tagged_matrices

std::vector<SparseMatrix<Number> *> SystemBase::_tagged_matrices
protected

◆ _tagged_vectors

std::vector<NumericVector<Number> *> SystemBase::_tagged_vectors
protected

◆ _var_kind

Moose::VarKindType SystemBase::_var_kind
protected

default kind of variables in this system

Definition at line 699 of file SystemBase.h.

Referenced by addScalarVariable(), and addVariable().

◆ _var_map

std::map<unsigned int, std::set<SubdomainID> > SystemBase::_var_map
protected

Map of variables (variable id -> array of subdomains where it lives)

Definition at line 675 of file SystemBase.h.

Referenced by addScalarVariable(), addVariable(), getSubdomainsForVar(), and getVariableBlocks().

◆ _var_to_copy

std::vector<VarCopyInfo> SystemBase::_var_to_copy
protected

Definition at line 701 of file SystemBase.h.

Referenced by addVariableToCopy(), and copyVars().

◆ _vars

std::vector<VariableWarehouse> SystemBase::_vars
protected

◆ _vars_to_be_zeroed_on_jacobian

std::vector<std::string> SystemBase::_vars_to_be_zeroed_on_jacobian
protected

Definition at line 678 of file SystemBase.h.

Referenced by addVariableToZeroOnJacobian(), and zeroVariablesForJacobian().

◆ _vars_to_be_zeroed_on_residual

std::vector<std::string> SystemBase::_vars_to_be_zeroed_on_residual
protected

Definition at line 677 of file SystemBase.h.

Referenced by addVariableToZeroOnResidual(), and zeroVariablesForResidual().


The documentation for this class was generated from the following files: