https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
DumpObjectsNonlinearSystem Class Reference

Nonlinear system for dumping objects. More...

#include <DumpObjectsNonlinearSystem.h>

Inheritance diagram for DumpObjectsNonlinearSystem:
[legend]

Public Member Functions

 DumpObjectsNonlinearSystem (FEProblemBase &problem, const std::string &name)
 
virtual libMesh::NonlinearSolver< Number > * nonlinearSolver () override
 
virtual void solve () override
 Solve the system (using libMesh magic) More...
 
virtual void stopSolve (const ExecFlagType &, const std::set< TagID > &) override
 Quit the current solve as soon as possible. More...
 
virtual bool converged () override
 Returns the convergence state. More...
 
virtual NumericVector< Number > & RHS () override
 
virtual SNES getSNES () override
 
virtual unsigned int getCurrentNonlinearIterationNumber () override
 
virtual void setupFiniteDifferencedPreconditioner () override
 
virtual void attachPreconditioner (libMesh::Preconditioner< Number > *) override
 Attach a customized preconditioner that requires physics knowledge. More...
 
void residualAndJacobianTogether () override
 Call this method if you want the residual and Jacobian to be computed simultaneously. More...
 
virtual void preInit () override
 This is called prior to the libMesh system has been init'd. More...
 
void reinitMortarFunctors ()
 Update the mortar functors if the mesh has changed. More...
 
bool computedScalingJacobian () const
 
virtual void turnOffJacobian ()
 Turn off the Jacobian (must be called before equation system initialization) More...
 
bool computingPreSMOResidual ()
 Returns true if this system is currently computing the pre-SMO residual for a solve. More...
 
virtual void initialSetup () override
 Setup Functions. More...
 
virtual void timestepSetup () override
 
virtual void customSetup (const ExecFlagType &exec_type) override
 
virtual void residualSetup () override
 
virtual void jacobianSetup () override
 
bool haveFiniteDifferencedPreconditioner () const
 
bool haveFieldSplitPreconditioner () const
 
virtual void addKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a kernel. More...
 
virtual void addHDGKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a hybridized discontinuous Galerkin (HDG) kernel. More...
 
virtual void addNodalKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a NodalKernel. More...
 
void addScalarKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a scalar kernel. More...
 
void addBoundaryCondition (const std::string &bc_name, const std::string &name, InputParameters &parameters)
 Adds a boundary condition. More...
 
void addConstraint (const std::string &c_name, const std::string &name, InputParameters &parameters)
 Adds a Constraint. More...
 
void addDiracKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a Dirac kernel. More...
 
void addDGKernel (std::string dg_kernel_name, const std::string &name, InputParameters &parameters)
 Adds a DG kernel. More...
 
void addInterfaceKernel (std::string interface_kernel_name, const std::string &name, InputParameters &parameters)
 Adds an interface kernel. More...
 
void addDamper (const std::string &damper_name, const std::string &name, InputParameters &parameters)
 Adds a damper. More...
 
void addSplit (const std::string &split_name, const std::string &name, InputParameters &parameters)
 Adds a split. More...
 
std::shared_ptr< SplitgetSplit (const std::string &name)
 Retrieves a split by name. More...
 
MooseObjectWarehouseBase< Split > & getSplits ()
 Retrieves all splits. More...
 
bool shouldEvaluatePreSMOResidual () const
 We offer the option to check convergence against the pre-SMO residual. More...
 
void setPreSMOResidual (bool use)
 Set whether to evaluate the pre-SMO residual and use it in the subsequent relative convergence checks. More...
 
const bool & usePreSMOResidual () const
 Whether we are using pre-SMO residual in relative convergence checks. More...
 
Real referenceResidual () const
 The reference residual used in relative convergence check. More...
 
Real preSMOResidual () const
 The pre-SMO residual. More...
 
Real initialResidual () const
 The initial residual. More...
 
void setInitialResidual (Real r)
 Record the initial residual (for later relative convergence check) More...
 
void zeroVectorForResidual (const std::string &vector_name)
 
void setInitialSolution ()
 
void setConstraintSecondaryValues (NumericVector< Number > &solution, bool displaced)
 Sets the value of constrained variables in the solution vector. More...
 
void constraintResiduals (NumericVector< Number > &residual, bool displaced)
 Add residual contributions from Constraints. More...
 
void computeResidualTag (NumericVector< Number > &residual, TagID tag_id)
 Computes residual for a given tag. More...
 
void computeResidualTags (const std::set< TagID > &tags)
 Form multiple tag-associated residual vectors for all the given tags. More...
 
void computeResidualAndJacobianTags (const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
 Form possibly multiple tag-associated vectors and matrices. More...
 
void computeResidualAndJacobianInternal (const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
 Compute residual and Jacobian from contributions not related to constraints, such as nodal boundary conditions. More...
 
void computeResidual (NumericVector< Number > &residual, TagID tag_id)
 Form a residual vector for a given tag. More...
 
void addImplicitGeometricCouplingEntries (GeometricSearchData &geom_search_data)
 Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled that are related geometrically (i.e. More...
 
void constraintJacobians (const SparseMatrix< Number > &jacobian_to_view, bool displaced)
 Add jacobian contributions from Constraints. More...
 
void computeJacobianTags (const std::set< TagID > &tags)
 Computes multiple (tag associated) Jacobian matricese. More...
 
bool computeScaling ()
 Method used to obtain scaling factors for variables. More...
 
void computeJacobian (libMesh::SparseMatrix< Number > &jacobian, const std::set< TagID > &tags)
 Associate jacobian to systemMatrixTag, and then form a matrix for all the tags. More...
 
void computeJacobian (libMesh::SparseMatrix< Number > &jacobian)
 Take all tags in the system, and form a matrix for all tags in the system. More...
 
void computeJacobianBlocks (std::vector< JacobianBlock *> &blocks)
 Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditioning matrices. More...
 
void computeJacobianBlocks (std::vector< JacobianBlock *> &blocks, const std::set< TagID > &tags)
 
Real computeDamping (const NumericVector< Number > &solution, const NumericVector< Number > &update)
 Compute damping. More...
 
void onTimestepBegin ()
 Called at the beginning of the time step. More...
 
virtual void subdomainSetup (SubdomainID subdomain, THREAD_ID tid)
 Called from assembling when we hit a new subdomain. More...
 
virtual void subdomainSetup ()
 
virtual void subdomainSetup ()
 
void overwriteNodeFace (NumericVector< Number > &soln)
 Called from explicit time stepping to overwrite boundary positions (explicit dynamics). More...
 
void updateActive (THREAD_ID tid)
 Update active objects of Warehouses owned by NonlinearSystemBase. More...
 
virtual void setSolutionUDot (const NumericVector< Number > &udot)
 Set transient term used by residual and Jacobian evaluation. More...
 
virtual void setSolutionUDotDot (const NumericVector< Number > &udotdot)
 Set transient term used by residual and Jacobian evaluation. More...
 
NumericVector< Number > & getResidualTimeVector ()
 Return a numeric vector that is associated with the time tag. More...
 
NumericVector< Number > & getResidualNonTimeVector ()
 Return a numeric vector that is associated with the nontime tag. More...
 
NumericVector< Number > & residualVector (TagID tag)
 Return a residual vector that is associated with the residual tag. More...
 
virtual NumericVector< Number > & residualCopy () override
 
virtual NumericVector< Number > & residualGhosted () override
 
virtual void augmentSparsity (libMesh::SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz) override
 Will modify the sparsity pattern to add logical geometric connections. More...
 
void setPreconditioner (std::shared_ptr< MoosePreconditioner > pc)
 Sets a preconditioner. More...
 
MoosePreconditioner const * getPreconditioner () const
 
void useFiniteDifferencedPreconditioner (bool use=true)
 If called with true this system will use a finite differenced form of the Jacobian as the preconditioner. More...
 
void useFieldSplitPreconditioner (FieldSplitPreconditionerBase *fsp)
 If called with a non-null object true this system will use a field split preconditioner matrix. More...
 
FieldSplitPreconditionerBasegetFieldSplitPreconditioner ()
 
void addImplicitGeometricCouplingEntriesToJacobian (bool add=true)
 If called with true this will add entries into the jacobian to link together degrees of freedom that are found to be related through the geometric search system. More...
 
void assembleConstraintsSeparately (bool separately=true)
 Indicates whether to assemble residual and Jacobian after each constraint application. More...
 
void setupDampers ()
 Setup damping stuff (called before we actually start) More...
 
void reinitIncrementAtQpsForDampers (THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
 Compute the incremental change in variables at QPs for dampers. More...
 
void reinitIncrementAtNodeForDampers (THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
 Compute the incremental change in variables at nodes for dampers. More...
 
unsigned int nNonlinearIterations () const
 Return the number of non-linear iterations. More...
 
unsigned int nLinearIterations () const
 Return the number of linear iterations. More...
 
unsigned int nResidualEvaluations () const
 Return the total number of residual evaluations done so far in this calculation. More...
 
Real finalNonlinearResidual () const
 Return the final nonlinear residual. More...
 
Real nonlinearNorm () const
 Return the last nonlinear norm. More...
 
void printAllVariableNorms (bool state)
 Force the printing of all variable norms after each solve. More...
 
void debuggingResiduals (bool state)
 
void setPredictor (std::shared_ptr< Predictor > predictor)
 
PredictorgetPredictor ()
 
bool needBoundaryMaterialOnSide (BoundaryID bnd_id, THREAD_ID tid) const
 Indicated whether this system needs material properties on boundaries. More...
 
bool needInterfaceMaterialOnSide (BoundaryID bnd_id, THREAD_ID tid) const
 Indicated whether this system needs material properties on interfaces. More...
 
bool needSubdomainMaterialOnSide (SubdomainID subdomain_id, THREAD_ID tid) const
 Indicates whether this system needs material properties on internal sides. More...
 
bool doingDG () const
 Getter for _doing_dg. More...
 
bool hasSaveIn () const
 Weather or not the nonlinear system has save-ins. More...
 
bool hasDiagSaveIn () const
 Weather or not the nonlinear system has diagonal Jacobian save-ins. More...
 
virtual libMesh::Systemsystem () override
 Get the reference to the libMesh system. More...
 
virtual const libMesh::Systemsystem () const override
 
virtual void setSolutionUDotOld (const NumericVector< Number > &u_dot_old)
 
virtual void setSolutionUDotDotOld (const NumericVector< Number > &u_dotdot_old)
 
virtual void setPreviousNewtonSolution (const NumericVector< Number > &soln)
 
TagID timeVectorTag () const override
 Ideally, we should not need this API. More...
 
TagID nonTimeVectorTag () const override
 
TagID residualVectorTag () const override
 
TagID systemMatrixTag () const override
 Return the Matrix Tag ID for System. More...
 
bool computeScalingOnce () const
 
void computeScalingOnce (bool compute_scaling_once)
 
void autoScalingParam (Real resid_vs_jac_scaling_param)
 Sets the param that indicates the weighting of the residual vs the Jacobian in determining variable scaling parameters. More...
 
void scalingGroupVariables (const std::vector< std::vector< std::string >> &scaling_group_variables)
 
void ignoreVariablesForAutoscaling (const std::vector< std::string > &ignore_variables_for_autoscaling)
 
bool offDiagonalsInAutoScaling () const
 
void offDiagonalsInAutoScaling (bool off_diagonals_in_auto_scaling)
 
void setupDM ()
 Setup the PETSc DM object (when appropriate) More...
 
virtual void potentiallySetupFiniteDifferencing ()
 Create finite differencing contexts for assembly of the Jacobian and/or approximating the action of the Jacobian on vectors (e.g. More...
 
void destroyColoring ()
 Destroy the coloring object if it exists. More...
 
virtual void reinitNodeFace (const Node *node, BoundaryID bnd_id, THREAD_ID tid)
 Reinit nodal assembly info on a face. More...
 
virtual void reinitNodeFace (const Node *node, BoundaryID bnd_id, THREAD_ID tid)
 Reinit nodal assembly info on a face. More...
 
virtual void restoreSolutions () override final
 Restore current solutions (call after your solve failed) More...
 
void serializeSolution ()
 
void setSolution (const NumericVector< Number > &soln)
 Set the solution to a given vector. More...
 
void setPCSide (MooseEnum pcs)
 Set the side on which the preconditioner is applied to. More...
 
Moose::PCSideType getPCSide ()
 Get the current preconditioner side. More...
 
void setMooseKSPNormType (MooseEnum kspnorm)
 Set the norm in which the linear convergence will be measured. More...
 
Moose::MooseKSPNormType getMooseKSPNormType ()
 Get the norm in which the linear convergence is measured. More...
 
virtual const NumericVector< Number > *const & currentSolution () const override final
 The solution vector that is currently being operated on. More...
 
virtual void compute (ExecFlagType type) override
 Compute time derivatives, auxiliary variables, etc. More...
 
unsigned int number () const
 Gets the number of this system. More...
 
MooseMeshmesh ()
 
const MooseMeshmesh () const
 
SubProblemsubproblem ()
 
const SubProblemsubproblem () const
 
FEProblemBasefeProblem ()
 
const FEProblemBasefeProblem () const
 
void applyScalingFactors (const std::vector< Real > &inverse_scaling_factors)
 Applies scaling factors to the system's variables. More...
 
bool computingScalingJacobian () const
 Whether we are computing an initial Jacobian for automatic variable scaling. More...
 
bool automaticScaling () const
 Getter for whether we are performing automatic scaling. More...
 
void automaticScaling (bool automatic_scaling)
 Setter for whether we are performing automatic scaling. More...
 
void setVerboseFlag (const bool &verbose)
 Sets the verbose flag. More...
 
virtual libMesh::DofMapdofMap ()
 Gets writeable reference to the dof map. More...
 
virtual const libMesh::DofMapdofMap () const
 Gets const reference to the dof map. More...
 
virtual void postInit ()
 
virtual void reinit ()
 Reinitialize the system when the degrees of freedom in this system have changed. More...
 
virtual void initializeObjects ()
 Called only once, just before the solve begins so objects can do some precalculations. More...
 
void update ()
 Update the system (doing libMesh magic) More...
 
virtual void copyOldSolutions ()
 Shifts the solutions backwards in time. More...
 
virtual void copyPreviousNonlinearSolutions ()
 Shifts the solutions backwards in nonlinear iteration history. More...
 
virtual void copyPreviousFixedPointSolutions ()
 
NumericVector< Number > & solution ()
 
const NumericVector< Number > & solution () const
 
NumericVector< Number > & solutionOld ()
 
const NumericVector< Number > & solutionOld () const
 
NumericVector< Number > & solutionOlder ()
 
const NumericVector< Number > & solutionOlder () const
 
virtual const NumericVector< Number > * solutionPreviousNewton () const
 
virtual NumericVector< Number > * solutionPreviousNewton ()
 
virtual void initSolutionState ()
 Initializes the solution state. More...
 
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). More...
 
virtual const NumericVector< Number > & solutionState (const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
 Get a state of the solution (0 = current, 1 = old, 2 = older, etc). More...
 
libMesh::ParallelType solutionStateParallelType (const unsigned int state, const Moose::SolutionIterationType iteration_type) const
 Returns the parallel type of the given solution state. More...
 
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. More...
 
virtual bool hasSolutionState (const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
 Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc). More...
 
virtual void addDotVectors ()
 Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator. More...
 
virtual std::vector< Number > & duDotDus ()
 
virtual NumberduDotDotDu ()
 
virtual const NumberduDotDotDu () const
 
virtual const NumberduDotDu (unsigned int var_num=0) const
 
virtual NumericVector< Number > * solutionUDot ()
 
virtual const NumericVector< Number > * solutionUDot () const
 
virtual NumericVector< Number > * solutionUDotDot ()
 
virtual const NumericVector< Number > * solutionUDotDot () const
 
virtual NumericVector< Number > * solutionUDotOld ()
 
virtual const NumericVector< Number > * solutionUDotOld () const
 
virtual NumericVector< Number > * solutionUDotDotOld ()
 
virtual const NumericVector< Number > * solutionUDotDotOld () const
 
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) const
 Check if the tagged vector exists in the system. More...
 
virtual std::set< TagIDdefaultVectorTags () const
 Get the default vector tags associated with this system. More...
 
virtual std::set< TagIDdefaultMatrixTags () const
 Get the default matrix tags associted with this system. 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)
 Disassociate a given vector from a given tag. More...
 
virtual void disassociateVectorFromTag (TagID tag)
 Disassociate any vector that is associated with a given tag. More...
 
virtual void disassociateDefaultVectorTags ()
 Disassociate the vectors associated with the default vector tags of this system. More...
 
virtual bool hasMatrix (TagID tag) const
 Check if the tagged matrix exists in the system. More...
 
virtual libMesh::SparseMatrix< Number > & getMatrix (TagID tag)
 Get a raw SparseMatrix. More...
 
virtual const libMesh::SparseMatrix< Number > & getMatrix (TagID tag) const
 Get a raw SparseMatrix. More...
 
virtual void activateAllMatrixTags ()
 Make all existing matrices active. More...
 
virtual bool matrixTagActive (TagID tag) const
 If or not a matrix tag is active. More...
 
virtual void deactivateAllMatrixTags ()
 Make matrices inactive. More...
 
void closeTaggedMatrices (const std::set< TagID > &tags)
 Close all matrices associated the tags. More...
 
void flushTaggedMatrices (const std::set< TagID > &tags)
 flushes all matrices associated to tags. More...
 
virtual void associateMatrixToTag (libMesh::SparseMatrix< Number > &matrix, TagID tag)
 Associate a matrix to a tag. More...
 
virtual void disassociateMatrixFromTag (libMesh::SparseMatrix< Number > &matrix, TagID tag)
 Disassociate a matrix from a tag. More...
 
virtual void disassociateMatrixFromTag (TagID tag)
 Disassociate any matrix that is associated with a given tag. More...
 
virtual void disassociateDefaultMatrixTags ()
 Disassociate the matrices associated with the default matrix tags of this system. More...
 
virtual NumericVector< Number > & serializedSolution ()
 Returns a reference to a serialized version of the solution vector for this subproblem. More...
 
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 addVariable (const std::string &var_type, const std::string &var_name, InputParameters &parameters)
 Canonical method for adding a variable. More...
 
virtual bool isArrayVariable (const std::string &var_name) const
 If a variable is an array variable. More...
 
virtual bool isScalarVariable (unsigned int var_name) const
 
MooseVariableFieldBasegetVariable (THREAD_ID tid, const std::string &var_name) const
 Gets a reference to a variable of with specified name. More...
 
MooseVariableFieldBasegetVariable (THREAD_ID tid, unsigned int var_number) const
 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...
 
template<typename T >
MooseVariableField< T > & getActualFieldVariable (THREAD_ID tid, const std::string &var_name)
 Returns a field variable pointer - this includes finite volume variables. More...
 
template<typename T >
MooseVariableField< T > & getActualFieldVariable (THREAD_ID tid, unsigned int var_number)
 Returns a field variable pointer - this includes finite volume variables. More...
 
template<typename T >
MooseVariableFV< T > & getFVVariable (THREAD_ID tid, const std::string &var_name)
 Return a finite volume variable. More...
 
virtual MooseVariableScalargetScalarVariable (THREAD_ID tid, const std::string &var_name) const
 Gets a reference to a scalar variable with specified number. More...
 
virtual MooseVariableScalargetScalarVariable (THREAD_ID tid, unsigned int var_number) const
 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...
 
unsigned int nFieldVariables () const
 Get the number of field variables in this system. More...
 
unsigned int nFVVariables () const
 Get the number of finite volume variables in this system. More...
 
std::size_t getMaxVarNDofsPerElem () const
 Gets the maximum number of dofs used by any one variable on any one element. More...
 
std::size_t getMaxVarNDofsPerNode () const
 Gets the maximum number of dofs used by any one variable on any one node. More...
 
void assignMaxVarNDofsPerElem (std::size_t max_dofs)
 assign the maximum element dofs More...
 
void assignMaxVarNDofsPerNode (std::size_t max_dofs)
 assign the maximum node dofs 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 libMesh::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 prepareLowerD (THREAD_ID tid)
 Prepare the system for use for lower dimensional elements. 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, THREAD_ID tid)
 Reinit assembly info for a side of an element. More...
 
virtual void reinitNeighborFace (const Elem *elem, unsigned int side, 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 reinitLowerD (THREAD_ID tid)
 Compute the values of the variables on the lower dimensional element. More...
 
virtual void reinitNode (const Node *node, THREAD_ID tid)
 Reinit nodal assembly info. 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, bool reinit_for_derivative_reordering=false)
 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< MooseVariableFieldBase * > & getVariables (THREAD_ID tid)
 
const std::vector< MooseVariableScalar * > & getScalarVariables (THREAD_ID tid)
 
const std::set< SubdomainID > & getSubdomainsForVar (unsigned int var_number) const
 
const std::set< SubdomainID > & getSubdomainsForVar (const std::string &var_name) const
 Get the block where a variable of this system is defined. More...
 
void removeVector (const std::string &name)
 Remove a vector from the system with the given name. More...
 
void removeVector (TagID tag_id)
 Remove a solution length vector from the system with the specified TagID. More...
 
NumericVector< Number > & addVector (const std::string &vector_name, const bool project, const libMesh::ParallelType type)
 Adds a solution length vector to the system. More...
 
NumericVector< Number > & addVector (TagID tag, const bool project, const libMesh::ParallelType type)
 Adds a solution length vector to the system with the specified TagID. More...
 
void closeTaggedVector (const TagID tag)
 Close vector with the given tag. More...
 
void closeTaggedVectors (const std::set< TagID > &tags)
 Close all vectors for given tags. More...
 
void zeroTaggedVector (const TagID tag)
 Zero vector with the given tag. More...
 
void zeroTaggedVectors (const std::set< TagID > &tags)
 Zero all vectors for given tags. More...
 
void setVariableGlobalDoFs (const std::string &var_name)
 set all the global dof indices for a variable More...
 
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 setVariableGlobalDoFs More...
 
libMesh::SparseMatrix< Number > & addMatrix (TagID tag)
 Adds a matrix with a given tag. More...
 
void removeMatrix (TagID tag)
 Removes a matrix with a given tag. More...
 
virtual const std::string & name () const
 
const std::vector< VariableName > & getVariableNames () const
 
void getStandardFieldVariableNames (std::vector< VariableName > &std_field_variables) const
 
unsigned int getMaxVariableNumber () const
 Returns the maximum number of all variables on the system. More...
 
virtual void computeVariables (const NumericVector< Number > &)
 
void copyVars (libMesh::ExodusII_IO &io)
 
virtual void copySolutionsBackwards ()
 Copy current solution into old and older. More...
 
void addTimeIntegrator (const std::string &type, const std::string &name, InputParameters &parameters)
 
bool hasVarCopy () const
 Whether or not there are variables to be restarted from an Exodus mesh file. More...
 
void addScalingVector ()
 Add the scaling factor vector to the system. More...
 
bool solutionStatesInitialized () const
 Whether or not the solution states have been initialized via initSolutionState() More...
 
void clearAllDofIndices ()
 Clear all dof indices from moose variables. More...
 
void setActiveVariableCoupleableVectorTags (const std::set< TagID > &vtags, THREAD_ID tid)
 Set the active vector tags for the variables. More...
 
void setActiveScalarVariableCoupleableVectorTags (const std::set< TagID > &vtags, THREAD_ID tid)
 Set the active vector tags for the scalar variables. More...
 
Moose::VarKindType varKind () const
 
const std::vector< std::unique_ptr< NumericVector< Number > > > & gradientContainer () const
 Reference to the container vector which hold gradients at dofs (if it can be interpreted). More...
 
void copyTimeIntegrators (const SystemBase &other_sys)
 Copy time integrators from another system. More...
 
const TimeIntegratorgetTimeIntegrator (const unsigned int var_num) const
 Retrieve the time integrator that integrates the given variable's equation. More...
 
const TimeIntegratorqueryTimeIntegrator (const unsigned int var_num) const
 Retrieve the time integrator that integrates the given variable's equation. More...
 
const std::vector< std::shared_ptr< TimeIntegrator > > & getTimeIntegrators ()
 
std::string prefix () const
 
void sizeVariableMatrixData ()
 size the matrix data for each variable for the number of matrix tags we have More...
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
PerfGraphperfGraph ()
 Get the PerfGraph. More...
 
void checkKernelCoverage (const std::set< SubdomainID > &mesh_subdomains) const
 
virtual bool containsTimeKernel () override
 If the system has a kernel that corresponds to a time derivative. More...
 
virtual std::vector< std::string > timeKernelVariableNames () override
 Returns the names of the variables that have time derivative kernels in the system. More...
 
MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse ()
 Access functions to Warehouses from outside NonlinearSystemBase. More...
 
const MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse () const
 
MooseObjectTagWarehouse< DGKernelBase > & getDGKernelWarehouse ()
 
MooseObjectTagWarehouse< InterfaceKernelBase > & getInterfaceKernelWarehouse ()
 
MooseObjectTagWarehouse< DiracKernelBase > & getDiracKernelWarehouse ()
 
MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse ()
 
const MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse () const
 Return the IntegratedBCBase warehouse. More...
 
const MooseObjectTagWarehouse< ScalarKernelBase > & getScalarKernelWarehouse () const
 
const MooseObjectTagWarehouse< NodalKernelBase > & getNodalKernelWarehouse () const
 
MooseObjectTagWarehouse< HDGKernel > & getHDGKernelWarehouse ()
 
const MooseObjectWarehouse< ElementDamper > & getElementDamperWarehouse () const
 
const MooseObjectWarehouse< NodalDamper > & getNodalDamperWarehouse () const
 
const ConstraintWarehousegetConstraintWarehouse () const
 
const MooseObjectTagWarehouse< NodalBCBase > & getNodalBCWarehouse () const
 Return the NodalBCBase warehouse. More...
 
virtual NumericVector< Number > & getVector (const std::string &name)
 Get a raw NumericVector by name. More...
 
virtual const NumericVector< Number > & getVector (const std::string &name) const
 
virtual NumericVector< Number > & getVector (TagID tag)
 Get a raw NumericVector by tag. More...
 
virtual const NumericVector< Number > & getVector (TagID tag) const
 
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
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

unsigned int _num_residual_evaluations
 
libMesh::System_sys
 
Real _last_nl_rnorm
 
std::vector< unsigned int_current_l_its
 
unsigned int _current_nl_its
 
const ConsoleStream _console
 An instance of helper class to write streams to the Console objects. More...
 

Protected Member Functions

void computeScalingJacobian () override
 Compute a "Jacobian" for automatic scaling purposes. More...
 
void computeScalingResidual () override
 Compute a "residual" for automatic scaling purposes. More...
 
void computeResidualInternal (const std::set< TagID > &tags)
 Compute the residual for a given tag. More...
 
void computeNodalBCs (NumericVector< Number > &residual)
 Enforces nodal boundary conditions. More...
 
void computeNodalBCs (NumericVector< Number > &residual, const std::set< TagID > &tags)
 Form a residual for BCs that at least has one of the given tags. More...
 
void computeNodalBCs (const std::set< TagID > &tags)
 Form multiple tag-associated residual vectors for the given tags. More...
 
void computeNodalBCsResidualAndJacobian ()
 compute the residual and Jacobian for nodal boundary conditions More...
 
void computeJacobianInternal (const std::set< TagID > &tags)
 Form multiple matrices for all the tags. More...
 
void computeDiracContributions (const std::set< TagID > &tags, bool is_jacobian)
 
void computeScalarKernelsJacobians (const std::set< TagID > &tags)
 
void enforceNodalConstraintsResidual (NumericVector< Number > &residual)
 Enforce nodal constraints. More...
 
void enforceNodalConstraintsJacobian ()
 
void mortarConstraints (Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
 Do mortar constraint residual/jacobian computations. More...
 
void assembleScalingVector ()
 Assemble the numeric vector of scaling factors such that it can be used during assembly of the system matrix. More...
 
virtual void postAddResidualObject (ResidualObject &)
 Called after any ResidualObject-derived objects are added to the system. More...
 
void reinitNodeFace (const Node &secondary_node, const BoundaryID secondary_boundary, const PenetrationInfo &info, const bool displaced)
 Reinitialize quantities such as variables, residuals, Jacobians, materials for node-face constraints. More...
 
bool preSolve ()
 Perform some steps to get ready for the solver. More...
 
void getNodeDofs (dof_id_type node_id, std::vector< dof_id_type > &dofs)
 
void checkInvalidSolution ()
 
virtual NumericVector< Number > & solutionInternal () const override final
 Internal getter for solution owned by libMesh. More...
 
virtual bool matrixFromColoring () const
 Whether a system matrix is formed from coloring. More...
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 Call to register a named section for timing. More...
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 Call to register a named section for timing. More...
 
std::string timedSectionName (const std::string &section_name) const
 

Protected Attributes

NumericVector< Number > * _dummy
 
NumericVector< Number > * _residual_ghosted
 ghosted form of the residual More...
 
std::unique_ptr< NumericVector< Number > > _residual_copy
 Copy of the residual vector, or nullptr if a copy is not needed. More...
 
Number _du_dot_du
 \( {du^dot}\over{du} \) More...
 
Number _du_dotdot_du
 \( {du^dotdot}\over{du} \) More...
 
TagID _Re_time_tag
 Tag for time contribution residual. More...
 
std::set< TagID_nl_vector_tags
 Vector tags to temporarily store all tags associated with the current system. More...
 
std::set< TagID_nl_matrix_tags
 Matrix tags to temporarily store all tags associated with the current system. More...
 
NumericVector< Number > * _Re_time
 residual vector for time contributions More...
 
TagID _Re_non_time_tag
 Tag for non-time contribution residual. More...
 
NumericVector< Number > * _Re_non_time
 residual vector for non-time contributions More...
 
TagID _Re_tag
 Used for the residual vector from PETSc. More...
 
TagID _Ke_non_time_tag
 Tag for non-time contribution Jacobian. More...
 
TagID _Ke_system_tag
 Tag for system contribution Jacobian. More...
 
MooseObjectTagWarehouse< DiracKernelBase_dirac_kernels
 Dirac Kernel storage for each thread. More...
 
MooseObjectWarehouse< ElementDamper_element_dampers
 Element Dampers for each thread. More...
 
MooseObjectWarehouse< NodalDamper_nodal_dampers
 Nodal Dampers for each thread. More...
 
MooseObjectWarehouse< GeneralDamper_general_dampers
 General Dampers. More...
 
MooseObjectTagWarehouse< NodalKernelBase_nodal_kernels
 NodalKernels for each thread. More...
 
MooseObjectWarehouseBase< Split_splits
 Decomposition splits. More...
 
ConstraintWarehouse _constraints
 Constraints storage object. More...
 
NumericVector< Number > * _increment_vec
 increment vector More...
 
std::shared_ptr< MoosePreconditioner_preconditioner
 Preconditioner. More...
 
bool _use_finite_differenced_preconditioner
 Whether or not to use a finite differenced preconditioner. More...
 
MatFDColoring _fdcoloring
 
FieldSplitPreconditionerBase_fsp
 The field split preconditioner if this sytem is using one. More...
 
bool _add_implicit_geometric_coupling_entries_to_jacobian
 Whether or not to add implicit geometric couplings to the Jacobian for FDP. More...
 
bool _assemble_constraints_separately
 Whether or not to assemble the residual and Jacobian after the application of each constraint. More...
 
bool _need_residual_ghosted
 Whether or not a ghosted copy of the residual needs to be made. More...
 
bool _debugging_residuals
 true if debugging residuals More...
 
bool _doing_dg
 true if DG is active (optimization reasons) More...
 
std::vector< std::string > _vecs_to_zero_for_residual
 vectors that will be zeroed before a residual computation More...
 
unsigned int _n_iters
 
unsigned int _n_linear_iters
 
unsigned int _n_residual_evaluations
 Total number of residual evaluations that have been performed. More...
 
Real _final_residual
 
std::shared_ptr< Predictor_predictor
 If predictor is active, this is non-NULL. More...
 
bool _computing_pre_smo_residual
 
Real _pre_smo_residual
 The pre-SMO residual, see setPreSMOResidual for a detailed explanation. More...
 
Real _initial_residual
 The initial (i.e., 0th nonlinear iteration) residual, see setPreSMOResidual for a detailed explanation. More...
 
bool _use_pre_smo_residual
 Whether to use the pre-SMO initial residual in the relative convergence check. More...
 
bool _print_all_var_norms
 
bool _has_save_in
 If there is any Kernel or IntegratedBC having save_in. More...
 
bool _has_diag_save_in
 If there is any Kernel or IntegratedBC having diag_save_in. More...
 
bool _has_nodalbc_save_in
 If there is a nodal BC having save_in. More...
 
bool _has_nodalbc_diag_save_in
 If there is a nodal BC having diag_save_in. More...
 
bool _computed_scaling
 Flag used to indicate whether we have already computed the scaling Jacobian. More...
 
bool _compute_scaling_once
 Whether the scaling factors should only be computed once at the beginning of the simulation through an extra Jacobian evaluation. More...
 
Real _resid_vs_jac_scaling_param
 The param that indicates the weighting of the residual vs the Jacobian in determining variable scaling parameters. More...
 
std::vector< std::vector< std::string > > _scaling_group_variables
 A container of variable groupings that can be used in scaling calculations. More...
 
std::vector< bool > _variable_autoscaled
 Container to hold flag if variable is to participate in autoscaling. More...
 
std::vector< std::string > _ignore_variables_for_autoscaling
 A container for variables that do not partipate in autoscaling. More...
 
bool _off_diagonals_in_auto_scaling
 Whether to include off diagonals when determining automatic scaling factors. More...
 
std::unique_ptr< libMesh::DiagonalMatrix< Number > > _scaling_matrix
 A diagonal matrix used for computing scaling. More...
 
const NumericVector< Number > * _current_solution
 solution vector from solver More...
 
Moose::PCSideType _pc_side
 Preconditioning side. More...
 
Moose::MooseKSPNormType _ksp_norm
 KSP norm type. More...
 
bool _solution_is_invalid
 Boolean to see if solution is invalid. More...
 
SubProblem_subproblem
 The subproblem for whom this class holds variable data, etc; this can either be the governing finite element/volume problem or a subjugate displaced problem. More...
 
FEProblemBase_fe_problem
 the governing finite element/volume problem More...
 
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...
 
unsigned int _max_var_number
 Maximum variable number. More...
 
std::vector< std::string > _vars_to_be_zeroed_on_residual
 
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
 
NumericVector< Number > * _u_dot
 solution vector for u^dot More...
 
NumericVector< Number > * _u_dotdot
 solution vector for u^dotdot More...
 
NumericVector< Number > * _u_dot_old
 old solution vector for u^dot More...
 
NumericVector< Number > * _u_dotdot_old
 old solution vector for u^dotdot More...
 
std::vector< NumericVector< Number > * > _tagged_vectors
 Tagged vectors (pointer) More...
 
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
 Tagged matrices (pointer) More...
 
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. We use a map instead of a vector so that users can easily add and remove to this container with calls to (de)activateMatrixTag. 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...
 
size_t _max_var_n_dofs_per_node
 Maximum number of dofs for any one variable on any one node. More...
 
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
 Time integrator. More...
 
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
 Map variable number to its pointer. More...
 
bool _automatic_scaling
 Whether to automatically scale the variables. More...
 
bool _verbose
 True if printing out additional information. More...
 
bool _solution_states_initialized
 Whether or not the solution states have been initialized. More...
 
std::vector< dof_id_type_var_all_dof_indices
 Container for the dof indices of a given variable. More...
 
std::unique_ptr< NumericVector< Number > > _serialized_solution
 Serialized version of the solution vector, or nullptr if a serialized solution is not needed. More...
 
std::vector< std::unique_ptr< NumericVector< Number > > > _raw_grad_container
 A cache for storing gradients at dof locations. More...
 
const Parallel::Communicator_communicator
 
MooseApp_pg_moose_app
 The MooseApp that owns the PerfGraph. More...
 
const std::string _prefix
 A prefix to use for all sections. More...
 
MooseObjectTagWarehouse< KernelBase_kernels
 
MooseObjectTagWarehouse< HDGKernel_hybridized_kernels
 
MooseObjectTagWarehouse< ScalarKernelBase_scalar_kernels
 
MooseObjectTagWarehouse< DGKernelBase_dg_kernels
 
MooseObjectTagWarehouse< InterfaceKernelBase_interface_kernels
 
MooseObjectTagWarehouse< IntegratedBCBase_integrated_bcs
 
MooseObjectTagWarehouse< NodalBCBase_nodal_bcs
 
MooseObjectWarehouse< DirichletBCBase_preset_nodal_bcs
 
MooseObjectWarehouse< ADDirichletBCBase_ad_preset_nodal_bcs
 

Detailed Description

Nonlinear system for dumping objects.

Definition at line 24 of file DumpObjectsNonlinearSystem.h.

Constructor & Destructor Documentation

◆ DumpObjectsNonlinearSystem()

DumpObjectsNonlinearSystem::DumpObjectsNonlinearSystem ( FEProblemBase problem,
const std::string &  name 
)

Definition at line 13 of file DumpObjectsNonlinearSystem.C.

17  _dummy(nullptr)
18 {
19 }
NumericVector< Number > * _dummy
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual libMesh::EquationSystems & es() override
NonlinearSystemBase(FEProblemBase &problem, libMesh::System &sys, const std::string &name)
virtual System & add_system(std::string_view system_type, std::string_view name)

Member Function Documentation

◆ activateAllMatrixTags()

void SystemBase::activateAllMatrixTags ( )
virtualinherited

Make all existing matrices active.

Definition at line 1123 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal(), LinearSystem::computeLinearSystemInternal(), NonlinearSystemBase::computeResidualAndJacobianInternal(), and NonlinearSystemBase::computeResidualTags().

1124 {
1125  auto num_matrix_tags = _subproblem.numMatrixTags();
1126 
1127  _matrix_tag_active_flags.resize(num_matrix_tags);
1128  _active_tagged_matrices.clear();
1129 
1130  for (const auto tag : make_range(num_matrix_tags))
1131  if (hasMatrix(tag))
1132  {
1133  _matrix_tag_active_flags[tag] = true;
1134  _active_tagged_matrices.emplace(tag, &getMatrix(tag));
1135  }
1136  else
1137  _matrix_tag_active_flags[tag] = false;
1138 }
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...
Definition: SystemBase.h:1025
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:1027
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:248
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1016
IntRange< T > make_range(T beg, T end)

◆ addBoundaryCondition()

void NonlinearSystemBase::addBoundaryCondition ( const std::string &  bc_name,
const std::string &  name,
InputParameters parameters 
)
inherited

Adds a boundary condition.

Parameters
bc_nameThe type of the boundary condition
nameThe name of the boundary condition
parametersBoundary condition parameters

Definition at line 505 of file NonlinearSystemBase.C.

508 {
509  // ThreadID
510  THREAD_ID tid = 0;
511 
512  // Create the object
513  std::shared_ptr<BoundaryCondition> bc =
514  _factory.create<BoundaryCondition>(bc_name, name, parameters, tid);
516 
517  // Active BoundaryIDs for the object
518  const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
519  auto bc_var = dynamic_cast<const MooseVariableFieldBase *>(&bc->variable());
520  _vars[tid].addBoundaryVar(boundary_ids, bc_var);
521 
522  // Cast to the various types of BCs
523  std::shared_ptr<NodalBCBase> nbc = std::dynamic_pointer_cast<NodalBCBase>(bc);
524  std::shared_ptr<IntegratedBCBase> ibc = std::dynamic_pointer_cast<IntegratedBCBase>(bc);
525 
526  // NodalBCBase
527  if (nbc)
528  {
529  if (nbc->checkNodalVar() && !nbc->variable().isNodal())
530  mooseError("Trying to use nodal boundary condition '",
531  nbc->name(),
532  "' on a non-nodal variable '",
533  nbc->variable().name(),
534  "'.");
535 
536  _nodal_bcs.addObject(nbc);
537  // Add to theWarehouse, a centralized storage for all moose objects
539  _vars[tid].addBoundaryVars(boundary_ids, nbc->getCoupledVars());
540 
541  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
542  _has_nodalbc_save_in = true;
543  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
545 
546  // DirichletBCs that are preset
547  std::shared_ptr<DirichletBCBase> dbc = std::dynamic_pointer_cast<DirichletBCBase>(bc);
548  if (dbc && dbc->preset())
550 
551  std::shared_ptr<ADDirichletBCBase> addbc = std::dynamic_pointer_cast<ADDirichletBCBase>(bc);
552  if (addbc && addbc->preset())
554  }
555 
556  // IntegratedBCBase
557  else if (ibc)
558  {
559  _integrated_bcs.addObject(ibc, tid);
560  // Add to theWarehouse, a centralized storage for all moose objects
562  _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
563 
564  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
565  _has_save_in = true;
566  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
567  _has_diag_save_in = true;
568 
569  for (tid = 1; tid < libMesh::n_threads(); tid++)
570  {
571  // Create the object
572  bc = _factory.create<BoundaryCondition>(bc_name, name, parameters, tid);
573 
574  // Give users opportunity to set some parameters
576 
577  // Active BoundaryIDs for the object
578  const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
579  _vars[tid].addBoundaryVar(boundary_ids, bc_var);
580 
581  ibc = std::static_pointer_cast<IntegratedBCBase>(bc);
582 
583  _integrated_bcs.addObject(ibc, tid);
584  _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
585  }
586  }
587 
588  else
589  mooseError("Unknown BoundaryCondition type for object named ", bc->name());
590 }
unsigned int n_threads()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
Base class for automatic differentiation Dirichlet BCs.
void add(std::shared_ptr< MooseObject > obj)
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/fi...
Definition: TheWarehouse.C:116
Base boundary condition of a Dirichlet type.
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
Factory & _factory
Definition: SystemBase.h:989
bool _has_nodalbc_save_in
If there is a nodal BC having save_in.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
This class provides an interface for common operations on field variables of both FE and FV types wit...
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
virtual const std::string & name() const
Definition: SystemBase.C:1332
MooseObjectWarehouse< DirichletBCBase > _preset_nodal_bcs
virtual std::unique_ptr< Base > create()=0
TheWarehouse & theWarehouse() const
Base class for deriving any boundary condition that works at nodes.
Definition: NodalBCBase.h:26
Base class for creating new types of boundary conditions.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
Base class for deriving any boundary condition of a integrated type.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
MooseObjectWarehouse< ADDirichletBCBase > _ad_preset_nodal_bcs

◆ addConstraint()

void NonlinearSystemBase::addConstraint ( const std::string &  c_name,
const std::string &  name,
InputParameters parameters 
)
inherited

Adds a Constraint.

Parameters
c_nameThe type of the constraint
nameThe name of the constraint
parametersConstraint parameters

Definition at line 593 of file NonlinearSystemBase.C.

596 {
597  std::shared_ptr<Constraint> constraint = _factory.create<Constraint>(c_name, name, parameters);
598  _constraints.addObject(constraint);
599  postAddResidualObject(*constraint);
600 
601  if (constraint && constraint->addCouplingEntriesToJacobian())
603 }
void addImplicitGeometricCouplingEntriesToJacobian(bool add=true)
If called with true this will add entries into the jacobian to link together degrees of freedom that ...
Base class for all Constraint types.
Definition: Constraint.h:19
Factory & _factory
Definition: SystemBase.h:989
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual std::unique_ptr< Base > create()=0
ConstraintWarehouse _constraints
Constraints storage object.
void addObject(std::shared_ptr< Constraint > object, THREAD_ID tid=0, bool recurse=true) override
Add Constraint object to the warehouse.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.

◆ addDamper()

void NonlinearSystemBase::addDamper ( const std::string &  damper_name,
const std::string &  name,
InputParameters parameters 
)
inherited

Adds a damper.

Parameters
damper_nameThe type of the damper
nameThe name of the damper
parametersDamper parameters

Definition at line 666 of file NonlinearSystemBase.C.

669 {
670  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
671  {
672  std::shared_ptr<Damper> damper = _factory.create<Damper>(damper_name, name, parameters, tid);
673 
674  // Attempt to cast to the damper types
675  std::shared_ptr<ElementDamper> ed = std::dynamic_pointer_cast<ElementDamper>(damper);
676  std::shared_ptr<NodalDamper> nd = std::dynamic_pointer_cast<NodalDamper>(damper);
677  std::shared_ptr<GeneralDamper> gd = std::dynamic_pointer_cast<GeneralDamper>(damper);
678 
679  if (gd)
680  {
682  break; // not threaded
683  }
684  else if (ed)
685  _element_dampers.addObject(ed, tid);
686  else if (nd)
687  _nodal_dampers.addObject(nd, tid);
688  else
689  mooseError("Invalid damper type");
690  }
691 }
Base class for deriving general dampers.
Definition: GeneralDamper.h:21
unsigned int n_threads()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
Factory & _factory
Definition: SystemBase.h:989
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual std::unique_ptr< Base > create()=0
Base class for deriving nodal dampers.
Definition: NodalDamper.h:27
Base class for deriving element dampers.
Definition: ElementDamper.h:33
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
Base class for deriving dampers.
Definition: Damper.h:24
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ addDGKernel()

void NonlinearSystemBase::addDGKernel ( std::string  dg_kernel_name,
const std::string &  name,
InputParameters parameters 
)
inherited

Adds a DG kernel.

Parameters
dg_kernel_nameThe type of the DG kernel
nameThe name of the DG kernel
parametersDG kernel parameters

Definition at line 622 of file NonlinearSystemBase.C.

625 {
626  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
627  {
628  auto dg_kernel = _factory.create<DGKernelBase>(dg_kernel_name, name, parameters, tid);
629  _dg_kernels.addObject(dg_kernel, tid);
630  // Add to theWarehouse, a centralized storage for all moose objects
631  _fe_problem.theWarehouse().add(dg_kernel);
632  postAddResidualObject(*dg_kernel);
633  }
634 
635  _doing_dg = true;
636 
637  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
638  _has_save_in = true;
639  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
640  _has_diag_save_in = true;
641 }
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
void add(std::shared_ptr< MooseObject > obj)
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/fi...
Definition: TheWarehouse.C:116
Factory & _factory
Definition: SystemBase.h:989
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
Serves as a base class for DGKernel and ADDGKernel.
Definition: DGKernelBase.h:32
virtual const std::string & name() const
Definition: SystemBase.C:1332
bool _doing_dg
true if DG is active (optimization reasons)
virtual std::unique_ptr< Base > create()=0
TheWarehouse & theWarehouse() const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ addDiracKernel()

void NonlinearSystemBase::addDiracKernel ( const std::string &  kernel_name,
const std::string &  name,
InputParameters parameters 
)
inherited

Adds a Dirac kernel.

Parameters
kernel_nameThe type of the dirac kernel
nameThe name of the Dirac kernel
parametersDirac kernel parameters

Definition at line 606 of file NonlinearSystemBase.C.

609 {
610  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
611  {
612  std::shared_ptr<DiracKernelBase> kernel =
613  _factory.create<DiracKernelBase>(kernel_name, name, parameters, tid);
614  postAddResidualObject(*kernel);
615  _dirac_kernels.addObject(kernel, tid);
616  // Add to theWarehouse, a centralized storage for all moose objects
617  _fe_problem.theWarehouse().add(kernel);
618  }
619 }
unsigned int n_threads()
void add(std::shared_ptr< MooseObject > obj)
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/fi...
Definition: TheWarehouse.C:116
Factory & _factory
Definition: SystemBase.h:989
virtual const std::string & name() const
Definition: SystemBase.C:1332
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
virtual std::unique_ptr< Base > create()=0
TheWarehouse & theWarehouse() const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
DiracKernelBase is the base class for all DiracKernel type classes.
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ addDotVectors()

void SystemBase::addDotVectors ( )
virtualinherited

Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator.

Reimplemented in DisplacedSystem.

Definition at line 1625 of file SystemBase.C.

Referenced by DisplacedSystem::addDotVectors().

1626 {
1627  if (_fe_problem.uDotRequested())
1628  _u_dot = &addVector("u_dot", true, GHOSTED);
1630  _u_dot_old = &addVector("u_dot_old", true, GHOSTED);
1632  _u_dotdot = &addVector("u_dotdot", true, GHOSTED);
1634  _u_dotdot_old = &addVector("u_dotdot_old", true, GHOSTED);
1635 }
virtual bool uDotDotOldRequested()
Get boolean flag to check whether old solution second time derivative needs to be stored...
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
Definition: SystemBase.h:1011
virtual bool uDotRequested()
Get boolean flag to check whether solution time derivative needs to be stored.
virtual bool uDotDotRequested()
Get boolean flag to check whether solution second time derivative needs to be stored.
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
Definition: SystemBase.h:1008
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
virtual bool uDotOldRequested()
Get boolean flag to check whether old solution time derivative needs to be stored.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
NumericVector< Number > * _u_dot
solution vector for u^dot
Definition: SystemBase.h:1006
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
Definition: SystemBase.h:1013

◆ addHDGKernel()

void NonlinearSystemBase::addHDGKernel ( const std::string &  kernel_name,
const std::string &  name,
InputParameters parameters 
)
virtualinherited

Adds a hybridized discontinuous Galerkin (HDG) kernel.

Parameters
kernel_nameThe type of the hybridized kernel
nameThe name of the hybridized kernel
parametersHDG kernel parameters

Definition at line 453 of file NonlinearSystemBase.C.

456 {
457  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
458  {
459  // Create the kernel object via the factory and add to warehouse
460  auto kernel = _factory.create<HDGKernel>(kernel_name, name, parameters, tid);
461  _kernels.addObject(kernel, tid);
462  _hybridized_kernels.addObject(kernel, tid);
463  // Add to theWarehouse, a centralized storage for all moose objects
464  _fe_problem.theWarehouse().add(kernel);
465  postAddResidualObject(*kernel);
466  }
467 }
A kernel for hybridized finite element formulations.
Definition: HDGKernel.h:17
unsigned int n_threads()
void add(std::shared_ptr< MooseObject > obj)
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/fi...
Definition: TheWarehouse.C:116
Factory & _factory
Definition: SystemBase.h:989
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual std::unique_ptr< Base > create()=0
TheWarehouse & theWarehouse() const
MooseObjectTagWarehouse< KernelBase > _kernels
MooseObjectTagWarehouse< HDGKernel > _hybridized_kernels
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ addImplicitGeometricCouplingEntries()

void NonlinearSystemBase::addImplicitGeometricCouplingEntries ( GeometricSearchData geom_search_data)
inherited

Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled that are related geometrically (i.e.

near each other across a gap).

Definition at line 2262 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

2263 {
2264  if (!hasMatrix(systemMatrixTag()))
2265  mooseError("Need a system matrix ");
2266 
2267  // At this point, have no idea how to make
2268  // this work with tag system
2269  auto & jacobian = getMatrix(systemMatrixTag());
2270 
2271  std::unordered_map<dof_id_type, std::vector<dof_id_type>> graph;
2272 
2273  findImplicitGeometricCouplingEntries(geom_search_data, graph);
2274 
2275  for (const auto & it : graph)
2276  {
2277  dof_id_type dof = it.first;
2278  const auto & row = it.second;
2279 
2280  for (const auto & coupled_dof : row)
2281  jacobian.add(dof, coupled_dof, 0);
2282  }
2283 }
void findImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data, std::unordered_map< dof_id_type, std::vector< dof_id_type >> &graph)
Finds the implicit sparsity graph between geometrically related dofs.
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1016
uint8_t dof_id_type

◆ addImplicitGeometricCouplingEntriesToJacobian()

void NonlinearSystemBase::addImplicitGeometricCouplingEntriesToJacobian ( bool  add = true)
inlineinherited

If called with true this will add entries into the jacobian to link together degrees of freedom that are found to be related through the geometric search system.

These entries are really only used by the Finite Difference Preconditioner and the constraint system right now.

Definition at line 474 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::addConstraint(), and FiniteDifferencePreconditioner::FiniteDifferencePreconditioner().

475  {
477  }
bool _add_implicit_geometric_coupling_entries_to_jacobian
Whether or not to add implicit geometric couplings to the Jacobian for FDP.

◆ addInterfaceKernel()

void NonlinearSystemBase::addInterfaceKernel ( std::string  interface_kernel_name,
const std::string &  name,
InputParameters parameters 
)
inherited

Adds an interface kernel.

Parameters
interface_kernel_nameThe type of the interface kernel
nameThe name of the interface kernel
parametersinterface kernel parameters

Definition at line 644 of file NonlinearSystemBase.C.

647 {
648  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
649  {
650  std::shared_ptr<InterfaceKernelBase> interface_kernel =
651  _factory.create<InterfaceKernelBase>(interface_kernel_name, name, parameters, tid);
652  postAddResidualObject(*interface_kernel);
653 
654  const std::set<BoundaryID> & boundary_ids = interface_kernel->boundaryIDs();
655  auto ik_var = dynamic_cast<const MooseVariableFieldBase *>(&interface_kernel->variable());
656  _vars[tid].addBoundaryVar(boundary_ids, ik_var);
657 
658  _interface_kernels.addObject(interface_kernel, tid);
659  // Add to theWarehouse, a centralized storage for all moose objects
660  _fe_problem.theWarehouse().add(interface_kernel);
661  _vars[tid].addBoundaryVars(boundary_ids, interface_kernel->getCoupledVars());
662  }
663 }
unsigned int n_threads()
void add(std::shared_ptr< MooseObject > obj)
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/fi...
Definition: TheWarehouse.C:116
Factory & _factory
Definition: SystemBase.h:989
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual std::unique_ptr< Base > create()=0
TheWarehouse & theWarehouse() const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
InterfaceKernelBase is the base class for all InterfaceKernel type classes.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ addKernel()

void NonlinearSystemBase::addKernel ( const std::string &  kernel_name,
const std::string &  name,
InputParameters parameters 
)
virtualinherited

Adds a kernel.

Parameters
kernel_nameThe type of the kernel
nameThe name of the kernel
parametersKernel parameters

Reimplemented in MooseEigenSystem.

Definition at line 431 of file NonlinearSystemBase.C.

434 {
435  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
436  {
437  // Create the kernel object via the factory and add to warehouse
438  std::shared_ptr<KernelBase> kernel =
439  _factory.create<KernelBase>(kernel_name, name, parameters, tid);
440  _kernels.addObject(kernel, tid);
441  postAddResidualObject(*kernel);
442  // Add to theWarehouse, a centralized storage for all moose objects
443  _fe_problem.theWarehouse().add(kernel);
444  }
445 
446  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
447  _has_save_in = true;
448  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
449  _has_diag_save_in = true;
450 }
unsigned int n_threads()
void add(std::shared_ptr< MooseObject > obj)
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/fi...
Definition: TheWarehouse.C:116
Factory & _factory
Definition: SystemBase.h:989
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual std::unique_ptr< Base > create()=0
This is the common base class for the three main kernel types implemented in MOOSE, Kernel, VectorKernel and ArrayKernel.
Definition: KernelBase.h:23
TheWarehouse & theWarehouse() const
MooseObjectTagWarehouse< KernelBase > _kernels
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ addMatrix()

SparseMatrix< Number > & SystemBase::addMatrix ( TagID  tag)
inherited

Adds a matrix with a given tag.

Parameters
tag_nameThe name of the tag

Definition at line 570 of file SystemBase.C.

571 {
572  if (!_subproblem.matrixTagExists(tag))
573  mooseError("Cannot add tagged matrix with TagID ",
574  tag,
575  " in system '",
576  name(),
577  "' because the tag does not exist in the problem");
578 
579  if (hasMatrix(tag))
580  return getMatrix(tag);
581 
582  const auto matrix_name = _subproblem.matrixTagName(tag);
583  SparseMatrix<Number> & mat = system().add_matrix(matrix_name);
584  associateMatrixToTag(mat, tag);
585 
586  return mat;
587 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
virtual void associateMatrixToTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
Definition: SystemBase.C:1068
virtual const std::string & name() const
Definition: SystemBase.C:1332
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1016
SparseMatrix< Number > & add_matrix(std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:328
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:357

◆ addNodalKernel()

void NonlinearSystemBase::addNodalKernel ( const std::string &  kernel_name,
const std::string &  name,
InputParameters parameters 
)
virtualinherited

Adds a NodalKernel.

Parameters
kernel_nameThe type of the nodal kernel
nameThe name of the kernel
parametersKernel parameters

Definition at line 470 of file NonlinearSystemBase.C.

473 {
474  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
475  {
476  // Create the kernel object via the factory and add to the warehouse
477  std::shared_ptr<NodalKernelBase> kernel =
478  _factory.create<NodalKernelBase>(kernel_name, name, parameters, tid);
479  _nodal_kernels.addObject(kernel, tid);
480  // Add to theWarehouse, a centralized storage for all moose objects
481  _fe_problem.theWarehouse().add(kernel);
482  postAddResidualObject(*kernel);
483  }
484 
485  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
486  _has_save_in = true;
487  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
488  _has_diag_save_in = true;
489 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
void add(std::shared_ptr< MooseObject > obj)
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/fi...
Definition: TheWarehouse.C:116
Factory & _factory
Definition: SystemBase.h:989
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual std::unique_ptr< Base > create()=0
TheWarehouse & theWarehouse() const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
Base class for creating new types of nodal kernels.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ addScalarKernel()

void NonlinearSystemBase::addScalarKernel ( const std::string &  kernel_name,
const std::string &  name,
InputParameters parameters 
)
inherited

Adds a scalar kernel.

Parameters
kernel_nameThe type of the kernel
nameThe name of the kernel
parametersKernel parameters

Definition at line 492 of file NonlinearSystemBase.C.

495 {
496  std::shared_ptr<ScalarKernelBase> kernel =
497  _factory.create<ScalarKernelBase>(kernel_name, name, parameters);
498  postAddResidualObject(*kernel);
499  // Add to theWarehouse, a centralized storage for all moose objects
500  _fe_problem.theWarehouse().add(kernel);
501  _scalar_kernels.addObject(kernel);
502 }
void add(std::shared_ptr< MooseObject > obj)
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/fi...
Definition: TheWarehouse.C:116
Factory & _factory
Definition: SystemBase.h:989
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual std::unique_ptr< Base > create()=0
TheWarehouse & theWarehouse() const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
Base class shared by AD and non-AD scalar kernels.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels

◆ addScalingVector()

void SystemBase::addScalingVector ( )
inherited

Add the scaling factor vector to the system.

Definition at line 1537 of file SystemBase.C.

Referenced by MooseVariableBase::initialSetup().

1538 {
1539  addVector("scaling_factors", /*project=*/false, libMesh::ParallelType::GHOSTED);
1541 }
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
void hasScalingVector(const unsigned int nl_sys_num)
Tells this problem that the assembly associated with the given nonlinear system number involves a sca...
Definition: SubProblem.C:1170
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149

◆ addSplit()

void NonlinearSystemBase::addSplit ( const std::string &  split_name,
const std::string &  name,
InputParameters parameters 
)
inherited

Adds a split.

Parameters
split_nameThe type of the split
nameThe name of the split
parametersSplit parameters

Definition at line 694 of file NonlinearSystemBase.C.

697 {
698  std::shared_ptr<Split> split = _factory.create<Split>(split_name, name, parameters);
700  // Add to theWarehouse, a centralized storage for all moose objects
702 }
Base class for split-based preconditioners.
Definition: Split.h:25
void add(std::shared_ptr< MooseObject > obj)
add adds a new object to the warehouse and stores attributes/metadata about it for running queries/fi...
Definition: TheWarehouse.C:116
Factory & _factory
Definition: SystemBase.h:989
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual std::unique_ptr< Base > create()=0
TheWarehouse & theWarehouse() const
tbb::split split
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true)
Adds an object to the storage structure.

◆ addTimeIntegrator()

void SystemBase::addTimeIntegrator ( const std::string &  type,
const std::string &  name,
InputParameters parameters 
)
inherited

Definition at line 1650 of file SystemBase.C.

1653 {
1654  parameters.set<SystemBase *>("_sys") = this;
1655  _time_integrators.push_back(_factory.create<TimeIntegrator>(type, name, parameters));
1656 }
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
Definition: SystemBase.h:1049
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Factory & _factory
Definition: SystemBase.h:989
Base class for a system (of equations)
Definition: SystemBase.h:84
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual std::unique_ptr< Base > create()=0
Base class for time integrators.

◆ addVariable()

void SystemBase::addVariable ( const std::string &  var_type,
const std::string &  var_name,
InputParameters parameters 
)
virtualinherited

Canonical method for adding a variable.

Parameters
var_typethe type of the variable, e.g. MooseVariableScalar
var_namethe variable name, e.g. 'u'
paramsthe InputParameters from which to construct the variable

Reimplemented in AuxiliarySystem.

Definition at line 718 of file SystemBase.C.

Referenced by AuxiliarySystem::addVariable().

721 {
723 
724  const auto components = parameters.get<unsigned int>("components");
725 
726  // Convert the std::vector parameter provided by the user into a std::set for use by libMesh's
727  // System::add_variable method
728  std::set<SubdomainID> blocks;
729  const auto & block_param = parameters.get<std::vector<SubdomainName>>("block");
730  for (const auto & subdomain_name : block_param)
731  {
732  SubdomainID blk_id = _mesh.getSubdomainID(subdomain_name);
733  blocks.insert(blk_id);
734  }
735 
736  const auto fe_type =
737  FEType(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")),
738  Utility::string_to_enum<FEFamily>(parameters.get<MooseEnum>("family")));
739  const auto fe_field_type = FEInterface::field_type(fe_type);
740 
741  unsigned int var_num;
742 
743  if (var_type == "ArrayMooseVariable")
744  {
745  if (fe_field_type == TYPE_VECTOR)
746  mooseError("Vector family type cannot be used in an array variable");
747 
748  std::vector<std::string> array_var_component_names;
749  const bool has_array_names = parameters.isParamValid("array_var_component_names");
750  if (has_array_names)
751  {
752  array_var_component_names =
753  parameters.get<std::vector<std::string>>("array_var_component_names");
754  if (array_var_component_names.size() != components)
755  parameters.paramError("array_var_component_names",
756  "Must be the same size as 'components' (size ",
757  components,
758  ") for array variable '",
759  name,
760  "'");
761  }
762 
763  // Build up the variable names
764  std::vector<std::string> var_names;
765  for (unsigned int i = 0; i < components; i++)
766  {
767  if (!has_array_names)
768  array_var_component_names.push_back(std::to_string(i));
769  var_names.push_back(name + "_" + array_var_component_names[i]);
770  }
771 
772  // makes sure there is always a name, either the provided one or '1 2 3 ...'
773  parameters.set<std::vector<std::string>>("array_var_component_names") =
774  array_var_component_names;
775 
776  // The number returned by libMesh is the _last_ variable number... we want to hold onto the
777  // _first_
778  var_num = system().add_variables(var_names, fe_type, &blocks) - (components - 1);
779 
780  // Set as array variable
781  if (parameters.isParamSetByUser("array") && !parameters.get<bool>("array"))
782  parameters.paramError("array",
783  "Must be set to true for variable '",
784  name,
785  "' because 'components' > 1 (is an array variable)");
786  parameters.set<bool>("array") = true;
787  }
788  else
789  {
790  if (parameters.isParamSetByUser("array_var_component_names"))
791  parameters.paramError("array_var_component_names",
792  "Should not be set because this variable (",
793  name,
794  ") is a non-array variable");
795  var_num = system().add_variable(name, fe_type, &blocks);
796  }
797 
798  parameters.set<unsigned int>("_var_num") = var_num;
799  parameters.set<SystemBase *>("_system_base") = this;
800 
801  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
802  {
803  parameters.set<THREAD_ID>("tid") = tid;
804  std::shared_ptr<MooseVariableBase> var =
805  _factory.create<MooseVariableBase>(var_type, name, parameters, tid);
806 
807  _vars[tid].add(name, var);
808 
809  if (auto fe_var = dynamic_cast<MooseVariableFieldBase *>(var.get()))
810  {
811  auto required_size = var_num + components;
812  if (required_size > _numbered_vars[tid].size())
813  _numbered_vars[tid].resize(required_size);
814  for (MooseIndex(components) component = 0; component < components; ++component)
815  _numbered_vars[tid][var_num + component] = fe_var;
816 
817  if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADReal> *>(fe_var))
818  _subproblem.addFunctor(name, *functor, tid);
819  else if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADRealVectorValue> *>(fe_var))
820  _subproblem.addFunctor(name, *functor, tid);
821  else if (auto * const functor = dynamic_cast<Moose::FunctorBase<RealEigenVector> *>(fe_var))
822  _subproblem.addFunctor(name, *functor, tid);
823  else
824  mooseError("This should be a functor");
825  }
826 
827  if (var->blockRestricted())
828  for (const SubdomainID & id : var->blockIDs())
829  for (MooseIndex(components) component = 0; component < components; ++component)
830  _var_map[var_num + component].insert(id);
831  else
832  for (MooseIndex(components) component = 0; component < components; ++component)
833  _var_map[var_num + component] = std::set<SubdomainID>();
834  }
835 
836  // getMaxVariableNumber is an API method used in Rattlesnake
837  if (var_num > _max_var_number)
838  _max_var_number = var_num;
839  _du_dot_du.resize(var_num + 1);
840 }
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
Map variable number to its pointer.
Definition: SystemBase.h:1052
std::vector< Real > _du_dot_du
Derivative of time derivative of u with respect to uj.
Definition: SystemBase.h:1017
unsigned int n_threads()
char ** blocks
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
void addFunctor(const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
add a functor to the problem functor container
Definition: SubProblem.h:1375
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
Factory & _factory
Definition: SystemBase.h:989
Base class for a system (of equations)
Definition: SystemBase.h:84
virtual const std::string & name() const
Definition: SystemBase.C:1332
void paramError(const std::string &param, Args... args) const
Emits a parameter error prefixed with the parameter location and object information if available...
virtual std::unique_ptr< Base > create()=0
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
Definition: SystemBase.h:998
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
MooseMesh & _mesh
Definition: SystemBase.h:991
unsigned int _max_var_number
Maximum variable number.
Definition: SystemBase.h:1000
Base variable class.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
SubdomainID getSubdomainID(const SubdomainName &subdomain_name) const
Get the associated subdomain ID for the subdomain name.
Definition: MooseMesh.C:1731
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.

◆ addVariableToCopy()

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

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 1167 of file SystemBase.C.

Referenced by CopyNodalVarsAction::act(), and PhysicsBase::copyVariablesFromMesh().

1170 {
1171  _var_to_copy.push_back(VarCopyInfo(dest_name, source_name, timestep));
1172 }
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:1040
Information about variables that will be copied.
Definition: SystemBase.h:66

◆ addVariableToZeroOnJacobian()

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

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 180 of file SystemBase.C.

Referenced by ADDGKernel::ADDGKernel(), DisplacedSystem::addVariableToZeroOnJacobian(), ADIntegratedBCTempl< T >::ADIntegratedBCTempl(), ADKernelTempl< T >::ADKernelTempl(), ArrayDGKernel::ArrayDGKernel(), ArrayIntegratedBC::ArrayIntegratedBC(), ArrayKernel::ArrayKernel(), DGKernel::DGKernel(), IntegratedBC::IntegratedBC(), InterfaceKernelTempl< T >::InterfaceKernelTempl(), Kernel::Kernel(), NodalBC::NodalBC(), and NodalKernel::NodalKernel().

181 {
182  _vars_to_be_zeroed_on_jacobian.push_back(var_name);
183 }
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
Definition: SystemBase.h:1003

◆ addVariableToZeroOnResidual()

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

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 174 of file SystemBase.C.

Referenced by ADDGKernel::ADDGKernel(), DisplacedSystem::addVariableToZeroOnResidual(), ADIntegratedBCTempl< T >::ADIntegratedBCTempl(), ADKernelTempl< T >::ADKernelTempl(), ArrayDGKernel::ArrayDGKernel(), ArrayIntegratedBC::ArrayIntegratedBC(), ArrayKernel::ArrayKernel(), DGKernel::DGKernel(), IntegratedBC::IntegratedBC(), InterfaceKernelTempl< T >::InterfaceKernelTempl(), Kernel::Kernel(), NodalBC::NodalBC(), and NodalKernel::NodalKernel().

175 {
176  _vars_to_be_zeroed_on_residual.push_back(var_name);
177 }
std::vector< std::string > _vars_to_be_zeroed_on_residual
Definition: SystemBase.h:1002

◆ addVector() [1/2]

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

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.

Referenced by SystemBase::addDotVectors(), SystemBase::addScalingVector(), NonlinearTimeIntegratorInterface::addVector(), SecantSolve::allocateStorage(), SteffensenSolve::allocateStorage(), PicardSolve::allocateStorage(), NonlinearSystemBase::getResidualNonTimeVector(), NonlinearSystemBase::getResidualTimeVector(), CentralDifference::initialSetup(), SystemBase::needSolutionState(), NonlinearSystemBase::residualGhosted(), and SystemBase::saveOldSolutions().

◆ addVector() [2/2]

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

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.

◆ applyScalingFactors()

void SystemBase::applyScalingFactors ( const std::vector< Real > &  inverse_scaling_factors)
inherited

Applies scaling factors to the system's variables.

Parameters
inverse_scaling_factorsA vector containing the inverse of each variable's scaling factor, e.g. 1 / scaling_factor

Definition at line 1487 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeScaling().

1488 {
1489  for (MooseIndex(_vars) thread = 0; thread < _vars.size(); ++thread)
1490  {
1491  auto & field_variables = _vars[thread].fieldVariables();
1492  for (MooseIndex(field_variables) i = 0, p = 0; i < field_variables.size(); ++i)
1493  {
1494  auto factors = field_variables[i]->arrayScalingFactor();
1495  for (unsigned int j = 0; j < field_variables[i]->count(); ++j, ++p)
1496  factors[j] /= inverse_scaling_factors[p];
1497 
1498  field_variables[i]->scalingFactor(factors);
1499  }
1500 
1501  auto offset = field_variables.size();
1502 
1503  auto & scalar_variables = _vars[thread].scalars();
1504  for (MooseIndex(scalar_variables) i = 0; i < scalar_variables.size(); ++i)
1505  scalar_variables[i]->scalingFactor(
1506  {1. / inverse_scaling_factors[offset + i] * scalar_variables[i]->scalingFactor()});
1507 
1508  if (thread == 0 && _verbose)
1509  {
1510  _console << "Automatic scaling factors:\n";
1511  auto original_flags = _console.flags();
1512  auto original_precision = _console.precision();
1513  _console.unsetf(std::ios_base::floatfield);
1514  _console.precision(6);
1515 
1516  for (const auto & field_variable : field_variables)
1517  {
1518  const auto & factors = field_variable->arrayScalingFactor();
1519  _console << " " << field_variable->name() << ":";
1520  for (const auto i : make_range(field_variable->count()))
1521  _console << " " << factors[i];
1522  _console << "\n";
1523  }
1524  for (const auto & scalar_variable : scalar_variables)
1525  _console << " " << scalar_variable->name() << ": " << scalar_variable->scalingFactor()
1526  << "\n";
1527  _console << "\n" << std::endl;
1528 
1529  // restore state
1530  _console.flags(original_flags);
1531  _console.precision(original_precision);
1532  }
1533  }
1534 }
std::ios_base::fmtflags flags() const
Return the current flags.
Definition: ConsoleStream.C:56
void unsetf(std::ios_base::fmtflags mask) const
Unset format flags.
Definition: ConsoleStream.C:38
std::streamsize precision() const
Return the current precision.
Definition: ConsoleStream.C:44
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
bool _verbose
True if printing out additional information.
Definition: SystemBase.h:1058
IntRange< T > make_range(T beg, T end)
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.

◆ assembleConstraintsSeparately()

void NonlinearSystemBase::assembleConstraintsSeparately ( bool  separately = true)
inlineinherited

Indicates whether to assemble residual and Jacobian after each constraint application.

When true, enables "transitive" constraint application: subsequent constraints can use prior constraints' results.

Definition at line 484 of file NonlinearSystemBase.h.

485  {
487  }
bool _assemble_constraints_separately
Whether or not to assemble the residual and Jacobian after the application of each constraint...

◆ assembleScalingVector()

void NonlinearSystemBase::assembleScalingVector ( )
protectedinherited

Assemble the numeric vector of scaling factors such that it can be used during assembly of the system matrix.

Definition at line 4034 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeScaling(), and NonlinearSystemBase::preSolve().

4035 {
4036  if (!hasVector("scaling_factors"))
4037  // No variables have indicated they need scaling
4038  return;
4039 
4040  auto & scaling_vector = getVector("scaling_factors");
4041 
4042  const auto & lm_mesh = _mesh.getMesh();
4043  const auto & dof_map = dofMap();
4044 
4045  const auto & field_variables = _vars[0].fieldVariables();
4046  const auto & scalar_variables = _vars[0].scalars();
4047 
4048  std::vector<dof_id_type> dof_indices;
4049 
4050  for (const Elem * const elem :
4051  as_range(lm_mesh.active_local_elements_begin(), lm_mesh.active_local_elements_end()))
4052  for (const auto * const field_var : field_variables)
4053  {
4054  const auto & factors = field_var->arrayScalingFactor();
4055  for (const auto i : make_range(field_var->count()))
4056  {
4057  dof_map.dof_indices(elem, dof_indices, field_var->number() + i);
4058  for (const auto dof : dof_indices)
4059  scaling_vector.set(dof, factors[i]);
4060  }
4061  }
4062 
4063  for (const auto * const scalar_var : scalar_variables)
4064  {
4065  mooseAssert(scalar_var->count() == 1,
4066  "Scalar variables should always have only one component.");
4067  dof_map.SCALAR_dof_indices(dof_indices, scalar_var->number());
4068  for (const auto dof : dof_indices)
4069  scaling_vector.set(dof, scalar_var->scalingFactor());
4070  }
4071 
4072  // Parallel assemble
4073  scaling_vector.close();
4074 
4075  if (auto * displaced_problem = _fe_problem.getDisplacedProblem().get())
4076  // copy into the corresponding displaced system vector because they should be the exact same
4077  displaced_problem->systemBaseNonlinear(number()).getVector("scaling_factors") = scaling_vector;
4078 }
std::shared_ptr< DisplacedProblem > displaced_problem
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:916
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
Definition: SystemBase.C:1155
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3448
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
MooseMesh & _mesh
Definition: SystemBase.h:991
IntRange< T > make_range(T beg, T end)
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:925

◆ assignMaxVarNDofsPerElem()

void SystemBase::assignMaxVarNDofsPerElem ( std::size_t  max_dofs)
inlineinherited

assign the maximum element dofs

Definition at line 597 of file SystemBase.h.

597 { _max_var_n_dofs_per_elem = max_dofs; }
size_t _max_var_n_dofs_per_elem
Maximum number of dofs for any one variable on any one element.
Definition: SystemBase.h:1043

◆ assignMaxVarNDofsPerNode()

void SystemBase::assignMaxVarNDofsPerNode ( std::size_t  max_dofs)
inlineinherited

assign the maximum node dofs

Definition at line 602 of file SystemBase.h.

602 { _max_var_n_dofs_per_node = max_dofs; }
size_t _max_var_n_dofs_per_node
Maximum number of dofs for any one variable on any one node.
Definition: SystemBase.h:1046

◆ associateMatrixToTag()

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

Associate a matrix to a tag.

Reimplemented in DisplacedSystem.

Definition at line 1068 of file SystemBase.C.

Referenced by SystemBase::addMatrix(), DisplacedSystem::associateMatrixToTag(), NonlinearSystemBase::computeJacobian(), FEProblemBase::computeJacobianInternal(), FEProblemBase::computeJacobianTag(), FEProblemBase::computeLinearSystemSys(), and FEProblemBase::computeResidualAndJacobian().

1069 {
1070  if (!_subproblem.matrixTagExists(tag))
1071  mooseError("Cannot associate matrix to tag ", tag, " because that tag does not exist");
1072 
1073  if (_tagged_matrices.size() < tag + 1)
1074  _tagged_matrices.resize(tag + 1);
1075 
1076  _tagged_matrices[tag] = &matrix;
1077 }
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:1023
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:328

◆ associateVectorToTag()

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

Associate a vector for a given tag.

Reimplemented in DisplacedSystem.

Definition at line 973 of file SystemBase.C.

Referenced by DisplacedSystem::associateVectorToTag(), FEProblemBase::computeLinearSystemSys(), FEProblemBase::computeResidualAndJacobian(), FEProblemBase::computeResidualInternal(), NonlinearSystemBase::computeResidualTag(), FEProblemBase::computeResidualTag(), FEProblemBase::computeResidualType(), LinearSystem::LinearSystem(), and SolverSystem::setSolution().

974 {
975  if (!_subproblem.vectorTagExists(tag))
976  mooseError("Cannot associate vector to tag ", tag, " because that tag does not exist");
977 
978  if (_tagged_vectors.size() < tag + 1)
979  _tagged_vectors.resize(tag + 1);
980 
981  _tagged_vectors[tag] = &vec;
982 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:201
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:1021

◆ attachPreconditioner()

virtual void DumpObjectsNonlinearSystem::attachPreconditioner ( libMesh::Preconditioner< Number > *  preconditioner)
inlineoverridevirtual

Attach a customized preconditioner that requires physics knowledge.

Generic preconditioners should be implemented in PETSc, instead.

Implements NonlinearSystemBase.

Definition at line 38 of file DumpObjectsNonlinearSystem.h.

39  {
40  }

◆ augmentSendList()

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

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

Reimplemented in DisplacedSystem.

Definition at line 452 of file SystemBase.C.

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

453 {
454  std::set<dof_id_type> & ghosted_elems = _subproblem.ghostedElems();
455 
456  DofMap & dof_map = dofMap();
457 
458  std::vector<dof_id_type> dof_indices;
459 
460  System & sys = system();
461 
462  unsigned int sys_num = sys.number();
463 
464  unsigned int n_vars = sys.n_vars();
465 
466  for (const auto & elem_id : ghosted_elems)
467  {
468  Elem * elem = _mesh.elemPtr(elem_id);
469 
470  if (elem->active())
471  {
472  dof_map.dof_indices(elem, dof_indices);
473 
474  // Only need to ghost it if it's actually not on this processor
475  for (const auto & dof : dof_indices)
476  if (dof < dof_map.first_dof() || dof >= dof_map.end_dof())
477  send_list.push_back(dof);
478 
479  // Now add the DoFs from all of the nodes. This is necessary because of block
480  // restricted variables. A variable might not live _on_ this element but it
481  // might live on nodes connected to this element.
482  for (unsigned int n = 0; n < elem->n_nodes(); n++)
483  {
484  Node * node = elem->node_ptr(n);
485 
486  // Have to get each variable's dofs
487  for (unsigned int v = 0; v < n_vars; v++)
488  {
489  const Variable & var = sys.variable(v);
490  unsigned int var_num = var.number();
491  unsigned int n_comp = var.n_components();
492 
493  // See if this variable has any dofs at this node
494  if (node->n_dofs(sys_num, var_num) > 0)
495  {
496  // Loop over components of the variable
497  for (unsigned int c = 0; c < n_comp; c++)
498  send_list.push_back(node->dof_number(sys_num, var_num, c));
499  }
500  }
501  }
502  }
503  }
504 }
dof_id_type end_dof(const processor_id_type proc) const
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
const Variable & variable(unsigned int var) const
virtual Elem * elemPtr(const dof_id_type i)
Definition: MooseMesh.C:3113
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
unsigned int n_dofs(const unsigned int s, const unsigned int var=libMesh::invalid_uint) const
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
Definition: SystemBase.C:1155
unsigned int number() const
unsigned int n_vars
virtual unsigned int n_nodes() const=0
unsigned int n_components() const
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
Definition: SubProblem.h:672
MooseMesh & _mesh
Definition: SystemBase.h:991
const Node * node_ptr(const unsigned int i) const
dof_id_type first_dof(const processor_id_type proc) const
unsigned int number() const
unsigned int n_vars() const
bool active() const

◆ augmentSparsity()

void NonlinearSystemBase::augmentSparsity ( libMesh::SparsityPattern::Graph sparsity,
std::vector< dof_id_type > &  n_nz,
std::vector< dof_id_type > &  n_oz 
)
overridevirtualinherited

Will modify the sparsity pattern to add logical geometric connections.

Implements SystemBase.

Definition at line 3455 of file NonlinearSystemBase.C.

3458 {
3460  {
3462 
3463  std::unordered_map<dof_id_type, std::vector<dof_id_type>> graph;
3464 
3466 
3469  graph);
3470 
3471  const dof_id_type first_dof_on_proc = dofMap().first_dof(processor_id());
3472  const dof_id_type end_dof_on_proc = dofMap().end_dof(processor_id());
3473 
3474  // The total number of dofs on and off processor
3475  const dof_id_type n_dofs_on_proc = dofMap().n_local_dofs();
3476  const dof_id_type n_dofs_not_on_proc = dofMap().n_dofs() - dofMap().n_local_dofs();
3477 
3478  for (const auto & git : graph)
3479  {
3480  dof_id_type dof = git.first;
3481  dof_id_type local_dof = dof - first_dof_on_proc;
3482 
3483  if (dof < first_dof_on_proc || dof >= end_dof_on_proc)
3484  continue;
3485 
3486  const auto & row = git.second;
3487 
3488  SparsityPattern::Row & sparsity_row = sparsity[local_dof];
3489 
3490  unsigned int original_row_length = sparsity_row.size();
3491 
3492  sparsity_row.insert(sparsity_row.end(), row.begin(), row.end());
3493 
3495  sparsity_row.begin(), sparsity_row.begin() + original_row_length, sparsity_row.end());
3496 
3497  // Fix up nonzero arrays
3498  for (const auto & coupled_dof : row)
3499  {
3500  if (coupled_dof < first_dof_on_proc || coupled_dof >= end_dof_on_proc)
3501  {
3502  if (n_oz[local_dof] < n_dofs_not_on_proc)
3503  n_oz[local_dof]++;
3504  }
3505  else
3506  {
3507  if (n_nz[local_dof] < n_dofs_on_proc)
3508  n_nz[local_dof]++;
3509  }
3510  }
3511  }
3512  }
3513 }
dof_id_type end_dof(const processor_id_type proc) const
void findImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data, std::unordered_map< dof_id_type, std::vector< dof_id_type >> &graph)
Finds the implicit sparsity graph between geometrically related dofs.
dof_id_type n_dofs(const unsigned int vn) const
dof_id_type n_local_dofs(const unsigned int vn) const
virtual GeometricSearchData & geomSearchData() override
std::vector< dof_id_type, Threads::scalable_allocator< dof_id_type > > Row
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
Definition: SystemBase.C:1155
virtual void updateGeomSearch(GeometricSearchData::GeometricSearchType type=GeometricSearchData::ALL) override
bool _add_implicit_geometric_coupling_entries_to_jacobian
Whether or not to add implicit geometric couplings to the Jacobian for FDP.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
dof_id_type first_dof(const processor_id_type proc) const
processor_id_type processor_id() const
uint8_t dof_id_type
static void sort_row(const BidirectionalIterator begin, BidirectionalIterator middle, const BidirectionalIterator end)

◆ automaticScaling() [1/2]

bool SystemBase::automaticScaling ( ) const
inlineinherited

Getter for whether we are performing automatic scaling.

Returns
whether we are performing automatic scaling

Definition at line 122 of file SystemBase.h.

Referenced by SubProblem::automaticScaling().

122 { return _automatic_scaling; }
bool _automatic_scaling
Whether to automatically scale the variables.
Definition: SystemBase.h:1055

◆ automaticScaling() [2/2]

void SystemBase::automaticScaling ( bool  automatic_scaling)
inlineinherited

Setter for whether we are performing automatic scaling.

Parameters
automatic_scalingA boolean representing whether we are performing automatic scaling

Definition at line 128 of file SystemBase.h.

128 { _automatic_scaling = automatic_scaling; }
bool _automatic_scaling
Whether to automatically scale the variables.
Definition: SystemBase.h:1055

◆ autoScalingParam()

void NonlinearSystemBase::autoScalingParam ( Real  resid_vs_jac_scaling_param)
inlineinherited

Sets the param that indicates the weighting of the residual vs the Jacobian in determining variable scaling parameters.

A value of 1 indicates pure residual-based scaling. A value of 0 indicates pure Jacobian-based scaling

Definition at line 670 of file NonlinearSystemBase.h.

671  {
672  _resid_vs_jac_scaling_param = resid_vs_jac_scaling_param;
673  }
Real _resid_vs_jac_scaling_param
The param that indicates the weighting of the residual vs the Jacobian in determining variable scalin...

◆ checkInvalidSolution()

void SolverSystem::checkInvalidSolution ( )
protectedinherited

Definition at line 111 of file SolverSystem.C.

Referenced by NonlinearSystem::solve(), and LinearSystem::solve().

112 {
113  auto & solution_invalidity = _app.solutionInvalidity();
114 
115  // sync all solution invalid counts to rank 0 process
116  solution_invalidity.syncIteration();
117 
118  if (solution_invalidity.hasInvalidSolution())
119  {
122  solution_invalidity.print(_console);
123  else
124  mooseWarning("The Solution Invalidity warnings are detected but silenced! "
125  "Use Problem/show_invalid_solution_console=true to show solution counts");
126  else
127  // output the occurrence of solution invalid in a summary table
129  solution_invalidity.print(_console);
130  }
131 }
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:367
void syncIteration()
Sync iteration counts to main processor.
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:172
bool showInvalidSolutionConsole() const
Whether or not to print out the invalid solutions summary table in console.
MooseApp & _app
Definition: SystemBase.h:988
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
bool acceptInvalidSolution() const
Whether or not to accept the solution based on its invalidity.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.

◆ checkKernelCoverage()

void NonlinearSystemBase::checkKernelCoverage ( const std::set< SubdomainID > &  mesh_subdomains) const
inherited

System Integrity Checks

Definition at line 3577 of file NonlinearSystemBase.C.

3578 {
3579  // Obtain all blocks and variables covered by all kernels
3580  std::set<SubdomainID> input_subdomains;
3581  std::set<std::string> kernel_variables;
3582 
3583  bool global_kernels_exist = false;
3584  global_kernels_exist |= _scalar_kernels.hasActiveObjects();
3585  global_kernels_exist |= _nodal_kernels.hasActiveObjects();
3586 
3587  _kernels.subdomainsCovered(input_subdomains, kernel_variables);
3588  _dg_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3589  _nodal_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3590  _scalar_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3591  _constraints.subdomainsCovered(input_subdomains, kernel_variables);
3592 
3593  if (_fe_problem.haveFV())
3594  {
3595  std::vector<FVElementalKernel *> fv_elemental_kernels;
3597  .query()
3598  .template condition<AttribSystem>("FVElementalKernel")
3599  .queryInto(fv_elemental_kernels);
3600 
3601  for (auto fv_kernel : fv_elemental_kernels)
3602  {
3603  if (fv_kernel->blockRestricted())
3604  for (auto block_id : fv_kernel->blockIDs())
3605  input_subdomains.insert(block_id);
3606  else
3607  global_kernels_exist = true;
3608  kernel_variables.insert(fv_kernel->variable().name());
3609 
3610  // Check for lagrange multiplier
3611  if (dynamic_cast<FVScalarLagrangeMultiplierConstraint *>(fv_kernel))
3612  kernel_variables.insert(dynamic_cast<FVScalarLagrangeMultiplierConstraint *>(fv_kernel)
3613  ->lambdaVariable()
3614  .name());
3615  }
3616 
3617  std::vector<FVFluxKernel *> fv_flux_kernels;
3619  .query()
3620  .template condition<AttribSystem>("FVFluxKernel")
3621  .queryInto(fv_flux_kernels);
3622 
3623  for (auto fv_kernel : fv_flux_kernels)
3624  {
3625  if (fv_kernel->blockRestricted())
3626  for (auto block_id : fv_kernel->blockIDs())
3627  input_subdomains.insert(block_id);
3628  else
3629  global_kernels_exist = true;
3630  kernel_variables.insert(fv_kernel->variable().name());
3631  }
3632 
3633  std::vector<FVInterfaceKernel *> fv_interface_kernels;
3635  .query()
3636  .template condition<AttribSystem>("FVInterfaceKernel")
3637  .queryInto(fv_interface_kernels);
3638 
3639  for (auto fvik : fv_interface_kernels)
3640  if (auto scalar_fvik = dynamic_cast<FVScalarLagrangeMultiplierInterface *>(fvik))
3641  kernel_variables.insert(scalar_fvik->lambdaVariable().name());
3642 
3643  std::vector<FVFluxBC *> fv_flux_bcs;
3645  .query()
3646  .template condition<AttribSystem>("FVFluxBC")
3647  .queryInto(fv_flux_bcs);
3648 
3649  for (auto fvbc : fv_flux_bcs)
3650  if (auto scalar_fvbc = dynamic_cast<FVBoundaryScalarLagrangeMultiplierConstraint *>(fvbc))
3651  kernel_variables.insert(scalar_fvbc->lambdaVariable().name());
3652  }
3653 
3654  // Check kernel coverage of subdomains (blocks) in your mesh
3655  if (!global_kernels_exist)
3656  {
3657  std::set<SubdomainID> difference;
3658  std::set_difference(mesh_subdomains.begin(),
3659  mesh_subdomains.end(),
3660  input_subdomains.begin(),
3661  input_subdomains.end(),
3662  std::inserter(difference, difference.end()));
3663 
3664  // there supposed to be no kernels on this lower-dimensional subdomain
3665  for (const auto & id : _mesh.interiorLowerDBlocks())
3666  difference.erase(id);
3667  for (const auto & id : _mesh.boundaryLowerDBlocks())
3668  difference.erase(id);
3669 
3670  if (!difference.empty())
3671  {
3672  std::vector<SubdomainID> difference_vec =
3673  std::vector<SubdomainID>(difference.begin(), difference.end());
3674  std::vector<SubdomainName> difference_names = _mesh.getSubdomainNames(difference_vec);
3675  std::stringstream missing_block_names;
3676  std::copy(difference_names.begin(),
3677  difference_names.end(),
3678  std::ostream_iterator<std::string>(missing_block_names, " "));
3679  std::stringstream missing_block_ids;
3680  std::copy(difference.begin(),
3681  difference.end(),
3682  std::ostream_iterator<unsigned int>(missing_block_ids, " "));
3683 
3684  mooseError("Each subdomain must contain at least one Kernel.\nThe following block(s) lack an "
3685  "active kernel: " +
3686  missing_block_names.str(),
3687  " (ids: ",
3688  missing_block_ids.str(),
3689  ")");
3690  }
3691  }
3692 
3693  // Check kernel use of variables
3694  std::set<VariableName> variables(getVariableNames().begin(), getVariableNames().end());
3695 
3696  std::set<VariableName> difference;
3697  std::set_difference(variables.begin(),
3698  variables.end(),
3699  kernel_variables.begin(),
3700  kernel_variables.end(),
3701  std::inserter(difference, difference.end()));
3702 
3703  // skip checks for varaibles defined on lower-dimensional subdomain
3704  std::set<VariableName> vars(difference);
3705  for (auto & var_name : vars)
3706  {
3707  auto blks = getSubdomainsForVar(var_name);
3708  for (const auto & id : blks)
3709  if (_mesh.interiorLowerDBlocks().count(id) > 0 || _mesh.boundaryLowerDBlocks().count(id) > 0)
3710  difference.erase(var_name);
3711  }
3712 
3713  if (!difference.empty())
3714  {
3715  std::stringstream missing_kernel_vars;
3716  std::copy(difference.begin(),
3717  difference.end(),
3718  std::ostream_iterator<std::string>(missing_kernel_vars, " "));
3719  mooseError("Each variable must be referenced by at least one active Kernel.\nThe following "
3720  "variable(s) lack an active kernel: " +
3721  missing_kernel_vars.str());
3722  }
3723 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
const std::set< SubdomainID > & interiorLowerDBlocks() const
Definition: MooseMesh.h:1403
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
char ** vars
TheWarehouse & theWarehouse() const
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Populates a set of covered subdomains and the associated variable names.
MooseObjectTagWarehouse< KernelBase > _kernels
const std::set< SubdomainID > & boundaryLowerDBlocks() const
Definition: MooseMesh.h:1407
std::vector< SubdomainName > getSubdomainNames(const std::vector< SubdomainID > &subdomain_ids) const
Get the associated subdomainNames for the subdomain ids that are passed in.
Definition: MooseMesh.C:1769
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
MooseMesh & _mesh
Definition: SystemBase.h:991
bool hasActiveObjects(THREAD_ID tid=0) const
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:860
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
Definition: SystemBase.h:761
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Update supplied subdomain and variable coverate containters.
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels

◆ clearAllDofIndices()

void SystemBase::clearAllDofIndices ( )
inherited

Clear all dof indices from moose variables.

Definition at line 1605 of file SystemBase.C.

Referenced by SubProblem::clearAllDofIndices().

1606 {
1607  for (auto & var_warehouse : _vars)
1608  var_warehouse.clearAllDofIndices();
1609 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ closeTaggedMatrices()

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

Close all matrices associated the tags.

Definition at line 1052 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal(), LinearSystem::computeLinearSystemInternal(), and NonlinearSystemBase::computeResidualAndJacobianTags().

1053 {
1054  for (auto tag : tags)
1055  if (hasMatrix(tag))
1056  getMatrix(tag).close();
1057 }
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
virtual void close()=0
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1016

◆ closeTaggedVector()

void SystemBase::closeTaggedVector ( const TagID  tag)
inherited

Close vector with the given tag.

Definition at line 649 of file SystemBase.C.

Referenced by SystemBase::closeTaggedVectors().

650 {
651  if (!_subproblem.vectorTagExists(tag))
652  mooseError("Cannot close vector with TagID ",
653  tag,
654  " in system '",
655  name(),
656  "' because that tag does not exist in the problem");
657  else if (!hasVector(tag))
658  mooseError("Cannot close vector tag with name '",
660  "' in system '",
661  name(),
662  "' because there is no vector associated with that tag");
663  getVector(tag).close();
664 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:916
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual const std::string & name() const
Definition: SystemBase.C:1332
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:201
virtual void close()=0
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:221
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:925

◆ closeTaggedVectors()

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

Close all vectors for given tags.

Definition at line 667 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeResidualAndJacobianTags(), NonlinearSystemBase::computeResidualTags(), NonlinearSystem::stopSolve(), and LinearSystem::stopSolve().

668 {
669  for (const auto tag : tags)
670  closeTaggedVector(tag);
671 }
void closeTaggedVector(const TagID tag)
Close vector with the given tag.
Definition: SystemBase.C:649

◆ compute()

void SolverSystem::compute ( ExecFlagType  type)
overridevirtualinherited

Compute time derivatives, auxiliary variables, etc.

Parameters
typeOur current execution stage

Implements SystemBase.

Reimplemented in LinearSystem.

Definition at line 134 of file SolverSystem.C.

135 {
136  // Let's try not to overcompute
137  bool compute_tds = false;
138  if (type == EXEC_LINEAR)
139  compute_tds = true;
140  else if (type == EXEC_NONLINEAR)
141  {
143  compute_tds = true;
144  }
145  else if ((type == EXEC_TIMESTEP_END) || (type == EXEC_FINAL))
146  {
148  // We likely don't have a final residual evaluation upon which we compute the time derivatives
149  // so we need to do so now
150  compute_tds = true;
151  }
152 
153  if (compute_tds && _fe_problem.dt() > 0.)
154  for (auto & ti : _time_integrators)
155  {
156  // avoid division by dt which might be zero.
157  ti->preStep();
158  ti->computeTimeDerivatives();
159  }
160 }
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
Definition: SystemBase.h:1049
Solving a linear problem.
Definition: MooseTypes.h:849
const ExecFlagType EXEC_TIMESTEP_END
Definition: Moose.C:36
void computingScalingJacobian(bool computing_scaling_jacobian)
Setter for whether we&#39;re computing the scaling jacobian.
virtual bool matrixFromColoring() const
Whether a system matrix is formed from coloring.
Definition: SolverSystem.h:102
Moose::SolveType _type
Definition: SolverParams.h:19
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
const ExecFlagType EXEC_LINEAR
Definition: Moose.C:31
const ExecFlagType EXEC_NONLINEAR
Definition: Moose.C:33
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
SolverParams & solverParams(unsigned int solver_sys_num=0)
Get the solver parameters.
virtual Real & dt() const
const ExecFlagType EXEC_FINAL
Definition: Moose.C:46

◆ computeDamping()

Real NonlinearSystemBase::computeDamping ( const NumericVector< Number > &  solution,
const NumericVector< Number > &  update 
)
inherited

Compute damping.

Parameters
solutionThe trail solution vector
updateThe incremental update to the solution vector
Returns
returns The damping factor

Definition at line 3303 of file NonlinearSystemBase.C.

Referenced by FEProblemBase::computeDamping().

3305 {
3306  // Default to no damping
3307  Real damping = 1.0;
3308  bool has_active_dampers = false;
3309 
3310  try
3311  {
3313  {
3314  PARALLEL_TRY
3315  {
3316  TIME_SECTION("computeDampers", 3, "Computing Dampers");
3317  has_active_dampers = true;
3321  damping = std::min(cid.damping(), damping);
3322  }
3323  PARALLEL_CATCH;
3324  }
3325 
3327  {
3328  PARALLEL_TRY
3329  {
3330  TIME_SECTION("computeDamping::element", 3, "Computing Element Damping");
3331 
3332  has_active_dampers = true;
3336  damping = std::min(cndt.damping(), damping);
3337  }
3338  PARALLEL_CATCH;
3339  }
3340 
3342  {
3343  PARALLEL_TRY
3344  {
3345  TIME_SECTION("computeDamping::general", 3, "Computing General Damping");
3346 
3347  has_active_dampers = true;
3348  const auto & gdampers = _general_dampers.getActiveObjects();
3349  for (const auto & damper : gdampers)
3350  {
3351  Real gd_damping = damper->computeDamping(solution, update);
3352  try
3353  {
3354  damper->checkMinDamping(gd_damping);
3355  }
3356  catch (MooseException & e)
3357  {
3359  }
3360  damping = std::min(gd_damping, damping);
3361  }
3362  }
3363  PARALLEL_CATCH;
3364  }
3365  }
3366  catch (MooseException & e)
3367  {
3368  // The buck stops here, we have already handled the exception by
3369  // calling stopSolve(), it is now up to PETSc to return a
3370  // "diverged" reason during the next solve.
3371  }
3372 
3373  _communicator.min(damping);
3374 
3375  if (has_active_dampers && damping < 1.0)
3376  _console << " Damping factor: " << damping << std::endl;
3377 
3378  return damping;
3379 }
virtual const char * what() const
Get out the error message.
NumericVector< Number > & solution()
Definition: SystemBase.h:196
void parallel_reduce(const Range &range, Body &body, const Partitioner &)
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
const Parallel::Communicator & _communicator
const libMesh::ConstElemRange & getCurrentAlgebraicElementRange()
These are the element and nodes that contribute to the jacobian and residual for this local processor...
const libMesh::ConstNodeRange & getCurrentAlgebraicNodeRange()
void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:1235
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
void min(const T &r, T &o, Request &req) const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
Provides a way for users to bail out of the current solve.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
NumericVector< Number > * _increment_vec
increment vector
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
auto min(const L &left, const R &right)

◆ computeDiracContributions()

void NonlinearSystemBase::computeDiracContributions ( const std::set< TagID > &  tags,
bool  is_jacobian 
)
protectedinherited

Definition at line 3382 of file NonlinearSystemBase.C.

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

3383 {
3385 
3386  std::set<const Elem *> dirac_elements;
3387 
3389  {
3390  TIME_SECTION("computeDirac", 3, "Computing DiracKernels");
3391 
3392  // TODO: Need a threading fix... but it's complicated!
3393  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
3394  {
3395  const auto & dkernels = _dirac_kernels.getActiveObjects(tid);
3396  for (const auto & dkernel : dkernels)
3397  {
3398  dkernel->clearPoints();
3399  dkernel->addPoints();
3400  }
3401  }
3402 
3403  ComputeDiracThread cd(_fe_problem, tags, is_jacobian);
3404 
3405  _fe_problem.getDiracElements(dirac_elements);
3406 
3407  DistElemRange range(dirac_elements.begin(), dirac_elements.end(), 1);
3408  // TODO: Make Dirac work thread!
3409  // Threads::parallel_reduce(range, cd);
3410 
3411  cd(range);
3412  }
3413 }
unsigned int n_threads()
virtual void getDiracElements(std::set< const Elem *> &elems) override
Fills "elems" with the elements that should be looped over for Dirac Kernels.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
virtual void clearDiracInfo() override
Gets called before Dirac Kernels are asked to add the points they are supposed to be evaluated in...
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
bool hasActiveObjects(THREAD_ID tid=0) const
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ computedScalingJacobian()

bool NonlinearSystemBase::computedScalingJacobian ( ) const
inlineinherited

Definition at line 78 of file NonlinearSystemBase.h.

78 { return _computed_scaling; }
bool _computed_scaling
Flag used to indicate whether we have already computed the scaling Jacobian.

◆ computeJacobian() [1/2]

void NonlinearSystemBase::computeJacobian ( libMesh::SparseMatrix< Number > &  jacobian,
const std::set< TagID > &  tags 
)
inherited

Associate jacobian to systemMatrixTag, and then form a matrix for all the tags.

Definition at line 3153 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobian().

3154 {
3156 
3157  computeJacobianTags(tags);
3158 
3160 }
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
virtual void associateMatrixToTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
Definition: SystemBase.C:1068
virtual void disassociateMatrixFromTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
Definition: SystemBase.C:1080
void computeJacobianTags(const std::set< TagID > &tags)
Computes multiple (tag associated) Jacobian matricese.

◆ computeJacobian() [2/2]

void NonlinearSystemBase::computeJacobian ( libMesh::SparseMatrix< Number > &  jacobian)
inherited

Take all tags in the system, and form a matrix for all tags in the system.

Definition at line 3140 of file NonlinearSystemBase.C.

3141 {
3142  _nl_matrix_tags.clear();
3143 
3144  auto & tags = _fe_problem.getMatrixTags();
3145 
3146  for (auto & tag : tags)
3147  _nl_matrix_tags.insert(tag.second);
3148 
3149  computeJacobian(jacobian, _nl_matrix_tags);
3150 }
void computeJacobian(libMesh::SparseMatrix< Number > &jacobian, const std::set< TagID > &tags)
Associate jacobian to systemMatrixTag, and then form a matrix for all the tags.
std::set< TagID > _nl_matrix_tags
Matrix tags to temporarily store all tags associated with the current system.
virtual std::map< TagName, TagID > & getMatrixTags()
Return all matrix tags in the system, where a tag is represented by a map from name to ID...
Definition: SubProblem.h:253
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986

◆ computeJacobianBlocks() [1/2]

void NonlinearSystemBase::computeJacobianBlocks ( std::vector< JacobianBlock *> &  blocks)
inherited

Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditioning matrices.

Used by Physics-based preconditioning

Parameters
blocksThe blocks to fill in (JacobianBlock is defined in ComputeJacobianBlocksThread)

Definition at line 3182 of file NonlinearSystemBase.C.

Referenced by EigenProblem::computeJacobianBlocks(), and FEProblemBase::computeJacobianBlocks().

3183 {
3184  _nl_matrix_tags.clear();
3185 
3186  auto & tags = _fe_problem.getMatrixTags();
3187  for (auto & tag : tags)
3188  _nl_matrix_tags.insert(tag.second);
3189 
3191 }
void computeJacobianBlocks(std::vector< JacobianBlock *> &blocks)
Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditio...
char ** blocks
std::set< TagID > _nl_matrix_tags
Matrix tags to temporarily store all tags associated with the current system.
virtual std::map< TagName, TagID > & getMatrixTags()
Return all matrix tags in the system, where a tag is represented by a map from name to ID...
Definition: SubProblem.h:253
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986

◆ computeJacobianBlocks() [2/2]

void NonlinearSystemBase::computeJacobianBlocks ( std::vector< JacobianBlock *> &  blocks,
const std::set< TagID > &  tags 
)
inherited

Definition at line 3194 of file NonlinearSystemBase.C.

3196 {
3197  TIME_SECTION("computeJacobianBlocks", 3);
3198  FloatingPointExceptionGuard fpe_guard(_app);
3199 
3200  for (unsigned int i = 0; i < blocks.size(); i++)
3201  {
3202  SparseMatrix<Number> & jacobian = blocks[i]->_jacobian;
3203 
3204  LibmeshPetscCall(MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
3205  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
3206  PETSC_TRUE));
3208  LibmeshPetscCall(MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
3209  MAT_NEW_NONZERO_ALLOCATION_ERR,
3210  PETSC_TRUE));
3211 
3212  jacobian.zero();
3213  }
3214 
3215  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
3217 
3218  PARALLEL_TRY
3219  {
3222  Threads::parallel_reduce(elem_range, cjb);
3223  }
3224  PARALLEL_CATCH;
3225 
3226  for (unsigned int i = 0; i < blocks.size(); i++)
3227  blocks[i]->_jacobian.close();
3228 
3229  for (unsigned int i = 0; i < blocks.size(); i++)
3230  {
3231  libMesh::System & precond_system = blocks[i]->_precond_system;
3232  SparseMatrix<Number> & jacobian = blocks[i]->_jacobian;
3233 
3234  unsigned int ivar = blocks[i]->_ivar;
3235  unsigned int jvar = blocks[i]->_jvar;
3236 
3237  // Dirichlet BCs
3238  std::vector<numeric_index_type> zero_rows;
3239  PARALLEL_TRY
3240  {
3242  for (const auto & bnode : bnd_nodes)
3243  {
3244  BoundaryID boundary_id = bnode->_bnd_id;
3245  Node * node = bnode->_node;
3246 
3247  if (_nodal_bcs.hasActiveBoundaryObjects(boundary_id))
3248  {
3249  const auto & bcs = _nodal_bcs.getActiveBoundaryObjects(boundary_id);
3250 
3251  if (node->processor_id() == processor_id())
3252  {
3253  _fe_problem.reinitNodeFace(node, boundary_id, 0);
3254 
3255  for (const auto & bc : bcs)
3256  if (bc->variable().number() == ivar && bc->shouldApply())
3257  {
3258  // The first zero is for the variable number... there is only one variable in
3259  // each mini-system The second zero only works with Lagrange elements!
3260  zero_rows.push_back(node->dof_number(precond_system.number(), 0, 0));
3261  }
3262  }
3263  }
3264  }
3265  }
3266  PARALLEL_CATCH;
3267 
3268  jacobian.close();
3269 
3270  // This zeroes the rows corresponding to Dirichlet BCs and puts a 1.0 on the diagonal
3271  if (ivar == jvar)
3272  jacobian.zero_rows(zero_rows, 1.0);
3273  else
3274  jacobian.zero_rows(zero_rows, 0.0);
3275 
3276  jacobian.close();
3277  }
3278 }
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
unsigned int n_threads()
char ** blocks
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
void parallel_reduce(const Range &range, Body &body, const Partitioner &)
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
const libMesh::ConstElemRange & getCurrentAlgebraicElementRange()
These are the element and nodes that contribute to the jacobian and residual for this local processor...
Scope guard for starting and stopping Floating Point Exception Trapping.
Specialization for filling multiple "small" preconditioning matrices simulatenously.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
const ConstBndNodeRange & getCurrentAlgebraicBndNodeRange()
unsigned int number() const
virtual void zero()=0
boundary_id_type BoundaryID
virtual void zero_rows(std::vector< numeric_index_type > &rows, T diag_value=0.0)
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
MooseApp & _app
Definition: SystemBase.h:988
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual void close()=0
processor_id_type processor_id() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
processor_id_type processor_id() const

◆ computeJacobianInternal()

void NonlinearSystemBase::computeJacobianInternal ( const std::set< TagID > &  tags)
protectedinherited

Form multiple matrices for all the tags.

Users should not call this func directly.

Definition at line 2774 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianTags().

2775 {
2776  TIME_SECTION("computeJacobianInternal", 3);
2777 
2779 
2780  // Make matrix ready to use
2782 
2783  for (auto tag : tags)
2784  {
2785  if (!hasMatrix(tag))
2786  continue;
2787 
2788  auto & jacobian = getMatrix(tag);
2789  // Necessary for speed
2790  if (auto petsc_matrix = dynamic_cast<PetscMatrix<Number> *>(&jacobian))
2791  {
2792  LibmeshPetscCall(MatSetOption(petsc_matrix->mat(),
2793  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2794  PETSC_TRUE));
2796  LibmeshPetscCall(
2797  MatSetOption(petsc_matrix->mat(), MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE));
2799  LibmeshPetscCall(MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2800  MAT_IGNORE_ZERO_ENTRIES,
2801  PETSC_TRUE));
2802  }
2803  }
2804 
2805  jacobianSetup();
2806 
2807  // Jacobian contributions from UOs - for now this is used for ray tracing
2808  // and ray kernels that contribute to the Jacobian (think line sources)
2809  std::vector<UserObject *> uos;
2811  .query()
2812  .condition<AttribSystem>("UserObject")
2813  .condition<AttribExecOns>(EXEC_PRE_KERNELS)
2814  .queryInto(uos);
2815  for (auto & uo : uos)
2816  uo->jacobianSetup();
2817  for (auto & uo : uos)
2818  {
2819  uo->initialize();
2820  uo->execute();
2821  uo->finalize();
2822  }
2823 
2824  // reinit scalar variables
2825  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
2827 
2828  PARALLEL_TRY
2829  {
2830  // We would like to compute ScalarKernels, block NodalKernels, FVFluxKernels, and mortar objects
2831  // up front because we want these included whether we are computing an ordinary Jacobian or a
2832  // Jacobian for determining variable scaling factors
2834 
2835  // Block restricted Nodal Kernels
2837  {
2840  Threads::parallel_reduce(range, cnkjt);
2841 
2842  unsigned int n_threads = libMesh::n_threads();
2843  for (unsigned int i = 0; i < n_threads;
2844  i++) // Add any cached jacobians that might be hanging around
2846  }
2847 
2849  if (_fe_problem.haveFV())
2850  {
2851  // the same loop works for both residual and jacobians because it keys
2852  // off of FEProblem's _currently_computing_jacobian parameter
2854  _fe_problem, this->number(), tags, /*on_displaced=*/false);
2856  Threads::parallel_reduce(faces, fvj);
2857  }
2859  displaced_problem && displaced_problem->haveFV())
2860  {
2862  _fe_problem, this->number(), tags, /*on_displaced=*/true);
2863  FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
2864  displaced_problem->mesh().ownedFaceInfoEnd());
2865  Threads::parallel_reduce(faces, fvr);
2866  }
2867 
2869 
2870  // Get our element range for looping over
2872 
2874  {
2875  // Only compute Jacobians corresponding to the diagonals of volumetric compute objects
2876  // because this typically gives us a good representation of the physics. NodalBCs and
2877  // Constraints can introduce dramatically different scales (often order unity).
2878  // IntegratedBCs and/or InterfaceKernels may use penalty factors. DGKernels may be ok, but
2879  // they are almost always used in conjunction with Kernels
2881  Threads::parallel_reduce(elem_range, cj);
2882  unsigned int n_threads = libMesh::n_threads();
2883  for (unsigned int i = 0; i < n_threads;
2884  i++) // Add any Jacobian contributions still hanging around
2886 
2887  // Check whether any exceptions were thrown and propagate this information for parallel
2888  // consistency before
2889  // 1) we do parallel communication when closing tagged matrices
2890  // 2) early returning before reaching our PARALLEL_CATCH below
2892 
2893  closeTaggedMatrices(tags);
2894 
2895  return;
2896  }
2897 
2898  switch (_fe_problem.coupling())
2899  {
2900  case Moose::COUPLING_DIAG:
2901  {
2903  Threads::parallel_reduce(elem_range, cj);
2904 
2905  unsigned int n_threads = libMesh::n_threads();
2906  for (unsigned int i = 0; i < n_threads;
2907  i++) // Add any Jacobian contributions still hanging around
2909 
2910  // Boundary restricted Nodal Kernels
2912  {
2915 
2916  Threads::parallel_reduce(bnd_range, cnkjt);
2917  unsigned int n_threads = libMesh::n_threads();
2918  for (unsigned int i = 0; i < n_threads;
2919  i++) // Add any cached jacobians that might be hanging around
2921  }
2922  }
2923  break;
2924 
2925  default:
2927  {
2929  Threads::parallel_reduce(elem_range, cj);
2930  unsigned int n_threads = libMesh::n_threads();
2931 
2932  for (unsigned int i = 0; i < n_threads; i++)
2934 
2935  // Boundary restricted Nodal Kernels
2937  {
2940 
2941  Threads::parallel_reduce(bnd_range, cnkjt);
2942  unsigned int n_threads = libMesh::n_threads();
2943  for (unsigned int i = 0; i < n_threads;
2944  i++) // Add any cached jacobians that might be hanging around
2946  }
2947  }
2948  break;
2949  }
2950 
2951  computeDiracContributions(tags, true);
2952 
2953  static bool first = true;
2954 
2955  // This adds zeroes into geometric coupling entries to ensure they stay in the matrix
2956  if ((_fe_problem.restoreOriginalNonzeroPattern() || first) &&
2958  {
2959  first = false;
2961 
2964  }
2965  }
2966  PARALLEL_CATCH;
2967 
2968  // Have no idea how to have constraints work
2969  // with the tag system
2970  PARALLEL_TRY
2971  {
2972  // Add in Jacobian contributions from other Constraints
2973  if (_fe_problem._has_constraints && tags.count(systemMatrixTag()))
2974  {
2975  // Some constraints need to be able to read values from the Jacobian, which requires that it
2976  // be closed/assembled
2977  auto & system_matrix = getMatrix(systemMatrixTag());
2978 #if PETSC_RELEASE_GREATER_EQUALS(3, 23, 0)
2979  SparseMatrix<Number> * view_jac_ptr;
2980  std::unique_ptr<SparseMatrix<Number>> hash_copy;
2981  if (system_matrix.use_hash_table())
2982  {
2983  hash_copy = libMesh::cast_ref<PetscMatrix<Number> &>(system_matrix).copy_from_hash();
2984  view_jac_ptr = hash_copy.get();
2985  }
2986  else
2987  view_jac_ptr = &system_matrix;
2988  auto & jacobian_to_view = *view_jac_ptr;
2989 #else
2990  auto & jacobian_to_view = system_matrix;
2991 #endif
2992  if (&jacobian_to_view == &system_matrix)
2993  system_matrix.close();
2994 
2995  // Nodal Constraints
2997 
2998  // Undisplaced Constraints
2999  constraintJacobians(jacobian_to_view, false);
3000 
3001  // Displaced Constraints
3003  constraintJacobians(jacobian_to_view, true);
3004  }
3005  }
3006  PARALLEL_CATCH;
3007 
3008  // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs
3009  // on boundary nodes
3010  if (_has_diag_save_in)
3012 
3013  PARALLEL_TRY
3014  {
3015  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
3016  // Select nodal kernels
3017  if (tags.size() == _fe_problem.numMatrixTags() || !tags.size())
3018  nbc_warehouse = &_nodal_bcs;
3019  else if (tags.size() == 1)
3020  nbc_warehouse = &(_nodal_bcs.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
3021  else
3022  nbc_warehouse = &(_nodal_bcs.getMatrixTagsObjectWarehouse(tags, 0));
3023 
3024  if (nbc_warehouse->hasActiveObjects())
3025  {
3026  // We may be switching from add to set. Moreover, we rely on a call to MatZeroRows to enforce
3027  // the nodal boundary condition constraints which requires that the matrix be truly assembled
3028  // as opposed to just flushed. Consequently we can't do the following despite any desire to
3029  // keep our initial sparsity pattern honored (see https://gitlab.com/petsc/petsc/-/issues/852)
3030  //
3031  // flushTaggedMatrices(tags);
3032  closeTaggedMatrices(tags);
3033 
3034  // Cache the information about which BCs are coupled to which
3035  // variables, so we don't have to figure it out for each node.
3036  std::map<std::string, std::set<unsigned int>> bc_involved_vars;
3037  const std::set<BoundaryID> & all_boundary_ids = _mesh.getBoundaryIDs();
3038  for (const auto & bid : all_boundary_ids)
3039  {
3040  // Get reference to all the NodalBCs for this ID. This is only
3041  // safe if there are NodalBCBases there to be gotten...
3042  if (nbc_warehouse->hasActiveBoundaryObjects(bid))
3043  {
3044  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(bid);
3045  for (const auto & bc : bcs)
3046  {
3047  const std::vector<MooseVariableFEBase *> & coupled_moose_vars =
3048  bc->getCoupledMooseVars();
3049 
3050  // Create the set of "involved" MOOSE nonlinear vars, which includes all coupled vars
3051  // and the BC's own variable
3052  std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
3053  for (const auto & coupled_var : coupled_moose_vars)
3054  if (coupled_var->kind() == Moose::VAR_SOLVER)
3055  var_set.insert(coupled_var->number());
3056 
3057  var_set.insert(bc->variable().number());
3058  }
3059  }
3060  }
3061 
3062  // reinit scalar variables again. This reinit does not re-fill any of the scalar variable
3063  // solution arrays because that was done above. It only will reorder the derivative
3064  // information for AD calculations to be suitable for NodalBC calculations
3065  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
3066  _fe_problem.reinitScalars(tid, true);
3067 
3068  // Get variable coupling list. We do all the NodalBCBase stuff on
3069  // thread 0... The couplingEntries() data structure determines
3070  // which variables are "coupled" as far as the preconditioner is
3071  // concerned, not what variables a boundary condition specifically
3072  // depends on.
3073  auto & coupling_entries = _fe_problem.couplingEntries(/*_tid=*/0, this->number());
3074 
3075  // Compute Jacobians for NodalBCBases
3077  for (const auto & bnode : bnd_nodes)
3078  {
3079  BoundaryID boundary_id = bnode->_bnd_id;
3080  Node * node = bnode->_node;
3081 
3082  if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id) &&
3083  node->processor_id() == processor_id())
3084  {
3085  _fe_problem.reinitNodeFace(node, boundary_id, 0);
3086 
3087  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
3088  for (const auto & bc : bcs)
3089  {
3090  // Get the set of involved MOOSE vars for this BC
3091  std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
3092 
3093  // Loop over all the variables whose Jacobian blocks are
3094  // actually being computed, call computeOffDiagJacobian()
3095  // for each one which is actually coupled (otherwise the
3096  // value is zero.)
3097  for (const auto & it : coupling_entries)
3098  {
3099  unsigned int ivar = it.first->number(), jvar = it.second->number();
3100 
3101  // We are only going to call computeOffDiagJacobian() if:
3102  // 1.) the BC's variable is ivar
3103  // 2.) jvar is "involved" with the BC (including jvar==ivar), and
3104  // 3.) the BC should apply.
3105  if ((bc->variable().number() == ivar) && var_set.count(jvar) && bc->shouldApply())
3106  bc->computeOffDiagJacobian(jvar);
3107  }
3108 
3109  const auto & coupled_scalar_vars = bc->getCoupledMooseScalarVars();
3110  for (const auto & jvariable : coupled_scalar_vars)
3111  if (hasScalarVariable(jvariable->name()))
3112  bc->computeOffDiagJacobianScalar(jvariable->number());
3113  }
3114  }
3115  } // end loop over boundary nodes
3116 
3117  // Set the cached NodalBCBase values in the Jacobian matrix
3119  }
3120  }
3121  PARALLEL_CATCH;
3122 
3123  closeTaggedMatrices(tags);
3124 
3125  // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs
3126  // on boundary nodes
3129 
3130  if (hasDiagSaveIn())
3132 
3133  // Accumulate the occurrence of solution invalid warnings for the current iteration cumulative
3134  // counters
3137 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
std::vector< std::pair< MooseVariableFEBase *, MooseVariableFEBase * > > & couplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num)
unsigned int n_threads()
bool hasActiveBlockObjects(THREAD_ID tid=0) const
std::shared_ptr< DisplacedProblem > displaced_problem
virtual void checkExceptionAndStopSolve(bool print_message=true)
Check to see if an exception has occurred on any processor and, if possible, force the solve to fail...
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
NumericVector< Number > & solution()
Definition: SystemBase.h:196
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
face_info_iterator ownedFaceInfoBegin()
Iterators to owned faceInfo objects.
Definition: MooseMesh.C:1510
bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
void parallel_reduce(const Range &range, Body &body, const Partitioner &)
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
bool hasDiagSaveIn() const
Weather or not the nonlinear system has diagonal Jacobian save-ins.
const libMesh::ConstElemRange & getCurrentAlgebraicElementRange()
These are the element and nodes that contribute to the jacobian and residual for this local processor...
const libMesh::ConstNodeRange & getCurrentAlgebraicNodeRange()
void computingScalingJacobian(bool computing_scaling_jacobian)
Setter for whether we&#39;re computing the scaling jacobian.
virtual GeometricSearchData & geomSearchData() override
void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:1235
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
virtual void activateAllMatrixTags()
Make all existing matrices active.
Definition: SystemBase.C:1123
const ConstBndNodeRange & getCurrentAlgebraicBndNodeRange()
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
Definition: SystemBase.C:1052
void solutionInvalidAccumulation()
Pass the number of solution invalid occurrences from current iteration to cumulative counters...
void syncIteration()
Sync iteration counts to main processor.
void setCurrentNonlinearSystem(const unsigned int nl_sys_num)
void computeDiracContributions(const std::set< TagID > &tags, bool is_jacobian)
TheWarehouse & theWarehouse() const
boundary_id_type BoundaryID
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:172
void addImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data)
Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled th...
MooseObjectWarehouse< T > & getMatrixTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given matrix tag...
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
Moose::CouplingType coupling() const
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
AuxiliarySystem & getAuxiliarySystem()
virtual void close()=0
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
bool _add_implicit_geometric_coupling_entries_to_jacobian
Whether or not to add implicit geometric couplings to the Jacobian for FDP.
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:248
MooseApp & _app
Definition: SystemBase.h:988
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual void close()=0
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
MooseMesh & _mesh
Definition: SystemBase.h:991
bool hasActiveObjects(THREAD_ID tid=0) const
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1016
MooseObjectWarehouse< T > & getMatrixTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has one of the given matrix tags...
void computeScalarKernelsJacobians(const std::set< TagID > &tags)
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
virtual MooseMesh & mesh() override
void setCachedJacobian(GlobalDataKey)
Sets previously-cached Jacobian values via SparseMatrix::set() calls.
Definition: Assembly.C:4492
bool ignoreZerosInJacobian() const
Will return true if zeros in the Jacobian are to be dropped from the sparsity pattern.
const ExecFlagType EXEC_PRE_KERNELS
Definition: Moose.C:56
void mortarConstraints(Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Do mortar constraint residual/jacobian computations.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:284
bool restoreOriginalNonzeroPattern() const
face_info_iterator ownedFaceInfoEnd()
Definition: MooseMesh.C:1519
void constraintJacobians(const SparseMatrix< Number > &jacobian_to_view, bool displaced)
Add jacobian contributions from Constraints.
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side. ...
bool _has_constraints
Whether or not this system has any Constraints.
virtual bool hasScalarVariable(const std::string &var_name) const
Definition: SystemBase.C:868
processor_id_type processor_id() const
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
Definition: Assembly.C:3815
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
processor_id_type processor_id() const
virtual void jacobianSetup() override
virtual void addCachedJacobian(const THREAD_ID tid) override
Key structure for APIs manipulating global vectors/matrices.
Definition: Assembly.h:805

◆ computeJacobianTags()

void NonlinearSystemBase::computeJacobianTags ( const std::set< TagID > &  tags)
inherited

Computes multiple (tag associated) Jacobian matricese.

Definition at line 3163 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobian(), and FEProblemBase::computeJacobianTags().

3164 {
3165  TIME_SECTION("computeJacobianTags", 5);
3166 
3167  FloatingPointExceptionGuard fpe_guard(_app);
3168 
3169  try
3170  {
3172  }
3173  catch (MooseException & e)
3174  {
3175  // The buck stops here, we have already handled the exception by
3176  // calling stopSolve(), it is now up to PETSc to return a
3177  // "diverged" reason during the next solve.
3178  }
3179 }
Scope guard for starting and stopping Floating Point Exception Trapping.
MooseApp & _app
Definition: SystemBase.h:988
Provides a way for users to bail out of the current solve.
void computeJacobianInternal(const std::set< TagID > &tags)
Form multiple matrices for all the tags.

◆ computeNodalBCs() [1/3]

void NonlinearSystemBase::computeNodalBCs ( NumericVector< Number > &  residual)
protectedinherited

Enforces nodal boundary conditions.

The boundary condition will be implemented in the residual using all the tags in the system.

Referenced by NonlinearSystemBase::computeResidualTags().

◆ computeNodalBCs() [2/3]

void NonlinearSystemBase::computeNodalBCs ( NumericVector< Number > &  residual,
const std::set< TagID > &  tags 
)
protectedinherited

Form a residual for BCs that at least has one of the given tags.

◆ computeNodalBCs() [3/3]

void NonlinearSystemBase::computeNodalBCs ( const std::set< TagID > &  tags)
protectedinherited

Form multiple tag-associated residual vectors for the given tags.

Definition at line 2047 of file NonlinearSystemBase.C.

2048 {
2049  // We need to close the diag_save_in variables on the aux system before NodalBCBases clear the
2050  // dofs on boundary nodes
2051  if (_has_save_in)
2053 
2054  // Select nodal kernels
2055  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
2056 
2057  if (tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL) || !tags.size())
2058  nbc_warehouse = &_nodal_bcs;
2059  else if (tags.size() == 1)
2060  nbc_warehouse = &(_nodal_bcs.getVectorTagObjectWarehouse(*(tags.begin()), 0));
2061  else
2062  nbc_warehouse = &(_nodal_bcs.getVectorTagsObjectWarehouse(tags, 0));
2063 
2064  // Return early if there is no nodal kernel
2065  if (!nbc_warehouse->size())
2066  return;
2067 
2068  PARALLEL_TRY
2069  {
2071 
2072  if (!bnd_nodes.empty())
2073  {
2074  TIME_SECTION("NodalBCs", 3 /*, "Computing NodalBCs"*/);
2075 
2076  for (const auto & bnode : bnd_nodes)
2077  {
2078  BoundaryID boundary_id = bnode->_bnd_id;
2079  Node * node = bnode->_node;
2080 
2081  if (node->processor_id() == processor_id() &&
2082  nbc_warehouse->hasActiveBoundaryObjects(boundary_id))
2083  {
2084  // reinit variables in nodes
2085  _fe_problem.reinitNodeFace(node, boundary_id, 0);
2086 
2087  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
2088  for (const auto & nbc : bcs)
2089  if (nbc->shouldApply())
2090  nbc->computeResidual();
2091  }
2092  }
2093  }
2094  }
2095  PARALLEL_CATCH;
2096 
2097  if (_Re_time)
2098  _Re_time->close();
2099  _Re_non_time->close();
2100 }
NumericVector< Number > * _Re_time
residual vector for time contributions
unsigned int size(THREAD_ID tid=0) const
Return how many kernels we store in the current warehouse.
bool empty() const
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
NumericVector< Number > & solution()
Definition: SystemBase.h:196
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< T > & getVectorTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object at least has one of the given vector ta...
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
const ConstBndNodeRange & getCurrentAlgebraicBndNodeRange()
boundary_id_type BoundaryID
AuxiliarySystem & getAuxiliarySystem()
virtual void close()=0
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual unsigned int numVectorTags(const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const
The total number of tags, which can be limited to the tag type.
Definition: SubProblem.C:195
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...
processor_id_type processor_id() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
processor_id_type processor_id() const

◆ computeNodalBCsResidualAndJacobian()

void NonlinearSystemBase::computeNodalBCsResidualAndJacobian ( )
protectedinherited

compute the residual and Jacobian for nodal boundary conditions

Definition at line 2103 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualAndJacobianTags().

2104 {
2105  PARALLEL_TRY
2106  {
2108 
2109  if (!bnd_nodes.empty())
2110  {
2111  TIME_SECTION("NodalBCs", 3 /*, "Computing NodalBCs"*/);
2112 
2113  for (const auto & bnode : bnd_nodes)
2114  {
2115  BoundaryID boundary_id = bnode->_bnd_id;
2116  Node * node = bnode->_node;
2117 
2118  if (node->processor_id() == processor_id())
2119  {
2120  // reinit variables in nodes
2121  _fe_problem.reinitNodeFace(node, boundary_id, 0);
2122  if (_nodal_bcs.hasActiveBoundaryObjects(boundary_id))
2123  {
2124  const auto & bcs = _nodal_bcs.getActiveBoundaryObjects(boundary_id);
2125  for (const auto & nbc : bcs)
2126  if (nbc->shouldApply())
2127  nbc->computeResidualAndJacobian();
2128  }
2129  }
2130  }
2131  }
2132  }
2133  PARALLEL_CATCH;
2134 
2135  // Set the cached NodalBCBase values in the Jacobian matrix
2137 }
bool empty() const
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
const ConstBndNodeRange & getCurrentAlgebraicBndNodeRange()
boundary_id_type BoundaryID
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
void setCachedJacobian(GlobalDataKey)
Sets previously-cached Jacobian values via SparseMatrix::set() calls.
Definition: Assembly.C:4492
processor_id_type processor_id() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
processor_id_type processor_id() const
Key structure for APIs manipulating global vectors/matrices.
Definition: Assembly.h:805

◆ computeResidual()

void NonlinearSystemBase::computeResidual ( NumericVector< Number > &  residual,
TagID  tag_id 
)
inherited

Form a residual vector for a given tag.

Definition at line 780 of file NonlinearSystemBase.C.

781 {
782  mooseDeprecated(" Please use computeResidualTag");
783 
784  computeResidualTag(residual, tag_id);
785 }
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:384
void computeResidualTag(NumericVector< Number > &residual, TagID tag_id)
Computes residual for a given tag.

◆ computeResidualAndJacobianInternal()

void NonlinearSystemBase::computeResidualAndJacobianInternal ( const std::set< TagID > &  vector_tags,
const std::set< TagID > &  matrix_tags 
)
inherited

Compute residual and Jacobian from contributions not related to constraints, such as nodal boundary conditions.

Definition at line 1928 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualAndJacobianTags().

1930 {
1931  TIME_SECTION("computeResidualAndJacobianInternal", 3);
1932 
1933  // Make matrix ready to use
1935 
1936  for (auto tag : matrix_tags)
1937  {
1938  if (!hasMatrix(tag))
1939  continue;
1940 
1941  auto & jacobian = getMatrix(tag);
1942  // Necessary for speed
1943  if (auto petsc_matrix = dynamic_cast<PetscMatrix<Number> *>(&jacobian))
1944  {
1945  LibmeshPetscCall(MatSetOption(petsc_matrix->mat(),
1946  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
1947  PETSC_TRUE));
1949  LibmeshPetscCall(
1950  MatSetOption(petsc_matrix->mat(), MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE));
1952  LibmeshPetscCall(MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
1953  MAT_IGNORE_ZERO_ENTRIES,
1954  PETSC_TRUE));
1955  }
1956  }
1957 
1958  residualSetup();
1959 
1960  // Residual contributions from UOs - for now this is used for ray tracing
1961  // and ray kernels that contribute to the residual (think line sources)
1962  std::vector<UserObject *> uos;
1964  .query()
1965  .condition<AttribSystem>("UserObject")
1966  .condition<AttribExecOns>(EXEC_PRE_KERNELS)
1967  .queryInto(uos);
1968  for (auto & uo : uos)
1969  uo->residualSetup();
1970  for (auto & uo : uos)
1971  {
1972  uo->initialize();
1973  uo->execute();
1974  uo->finalize();
1975  }
1976 
1977  // reinit scalar variables
1978  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
1980 
1981  // residual contributions from the domain
1982  PARALLEL_TRY
1983  {
1984  TIME_SECTION("Kernels", 3 /*, "Computing Kernels"*/);
1985 
1987 
1988  ComputeResidualAndJacobianThread crj(_fe_problem, vector_tags, matrix_tags);
1989  Threads::parallel_reduce(elem_range, crj);
1990 
1992  if (_fe_problem.haveFV())
1993  {
1995  _fe_problem, this->number(), vector_tags, matrix_tags, /*on_displaced=*/false);
1997  Threads::parallel_reduce(faces, fvrj);
1998  }
2000  displaced_problem && displaced_problem->haveFV())
2001  {
2003  _fe_problem, this->number(), vector_tags, matrix_tags, /*on_displaced=*/true);
2004  FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
2005  displaced_problem->mesh().ownedFaceInfoEnd());
2006  Threads::parallel_reduce(faces, fvr);
2007  }
2008 
2010 
2011  unsigned int n_threads = libMesh::n_threads();
2012  for (unsigned int i = 0; i < n_threads;
2013  i++) // Add any cached residuals that might be hanging around
2014  {
2017  }
2018  }
2019  PARALLEL_CATCH;
2020 }
unsigned int n_threads()
std::shared_ptr< DisplacedProblem > displaced_problem
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
face_info_iterator ownedFaceInfoBegin()
Iterators to owned faceInfo objects.
Definition: MooseMesh.C:1510
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
void parallel_reduce(const Range &range, Body &body, const Partitioner &)
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
const libMesh::ConstElemRange & getCurrentAlgebraicElementRange()
These are the element and nodes that contribute to the jacobian and residual for this local processor...
virtual void activateAllMatrixTags()
Make all existing matrices active.
Definition: SystemBase.C:1123
TheWarehouse & theWarehouse() const
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1016
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
virtual MooseMesh & mesh() override
bool ignoreZerosInJacobian() const
Will return true if zeros in the Jacobian are to be dropped from the sparsity pattern.
const ExecFlagType EXEC_PRE_KERNELS
Definition: Moose.C:56
void mortarConstraints(Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Do mortar constraint residual/jacobian computations.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:284
face_info_iterator ownedFaceInfoEnd()
Definition: MooseMesh.C:1519
virtual void addCachedResidual(const THREAD_ID tid) override
virtual void addCachedJacobian(const THREAD_ID tid) override
virtual void residualSetup() override

◆ computeResidualAndJacobianTags()

void NonlinearSystemBase::computeResidualAndJacobianTags ( const std::set< TagID > &  vector_tags,
const std::set< TagID > &  matrix_tags 
)
inherited

Form possibly multiple tag-associated vectors and matrices.

Definition at line 868 of file NonlinearSystemBase.C.

Referenced by FEProblemBase::computeResidualAndJacobian().

870 {
871  const bool required_residual =
872  vector_tags.find(residualVectorTag()) == vector_tags.end() ? false : true;
873 
874  try
875  {
876  zeroTaggedVectors(vector_tags);
877  computeResidualAndJacobianInternal(vector_tags, matrix_tags);
878  closeTaggedVectors(vector_tags);
879  closeTaggedMatrices(matrix_tags);
880 
881  if (required_residual)
882  {
883  auto & residual = getVector(residualVectorTag());
884  if (!_time_integrators.empty())
885  {
886  for (auto & ti : _time_integrators)
887  ti->postResidual(residual);
888  }
889  else
890  residual += *_Re_non_time;
891  residual.close();
892  }
893 
895  closeTaggedVectors(vector_tags);
896  closeTaggedMatrices(matrix_tags);
897  }
898  catch (MooseException & e)
899  {
900  // The buck stops here, we have already handled the exception by
901  // calling stopSolve(), it is now up to PETSc to return a
902  // "diverged" reason during the next solve.
903  }
904 }
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
Definition: SystemBase.h:1049
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition: SystemBase.C:693
void computeNodalBCsResidualAndJacobian()
compute the residual and Jacobian for nodal boundary conditions
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
void computeResidualAndJacobianInternal(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Compute residual and Jacobian from contributions not related to constraints, such as nodal boundary c...
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
Definition: SystemBase.C:1052
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition: SystemBase.C:667
virtual void close()=0
TagID residualVectorTag() const override
Provides a way for users to bail out of the current solve.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:925

◆ computeResidualInternal()

void NonlinearSystemBase::computeResidualInternal ( const std::set< TagID > &  tags)
protectedinherited

Compute the residual for a given tag.

Parameters
tagsThe tags of kernels for which the residual is to be computed.

Definition at line 1708 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTags().

1709 {
1710  parallel_object_only();
1711 
1712  TIME_SECTION("computeResidualInternal", 3);
1713 
1714  residualSetup();
1715 
1716  const auto vector_tag_data = _fe_problem.getVectorTags(tags);
1717 
1718  // Residual contributions from UOs - for now this is used for ray tracing
1719  // and ray kernels that contribute to the residual (think line sources)
1720  std::vector<UserObject *> uos;
1722  .query()
1723  .condition<AttribSystem>("UserObject")
1724  .condition<AttribExecOns>(EXEC_PRE_KERNELS)
1725  .queryInto(uos);
1726  for (auto & uo : uos)
1727  uo->residualSetup();
1728  for (auto & uo : uos)
1729  {
1730  uo->initialize();
1731  uo->execute();
1732  uo->finalize();
1733  }
1734 
1735  // reinit scalar variables
1736  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
1738 
1739  // residual contributions from the domain
1740  PARALLEL_TRY
1741  {
1742  TIME_SECTION("Kernels", 3 /*, "Computing Kernels"*/);
1743 
1745 
1747  Threads::parallel_reduce(elem_range, cr);
1748 
1749  // We pass face information directly to FV residual objects for their evaluation. Consequently
1750  // we must make sure to do separate threaded loops for 1) undisplaced face information objects
1751  // and undisplaced residual objects and 2) displaced face information objects and displaced
1752  // residual objects
1754  if (_fe_problem.haveFV())
1755  {
1757  _fe_problem, this->number(), tags, /*on_displaced=*/false);
1759  Threads::parallel_reduce(faces, fvr);
1760  }
1762  displaced_problem && displaced_problem->haveFV())
1763  {
1765  _fe_problem, this->number(), tags, /*on_displaced=*/true);
1766  FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
1767  displaced_problem->mesh().ownedFaceInfoEnd());
1768  Threads::parallel_reduce(faces, fvr);
1769  }
1770 
1771  unsigned int n_threads = libMesh::n_threads();
1772  for (unsigned int i = 0; i < n_threads;
1773  i++) // Add any cached residuals that might be hanging around
1775  }
1776  PARALLEL_CATCH;
1777 
1778  // residual contributions from the scalar kernels
1779  PARALLEL_TRY
1780  {
1781  // do scalar kernels (not sure how to thread this)
1783  {
1784  TIME_SECTION("ScalarKernels", 3 /*, "Computing ScalarKernels"*/);
1785 
1786  MooseObjectWarehouse<ScalarKernelBase> * scalar_kernel_warehouse;
1787  // This code should be refactored once we can do tags for scalar
1788  // kernels
1789  // Should redo this based on Warehouse
1790  if (!tags.size() || tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL))
1791  scalar_kernel_warehouse = &_scalar_kernels;
1792  else if (tags.size() == 1)
1793  scalar_kernel_warehouse =
1794  &(_scalar_kernels.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1795  else
1796  // scalar_kernels is not threading
1797  scalar_kernel_warehouse = &(_scalar_kernels.getVectorTagsObjectWarehouse(tags, 0));
1798 
1799  bool have_scalar_contributions = false;
1800  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
1801  for (const auto & scalar_kernel : scalars)
1802  {
1803  scalar_kernel->reinit();
1804  const std::vector<dof_id_type> & dof_indices = scalar_kernel->variable().dofIndices();
1805  const DofMap & dof_map = scalar_kernel->variable().dofMap();
1806  const dof_id_type first_dof = dof_map.first_dof();
1807  const dof_id_type end_dof = dof_map.end_dof();
1808  for (dof_id_type dof : dof_indices)
1809  {
1810  if (dof >= first_dof && dof < end_dof)
1811  {
1812  scalar_kernel->computeResidual();
1813  have_scalar_contributions = true;
1814  break;
1815  }
1816  }
1817  }
1818  if (have_scalar_contributions)
1820  }
1821  }
1822  PARALLEL_CATCH;
1823 
1824  // residual contributions from Block NodalKernels
1825  PARALLEL_TRY
1826  {
1828  {
1829  TIME_SECTION("NodalKernels", 3 /*, "Computing NodalKernels"*/);
1830 
1832 
1834 
1835  if (range.begin() != range.end())
1836  {
1837  _fe_problem.reinitNode(*range.begin(), 0);
1838 
1839  Threads::parallel_reduce(range, cnk);
1840 
1841  unsigned int n_threads = libMesh::n_threads();
1842  for (unsigned int i = 0; i < n_threads;
1843  i++) // Add any cached residuals that might be hanging around
1845  }
1846  }
1847  }
1848  PARALLEL_CATCH;
1849 
1851  // We computed the volumetric objects. We can return now before we get into
1852  // any strongly enforced constraint conditions or penalty-type objects
1853  // (DGKernels, IntegratedBCs, InterfaceKernels, Constraints)
1854  return;
1855 
1856  // residual contributions from boundary NodalKernels
1857  PARALLEL_TRY
1858  {
1860  {
1861  TIME_SECTION("NodalKernelBCs", 3 /*, "Computing NodalKernelBCs"*/);
1862 
1864 
1866 
1867  Threads::parallel_reduce(bnd_node_range, cnk);
1868 
1869  unsigned int n_threads = libMesh::n_threads();
1870  for (unsigned int i = 0; i < n_threads;
1871  i++) // Add any cached residuals that might be hanging around
1873  }
1874  }
1875  PARALLEL_CATCH;
1876 
1878 
1879  if (_residual_copy.get())
1880  {
1881  _Re_non_time->close();
1883  }
1884 
1886  {
1887  _Re_non_time->close();
1890  }
1891 
1892  PARALLEL_TRY { computeDiracContributions(tags, false); }
1893  PARALLEL_CATCH;
1894 
1896  {
1897  PARALLEL_TRY { enforceNodalConstraintsResidual(*_Re_non_time); }
1898  PARALLEL_CATCH;
1899  _Re_non_time->close();
1900  }
1901 
1902  // Add in Residual contributions from other Constraints
1904  {
1905  PARALLEL_TRY
1906  {
1907  // Undisplaced Constraints
1909 
1910  // Displaced Constraints
1913 
1916  }
1917  PARALLEL_CATCH;
1918  _Re_non_time->close();
1919  }
1920 
1921  // Accumulate the occurrence of solution invalid warnings for the current iteration cumulative
1922  // counters
1925 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
dof_id_type end_dof(const processor_id_type proc) const
unsigned int n_threads()
bool hasActiveBlockObjects(THREAD_ID tid=0) const
std::shared_ptr< DisplacedProblem > displaced_problem
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
face_info_iterator ownedFaceInfoBegin()
Iterators to owned faceInfo objects.
Definition: MooseMesh.C:1510
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
void parallel_reduce(const Range &range, Body &body, const Partitioner &)
MooseObjectWarehouse< T > & getVectorTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object at least has one of the given vector ta...
const libMesh::ConstElemRange & getCurrentAlgebraicElementRange()
These are the element and nodes that contribute to the jacobian and residual for this local processor...
const libMesh::ConstNodeRange & getCurrentAlgebraicNodeRange()
void constraintResiduals(NumericVector< Number > &residual, bool displaced)
Add residual contributions from Constraints.
const Variable & variable(const unsigned int c) const override
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
const ConstBndNodeRange & getCurrentAlgebraicBndNodeRange()
void solutionInvalidAccumulation()
Pass the number of solution invalid occurrences from current iteration to cumulative counters...
void syncIteration()
Sync iteration counts to main processor.
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
void computeDiracContributions(const std::set< TagID > &tags, bool is_jacobian)
TheWarehouse & theWarehouse() const
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:172
void computingScalingResidual(bool computing_scaling_residual)
Setter for whether we&#39;re computing the scaling residual.
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition: SubProblem.C:172
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
virtual void close()=0
ConstraintWarehouse _constraints
Constraints storage object.
void computingNonlinearResid(bool computing_nonlinear_residual) final
Set whether or not the problem is in the process of computing the nonlinear residual.
const_iterator end() const
MooseApp & _app
Definition: SystemBase.h:988
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
std::unique_ptr< NumericVector< Number > > _residual_copy
Copy of the residual vector, or nullptr if a copy is not needed.
bool hasActiveObjects(THREAD_ID tid=0) const
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
const_iterator begin() const
virtual MooseMesh & mesh() override
virtual unsigned int numVectorTags(const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const
The total number of tags, which can be limited to the tag type.
Definition: SubProblem.C:195
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...
const ExecFlagType EXEC_PRE_KERNELS
Definition: Moose.C:56
void mortarConstraints(Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Do mortar constraint residual/jacobian computations.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:284
face_info_iterator ownedFaceInfoEnd()
Definition: MooseMesh.C:1519
bool _has_constraints
Whether or not this system has any Constraints.
dof_id_type first_dof(const processor_id_type proc) const
void enforceNodalConstraintsResidual(NumericVector< Number > &residual)
Enforce nodal constraints.
virtual void addResidualScalar(const THREAD_ID tid=0)
virtual void addCachedResidual(const THREAD_ID tid) override
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
virtual void residualEnd(THREAD_ID tid=0) const
uint8_t dof_id_type
virtual void residualSetup() override
virtual void localize(std::vector< T > &v_local) const=0

◆ computeResidualTag()

void NonlinearSystemBase::computeResidualTag ( NumericVector< Number > &  residual,
TagID  tag_id 
)
inherited

Computes residual for a given tag.

Parameters
residualResidual is formed in here
thetag of kernels for which the residual is to be computed.

Definition at line 766 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidual(), and CrankNicolson::init().

767 {
768  _nl_vector_tags.clear();
769  _nl_vector_tags.insert(tag_id);
771 
773 
775 
777 }
std::set< TagID > _nl_vector_tags
Vector tags to temporarily store all tags associated with the current system.
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:973
void computeResidualTags(const std::set< TagID > &tags)
Form multiple tag-associated residual vectors for all the given tags.
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
TagID residualVectorTag() const override

◆ computeResidualTags()

void NonlinearSystemBase::computeResidualTags ( const std::set< TagID > &  tags)
inherited

Form multiple tag-associated residual vectors for all the given tags.

Definition at line 788 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTag(), and FEProblemBase::computeResidualTags().

789 {
790  parallel_object_only();
791 
792  TIME_SECTION("nl::computeResidualTags", 5);
793 
796 
797  bool required_residual = tags.find(residualVectorTag()) == tags.end() ? false : true;
798 
800 
801  // not suppose to do anythin on matrix
803 
805 
806  for (const auto & numeric_vec : _vecs_to_zero_for_residual)
807  if (hasVector(numeric_vec))
808  {
809  NumericVector<Number> & vec = getVector(numeric_vec);
810  vec.close();
811  vec.zero();
812  }
813 
814  try
815  {
816  zeroTaggedVectors(tags);
818  closeTaggedVectors(tags);
819 
820  if (required_residual)
821  {
822  auto & residual = getVector(residualVectorTag());
823  if (!_time_integrators.empty())
824  {
825  for (auto & ti : _time_integrators)
826  ti->postResidual(residual);
827  }
828  else
829  residual += *_Re_non_time;
830  residual.close();
831  }
833  // We don't want to do nodal bcs or anything else
834  return;
835 
836  computeNodalBCs(tags);
837  closeTaggedVectors(tags);
838 
839  // If we are debugging residuals we need one more assignment to have the ghosted copy up to
840  // date
841  if (_need_residual_ghosted && _debugging_residuals && required_residual)
842  {
843  auto & residual = getVector(residualVectorTag());
844 
845  *_residual_ghosted = residual;
847  }
848  // Need to close and update the aux system in case residuals were saved to it.
851  if (hasSaveIn())
853  }
854  catch (MooseException & e)
855  {
856  // The buck stops here, we have already handled the exception by
857  // calling stopSolve(), it is now up to PETSc to return a
858  // "diverged" reason during the next solve.
859  }
860 
861  // not supposed to do anything on matrix
863 
865 }
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
Definition: SystemBase.h:1049
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition: SystemBase.C:693
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:916
bool _debugging_residuals
true if debugging residuals
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
NumericVector< Number > & solution()
Definition: SystemBase.h:196
void setCurrentlyComputingResidual(bool currently_computing_residual) final
Set whether or not the problem is in the process of computing the residual.
bool _has_nodalbc_save_in
If there is a nodal BC having save_in.
Scope guard for starting and stopping Floating Point Exception Trapping.
virtual void zero()=0
void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:1235
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
virtual void activateAllMatrixTags()
Make all existing matrices active.
Definition: SystemBase.C:1123
virtual void deactivateAllMatrixTags()
Make matrices inactive.
Definition: SystemBase.C:1111
void setCurrentNonlinearSystem(const unsigned int nl_sys_num)
void computingScalingResidual(bool computing_scaling_residual)
Setter for whether we&#39;re computing the scaling residual.
std::vector< std::string > _vecs_to_zero_for_residual
vectors that will be zeroed before a residual computation
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
AuxiliarySystem & getAuxiliarySystem()
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition: SystemBase.C:667
void computeResidualInternal(const std::set< TagID > &tags)
Compute the residual for a given tag.
virtual void close()=0
TagID residualVectorTag() const override
MooseApp & _app
Definition: SystemBase.h:988
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
Provides a way for users to bail out of the current solve.
unsigned int _n_residual_evaluations
Total number of residual evaluations that have been performed.
bool hasSaveIn() const
Weather or not the nonlinear system has save-ins.
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
void computeNodalBCs(NumericVector< Number > &residual)
Enforces nodal boundary conditions.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:925

◆ computeScalarKernelsJacobians()

void NonlinearSystemBase::computeScalarKernelsJacobians ( const std::set< TagID > &  tags)
protectedinherited

Definition at line 2697 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

2698 {
2699  MooseObjectWarehouse<ScalarKernelBase> * scalar_kernel_warehouse;
2700 
2701  if (!tags.size() || tags.size() == _fe_problem.numMatrixTags())
2702  scalar_kernel_warehouse = &_scalar_kernels;
2703  else if (tags.size() == 1)
2704  scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2705  else
2706  scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagsObjectWarehouse(tags, 0));
2707 
2708  // Compute the diagonal block for scalar variables
2709  if (scalar_kernel_warehouse->hasActiveObjects())
2710  {
2711  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
2712 
2713  _fe_problem.reinitScalars(/*tid=*/0);
2714 
2715  _fe_problem.reinitOffDiagScalars(/*_tid*/ 0);
2716 
2717  bool have_scalar_contributions = false;
2718  for (const auto & kernel : scalars)
2719  {
2720  if (!kernel->computesJacobian())
2721  continue;
2722 
2723  kernel->reinit();
2724  const std::vector<dof_id_type> & dof_indices = kernel->variable().dofIndices();
2725  const DofMap & dof_map = kernel->variable().dofMap();
2726  const dof_id_type first_dof = dof_map.first_dof();
2727  const dof_id_type end_dof = dof_map.end_dof();
2728  for (dof_id_type dof : dof_indices)
2729  {
2730  if (dof >= first_dof && dof < end_dof)
2731  {
2732  kernel->computeJacobian();
2733  _fe_problem.addJacobianOffDiagScalar(kernel->variable().number());
2734  have_scalar_contributions = true;
2735  break;
2736  }
2737  }
2738  }
2739 
2740  if (have_scalar_contributions)
2742  }
2743 }
dof_id_type end_dof(const processor_id_type proc) const
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
virtual void addJacobianOffDiagScalar(unsigned int ivar, const THREAD_ID tid=0)
const Variable & variable(const unsigned int c) const override
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
MooseObjectWarehouse< T > & getMatrixTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given matrix tag...
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:248
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< T > & getMatrixTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has one of the given matrix tags...
dof_id_type first_dof(const processor_id_type proc) const
virtual void reinitOffDiagScalars(const THREAD_ID tid) override
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
uint8_t dof_id_type
virtual void addJacobianScalar(const THREAD_ID tid=0)

◆ computeScaling()

bool NonlinearSystemBase::computeScaling ( )
inherited

Method used to obtain scaling factors for variables.

Returns
whether this method ran without exceptions

Definition at line 3873 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::preSolve().

3874 {
3876  return true;
3877 
3878  _console << "\nPerforming automatic scaling calculation\n" << std::endl;
3879 
3880  TIME_SECTION("computeScaling", 3, "Computing Automatic Scaling");
3881 
3882  // It's funny but we need to assemble our vector of scaling factors here otherwise we will be
3883  // applying scaling factors of 0 during Assembly of our scaling Jacobian
3885 
3886  // container for repeated access of element global dof indices
3887  std::vector<dof_id_type> dof_indices;
3888 
3889  if (!_auto_scaling_initd)
3890  setupScalingData();
3891 
3892  std::vector<Real> inverse_scaling_factors(_num_scaling_groups, 0);
3893  std::vector<Real> resid_inverse_scaling_factors(_num_scaling_groups, 0);
3894  std::vector<Real> jac_inverse_scaling_factors(_num_scaling_groups, 0);
3895  auto & dof_map = dofMap();
3896 
3897  // what types of scaling do we want?
3898  bool jac_scaling = _resid_vs_jac_scaling_param < 1. - TOLERANCE;
3899  bool resid_scaling = _resid_vs_jac_scaling_param > TOLERANCE;
3900 
3901  const NumericVector<Number> & scaling_residual = RHS();
3902 
3903  if (jac_scaling)
3904  {
3905  // if (!_auto_scaling_initd)
3906  // We need to reinit this when the number of dofs changes
3907  // but there is no good way to track that
3908  // In theory, it is the job of libmesh system to track this,
3909  // but this special matrix is not owned by libMesh system
3910  // Let us reinit eveytime since it is not expensive
3911  {
3912  auto init_vector = NumericVector<Number>::build(this->comm());
3913  init_vector->init(system().n_dofs(), system().n_local_dofs(), /*fast=*/false, PARALLEL);
3914 
3915  _scaling_matrix->clear();
3916  _scaling_matrix->init(*init_vector);
3917  }
3918 
3920  // Dispatch to derived classes to ensure that we use the correct matrix tag
3923  }
3924 
3925  if (resid_scaling)
3926  {
3929  // Dispatch to derived classes to ensure that we use the correct vector tag
3933  }
3934 
3935  // Did something bad happen during residual/Jacobian scaling computation?
3937  return false;
3938 
3939  auto examine_dof_indices = [this,
3940  jac_scaling,
3941  resid_scaling,
3942  &dof_map,
3943  &jac_inverse_scaling_factors,
3944  &resid_inverse_scaling_factors,
3945  &scaling_residual](const auto & dof_indices, const auto var_number)
3946  {
3947  for (auto dof_index : dof_indices)
3948  if (dof_map.local_index(dof_index))
3949  {
3950  if (jac_scaling)
3951  {
3952  // For now we will use the diagonal for determining scaling
3953  auto mat_value = (*_scaling_matrix)(dof_index, dof_index);
3954  auto & factor = jac_inverse_scaling_factors[_var_to_group_var[var_number]];
3955  factor = std::max(factor, std::abs(mat_value));
3956  }
3957  if (resid_scaling)
3958  {
3959  auto vec_value = scaling_residual(dof_index);
3960  auto & factor = resid_inverse_scaling_factors[_var_to_group_var[var_number]];
3961  factor = std::max(factor, std::abs(vec_value));
3962  }
3963  }
3964  };
3965 
3966  // Compute our scaling factors for the spatial field variables
3967  for (const auto & elem : _fe_problem.getCurrentAlgebraicElementRange())
3968  for (const auto i : make_range(system().n_vars()))
3970  {
3971  dof_map.dof_indices(elem, dof_indices, i);
3972  examine_dof_indices(dof_indices, i);
3973  }
3974 
3975  for (const auto i : make_range(system().n_vars()))
3976  if (_variable_autoscaled[i] && system().variable_type(i).family == SCALAR)
3977  {
3978  dof_map.SCALAR_dof_indices(dof_indices, i);
3979  examine_dof_indices(dof_indices, i);
3980  }
3981 
3982  if (resid_scaling)
3983  _communicator.max(resid_inverse_scaling_factors);
3984  if (jac_scaling)
3985  _communicator.max(jac_inverse_scaling_factors);
3986 
3987  if (jac_scaling && resid_scaling)
3988  for (MooseIndex(inverse_scaling_factors) i = 0; i < inverse_scaling_factors.size(); ++i)
3989  {
3990  // Be careful not to take log(0)
3991  if (!resid_inverse_scaling_factors[i])
3992  {
3993  if (!jac_inverse_scaling_factors[i])
3994  inverse_scaling_factors[i] = 1;
3995  else
3996  inverse_scaling_factors[i] = jac_inverse_scaling_factors[i];
3997  }
3998  else if (!jac_inverse_scaling_factors[i])
3999  // We know the resid is not zero
4000  inverse_scaling_factors[i] = resid_inverse_scaling_factors[i];
4001  else
4002  inverse_scaling_factors[i] =
4003  std::exp(_resid_vs_jac_scaling_param * std::log(resid_inverse_scaling_factors[i]) +
4004  (1 - _resid_vs_jac_scaling_param) * std::log(jac_inverse_scaling_factors[i]));
4005  }
4006  else if (jac_scaling)
4007  inverse_scaling_factors = jac_inverse_scaling_factors;
4008  else if (resid_scaling)
4009  inverse_scaling_factors = resid_inverse_scaling_factors;
4010  else
4011  mooseError("We shouldn't be calling this routine if we're not performing any scaling");
4012 
4013  // We have to make sure that our scaling values are not zero
4014  for (auto & scaling_factor : inverse_scaling_factors)
4015  if (scaling_factor == 0)
4016  scaling_factor = 1;
4017 
4018  // Now flatten the group scaling factors to the individual variable scaling factors
4019  std::vector<Real> flattened_inverse_scaling_factors(system().n_vars());
4020  for (const auto i : index_range(flattened_inverse_scaling_factors))
4021  flattened_inverse_scaling_factors[i] = inverse_scaling_factors[_var_to_group_var[i]];
4022 
4023  // Now set the scaling factors for the variables
4024  applyScalingFactors(flattened_inverse_scaling_factors);
4026  displaced_problem->systemBaseNonlinear(number()).applyScalingFactors(
4027  flattened_inverse_scaling_factors);
4028 
4029  _computed_scaling = true;
4030  return true;
4031 }
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
Definition: EigenADReal.h:42
std::vector< bool > _variable_autoscaled
Container to hold flag if variable is to participate in autoscaling.
std::shared_ptr< DisplacedProblem > displaced_problem
void applyScalingFactors(const std::vector< Real > &inverse_scaling_factors)
Applies scaling factors to the system&#39;s variables.
Definition: SystemBase.C:1487
SCALAR
auto exp(const T &)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
const Parallel::Communicator & comm() const
std::unique_ptr< libMesh::DiagonalMatrix< Number > > _scaling_matrix
A diagonal matrix used for computing scaling.
const Parallel::Communicator & _communicator
const libMesh::ConstElemRange & getCurrentAlgebraicElementRange()
These are the element and nodes that contribute to the jacobian and residual for this local processor...
std::size_t _num_scaling_groups
The number of scaling groups.
void computingScalingJacobian(bool computing_scaling_jacobian)
Setter for whether we&#39;re computing the scaling jacobian.
bool _compute_scaling_once
Whether the scaling factors should only be computed once at the beginning of the simulation through a...
auto max(const L &left, const R &right)
Real _resid_vs_jac_scaling_param
The param that indicates the weighting of the residual vs the Jacobian in determining variable scalin...
bool _auto_scaling_initd
Whether we&#39;ve initialized the automatic scaling data structures.
virtual void computeScalingResidual()=0
Compute a "residual" for automatic scaling purposes.
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
Definition: SystemBase.C:1155
std::unordered_map< unsigned int, unsigned int > _var_to_group_var
A map from variable index to group variable index and it&#39;s associated (inverse) scaling factor...
unsigned int n_vars
void computingScalingResidual(bool computing_scaling_residual)
Setter for whether we&#39;re computing the scaling residual.
virtual void computeScalingJacobian()=0
Compute a "Jacobian" for automatic scaling purposes.
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
void setupScalingData()
Setup group scaling containers.
auto log(const T &)
void computingNonlinearResid(bool computing_nonlinear_residual) final
Set whether or not the problem is in the process of computing the nonlinear residual.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual NumericVector< Number > & RHS()=0
const FEType & variable_type(const unsigned int i) const
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
void max(const T &r, T &o, Request &req) const
bool getFailNextNonlinearConvergenceCheck() const
Whether it will skip further residual evaluations and fail the next nonlinear convergence check(s) ...
IntRange< T > make_range(T beg, T end)
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
bool _computed_scaling
Flag used to indicate whether we have already computed the scaling Jacobian.
auto index_range(const T &sizable)
void assembleScalingVector()
Assemble the numeric vector of scaling factors such that it can be used during assembly of the system...
virtual libMesh::System & system() override
Get the reference to the libMesh system.

◆ computeScalingJacobian()

void DumpObjectsNonlinearSystem::computeScalingJacobian ( )
inlineoverrideprotectedvirtual

Compute a "Jacobian" for automatic scaling purposes.

Implements NonlinearSystemBase.

Definition at line 44 of file DumpObjectsNonlinearSystem.h.

44 {}

◆ computeScalingOnce() [1/2]

bool NonlinearSystemBase::computeScalingOnce ( ) const
inlineinherited

Definition at line 659 of file NonlinearSystemBase.h.

659 { return _compute_scaling_once; }
bool _compute_scaling_once
Whether the scaling factors should only be computed once at the beginning of the simulation through a...

◆ computeScalingOnce() [2/2]

void NonlinearSystemBase::computeScalingOnce ( bool  compute_scaling_once)
inlineinherited

Definition at line 660 of file NonlinearSystemBase.h.

661  {
662  _compute_scaling_once = compute_scaling_once;
663  }
bool _compute_scaling_once
Whether the scaling factors should only be computed once at the beginning of the simulation through a...

◆ computeScalingResidual()

void DumpObjectsNonlinearSystem::computeScalingResidual ( )
inlineoverrideprotectedvirtual

Compute a "residual" for automatic scaling purposes.

Implements NonlinearSystemBase.

Definition at line 45 of file DumpObjectsNonlinearSystem.h.

45 {}

◆ computeVariables()

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

Definition at line 869 of file SystemBase.h.

869 {}

◆ computingPreSMOResidual()

bool NonlinearSystemBase::computingPreSMOResidual ( )
inlineinherited

Returns true if this system is currently computing the pre-SMO residual for a solve.

Returns
Whether or not we are currently computing the pre-SMO residual.

Definition at line 97 of file NonlinearSystemBase.h.

◆ computingScalingJacobian()

bool SystemBase::computingScalingJacobian ( ) const
inherited

Whether we are computing an initial Jacobian for automatic variable scaling.

Definition at line 1544 of file SystemBase.C.

Referenced by Assembly::addJacobianBlock(), Assembly::addJacobianBlockNonlocal(), Kernel::computeJacobian(), VectorKernel::computeJacobian(), EigenKernel::computeJacobian(), and FEProblemBase::computeJacobianTags().

1545 {
1547 }
virtual bool computingScalingJacobian() const =0
Getter for whether we&#39;re computing the scaling jacobian.
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983

◆ constraintJacobians()

void NonlinearSystemBase::constraintJacobians ( const SparseMatrix< Number > &  jacobian_to_view,
bool  displaced 
)
inherited

Add jacobian contributions from Constraints.

Parameters
jacobianreference to a read-only view of the Jacobian matrix
displacedControls whether to do the displaced Constraints or non-displaced

Definition at line 2286 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

2288 {
2289  if (!hasMatrix(systemMatrixTag()))
2290  mooseError("A system matrix is required");
2291 
2292  auto & jacobian = getMatrix(systemMatrixTag());
2293 
2295  LibmeshPetscCall(MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2296  MAT_NEW_NONZERO_ALLOCATION_ERR,
2297  PETSC_FALSE));
2299  LibmeshPetscCall(MatSetOption(
2300  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE));
2301 
2302  std::vector<numeric_index_type> zero_rows;
2303 
2304  if (displaced)
2305  mooseAssert(_fe_problem.getDisplacedProblem(),
2306  "If we're calling this method with displaced = true, then we better well have a "
2307  "displaced problem");
2308  auto & subproblem = displaced ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
2309  : static_cast<SubProblem &>(_fe_problem);
2310  const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
2311 
2312  bool constraints_applied;
2314  constraints_applied = false;
2315  for (const auto & it : penetration_locators)
2316  {
2318  {
2319  // Reset the constraint_applied flag before each new constraint, as they need to be
2320  // assembled separately
2321  constraints_applied = false;
2322  }
2323  PenetrationLocator & pen_loc = *(it.second);
2324 
2325  std::vector<dof_id_type> & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
2326 
2327  BoundaryID secondary_boundary = pen_loc._secondary_boundary;
2328  BoundaryID primary_boundary = pen_loc._primary_boundary;
2329 
2330  zero_rows.clear();
2331  if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, displaced))
2332  {
2333  const auto & constraints =
2334  _constraints.getActiveNodeFaceConstraints(secondary_boundary, displaced);
2335 
2336  for (const auto & secondary_node_num : secondary_nodes)
2337  {
2338  Node & secondary_node = _mesh.nodeRef(secondary_node_num);
2339 
2340  if (secondary_node.processor_id() == processor_id())
2341  {
2342  if (pen_loc._penetration_info[secondary_node_num])
2343  {
2344  PenetrationInfo & info = *pen_loc._penetration_info[secondary_node_num];
2345 
2346  reinitNodeFace(secondary_node, secondary_boundary, info, displaced);
2348 
2349  for (const auto & nfc : constraints)
2350  {
2351  if (nfc->isExplicitConstraint())
2352  continue;
2353  // Return if this constraint does not correspond to the primary-secondary pair
2354  // prepared by the outer loops.
2355  // This continue statement is required when, e.g. one secondary surface constrains
2356  // more than one primary surface.
2357  if (nfc->secondaryBoundary() != secondary_boundary ||
2358  nfc->primaryBoundary() != primary_boundary)
2359  continue;
2360 
2361  nfc->_jacobian = &jacobian_to_view;
2362 
2363  if (nfc->shouldApply())
2364  {
2365  constraints_applied = true;
2366 
2367  nfc->prepareShapes(nfc->variable().number());
2368  nfc->prepareNeighborShapes(nfc->variable().number());
2369 
2370  nfc->computeJacobian();
2371 
2372  if (nfc->overwriteSecondaryJacobian())
2373  {
2374  // Add this variable's dof's row to be zeroed
2375  zero_rows.push_back(nfc->variable().nodalDofIndex());
2376  }
2377 
2378  std::vector<dof_id_type> secondary_dofs(1, nfc->variable().nodalDofIndex());
2379 
2380  // Assume that if the user is overwriting the secondary Jacobian, then they are
2381  // supplying Jacobians that do not correspond to their other physics
2382  // (e.g. Kernels), hence we should not apply a scalingFactor that is normally
2383  // based on the order of their other physics (e.g. Kernels)
2384  Real scaling_factor =
2385  nfc->overwriteSecondaryJacobian() ? 1. : nfc->variable().scalingFactor();
2386 
2387  // Cache the jacobian block for the secondary side
2388  nfc->addJacobian(_fe_problem.assembly(0, number()),
2389  nfc->_Kee,
2390  secondary_dofs,
2391  nfc->_connected_dof_indices,
2392  scaling_factor);
2393 
2394  // Cache Ken, Kne, Knn
2395  if (nfc->addCouplingEntriesToJacobian())
2396  {
2397  // Make sure we use a proper scaling factor (e.g. don't use an interior scaling
2398  // factor when we're overwriting secondary stuff)
2399  nfc->addJacobian(_fe_problem.assembly(0, number()),
2400  nfc->_Ken,
2401  secondary_dofs,
2402  nfc->primaryVariable().dofIndicesNeighbor(),
2403  scaling_factor);
2404 
2405  // Use _connected_dof_indices to get all the correct columns
2406  nfc->addJacobian(_fe_problem.assembly(0, number()),
2407  nfc->_Kne,
2408  nfc->primaryVariable().dofIndicesNeighbor(),
2409  nfc->_connected_dof_indices,
2410  nfc->primaryVariable().scalingFactor());
2411 
2412  // We've handled Ken and Kne, finally handle Knn
2414  }
2415 
2416  // Do the off-diagonals next
2417  const std::vector<MooseVariableFEBase *> coupled_vars = nfc->getCoupledMooseVars();
2418  for (const auto & jvar : coupled_vars)
2419  {
2420  // Only compute jacobians for nonlinear variables
2421  if (jvar->kind() != Moose::VAR_SOLVER)
2422  continue;
2423 
2424  // Only compute Jacobian entries if this coupling is being used by the
2425  // preconditioner
2426  if (nfc->variable().number() == jvar->number() ||
2428  nfc->variable().number(), jvar->number(), this->number()))
2429  continue;
2430 
2431  // Need to zero out the matrices first
2433 
2434  nfc->prepareShapes(nfc->variable().number());
2435  nfc->prepareNeighborShapes(jvar->number());
2436 
2437  nfc->computeOffDiagJacobian(jvar->number());
2438 
2439  // Cache the jacobian block for the secondary side
2440  nfc->addJacobian(_fe_problem.assembly(0, number()),
2441  nfc->_Kee,
2442  secondary_dofs,
2443  nfc->_connected_dof_indices,
2444  scaling_factor);
2445 
2446  // Cache Ken, Kne, Knn
2447  if (nfc->addCouplingEntriesToJacobian())
2448  {
2449  // Make sure we use a proper scaling factor (e.g. don't use an interior scaling
2450  // factor when we're overwriting secondary stuff)
2451  nfc->addJacobian(_fe_problem.assembly(0, number()),
2452  nfc->_Ken,
2453  secondary_dofs,
2454  jvar->dofIndicesNeighbor(),
2455  scaling_factor);
2456 
2457  // Use _connected_dof_indices to get all the correct columns
2458  nfc->addJacobian(_fe_problem.assembly(0, number()),
2459  nfc->_Kne,
2460  nfc->variable().dofIndicesNeighbor(),
2461  nfc->_connected_dof_indices,
2462  nfc->variable().scalingFactor());
2463 
2464  // We've handled Ken and Kne, finally handle Knn
2466  }
2467  }
2468  }
2469  }
2470  }
2471  }
2472  }
2473  }
2475  {
2476  // See if constraints were applied anywhere
2477  _communicator.max(constraints_applied);
2478 
2479  if (constraints_applied)
2480  {
2481  LibmeshPetscCall(MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2482  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2483  PETSC_TRUE));
2484 
2485  jacobian.close();
2486  jacobian.zero_rows(zero_rows, 0.0);
2487  jacobian.close();
2489  jacobian.close();
2490  }
2491  }
2492  }
2494  {
2495  // See if constraints were applied anywhere
2496  _communicator.max(constraints_applied);
2497 
2498  if (constraints_applied)
2499  {
2500  LibmeshPetscCall(MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2501  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2502  PETSC_TRUE));
2503 
2504  jacobian.close();
2505  jacobian.zero_rows(zero_rows, 0.0);
2506  jacobian.close();
2508  jacobian.close();
2509  }
2510  }
2511 
2512  THREAD_ID tid = 0;
2513  // go over element-element constraint interface
2514  const auto & element_pair_locators = subproblem.geomSearchData()._element_pair_locators;
2515  for (const auto & it : element_pair_locators)
2516  {
2517  ElementPairLocator & elem_pair_loc = *(it.second);
2518 
2519  if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
2520  {
2521  // ElemElemConstraint objects
2522  const auto & _element_constraints =
2523  _constraints.getActiveElemElemConstraints(it.first, displaced);
2524 
2525  // go over pair elements
2526  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
2527  elem_pair_loc.getElemPairs();
2528  for (const auto & pr : elem_pairs)
2529  {
2530  const Elem * elem1 = pr.first;
2531  const Elem * elem2 = pr.second;
2532 
2533  if (elem1->processor_id() != processor_id())
2534  continue;
2535 
2536  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
2537 
2538  // for each element process constraints on the
2539  for (const auto & ec : _element_constraints)
2540  {
2541  _fe_problem.setCurrentSubdomainID(elem1, tid);
2542  subproblem.reinitElemPhys(elem1, info._elem1_constraint_q_point, tid);
2543  _fe_problem.setNeighborSubdomainID(elem2, tid);
2544  subproblem.reinitNeighborPhys(elem2, info._elem2_constraint_q_point, tid);
2545 
2546  ec->prepareShapes(ec->variable().number());
2547  ec->prepareNeighborShapes(ec->variable().number());
2548 
2549  ec->reinit(info);
2550  ec->computeJacobian();
2553  }
2555  }
2556  }
2557  }
2558 
2559  // go over NodeElemConstraints
2560  std::set<dof_id_type> unique_secondary_node_ids;
2561  constraints_applied = false;
2562  for (const auto & secondary_id : _mesh.meshSubdomains())
2563  {
2564  for (const auto & primary_id : _mesh.meshSubdomains())
2565  {
2566  if (_constraints.hasActiveNodeElemConstraints(secondary_id, primary_id, displaced))
2567  {
2568  const auto & constraints =
2569  _constraints.getActiveNodeElemConstraints(secondary_id, primary_id, displaced);
2570 
2571  // get unique set of ids of all nodes on current block
2572  unique_secondary_node_ids.clear();
2573  const MeshBase & meshhelper = _mesh.getMesh();
2574  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
2575  meshhelper.active_subdomain_elements_end(secondary_id)))
2576  {
2577  for (auto & n : elem->node_ref_range())
2578  unique_secondary_node_ids.insert(n.id());
2579  }
2580 
2581  for (auto secondary_node_id : unique_secondary_node_ids)
2582  {
2583  const Node & secondary_node = _mesh.nodeRef(secondary_node_id);
2584  // check if secondary node is on current processor
2585  if (secondary_node.processor_id() == processor_id())
2586  {
2587  // This reinits the variables that exist on the secondary node
2588  _fe_problem.reinitNodeFace(&secondary_node, secondary_id, 0);
2589 
2590  // This will set aside residual and jacobian space for the variables that have dofs
2591  // on the secondary node
2594 
2595  for (const auto & nec : constraints)
2596  {
2597  if (nec->shouldApply())
2598  {
2599  constraints_applied = true;
2600 
2601  nec->_jacobian = &jacobian_to_view;
2602  nec->prepareShapes(nec->variable().number());
2603  nec->prepareNeighborShapes(nec->variable().number());
2604 
2605  nec->computeJacobian();
2606 
2607  if (nec->overwriteSecondaryJacobian())
2608  {
2609  // Add this variable's dof's row to be zeroed
2610  zero_rows.push_back(nec->variable().nodalDofIndex());
2611  }
2612 
2613  std::vector<dof_id_type> secondary_dofs(1, nec->variable().nodalDofIndex());
2614 
2615  // Cache the jacobian block for the secondary side
2616  nec->addJacobian(_fe_problem.assembly(0, number()),
2617  nec->_Kee,
2618  secondary_dofs,
2619  nec->_connected_dof_indices,
2620  nec->variable().scalingFactor());
2621 
2622  // Cache the jacobian block for the primary side
2623  nec->addJacobian(_fe_problem.assembly(0, number()),
2624  nec->_Kne,
2625  nec->primaryVariable().dofIndicesNeighbor(),
2626  nec->_connected_dof_indices,
2627  nec->primaryVariable().scalingFactor());
2628 
2631 
2632  // Do the off-diagonals next
2633  const std::vector<MooseVariableFEBase *> coupled_vars = nec->getCoupledMooseVars();
2634  for (const auto & jvar : coupled_vars)
2635  {
2636  // Only compute jacobians for nonlinear variables
2637  if (jvar->kind() != Moose::VAR_SOLVER)
2638  continue;
2639 
2640  // Only compute Jacobian entries if this coupling is being used by the
2641  // preconditioner
2642  if (nec->variable().number() == jvar->number() ||
2644  nec->variable().number(), jvar->number(), this->number()))
2645  continue;
2646 
2647  // Need to zero out the matrices first
2649 
2650  nec->prepareShapes(nec->variable().number());
2651  nec->prepareNeighborShapes(jvar->number());
2652 
2653  nec->computeOffDiagJacobian(jvar->number());
2654 
2655  // Cache the jacobian block for the secondary side
2656  nec->addJacobian(_fe_problem.assembly(0, number()),
2657  nec->_Kee,
2658  secondary_dofs,
2659  nec->_connected_dof_indices,
2660  nec->variable().scalingFactor());
2661 
2662  // Cache the jacobian block for the primary side
2663  nec->addJacobian(_fe_problem.assembly(0, number()),
2664  nec->_Kne,
2665  nec->variable().dofIndicesNeighbor(),
2666  nec->_connected_dof_indices,
2667  nec->variable().scalingFactor());
2668 
2671  }
2672  }
2673  }
2674  }
2675  }
2676  }
2677  }
2678  }
2679  // See if constraints were applied anywhere
2680  _communicator.max(constraints_applied);
2681 
2682  if (constraints_applied)
2683  {
2684  LibmeshPetscCall(MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2685  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2686  PETSC_TRUE));
2687 
2688  jacobian.close();
2689  jacobian.zero_rows(zero_rows, 0.0);
2690  jacobian.close();
2692  jacobian.close();
2693  }
2694 }
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
std::map< std::pair< BoundaryID, BoundaryID >, PenetrationLocator * > _penetration_locators
BoundaryID _secondary_boundary
bool _assemble_constraints_separately
Whether or not to assemble the residual and Jacobian after the application of each constraint...
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
MPI_Info info
bool areCoupled(const unsigned int ivar, const unsigned int jvar, const unsigned int nl_sys_num) const
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
Data structure used to hold penetration information.
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem *> elem_pair) const
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
const Parallel::Communicator & _communicator
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
bool hasActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
const std::vector< std::shared_ptr< NodeElemConstraintBase > > & getActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
virtual void cacheJacobianNeighbor(const THREAD_ID tid) override
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:834
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
std::vector< dof_id_type > _secondary_nodes
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3448
const ElementPairList & getElemPairs() const
boundary_id_type BoundaryID
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
SubProblem & subproblem()
Definition: SystemBase.h:101
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
This is the ElementPairLocator class.
This is the ElementPairInfo class.
std::map< BoundaryID, std::shared_ptr< ElementPairLocator > > _element_pair_locators
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
virtual GeometricSearchData & geomSearchData()=0
virtual void prepareAssembly(const THREAD_ID tid) override
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid)=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
MooseMesh & _mesh
Definition: SystemBase.h:991
void max(const T &r, T &o, Request &req) const
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1016
bool hasActiveElemElemConstraints(const InterfaceID interface_id, bool displaced) const
void reinitNodeFace(const Node &secondary_node, const BoundaryID secondary_boundary, const PenetrationInfo &info, const bool displaced)
Reinitialize quantities such as variables, residuals, Jacobians, materials for node-face constraints...
bool ignoreZerosInJacobian() const
Will return true if zeros in the Jacobian are to be dropped from the sparsity pattern.
processor_id_type processor_id() const
const std::vector< std::shared_ptr< ElemElemConstraint > > & getActiveElemElemConstraints(InterfaceID interface_id, bool displaced) const
virtual void cacheJacobian(const THREAD_ID tid) override
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
virtual void reinitOffDiagScalars(const THREAD_ID tid) override
processor_id_type processor_id() const
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override
BoundaryID _primary_boundary
unsigned int THREAD_ID
Definition: MooseTypes.h:209
NearestNodeLocator & _nearest_node
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:3171
virtual void addCachedJacobian(const THREAD_ID tid) override

◆ constraintResiduals()

void NonlinearSystemBase::constraintResiduals ( NumericVector< Number > &  residual,
bool  displaced 
)
inherited

Add residual contributions from Constraints.

Parameters
residual- reference to the residual vector where constraint contributions will be computed
displacedControls whether to do the displaced Constraints or non-displaced

Definition at line 1313 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualInternal().

1314 {
1315  // Make sure the residual is in a good state
1316  residual.close();
1317 
1318  if (displaced)
1319  mooseAssert(_fe_problem.getDisplacedProblem(),
1320  "If we're calling this method with displaced = true, then we better well have a "
1321  "displaced problem");
1322  auto & subproblem = displaced ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
1323  : static_cast<SubProblem &>(_fe_problem);
1324  const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
1325 
1326  bool constraints_applied;
1327  bool residual_has_inserted_values = false;
1329  constraints_applied = false;
1330  for (const auto & it : penetration_locators)
1331  {
1333  {
1334  // Reset the constraint_applied flag before each new constraint, as they need to be
1335  // assembled separately
1336  constraints_applied = false;
1337  }
1338  PenetrationLocator & pen_loc = *(it.second);
1339 
1340  std::vector<dof_id_type> & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
1341 
1342  BoundaryID secondary_boundary = pen_loc._secondary_boundary;
1343  BoundaryID primary_boundary = pen_loc._primary_boundary;
1344 
1345  bool has_writable_variables(false);
1346 
1347  if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, displaced))
1348  {
1349  const auto & constraints =
1350  _constraints.getActiveNodeFaceConstraints(secondary_boundary, displaced);
1351 
1352  for (unsigned int i = 0; i < secondary_nodes.size(); i++)
1353  {
1354  dof_id_type secondary_node_num = secondary_nodes[i];
1355  Node & secondary_node = _mesh.nodeRef(secondary_node_num);
1356 
1357  if (secondary_node.processor_id() == processor_id())
1358  {
1359  if (pen_loc._penetration_info[secondary_node_num])
1360  {
1361  PenetrationInfo & info = *pen_loc._penetration_info[secondary_node_num];
1362 
1363  reinitNodeFace(secondary_node, secondary_boundary, info, displaced);
1364 
1365  for (const auto & nfc : constraints)
1366  {
1367  // Return if this constraint does not correspond to the primary-secondary pair
1368  // prepared by the outer loops.
1369  // This continue statement is required when, e.g. one secondary surface constrains
1370  // more than one primary surface.
1371  if (nfc->secondaryBoundary() != secondary_boundary ||
1372  nfc->primaryBoundary() != primary_boundary)
1373  continue;
1374 
1375  if (nfc->shouldApply())
1376  {
1377  constraints_applied = true;
1378  nfc->computeResidual();
1379 
1380  if (nfc->overwriteSecondaryResidual())
1381  {
1382  // The below will actually overwrite the residual for every single dof that
1383  // lives on the node. We definitely don't want to do that!
1384  // _fe_problem.setResidual(residual, 0);
1385 
1386  const auto & secondary_var = nfc->variable();
1387  const auto & secondary_dofs = secondary_var.dofIndices();
1388  mooseAssert(secondary_dofs.size() == secondary_var.count(),
1389  "We are on a node so there should only be one dof per variable (for "
1390  "an ArrayVariable we should have a number of dofs equal to the "
1391  "number of components");
1392 
1393  // Assume that if the user is overwriting the secondary residual, then they are
1394  // supplying residuals that do not correspond to their other physics
1395  // (e.g. Kernels), hence we should not apply a scalingFactor that is normally
1396  // based on the order of their other physics (e.g. Kernels)
1397  std::vector<Number> values = {nfc->secondaryResidual()};
1398  residual.insert(values, secondary_dofs);
1399  residual_has_inserted_values = true;
1400  }
1401  else
1404  }
1405  if (nfc->hasWritableCoupledVariables())
1406  {
1407  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1408  has_writable_variables = true;
1409  for (auto * var : nfc->getWritableCoupledVariables())
1410  {
1411  if (var->isNodalDefined())
1412  var->insert(_fe_problem.getAuxiliarySystem().solution());
1413  }
1414  }
1415  }
1416  }
1417  }
1418  }
1419  }
1420  _communicator.max(has_writable_variables);
1421 
1422  if (has_writable_variables)
1423  {
1424  // Explicit contact dynamic constraints write to auxiliary variables and update the old
1425  // displacement solution on the constraint boundaries. Close solutions and update system
1426  // accordingly.
1429  solutionOld().close();
1430  }
1431 
1433  {
1434  // Make sure that secondary contribution to primary are assembled, and ghosts have been
1435  // exchanged, as current primaries might become secondaries on next iteration and will need to
1436  // contribute their former secondaries' contributions to the future primaries. See if
1437  // constraints were applied anywhere
1438  _communicator.max(constraints_applied);
1439 
1440  if (constraints_applied)
1441  {
1442  // If any of the above constraints inserted values in the residual, it needs to be
1443  // assembled before adding the cached residuals below.
1444  _communicator.max(residual_has_inserted_values);
1445  if (residual_has_inserted_values)
1446  {
1447  residual.close();
1448  residual_has_inserted_values = false;
1449  }
1451  residual.close();
1452 
1454  *_residual_ghosted = residual;
1455  }
1456  }
1457  }
1459  {
1460  _communicator.max(constraints_applied);
1461 
1462  if (constraints_applied)
1463  {
1464  // If any of the above constraints inserted values in the residual, it needs to be assembled
1465  // before adding the cached residuals below.
1466  _communicator.max(residual_has_inserted_values);
1467  if (residual_has_inserted_values)
1468  residual.close();
1469 
1471  residual.close();
1472 
1474  *_residual_ghosted = residual;
1475  }
1476  }
1477 
1478  // go over element-element constraint interface
1479  THREAD_ID tid = 0;
1480  const auto & element_pair_locators = subproblem.geomSearchData()._element_pair_locators;
1481  for (const auto & it : element_pair_locators)
1482  {
1483  ElementPairLocator & elem_pair_loc = *(it.second);
1484 
1485  if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
1486  {
1487  // ElemElemConstraint objects
1488  const auto & _element_constraints =
1489  _constraints.getActiveElemElemConstraints(it.first, displaced);
1490 
1491  // go over pair elements
1492  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
1493  elem_pair_loc.getElemPairs();
1494  for (const auto & pr : elem_pairs)
1495  {
1496  const Elem * elem1 = pr.first;
1497  const Elem * elem2 = pr.second;
1498 
1499  if (elem1->processor_id() != processor_id())
1500  continue;
1501 
1502  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
1503 
1504  // for each element process constraints on the
1505  for (const auto & ec : _element_constraints)
1506  {
1507  _fe_problem.setCurrentSubdomainID(elem1, tid);
1508  subproblem.reinitElemPhys(elem1, info._elem1_constraint_q_point, tid);
1509  _fe_problem.setNeighborSubdomainID(elem2, tid);
1510  subproblem.reinitNeighborPhys(elem2, info._elem2_constraint_q_point, tid);
1511 
1512  ec->prepareShapes(ec->variable().number());
1513  ec->prepareNeighborShapes(ec->variable().number());
1514 
1515  ec->reinit(info);
1516  ec->computeResidual();
1519  }
1521  }
1522  }
1523  }
1524 
1525  // go over NodeElemConstraints
1526  std::set<dof_id_type> unique_secondary_node_ids;
1527 
1528  constraints_applied = false;
1529  residual_has_inserted_values = false;
1530  bool has_writable_variables = false;
1531  for (const auto & secondary_id : _mesh.meshSubdomains())
1532  {
1533  for (const auto & primary_id : _mesh.meshSubdomains())
1534  {
1535  if (_constraints.hasActiveNodeElemConstraints(secondary_id, primary_id, displaced))
1536  {
1537  const auto & constraints =
1538  _constraints.getActiveNodeElemConstraints(secondary_id, primary_id, displaced);
1539 
1540  // get unique set of ids of all nodes on current block
1541  unique_secondary_node_ids.clear();
1542  const MeshBase & meshhelper = _mesh.getMesh();
1543  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
1544  meshhelper.active_subdomain_elements_end(secondary_id)))
1545  {
1546  for (auto & n : elem->node_ref_range())
1547  unique_secondary_node_ids.insert(n.id());
1548  }
1549 
1550  for (auto secondary_node_id : unique_secondary_node_ids)
1551  {
1552  Node & secondary_node = _mesh.nodeRef(secondary_node_id);
1553  // check if secondary node is on current processor
1554  if (secondary_node.processor_id() == processor_id())
1555  {
1556  // This reinits the variables that exist on the secondary node
1557  _fe_problem.reinitNodeFace(&secondary_node, secondary_id, 0);
1558 
1559  // This will set aside residual and jacobian space for the variables that have dofs
1560  // on the secondary node
1562 
1563  for (const auto & nec : constraints)
1564  {
1565  if (nec->shouldApply())
1566  {
1567  constraints_applied = true;
1568  nec->computeResidual();
1569 
1570  if (nec->overwriteSecondaryResidual())
1571  {
1572  _fe_problem.setResidual(residual, 0);
1573  residual_has_inserted_values = true;
1574  }
1575  else
1578  }
1579  if (nec->hasWritableCoupledVariables())
1580  {
1581  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1582  has_writable_variables = true;
1583  for (auto * var : nec->getWritableCoupledVariables())
1584  {
1585  if (var->isNodalDefined())
1586  var->insert(_fe_problem.getAuxiliarySystem().solution());
1587  }
1588  }
1589  }
1591  }
1592  }
1593  }
1594  }
1595  }
1596  _communicator.max(constraints_applied);
1597 
1598  if (constraints_applied)
1599  {
1600  // If any of the above constraints inserted values in the residual, it needs to be assembled
1601  // before adding the cached residuals below.
1602  _communicator.max(residual_has_inserted_values);
1603  if (residual_has_inserted_values)
1604  residual.close();
1605 
1607  residual.close();
1608 
1610  *_residual_ghosted = residual;
1611  }
1612  _communicator.max(has_writable_variables);
1613 
1614  if (has_writable_variables)
1615  {
1616  // Explicit contact dynamic constraints write to auxiliary variables and update the old
1617  // displacement solution on the constraint boundaries. Close solutions and update system
1618  // accordingly.
1621  solutionOld().close();
1622  }
1623 
1624  // We may have additional tagged vectors that also need to be accumulated
1626 }
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
std::map< std::pair< BoundaryID, BoundaryID >, PenetrationLocator * > _penetration_locators
virtual void cacheResidualNeighbor(const THREAD_ID tid) override
BoundaryID _secondary_boundary
bool _assemble_constraints_separately
Whether or not to assemble the residual and Jacobian after the application of each constraint...
MPI_Info info
NumericVector< Number > & solution()
Definition: SystemBase.h:196
Data structure used to hold penetration information.
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem *> elem_pair) const
const Parallel::Communicator & _communicator
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
bool hasActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
const std::vector< std::shared_ptr< NodeElemConstraintBase > > & getActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:834
virtual void setResidual(NumericVector< libMesh::Number > &residual, const THREAD_ID tid) override
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
virtual void addCachedResidualDirectly(NumericVector< libMesh::Number > &residual, const THREAD_ID tid)
Allows for all the residual contributions that are currently cached to be added directly into the vec...
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
std::vector< dof_id_type > _secondary_nodes
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3448
const ElementPairList & getElemPairs() const
boundary_id_type BoundaryID
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
SubProblem & subproblem()
Definition: SystemBase.h:101
virtual void cacheResidual(const THREAD_ID tid) override
This is the ElementPairLocator class.
This is the ElementPairInfo class.
std::map< BoundaryID, std::shared_ptr< ElementPairLocator > > _element_pair_locators
virtual GeometricSearchData & geomSearchData()=0
AuxiliarySystem & getAuxiliarySystem()
virtual void prepareAssembly(const THREAD_ID tid) override
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
virtual void close()=0
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid)=0
virtual void update()
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
MooseMesh & _mesh
Definition: SystemBase.h:991
void max(const T &r, T &o, Request &req) const
bool hasActiveElemElemConstraints(const InterfaceID interface_id, bool displaced) const
void reinitNodeFace(const Node &secondary_node, const BoundaryID secondary_boundary, const PenetrationInfo &info, const bool displaced)
Reinitialize quantities such as variables, residuals, Jacobians, materials for node-face constraints...
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
virtual libMesh::System & system() override
Get the reference to the libMesh system.
NumericVector< Number > & solutionOld()
Definition: SystemBase.h:197
processor_id_type processor_id() const
const std::vector< std::shared_ptr< ElemElemConstraint > > & getActiveElemElemConstraints(InterfaceID interface_id, bool displaced) const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
processor_id_type processor_id() const
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override
virtual void addCachedResidual(const THREAD_ID tid) override
BoundaryID _primary_boundary
unsigned int THREAD_ID
Definition: MooseTypes.h:209
uint8_t dof_id_type
NearestNodeLocator & _nearest_node
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:3171

◆ containsTimeKernel()

bool NonlinearSystemBase::containsTimeKernel ( )
overridevirtualinherited

If the system has a kernel that corresponds to a time derivative.

Implements SolverSystem.

Definition at line 3726 of file NonlinearSystemBase.C.

Referenced by EigenExecutionerBase::checkIntegrity(), and Eigenvalue::checkIntegrity().

3727 {
3728  auto & time_kernels = _kernels.getVectorTagObjectWarehouse(timeVectorTag(), 0);
3729 
3730  return time_kernels.hasActiveObjects();
3731 }
MooseObjectTagWarehouse< KernelBase > _kernels
TagID timeVectorTag() const override
Ideally, we should not need this API.
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...

◆ converged()

virtual bool DumpObjectsNonlinearSystem::converged ( )
inlineoverridevirtual

Returns the convergence state.

Returns
true if converged, otherwise false

Implements SolverSystem.

Definition at line 32 of file DumpObjectsNonlinearSystem.h.

32 { return true; }

◆ copyOldSolutions()

void SystemBase::copyOldSolutions ( )
virtualinherited

Shifts the solutions backwards in time.

Definition at line 1278 of file SystemBase.C.

Referenced by SystemBase::copySolutionsBackwards(), and EigenExecutionerBase::inversePowerIteration().

1279 {
1280  // copy the solutions backward: current->old, old->older
1281  const auto states =
1282  _solution_states[static_cast<unsigned short>(Moose::SolutionIterationType::Time)].size();
1283  if (states > 1)
1284  for (unsigned int i = states - 1; i > 0; --i)
1285  solutionState(i) = solutionState(i - 1);
1286 
1287  if (solutionUDotOld())
1288  *solutionUDotOld() = *solutionUDot();
1289  if (solutionUDotDotOld())
1291 }
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).
Definition: SystemBase.C:1423
virtual NumericVector< Number > * solutionUDotDotOld()
Definition: SystemBase.h:264
virtual NumericVector< Number > * solutionUDot()
Definition: SystemBase.h:261
virtual NumericVector< Number > * solutionUDotOld()
Definition: SystemBase.h:263
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1084
virtual NumericVector< Number > * solutionUDotDot()
Definition: SystemBase.h:262

◆ copyPreviousFixedPointSolutions()

void SystemBase::copyPreviousFixedPointSolutions ( )
virtualinherited

Definition at line 1294 of file SystemBase.C.

Referenced by FixedPointSolve::solveStep().

1295 {
1296  const auto n_states =
1297  _solution_states[static_cast<unsigned short>(Moose::SolutionIterationType::FixedPoint)]
1298  .size();
1299  if (n_states > 1)
1300  for (unsigned int i = n_states - 1; i > 0; --i)
1303 }
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).
Definition: SystemBase.C:1423
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1084

◆ copyPreviousNonlinearSolutions()

void SystemBase::copyPreviousNonlinearSolutions ( )
virtualinherited

Shifts the solutions backwards in nonlinear iteration history.

Definition at line 1261 of file SystemBase.C.

Referenced by SystemBase::copySolutionsBackwards().

1262 {
1263  const auto states =
1264  _solution_states[static_cast<unsigned short>(Moose::SolutionIterationType::Nonlinear)].size();
1265  if (states > 1)
1266  for (unsigned int i = states - 1; i > 0; --i)
1269 
1270  if (solutionPreviousNewton())
1272 }
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
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).
Definition: SystemBase.C:1423
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1084
virtual const NumericVector< Number > * solutionPreviousNewton() const
Definition: SystemBase.C:1347

◆ copySolutionsBackwards()

void SystemBase::copySolutionsBackwards ( )
virtualinherited

Copy current solution into old and older.

Definition at line 1250 of file SystemBase.C.

1251 {
1252  system().update();
1253  copyOldSolutions();
1255 }
virtual void copyOldSolutions()
Shifts the solutions backwards in time.
Definition: SystemBase.C:1278
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual void copyPreviousNonlinearSolutions()
Shifts the solutions backwards in nonlinear iteration history.
Definition: SystemBase.C:1261
virtual void update()

◆ copyTimeIntegrators()

void SystemBase::copyTimeIntegrators ( const SystemBase other_sys)
inherited

Copy time integrators from another system.

Definition at line 1659 of file SystemBase.C.

1660 {
1662 }
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
Definition: SystemBase.h:1049

◆ copyVars()

void SystemBase::copyVars ( libMesh::ExodusII_IO io)
inherited

Definition at line 1175 of file SystemBase.C.

1176 {
1177  int n_steps = io.get_num_time_steps();
1178 
1179  bool did_copy = false;
1180  for (const auto & vci : _var_to_copy)
1181  {
1182  int timestep = -1;
1183 
1184  if (vci._timestep == "LATEST")
1185  // Use the last time step in the file from which to retrieve the solution
1186  timestep = n_steps;
1187  else
1188  {
1189  timestep = MooseUtils::convert<int>(vci._timestep);
1190  if (timestep > n_steps)
1191  mooseError("Invalid value passed as \"initial_from_file_timestep\". Expected \"LATEST\" or "
1192  "a valid integer between 1 and ",
1193  n_steps,
1194  " inclusive, received ",
1195  vci._timestep);
1196  }
1197 
1198  did_copy = true;
1199 
1200  if (hasVariable(vci._dest_name))
1201  {
1202  const auto & var = getVariable(0, vci._dest_name);
1203  if (var.isArray())
1204  {
1205  const auto & array_var = getFieldVariable<RealEigenVector>(0, vci._dest_name);
1206  for (MooseIndex(var.count()) i = 0; i < var.count(); ++i)
1207  {
1208  const auto & exodus_var = var.arrayVariableComponent(i);
1209  const auto & system_var = array_var.componentName(i);
1210  if (var.isNodal())
1211  io.copy_nodal_solution(system(), exodus_var, system_var, timestep);
1212  else
1213  io.copy_elemental_solution(system(), exodus_var, system_var, timestep);
1214  }
1215  }
1216  else
1217  {
1218  if (var.isNodal())
1219  io.copy_nodal_solution(system(), vci._dest_name, vci._source_name, timestep);
1220  else
1221  io.copy_elemental_solution(system(), vci._dest_name, vci._source_name, timestep);
1222  }
1223  }
1224  else if (hasScalarVariable(vci._dest_name))
1225  io.copy_scalar_solution(system(), {vci._dest_name}, {vci._source_name}, timestep);
1226  else
1227  mooseError("Unrecognized variable ", vci._dest_name, " in variables to copy.");
1228  }
1229 
1230  if (did_copy)
1231  solution().close();
1232 }
NumericVector< Number > & solution()
Definition: SystemBase.h:196
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:1040
int convert< int >(const std::string &str, bool throw_on_failure)
Definition: MooseUtils.C:1009
void copy_nodal_solution(System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
void copy_elemental_solution(System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition: SystemBase.C:843
virtual void close()=0
void copy_scalar_solution(System &system, std::vector< std::string > system_var_names, std::vector< std::string > exodus_var_names, unsigned int timestep=1)
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:90
virtual bool hasScalarVariable(const std::string &var_name) const
Definition: SystemBase.C:868

◆ currentSolution()

const NumericVector< Number > *const & SolverSystem::currentSolution ( ) const
inlinefinaloverridevirtualinherited

The solution vector that is currently being operated on.

This is typically a ghosted vector that comes in from the Nonlinear solver.

Implements SystemBase.

Definition at line 117 of file SolverSystem.h.

Referenced by FEProblemBase::computeDamping(), FEProblemBase::computeLinearSystemSys(), FEProblemBase::computeResidualL2Norm(), and AB2PredictorCorrector::step().

118 {
119  return _current_solution;
120 }
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:105

◆ customSetup()

void NonlinearSystemBase::customSetup ( const ExecFlagType exec_type)
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 370 of file NonlinearSystemBase.C.

371 {
372  SolverSystem::customSetup(exec_type);
373 
374  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
375  {
376  _kernels.customSetup(exec_type, tid);
377  _nodal_kernels.customSetup(exec_type, tid);
378  _dirac_kernels.customSetup(exec_type, tid);
379  if (_doing_dg)
380  _dg_kernels.customSetup(exec_type, tid);
381  _interface_kernels.customSetup(exec_type, tid);
382  _element_dampers.customSetup(exec_type, tid);
383  _nodal_dampers.customSetup(exec_type, tid);
384  _integrated_bcs.customSetup(exec_type, tid);
385 
386  if (_fe_problem.haveFV())
387  {
388  std::vector<FVFluxBC *> bcs;
390  .query()
391  .template condition<AttribSystem>("FVFluxBC")
392  .template condition<AttribThread>(tid)
393  .queryInto(bcs);
394 
395  std::vector<FVInterfaceKernel *> iks;
397  .query()
398  .template condition<AttribSystem>("FVInterfaceKernel")
399  .template condition<AttribThread>(tid)
400  .queryInto(iks);
401 
402  std::vector<FVFluxKernel *> kernels;
404  .query()
405  .template condition<AttribSystem>("FVFluxKernel")
406  .template condition<AttribThread>(tid)
407  .queryInto(kernels);
408 
409  for (auto * bc : bcs)
410  bc->customSetup(exec_type);
411  for (auto * ik : iks)
412  ik->customSetup(exec_type);
413  for (auto * kernel : kernels)
414  kernel->customSetup(exec_type);
415  }
416  }
417  _scalar_kernels.customSetup(exec_type);
418  _constraints.customSetup(exec_type);
419  _general_dampers.customSetup(exec_type);
420  _nodal_bcs.customSetup(exec_type);
421 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
std::vector< T * > & queryInto(std::vector< T *> &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
Definition: TheWarehouse.h:311
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
virtual void customSetup(const ExecFlagType &exec_type, THREAD_ID tid=0) const
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
bool _doing_dg
true if DG is active (optimization reasons)
TheWarehouse & theWarehouse() const
MooseObjectTagWarehouse< KernelBase > _kernels
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
virtual void customSetup(const ExecFlagType &exec_type)
Definition: SystemBase.C:1577
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ deactivateAllMatrixTags()

void SystemBase::deactivateAllMatrixTags ( )
virtualinherited

Make matrices inactive.

Definition at line 1111 of file SystemBase.C.

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

1112 {
1113  auto num_matrix_tags = _subproblem.numMatrixTags();
1114 
1115  _matrix_tag_active_flags.resize(num_matrix_tags);
1116 
1117  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
1118  _matrix_tag_active_flags[tag] = false;
1119  _active_tagged_matrices.clear();
1120 }
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...
Definition: SystemBase.h:1025
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:1027
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:248

◆ debuggingResiduals()

void NonlinearSystemBase::debuggingResiduals ( bool  state)
inlineinherited

Definition at line 553 of file NonlinearSystemBase.h.

553 { _debugging_residuals = state; }
bool _debugging_residuals
true if debugging residuals

◆ defaultMatrixTags()

virtual std::set<TagID> SystemBase::defaultMatrixTags ( ) const
inlinevirtualinherited

Get the default matrix tags associted with this system.

Reimplemented in NonlinearEigenSystem, and DisplacedSystem.

Definition at line 319 of file SystemBase.h.

Referenced by DisplacedSystem::defaultMatrixTags(), NonlinearEigenSystem::defaultMatrixTags(), and SystemBase::disassociateDefaultMatrixTags().

319 { return {systemMatrixTag()}; }
virtual TagID systemMatrixTag() const
Return the Matrix Tag ID for System.
Definition: SystemBase.h:297

◆ defaultVectorTags()

virtual std::set<TagID> SystemBase::defaultVectorTags ( ) const
inlinevirtualinherited

Get the default vector tags associated with this system.

Reimplemented in NonlinearEigenSystem, and DisplacedSystem.

Definition at line 312 of file SystemBase.h.

Referenced by DisplacedSystem::defaultVectorTags(), NonlinearEigenSystem::defaultVectorTags(), and SystemBase::disassociateDefaultVectorTags().

313  {
315  }
virtual TagID timeVectorTag() const
Ideally, we should not need this API.
Definition: SystemBase.h:292
virtual TagID nonTimeVectorTag() const
Definition: SystemBase.h:302
virtual TagID residualVectorTag() const
Definition: SystemBase.h:307

◆ destroyColoring()

void NonlinearSystemBase::destroyColoring ( )
inherited

Destroy the coloring object if it exists.

Definition at line 4107 of file NonlinearSystemBase.C.

Referenced by LStableDirk2::solve(), LStableDirk3::solve(), and LStableDirk4::solve().

4108 {
4109  if (matrixFromColoring())
4110  LibmeshPetscCall(MatFDColoringDestroy(&_fdcoloring));
4111 }
virtual bool matrixFromColoring() const
Whether a system matrix is formed from coloring.
Definition: SolverSystem.h:102

◆ disassociateDefaultMatrixTags()

void SystemBase::disassociateDefaultMatrixTags ( )
virtualinherited

Disassociate the matrices associated with the default matrix tags of this system.

Reimplemented in DisplacedSystem.

Definition at line 1102 of file SystemBase.C.

Referenced by DisplacedSystem::disassociateDefaultMatrixTags().

1103 {
1104  const auto tags = defaultMatrixTags();
1105  for (const auto tag : tags)
1106  if (_subproblem.matrixTagExists(tag))
1108 }
virtual void disassociateMatrixFromTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
Definition: SystemBase.C:1080
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
Definition: SystemBase.h:319
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:328

◆ disassociateDefaultVectorTags()

void SystemBase::disassociateDefaultVectorTags ( )
virtualinherited

Disassociate the vectors associated with the default vector tags of this system.

Reimplemented in DisplacedSystem.

Definition at line 1007 of file SystemBase.C.

Referenced by DisplacedSystem::disassociateDefaultVectorTags().

1008 {
1009  const auto tags = defaultVectorTags();
1010  for (const auto tag : tags)
1011  if (_subproblem.vectorTagExists(tag))
1013 }
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:201
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
Definition: SystemBase.h:312

◆ disassociateMatrixFromTag() [1/2]

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

Disassociate a matrix from a tag.

Reimplemented in DisplacedSystem.

Definition at line 1080 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeJacobian(), FEProblemBase::computeJacobianInternal(), FEProblemBase::computeJacobianTag(), FEProblemBase::computeLinearSystemSys(), FEProblemBase::computeResidualAndJacobian(), SystemBase::disassociateDefaultMatrixTags(), and DisplacedSystem::disassociateMatrixFromTag().

1081 {
1082  if (!_subproblem.matrixTagExists(tag))
1083  mooseError("Cannot disassociate matrix from tag ", tag, " because that tag does not exist");
1084  if (hasMatrix(tag) && &getMatrix(tag) != &matrix)
1085  mooseError("You can not disassociate a matrix from a tag which it was not associated to");
1086 
1088 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
virtual void disassociateMatrixFromTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
Definition: SystemBase.C:1080
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1016
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:328

◆ disassociateMatrixFromTag() [2/2]

void SystemBase::disassociateMatrixFromTag ( TagID  tag)
virtualinherited

Disassociate any matrix that is associated with a given tag.

Reimplemented in DisplacedSystem.

Definition at line 1091 of file SystemBase.C.

1092 {
1093  if (!_subproblem.matrixTagExists(tag))
1094  mooseError("Cannot disassociate matrix from tag ", tag, " because that tag does not exist");
1095 
1096  if (_tagged_matrices.size() < tag + 1)
1097  _tagged_matrices.resize(tag + 1);
1098  _tagged_matrices[tag] = nullptr;
1099 }
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:1023
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:328

◆ disassociateVectorFromTag() [1/2]

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

◆ disassociateVectorFromTag() [2/2]

void SystemBase::disassociateVectorFromTag ( TagID  tag)
virtualinherited

Disassociate any vector that is associated with a given tag.

Reimplemented in DisplacedSystem.

Definition at line 996 of file SystemBase.C.

997 {
998  if (!_subproblem.vectorTagExists(tag))
999  mooseError("Cannot disassociate vector from tag ", tag, " because that tag does not exist");
1000 
1001  if (_tagged_vectors.size() < tag + 1)
1002  _tagged_vectors.resize(tag + 1);
1003  _tagged_vectors[tag] = nullptr;
1004 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:201
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:1021

◆ dofMap() [1/2]

DofMap & SystemBase::dofMap ( )
virtualinherited

◆ dofMap() [2/2]

const DofMap & SystemBase::dofMap ( ) const
virtualinherited

Gets const reference to the dof map.

Definition at line 1161 of file SystemBase.C.

1162 {
1163  return system().get_dof_map();
1164 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
const DofMap & get_dof_map() const

◆ doingDG()

bool NonlinearSystemBase::doingDG ( ) const
inherited

Getter for _doing_dg.

Definition at line 3765 of file NonlinearSystemBase.C.

3766 {
3767  return _doing_dg;
3768 }
bool _doing_dg
true if DG is active (optimization reasons)

◆ duDotDotDu() [1/2]

virtual Number& SystemBase::duDotDotDu ( )
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 257 of file SystemBase.h.

Referenced by DisplacedSystem::duDotDotDu(), and MooseVariableScalar::reinit().

257 { return _du_dotdot_du; }
Real _du_dotdot_du
Definition: SystemBase.h:1018

◆ duDotDotDu() [2/2]

virtual const Number& SystemBase::duDotDotDu ( ) const
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 259 of file SystemBase.h.

259 { return _du_dotdot_du; }
Real _du_dotdot_du
Definition: SystemBase.h:1018

◆ duDotDu()

const Number & SystemBase::duDotDu ( unsigned int  var_num = 0) const
virtualinherited

Reimplemented in DisplacedSystem.

Definition at line 1693 of file SystemBase.C.

Referenced by DisplacedSystem::duDotDu(), and MooseVariableScalar::reinit().

1694 {
1695  return _du_dot_du[var_num];
1696 }
std::vector< Real > _du_dot_du
Derivative of time derivative of u with respect to uj.
Definition: SystemBase.h:1017

◆ duDotDus()

virtual std::vector<Number>& SystemBase::duDotDus ( )
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 256 of file SystemBase.h.

Referenced by DisplacedSystem::duDotDus().

256 { return _du_dot_du; }
std::vector< Real > _du_dot_du
Derivative of time derivative of u with respect to uj.
Definition: SystemBase.h:1017

◆ enforceNodalConstraintsJacobian()

void NonlinearSystemBase::enforceNodalConstraintsJacobian ( )
protectedinherited

Definition at line 1081 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

1082 {
1083  if (!hasMatrix(systemMatrixTag()))
1084  mooseError(" A system matrix is required");
1085 
1086  auto & jacobian = getMatrix(systemMatrixTag());
1087  THREAD_ID tid = 0; // constraints are going to be done single-threaded
1088 
1090  {
1091  const auto & ncs = _constraints.getActiveNodalConstraints();
1092  for (const auto & nc : ncs)
1093  {
1094  std::vector<dof_id_type> & secondary_node_ids = nc->getSecondaryNodeId();
1095  std::vector<dof_id_type> & primary_node_ids = nc->getPrimaryNodeId();
1096 
1097  if ((secondary_node_ids.size() > 0) && (primary_node_ids.size() > 0))
1098  {
1099  _fe_problem.reinitNodes(primary_node_ids, tid);
1100  _fe_problem.reinitNodesNeighbor(secondary_node_ids, tid);
1101  nc->computeJacobian(jacobian);
1102  }
1103  }
1105  }
1106 }
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
const std::vector< std::shared_ptr< NodalConstraint > > & getActiveNodalConstraints() const
Access methods for active objects.
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
bool hasActiveNodalConstraints() const
Deterimine if active objects exist.
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1016
unsigned int THREAD_ID
Definition: MooseTypes.h:209
virtual void addCachedJacobian(const THREAD_ID tid) override

◆ enforceNodalConstraintsResidual()

void NonlinearSystemBase::enforceNodalConstraintsResidual ( NumericVector< Number > &  residual)
protectedinherited

Enforce nodal constraints.

Definition at line 1056 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualInternal().

1057 {
1058  THREAD_ID tid = 0; // constraints are going to be done single-threaded
1059  residual.close();
1061  {
1062  const auto & ncs = _constraints.getActiveNodalConstraints();
1063  for (const auto & nc : ncs)
1064  {
1065  std::vector<dof_id_type> & secondary_node_ids = nc->getSecondaryNodeId();
1066  std::vector<dof_id_type> & primary_node_ids = nc->getPrimaryNodeId();
1067 
1068  if ((secondary_node_ids.size() > 0) && (primary_node_ids.size() > 0))
1069  {
1070  _fe_problem.reinitNodes(primary_node_ids, tid);
1071  _fe_problem.reinitNodesNeighbor(secondary_node_ids, tid);
1072  nc->computeResidual(residual);
1073  }
1074  }
1075  _fe_problem.addCachedResidualDirectly(residual, tid);
1076  residual.close();
1077  }
1078 }
const std::vector< std::shared_ptr< NodalConstraint > > & getActiveNodalConstraints() const
Access methods for active objects.
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
bool hasActiveNodalConstraints() const
Deterimine if active objects exist.
virtual void addCachedResidualDirectly(NumericVector< libMesh::Number > &residual, const THREAD_ID tid)
Allows for all the residual contributions that are currently cached to be added directly into the vec...
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
virtual void close()=0
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ feProblem() [1/2]

FEProblemBase& SystemBase::feProblem ( )
inlineinherited

Definition at line 103 of file SystemBase.h.

Referenced by DMMooseGetEmbedding_Private(), and DMSetUp_Moose_Pre().

103 { return _fe_problem; }
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986

◆ feProblem() [2/2]

const FEProblemBase& SystemBase::feProblem ( ) const
inlineinherited

Definition at line 104 of file SystemBase.h.

104 { return _fe_problem; }
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986

◆ finalNonlinearResidual()

Real NonlinearSystemBase::finalNonlinearResidual ( ) const
inlineinherited

Return the final nonlinear residual.

Definition at line 539 of file NonlinearSystemBase.h.

539 { return _final_residual; }

◆ flushTaggedMatrices()

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

flushes all matrices associated to tags.

Flush assembles the matrix but doesn't shrink memory allocation

Definition at line 1060 of file SystemBase.C.

1061 {
1062  for (auto tag : tags)
1063  if (hasMatrix(tag))
1064  getMatrix(tag).flush();
1065 }
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
virtual void flush()
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1016

◆ getActualFieldVariable() [1/2]

template<typename T >
MooseVariableField< T > & SystemBase::getActualFieldVariable ( THREAD_ID  tid,
const std::string &  var_name 
)
inherited

Returns a field variable pointer - this includes finite volume variables.

Definition at line 118 of file SystemBase.C.

Referenced by BoundsBase::BoundsBase(), Assembly::copyFaceShapes(), Assembly::copyNeighborShapes(), and Assembly::copyShapes().

119 {
120  return *_vars[tid].getActualFieldVariable<T>(var_name);
121 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ getActualFieldVariable() [2/2]

template<typename T >
MooseVariableField< T > & SystemBase::getActualFieldVariable ( THREAD_ID  tid,
unsigned int  var_number 
)
inherited

Returns a field variable pointer - this includes finite volume variables.

Definition at line 139 of file SystemBase.C.

140 {
141  return *_vars[tid].getActualFieldVariable<T>(var_number);
142 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ getConstraintWarehouse()

const ConstraintWarehouse& NonlinearSystemBase::getConstraintWarehouse ( ) const
inlineinherited

Definition at line 613 of file NonlinearSystemBase.h.

613 { return _constraints; }
ConstraintWarehouse _constraints
Constraints storage object.

◆ getCurrentNonlinearIterationNumber()

virtual unsigned int DumpObjectsNonlinearSystem::getCurrentNonlinearIterationNumber ( )
inlineoverridevirtual

Implements NonlinearSystemBase.

Definition at line 36 of file DumpObjectsNonlinearSystem.h.

36 { return 0; }

◆ getDGKernelWarehouse()

MooseObjectTagWarehouse<DGKernelBase>& NonlinearSystemBase::getDGKernelWarehouse ( )
inlineinherited

Definition at line 589 of file NonlinearSystemBase.h.

Referenced by ExplicitTimeIntegrator::initialSetup().

589 { return _dg_kernels; }
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels

◆ getDiracKernelWarehouse()

MooseObjectTagWarehouse<DiracKernelBase>& NonlinearSystemBase::getDiracKernelWarehouse ( )
inlineinherited

Definition at line 594 of file NonlinearSystemBase.h.

594 { return _dirac_kernels; }
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.

◆ getElementDamperWarehouse()

const MooseObjectWarehouse<ElementDamper>& NonlinearSystemBase::getElementDamperWarehouse ( ) const
inlineinherited

Definition at line 605 of file NonlinearSystemBase.h.

Referenced by ComputeElemDampingThread::onElement(), and ComputeElemDampingThread::printGeneralExecutionInformation().

606  {
607  return _element_dampers;
608  }
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.

◆ getFieldSplitPreconditioner()

FieldSplitPreconditionerBase & NonlinearSystemBase::getFieldSplitPreconditioner ( )
inherited
Returns
A field split preconditioner. This will error if there is no field split preconditioner

Definition at line 4114 of file NonlinearSystemBase.C.

4115 {
4116  if (!_fsp)
4117  mooseError("No field split preconditioner is present for this system");
4118 
4119  return *_fsp;
4120 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
FieldSplitPreconditionerBase * _fsp
The field split preconditioner if this sytem is using one.

◆ getFieldVariable() [1/2]

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

Gets a reference to a variable of with specified name.

This excludes and cannot return finite volume variables.

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

Definition at line 111 of file SystemBase.C.

Referenced by Marker::getMarkerValue().

112 {
113  return *_vars[tid].getFieldVariable<T>(var_name);
114 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ getFieldVariable() [2/2]

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

Gets a reference to a variable with specified number.

This excludes and cannot return finite volume variables.

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

Definition at line 132 of file SystemBase.C.

133 {
134  return *_vars[tid].getFieldVariable<T>(var_number);
135 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ getFVVariable()

template<typename T >
template MooseVariableFV< Real > & SystemBase::getFVVariable< Real > ( THREAD_ID  tid,
const std::string &  var_name 
)
inherited

Return a finite volume variable.

Definition at line 125 of file SystemBase.C.

126 {
127  return *_vars[tid].getFVVariable<T>(var_name);
128 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ getHDGKernelWarehouse()

MooseObjectTagWarehouse<HDGKernel>& NonlinearSystemBase::getHDGKernelWarehouse ( )
inlineinherited

Definition at line 604 of file NonlinearSystemBase.h.

604 { return _hybridized_kernels; }
MooseObjectTagWarehouse< HDGKernel > _hybridized_kernels

◆ getIntegratedBCWarehouse() [1/2]

MooseObjectTagWarehouse<IntegratedBCBase>& NonlinearSystemBase::getIntegratedBCWarehouse ( )
inlineinherited

Definition at line 595 of file NonlinearSystemBase.h.

Referenced by BoundaryElemIntegrityCheckThread::operator()().

595 { return _integrated_bcs; }
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs

◆ getIntegratedBCWarehouse() [2/2]

const MooseObjectTagWarehouse<IntegratedBCBase>& NonlinearSystemBase::getIntegratedBCWarehouse ( ) const
inlineinherited

Return the IntegratedBCBase warehouse.

Definition at line 623 of file NonlinearSystemBase.h.

624  {
625  return _integrated_bcs;
626  }
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs

◆ getInterfaceKernelWarehouse()

MooseObjectTagWarehouse<InterfaceKernelBase>& NonlinearSystemBase::getInterfaceKernelWarehouse ( )
inlineinherited

Definition at line 590 of file NonlinearSystemBase.h.

591  {
592  return _interface_kernels;
593  }
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels

◆ getKernelWarehouse() [1/2]

MooseObjectTagWarehouse<KernelBase>& NonlinearSystemBase::getKernelWarehouse ( )
inlineinherited

Access functions to Warehouses from outside NonlinearSystemBase.

Definition at line 587 of file NonlinearSystemBase.h.

Referenced by ExplicitTimeIntegrator::initialSetup(), DOFMapOutput::output(), and BlockRestrictionDebugOutput::printBlockRestrictionMap().

587 { return _kernels; }
MooseObjectTagWarehouse< KernelBase > _kernels

◆ getKernelWarehouse() [2/2]

const MooseObjectTagWarehouse<KernelBase>& NonlinearSystemBase::getKernelWarehouse ( ) const
inlineinherited

Definition at line 588 of file NonlinearSystemBase.h.

588 { return _kernels; }
MooseObjectTagWarehouse< KernelBase > _kernels

◆ getMatrix() [1/2]

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

Get a raw SparseMatrix.

Reimplemented in DisplacedSystem.

Definition at line 1016 of file SystemBase.C.

Referenced by SystemBase::activateAllMatrixTags(), Assembly::addCachedJacobian(), NonlinearSystemBase::addImplicitGeometricCouplingEntries(), Assembly::addJacobianCoupledVarPair(), Assembly::addJacobianLowerD(), Assembly::addJacobianNeighbor(), Assembly::addJacobianNeighborLowerD(), Assembly::addJacobianNonlocal(), SystemBase::addMatrix(), SystemBase::closeTaggedMatrices(), NonlinearSystemBase::computeJacobianInternal(), FEProblemBase::computeJacobianTags(), LinearSystem::computeLinearSystemInternal(), FEProblemBase::computeLinearSystemTags(), FEProblemBase::computeResidualAndJacobian(), NonlinearSystemBase::computeResidualAndJacobianInternal(), NonlinearSystemBase::constraintJacobians(), SystemBase::disassociateMatrixFromTag(), NonlinearSystemBase::enforceNodalConstraintsJacobian(), SystemBase::flushTaggedMatrices(), DisplacedSystem::getMatrix(), LinearSystemContributionObject::linkTaggedVectorsAndMatrices(), MooseVariableScalar::reinit(), Assembly::setCachedJacobian(), and Assembly::zeroCachedJacobian().

1017 {
1018  if (!hasMatrix(tag))
1019  {
1020  if (!_subproblem.matrixTagExists(tag))
1021  mooseError("Cannot retreive matrix with tag ", tag, " because that tag does not exist");
1022  else
1023  mooseError("Cannot retreive matrix with tag ",
1024  tag,
1025  " in system '",
1026  name(),
1027  "'\nbecause a matrix has not been associated with that tag.");
1028  }
1029 
1030  return *_tagged_matrices[tag];
1031 }
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:1023
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
virtual const std::string & name() const
Definition: SystemBase.C:1332
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:328

◆ getMatrix() [2/2]

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

Get a raw SparseMatrix.

Reimplemented in DisplacedSystem.

Definition at line 1034 of file SystemBase.C.

1035 {
1036  if (!hasMatrix(tag))
1037  {
1038  if (!_subproblem.matrixTagExists(tag))
1039  mooseError("Cannot retreive matrix with tag ", tag, " because that tag does not exist");
1040  else
1041  mooseError("Cannot retreive matrix with tag ",
1042  tag,
1043  " in system '",
1044  name(),
1045  "'\nbecause a matrix has not been associated with that tag.");
1046  }
1047 
1048  return *_tagged_matrices[tag];
1049 }
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:1023
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
virtual const std::string & name() const
Definition: SystemBase.C:1332
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:328

◆ getMaxVariableNumber()

unsigned int SystemBase::getMaxVariableNumber ( ) const
inlineinherited

Returns the maximum number of all variables on the system.

Definition at line 867 of file SystemBase.h.

867 { return _max_var_number; }
unsigned int _max_var_number
Maximum variable number.
Definition: SystemBase.h:1000

◆ getMaxVarNDofsPerElem()

std::size_t SystemBase::getMaxVarNDofsPerElem ( ) const
inlineinherited

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

Returns
The max

Definition at line 585 of file SystemBase.h.

Referenced by Moose::globalDofIndexToDerivative().

585 { 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:1043

◆ getMaxVarNDofsPerNode()

std::size_t SystemBase::getMaxVarNDofsPerNode ( ) const
inlineinherited

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

Returns
The max

Definition at line 592 of file SystemBase.h.

592 { return _max_var_n_dofs_per_node; }
size_t _max_var_n_dofs_per_node
Maximum number of dofs for any one variable on any one node.
Definition: SystemBase.h:1046

◆ getMinQuadratureOrder()

Order SystemBase::getMinQuadratureOrder ( )
virtualinherited

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

Returns
The minimal order of quadrature

Reimplemented in AuxiliarySystem.

Definition at line 241 of file SystemBase.C.

242 {
243  Order order = CONSTANT;
244  const std::vector<MooseVariableFieldBase *> & vars = _vars[0].fieldVariables();
245  for (const auto & var : vars)
246  {
247  FEType fe_type = var->feType();
248  if (fe_type.default_quadrature_order() > order)
249  order = fe_type.default_quadrature_order();
250  }
251 
252  return order;
253 }
Order
char ** vars
Order default_quadrature_order() const
CONSTANT
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ getMooseKSPNormType()

Moose::MooseKSPNormType SolverSystem::getMooseKSPNormType ( )
inlineinherited

Get the norm in which the linear convergence is measured.

Definition at line 87 of file SolverSystem.h.

Referenced by Moose::PetscSupport::petscSetDefaultKSPNormType().

87 { return _ksp_norm; }
Moose::MooseKSPNormType _ksp_norm
KSP norm type.
Definition: SolverSystem.h:110

◆ getNodalBCWarehouse()

const MooseObjectTagWarehouse<NodalBCBase>& NonlinearSystemBase::getNodalBCWarehouse ( ) const
inlineinherited

Return the NodalBCBase warehouse.

Definition at line 618 of file NonlinearSystemBase.h.

618 { return _nodal_bcs; }
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs

◆ getNodalDamperWarehouse()

const MooseObjectWarehouse<NodalDamper>& NonlinearSystemBase::getNodalDamperWarehouse ( ) const
inlineinherited

Definition at line 609 of file NonlinearSystemBase.h.

Referenced by ComputeNodalDampingThread::onNode(), and ComputeNodalDampingThread::printGeneralExecutionInformation().

610  {
611  return _nodal_dampers;
612  }
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.

◆ getNodalKernelWarehouse()

const MooseObjectTagWarehouse<NodalKernelBase>& NonlinearSystemBase::getNodalKernelWarehouse ( ) const
inlineinherited

Definition at line 600 of file NonlinearSystemBase.h.

Referenced by ExplicitTimeIntegrator::initialSetup().

601  {
602  return _nodal_kernels;
603  }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.

◆ getNodeDofs()

void NonlinearSystemBase::getNodeDofs ( dof_id_type  node_id,
std::vector< dof_id_type > &  dofs 
)
protectedinherited

Definition at line 2140 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::findImplicitGeometricCouplingEntries().

2141 {
2142  const Node & node = _mesh.nodeRef(node_id);
2143  unsigned int s = number();
2144  if (node.has_dofs(s))
2145  {
2146  for (unsigned int v = 0; v < nVariables(); v++)
2147  for (unsigned int c = 0; c < node.n_comp(s, v); c++)
2148  dofs.push_back(node.dof_number(s, v, c));
2149  }
2150 }
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
unsigned int n_comp(const unsigned int s, const unsigned int var) const
bool has_dofs(const unsigned int s=libMesh::invalid_uint) const
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:834
virtual unsigned int nVariables() const
Get the number of variables in this system.
Definition: SystemBase.C:883
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
MooseMesh & _mesh
Definition: SystemBase.h:991

◆ getPCSide()

Moose::PCSideType SolverSystem::getPCSide ( )
inlineinherited

Get the current preconditioner side.

Definition at line 76 of file SolverSystem.h.

Referenced by Moose::PetscSupport::petscSetDefaultPCSide().

76 { return _pc_side; }
Moose::PCSideType _pc_side
Preconditioning side.
Definition: SolverSystem.h:108

◆ getPreconditioner()

MoosePreconditioner const * NonlinearSystemBase::getPreconditioner ( ) const
inherited

Definition at line 3549 of file NonlinearSystemBase.C.

Referenced by ConsoleUtils::outputExecutionInformation().

3550 {
3551  return _preconditioner.get();
3552 }
std::shared_ptr< MoosePreconditioner > _preconditioner
Preconditioner.

◆ getPredictor()

Predictor* NonlinearSystemBase::getPredictor ( )
inlineinherited

Definition at line 558 of file NonlinearSystemBase.h.

Referenced by AB2PredictorCorrector::estimateTimeError().

558 { return _predictor.get(); }
std::shared_ptr< Predictor > _predictor
If predictor is active, this is non-NULL.

◆ getResidualNonTimeVector()

NumericVector< Number > & NonlinearSystemBase::getResidualNonTimeVector ( )
inherited

Return a numeric vector that is associated with the nontime tag.

Definition at line 1016 of file NonlinearSystemBase.C.

Referenced by PseudoTimestep::currentResidualNorm(), NonlinearSystemBase::NonlinearSystemBase(), and NonlinearSystemBase::residualVector().

1017 {
1018  if (!_Re_non_time)
1019  {
1021 
1022  // Most applications don't need the expense of ghosting
1024  _Re_non_time = &addVector(_Re_non_time_tag, false, ptype);
1025  }
1027  {
1028  const auto vector_name = _subproblem.vectorTagName(_Re_non_time_tag);
1029 
1030  // If an application changes its mind, the libMesh API lets us
1031  // change the vector.
1032  _Re_non_time = &system().add_vector(vector_name, false, GHOSTED);
1033  }
1034 
1035  return *_Re_non_time;
1036 }
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
PARALLEL
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition: SubProblem.C:92
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
TagID _Re_non_time_tag
Tag for non-time contribution residual.
GHOSTED
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
ParallelType type() const
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:221
ParallelType
virtual libMesh::System & system() override
Get the reference to the libMesh system.

◆ getResidualTimeVector()

NumericVector< Number > & NonlinearSystemBase::getResidualTimeVector ( )
inherited

Return a numeric vector that is associated with the time tag.

Definition at line 993 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::residualVector().

994 {
995  if (!_Re_time)
996  {
998 
999  // Most applications don't need the expense of ghosting
1001  _Re_time = &addVector(_Re_time_tag, false, ptype);
1002  }
1003  else if (_need_residual_ghosted && _Re_time->type() == PARALLEL)
1004  {
1005  const auto vector_name = _subproblem.vectorTagName(_Re_time_tag);
1006 
1007  // If an application changes its mind, the libMesh API lets us
1008  // change the vector.
1009  _Re_time = &system().add_vector(vector_name, false, GHOSTED);
1010  }
1011 
1012  return *_Re_time;
1013 }
NumericVector< Number > * _Re_time
residual vector for time contributions
TagID _Re_time_tag
Tag for time contribution residual.
PARALLEL
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition: SubProblem.C:92
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
GHOSTED
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
ParallelType type() const
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:221
ParallelType
virtual libMesh::System & system() override
Get the reference to the libMesh system.

◆ getScalarKernelWarehouse()

const MooseObjectTagWarehouse<ScalarKernelBase>& NonlinearSystemBase::getScalarKernelWarehouse ( ) const
inlineinherited

Definition at line 596 of file NonlinearSystemBase.h.

Referenced by ExplicitTimeIntegrator::initialSetup().

597  {
598  return _scalar_kernels;
599  }
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels

◆ getScalarVariable() [1/2]

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

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 145 of file SystemBase.C.

Referenced by Assembly::addJacobianOffDiagScalar(), ODEKernel::computeOffDiagJacobianScalar(), VectorKernel::computeOffDiagJacobianScalar(), ArrayKernel::computeOffDiagJacobianScalar(), IntegratedBC::computeOffDiagJacobianScalar(), VectorIntegratedBC::computeOffDiagJacobianScalar(), ArrayIntegratedBC::computeOffDiagJacobianScalar(), Kernel::computeOffDiagJacobianScalar(), ScalarLagrangeMultiplier::computeOffDiagJacobianScalar(), MortarScalarBase::computeOffDiagJacobianScalar(), KernelScalarBase::computeOffDiagJacobianScalarLocal(), KernelScalarBase::computeScalarOffDiagJacobianScalar(), MortarScalarBase::computeScalarOffDiagJacobianScalar(), DMMooseSetVariables(), Assembly::init(), ReferenceResidualConvergence::initialSetup(), and NonlinearSystemBase::setupScalingData().

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

◆ getScalarVariable() [2/2]

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

Gets a reference to a variable with specified number.

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

Definition at line 154 of file SystemBase.C.

155 {
156  MooseVariableScalar * var =
157  dynamic_cast<MooseVariableScalar *>(_vars[tid].getVariable(var_number));
158  if (!var)
159  mooseError("variable #" + Moose::stringify(var_number) + " does not exist in this system");
160  return *var;
161 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
Class for scalar variables (they are different).

◆ getScalarVariables()

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

◆ getSNES()

virtual SNES DumpObjectsNonlinearSystem::getSNES ( )
inlineoverridevirtual

Implements NonlinearSystemBase.

Definition at line 34 of file DumpObjectsNonlinearSystem.h.

34 { return nullptr; }

◆ getSplit()

std::shared_ptr< Split > NonlinearSystemBase::getSplit ( const std::string &  name)
inherited

Retrieves a split by name.

Parameters
nameThe name of the split

Definition at line 705 of file NonlinearSystemBase.C.

Referenced by FieldSplitPreconditioner::FieldSplitPreconditioner(), Split::setup(), and StaticCondensationFieldSplitPreconditioner::StaticCondensationFieldSplitPreconditioner().

706 {
707  return _splits.getActiveObject(name);
708 }
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.
virtual const std::string & name() const
Definition: SystemBase.C:1332
std::shared_ptr< T > getActiveObject(const std::string &name, THREAD_ID tid=0) const

◆ getSplits()

MooseObjectWarehouseBase<Split>& NonlinearSystemBase::getSplits ( )
inlineinherited

Retrieves all splits.

Definition at line 230 of file NonlinearSystemBase.h.

Referenced by ConsoleUtils::outputExecutionInformation().

230 { return _splits; }
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.

◆ getStandardFieldVariableNames()

void SystemBase::getStandardFieldVariableNames ( std::vector< VariableName > &  std_field_variables) const
inherited

◆ getSubdomainsForVar() [1/2]

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

Definition at line 761 of file SystemBase.h.

Referenced by NonlinearSystemBase::checkKernelCoverage(), and SystemBase::getSubdomainsForVar().

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

◆ getSubdomainsForVar() [2/2]

const std::set< SubdomainID > & SystemBase::getSubdomainsForVar ( const std::string &  var_name) const
inherited

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

Parameters
var_nameThe name of the variable
Returns
the set of subdomain ids where the variable is active (defined)

Definition at line 1699 of file SystemBase.C.

1700 {
1701  return getSubdomainsForVar(getVariable(0, var_name).number());
1702 }
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
Definition: SystemBase.h:761
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:90

◆ getTimeIntegrator()

const TimeIntegrator & SystemBase::getTimeIntegrator ( const unsigned int  var_num) const
inherited

Retrieve the time integrator that integrates the given variable's equation.

Definition at line 1675 of file SystemBase.C.

Referenced by AB2PredictorCorrector::estimateTimeError().

1676 {
1677  const auto * const ti = queryTimeIntegrator(var_num);
1678 
1679  if (ti)
1680  return *ti;
1681  else
1682  mooseError("No time integrator found that integrates variable number ",
1683  std::to_string(var_num));
1684 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable&#39;s equation.
Definition: SystemBase.C:1665

◆ getTimeIntegrators()

const std::vector< std::shared_ptr< TimeIntegrator > > & SystemBase::getTimeIntegrators ( )
inherited
Returns
All the time integrators owned by this system

Definition at line 1687 of file SystemBase.C.

1688 {
1689  return _time_integrators;
1690 }
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
Definition: SystemBase.h:1049

◆ getVariable() [1/2]

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

Gets a reference to a variable of with specified name.

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

Definition at line 90 of file SystemBase.C.

Referenced by AdaptivityAction::act(), Assembly::addJacobianBlockNonlocal(), FEProblemBase::addJacobianBlockTags(), NonlocalKernel::computeNonlocalOffDiagJacobian(), NonlocalIntegratedBC::computeNonlocalOffDiagJacobian(), Assembly::copyFaceShapes(), Assembly::copyNeighborShapes(), Assembly::copyShapes(), SystemBase::copyVars(), DMMooseSetVariables(), FieldSplitPreconditionerTempl< MoosePreconditioner >::FieldSplitPreconditionerTempl(), FiniteDifferencePreconditioner::FiniteDifferencePreconditioner(), NodeElemConstraint::getConnectedDofIndices(), NodeFaceConstraint::getConnectedDofIndices(), SystemBase::getSubdomainsForVar(), ResidualObject::getVariable(), SubProblem::getVariableHelper(), Assembly::init(), NodalNormalsPreprocessor::initialize(), ExplicitTimeIntegrator::initialSetup(), ReferenceResidualConvergence::initialSetup(), LinearSystem::initialSetup(), Assembly::initNonlocalCoupling(), PNGOutput::makeMeshFunc(), MooseStaticCondensationPreconditioner::MooseStaticCondensationPreconditioner(), UpdateErrorVectorsThread::onElement(), Assembly::prepareBlock(), Assembly::prepareBlockNonlocal(), AddPeriodicBCAction::setPeriodicVars(), NonlinearSystemBase::setupScalingData(), and VariableCondensationPreconditioner::VariableCondensationPreconditioner().

91 {
93  dynamic_cast<MooseVariableFieldBase *>(_vars[tid].getVariable(var_name));
94  if (!var)
95  mooseError("Variable '", var_name, "' does not exist in this system");
96  return *var;
97 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
This class provides an interface for common operations on field variables of both FE and FV types wit...
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ getVariable() [2/2]

MooseVariableFieldBase & SystemBase::getVariable ( THREAD_ID  tid,
unsigned int  var_number 
) const
inherited

Gets a reference to a variable with specified number.

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

Definition at line 100 of file SystemBase.C.

101 {
102  if (var_number < _numbered_vars[tid].size())
103  if (_numbered_vars[tid][var_number])
104  return *_numbered_vars[tid][var_number];
105 
106  mooseError("Variable #", Moose::stringify(var_number), " does not exist in this system");
107 }
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
Map variable number to its pointer.
Definition: SystemBase.h:1052
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64

◆ getVariableBlocks()

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

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 164 of file SystemBase.C.

Referenced by PhysicsBasedPreconditioner::addSystem().

165 {
166  mooseAssert(_var_map.find(var_number) != _var_map.end(), "Variable does not exist.");
167  if (_var_map[var_number].empty())
168  return nullptr;
169  else
170  return &_var_map[var_number];
171 }
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
Definition: SystemBase.h:998

◆ getVariableGlobalDoFs()

const std::vector<dof_id_type>& SystemBase::getVariableGlobalDoFs ( )
inlineinherited

Get the global dof indices of a variable, this needs to be called after the indices have been set by setVariableGlobalDoFs

Definition at line 842 of file SystemBase.h.

842 { return _var_all_dof_indices; }
std::vector< dof_id_type > _var_all_dof_indices
Container for the dof indices of a given variable.
Definition: SystemBase.h:1064

◆ getVariableNames()

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

◆ getVariables()

const std::vector<MooseVariableFieldBase *>& SystemBase::getVariables ( THREAD_ID  tid)
inlineinherited

◆ getVector() [1/4]

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

Get a raw NumericVector by name.

Get a raw NumericVector with the given name.

Reimplemented in DisplacedSystem.

Definition at line 925 of file SystemBase.C.

Referenced by Assembly::addCachedResiduals(), Assembly::addResidual(), Assembly::addResidualLower(), Assembly::addResidualNeighbor(), Assembly::addResidualScalar(), NonlinearSystemBase::assembleScalingVector(), SystemBase::closeTaggedVector(), FEProblemBase::computeBounds(), FEProblemBase::computeNearNullSpace(), FEProblemBase::computeNullSpace(), NonlinearSystemBase::computeResidualAndJacobianTags(), NonlinearSystemBase::computeResidualTags(), CentralDifference::computeTimeDerivatives(), FEProblemBase::computeTransposeNullSpace(), DisplacedSystem::getVector(), Assembly::hasScalingVector(), LinearSystemContributionObject::linkTaggedVectorsAndMatrices(), SystemBase::needSolutionState(), ReferenceResidualConvergence::ReferenceResidualConvergence(), MooseVariableScalar::reinit(), SecantSolve::saveVariableValues(), SteffensenSolve::saveVariableValues(), PicardSolve::saveVariableValues(), NonlinearSystemBase::setPreviousNewtonSolution(), TaggingInterface::setResidual(), SystemBase::solutionPreviousNewton(), SystemBase::solutionState(), MultiAppDofCopyTransfer::transfer(), SecantSolve::transformVariables(), SteffensenSolve::transformVariables(), PicardSolve::transformVariables(), and SystemBase::zeroTaggedVector().

926 {
927  return system().get_vector(name);
928 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual const std::string & name() const
Definition: SystemBase.C:1332
const NumericVector< Number > & get_vector(std::string_view vec_name) const

◆ getVector() [2/4]

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

Reimplemented in DisplacedSystem.

Definition at line 931 of file SystemBase.C.

932 {
933  return system().get_vector(name);
934 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual const std::string & name() const
Definition: SystemBase.C:1332
const NumericVector< Number > & get_vector(std::string_view vec_name) const

◆ getVector() [3/4]

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

Get a raw NumericVector by tag.

Reimplemented in DisplacedSystem.

Definition at line 937 of file SystemBase.C.

938 {
939  if (!hasVector(tag))
940  {
941  if (!_subproblem.vectorTagExists(tag))
942  mooseError("Cannot retreive vector with tag ", tag, " because that tag does not exist");
943  else
944  mooseError("Cannot retreive vector with tag ",
945  tag,
946  " in system '",
947  name(),
948  "'\nbecause a vector has not been associated with that tag.");
949  }
950 
951  return *_tagged_vectors[tag];
952 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:916
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual const std::string & name() const
Definition: SystemBase.C:1332
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:201
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:1021

◆ getVector() [4/4]

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

Reimplemented in DisplacedSystem.

Definition at line 955 of file SystemBase.C.

956 {
957  if (!hasVector(tag))
958  {
959  if (!_subproblem.vectorTagExists(tag))
960  mooseError("Cannot retreive vector with tag ", tag, " because that tag does not exist");
961  else
962  mooseError("Cannot retreive vector with tag ",
963  tag,
964  " in system '",
965  name(),
966  "'\nbecause a vector has not been associated with that tag.");
967  }
968 
969  return *_tagged_vectors[tag];
970 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:916
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual const std::string & name() const
Definition: SystemBase.C:1332
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:201
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:1021

◆ gradientContainer()

const std::vector<std::unique_ptr<NumericVector<Number> > >& SystemBase::gradientContainer ( ) const
inlineinherited

Reference to the container vector which hold gradients at dofs (if it can be interpreted).

Mainly used for finite volume systems.

Definition at line 930 of file SystemBase.h.

931  {
932  return _raw_grad_container;
933  }
std::vector< std::unique_ptr< NumericVector< Number > > > _raw_grad_container
A cache for storing gradients at dof locations.
Definition: SystemBase.h:1073

◆ hasDiagSaveIn()

bool NonlinearSystemBase::hasDiagSaveIn ( ) const
inlineinherited

Weather or not the nonlinear system has diagonal Jacobian save-ins.

Definition at line 638 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeJacobianInternal().

bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.

◆ hasMatrix()

virtual bool SystemBase::hasMatrix ( TagID  tag) const
inlinevirtualinherited

Check if the tagged matrix exists in the system.

Reimplemented in DisplacedSystem.

Definition at line 360 of file SystemBase.h.

Referenced by SystemBase::activateAllMatrixTags(), Assembly::addCachedJacobian(), NonlinearSystemBase::addImplicitGeometricCouplingEntries(), Assembly::addJacobianCoupledVarPair(), Assembly::addJacobianLowerD(), Assembly::addJacobianNeighbor(), Assembly::addJacobianNeighborLowerD(), Assembly::addJacobianNonlocal(), SystemBase::addMatrix(), Assembly::cacheJacobian(), Assembly::cacheJacobianBlockNonzero(), Assembly::cacheJacobianCoupledVarPair(), Assembly::cacheJacobianMortar(), Assembly::cacheJacobianNeighbor(), Assembly::cacheJacobianNonlocal(), SystemBase::closeTaggedMatrices(), NonlinearSystemBase::computeJacobianInternal(), FEProblemBase::computeJacobianTags(), FEProblemBase::computeResidualAndJacobian(), NonlinearSystemBase::computeResidualAndJacobianInternal(), NonlinearSystemBase::constraintJacobians(), SystemBase::disassociateMatrixFromTag(), NonlinearSystemBase::enforceNodalConstraintsJacobian(), SystemBase::flushTaggedMatrices(), SystemBase::getMatrix(), DisplacedSystem::hasMatrix(), MooseVariableScalar::reinit(), SystemBase::removeMatrix(), SubProblem::selectMatrixTagsFromSystem(), Assembly::setCachedJacobian(), and Assembly::zeroCachedJacobian().

361  {
362  return tag < _tagged_matrices.size() && _tagged_matrices[tag];
363  }
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:1023

◆ hasSaveIn()

bool NonlinearSystemBase::hasSaveIn ( ) const
inlineinherited

Weather or not the nonlinear system has save-ins.

Definition at line 633 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeResidualTags().

633 { return _has_save_in || _has_nodalbc_save_in; }
bool _has_nodalbc_save_in
If there is a nodal BC having save_in.
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.

◆ hasScalarVariable()

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

Definition at line 868 of file SystemBase.C.

Referenced by MortarScalarBase::computeJacobian(), NonlinearSystemBase::computeJacobianInternal(), ComputeFullJacobianThread::computeOnBoundary(), ComputeFullJacobianThread::computeOnElement(), SystemBase::copyVars(), ExplicitTimeIntegrator::initialSetup(), NonlinearEigenSystem::postAddResidualObject(), AddPeriodicBCAction::setPeriodicVars(), and NonlinearSystemBase::setupScalingData().

869 {
870  if (system().has_variable(var_name))
871  return system().variable_type(var_name).family == SCALAR;
872  else
873  return false;
874 }
SCALAR
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
const FEType & variable_type(const unsigned int i) const

◆ hasSolutionState()

bool SystemBase::hasSolutionState ( const unsigned int  state,
Moose::SolutionIterationType  iteration_type = Moose::SolutionIterationType::Time 
) const
inlinevirtualinherited

Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).

Reimplemented in DisplacedSystem.

Definition at line 1090 of file SystemBase.h.

Referenced by PointwiseRenormalizeVector::execute(), PointwiseRenormalizeVector::finalize(), DisplacedSystem::hasSolutionState(), SystemBase::needSolutionState(), SystemBase::restoreSolutions(), ElementSubdomainModifierBase::setOldAndOlderSolutions(), SystemBase::solutionState(), and SystemBase::solutionStateParallelType().

1092 {
1093  return _solution_states[static_cast<unsigned short>(iteration_type)].size() > state;
1094 }
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1084

◆ hasVarCopy()

bool SystemBase::hasVarCopy ( ) const
inlineinherited

Whether or not there are variables to be restarted from an Exodus mesh file.

Definition at line 883 of file SystemBase.h.

883 { return _var_to_copy.size() > 0; }
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:1040

◆ hasVariable()

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

Query a system for a variable.

Parameters
var_namename of the variable
Returns
true if the variable exists

Definition at line 843 of file SystemBase.C.

Referenced by ADDGKernel::ADDGKernel(), ArrayDGKernel::ArrayDGKernel(), SystemBase::copyVars(), DGKernel::DGKernel(), DMMooseSetVariables(), FEProblemBase::duplicateVariableCheck(), SubProblem::getVariableHelper(), SubProblem::hasAuxiliaryVariable(), ExplicitTimeIntegrator::initialSetup(), InterfaceKernelTempl< T >::InterfaceKernelTempl(), PNGOutput::makeMeshFunc(), MultiAppVariableValueSamplePostprocessorTransfer::MultiAppVariableValueSamplePostprocessorTransfer(), NonlinearSystemBase::setupScalingData(), and Coupleable::writableCoupledValue().

844 {
845  auto & names = getVariableNames();
846  if (system().has_variable(var_name))
847  return system().variable_type(var_name).family != SCALAR;
848  if (std::find(names.begin(), names.end(), var_name) != names.end())
849  // array variable
850  return true;
851  else
852  return false;
853 }
SCALAR
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
const FEType & variable_type(const unsigned int i) const
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:860

◆ hasVector() [1/2]

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

◆ hasVector() [2/2]

virtual bool SystemBase::hasVector ( TagID  tag_id) const
inlinevirtualinherited

Check if the tagged vector exists in the system.

Reimplemented in DisplacedSystem.

Definition at line 281 of file SystemBase.h.

282  {
283  return tag_id < _tagged_vectors.size() && _tagged_vectors[tag_id];
284  }
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:1021

◆ haveFieldSplitPreconditioner()

bool NonlinearSystemBase::haveFieldSplitPreconditioner ( ) const
inlineinherited

Definition at line 112 of file NonlinearSystemBase.h.

112 { return _fsp; }
FieldSplitPreconditionerBase * _fsp
The field split preconditioner if this sytem is using one.

◆ haveFiniteDifferencedPreconditioner()

bool NonlinearSystemBase::haveFiniteDifferencedPreconditioner ( ) const
inlineinherited

Definition at line 108 of file NonlinearSystemBase.h.

109  {
111  }
bool _use_finite_differenced_preconditioner
Whether or not to use a finite differenced preconditioner.

◆ ignoreVariablesForAutoscaling()

void NonlinearSystemBase::ignoreVariablesForAutoscaling ( const std::vector< std::string > &  ignore_variables_for_autoscaling)
inlineinherited

Definition at line 681 of file NonlinearSystemBase.h.

682  {
683  _ignore_variables_for_autoscaling = ignore_variables_for_autoscaling;
684  }
std::vector< std::string > _ignore_variables_for_autoscaling
A container for variables that do not partipate in autoscaling.

◆ initializeObjects()

virtual void SystemBase::initializeObjects ( )
inlinevirtualinherited

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

Definition at line 173 of file SystemBase.h.

173 {}

◆ initialResidual()

Real NonlinearSystemBase::initialResidual ( ) const
inherited

The initial residual.

Definition at line 744 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::referenceResidual().

745 {
746  return _initial_residual;
747 }
Real _initial_residual
The initial (i.e., 0th nonlinear iteration) residual, see setPreSMOResidual for a detailed explanatio...

◆ initialSetup()

void NonlinearSystemBase::initialSetup ( )
overridevirtualinherited

Setup Functions.

Reimplemented from SystemBase.

Definition at line 212 of file NonlinearSystemBase.C.

213 {
214  TIME_SECTION("nlInitialSetup", 2, "Setting Up Nonlinear System");
215 
217 
218  {
219  TIME_SECTION("kernelsInitialSetup", 2, "Setting Up Kernels/BCs/Constraints");
220 
221  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
222  {
223  _kernels.initialSetup(tid);
226  if (_doing_dg)
229 
233 
234  if (_fe_problem.haveFV())
235  {
236  std::vector<FVElementalKernel *> fv_elemental_kernels;
238  .query()
239  .template condition<AttribSystem>("FVElementalKernel")
240  .template condition<AttribThread>(tid)
241  .queryInto(fv_elemental_kernels);
242 
243  for (auto * fv_kernel : fv_elemental_kernels)
244  fv_kernel->initialSetup();
245 
246  std::vector<FVFluxKernel *> fv_flux_kernels;
248  .query()
249  .template condition<AttribSystem>("FVFluxKernel")
250  .template condition<AttribThread>(tid)
251  .queryInto(fv_flux_kernels);
252 
253  for (auto * fv_kernel : fv_flux_kernels)
254  fv_kernel->initialSetup();
255  }
256  }
257 
262  }
263 
264  {
265  TIME_SECTION("mortarSetup", 2, "Initializing Mortar Interfaces");
266 
267  auto create_mortar_functors = [this](const bool displaced)
268  {
269  // go over mortar interfaces and construct functors
270  const auto & mortar_interfaces = _fe_problem.getMortarInterfaces(displaced);
271  for (const auto & mortar_interface : mortar_interfaces)
272  {
273  const auto primary_secondary_boundary_pair = mortar_interface.first;
274  if (!_constraints.hasActiveMortarConstraints(primary_secondary_boundary_pair, displaced))
275  continue;
276 
277  const auto & mortar_generation_object = mortar_interface.second;
278 
279  auto & mortar_constraints =
280  _constraints.getActiveMortarConstraints(primary_secondary_boundary_pair, displaced);
281 
282  auto & subproblem = displaced
283  ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
284  : static_cast<SubProblem &>(_fe_problem);
285 
286  auto & mortar_functors =
288 
289  mortar_functors.emplace(primary_secondary_boundary_pair,
290  ComputeMortarFunctor(mortar_constraints,
291  mortar_generation_object,
292  subproblem,
293  _fe_problem,
294  displaced,
295  subproblem.assembly(0, number())));
296  }
297  };
298 
299  create_mortar_functors(false);
300  create_mortar_functors(true);
301  }
302 
303  if (_automatic_scaling)
304  {
306  _scaling_matrix = std::make_unique<OffDiagonalScalingMatrix<Number>>(_communicator);
307  else
308  _scaling_matrix = std::make_unique<DiagonalMatrix<Number>>(_communicator);
309  }
310 
311  if (_preconditioner)
312  _preconditioner->initialSetup();
313 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
std::vector< T * > & queryInto(std::vector< T *> &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
Definition: TheWarehouse.h:311
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
bool hasActiveMortarConstraints(const std::pair< BoundaryID, BoundaryID > &mortar_interface_key, bool displaced) const
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
std::unique_ptr< libMesh::DiagonalMatrix< Number > > _scaling_matrix
A diagonal matrix used for computing scaling.
const Parallel::Communicator & _communicator
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _undisplaced_mortar_functors
Functors for computing undisplaced mortar constraints.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
bool _doing_dg
true if DG is active (optimization reasons)
TheWarehouse & theWarehouse() const
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _displaced_mortar_functors
Functors for computing displaced mortar constraints.
bool _automatic_scaling
Whether to automatically scale the variables.
Definition: SystemBase.h:1055
std::shared_ptr< MoosePreconditioner > _preconditioner
Preconditioner.
SubProblem & subproblem()
Definition: SystemBase.h:101
MooseObjectTagWarehouse< KernelBase > _kernels
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
virtual void initialSetup(THREAD_ID tid=0) const
Convenience methods for calling object setup methods.
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
const std::vector< std::shared_ptr< MortarConstraintBase > > & getActiveMortarConstraints(const std::pair< BoundaryID, BoundaryID > &mortar_interface_key, bool displaced) const
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
bool _off_diagonals_in_auto_scaling
Whether to include off diagonals when determining automatic scaling factors.
const std::unordered_map< std::pair< BoundaryID, BoundaryID >, AutomaticMortarGeneration > & getMortarInterfaces(bool on_displaced) const
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
virtual void initialSetup()
Setup Functions.
Definition: SystemBase.C:1550
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ initSolutionState()

void SystemBase::initSolutionState ( )
virtualinherited

Initializes the solution state.

Reimplemented in DisplacedSystem.

Definition at line 1356 of file SystemBase.C.

Referenced by DisplacedSystem::initSolutionState().

1357 {
1358  // Default is the current solution
1359  unsigned int state = 0;
1360 
1361  // Add additional states as required by the variable states requested
1362  for (const auto & var : getVariables(/* tid = */ 0))
1363  state = std::max(state, var->oldestSolutionStateRequested());
1364  for (const auto & var : getScalarVariables(/* tid = */ 0))
1365  state = std::max(state, var->oldestSolutionStateRequested());
1366 
1368 
1370 }
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
Definition: SystemBase.h:751
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
Definition: SystemBase.h:756
bool _solution_states_initialized
Whether or not the solution states have been initialized.
Definition: SystemBase.h:1061
auto max(const L &left, const R &right)
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.
Definition: SystemBase.C:1442

◆ isArrayVariable()

bool SystemBase::isArrayVariable ( const std::string &  var_name) const
virtualinherited

If a variable is an array variable.

Definition at line 856 of file SystemBase.C.

857 {
858  auto & names = getVariableNames();
859  if (!system().has_variable(var_name) &&
860  std::find(names.begin(), names.end(), var_name) != names.end())
861  // array variable
862  return true;
863  else
864  return false;
865 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:860

◆ isScalarVariable()

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

Definition at line 877 of file SystemBase.C.

Referenced by Assembly::init(), ReferenceResidualConvergence::initialSetup(), and Assembly::initNonlocalCoupling().

878 {
879  return (system().variable(var_num).type().family == SCALAR);
880 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.

◆ jacobianSetup()

void NonlinearSystemBase::jacobianSetup ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 2746 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

2747 {
2749 
2750  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
2751  {
2752  _kernels.jacobianSetup(tid);
2755  if (_doing_dg)
2761  }
2766 
2767  // Avoid recursion
2768  if (this == &_fe_problem.currentNonlinearSystem())
2771 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
virtual void jacobianSetup()
Definition: SystemBase.C:1598
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
bool _doing_dg
true if DG is active (optimization reasons)
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:172
NonlinearSystemBase & currentNonlinearSystem()
MooseObjectTagWarehouse< KernelBase > _kernels
virtual void jacobianSetup(THREAD_ID tid=0) const
ConstraintWarehouse _constraints
Constraints storage object.
MooseApp & _app
Definition: SystemBase.h:988
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
void resetSolutionInvalidCurrentIteration()
Reset the number of solution invalid occurrences back to zero.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
void jacobianSetup() override
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ matrixFromColoring()

virtual bool SolverSystem::matrixFromColoring ( ) const
inlineprotectedvirtualinherited

Whether a system matrix is formed from coloring.

This influences things like when to compute time derivatives

Reimplemented in NonlinearSystem.

Definition at line 102 of file SolverSystem.h.

Referenced by SolverSystem::compute(), and NonlinearSystemBase::destroyColoring().

102 { return false; }

◆ matrixTagActive()

bool SystemBase::matrixTagActive ( TagID  tag) const
virtualinherited

If or not a matrix tag is active.

Definition at line 1141 of file SystemBase.C.

1142 {
1143  mooseAssert(_subproblem.matrixTagExists(tag), "Matrix tag " << tag << " does not exist");
1144 
1145  return tag < _matrix_tag_active_flags.size() && _matrix_tag_active_flags[tag];
1146 }
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:1027
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:328

◆ mesh() [1/2]

MooseMesh& SystemBase::mesh ( )
inlineinherited

◆ mesh() [2/2]

const MooseMesh& SystemBase::mesh ( ) const
inlineinherited

Definition at line 100 of file SystemBase.h.

100 { return _mesh; }
MooseMesh & _mesh
Definition: SystemBase.h:991

◆ mortarConstraints()

void NonlinearSystemBase::mortarConstraints ( Moose::ComputeType  compute_type,
const std::set< TagID > &  vector_tags,
const std::set< TagID > &  matrix_tags 
)
protectedinherited

Do mortar constraint residual/jacobian computations.

Definition at line 3778 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal(), NonlinearSystemBase::computeResidualAndJacobianInternal(), and NonlinearSystemBase::computeResidualInternal().

3781 {
3782  parallel_object_only();
3783 
3784  try
3785  {
3786  for (auto & map_pr : _undisplaced_mortar_functors)
3787  map_pr.second(compute_type, vector_tags, matrix_tags);
3788 
3789  for (auto & map_pr : _displaced_mortar_functors)
3790  map_pr.second(compute_type, vector_tags, matrix_tags);
3791  }
3792  catch (MetaPhysicL::LogicError &)
3793  {
3794  mooseError(
3795  "We caught a MetaPhysicL error in NonlinearSystemBase::mortarConstraints. This is very "
3796  "likely due to AD not having a sufficiently large derivative container size. Please run "
3797  "MOOSE configure with the '--with-derivative-size=<n>' option");
3798  }
3799 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _undisplaced_mortar_functors
Functors for computing undisplaced mortar constraints.
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _displaced_mortar_functors
Functors for computing displaced mortar constraints.

◆ name()

const std::string & SystemBase::name ( ) const
virtualinherited

Definition at line 1332 of file SystemBase.C.

Referenced by NonlinearSystemBase::addBoundaryCondition(), NonlinearSystemBase::addConstraint(), NonlinearSystemBase::addDamper(), NonlinearSystemBase::addDGKernel(), NonlinearSystemBase::addDiracKernel(), NonlinearSystemBase::addHDGKernel(), NonlinearSystemBase::addInterfaceKernel(), MooseEigenSystem::addKernel(), AuxiliarySystem::addKernel(), NonlinearSystemBase::addKernel(), SystemBase::addMatrix(), NonlinearSystemBase::addNodalKernel(), AuxiliarySystem::addScalarKernel(), NonlinearSystemBase::addScalarKernel(), NonlinearSystemBase::addSplit(), SystemBase::addTimeIntegrator(), AuxiliarySystem::addVariable(), SystemBase::addVariable(), DiffusionLHDGAssemblyHelper::checkCoupling(), SystemBase::closeTaggedVector(), LinearSystem::computeGradients(), LinearSystem::computeLinearSystemTags(), DisplacedProblem::DisplacedProblem(), SystemBase::getMatrix(), NonlinearSystemBase::getSplit(), DisplacedSystem::getVector(), SystemBase::getVector(), SystemBase::hasVector(), LinearSystem::initialSetup(), Moose::PetscSupport::petscSetDefaults(), NonlinearEigenSystem::postAddResidualObject(), MooseStaticCondensationPreconditioner::prefix(), SystemBase::removeMatrix(), SystemBase::removeVector(), SystemBase::solutionState(), LinearSystem::solve(), LinearTimeIntegratorInterface::timeDerivativeMatrixContribution(), LinearTimeIntegratorInterface::timeDerivativeRHSContribution(), and SystemBase::zeroTaggedVector().

1333 {
1334  return system().name();
1335 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
const std::string & name() const

◆ needBoundaryMaterialOnSide()

bool NonlinearSystemBase::needBoundaryMaterialOnSide ( BoundaryID  bnd_id,
THREAD_ID  tid 
) const
inherited

Indicated whether this system needs material properties on boundaries.

Returns
Boolean if IntegratedBCs are active

Definition at line 3746 of file NonlinearSystemBase.C.

3747 {
3748  return _integrated_bcs.hasActiveBoundaryObjects(bnd_id, tid);
3749 }
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs

◆ needInterfaceMaterialOnSide()

bool NonlinearSystemBase::needInterfaceMaterialOnSide ( BoundaryID  bnd_id,
THREAD_ID  tid 
) const
inherited

Indicated whether this system needs material properties on interfaces.

Returns
Boolean if IntegratedBCs are active

Definition at line 3752 of file NonlinearSystemBase.C.

3753 {
3754  return _interface_kernels.hasActiveBoundaryObjects(bnd_id, tid);
3755 }
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels

◆ needSolutionState()

void SystemBase::needSolutionState ( const unsigned int  state,
Moose::SolutionIterationType  iteration_type = Moose::SolutionIterationType::Time,
libMesh::ParallelType  parallel_type = GHOSTED 
)
virtualinherited

Registers that the solution state state is needed.

Reimplemented in DisplacedSystem.

Definition at line 1442 of file SystemBase.C.

Referenced by SecantSolve::allocateStorage(), PicardSolve::allocateStorage(), EigenExecutionerBase::EigenExecutionerBase(), SystemBase::initSolutionState(), DisplacedSystem::needSolutionState(), and SystemBase::solutionState().

1445 {
1446  libmesh_parallel_only(this->comm());
1447  mooseAssert(!Threads::in_threads,
1448  "This routine is not thread-safe. Request the solution state before using it in "
1449  "a threaded region.");
1450 
1451  if (hasSolutionState(state, iteration_type))
1452  return;
1453 
1454  auto & solution_states = _solution_states[static_cast<unsigned short>(iteration_type)];
1455  solution_states.resize(state + 1);
1456 
1457  // The 0-th (current) solution state is owned by libMesh
1458  if (!solution_states[0])
1459  solution_states[0] = &solutionInternal();
1460  else
1461  mooseAssert(solution_states[0] == &solutionInternal(), "Inconsistent current solution");
1462 
1463  // We will manually add all states past current
1464  for (unsigned int i = 1; i <= state; ++i)
1465  if (!solution_states[i])
1466  {
1467  auto tag = _subproblem.addVectorTag(oldSolutionStateVectorName(i, iteration_type),
1469  solution_states[i] = &addVector(tag, true, parallel_type);
1470  }
1471  else
1472  {
1473  // If the existing parallel type is PARALLEL and GHOSTED is now requested,
1474  // this would require an upgrade, which is risky if anybody has already
1475  // stored a pointer to the existing vector, since the upgrade would create
1476  // a new vector and make that pointer null. If the existing parallel type
1477  // is GHOSTED and PARALLEL is now requested, we don't need to do anything.
1478  if (parallel_type == GHOSTED && solutionStateParallelType(i, iteration_type) == PARALLEL)
1479  mooseError("The solution state has already been declared as PARALLEL");
1480 
1481  mooseAssert(solution_states[i] == &getVector(oldSolutionStateVectorName(i, iteration_type)),
1482  "Inconsistent solution state");
1483  }
1484 }
virtual NumericVector< Number > & solutionInternal() const =0
Internal getter for solution owned by libMesh.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition: SubProblem.C:92
const Parallel::Communicator & comm() const
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.h:1090
TagName oldSolutionStateVectorName(const unsigned int, Moose::SolutionIterationType iteration_type) const
Gets the vector name used for an old (not current) solution state.
Definition: SystemBase.C:1373
libMesh::ParallelType solutionStateParallelType(const unsigned int state, const Moose::SolutionIterationType iteration_type) const
Returns the parallel type of the given solution state.
Definition: SystemBase.C:1432
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1084
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:925

◆ needSubdomainMaterialOnSide()

bool NonlinearSystemBase::needSubdomainMaterialOnSide ( SubdomainID  subdomain_id,
THREAD_ID  tid 
) const
inherited

Indicates whether this system needs material properties on internal sides.

Returns
Boolean if DGKernels are active

Definition at line 3758 of file NonlinearSystemBase.C.

3760 {
3761  return _doing_dg;
3762 }
bool _doing_dg
true if DG is active (optimization reasons)

◆ nFieldVariables()

unsigned int SystemBase::nFieldVariables ( ) const
inherited

Get the number of field variables in this system.

Returns
the number of field variables

Definition at line 892 of file SystemBase.C.

Referenced by SystemBase::nVariables().

893 {
894  unsigned int n = 0;
895  for (auto & var : _vars[0].fieldVariables())
896  n += var->count();
897 
898  return n;
899 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ nFVVariables()

unsigned int SystemBase::nFVVariables ( ) const
inherited

Get the number of finite volume variables in this system.

Returns
the number of finite volume variables

Definition at line 902 of file SystemBase.C.

903 {
904  unsigned int n = 0;
905  for (auto & var : _vars[0].fieldVariables())
906  if (var->isFV())
907  n += var->count();
908 
909  return n;
910 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ nLinearIterations()

unsigned int NonlinearSystemBase::nLinearIterations ( ) const
inlineinherited

Return the number of linear iterations.

Definition at line 529 of file NonlinearSystemBase.h.

Referenced by IterationAdaptiveDT::acceptStep().

529 { return _n_linear_iters; }

◆ nNonlinearIterations()

unsigned int NonlinearSystemBase::nNonlinearIterations ( ) const
inlineinherited

Return the number of non-linear iterations.

Definition at line 524 of file NonlinearSystemBase.h.

Referenced by IterationAdaptiveDT::acceptStep().

524 { return _n_iters; }

◆ nonlinearNorm()

Real NonlinearSystemBase::nonlinearNorm ( ) const
inlineinherited

Return the last nonlinear norm.

Returns
A Real containing the last computed residual norm

Definition at line 545 of file NonlinearSystemBase.h.

Referenced by Console::writeVariableNorms().

545 { return _last_nl_rnorm; }

◆ nonlinearSolver()

virtual libMesh::NonlinearSolver<Number>* DumpObjectsNonlinearSystem::nonlinearSolver ( )
inlineoverridevirtual

Implements NonlinearSystemBase.

Definition at line 29 of file DumpObjectsNonlinearSystem.h.

29 { return NULL; }

◆ nonTimeVectorTag()

TagID NonlinearSystemBase::nonTimeVectorTag ( ) const
inlineoverridevirtualinherited

Reimplemented from SystemBase.

Definition at line 650 of file NonlinearSystemBase.h.

Referenced by FEProblemBase::addCachedResidualDirectly(), and CrankNicolson::init().

650 { return _Re_non_time_tag; }
TagID _Re_non_time_tag
Tag for non-time contribution residual.

◆ nResidualEvaluations()

unsigned int NonlinearSystemBase::nResidualEvaluations ( ) const
inlineinherited

Return the total number of residual evaluations done so far in this calculation.

Definition at line 534 of file NonlinearSystemBase.h.

534 { return _n_residual_evaluations; }
unsigned int _n_residual_evaluations
Total number of residual evaluations that have been performed.

◆ number()

unsigned int SystemBase::number ( ) const
inherited

Gets the number of this system.

Returns
The number of this system

Definition at line 1149 of file SystemBase.C.

Referenced by SetupResidualDebugAction::act(), FEProblemBase::addCachedResidualDirectly(), FEProblemBase::addJacobian(), FEProblemBase::addJacobianBlockTags(), FEProblemBase::addJacobianLowerD(), FEProblemBase::addJacobianNeighbor(), FEProblemBase::addJacobianNeighborLowerD(), FEProblemBase::addJacobianOffDiagScalar(), FEProblemBase::addJacobianScalar(), FEProblemBase::addResidual(), FEProblemBase::addResidualLower(), FEProblemBase::addResidualNeighbor(), FEProblemBase::addResidualScalar(), SystemBase::addScalingVector(), ADKernelTempl< T >::ADKernelTempl(), ElementSubdomainModifierBase::applyIC(), ArrayKernel::ArrayKernel(), NonlinearSystemBase::assembleScalingVector(), NonlinearEigenSystem::attachPreconditioner(), DiffusionLHDGAssemblyHelper::checkCoupling(), SolverSystem::compute(), MooseVariableScalar::computeAD(), FEProblemBase::computeBounds(), Assembly::computeFaceMap(), InternalSideIndicatorBase::computeIndicator(), VectorNodalBC::computeJacobian(), ArrayNodalBC::computeJacobian(), NodalBC::computeJacobian(), FVBoundaryScalarLagrangeMultiplierConstraint::computeJacobian(), FVFluxBC::computeJacobian(), FVFluxKernel::computeJacobian(), FVInterfaceKernel::computeJacobian(), FEProblemBase::computeJacobianBlock(), NonlinearSystemBase::computeJacobianInternal(), LinearSystem::computeLinearSystemInternal(), FEProblemBase::computeNearNullSpace(), NonlinearSystemBase::computeNodalBCsResidualAndJacobian(), FEProblemBase::computeNullSpace(), VectorNodalBC::computeOffDiagJacobian(), ArrayNodalBC::computeOffDiagJacobian(), NodalBC::computeOffDiagJacobian(), NodalKernel::computeOffDiagJacobian(), ComputeFullJacobianThread::computeOnBoundary(), ComputeFullJacobianThread::computeOnElement(), ComputeFullJacobianThread::computeOnInterface(), ComputeFullJacobianThread::computeOnInternalFace(), FEProblemBase::computePostCheck(), FVBoundaryScalarLagrangeMultiplierConstraint::computeResidual(), FVFluxKernel::computeResidual(), FVInterfaceKernel::computeResidual(), Kernel::computeResidualAndJacobian(), NodalBC::computeResidualAndJacobian(), IntegratedBC::computeResidualAndJacobian(), NonlinearSystemBase::computeResidualAndJacobianInternal(), NonlinearSystemBase::computeResidualInternal(), FEProblemBase::computeResidualL2Norm(), NonlinearSystemBase::computeResidualTags(), NonlinearSystemBase::computeScaling(), Assembly::computeSinglePointMapAD(), FEProblemBase::computeTransposeNullSpace(), DebugResidualAux::computeValue(), NearestNodeValueAux::computeValue(), SlepcEigenSolverConfiguration::configure_solver(), NonlinearSystemBase::constraintJacobians(), LinearSystem::containsTimeKernel(), Coupleable::coupled(), FEProblemBase::currentLinearSysNum(), FEProblemBase::currentNlSysNum(), PseudoTimestep::currentResidualNorm(), ComputeResidualThread::determineObjectWarehouses(), ComputeResidualAndJacobianThread::determineObjectWarehouses(), Moose::doDerivatives(), VariableResidual::execute(), GreaterThanLessThanPostprocessor::execute(), NodalNormalsEvaluator::execute(), NodalNormalsCorner::execute(), NodalNormalsPreprocessor::execute(), ExplicitTimeIntegrator::ExplicitTimeIntegrator(), InternalSideIndicatorBase::finalize(), NumNonlinearIterations::finalize(), BoundsBase::getDoFIndex(), NonlinearSystemBase::getNodeDofs(), NonlinearEigenSystem::getSNES(), SystemBase::getSubdomainsForVar(), NumLinearIterations::getValue(), Residual::getValue(), NumResidualEvaluations::getValue(), Moose::globalDofIndexToDerivative(), FVBoundaryCondition::hasFaceSide(), ExplicitTimeIntegrator::init(), ExplicitTimeIntegrator::initialSetup(), NonlinearSystemBase::initialSetup(), ActivateElementsUserObjectBase::initSolutions(), EigenExecutionerBase::inversePowerIteration(), Kernel::Kernel(), Moose::SlepcSupport::mooseSlepcEigenFormFunctionA(), Moose::SlepcSupport::mooseSlepcEigenFormFunctionAB(), Moose::SlepcSupport::mooseSlepcEigenFormFunctionB(), Moose::SlepcSupport::mooseSlepcEigenFormJacobianA(), MooseStaticCondensationPreconditioner::MooseStaticCondensationPreconditioner(), MooseVariableInterface< Real >::MooseVariableInterface(), EigenExecutionerBase::nonlinearSolve(), ComputeDiracThread::onElement(), ComputeNodalKernelBCJacobiansThread::onNode(), ComputeNodalKernelJacobiansThread::onNode(), VariableResidualNormsDebugOutput::output(), Moose::PetscSupport::petscLinearConverged(), Moose::PetscSupport::petscNonlinearConverged(), PhysicsBasedPreconditioner::PhysicsBasedPreconditioner(), PointwiseRenormalizeVector::PointwiseRenormalizeVector(), FEProblemBase::prepareAssembly(), SystemBase::prepareFace(), FEProblemBase::prepareFaceShapes(), FEProblemBase::prepareNeighborShapes(), FEProblemBase::prepareShapes(), FEProblemBase::reinitDirac(), FEProblemBase::reinitOffDiagScalars(), NonlinearSystem::residualAndJacobianTogether(), FEProblemBase::setResidual(), FEProblemBase::setResidualNeighbor(), PhysicsBasedPreconditioner::setup(), FVInterfaceKernel::setupData(), NonlinearSystemBase::shouldEvaluatePreSMOResidual(), ActuallyExplicitEuler::solve(), NonlinearEigenSystem::solve(), LStableDirk2::solve(), LStableDirk3::solve(), ImplicitMidpoint::solve(), ExplicitTVDRK2::solve(), AStableDirk4::solve(), LStableDirk4::solve(), ExplicitRK2::solve(), ExplicitSSPRungeKutta::solveStage(), NonlinearThread::subdomainChanged(), UserObject::systemNumber(), MultiAppDofCopyTransfer::transferDofObject(), FVFluxBC::uOnGhost(), FVFluxBC::uOnUSub(), FVFluxBC::updateCurrentFace(), and MortarConstraintBase::zeroInactiveLMDofs().

1150 {
1151  return system().number();
1152 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
unsigned int number() const

◆ nVariables()

unsigned int SystemBase::nVariables ( ) const
virtualinherited

Get the number of variables in this system.

Returns
the number of variables

Definition at line 883 of file SystemBase.C.

Referenced by AdaptivityAction::act(), FieldSplitPreconditionerTempl< MoosePreconditioner >::FieldSplitPreconditionerTempl(), FiniteDifferencePreconditioner::FiniteDifferencePreconditioner(), NonlinearSystemBase::getNodeDofs(), Assembly::init(), ExplicitTimeIntegrator::initialSetup(), MaxVarNDofsPerElem::onElement(), MaxVarNDofsPerNode::onNode(), PhysicsBasedPreconditioner::PhysicsBasedPreconditioner(), SingleMatrixPreconditioner::SingleMatrixPreconditioner(), and AuxiliarySystem::variableWiseRelativeSolutionDifferenceNorm().

884 {
885  unsigned int n = nFieldVariables();
886  n += _vars[0].scalars().size();
887 
888  return n;
889 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
unsigned int nFieldVariables() const
Get the number of field variables in this system.
Definition: SystemBase.C:892

◆ offDiagonalsInAutoScaling() [1/2]

bool NonlinearSystemBase::offDiagonalsInAutoScaling ( ) const
inlineinherited

Definition at line 686 of file NonlinearSystemBase.h.

Referenced by ComputeJacobianForScalingThread::computeOnElement().

bool _off_diagonals_in_auto_scaling
Whether to include off diagonals when determining automatic scaling factors.

◆ offDiagonalsInAutoScaling() [2/2]

void NonlinearSystemBase::offDiagonalsInAutoScaling ( bool  off_diagonals_in_auto_scaling)
inlineinherited

Definition at line 687 of file NonlinearSystemBase.h.

688  {
689  _off_diagonals_in_auto_scaling = off_diagonals_in_auto_scaling;
690  }
bool _off_diagonals_in_auto_scaling
Whether to include off diagonals when determining automatic scaling factors.

◆ onTimestepBegin()

void NonlinearSystemBase::onTimestepBegin ( )
inherited

Called at the beginning of the time step.

Definition at line 907 of file NonlinearSystemBase.C.

908 {
909  for (auto & ti : _time_integrators)
910  ti->preSolve();
911  if (_predictor.get())
912  _predictor->timestepSetup();
913 }
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
Definition: SystemBase.h:1049
std::shared_ptr< Predictor > _predictor
If predictor is active, this is non-NULL.

◆ overwriteNodeFace()

void NonlinearSystemBase::overwriteNodeFace ( NumericVector< Number > &  soln)
inherited

Called from explicit time stepping to overwrite boundary positions (explicit dynamics).

This will close/assemble the passed-in soln after overwrite

Definition at line 1629 of file NonlinearSystemBase.C.

Referenced by ActuallyExplicitEuler::solve().

1630 {
1631  // Overwrite results from integrator in case we have explicit dynamics contact constraints
1633  ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
1634  : static_cast<SubProblem &>(_fe_problem);
1635  const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
1636 
1637  for (const auto & it : penetration_locators)
1638  {
1639  PenetrationLocator & pen_loc = *(it.second);
1640 
1641  const auto & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
1642  const BoundaryID secondary_boundary = pen_loc._secondary_boundary;
1643  const BoundaryID primary_boundary = pen_loc._primary_boundary;
1644 
1645  if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, true))
1646  {
1647  const auto & constraints =
1648  _constraints.getActiveNodeFaceConstraints(secondary_boundary, true);
1649  for (const auto i : index_range(secondary_nodes))
1650  {
1651  const auto secondary_node_num = secondary_nodes[i];
1652  const Node & secondary_node = _mesh.nodeRef(secondary_node_num);
1653 
1654  if (secondary_node.processor_id() == processor_id())
1655  if (pen_loc._penetration_info[secondary_node_num])
1656  for (const auto & nfc : constraints)
1657  {
1658  if (!nfc->isExplicitConstraint())
1659  continue;
1660 
1661  // Return if this constraint does not correspond to the primary-secondary pair
1662  // prepared by the outer loops.
1663  // This continue statement is required when, e.g. one secondary surface constrains
1664  // more than one primary surface.
1665  if (nfc->secondaryBoundary() != secondary_boundary ||
1666  nfc->primaryBoundary() != primary_boundary)
1667  continue;
1668 
1669  nfc->overwriteBoundaryVariables(soln, secondary_node);
1670  }
1671  }
1672  }
1673  }
1674  soln.close();
1675 }
std::map< std::pair< BoundaryID, BoundaryID >, PenetrationLocator * > _penetration_locators
BoundaryID _secondary_boundary
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:834
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
std::vector< dof_id_type > _secondary_nodes
boundary_id_type BoundaryID
SubProblem & subproblem()
Definition: SystemBase.h:101
virtual GeometricSearchData & geomSearchData()=0
virtual void close()=0
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
MooseMesh & _mesh
Definition: SystemBase.h:991
processor_id_type processor_id() const
processor_id_type processor_id() const
auto index_range(const T &sizable)
BoundaryID _primary_boundary
NearestNodeLocator & _nearest_node

◆ perfGraph()

PerfGraph & PerfGraphInterface::perfGraph ( )
inherited

Get the PerfGraph.

Definition at line 78 of file PerfGraphInterface.C.

Referenced by CommonOutputAction::act(), PerfGraphData::finalize(), and PerfGraphOutput::output().

79 {
80  return _pg_moose_app.perfGraph();
81 }
MooseApp & _pg_moose_app
The MooseApp that owns the PerfGraph.
PerfGraph & perfGraph()
Get the PerfGraph for this app.
Definition: MooseApp.h:166

◆ postAddResidualObject()

virtual void NonlinearSystemBase::postAddResidualObject ( ResidualObject )
inlineprotectedvirtualinherited

◆ postInit()

virtual void SystemBase::postInit ( )
inlinevirtualinherited

Reimplemented in NonlinearEigenSystem.

Definition at line 162 of file SystemBase.h.

Referenced by NonlinearEigenSystem::postInit().

162 {}

◆ potentiallySetupFiniteDifferencing()

virtual void NonlinearSystemBase::potentiallySetupFiniteDifferencing ( )
inlinevirtualinherited

Create finite differencing contexts for assembly of the Jacobian and/or approximating the action of the Jacobian on vectors (e.g.

FD and/or MFFD respectively)

Reimplemented in NonlinearSystem.

Definition at line 709 of file NonlinearSystemBase.h.

Referenced by LStableDirk2::solve(), LStableDirk3::solve(), and LStableDirk4::solve().

709 {}

◆ prefix()

std::string SystemBase::prefix ( ) const
inherited
Returns
The prefix used for this system for solver settings for PETSc. This prefix is used to prevent collision of solver settings for different systems. Note that this prefix does not have a leading dash so it's appropriate for passage straight to PETSc APIs

Definition at line 1705 of file SystemBase.C.

Referenced by FieldSplitPreconditioner::FieldSplitPreconditioner(), MoosePreconditioner::initialSetup(), and FieldSplitPreconditioner::prefix().

1706 {
1707  return system().prefix_with_name() ? system().prefix() : "";
1708 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
std::string prefix() const
void prefix_with_name(bool value)

◆ preInit()

void NonlinearSystemBase::preInit ( )
overridevirtualinherited

This is called prior to the libMesh system has been init'd.

MOOSE system wrappers can use this method to add vectors and matrices to the libMesh system

Reimplemented from SolverSystem.

Definition at line 182 of file NonlinearSystemBase.C.

183 {
185 
186  if (_fe_problem.hasDampers())
187  setupDampers();
188 
189  if (_residual_copy.get())
190  _residual_copy->init(_sys.n_dofs(), false, SERIAL);
191 }
void setupDampers()
Setup damping stuff (called before we actually start)
bool hasDampers()
Whether or not this system has dampers.
dof_id_type n_dofs() const
SERIAL
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
std::unique_ptr< NumericVector< Number > > _residual_copy
Copy of the residual vector, or nullptr if a copy is not needed.
virtual void preInit() override
This is called prior to the libMesh system has been init&#39;d.
Definition: SolverSystem.C:32
libMesh::System & _sys

◆ prepare()

void SystemBase::prepare ( THREAD_ID  tid)
virtualinherited

Prepare the system for use.

Parameters
tidID of the thread

Definition at line 256 of file SystemBase.C.

Referenced by SubProblem::reinitElemFaceRef().

257 {
259  {
260  const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
262  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
263  for (const auto & var : vars)
264  var->clearDofIndices();
265 
266  for (const auto & var : active_elemental_moose_variables)
267  if (&(var->sys()) == this)
268  var->prepare();
269  }
270  else
271  {
272  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
273  for (const auto & var : vars)
274  var->prepare();
275  }
276 }
char ** vars
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:454
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition: SubProblem.C:460

◆ prepareFace()

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

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 279 of file SystemBase.C.

280 {
281  // We only need to do something if the element prepare was restricted
283  {
284  const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
286 
287  std::vector<MooseVariableFieldBase *> newly_prepared_vars;
288 
289  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
290  for (const auto & var : vars)
291  {
292  mooseAssert(&var->sys() == this,
293  "I will cry if we store variables in our warehouse that don't belong to us");
294 
295  // If it wasn't in the active list, we need to prepare it. This has the potential to duplicate
296  // prepare if we have these conditions:
297  //
298  // 1. We have a displaced problem
299  // 2. We are using AD
300  // 3. We are not using global AD indexing
301  //
302  // But I think I would rather risk duplicate prepare than introduce an additional member set
303  // variable for tracking prepared variables. Set insertion is slow and some simulations have a
304  // ton of variables
305  if (!active_elemental_moose_variables.count(var))
306  {
307  var->prepare();
308  newly_prepared_vars.push_back(var);
309  }
310  }
311 
312  // Make sure to resize the residual and jacobian datastructures for all the new variables
313  if (resize_data)
314  for (const auto var_ptr : newly_prepared_vars)
315  {
316  _subproblem.assembly(tid, number()).prepareVariable(var_ptr);
319  }
320  }
321 }
virtual bool checkNonlocalCouplingRequirement() const =0
char ** vars
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:454
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
void prepareVariableNonlocal(MooseVariableFieldBase *var)
Definition: Assembly.C:2772
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
void prepareVariable(MooseVariableFieldBase *var)
Used for preparing the dense residual and jacobian blocks for one particular variable.
Definition: Assembly.C:2744
virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition: SubProblem.C:460

◆ prepareLowerD()

void SystemBase::prepareLowerD ( THREAD_ID  tid)
virtualinherited

Prepare the system for use for lower dimensional elements.

Parameters
tidID of the thread

Definition at line 332 of file SystemBase.C.

Referenced by SubProblem::reinitLowerDElem().

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

◆ prepareNeighbor()

void SystemBase::prepareNeighbor ( THREAD_ID  tid)
virtualinherited

Prepare the system for use.

Parameters
tidID of the thread

Definition at line 324 of file SystemBase.C.

Referenced by SubProblem::reinitNeighborFaceRef().

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

◆ preSMOResidual()

Real NonlinearSystemBase::preSMOResidual ( ) const
inherited

The pre-SMO residual.

Definition at line 735 of file NonlinearSystemBase.C.

Referenced by Residual::getValue(), and NonlinearSystemBase::referenceResidual().

736 {
738  mooseError("pre-SMO residual is requested but not evaluated.");
739 
740  return _pre_smo_residual;
741 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
Real _pre_smo_residual
The pre-SMO residual, see setPreSMOResidual for a detailed explanation.
bool shouldEvaluatePreSMOResidual() const
We offer the option to check convergence against the pre-SMO residual.

◆ preSolve()

bool NonlinearSystemBase::preSolve ( )
protectedinherited

Perform some steps to get ready for the solver.

These include

  • zeroing iteration counters
  • setting initial solutions
  • possibly performing automatic scaling
  • forming a scaling vector which, at least at some point, was required when AD objects were used with non-unity scaling factors for nonlinear variables
    Returns
    Whether any exceptions were raised while running this method

Definition at line 4081 of file NonlinearSystemBase.C.

Referenced by NonlinearSystem::solve(), and NonlinearEigenSystem::solve().

4082 {
4083  // Clear the iteration counters
4084  _current_l_its.clear();
4085  _current_nl_its = 0;
4086 
4087  // Initialize the solution vector using a predictor and known values from nodal bcs
4089 
4090  // Now that the initial solution has ben set, potentially perform a residual/Jacobian evaluation
4091  // to determine variable scaling factors
4092  if (_automatic_scaling)
4093  {
4094  const bool scaling_succeeded = computeScaling();
4095  if (!scaling_succeeded)
4096  return false;
4097  }
4098 
4099  // We do not know a priori what variable a global degree of freedom corresponds to, so we need a
4100  // map from global dof to scaling factor. We just use a ghosted NumericVector for that mapping
4102 
4103  return true;
4104 }
std::vector< unsigned int > _current_l_its
bool _automatic_scaling
Whether to automatically scale the variables.
Definition: SystemBase.h:1055
bool computeScaling()
Method used to obtain scaling factors for variables.
void assembleScalingVector()
Assemble the numeric vector of scaling factors such that it can be used during assembly of the system...

◆ printAllVariableNorms()

void NonlinearSystemBase::printAllVariableNorms ( bool  state)
inlineinherited

Force the printing of all variable norms after each solve.

Todo:
{Remove after output update

Definition at line 551 of file NonlinearSystemBase.h.

◆ queryTimeIntegrator()

const TimeIntegrator * SystemBase::queryTimeIntegrator ( const unsigned int  var_num) const
inherited

Retrieve the time integrator that integrates the given variable's equation.

If no suitable time integrator is found (this could happen for instance if we're solving a non-transient problem), then a nullptr will be returned

Definition at line 1665 of file SystemBase.C.

Referenced by SystemBase::getTimeIntegrator(), HDGKernel::HDGKernel(), and MooseVariableData< OutputType >::MooseVariableData().

1666 {
1667  for (auto & ti : _time_integrators)
1668  if (ti->integratesVar(var_num))
1669  return ti.get();
1670 
1671  return nullptr;
1672 }
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
Definition: SystemBase.h:1049

◆ referenceResidual()

Real NonlinearSystemBase::referenceResidual ( ) const
inherited

The reference residual used in relative convergence check.

Definition at line 729 of file NonlinearSystemBase.C.

Referenced by DefaultNonlinearConvergence::checkConvergence(), and EigenExecutionerBase::inversePowerIteration().

730 {
732 }
Real preSMOResidual() const
The pre-SMO residual.
Real initialResidual() const
The initial residual.
const bool & usePreSMOResidual() const
Whether we are using pre-SMO residual in relative convergence checks.

◆ registerTimedSection() [1/2]

PerfID PerfGraphInterface::registerTimedSection ( const std::string &  section_name,
const unsigned int  level 
) const
protectedinherited

Call to register a named section for timing.

Parameters
section_nameThe name of the code section to be timed
levelThe importance of the timer - lower is more important (0 will always come out)
Returns
The ID of the section - use when starting timing

Definition at line 53 of file PerfGraphInterface.C.

55 {
56  const auto timed_section_name = timedSectionName(section_name);
57  if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
58  return moose::internal::getPerfGraphRegistry().registerSection(timed_section_name, level);
59  else
60  return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
61 }
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
std::string timedSectionName(const std::string &section_name) const
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID The name of the section.
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.

◆ registerTimedSection() [2/2]

PerfID PerfGraphInterface::registerTimedSection ( const std::string &  section_name,
const unsigned int  level,
const std::string &  live_message,
const bool  print_dots = true 
) const
protectedinherited

Call to register a named section for timing.

Parameters
section_nameThe name of the code section to be timed
levelThe importance of the timer - lower is more important (0 will always come out)
live_messageThe message to be printed to the screen during execution
print_dotsWhether or not progress dots should be printed for this section
Returns
The ID of the section - use when starting timing

Definition at line 64 of file PerfGraphInterface.C.

68 {
69  const auto timed_section_name = timedSectionName(section_name);
70  if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
72  timedSectionName(section_name), level, live_message, print_dots);
73  else
74  return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
75 }
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
std::string timedSectionName(const std::string &section_name) const
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID The name of the section.
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.

◆ reinit()

virtual void SystemBase::reinit ( )
inlinevirtualinherited

Reinitialize the system when the degrees of freedom in this system have changed.

This is called after the libMesh system has been reinit'd

Reimplemented in NonlinearEigenSystem.

Definition at line 168 of file SystemBase.h.

Referenced by NonlinearEigenSystem::reinit().

168 {}

◆ reinitElem()

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

Reinit an element assembly info.

Parameters
elemWhich element we are reinitializing for
tidID of the thread

Reimplemented in AuxiliarySystem.

Definition at line 340 of file SystemBase.C.

341 {
343  {
344  const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
346  for (const auto & var : active_elemental_moose_variables)
347  if (&(var->sys()) == this)
348  var->computeElemValues();
349  }
350  else
351  {
352  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
353  for (const auto & var : vars)
354  var->computeElemValues();
355  }
356 
357  if (system().has_static_condensation())
358  for (auto & [tag, matrix] : _active_tagged_matrices)
359  {
360  libmesh_ignore(tag);
361  cast_ptr<StaticCondensation *>(matrix)->set_current_elem(*elem);
362  }
363 }
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...
Definition: SystemBase.h:1025
char ** vars
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:454
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
void libmesh_ignore(const Args &...)
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition: SubProblem.C:460

◆ reinitElemFace()

void SystemBase::reinitElemFace ( const Elem elem,
unsigned int  side,
THREAD_ID  tid 
)
virtualinherited

Reinit assembly info for a side of an element.

Parameters
elemThe element
sideSide of of the element
tidThread ID

Reimplemented in AuxiliarySystem.

Definition at line 366 of file SystemBase.C.

Referenced by SubProblem::reinitElemFaceRef().

367 {
368  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
369  for (const auto & var : vars)
370  var->computeElemValuesFace();
371 }
char ** vars
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ reinitIncrementAtNodeForDampers()

void NonlinearSystemBase::reinitIncrementAtNodeForDampers ( THREAD_ID  tid,
const std::set< MooseVariable *> &  damped_vars 
)
inherited

Compute the incremental change in variables at nodes for dampers.

Called before we use damping

Parameters
tidThread ID
damped_varsSet of variables for which increment is to be computed

Definition at line 3569 of file NonlinearSystemBase.C.

Referenced by ComputeNodalDampingThread::onNode().

3571 {
3572  for (const auto & var : damped_vars)
3573  var->computeIncrementAtNode(*_increment_vec);
3574 }
NumericVector< Number > * _increment_vec
increment vector

◆ reinitIncrementAtQpsForDampers()

void NonlinearSystemBase::reinitIncrementAtQpsForDampers ( THREAD_ID  tid,
const std::set< MooseVariable *> &  damped_vars 
)
inherited

Compute the incremental change in variables at QPs for dampers.

Called before we use damping

Parameters
tidThread ID
damped_varsSet of variables for which increment is to be computed

Definition at line 3561 of file NonlinearSystemBase.C.

Referenced by ComputeElemDampingThread::onElement().

3563 {
3564  for (const auto & var : damped_vars)
3565  var->computeIncrementAtQps(*_increment_vec);
3566 }
NumericVector< Number > * _increment_vec
increment vector

◆ reinitLowerD()

void SystemBase::reinitLowerD ( THREAD_ID  tid)
virtualinherited

Compute the values of the variables on the lower dimensional element.

Definition at line 390 of file SystemBase.C.

Referenced by SubProblem::reinitLowerDElem().

391 {
392  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
393  for (const auto & var : vars)
394  var->computeLowerDValues();
395 }
char ** vars
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ reinitMortarFunctors()

void NonlinearSystemBase::reinitMortarFunctors ( )
inherited

Update the mortar functors if the mesh has changed.

Definition at line 194 of file NonlinearSystemBase.C.

195 {
196  // reinit is called on meshChanged() in FEProblemBase. We could implement meshChanged() instead.
197  // Subdomains might have changed
198  for (auto & functor : _displaced_mortar_functors)
199  functor.second.setupMortarMaterials();
200  for (auto & functor : _undisplaced_mortar_functors)
201  functor.second.setupMortarMaterials();
202 }
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _undisplaced_mortar_functors
Functors for computing undisplaced mortar constraints.
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _displaced_mortar_functors
Functors for computing displaced mortar constraints.

◆ reinitNeighbor()

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

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

Definition at line 382 of file SystemBase.C.

383 {
384  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
385  for (const auto & var : vars)
386  var->computeNeighborValues();
387 }
char ** vars
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ reinitNeighborFace()

void SystemBase::reinitNeighborFace ( const Elem elem,
unsigned int  side,
THREAD_ID  tid 
)
virtualinherited

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

Definition at line 374 of file SystemBase.C.

Referenced by SubProblem::reinitNeighborFaceRef().

375 {
376  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
377  for (const auto & var : vars)
378  var->computeNeighborValuesFace();
379 }
char ** vars
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ reinitNode()

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

Reinit nodal assembly info.

Parameters
nodeNode to reinit for
tidThread ID

Definition at line 398 of file SystemBase.C.

399 {
400  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
401  for (const auto & var : vars)
402  {
403  var->reinitNode();
404  if (var->isNodalDefined())
405  var->computeNodalValues();
406  }
407 }
char ** vars
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ reinitNodeFace() [1/3]

void SystemBase::reinitNodeFace
inherited

Reinit nodal assembly info on a face.

Parameters
nodeNode to reinit
bnd_idBoundary ID
tidThread ID

Definition at line 410 of file SystemBase.C.

411 {
412  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
413  for (const auto & var : vars)
414  {
415  var->reinitNode();
416  if (var->isNodalDefined())
417  var->computeNodalValues();
418  }
419 }
char ** vars
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ reinitNodeFace() [2/3]

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

Reinit nodal assembly info on a face.

Parameters
nodeNode to reinit
bnd_idBoundary ID
tidThread ID

Definition at line 410 of file SystemBase.C.

411 {
412  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
413  for (const auto & var : vars)
414  {
415  var->reinitNode();
416  if (var->isNodalDefined())
417  var->computeNodalValues();
418  }
419 }
char ** vars
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ reinitNodeFace() [3/3]

void NonlinearSystemBase::reinitNodeFace ( const Node secondary_node,
const BoundaryID  secondary_boundary,
const PenetrationInfo info,
const bool  displaced 
)
protectedinherited

Reinitialize quantities such as variables, residuals, Jacobians, materials for node-face constraints.

Definition at line 1109 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::constraintJacobians(), NonlinearSystemBase::constraintResiduals(), and NonlinearSystemBase::setConstraintSecondaryValues().

1113 {
1114  auto & subproblem = displaced ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
1115  : static_cast<SubProblem &>(_fe_problem);
1116 
1117  const Elem * primary_elem = info._elem;
1118  unsigned int primary_side = info._side_num;
1119  std::vector<Point> points;
1120  points.push_back(info._closest_point);
1121 
1122  // *These next steps MUST be done in this order!*
1123  // ADL: This is a Chesterton's fence situation. I don't know which calls exactly the above comment
1124  // is referring to. If I had to guess I would guess just the reinitNodeFace and prepareAssembly
1125  // calls since the former will size the variable's dof indices and then the latter will resize the
1126  // residual/Jacobian based off the variable's cached dof indices size
1127 
1128  // This reinits the variables that exist on the secondary node
1129  _fe_problem.reinitNodeFace(&secondary_node, secondary_boundary, 0);
1130 
1131  // This will set aside residual and jacobian space for the variables that have dofs on
1132  // the secondary node
1134 
1135  _fe_problem.setNeighborSubdomainID(primary_elem, 0);
1136 
1137  //
1138  // Reinit material on undisplaced mesh
1139  //
1140 
1141  const Elem * const undisplaced_primary_elem =
1142  displaced ? _mesh.elemPtr(primary_elem->id()) : primary_elem;
1143  const Point undisplaced_primary_physical_point =
1144  [&points, displaced, primary_elem, undisplaced_primary_elem]()
1145  {
1146  if (displaced)
1147  {
1148  const Point reference_point =
1149  FEMap::inverse_map(primary_elem->dim(), primary_elem, points[0]);
1150  return FEMap::map(primary_elem->dim(), undisplaced_primary_elem, reference_point);
1151  }
1152  else
1153  // If our penetration locator is on the reference mesh, then our undisplaced
1154  // physical point is simply the point coming from the penetration locator
1155  return points[0];
1156  }();
1157 
1159  undisplaced_primary_elem, primary_side, {undisplaced_primary_physical_point}, 0);
1160  // Stateful material properties are only initialized for neighbor material data for internal faces
1161  // for discontinuous Galerkin methods or for conforming interfaces for interface kernels. We don't
1162  // have either of those use cases here where we likely have disconnected meshes
1163  _fe_problem.reinitMaterialsNeighbor(primary_elem->subdomain_id(), 0, /*swap_stateful=*/false);
1164 
1165  // Reinit points for constraint enforcement
1166  if (displaced)
1167  subproblem.reinitNeighborPhys(primary_elem, primary_side, points, 0);
1168 }
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
virtual Elem * elemPtr(const dof_id_type i)
Definition: MooseMesh.C:3113
MPI_Info info
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid) override
dof_id_type id() const
void reinitMaterialsNeighbor(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase *> *reinit_mats=nullptr)
reinit materials on the neighboring element face
SubProblem & subproblem()
Definition: SystemBase.h:101
virtual void prepareAssembly(const THREAD_ID tid) override
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
MooseMesh & _mesh
Definition: SystemBase.h:991
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override

◆ reinitNodes()

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

Reinit variables at a set of nodes.

Parameters
nodesList of node ids to reinit
tidThread ID

Definition at line 422 of file SystemBase.C.

423 {
424  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
425  for (const auto & var : vars)
426  {
427  var->reinitNodes(nodes);
428  var->computeNodalValues();
429  }
430 }
char ** vars
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ reinitNodesNeighbor()

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

Reinit variables at a set of neighbor nodes.

Parameters
nodesList of node ids to reinit
tidThread ID

Definition at line 433 of file SystemBase.C.

434 {
435  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
436  for (const auto & var : vars)
437  {
438  var->reinitNodesNeighbor(nodes);
439  var->computeNodalNeighborValues();
440  }
441 }
char ** vars
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ reinitScalars()

void SystemBase::reinitScalars ( THREAD_ID  tid,
bool  reinit_for_derivative_reordering = false 
)
virtualinherited

Reinit scalar varaibles.

Parameters
tidThread ID
reinit_for_derivative_reorderingA flag indicating whether we are reinitializing for the purpose of re-ordering derivative information for ADNodalBCs

Definition at line 444 of file SystemBase.C.

445 {
446  const std::vector<MooseVariableScalar *> & vars = _vars[tid].scalars();
447  for (const auto & var : vars)
448  var->reinit(reinit_for_derivative_reordering);
449 }
char ** vars
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ removeMatrix()

void SystemBase::removeMatrix ( TagID  tag)
inherited

Removes a matrix with a given tag.

Parameters
tag_nameThe name of the tag

Definition at line 590 of file SystemBase.C.

591 {
592  if (!_subproblem.matrixTagExists(tag_id))
593  mooseError("Cannot remove the matrix with TagID ",
594  tag_id,
595  "\nin system '",
596  name(),
597  "', because that tag does not exist in the problem");
598 
599  if (hasMatrix(tag_id))
600  {
601  const auto matrix_name = _subproblem.matrixTagName(tag_id);
602  system().remove_matrix(matrix_name);
603  _tagged_matrices[tag_id] = nullptr;
604  }
605 }
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:1023
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:360
virtual const std::string & name() const
Definition: SystemBase.C:1332
void remove_matrix(std::string_view mat_name)
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:328
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:357

◆ removeVector() [1/2]

void SystemBase::removeVector ( const std::string &  name)
inherited

Remove a vector from the system with the given name.

Definition at line 1326 of file SystemBase.C.

Referenced by SystemBase::restoreOldSolutions().

1327 {
1329 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual const std::string & name() const
Definition: SystemBase.C:1332
void remove_vector(std::string_view vec_name)

◆ removeVector() [2/2]

void SystemBase::removeVector ( TagID  tag_id)
inherited

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

Parameters
tag_idTag ID

Definition at line 700 of file SystemBase.C.

701 {
702  if (!_subproblem.vectorTagExists(tag_id))
703  mooseError("Cannot remove the vector with TagID ",
704  tag_id,
705  "\nin system '",
706  name(),
707  "', because that tag does not exist in the problem");
708 
709  if (hasVector(tag_id))
710  {
711  auto vector_name = _subproblem.vectorTagName(tag_id);
712  system().remove_vector(vector_name);
713  _tagged_vectors[tag_id] = nullptr;
714  }
715 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:916
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual const std::string & name() const
Definition: SystemBase.C:1332
void remove_vector(std::string_view vec_name)
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:201
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:221
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:1021

◆ residualAndJacobianTogether()

void DumpObjectsNonlinearSystem::residualAndJacobianTogether ( )
inlineoverridevirtual

Call this method if you want the residual and Jacobian to be computed simultaneously.

Implements NonlinearSystemBase.

Definition at line 41 of file DumpObjectsNonlinearSystem.h.

41 {}

◆ residualCopy()

NumericVector< Number > & NonlinearSystemBase::residualCopy ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 3416 of file NonlinearSystemBase.C.

3417 {
3418  if (!_residual_copy.get())
3420 
3421  return *_residual_copy;
3422 }
const Parallel::Communicator & _communicator
std::unique_ptr< NumericVector< Number > > _residual_copy
Copy of the residual vector, or nullptr if a copy is not needed.

◆ residualGhosted()

NumericVector< Number > & NonlinearSystemBase::residualGhosted ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 3425 of file NonlinearSystemBase.C.

3426 {
3427  _need_residual_ghosted = true;
3428  if (!_residual_ghosted)
3429  {
3430  // The first time we realize we need a ghosted residual vector,
3431  // we add it.
3432  _residual_ghosted = &addVector("residual_ghosted", false, GHOSTED);
3433 
3434  // If we've already realized we need time and/or non-time
3435  // residual vectors, but we haven't yet realized they need to be
3436  // ghosted, fix that now.
3437  //
3438  // If an application changes its mind, the libMesh API lets us
3439  // change the vector.
3440  if (_Re_time)
3441  {
3442  const auto vector_name = _subproblem.vectorTagName(_Re_time_tag);
3443  _Re_time = &system().add_vector(vector_name, false, GHOSTED);
3444  }
3445  if (_Re_non_time)
3446  {
3447  const auto vector_name = _subproblem.vectorTagName(_Re_non_time_tag);
3448  _Re_non_time = &system().add_vector(vector_name, false, GHOSTED);
3449  }
3450  }
3451  return *_residual_ghosted;
3452 }
NumericVector< Number > * _Re_time
residual vector for time contributions
TagID _Re_time_tag
Tag for time contribution residual.
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
TagID _Re_non_time_tag
Tag for non-time contribution residual.
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:221
virtual libMesh::System & system() override
Get the reference to the libMesh system.

◆ residualSetup()

void NonlinearSystemBase::residualSetup ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 1678 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualAndJacobianInternal(), and NonlinearSystemBase::computeResidualInternal().

1679 {
1680  TIME_SECTION("residualSetup", 3);
1681 
1683 
1684  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1685  {
1686  _kernels.residualSetup(tid);
1689  if (_doing_dg)
1695  }
1700 
1701  // Avoid recursion
1702  if (this == &_fe_problem.currentNonlinearSystem())
1705 }
virtual void residualSetup(THREAD_ID tid=0) const
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
void residualSetup() override
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
bool _doing_dg
true if DG is active (optimization reasons)
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:172
NonlinearSystemBase & currentNonlinearSystem()
MooseObjectTagWarehouse< KernelBase > _kernels
ConstraintWarehouse _constraints
Constraints storage object.
MooseApp & _app
Definition: SystemBase.h:988
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
void resetSolutionInvalidCurrentIteration()
Reset the number of solution invalid occurrences back to zero.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
virtual void residualSetup()
Definition: SystemBase.C:1591
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ residualVector()

NumericVector< Number > & NonlinearSystemBase::residualVector ( TagID  tag)
inherited

Return a residual vector that is associated with the residual tag.

Definition at line 1039 of file NonlinearSystemBase.C.

1040 {
1041  mooseDeprecated("Please use getVector()");
1042  switch (tag)
1043  {
1044  case 0:
1045  return getResidualNonTimeVector();
1046 
1047  case 1:
1048  return getResidualTimeVector();
1049 
1050  default:
1051  mooseError("The required residual vector is not available");
1052  }
1053 }
NumericVector< Number > & getResidualTimeVector()
Return a numeric vector that is associated with the time tag.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:384
NumericVector< Number > & getResidualNonTimeVector()
Return a numeric vector that is associated with the nontime tag.

◆ residualVectorTag()

TagID NonlinearSystemBase::residualVectorTag ( ) const
inlineoverridevirtualinherited

◆ restoreOldSolutions()

void SystemBase::restoreOldSolutions ( )
virtualinherited

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

Definition at line 542 of file SystemBase.C.

543 {
544  const auto states =
545  _solution_states[static_cast<unsigned short>(Moose::SolutionIterationType::Time)].size();
546  if (states > 1)
547  for (unsigned int i = 1; i <= states - 1; ++i)
548  if (_saved_solution_states[i])
549  {
551  removeVector("save_solution_state_" + std::to_string(i));
552  _saved_solution_states[i] = nullptr;
553  }
554 
556  {
558  removeVector("save_solution_dot_old");
559  _saved_dot_old = nullptr;
560  }
562  {
564  removeVector("save_solution_dotdot_old");
565  _saved_dotdot_old = nullptr;
566  }
567 }
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).
Definition: SystemBase.C:1423
virtual NumericVector< Number > * solutionUDotDotOld()
Definition: SystemBase.h:264
virtual NumericVector< Number > * solutionUDotOld()
Definition: SystemBase.h:263
NumericVector< Real > * _saved_dot_old
Definition: SystemBase.h:1034
void removeVector(const std::string &name)
Remove a vector from the system with the given name.
Definition: SystemBase.C:1326
NumericVector< Real > * _saved_dotdot_old
Definition: SystemBase.h:1035
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1084
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1086

◆ restoreSolutions()

void SolverSystem::restoreSolutions ( )
finaloverridevirtualinherited

Restore current solutions (call after your solve failed)

Reimplemented from SystemBase.

Definition at line 43 of file SolverSystem.C.

44 {
45  // call parent
47  // and update _current_solution
49 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:105
std::unique_ptr< NumericVector< Number > > current_local_solution
virtual void restoreSolutions()
Restore current solutions (call after your solve failed)
Definition: SystemBase.C:1309

◆ RHS()

virtual NumericVector<Number>& DumpObjectsNonlinearSystem::RHS ( )
inlineoverridevirtual

Implements NonlinearSystemBase.

Definition at line 33 of file DumpObjectsNonlinearSystem.h.

33 { return *_dummy; }
NumericVector< Number > * _dummy

◆ saveOldSolutions()

void SystemBase::saveOldSolutions ( )
virtualinherited

Save the old and older solutions.

Definition at line 510 of file SystemBase.C.

511 {
512  const auto states =
513  _solution_states[static_cast<unsigned short>(Moose::SolutionIterationType::Time)].size();
514  if (states > 1)
515  {
516  _saved_solution_states.resize(states);
517  for (unsigned int i = 1; i <= states - 1; ++i)
518  if (!_saved_solution_states[i])
520  &addVector("save_solution_state_" + std::to_string(i), false, PARALLEL);
521 
522  for (unsigned int i = 1; i <= states - 1; ++i)
524  }
525 
527  _saved_dot_old = &addVector("save_solution_dot_old", false, PARALLEL);
529  _saved_dotdot_old = &addVector("save_solution_dotdot_old", false, PARALLEL);
530 
531  if (solutionUDotOld())
533 
534  if (solutionUDotDotOld())
536 }
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).
Definition: SystemBase.C:1423
virtual NumericVector< Number > * solutionUDotDotOld()
Definition: SystemBase.h:264
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
virtual NumericVector< Number > * solutionUDotOld()
Definition: SystemBase.h:263
NumericVector< Real > * _saved_dot_old
Definition: SystemBase.h:1034
NumericVector< Real > * _saved_dotdot_old
Definition: SystemBase.h:1035
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1084
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1086

◆ scalingGroupVariables()

void NonlinearSystemBase::scalingGroupVariables ( const std::vector< std::vector< std::string >> &  scaling_group_variables)
inlineinherited

Definition at line 675 of file NonlinearSystemBase.h.

676  {
677  _scaling_group_variables = scaling_group_variables;
678  }
std::vector< std::vector< std::string > > _scaling_group_variables
A container of variable groupings that can be used in scaling calculations.

◆ serializedSolution()

NumericVector< Number > & SystemBase::serializedSolution ( )
virtualinherited

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

Reimplemented in DisplacedSystem.

Definition at line 1638 of file SystemBase.C.

Referenced by PNGOutput::calculateRescalingValues(), PNGOutput::makeMeshFunc(), and DisplacedSystem::serializedSolution().

1639 {
1640  if (!_serialized_solution.get())
1641  {
1643  _serialized_solution->init(system().n_dofs(), false, SERIAL);
1644  }
1645 
1646  return *_serialized_solution;
1647 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
const Parallel::Communicator & _communicator
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed...
Definition: SystemBase.h:1068

◆ serializeSolution()

void SolverSystem::serializeSolution ( )
inherited

Definition at line 52 of file SolverSystem.C.

Referenced by SolverSystem::setSolution().

53 {
54  if (_serialized_solution.get())
55  {
56  if (!_serialized_solution->initialized() || _serialized_solution->size() != system().n_dofs())
57  {
58  _serialized_solution->clear();
59  _serialized_solution->init(system().n_dofs(), false, SERIAL);
60  }
61 
63  }
64 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed...
Definition: SystemBase.h:1068
dof_id_type n_dofs() const
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:105
virtual void localize(std::vector< T > &v_local) const=0

◆ setActiveScalarVariableCoupleableVectorTags()

void SystemBase::setActiveScalarVariableCoupleableVectorTags ( const std::set< TagID > &  vtags,
THREAD_ID  tid 
)
inherited

Set the active vector tags for the scalar variables.

Definition at line 1618 of file SystemBase.C.

Referenced by SubProblem::setActiveScalarVariableCoupleableVectorTags().

1620 {
1621  _vars[tid].setActiveScalarVariableCoupleableVectorTags(vtags);
1622 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ setActiveVariableCoupleableVectorTags()

void SystemBase::setActiveVariableCoupleableVectorTags ( const std::set< TagID > &  vtags,
THREAD_ID  tid 
)
inherited

Set the active vector tags for the variables.

Definition at line 1612 of file SystemBase.C.

Referenced by SubProblem::setActiveFEVariableCoupleableVectorTags().

1613 {
1614  _vars[tid].setActiveVariableCoupleableVectorTags(vtags);
1615 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ setConstraintSecondaryValues()

void NonlinearSystemBase::setConstraintSecondaryValues ( NumericVector< Number > &  solution,
bool  displaced 
)
inherited

Sets the value of constrained variables in the solution vector.

Definition at line 1171 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::setInitialSolution().

1172 {
1173 
1174  if (displaced)
1175  mooseAssert(_fe_problem.getDisplacedProblem(),
1176  "If we're calling this method with displaced = true, then we better well have a "
1177  "displaced problem");
1178  auto & subproblem = displaced ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
1179  : static_cast<SubProblem &>(_fe_problem);
1180  const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
1181 
1182  bool constraints_applied = false;
1183 
1184  for (const auto & it : penetration_locators)
1185  {
1186  PenetrationLocator & pen_loc = *(it.second);
1187 
1188  std::vector<dof_id_type> & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
1189 
1190  BoundaryID secondary_boundary = pen_loc._secondary_boundary;
1191  BoundaryID primary_boundary = pen_loc._primary_boundary;
1192 
1193  if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, displaced))
1194  {
1195  const auto & constraints =
1196  _constraints.getActiveNodeFaceConstraints(secondary_boundary, displaced);
1197  std::unordered_set<unsigned int> needed_mat_props;
1198  for (const auto & constraint : constraints)
1199  {
1200  const auto & mp_deps = constraint->getMatPropDependencies();
1201  needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
1202  }
1203  _fe_problem.setActiveMaterialProperties(needed_mat_props, /*tid=*/0);
1204 
1205  for (unsigned int i = 0; i < secondary_nodes.size(); i++)
1206  {
1207  dof_id_type secondary_node_num = secondary_nodes[i];
1208  Node & secondary_node = _mesh.nodeRef(secondary_node_num);
1209 
1210  if (secondary_node.processor_id() == processor_id())
1211  {
1212  if (pen_loc._penetration_info[secondary_node_num])
1213  {
1214  PenetrationInfo & info = *pen_loc._penetration_info[secondary_node_num];
1215 
1216  reinitNodeFace(secondary_node, secondary_boundary, info, displaced);
1217 
1218  for (const auto & nfc : constraints)
1219  {
1220  if (nfc->isExplicitConstraint())
1221  continue;
1222  // Return if this constraint does not correspond to the primary-secondary pair
1223  // prepared by the outer loops.
1224  // This continue statement is required when, e.g. one secondary surface constrains
1225  // more than one primary surface.
1226  if (nfc->secondaryBoundary() != secondary_boundary ||
1227  nfc->primaryBoundary() != primary_boundary)
1228  continue;
1229 
1230  if (nfc->shouldApply())
1231  {
1232  constraints_applied = true;
1233  nfc->computeSecondaryValue(solution);
1234  }
1235 
1236  if (nfc->hasWritableCoupledVariables())
1237  {
1238  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1239  for (auto * var : nfc->getWritableCoupledVariables())
1240  {
1241  if (var->isNodalDefined())
1242  var->insert(_fe_problem.getAuxiliarySystem().solution());
1243  }
1244  }
1245  }
1246  }
1247  }
1248  }
1249  }
1250  }
1251 
1252  // go over NodeELemConstraints
1253  std::set<dof_id_type> unique_secondary_node_ids;
1254 
1255  for (const auto & secondary_id : _mesh.meshSubdomains())
1256  {
1257  for (const auto & primary_id : _mesh.meshSubdomains())
1258  {
1259  if (_constraints.hasActiveNodeElemConstraints(secondary_id, primary_id, displaced))
1260  {
1261  const auto & constraints =
1262  _constraints.getActiveNodeElemConstraints(secondary_id, primary_id, displaced);
1263 
1264  // get unique set of ids of all nodes on current block
1265  unique_secondary_node_ids.clear();
1266  const MeshBase & meshhelper = _mesh.getMesh();
1267  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
1268  meshhelper.active_subdomain_elements_end(secondary_id)))
1269  {
1270  for (auto & n : elem->node_ref_range())
1271  unique_secondary_node_ids.insert(n.id());
1272  }
1273 
1274  for (auto secondary_node_id : unique_secondary_node_ids)
1275  {
1276  Node & secondary_node = _mesh.nodeRef(secondary_node_id);
1277 
1278  // check if secondary node is on current processor
1279  if (secondary_node.processor_id() == processor_id())
1280  {
1281  // This reinits the variables that exist on the secondary node
1282  _fe_problem.reinitNodeFace(&secondary_node, secondary_id, 0);
1283 
1284  // This will set aside residual and jacobian space for the variables that have dofs
1285  // on the secondary node
1287 
1288  for (const auto & nec : constraints)
1289  {
1290  if (nec->shouldApply())
1291  {
1292  constraints_applied = true;
1293  nec->computeSecondaryValue(solution);
1294  }
1295  }
1296  }
1297  }
1298  }
1299  }
1300  }
1301 
1302  // See if constraints were applied anywhere
1303  _communicator.max(constraints_applied);
1304 
1305  if (constraints_applied)
1306  {
1307  solution.close();
1308  update();
1309  }
1310 }
void setActiveMaterialProperties(const std::unordered_set< unsigned int > &mat_prop_ids, const THREAD_ID tid)
Record and set the material properties required by the current computing thread.
std::map< std::pair< BoundaryID, BoundaryID >, PenetrationLocator * > _penetration_locators
BoundaryID _secondary_boundary
MPI_Info info
NumericVector< Number > & solution()
Definition: SystemBase.h:196
Data structure used to hold penetration information.
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
const Parallel::Communicator & _communicator
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
bool hasActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
const std::vector< std::shared_ptr< NodeElemConstraintBase > > & getActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:834
void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:1235
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
std::vector< dof_id_type > _secondary_nodes
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3448
boundary_id_type BoundaryID
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
SubProblem & subproblem()
Definition: SystemBase.h:101
virtual GeometricSearchData & geomSearchData()=0
AuxiliarySystem & getAuxiliarySystem()
virtual void prepareAssembly(const THREAD_ID tid) override
virtual void close()=0
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
MooseMesh & _mesh
Definition: SystemBase.h:991
void max(const T &r, T &o, Request &req) const
void reinitNodeFace(const Node &secondary_node, const BoundaryID secondary_boundary, const PenetrationInfo &info, const bool displaced)
Reinitialize quantities such as variables, residuals, Jacobians, materials for node-face constraints...
processor_id_type processor_id() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
processor_id_type processor_id() const
BoundaryID _primary_boundary
uint8_t dof_id_type
NearestNodeLocator & _nearest_node
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:3171

◆ setInitialResidual()

void NonlinearSystemBase::setInitialResidual ( Real  r)
inherited

Record the initial residual (for later relative convergence check)

Definition at line 750 of file NonlinearSystemBase.C.

Referenced by DefaultNonlinearConvergence::checkConvergence().

751 {
752  _initial_residual = r;
753 }
Real _initial_residual
The initial (i.e., 0th nonlinear iteration) residual, see setPreSMOResidual for a detailed explanatio...

◆ setInitialSolution()

void NonlinearSystemBase::setInitialSolution ( )
inherited

Definition at line 916 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::preSolve().

917 {
919 
920  NumericVector<Number> & initial_solution(solution());
921  if (_predictor.get())
922  {
923  if (_predictor->shouldApply())
924  {
925  TIME_SECTION("applyPredictor", 2, "Applying Predictor");
926 
927  _predictor->apply(initial_solution);
928  _fe_problem.predictorCleanup(initial_solution);
929  }
930  else
931  _console << " Skipping predictor this step" << std::endl;
932  }
933 
934  // do nodal BC
935  {
936  TIME_SECTION("initialBCs", 2, "Applying BCs To Initial Condition");
937 
939  for (const auto & bnode : bnd_nodes)
940  {
941  BoundaryID boundary_id = bnode->_bnd_id;
942  Node * node = bnode->_node;
943 
944  if (node->processor_id() == processor_id())
945  {
946  // reinit variables in nodes
947  _fe_problem.reinitNodeFace(node, boundary_id, 0);
948 
950  {
951  const auto & preset_bcs = _preset_nodal_bcs.getActiveBoundaryObjects(boundary_id);
952  for (const auto & preset_bc : preset_bcs)
953  preset_bc->computeValue(initial_solution);
954  }
956  {
957  const auto & preset_bcs_res = _ad_preset_nodal_bcs.getActiveBoundaryObjects(boundary_id);
958  for (const auto & preset_bc : preset_bcs_res)
959  preset_bc->computeValue(initial_solution);
960  }
961  }
962  }
963  }
964 
965  _sys.solution->close();
966  update();
967 
968  // Set constraint secondary values
969  setConstraintSecondaryValues(initial_solution, false);
970 
972  setConstraintSecondaryValues(initial_solution, true);
973 }
virtual void predictorCleanup(NumericVector< libMesh::Number > &ghosted_solution)
Perform cleanup tasks after application of predictor to solution vector.
NumericVector< Number > & solution()
Definition: SystemBase.h:196
void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:1235
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
const ConstBndNodeRange & getCurrentAlgebraicBndNodeRange()
virtual void deactivateAllMatrixTags()
Make matrices inactive.
Definition: SystemBase.C:1111
MooseObjectWarehouse< DirichletBCBase > _preset_nodal_bcs
boundary_id_type BoundaryID
std::unique_ptr< NumericVector< Number > > solution
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
libMesh::System & _sys
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
processor_id_type processor_id() const
std::shared_ptr< Predictor > _predictor
If predictor is active, this is non-NULL.
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
processor_id_type processor_id() const
void setConstraintSecondaryValues(NumericVector< Number > &solution, bool displaced)
Sets the value of constrained variables in the solution vector.
MooseObjectWarehouse< ADDirichletBCBase > _ad_preset_nodal_bcs

◆ setMooseKSPNormType()

void SolverSystem::setMooseKSPNormType ( MooseEnum  kspnorm)
inherited

Set the norm in which the linear convergence will be measured.

Parameters
kspnormThe required norm

Definition at line 94 of file SolverSystem.C.

Referenced by MoosePreconditioner::MoosePreconditioner().

95 {
96  if (kspnorm == "none")
98  else if (kspnorm == "preconditioned")
100  else if (kspnorm == "unpreconditioned")
102  else if (kspnorm == "natural")
104  else if (kspnorm == "default")
106  else
107  mooseError("Unknown ksp norm type specified.");
108 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
Use whatever we have in PETSc.
Definition: MooseTypes.h:837
Moose::MooseKSPNormType _ksp_norm
KSP norm type.
Definition: SolverSystem.h:110

◆ setPCSide()

void SolverSystem::setPCSide ( MooseEnum  pcs)
inherited

Set the side on which the preconditioner is applied to.

Parameters
pcsThe required preconditioning side

Definition at line 79 of file SolverSystem.C.

Referenced by MoosePreconditioner::MoosePreconditioner().

80 {
81  if (pcs == "left")
83  else if (pcs == "right")
85  else if (pcs == "symmetric")
87  else if (pcs == "default")
89  else
90  mooseError("Unknown PC side specified.");
91 }
Moose::PCSideType _pc_side
Preconditioning side.
Definition: SolverSystem.h:108
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
Use whatever we have in PETSc.
Definition: MooseTypes.h:825

◆ setPreconditioner()

void NonlinearSystemBase::setPreconditioner ( std::shared_ptr< MoosePreconditioner pc)
inherited

Sets a preconditioner.

Parameters
pcThe preconditioner to be set

Definition at line 3540 of file NonlinearSystemBase.C.

Referenced by SetupPreconditionerAction::act().

3541 {
3542  if (_preconditioner.get() != nullptr)
3543  mooseError("More than one active Preconditioner detected");
3544 
3545  _preconditioner = pc;
3546 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
std::shared_ptr< MoosePreconditioner > _preconditioner
Preconditioner.

◆ setPredictor()

void NonlinearSystemBase::setPredictor ( std::shared_ptr< Predictor predictor)
inherited

Definition at line 976 of file NonlinearSystemBase.C.

Referenced by SetupPredictorAction::act().

977 {
978  _predictor = predictor;
979 }
std::shared_ptr< Predictor > _predictor
If predictor is active, this is non-NULL.

◆ setPreSMOResidual()

void NonlinearSystemBase::setPreSMOResidual ( bool  use)
inlineinherited

Set whether to evaluate the pre-SMO residual and use it in the subsequent relative convergence checks.

If set to true, an additional residual evaluation is performed before any solution-modifying object is executed, and before the initial (0-th nonlinear iteration) residual evaluation. Such residual is referred to as the pre-SMO residual. If the pre-SMO residual is evaluated, it is used in the subsequent relative convergence checks.

If set to false, no residual evaluation takes place before the initial residual evaluation, and the initial residual is used in the subsequent relative convergence checks. This mode is recommended for performance-critical code as it avoids the additional pre-SMO residual evaluation.

Definition at line 254 of file NonlinearSystemBase.h.

Referenced by FEProblemSolve::FEProblemSolve().

254 { _use_pre_smo_residual = use; }
bool _use_pre_smo_residual
Whether to use the pre-SMO initial residual in the relative convergence check.

◆ setPreviousNewtonSolution()

void NonlinearSystemBase::setPreviousNewtonSolution ( const NumericVector< Number > &  soln)
virtualinherited

Definition at line 3771 of file NonlinearSystemBase.C.

Referenced by FEProblemBase::computePostCheck().

3772 {
3775 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:916
const TagName PREVIOUS_NL_SOLUTION_TAG
Definition: MooseTypes.C:28
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:925

◆ setSolution()

void SolverSystem::setSolution ( const NumericVector< Number > &  soln)
inherited

Set the solution to a given vector.

Parameters
solnThe vector which should be treated as the solution.

Definition at line 67 of file SolverSystem.C.

Referenced by FEProblemBase::computeDamping(), FEProblemBase::computeJacobianInternal(), FEProblemBase::computeJacobianTag(), FEProblemBase::computeLinearSystemTags(), FEProblemBase::computeResidualAndJacobian(), FEProblemBase::computeResidualInternal(), FEProblemBase::computeResidualTag(), FEProblemBase::computeResidualType(), ActuallyExplicitEuler::solve(), and ExplicitSSPRungeKutta::solveStage().

68 {
69  _current_solution = &soln;
70 
72  associateVectorToTag(const_cast<NumericVector<Number> &>(soln), tag);
73 
74  if (_serialized_solution.get())
76 }
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition: SubProblem.C:203
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:973
void serializeSolution()
Definition: SolverSystem.C:52
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed...
Definition: SystemBase.h:1068
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:105
const TagName SOLUTION_TAG
Definition: MooseTypes.C:25

◆ setSolutionUDot()

void NonlinearSystemBase::setSolutionUDot ( const NumericVector< Number > &  udot)
virtualinherited

Set transient term used by residual and Jacobian evaluation.

Parameters
udottransient term
Note
If the calling sequence for residual evaluation was changed, this could become an explicit argument.

Definition at line 3516 of file NonlinearSystemBase.C.

3517 {
3518  *_u_dot = u_dot;
3519 }
NumericVector< Number > * _u_dot
solution vector for u^dot
Definition: SystemBase.h:1006

◆ setSolutionUDotDot()

void NonlinearSystemBase::setSolutionUDotDot ( const NumericVector< Number > &  udotdot)
virtualinherited

Set transient term used by residual and Jacobian evaluation.

Parameters
udotdottransient term
Note
If the calling sequence for residual evaluation was changed, this could become an explicit argument.

Definition at line 3522 of file NonlinearSystemBase.C.

3523 {
3524  *_u_dotdot = u_dotdot;
3525 }
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
Definition: SystemBase.h:1008

◆ setSolutionUDotDotOld()

void NonlinearSystemBase::setSolutionUDotDotOld ( const NumericVector< Number > &  u_dotdot_old)
virtualinherited

Definition at line 3534 of file NonlinearSystemBase.C.

3535 {
3536  *_u_dotdot_old = u_dotdot_old;
3537 }
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
Definition: SystemBase.h:1013

◆ setSolutionUDotOld()

void NonlinearSystemBase::setSolutionUDotOld ( const NumericVector< Number > &  u_dot_old)
virtualinherited

Definition at line 3528 of file NonlinearSystemBase.C.

3529 {
3530  *_u_dot_old = u_dot_old;
3531 }
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
Definition: SystemBase.h:1011

◆ setupDampers()

void NonlinearSystemBase::setupDampers ( )
inherited

Setup damping stuff (called before we actually start)

Definition at line 3555 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::preInit().

3556 {
3557  _increment_vec = &_sys.add_vector("u_increment", true, GHOSTED);
3558 }
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
libMesh::System & _sys
NumericVector< Number > * _increment_vec
increment vector

◆ setupDM()

void NonlinearSystemBase::setupDM ( )
inherited

Setup the PETSc DM object (when appropriate)

Definition at line 424 of file NonlinearSystemBase.C.

Referenced by FEProblemBase::solve().

425 {
426  if (_fsp)
427  _fsp->setupDM();
428 }
virtual void setupDM()=0
setup the data management data structure that manages the field split
FieldSplitPreconditionerBase * _fsp
The field split preconditioner if this sytem is using one.

◆ setupFiniteDifferencedPreconditioner()

virtual void DumpObjectsNonlinearSystem::setupFiniteDifferencedPreconditioner ( )
inlineoverridevirtual

Implements NonlinearSystemBase.

Definition at line 37 of file DumpObjectsNonlinearSystem.h.

37 {}

◆ setVariableGlobalDoFs()

void SystemBase::setVariableGlobalDoFs ( const std::string &  var_name)
inherited

set all the global dof indices for a variable

Parameters
var_nameThe name of the variable

Definition at line 186 of file SystemBase.C.

187 {
188  AllLocalDofIndicesThread aldit(_subproblem, {var_name});
190  Threads::parallel_reduce(elem_range, aldit);
191 
192  // Gather the dof indices across procs to get all the dof indices for var_name
193  aldit.dofIndicesSetUnion();
194 
195  const auto & all_dof_indices = aldit.getDofIndices();
196  _var_all_dof_indices.assign(all_dof_indices.begin(), all_dof_indices.end());
197 }
libMesh::ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:1238
std::vector< dof_id_type > _var_all_dof_indices
Container for the dof indices of a given variable.
Definition: SystemBase.h:1064
void parallel_reduce(const Range &range, Body &body, const Partitioner &)
Grab all the (possibly semi)local dof indices for the variables passed in, in the system passed in...
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
MooseMesh & _mesh
Definition: SystemBase.h:991

◆ setVerboseFlag()

void SystemBase::setVerboseFlag ( const bool &  verbose)
inlineinherited

Sets the verbose flag.

Parameters
[in]verboseVerbose flag

Definition at line 134 of file SystemBase.h.

Referenced by Executioner::Executioner().

134 { _verbose = verbose; }
bool _verbose
True if printing out additional information.
Definition: SystemBase.h:1058

◆ shouldEvaluatePreSMOResidual()

bool NonlinearSystemBase::shouldEvaluatePreSMOResidual ( ) const
inherited

We offer the option to check convergence against the pre-SMO residual.

This method handles the logic as to whether we should perform such residual evaluation.

Returns
A boolean indicating whether we should evaluate the pre-SMO residual.

Definition at line 711 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::preSMOResidual(), and NonlinearSystem::solve().

712 {
714  return false;
715 
716  // The legacy behavior (#10464) _always_ performs the pre-SMO residual evaluation
717  // regardless of whether it is needed.
718  //
719  // This is not ideal and has been fixed by #23472. This legacy option ensures a smooth transition
720  // to the new behavior. Modules and Apps that want to migrate to the new behavior should set this
721  // parameter to false.
722  if (_app.parameters().get<bool>("use_legacy_initial_residual_evaluation_behavior"))
723  return true;
724 
725  return _use_pre_smo_residual;
726 }
bool _use_pre_smo_residual
Whether to use the pre-SMO initial residual in the relative convergence check.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:127
Solving a linear problem.
Definition: MooseTypes.h:849
Moose::SolveType _type
Definition: SolverParams.h:19
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
MooseApp & _app
Definition: SystemBase.h:988
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
SolverParams & solverParams(unsigned int solver_sys_num=0)
Get the solver parameters.

◆ sizeVariableMatrixData()

void SystemBase::sizeVariableMatrixData ( )
inherited

size the matrix data for each variable for the number of matrix tags we have

Definition at line 1711 of file SystemBase.C.

1712 {
1713  for (const auto & warehouse : _vars)
1714  for (const auto & [var_num, var_ptr] : warehouse.numberToVariableMap())
1715  var_ptr->sizeMatrixTagData();
1716 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996

◆ solution() [1/2]

NumericVector<Number>& SystemBase::solution ( )
inlineinherited

Definition at line 196 of file SystemBase.h.

Referenced by Adaptivity::adaptMesh(), TransientMultiApp::appTransferVector(), MooseEigenSystem::combineSystemSolution(), NonlinearSystemBase::computeDamping(), AuxiliarySystem::computeElementalVarsHelper(), NonlinearSystemBase::computeJacobianInternal(), AuxiliarySystem::computeMortarNodalVars(), NonlinearSystemBase::computeNodalBCs(), AuxiliarySystem::computeNodalVarsHelper(), NonlinearSystemBase::computeResidualTags(), AuxiliarySystem::computeScalarVars(), NonlinearSystemBase::constraintResiduals(), SystemBase::copyVars(), MultiAppPostprocessorToAuxScalarTransfer::execute(), MultiAppScalarToAuxScalarTransfer::execute(), NodalNormalsCorner::execute(), NodalNormalsEvaluator::execute(), MultiAppVariableValueSamplePostprocessorTransfer::execute(), NodalNormalsPreprocessor::execute(), NodalNormalsCorner::finalize(), NodalNormalsEvaluator::finalize(), NodalNormalsPreprocessor::finalize(), NodalNormalsEvaluator::initialize(), NodalNormalsCorner::initialize(), NodalNormalsPreprocessor::initialize(), MooseEigenSystem::initSystemSolution(), ComputeMarkerThread::onElement(), ComputeIndicatorThread::onElement(), ComputeUserObjectsThread::onElement(), ComputeNodalUserObjectsThread::onNode(), FEProblemBase::projectInitialConditionOnCustomRange(), FEProblemBase::projectSolution(), Transient::relativeSolutionDifferenceNorm(), MultiApp::restore(), SystemBase::restoreSolutions(), SecantSolve::saveVariableValues(), SteffensenSolve::saveVariableValues(), PicardSolve::saveVariableValues(), MooseEigenSystem::scaleSystemSolution(), AuxiliarySystem::serializeSolution(), NonlinearSystemBase::setConstraintSecondaryValues(), NonlinearSystemBase::setInitialSolution(), DisplacedSystem::solutionInternal(), NonlinearEigenSystem::solve(), MultiAppDofCopyTransfer::transfer(), SecantSolve::transformVariables(), SteffensenSolve::transformVariables(), PicardSolve::transformVariables(), AuxiliarySystem::variableWiseRelativeSolutionDifferenceNorm(), and SystemBase::zeroVariables().

196 { return solutionState(0); }
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).
Definition: SystemBase.C:1423

◆ solution() [2/2]

const NumericVector<Number>& SystemBase::solution ( ) const
inlineinherited

Definition at line 199 of file SystemBase.h.

199 { return solutionState(0); }
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).
Definition: SystemBase.C:1423

◆ solutionInternal()

NumericVector< Number > & SolverSystem::solutionInternal ( ) const
inlinefinaloverrideprotectedvirtualinherited

Internal getter for solution owned by libMesh.

Implements SystemBase.

Definition at line 123 of file SolverSystem.h.

124 {
125  return *system().solution;
126 }
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
std::unique_ptr< NumericVector< Number > > solution

◆ solutionOld() [1/2]

NumericVector<Number>& SystemBase::solutionOld ( )
inlineinherited

◆ solutionOld() [2/2]

const NumericVector<Number>& SystemBase::solutionOld ( ) const
inlineinherited

Definition at line 200 of file SystemBase.h.

200 { return solutionState(1); }
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).
Definition: SystemBase.C:1423

◆ solutionOlder() [1/2]

NumericVector<Number>& SystemBase::solutionOlder ( )
inlineinherited

Definition at line 198 of file SystemBase.h.

Referenced by MooseEigenSystem::combineSystemSolution(), CentralDifference::computeTimeDerivatives(), ActivateElementsUserObjectBase::initSolutions(), MooseVariableScalar::reinit(), and ElementSubdomainModifierBase::setOldAndOlderSolutions().

198 { return solutionState(2); }
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).
Definition: SystemBase.C:1423

◆ solutionOlder() [2/2]

const NumericVector<Number>& SystemBase::solutionOlder ( ) const
inlineinherited

Definition at line 201 of file SystemBase.h.

201 { return solutionState(2); }
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).
Definition: SystemBase.C:1423

◆ solutionPreviousNewton() [1/2]

const NumericVector< Number > * SystemBase::solutionPreviousNewton ( ) const
virtualinherited

Reimplemented in DisplacedSystem.

Definition at line 1347 of file SystemBase.C.

Referenced by AuxiliarySystem::copyCurrentIntoPreviousNL(), SystemBase::copyPreviousNonlinearSolutions(), and SystemBase::restoreSolutions().

1348 {
1351  else
1352  return nullptr;
1353 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:916
const TagName PREVIOUS_NL_SOLUTION_TAG
Definition: MooseTypes.C:28
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:925

◆ solutionPreviousNewton() [2/2]

NumericVector< Number > * SystemBase::solutionPreviousNewton ( )
virtualinherited

Reimplemented in DisplacedSystem.

Definition at line 1338 of file SystemBase.C.

1339 {
1342  else
1343  return nullptr;
1344 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:916
const TagName PREVIOUS_NL_SOLUTION_TAG
Definition: MooseTypes.C:28
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:925

◆ solutionState() [1/2]

NumericVector< Number > & SystemBase::solutionState ( const unsigned int  state,
Moose::SolutionIterationType  iteration_type = Moose::SolutionIterationType::Time 
)
virtualinherited

Get a state of the solution (0 = current, 1 = old, 2 = older, etc).

If the state does not exist, it will be initialized in addition to any newer states before it that have not been initialized.

Reimplemented in DisplacedSystem.

Definition at line 1423 of file SystemBase.C.

Referenced by SystemBase::copyOldSolutions(), SystemBase::copyPreviousFixedPointSolutions(), SystemBase::copyPreviousNonlinearSolutions(), PointwiseRenormalizeVector::execute(), PointwiseRenormalizeVector::finalize(), SystemBase::restoreOldSolutions(), SystemBase::saveOldSolutions(), SystemBase::solution(), SystemBase::solutionOld(), SystemBase::solutionOlder(), and DisplacedSystem::solutionState().

1425 {
1426  if (!hasSolutionState(state, iteration_type))
1427  needSolutionState(state, iteration_type);
1428  return *_solution_states[static_cast<unsigned short>(iteration_type)][state];
1429 }
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.h:1090
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.
Definition: SystemBase.C:1442
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1084

◆ solutionState() [2/2]

const NumericVector< Number > & SystemBase::solutionState ( const unsigned int  state,
Moose::SolutionIterationType  iteration_type = Moose::SolutionIterationType::Time 
) const
virtualinherited

Get a state of the solution (0 = current, 1 = old, 2 = older, etc).

Reimplemented in DisplacedSystem.

Definition at line 1394 of file SystemBase.C.

1396 {
1397  if (!hasSolutionState(state, iteration_type))
1398  mooseError("For iteration type '",
1399  Moose::stringify(iteration_type),
1400  "': solution state ",
1401  state,
1402  " was requested in ",
1403  name(),
1404  " but only up to state ",
1405  (_solution_states[static_cast<unsigned short>(iteration_type)].size() == 0)
1406  ? 0
1407  : _solution_states[static_cast<unsigned short>(iteration_type)].size() - 1,
1408  " is available.");
1409 
1410  const auto & solution_states = _solution_states[static_cast<unsigned short>(iteration_type)];
1411 
1412  if (state == 0)
1413  mooseAssert(solution_states[0] == &solutionInternal(), "Inconsistent current solution");
1414  else
1415  mooseAssert(solution_states[state] ==
1416  &getVector(oldSolutionStateVectorName(state, iteration_type)),
1417  "Inconsistent solution state");
1418 
1419  return *solution_states[state];
1420 }
virtual NumericVector< Number > & solutionInternal() const =0
Internal getter for solution owned by libMesh.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual const std::string & name() const
Definition: SystemBase.C:1332
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.h:1090
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64
TagName oldSolutionStateVectorName(const unsigned int, Moose::SolutionIterationType iteration_type) const
Gets the vector name used for an old (not current) solution state.
Definition: SystemBase.C:1373
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1084
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:925

◆ solutionStateParallelType()

libMesh::ParallelType SystemBase::solutionStateParallelType ( const unsigned int  state,
const Moose::SolutionIterationType  iteration_type 
) const
inherited

Returns the parallel type of the given solution state.

Definition at line 1432 of file SystemBase.C.

Referenced by SystemBase::needSolutionState().

1434 {
1435  if (!hasSolutionState(state, iteration_type))
1436  mooseError("solutionStateParallelType() may only be called if the solution state exists.");
1437 
1438  return _solution_states[static_cast<unsigned short>(iteration_type)][state]->type();
1439 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.h:1090
std::array< std::vector< NumericVector< Number > * >, 3 > _solution_states
2D array of solution state vector pointers; first index corresponds to SolutionIterationType, second index corresponds to state index (0=current, 1=old, 2=older)
Definition: SystemBase.h:1084

◆ solutionStatesInitialized()

bool SystemBase::solutionStatesInitialized ( ) const
inlineinherited

Whether or not the solution states have been initialized via initSolutionState()

After the solution states have been initialized, additional solution states cannot be added.

Definition at line 896 of file SystemBase.h.

Referenced by ScalarKernelBase::uOld(), and AuxScalarKernel::uOld().

bool _solution_states_initialized
Whether or not the solution states have been initialized.
Definition: SystemBase.h:1061

◆ solutionUDot() [1/2]

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

◆ solutionUDot() [2/2]

virtual const NumericVector<Number>* SystemBase::solutionUDot ( ) const
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 265 of file SystemBase.h.

265 { return _u_dot; }
NumericVector< Number > * _u_dot
solution vector for u^dot
Definition: SystemBase.h:1006

◆ solutionUDotDot() [1/2]

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

◆ solutionUDotDot() [2/2]

virtual const NumericVector<Number>* SystemBase::solutionUDotDot ( ) const
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 266 of file SystemBase.h.

266 { return _u_dotdot; }
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
Definition: SystemBase.h:1008

◆ solutionUDotDotOld() [1/2]

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

◆ solutionUDotDotOld() [2/2]

virtual const NumericVector<Number>* SystemBase::solutionUDotDotOld ( ) const
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 268 of file SystemBase.h.

268 { return _u_dotdot_old; }
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
Definition: SystemBase.h:1013

◆ solutionUDotOld() [1/2]

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

◆ solutionUDotOld() [2/2]

virtual const NumericVector<Number>* SystemBase::solutionUDotOld ( ) const
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 267 of file SystemBase.h.

267 { return _u_dot_old; }
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
Definition: SystemBase.h:1011

◆ solve()

virtual void DumpObjectsNonlinearSystem::solve ( )
inlineoverridevirtual

Solve the system (using libMesh magic)

Implements NonlinearSystemBase.

Definition at line 30 of file DumpObjectsNonlinearSystem.h.

30 {}

◆ stopSolve()

virtual void DumpObjectsNonlinearSystem::stopSolve ( const ExecFlagType exec_flag,
const std::set< TagID > &  vector_tags_to_close 
)
inlineoverridevirtual

Quit the current solve as soon as possible.

Implements SolverSystem.

Definition at line 31 of file DumpObjectsNonlinearSystem.h.

31 {}

◆ subdomainSetup() [1/3]

void SystemBase::subdomainSetup
inherited

Definition at line 1584 of file SystemBase.C.

1585 {
1586  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1587  _vars[tid].subdomainSetup();
1588 }
unsigned int n_threads()
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
virtual void subdomainSetup()
Definition: SystemBase.C:1584
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ subdomainSetup() [2/3]

void NonlinearSystemBase::subdomainSetup ( SubdomainID  subdomain,
THREAD_ID  tid 
)
virtualinherited

Called from assembling when we hit a new subdomain.

Parameters
subdomainID of the new subdomain
tidThread ID

Definition at line 982 of file NonlinearSystemBase.C.

983 {
985 
986  _kernels.subdomainSetup(subdomain, tid);
987  _nodal_kernels.subdomainSetup(subdomain, tid);
988  _element_dampers.subdomainSetup(subdomain, tid);
989  _nodal_dampers.subdomainSetup(subdomain, tid);
990 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
MooseObjectTagWarehouse< KernelBase > _kernels
virtual void subdomainSetup()
Definition: SystemBase.C:1584
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
virtual void subdomainSetup(THREAD_ID tid=0) const

◆ subdomainSetup() [3/3]

void SystemBase::subdomainSetup ( )
virtualinherited

Reimplemented in AuxiliarySystem.

Definition at line 1584 of file SystemBase.C.

Referenced by AuxiliarySystem::subdomainSetup(), and NonlinearSystemBase::subdomainSetup().

1585 {
1586  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1587  _vars[tid].subdomainSetup();
1588 }
unsigned int n_threads()
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:996
virtual void subdomainSetup()
Definition: SystemBase.C:1584
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ subproblem() [1/2]

SubProblem& SystemBase::subproblem ( )
inlineinherited

◆ subproblem() [2/2]

const SubProblem& SystemBase::subproblem ( ) const
inlineinherited

Definition at line 102 of file SystemBase.h.

102 { return _subproblem; }
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983

◆ system() [1/2]

virtual libMesh::System& NonlinearSystemBase::system ( )
inlineoverridevirtualinherited

Get the reference to the libMesh system.

Implements SystemBase.

Definition at line 640 of file NonlinearSystemBase.h.

Referenced by Adaptivity::adaptMesh(), PhysicsBasedPreconditioner::addSystem(), PhysicsBasedPreconditioner::apply(), FEProblemBase::computeJacobianTags(), FEProblemBase::computeResidualAndJacobian(), NonlinearSystemBase::computeScaling(), PseudoTimestep::currentResidualNorm(), DMMooseFunction(), DMMooseJacobian(), VariableResidual::execute(), NonlinearSystemBase::getResidualNonTimeVector(), NonlinearSystemBase::getResidualTimeVector(), NonlinearSystem::getSNES(), ExplicitTimeIntegrator::initialSetup(), ReferenceResidualConvergence::initialSetup(), MooseStaticCondensationPreconditioner::MooseStaticCondensationPreconditioner(), Moose::PetscSupport::petscSetDefaults(), PhysicsBasedPreconditioner::PhysicsBasedPreconditioner(), ComputeJacobianThread::postElement(), NonlinearSystemBase::residualGhosted(), Moose::PetscSupport::setLineSearchFromParams(), PhysicsBasedPreconditioner::setup(), NonlinearSystemBase::setupScalingData(), SingleMatrixPreconditioner::SingleMatrixPreconditioner(), NonlinearSystem::solve(), NonlinearEigenSystem::solve(), LStableDirk2::solve(), LStableDirk3::solve(), ImplicitMidpoint::solve(), ExplicitTVDRK2::solve(), LStableDirk4::solve(), AStableDirk4::solve(), ExplicitRK2::solve(), FieldSplitPreconditioner::system(), NonlinearSystemBase::turnOffJacobian(), ReferenceResidualConvergence::updateReferenceResidual(), VariableCondensationPreconditioner::VariableCondensationPreconditioner(), and Console::writeVariableNorms().

640 { return _sys; }
libMesh::System & _sys

◆ system() [2/2]

virtual const libMesh::System& NonlinearSystemBase::system ( ) const
inlineoverridevirtualinherited

Implements SystemBase.

Definition at line 641 of file NonlinearSystemBase.h.

641 { return _sys; }
libMesh::System & _sys

◆ systemMatrixTag()

TagID NonlinearSystemBase::systemMatrixTag ( ) const
inlineoverridevirtualinherited

◆ timedSectionName()

std::string PerfGraphInterface::timedSectionName ( const std::string &  section_name) const
protectedinherited
Returns
The name of the timed section with the name section_name.

Optionally adds a prefix if one is defined.

Definition at line 47 of file PerfGraphInterface.C.

Referenced by PerfGraphInterface::registerTimedSection().

48 {
49  return _prefix.empty() ? "" : (_prefix + "::") + section_name;
50 }
const std::string _prefix
A prefix to use for all sections.

◆ timeKernelVariableNames()

std::vector< std::string > NonlinearSystemBase::timeKernelVariableNames ( )
overridevirtualinherited

Returns the names of the variables that have time derivative kernels in the system.

Implements SolverSystem.

Definition at line 3734 of file NonlinearSystemBase.C.

3735 {
3736  std::vector<std::string> variable_names;
3737  const auto & time_kernels = _kernels.getVectorTagObjectWarehouse(timeVectorTag(), 0);
3738  if (time_kernels.hasActiveObjects())
3739  for (const auto & kernel : time_kernels.getObjects())
3740  variable_names.push_back(kernel->variable().name());
3741 
3742  return variable_names;
3743 }
MooseObjectTagWarehouse< KernelBase > _kernels
TagID timeVectorTag() const override
Ideally, we should not need this API.
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...

◆ timestepSetup()

void NonlinearSystemBase::timestepSetup ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 316 of file NonlinearSystemBase.C.

317 {
319 
320  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
321  {
322  _kernels.timestepSetup(tid);
325  if (_doing_dg)
331 
332  if (_fe_problem.haveFV())
333  {
334  std::vector<FVFluxBC *> bcs;
336  .query()
337  .template condition<AttribSystem>("FVFluxBC")
338  .template condition<AttribThread>(tid)
339  .queryInto(bcs);
340 
341  std::vector<FVInterfaceKernel *> iks;
343  .query()
344  .template condition<AttribSystem>("FVInterfaceKernel")
345  .template condition<AttribThread>(tid)
346  .queryInto(iks);
347 
348  std::vector<FVFluxKernel *> kernels;
350  .query()
351  .template condition<AttribSystem>("FVFluxKernel")
352  .template condition<AttribThread>(tid)
353  .queryInto(kernels);
354 
355  for (auto * bc : bcs)
356  bc->timestepSetup();
357  for (auto * ik : iks)
358  ik->timestepSetup();
359  for (auto * kernel : kernels)
360  kernel->timestepSetup();
361  }
362  }
367 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
std::vector< T * > & queryInto(std::vector< T *> &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
Definition: TheWarehouse.h:311
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
bool _doing_dg
true if DG is active (optimization reasons)
TheWarehouse & theWarehouse() const
virtual void timestepSetup(THREAD_ID tid=0) const
MooseObjectTagWarehouse< KernelBase > _kernels
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:986
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
unsigned int THREAD_ID
Definition: MooseTypes.h:209
virtual void timestepSetup()
Definition: SystemBase.C:1570

◆ timeVectorTag()

TagID NonlinearSystemBase::timeVectorTag ( ) const
inlineoverridevirtualinherited

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 from SystemBase.

Definition at line 649 of file NonlinearSystemBase.h.

Referenced by FEProblemBase::addCachedResidualDirectly(), NonlinearSystemBase::containsTimeKernel(), and NonlinearSystemBase::timeKernelVariableNames().

649 { return _Re_time_tag; }
TagID _Re_time_tag
Tag for time contribution residual.

◆ turnOffJacobian()

void NonlinearSystemBase::turnOffJacobian ( )
virtualinherited

Turn off the Jacobian (must be called before equation system initialization)

Reimplemented in NonlinearEigenSystem.

Definition at line 205 of file NonlinearSystemBase.C.

206 {
208  nonlinearSolver()->jacobian = NULL;
209 }
virtual libMesh::NonlinearSolver< Number > * nonlinearSolver()=0
void set_basic_system_only()
virtual libMesh::System & system() override
Get the reference to the libMesh system.

◆ update()

void SystemBase::update ( )
inherited

◆ updateActive()

void NonlinearSystemBase::updateActive ( THREAD_ID  tid)
inherited

Update active objects of Warehouses owned by NonlinearSystemBase.

Definition at line 3281 of file NonlinearSystemBase.C.

3282 {
3289  _kernels.updateActive(tid);
3291  if (tid == 0)
3292  {
3299  }
3300 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
void updateActive(THREAD_ID tid=0) override
Update the various active lists.
virtual void updateActive(THREAD_ID tid=0) override
Update the active status of Kernels.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
MooseObjectWarehouse< DirichletBCBase > _preset_nodal_bcs
MooseObjectTagWarehouse< KernelBase > _kernels
ConstraintWarehouse _constraints
Constraints storage object.
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
virtual void updateActive(THREAD_ID tid=0) override
Update the active status of Kernels.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
MooseObjectWarehouse< ADDirichletBCBase > _ad_preset_nodal_bcs

◆ useFieldSplitPreconditioner()

void NonlinearSystemBase::useFieldSplitPreconditioner ( FieldSplitPreconditionerBase fsp)
inlineinherited

If called with a non-null object true this system will use a field split preconditioner matrix.

Definition at line 458 of file NonlinearSystemBase.h.

Referenced by FieldSplitPreconditionerTempl< MoosePreconditioner >::FieldSplitPreconditionerTempl().

458 { _fsp = fsp; }
FieldSplitPreconditionerBase * _fsp
The field split preconditioner if this sytem is using one.

◆ useFiniteDifferencedPreconditioner()

void NonlinearSystemBase::useFiniteDifferencedPreconditioner ( bool  use = true)
inlineinherited

If called with true this system will use a finite differenced form of the Jacobian as the preconditioner.

Definition at line 450 of file NonlinearSystemBase.h.

Referenced by FiniteDifferencePreconditioner::FiniteDifferencePreconditioner().

451  {
453  }
bool _use_finite_differenced_preconditioner
Whether or not to use a finite differenced preconditioner.

◆ usePreSMOResidual()

const bool& NonlinearSystemBase::usePreSMOResidual ( ) const
inlineinherited

Whether we are using pre-SMO residual in relative convergence checks.

Definition at line 257 of file NonlinearSystemBase.h.

Referenced by Console::outputSystemInformation(), and NonlinearSystemBase::referenceResidual().

257 { return _use_pre_smo_residual; }
bool _use_pre_smo_residual
Whether to use the pre-SMO initial residual in the relative convergence check.

◆ validParams()

InputParameters PerfGraphInterface::validParams ( )
staticinherited

Definition at line 16 of file PerfGraphInterface.C.

Referenced by Convergence::validParams().

17 {
19  return params;
20 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()

◆ varKind()

Moose::VarKindType SystemBase::varKind ( ) const
inlineinherited
Returns
the type of variables this system holds, e.g. nonlinear or auxiliary

Definition at line 924 of file SystemBase.h.

Referenced by Coupleable::coupled().

924 { return _var_kind; }
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:1038

◆ zeroTaggedVector()

void SystemBase::zeroTaggedVector ( const TagID  tag)
inherited

Zero vector with the given tag.

Definition at line 674 of file SystemBase.C.

Referenced by SystemBase::zeroTaggedVectors().

675 {
676  if (!_subproblem.vectorTagExists(tag))
677  mooseError("Cannot zero vector with TagID ",
678  tag,
679  " in system '",
680  name(),
681  "' because that tag does not exist in the problem");
682  else if (!hasVector(tag))
683  mooseError("Cannot zero vector tag with name '",
685  "' in system '",
686  name(),
687  "' because there is no vector associated with that tag");
689  getVector(tag).zero();
690 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:916
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
bool vectorTagNotZeroed(const TagID tag) const
Checks if a vector tag is in the list of vectors that will not be zeroed when other tagged vectors ar...
Definition: SubProblem.C:155
virtual void zero()=0
virtual const std::string & name() const
Definition: SystemBase.C:1332
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:201
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:221
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:925

◆ zeroTaggedVectors()

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

Zero all vectors for given tags.

Definition at line 693 of file SystemBase.C.

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

694 {
695  for (const auto tag : tags)
696  zeroTaggedVector(tag);
697 }
void zeroTaggedVector(const TagID tag)
Zero vector with the given tag.
Definition: SystemBase.C:674

◆ zeroVariables()

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

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 200 of file SystemBase.C.

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

201 {
202  if (vars_to_be_zeroed.size() > 0)
203  {
205 
206  auto problem = dynamic_cast<FEProblemBase *>(&_subproblem);
207  if (!problem)
208  mooseError("System needs to be registered in FEProblemBase for using zeroVariables.");
209 
210  AllLocalDofIndicesThread aldit(*problem, vars_to_be_zeroed, true);
212  Threads::parallel_reduce(elem_range, aldit);
213 
214  const auto & dof_indices_to_zero = aldit.getDofIndices();
215 
216  solution.close();
217 
218  for (const auto & dof : dof_indices_to_zero)
219  solution.set(dof, 0);
220 
221  solution.close();
222 
223  // Call update to update the current_local_solution for this system
224  system().update();
225  }
226 }
libMesh::ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:1238
NumericVector< Number > & solution()
Definition: SystemBase.h:196
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
void parallel_reduce(const Range &range, Body &body, const Partitioner &)
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Grab all the (possibly semi)local dof indices for the variables passed in, in the system passed in...
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:983
virtual void close()=0
virtual void update()
MooseMesh & _mesh
Definition: SystemBase.h:991
virtual void set(const numeric_index_type i, const T value)=0

◆ zeroVariablesForJacobian()

void SystemBase::zeroVariablesForJacobian ( )
virtualinherited

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 235 of file SystemBase.C.

236 {
238 }
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
Definition: SystemBase.h:1003
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:200

◆ zeroVariablesForResidual()

void SystemBase::zeroVariablesForResidual ( )
virtualinherited

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 229 of file SystemBase.C.

230 {
232 }
std::vector< std::string > _vars_to_be_zeroed_on_residual
Definition: SystemBase.h:1002
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:200

◆ zeroVectorForResidual()

void NonlinearSystemBase::zeroVectorForResidual ( const std::string &  vector_name)
inherited

Definition at line 756 of file NonlinearSystemBase.C.

757 {
758  for (unsigned int i = 0; i < _vecs_to_zero_for_residual.size(); ++i)
759  if (vector_name == _vecs_to_zero_for_residual[i])
760  return;
761 
762  _vecs_to_zero_for_residual.push_back(vector_name);
763 }
std::vector< std::string > _vecs_to_zero_for_residual
vectors that will be zeroed before a residual computation

Member Data Documentation

◆ _active_tagged_matrices

std::unordered_map<TagID, libMesh::SparseMatrix<Number> *> SystemBase::_active_tagged_matrices
protectedinherited

Active tagged matrices. A matrix is active if its tag-matrix pair is present in the map. We use a map instead of a vector so that users can easily add and remove to this container with calls to (de)activateMatrixTag.

Definition at line 1025 of file SystemBase.h.

Referenced by SystemBase::activateAllMatrixTags(), SystemBase::deactivateAllMatrixTags(), and SystemBase::reinitElem().

◆ _ad_preset_nodal_bcs

MooseObjectWarehouse<ADDirichletBCBase> NonlinearSystemBase::_ad_preset_nodal_bcs
protectedinherited

◆ _add_implicit_geometric_coupling_entries_to_jacobian

bool NonlinearSystemBase::_add_implicit_geometric_coupling_entries_to_jacobian
protectedinherited

Whether or not to add implicit geometric couplings to the Jacobian for FDP.

Definition at line 898 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::addImplicitGeometricCouplingEntriesToJacobian(), NonlinearSystemBase::augmentSparsity(), and NonlinearSystemBase::computeJacobianInternal().

◆ _app

MooseApp& SystemBase::_app
protectedinherited

◆ _assemble_constraints_separately

bool NonlinearSystemBase::_assemble_constraints_separately
protectedinherited

Whether or not to assemble the residual and Jacobian after the application of each constraint.

Definition at line 901 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::assembleConstraintsSeparately(), NonlinearSystemBase::constraintJacobians(), and NonlinearSystemBase::constraintResiduals().

◆ _automatic_scaling

bool SystemBase::_automatic_scaling
protectedinherited

Whether to automatically scale the variables.

Definition at line 1055 of file SystemBase.h.

Referenced by SystemBase::automaticScaling(), NonlinearSystemBase::initialSetup(), and NonlinearSystemBase::preSolve().

◆ _compute_scaling_once

bool NonlinearSystemBase::_compute_scaling_once
protectedinherited

Whether the scaling factors should only be computed once at the beginning of the simulation through an extra Jacobian evaluation.

If this is set to false, then the scaling factors will be computed during an extra Jacobian evaluation at the beginning of every time step.

Definition at line 956 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeScaling(), and NonlinearSystemBase::computeScalingOnce().

◆ _computed_scaling

bool NonlinearSystemBase::_computed_scaling
protectedinherited

Flag used to indicate whether we have already computed the scaling Jacobian.

Definition at line 951 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computedScalingJacobian(), and NonlinearSystemBase::computeScaling().

◆ _computing_pre_smo_residual

bool NonlinearSystemBase::_computing_pre_smo_residual
protectedinherited

◆ _console

const ConsoleStream ConsoleStreamInterface::_console
inherited

An instance of helper class to write streams to the Console objects.

Definition at line 31 of file ConsoleStreamInterface.h.

Referenced by IterationAdaptiveDT::acceptStep(), MeshOnlyAction::act(), SetupDebugAction::act(), MaterialOutputAction::act(), Adaptivity::adaptMesh(), FEProblemBase::adaptMesh(), PerfGraph::addToExecutionList(), SimplePredictor::apply(), SystemBase::applyScalingFactors(), MultiApp::backup(), FEProblemBase::backupMultiApps(), CoarsenedPiecewiseLinear::buildCoarsenedGrid(), DefaultSteadyStateConvergence::checkConvergence(), MeshDiagnosticsGenerator::checkElementOverlap(), MeshDiagnosticsGenerator::checkElementTypes(), MeshDiagnosticsGenerator::checkElementVolumes(), FEProblemBase::checkExceptionAndStopSolve(), SolverSystem::checkInvalidSolution(), MeshDiagnosticsGenerator::checkLocalJacobians(), MeshDiagnosticsGenerator::checkNonConformalMesh(), MeshDiagnosticsGenerator::checkNonConformalMeshFromAdaptivity(), MeshDiagnosticsGenerator::checkNonMatchingEdges(), MeshDiagnosticsGenerator::checkNonPlanarSides(), FEProblemBase::checkProblemIntegrity(), ReferenceResidualConvergence::checkRelativeConvergence(), MeshDiagnosticsGenerator::checkSidesetsOrientation(), MeshDiagnosticsGenerator::checkWatertightNodesets(), MeshDiagnosticsGenerator::checkWatertightSidesets(), IterationAdaptiveDT::computeAdaptiveDT(), TransientBase::computeConstrainedDT(), DefaultMultiAppFixedPointConvergence::computeCustomConvergencePostprocessor(), NonlinearSystemBase::computeDamping(), FixedPointIterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeFailedDT(), IterationAdaptiveDT::computeInitialDT(), IterationAdaptiveDT::computeInterpolationDT(), LinearSystem::computeLinearSystemTags(), FEProblemBase::computeLinearSystemTags(), NonlinearSystemBase::computeScaling(), Problem::console(), IterationAdaptiveDT::constrainStep(), TimeStepper::constrainStep(), MultiApp::createApp(), FEProblemBase::execMultiApps(), FEProblemBase::execMultiAppTransfers(), MFEMSteady::execute(), MessageFromInput::execute(), SteadyBase::execute(), Eigenvalue::execute(), ActionWarehouse::executeActionsWithAction(), ActionWarehouse::executeAllActions(), MeshGeneratorSystem::executeMeshGenerators(), ElementQualityChecker::finalize(), SidesetAroundSubdomainUpdater::finalize(), FEProblemBase::finishMultiAppStep(), MeshRepairGenerator::fixOverlappingNodes(), CoarsenBlockGenerator::generate(), MeshGenerator::generateInternal(), VariableCondensationPreconditioner::getDofToCondense(), InversePowerMethod::init(), NonlinearEigen::init(), FEProblemBase::initialAdaptMesh(), DefaultMultiAppFixedPointConvergence::initialize(), EigenExecutionerBase::inversePowerIteration(), FEProblemBase::joinAndFinalize(), TransientBase::keepGoing(), IterationAdaptiveDT::limitDTByFunction(), IterationAdaptiveDT::limitDTToPostprocessorValue(), FEProblemBase::logAdd(), EigenExecutionerBase::makeBXConsistent(), Console::meshChanged(), MooseBase::mooseDeprecated(), MooseBase::mooseInfo(), MooseBase::mooseWarning(), MooseBase::mooseWarningNonPrefixed(), ReferenceResidualConvergence::nonlinearConvergenceSetup(), ReporterDebugOutput::output(), PerfGraphOutput::output(), SolutionInvalidityOutput::output(), MaterialPropertyDebugOutput::output(), DOFMapOutput::output(), VariableResidualNormsDebugOutput::output(), Console::output(), ControlOutput::outputActiveObjects(), ControlOutput::outputChangedControls(), ControlOutput::outputControls(), Console::outputInput(), Console::outputPostprocessors(), PseudoTimestep::outputPseudoTimestep(), Console::outputReporters(), DefaultMultiAppFixedPointConvergence::outputResidualNorm(), Console::outputScalarVariables(), Console::outputSystemInformation(), FEProblemBase::possiblyRebuildGeomSearchPatches(), EigenExecutionerBase::postExecute(), AB2PredictorCorrector::postSolve(), ActionWarehouse::printActionDependencySets(), BlockRestrictionDebugOutput::printBlockRestrictionMap(), SolutionInvalidity::printDebug(), EigenExecutionerBase::printEigenvalue(), SecantSolve::printFixedPointConvergenceHistory(), SteffensenSolve::printFixedPointConvergenceHistory(), PicardSolve::printFixedPointConvergenceHistory(), FixedPointSolve::printFixedPointConvergenceReason(), PerfGraphLivePrint::printLiveMessage(), MaterialPropertyDebugOutput::printMaterialMap(), PerfGraphLivePrint::printStats(), NEML2Action::printSummary(), AutomaticMortarGeneration::projectPrimaryNodesSinglePair(), AutomaticMortarGeneration::projectSecondaryNodesSinglePair(), CoarsenBlockGenerator::recursiveCoarsen(), SolutionTimeAdaptiveDT::rejectStep(), MultiApp::restore(), FEProblemBase::restoreMultiApps(), FEProblemBase::restoreSolutions(), NonlinearSystemBase::setInitialSolution(), MooseApp::setupOptions(), Checkpoint::shouldOutput(), SubProblem::showFunctorRequestors(), SubProblem::showFunctors(), FullSolveMultiApp::showStatusMessage(), EigenProblem::solve(), FEProblemSolve::solve(), NonlinearSystem::solve(), FixedPointSolve::solve(), LinearSystem::solve(), LStableDirk2::solve(), LStableDirk3::solve(), ImplicitMidpoint::solve(), ExplicitTVDRK2::solve(), LStableDirk4::solve(), AStableDirk4::solve(), ExplicitRK2::solve(), TransientMultiApp::solveStep(), FixedPointSolve::solveStep(), PerfGraphLivePrint::start(), AB2PredictorCorrector::step(), NonlinearEigen::takeStep(), MFEMTransient::takeStep(), TransientBase::takeStep(), TerminateChainControl::terminate(), Convergence::verboseOutput(), Console::writeTimestepInformation(), Console::writeVariableNorms(), and FEProblemBase::~FEProblemBase().

◆ _constraints

ConstraintWarehouse NonlinearSystemBase::_constraints
protectedinherited

◆ _current_l_its

std::vector<unsigned int> NonlinearSystemBase::_current_l_its
inherited

◆ _current_nl_its

unsigned int NonlinearSystemBase::_current_nl_its
inherited

◆ _current_solution

const NumericVector<Number>* SolverSystem::_current_solution
protectedinherited

◆ _debugging_residuals

bool NonlinearSystemBase::_debugging_residuals
protectedinherited

true if debugging residuals

Definition at line 906 of file NonlinearSystemBase.h.

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

◆ _dg_kernels

MooseObjectTagWarehouse<DGKernelBase> NonlinearSystemBase::_dg_kernels
protectedinherited

◆ _dirac_kernels

MooseObjectTagWarehouse<DiracKernelBase> NonlinearSystemBase::_dirac_kernels
protectedinherited

◆ _doing_dg

bool NonlinearSystemBase::_doing_dg
protectedinherited

◆ _du_dot_du

Number NonlinearSystemBase::_du_dot_du
protectedinherited

\( {du^dot}\over{du} \)

Definition at line 815 of file NonlinearSystemBase.h.

◆ _du_dotdot_du

Number NonlinearSystemBase::_du_dotdot_du
protectedinherited

\( {du^dotdot}\over{du} \)

Definition at line 817 of file NonlinearSystemBase.h.

◆ _dummy

NumericVector<Number>* DumpObjectsNonlinearSystem::_dummy
protected

Definition at line 47 of file DumpObjectsNonlinearSystem.h.

Referenced by RHS().

◆ _element_dampers

MooseObjectWarehouse<ElementDamper> NonlinearSystemBase::_element_dampers
protectedinherited

◆ _factory

Factory& SystemBase::_factory
protectedinherited

◆ _fdcoloring

MatFDColoring NonlinearSystemBase::_fdcoloring
protectedinherited

◆ _fe_problem

FEProblemBase& SystemBase::_fe_problem
protectedinherited

the governing finite element/volume problem

Definition at line 986 of file SystemBase.h.

Referenced by NonlinearSystemBase::addBoundaryCondition(), NonlinearSystemBase::addDGKernel(), NonlinearSystemBase::addDiracKernel(), SystemBase::addDotVectors(), NonlinearSystemBase::addHDGKernel(), NonlinearSystemBase::addInterfaceKernel(), NonlinearSystemBase::addKernel(), NonlinearSystemBase::addNodalKernel(), NonlinearSystemBase::addScalarKernel(), NonlinearSystemBase::addSplit(), NonlinearSystemBase::assembleScalingVector(), NonlinearSystemBase::augmentSparsity(), AuxiliarySystem::AuxiliarySystem(), SolverSystem::checkInvalidSolution(), NonlinearSystemBase::checkKernelCoverage(), AuxiliarySystem::clearScalarVariableCoupleableTags(), SolverSystem::compute(), AuxiliarySystem::compute(), NonlinearSystemBase::computeDamping(), NonlinearSystemBase::computeDiracContributions(), AuxiliarySystem::computeElementalVarsHelper(), LinearSystem::computeGradients(), NonlinearSystemBase::computeJacobian(), NonlinearSystemBase::computeJacobianBlocks(), NonlinearSystemBase::computeJacobianInternal(), LinearSystem::computeLinearSystemInternal(), LinearSystem::computeLinearSystemTags(), AuxiliarySystem::computeMortarNodalVars(), NonlinearSystemBase::computeNodalBCs(), NonlinearSystemBase::computeNodalBCsResidualAndJacobian(), AuxiliarySystem::computeNodalVarsHelper(), NonlinearSystemBase::computeResidualAndJacobianInternal(), NonlinearSystemBase::computeResidualInternal(), NonlinearSystemBase::computeResidualTags(), NonlinearSystemBase::computeScalarKernelsJacobians(), AuxiliarySystem::computeScalarVars(), NonlinearSystemBase::computeScaling(), NonlinearSystem::computeScalingJacobian(), NonlinearSystem::computeScalingResidual(), NonlinearSystemBase::constraintJacobians(), NonlinearSystemBase::constraintResiduals(), LinearSystem::containsTimeKernel(), NonlinearSystem::converged(), NonlinearSystemBase::customSetup(), MooseEigenSystem::eigenKernelOnCurrent(), MooseEigenSystem::eigenKernelOnOld(), NonlinearSystemBase::enforceNodalConstraintsJacobian(), NonlinearSystemBase::enforceNodalConstraintsResidual(), SystemBase::feProblem(), NonlinearSystemBase::getResidualNonTimeVector(), NonlinearSystemBase::getResidualTimeVector(), LinearSystem::initialSetup(), NonlinearSystemBase::initialSetup(), NonlinearSystemBase::jacobianSetup(), LinearSystem::LinearSystem(), NonlinearSystemBase::NonlinearSystemBase(), NonlinearSystemBase::overwriteNodeFace(), NonlinearSystem::potentiallySetupFiniteDifferencing(), NonlinearSystemBase::preInit(), NonlinearSystemBase::reinitNodeFace(), NonlinearSystem::residualAndJacobianTogether(), NonlinearSystemBase::residualSetup(), NonlinearSystemBase::setConstraintSecondaryValues(), NonlinearSystemBase::setInitialSolution(), AuxiliarySystem::setScalarVariableCoupleableTags(), NonlinearSystemBase::shouldEvaluatePreSMOResidual(), NonlinearSystem::solve(), and NonlinearSystemBase::timestepSetup().

◆ _final_residual

Real NonlinearSystemBase::_final_residual
protectedinherited

◆ _fsp

FieldSplitPreconditionerBase* NonlinearSystemBase::_fsp
protectedinherited

◆ _general_dampers

MooseObjectWarehouse<GeneralDamper> NonlinearSystemBase::_general_dampers
protectedinherited

◆ _has_diag_save_in

bool NonlinearSystemBase::_has_diag_save_in
protectedinherited

◆ _has_nodalbc_diag_save_in

bool NonlinearSystemBase::_has_nodalbc_diag_save_in
protectedinherited

◆ _has_nodalbc_save_in

bool NonlinearSystemBase::_has_nodalbc_save_in
protectedinherited

If there is a nodal BC having save_in.

Definition at line 943 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::addBoundaryCondition(), NonlinearSystemBase::computeResidualTags(), and NonlinearSystemBase::hasSaveIn().

◆ _has_save_in

bool NonlinearSystemBase::_has_save_in
protectedinherited

◆ _hybridized_kernels

MooseObjectTagWarehouse<HDGKernel> NonlinearSystemBase::_hybridized_kernels
protectedinherited

◆ _ignore_variables_for_autoscaling

std::vector<std::string> NonlinearSystemBase::_ignore_variables_for_autoscaling
protectedinherited

A container for variables that do not partipate in autoscaling.

Definition at line 972 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::ignoreVariablesForAutoscaling(), and NonlinearSystemBase::setupScalingData().

◆ _increment_vec

NumericVector<Number>* NonlinearSystemBase::_increment_vec
protectedinherited

◆ _initial_residual

Real NonlinearSystemBase::_initial_residual
protectedinherited

The initial (i.e., 0th nonlinear iteration) residual, see setPreSMOResidual for a detailed explanation.

Definition at line 930 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::initialResidual(), and NonlinearSystemBase::setInitialResidual().

◆ _integrated_bcs

MooseObjectTagWarehouse<IntegratedBCBase> NonlinearSystemBase::_integrated_bcs
protectedinherited

◆ _interface_kernels

MooseObjectTagWarehouse<InterfaceKernelBase> NonlinearSystemBase::_interface_kernels
protectedinherited

◆ _Ke_non_time_tag

TagID NonlinearSystemBase::_Ke_non_time_tag
protectedinherited

Tag for non-time contribution Jacobian.

Definition at line 840 of file NonlinearSystemBase.h.

◆ _Ke_system_tag

TagID NonlinearSystemBase::_Ke_system_tag
protectedinherited

Tag for system contribution Jacobian.

Definition at line 843 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::NonlinearSystemBase(), and NonlinearSystemBase::systemMatrixTag().

◆ _kernels

MooseObjectTagWarehouse<KernelBase> NonlinearSystemBase::_kernels
protectedinherited

◆ _ksp_norm

Moose::MooseKSPNormType SolverSystem::_ksp_norm
protectedinherited

KSP norm type.

Definition at line 110 of file SolverSystem.h.

Referenced by SolverSystem::getMooseKSPNormType(), and SolverSystem::setMooseKSPNormType().

◆ _last_nl_rnorm

Real NonlinearSystemBase::_last_nl_rnorm
inherited

◆ _matrix_tag_active_flags

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

Active flags for tagged matrices.

Definition at line 1027 of file SystemBase.h.

Referenced by SystemBase::activateAllMatrixTags(), SystemBase::deactivateAllMatrixTags(), and SystemBase::matrixTagActive().

◆ _max_var_n_dofs_per_elem

size_t SystemBase::_max_var_n_dofs_per_elem
protectedinherited

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

Definition at line 1043 of file SystemBase.h.

Referenced by SystemBase::assignMaxVarNDofsPerElem(), and SystemBase::getMaxVarNDofsPerElem().

◆ _max_var_n_dofs_per_node

size_t SystemBase::_max_var_n_dofs_per_node
protectedinherited

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

Definition at line 1046 of file SystemBase.h.

Referenced by SystemBase::assignMaxVarNDofsPerNode(), and SystemBase::getMaxVarNDofsPerNode().

◆ _max_var_number

unsigned int SystemBase::_max_var_number
protectedinherited

Maximum variable number.

Definition at line 1000 of file SystemBase.h.

Referenced by SystemBase::addVariable(), and SystemBase::getMaxVariableNumber().

◆ _mesh

MooseMesh& SystemBase::_mesh
protectedinherited

◆ _n_iters

unsigned int NonlinearSystemBase::_n_iters
protectedinherited

◆ _n_linear_iters

unsigned int NonlinearSystemBase::_n_linear_iters
protectedinherited

◆ _n_residual_evaluations

unsigned int NonlinearSystemBase::_n_residual_evaluations
protectedinherited

Total number of residual evaluations that have been performed.

Definition at line 918 of file NonlinearSystemBase.h.

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

◆ _name

std::string SystemBase::_name
protectedinherited

The name of this system.

Definition at line 993 of file SystemBase.h.

◆ _need_residual_ghosted

bool NonlinearSystemBase::_need_residual_ghosted
protectedinherited

◆ _nl_matrix_tags

std::set<TagID> NonlinearSystemBase::_nl_matrix_tags
protectedinherited

Matrix tags to temporarily store all tags associated with the current system.

Definition at line 826 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeJacobian(), and NonlinearSystemBase::computeJacobianBlocks().

◆ _nl_vector_tags

std::set<TagID> NonlinearSystemBase::_nl_vector_tags
protectedinherited

Vector tags to temporarily store all tags associated with the current system.

Definition at line 823 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeResidualTag().

◆ _nodal_bcs

MooseObjectTagWarehouse<NodalBCBase> NonlinearSystemBase::_nodal_bcs
protectedinherited

◆ _nodal_dampers

MooseObjectWarehouse<NodalDamper> NonlinearSystemBase::_nodal_dampers
protectedinherited

◆ _nodal_kernels

MooseObjectTagWarehouse<NodalKernelBase> NonlinearSystemBase::_nodal_kernels
protectedinherited

◆ _num_residual_evaluations

unsigned int NonlinearSystemBase::_num_residual_evaluations
inherited

Definition at line 555 of file NonlinearSystemBase.h.

◆ _numbered_vars

std::vector<std::vector<MooseVariableFieldBase *> > SystemBase::_numbered_vars
protectedinherited

Map variable number to its pointer.

Definition at line 1052 of file SystemBase.h.

Referenced by SystemBase::addVariable(), and SystemBase::getVariable().

◆ _off_diagonals_in_auto_scaling

bool NonlinearSystemBase::_off_diagonals_in_auto_scaling
protectedinherited

Whether to include off diagonals when determining automatic scaling factors.

Definition at line 975 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::initialSetup(), and NonlinearSystemBase::offDiagonalsInAutoScaling().

◆ _pc_side

Moose::PCSideType SolverSystem::_pc_side
protectedinherited

Preconditioning side.

Definition at line 108 of file SolverSystem.h.

Referenced by SolverSystem::getPCSide(), and SolverSystem::setPCSide().

◆ _pg_moose_app

MooseApp& PerfGraphInterface::_pg_moose_app
protectedinherited

The MooseApp that owns the PerfGraph.

Definition at line 124 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::perfGraph().

◆ _pre_smo_residual

Real NonlinearSystemBase::_pre_smo_residual
protectedinherited

The pre-SMO residual, see setPreSMOResidual for a detailed explanation.

Definition at line 928 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::preSMOResidual(), and NonlinearSystem::solve().

◆ _preconditioner

std::shared_ptr<MoosePreconditioner> NonlinearSystemBase::_preconditioner
protectedinherited

◆ _predictor

std::shared_ptr<Predictor> NonlinearSystemBase::_predictor
protectedinherited

◆ _prefix

const std::string PerfGraphInterface::_prefix
protectedinherited

A prefix to use for all sections.

Definition at line 127 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::timedSectionName().

◆ _preset_nodal_bcs

MooseObjectWarehouse<DirichletBCBase> NonlinearSystemBase::_preset_nodal_bcs
protectedinherited

◆ _print_all_var_norms

bool NonlinearSystemBase::_print_all_var_norms
protectedinherited

Definition at line 934 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::printAllVariableNorms().

◆ _raw_grad_container

std::vector<std::unique_ptr<NumericVector<Number> > > SystemBase::_raw_grad_container
protectedinherited

A cache for storing gradients at dof locations.

We store it on the system because we create copies of variables on each thread and that would lead to increased data duplication when using threading-based parallelism.

Definition at line 1073 of file SystemBase.h.

Referenced by LinearSystem::computeGradients(), SystemBase::gradientContainer(), and SystemBase::initialSetup().

◆ _Re_non_time

NumericVector<Number>* NonlinearSystemBase::_Re_non_time
protectedinherited

◆ _Re_non_time_tag

TagID NonlinearSystemBase::_Re_non_time_tag
protectedinherited

◆ _Re_tag

TagID NonlinearSystemBase::_Re_tag
protectedinherited

Used for the residual vector from PETSc.

Definition at line 837 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::NonlinearSystemBase(), and NonlinearSystemBase::residualVectorTag().

◆ _Re_time

NumericVector<Number>* NonlinearSystemBase::_Re_time
protectedinherited

◆ _Re_time_tag

TagID NonlinearSystemBase::_Re_time_tag
protectedinherited

◆ _resid_vs_jac_scaling_param

Real NonlinearSystemBase::_resid_vs_jac_scaling_param
protectedinherited

The param that indicates the weighting of the residual vs the Jacobian in determining variable scaling parameters.

A value of 1 indicates pure residual-based scaling. A value of 0 indicates pure Jacobian-based scaling

Definition at line 961 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::autoScalingParam(), and NonlinearSystemBase::computeScaling().

◆ _residual_copy

std::unique_ptr<NumericVector<Number> > NonlinearSystemBase::_residual_copy
protectedinherited

Copy of the residual vector, or nullptr if a copy is not needed.

Definition at line 812 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeResidualInternal(), NonlinearSystemBase::preInit(), and NonlinearSystemBase::residualCopy().

◆ _residual_ghosted

NumericVector<Number>* NonlinearSystemBase::_residual_ghosted
protectedinherited

◆ _saved_dot_old

NumericVector<Real>* SystemBase::_saved_dot_old
protectedinherited

Definition at line 1034 of file SystemBase.h.

Referenced by SystemBase::restoreOldSolutions(), and SystemBase::saveOldSolutions().

◆ _saved_dotdot_old

NumericVector<Real>* SystemBase::_saved_dotdot_old
protectedinherited

Definition at line 1035 of file SystemBase.h.

Referenced by SystemBase::restoreOldSolutions(), and SystemBase::saveOldSolutions().

◆ _saved_old

NumericVector<Real>* SystemBase::_saved_old
protectedinherited

Definition at line 1030 of file SystemBase.h.

◆ _saved_older

NumericVector<Real>* SystemBase::_saved_older
protectedinherited

Definition at line 1031 of file SystemBase.h.

◆ _scalar_kernels

MooseObjectTagWarehouse<ScalarKernelBase> NonlinearSystemBase::_scalar_kernels
protectedinherited

◆ _scaling_group_variables

std::vector<std::vector<std::string> > NonlinearSystemBase::_scaling_group_variables
protectedinherited

A container of variable groupings that can be used in scaling calculations.

This can be useful for simulations in which vector-like variables are split into invidual scalar-field components like for solid/fluid mechanics

Definition at line 966 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::scalingGroupVariables(), and NonlinearSystemBase::setupScalingData().

◆ _scaling_matrix

std::unique_ptr<libMesh::DiagonalMatrix<Number> > NonlinearSystemBase::_scaling_matrix
protectedinherited

◆ _serialized_solution

std::unique_ptr<NumericVector<Number> > SystemBase::_serialized_solution
protectedinherited

Serialized version of the solution vector, or nullptr if a serialized solution is not needed.

Definition at line 1068 of file SystemBase.h.

Referenced by AuxiliarySystem::compute(), SolverSystem::preInit(), SystemBase::serializedSolution(), SolverSystem::serializeSolution(), AuxiliarySystem::serializeSolution(), and SolverSystem::setSolution().

◆ _solution_is_invalid

bool SolverSystem::_solution_is_invalid
protectedinherited

Boolean to see if solution is invalid.

Definition at line 113 of file SolverSystem.h.

◆ _solution_states_initialized

bool SystemBase::_solution_states_initialized
protectedinherited

Whether or not the solution states have been initialized.

Definition at line 1061 of file SystemBase.h.

Referenced by SystemBase::initSolutionState(), and SystemBase::solutionStatesInitialized().

◆ _splits

MooseObjectWarehouseBase<Split> NonlinearSystemBase::_splits
protectedinherited

◆ _subproblem

SubProblem& SystemBase::_subproblem
protectedinherited

◆ _sys

libMesh::System& NonlinearSystemBase::_sys
inherited

◆ _tagged_matrices

std::vector<libMesh::SparseMatrix<Number> *> SystemBase::_tagged_matrices
protectedinherited

◆ _tagged_vectors

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

◆ _time_integrators

std::vector<std::shared_ptr<TimeIntegrator> > SystemBase::_time_integrators
protectedinherited

◆ _u_dot

NumericVector<Number>* SystemBase::_u_dot
protectedinherited

solution vector for u^dot

Definition at line 1006 of file SystemBase.h.

Referenced by SystemBase::addDotVectors(), NonlinearSystemBase::setSolutionUDot(), and SystemBase::solutionUDot().

◆ _u_dot_old

NumericVector<Number>* SystemBase::_u_dot_old
protectedinherited

old solution vector for u^dot

Definition at line 1011 of file SystemBase.h.

Referenced by SystemBase::addDotVectors(), NonlinearSystemBase::setSolutionUDotOld(), and SystemBase::solutionUDotOld().

◆ _u_dotdot

NumericVector<Number>* SystemBase::_u_dotdot
protectedinherited

solution vector for u^dotdot

Definition at line 1008 of file SystemBase.h.

Referenced by SystemBase::addDotVectors(), NonlinearSystemBase::setSolutionUDotDot(), and SystemBase::solutionUDotDot().

◆ _u_dotdot_old

NumericVector<Number>* SystemBase::_u_dotdot_old
protectedinherited

old solution vector for u^dotdot

Definition at line 1013 of file SystemBase.h.

Referenced by SystemBase::addDotVectors(), NonlinearSystemBase::setSolutionUDotDotOld(), and SystemBase::solutionUDotDotOld().

◆ _use_finite_differenced_preconditioner

bool NonlinearSystemBase::_use_finite_differenced_preconditioner
protectedinherited

◆ _use_pre_smo_residual

bool NonlinearSystemBase::_use_pre_smo_residual
protectedinherited

Whether to use the pre-SMO initial residual in the relative convergence check.

Definition at line 932 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::setPreSMOResidual(), NonlinearSystemBase::shouldEvaluatePreSMOResidual(), and NonlinearSystemBase::usePreSMOResidual().

◆ _var_all_dof_indices

std::vector<dof_id_type> SystemBase::_var_all_dof_indices
protectedinherited

Container for the dof indices of a given variable.

Definition at line 1064 of file SystemBase.h.

Referenced by SystemBase::getVariableGlobalDoFs(), and SystemBase::setVariableGlobalDoFs().

◆ _var_kind

Moose::VarKindType SystemBase::_var_kind
protectedinherited

default kind of variables in this system

Definition at line 1038 of file SystemBase.h.

Referenced by SystemBase::varKind().

◆ _var_map

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

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

Definition at line 998 of file SystemBase.h.

Referenced by SystemBase::addVariable(), SystemBase::getSubdomainsForVar(), and SystemBase::getVariableBlocks().

◆ _var_to_copy

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

◆ _variable_autoscaled

std::vector<bool> NonlinearSystemBase::_variable_autoscaled
protectedinherited

Container to hold flag if variable is to participate in autoscaling.

Definition at line 969 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeScaling(), and NonlinearSystemBase::setupScalingData().

◆ _vars

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

Variable warehouses (one for each thread)

Definition at line 996 of file SystemBase.h.

Referenced by NonlinearSystemBase::addBoundaryCondition(), NonlinearSystemBase::addInterfaceKernel(), AuxiliarySystem::addVariable(), SystemBase::addVariable(), SystemBase::applyScalingFactors(), NonlinearSystemBase::assembleScalingVector(), SystemBase::clearAllDofIndices(), AuxiliarySystem::compute(), SystemBase::customSetup(), SystemBase::getActualFieldVariable(), SystemBase::getFieldVariable(), SystemBase::getFVVariable(), AuxiliarySystem::getMinQuadratureOrder(), SystemBase::getMinQuadratureOrder(), SystemBase::getScalarVariable(), SystemBase::getScalarVariables(), SystemBase::getVariable(), SystemBase::getVariableNames(), SystemBase::getVariables(), LinearSystem::initialSetup(), SystemBase::initialSetup(), SystemBase::jacobianSetup(), SystemBase::nFieldVariables(), SystemBase::nFVVariables(), SystemBase::nVariables(), SystemBase::prepare(), SystemBase::prepareFace(), SystemBase::prepareLowerD(), SystemBase::prepareNeighbor(), SystemBase::reinitElem(), SystemBase::reinitElemFace(), SystemBase::reinitLowerD(), SystemBase::reinitNeighbor(), SystemBase::reinitNeighborFace(), SystemBase::reinitNode(), SystemBase::reinitNodeFace(), SystemBase::reinitNodes(), SystemBase::reinitNodesNeighbor(), SystemBase::reinitScalars(), SystemBase::residualSetup(), SystemBase::setActiveScalarVariableCoupleableVectorTags(), SystemBase::setActiveVariableCoupleableVectorTags(), NonlinearSystemBase::setupScalingData(), SystemBase::sizeVariableMatrixData(), SystemBase::subdomainSetup(), and SystemBase::timestepSetup().

◆ _vars_to_be_zeroed_on_jacobian

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

◆ _vars_to_be_zeroed_on_residual

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

◆ _vecs_to_zero_for_residual

std::vector<std::string> NonlinearSystemBase::_vecs_to_zero_for_residual
protectedinherited

vectors that will be zeroed before a residual computation

Definition at line 912 of file NonlinearSystemBase.h.

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

◆ _verbose

bool SystemBase::_verbose
protectedinherited

True if printing out additional information.

Definition at line 1058 of file SystemBase.h.

Referenced by SystemBase::applyScalingFactors(), and SystemBase::setVerboseFlag().


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