https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
MooseEigenSystem Class Reference

#include <MooseEigenSystem.h>

Inheritance diagram for MooseEigenSystem:
[legend]

Public Types

enum  SYSTEMTAG { ALL , EIGEN }
 System or kernel tags. More...
 

Public Member Functions

 MooseEigenSystem (FEProblemBase &problem, const std::string &name)
 
virtual ~MooseEigenSystem ()
 
virtual void addKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a kernel.
 
virtual void markEigenVariable (const VariableName &var_name)
 Mark a variable as a variable of the eigen system.
 
void scaleSystemSolution (SYSTEMTAG tag, Real scaling_factor)
 Scale the solution vector.
 
void combineSystemSolution (SYSTEMTAG tag, const std::vector< Real > &coefficients)
 Linear combination of the solution vectors.
 
void initSystemSolution (SYSTEMTAG tag, Real v)
 Initialize the solution vector with a constant value.
 
void initSystemSolutionOld (SYSTEMTAG tag, Real v)
 
void eigenKernelOnOld ()
 Ask eigenkernels to operate on old or current solution vectors.
 
void eigenKernelOnCurrent ()
 
void buildSystemDoFIndices (SYSTEMTAG tag=ALL)
 Build DoF indices for a system.
 
bool activeOnOld ()
 Return if eigen kernels should be on old solution.
 
const std::set< VariableName > & getEigenVariableNames () const
 Get variable names of the eigen system.
 
bool containsEigenKernel () const
 Weather or not the system contains eigen kernels.
 
virtual void solve () override
 Solve the system (using libMesh magic)
 
virtual void stopSolve (const ExecFlagType &exec_flag, const std::set< TagID > &vector_tags_to_close) override
 Quit the current solve as soon as possible.
 
virtual unsigned int getCurrentNonlinearIterationNumber () override
 Returns the current nonlinear iteration number.
 
virtual void setupFiniteDifferencedPreconditioner () override
 
virtual bool converged () override
 Returns the convergence state.
 
virtual NumericVector< Number > & RHS () override
 
virtual libMesh::NonlinearSolver< Number > * nonlinearSolver () override
 
virtual SNES getSNES () override
 
virtual libMesh::NonlinearImplicitSystem & sys ()
 
virtual void attachPreconditioner (libMesh::Preconditioner< Number > *preconditioner) override
 Attach a customized preconditioner that requires physics knowledge.
 
virtual void residualAndJacobianTogether () override
 Call this method if you want the residual and Jacobian to be computed simultaneously.
 
virtual void potentiallySetupFiniteDifferencing () override
 Create finite differencing contexts for assembly of the Jacobian and/or approximating the action of the Jacobian on vectors (e.g.
 
virtual void preInit () override
 This is called prior to the libMesh system has been init'd.
 
void reinitMortarFunctors ()
 Update the mortar functors if the mesh has changed.
 
bool computedScalingJacobian () const
 
virtual void turnOffJacobian ()
 Turn off the Jacobian (must be called before equation system initialization)
 
bool computingPreSMOResidual ()
 Returns true if this system is currently computing the pre-SMO residual for a solve.
 
virtual void initialSetup () override
 Setup Functions.
 
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 addHDGKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a hybridized discontinuous Galerkin (HDG) kernel.
 
virtual void addNodalKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a NodalKernel.
 
void addScalarKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a scalar kernel.
 
void addBoundaryCondition (const std::string &bc_name, const std::string &name, InputParameters &parameters)
 Adds a boundary condition.
 
virtual void addKokkosKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a Kokkos kernel.
 
virtual void addKokkosNodalKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a Kokkos nodal kernel.
 
void addKokkosBoundaryCondition (const std::string &bc_name, const std::string &name, InputParameters &parameters)
 Adds a Kokkos boundary condition.
 
void addConstraint (const std::string &c_name, const std::string &name, InputParameters &parameters)
 Adds a Constraint.
 
void addDiracKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a Dirac kernel.
 
void addDGKernel (std::string dg_kernel_name, const std::string &name, InputParameters &parameters)
 Adds a DG kernel.
 
void addInterfaceKernel (std::string interface_kernel_name, const std::string &name, InputParameters &parameters)
 Adds an interface kernel.
 
void addDamper (const std::string &damper_name, const std::string &name, InputParameters &parameters)
 Adds a damper.
 
void addSplit (const std::string &split_name, const std::string &name, InputParameters &parameters)
 Adds a split.
 
std::shared_ptr< Split > getSplit (const std::string &name)
 Retrieves a split by name.
 
MooseObjectWarehouseBase< Split > & getSplits ()
 Retrieves all splits.
 
bool shouldEvaluatePreSMOResidual () const
 We offer the option to check convergence against the pre-SMO residual.
 
void setPreSMOResidual (bool use)
 Set whether to evaluate the pre-SMO residual and use it in the subsequent relative convergence checks.
 
const bool & usePreSMOResidual () const
 Whether we are using pre-SMO residual in relative convergence checks.
 
Real referenceResidual () const
 The reference residual used in relative convergence check.
 
Real preSMOResidual () const
 The pre-SMO residual.
 
Real initialResidual () const
 The initial residual.
 
void setInitialResidual (Real r)
 Record the initial residual (for later relative convergence check)
 
void zeroVectorForResidual (const std::string &vector_name)
 
void setInitialSolution ()
 
void setKokkosInitialSolution ()
 
void setConstraintSecondaryValues (NumericVector< Number > &solution, bool displaced)
 Sets the value of constrained variables in the solution vector.
 
void constraintResiduals (NumericVector< Number > &residual, bool displaced)
 Add residual contributions from Constraints.
 
void computeResidualTag (NumericVector< Number > &residual, TagID tag_id)
 Computes residual for a given tag.
 
void computeResidualTags (const std::set< TagID > &tags)
 Form multiple tag-associated residual vectors for all the given tags.
 
void computeResidualAndJacobianTags (const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
 Form possibly multiple tag-associated vectors and matrices.
 
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.
 
void computeKokkosResidualAndJacobian (const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
 
void computeResidual (NumericVector< Number > &residual, TagID tag_id)
 Form a residual vector for a given tag.
 
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.
 
void constraintJacobians (const SparseMatrix< Number > &jacobian_to_view, bool displaced)
 Add jacobian contributions from Constraints.
 
void computeJacobianTags (const std::set< TagID > &tags)
 Computes multiple (tag associated) Jacobian matricese.
 
bool computeScaling ()
 Method used to obtain scaling factors for variables.
 
void computeJacobian (libMesh::SparseMatrix< Number > &jacobian, const std::set< TagID > &tags)
 Associate jacobian to systemMatrixTag, and then form a matrix for all the tags.
 
void computeJacobian (libMesh::SparseMatrix< Number > &jacobian)
 Take all tags in the system, and form a matrix for all tags in the system.
 
void computeJacobianBlocks (std::vector< JacobianBlock * > &blocks)
 Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditioning matrices.
 
void computeJacobianBlocks (std::vector< JacobianBlock * > &blocks, const std::set< TagID > &tags)
 
Real computeDamping (const NumericVector< Number > &solution, const NumericVector< Number > &update)
 Compute damping.
 
void onTimestepBegin ()
 Called at the beginning of the time step.
 
virtual void subdomainSetup (SubdomainID subdomain, THREAD_ID tid)
 Called from assembling when we hit a new subdomain.
 
virtual void subdomainSetup ()
 
void overwriteNodeFace (NumericVector< Number > &soln)
 Called from explicit time stepping to overwrite boundary positions (explicit dynamics).
 
void updateActive (THREAD_ID tid)
 Update active objects of Warehouses owned by NonlinearSystemBase.
 
virtual void setSolutionUDot (const NumericVector< Number > &udot)
 Set transient term used by residual and Jacobian evaluation.
 
virtual void setSolutionUDotDot (const NumericVector< Number > &udotdot)
 Set transient term used by residual and Jacobian evaluation.
 
NumericVector< Number > & getResidualTimeVector ()
 Return a numeric vector that is associated with the time tag.
 
NumericVector< Number > & getResidualNonTimeVector ()
 Return a numeric vector that is associated with the nontime tag.
 
NumericVector< Number > & residualVector (TagID tag)
 Return a residual vector that is associated with the residual tag.
 
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.
 
void setPreconditioner (std::shared_ptr< MoosePreconditioner > pc)
 Sets a preconditioner.
 
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.
 
void useFieldSplitPreconditioner (FieldSplitPreconditionerBase *fsp)
 If called with a non-null object true this system will use a field split preconditioner matrix.
 
FieldSplitPreconditionerBase & getFieldSplitPreconditioner ()
 
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.
 
void assembleConstraintsSeparately (bool separately=true)
 Indicates whether to assemble residual and Jacobian after each constraint application.
 
void setupDampers ()
 Setup damping stuff (called before we actually start)
 
void reinitIncrementAtQpsForDampers (THREAD_ID tid, const std::set< MooseVariable * > &damped_vars)
 Compute the incremental change in variables at QPs for dampers.
 
void reinitIncrementAtNodeForDampers (THREAD_ID tid, const std::set< MooseVariable * > &damped_vars)
 Compute the incremental change in variables at nodes for dampers.
 
virtual unsigned int nNonlinearIterations () const
 Return the number of non-linear iterations.
 
virtual unsigned int nLinearIterations () const
 Return the number of linear iterations.
 
unsigned int nResidualEvaluations () const
 Return the total number of residual evaluations done so far in this calculation.
 
virtual Real finalNonlinearResidual () const
 Return the final nonlinear residual.
 
Real nonlinearNorm () const
 Return the last nonlinear norm.
 
void printAllVariableNorms (bool state)
 Force the printing of all variable norms after each solve.
 
void debuggingResiduals (bool state)
 
void setPredictor (std::shared_ptr< Predictor > predictor)
 
Predictor * getPredictor ()
 
bool needBoundaryMaterialOnSide (BoundaryID bnd_id, THREAD_ID tid) const
 Indicated whether this system needs material properties on boundaries.
 
bool needInterfaceMaterialOnSide (BoundaryID bnd_id, THREAD_ID tid) const
 Indicated whether this system needs material properties on interfaces.
 
bool needInternalNeighborSideMaterial (SubdomainID subdomain_id, THREAD_ID tid) const
 Indicates whether this system needs material properties on internal sides.
 
bool doingDG () const
 Getter for _doing_dg.
 
MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse ()
 Access functions to Warehouses from outside NonlinearSystemBase.
 
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.
 
const MooseObjectTagWarehouse< ScalarKernelBase > & getScalarKernelWarehouse () const
 
const MooseObjectTagWarehouse< NodalKernelBase > & getNodalKernelWarehouse () const
 
MooseObjectTagWarehouse< HDGKernel > & getHDGKernelWarehouse ()
 
const MooseObjectWarehouse< ElementDamper > & getElementDamperWarehouse () const
 
const MooseObjectWarehouse< NodalDamper > & getNodalDamperWarehouse () const
 
const ConstraintWarehouse & getConstraintWarehouse () const
 
const MooseObjectTagWarehouse< NodalBCBase > & getNodalBCWarehouse () const
 Return the NodalBCBase warehouse.
 
bool hasSaveIn () const
 Weather or not the nonlinear system has save-ins.
 
bool hasDiagSaveIn () const
 Weather or not the nonlinear system has diagonal Jacobian save-ins.
 
virtual libMesh::System & system () override
 Get the reference to the libMesh system.
 
virtual const libMesh::System & system () 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.
 
TagID nonTimeVectorTag () const override
 
TagID residualVectorTag () const override
 
TagID systemMatrixTag () const override
 Return the Matrix Tag ID for System.
 
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.
 
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)
 
void destroyColoring ()
 Destroy the coloring object if it exists.
 
void setConvergenceName (const ConvergenceName &convergence_name)
 Sets the name of the associated Convergence object.
 
Convergence & convergence ()
 Retrieves the associated Convergence object.
 
virtual void reinitNodeFace (const Node *node, BoundaryID bnd_id, THREAD_ID tid)
 Reinit nodal assembly info on a face.
 
virtual void restoreSolutions () override final
 Restore current solutions (call after your solve failed)
 
void serializeSolution ()
 
void setSolution (const NumericVector< Number > &soln)
 Set the solution to a given vector.
 
void applyFixedPointRelaxation (const Real relaxation_factor, const Moose::SolutionIterationType iteration_type)
 Apply solution under/over-relaxation for fixed point iterations.
 
void setPCSide (MooseEnum pcs)
 Set the side on which the preconditioner is applied to.
 
Moose::PCSideType getPCSide ()
 Get the current preconditioner side.
 
void setMooseKSPNormType (MooseEnum kspnorm)
 Set the norm in which the linear convergence will be measured.
 
Moose::MooseKSPNormType getMooseKSPNormType ()
 Get the norm in which the linear convergence is measured.
 
virtual const NumericVector< Number > *const & currentSolution () const override final
 The solution vector that is currently being operated on.
 
virtual void compute (ExecFlagType type) override
 Compute time derivatives, auxiliary variables, etc.
 
unsigned int number () const
 Gets the number of this system.
 
MooseMesh & mesh ()
 
const MooseMesh & mesh () const
 
SubProblem & subproblem ()
 
const SubProblem & subproblem () const
 
FEProblemBase & feProblem ()
 
const FEProblemBase & feProblem () const
 
void applyScalingFactors (const std::vector< Real > &inverse_scaling_factors)
 Applies scaling factors to the system's variables.
 
bool computingScalingJacobian () const
 Whether we are computing an initial Jacobian for automatic variable scaling.
 
bool automaticScaling () const
 Getter for whether we are performing automatic scaling.
 
void automaticScaling (bool automatic_scaling)
 Setter for whether we are performing automatic scaling.
 
void setVerboseFlag (const bool &verbose)
 Sets the verbose flag.
 
virtual libMesh::DofMap & dofMap ()
 Gets writeable reference to the dof map.
 
virtual const libMesh::DofMap & dofMap () const
 Gets const reference to the dof map.
 
virtual void postInit ()
 
virtual void reinit ()
 Reinitialize the system when the degrees of freedom in this system have changed.
 
virtual void initializeObjects ()
 Called only once, just before the solve begins so objects can do some precalculations.
 
void update ()
 Update the system (doing libMesh magic)
 
void copyOldSolutions ()
 Copy the solution back in time (older -> old, etc).
 
void advanceStateHistory (Moose::SolutionIterationType iteration_type)
 Advance solution vectors and additional system-owned state together.
 
void copyPreviousSolutions (const Moose::SolutionIterationType iteration_type)
 Copy a specific type of solution back in time (current -> old -> older, etc).
 
void restoreStateHistory ()
 Restore solution vectors and additional system-owned state together.
 
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.
 
const std::vector< NumericVector< Number > * > & getSolutionStates (const Moose::SolutionIterationType iteration_type) const
 Get all of the solution states (current, old, ...) for the given iteration type.
 
std::size_t getNumSolutionStates (const Moose::SolutionIterationType iteration_type) const
 Get the number of solution states (0 = current, 1 = current + old, ...) for the given iteration type.
 
virtual 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).
 
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).
 
libMesh::ParallelType solutionStateParallelType (const unsigned int state, const Moose::SolutionIterationType iteration_type) const
 Returns the parallel type of the given solution state.
 
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.
 
virtual bool hasSolutionState (const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
 Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
 
virtual void addDotVectors ()
 Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator.
 
virtual std::vector< Number > & duDotDus ()
 
virtual Number & duDotDotDu ()
 
virtual const Number & duDotDotDu () const
 
virtual const Number & duDotDu (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.
 
virtual void restoreOldSolutions ()
 Restore the old and older solutions when the saved solutions present.
 
bool hasVector (const std::string &tag_name) const
 Check if the named vector exists in the system.
 
virtual bool hasVector (TagID tag_id) const
 Check if the tagged vector exists in the system.
 
virtual std::set< TagID > defaultVectorTags () const
 Get the default vector tags associated with this system.
 
virtual std::set< TagID > defaultMatrixTags () const
 Get the default matrix tags associted with this system.
 
virtual void associateVectorToTag (NumericVector< Number > &vec, TagID tag)
 Associate a vector for a given tag.
 
virtual void disassociateVectorFromTag (NumericVector< Number > &vec, TagID tag)
 Disassociate a given vector from a given tag.
 
virtual void disassociateVectorFromTag (TagID tag)
 Disassociate any vector that is associated with a given tag.
 
virtual void disassociateDefaultVectorTags ()
 Disassociate the vectors associated with the default vector tags of this system.
 
virtual bool hasMatrix (TagID tag) const
 Check if the tagged matrix exists in the system.
 
virtual libMesh::SparseMatrix< Number > & getMatrix (TagID tag)
 Get a raw SparseMatrix.
 
virtual const libMesh::SparseMatrix< Number > & getMatrix (TagID tag) const
 Get a raw SparseMatrix.
 
virtual void activateAllMatrixTags ()
 Make all existing matrices active.
 
virtual bool matrixTagActive (TagID tag) const
 If or not a matrix tag is active.
 
virtual void deactivateAllMatrixTags ()
 Make matrices inactive.
 
void closeTaggedMatrices (const std::set< TagID > &tags)
 Close all matrices associated the tags.
 
void flushTaggedMatrices (const std::set< TagID > &tags)
 flushes all matrices associated to tags.
 
virtual void associateMatrixToTag (libMesh::SparseMatrix< Number > &matrix, TagID tag)
 Associate a matrix to a tag.
 
virtual void disassociateMatrixFromTag (libMesh::SparseMatrix< Number > &matrix, TagID tag)
 Disassociate a matrix from a tag.
 
virtual void disassociateMatrixFromTag (TagID tag)
 Disassociate any matrix that is associated with a given tag.
 
virtual void disassociateDefaultMatrixTags ()
 Disassociate the matrices associated with the default matrix tags of this system.
 
virtual NumericVector< Number > & serializedSolution ()
 Returns a reference to a serialized version of the solution vector for this subproblem.
 
virtual void augmentSendList (std::vector< dof_id_type > &send_list)
 Will modify the send_list to add all of the extra ghosted dofs for this system.
 
virtual void addVariable (const std::string &var_type, const std::string &var_name, InputParameters &parameters)
 Canonical method for adding a variable.
 
virtual bool isArrayVariable (const std::string &var_name) const
 If a variable is an array variable.
 
virtual bool isScalarVariable (unsigned int var_name) const
 
MooseVariableFieldBase & getVariable (THREAD_ID tid, const std::string &var_name) const
 Gets a reference to a variable of with specified name.
 
MooseVariableFieldBase & getVariable (THREAD_ID tid, unsigned int var_number) const
 Gets a reference to a variable with specified number.
 
template<typename T >
MooseVariableFE< T > & getFieldVariable (THREAD_ID tid, const std::string &var_name)
 Gets a reference to a variable of with specified name.
 
template<typename T >
MooseVariableFE< T > & getFieldVariable (THREAD_ID tid, unsigned int var_number)
 Gets a reference to a variable with specified number.
 
template<typename T >
MooseVariableField< T > & getActualFieldVariable (THREAD_ID tid, const std::string &var_name)
 Returns a field variable pointer - this includes finite volume variables.
 
template<typename T >
MooseVariableField< T > & getActualFieldVariable (THREAD_ID tid, unsigned int var_number)
 Returns a field variable pointer - this includes finite volume variables.
 
template<typename T >
MooseVariableFV< T > & getFVVariable (THREAD_ID tid, const std::string &var_name)
 Return a finite volume variable.
 
virtual MooseVariableScalar & getScalarVariable (THREAD_ID tid, const std::string &var_name) const
 Gets a reference to a scalar variable with specified number.
 
virtual MooseVariableScalar & getScalarVariable (THREAD_ID tid, unsigned int var_number) const
 Gets a reference to a variable with specified number.
 
virtual const std::set< SubdomainID > * getVariableBlocks (unsigned int var_number)
 Get the block where a variable of this system is defined.
 
virtual unsigned int nVariables () const
 Get the number of variables in this system.
 
unsigned int nFieldVariables () const
 Get the number of field variables in this system.
 
unsigned int nFVVariables () const
 Get the number of finite volume variables in this system.
 
std::size_t getMaxVarNDofsPerElem () const
 Gets the maximum number of dofs used by any one variable on any one element.
 
std::size_t getMaxVarNDofsPerNode () const
 Gets the maximum number of dofs used by any one variable on any one node.
 
void assignMaxVarNDofsPerElem (std::size_t max_dofs)
 assign the maximum element dofs
 
void assignMaxVarNDofsPerNode (std::size_t max_dofs)
 assign the maximum node dofs
 
virtual void addVariableToZeroOnResidual (std::string var_name)
 Adds this variable to the list of variables to be zeroed during each residual evaluation.
 
virtual void addVariableToZeroOnJacobian (std::string var_name)
 Adds this variable to the list of variables to be zeroed during each Jacobian evaluation.
 
virtual void zeroVariables (std::vector< std::string > &vars_to_be_zeroed)
 Zero out the solution for the list of variables passed in.
 
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()
 
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()
 
virtual libMesh::Order getMinQuadratureOrder ()
 Get minimal quadrature order needed for integrating variables in this system.
 
virtual void prepare (THREAD_ID tid)
 Prepare the system for use.
 
virtual void prepareFace (THREAD_ID tid, bool resize_data)
 Prepare the system for use on sides.
 
virtual void prepareNeighbor (THREAD_ID tid)
 Prepare the system for use.
 
virtual void prepareLowerD (THREAD_ID tid)
 Prepare the system for use for lower dimensional elements.
 
virtual void reinitElem (const Elem *elem, THREAD_ID tid)
 Reinit an element assembly info.
 
virtual void reinitElemFace (const Elem *elem, unsigned int side, THREAD_ID tid)
 Reinit assembly info for a side of an element.
 
virtual void reinitNeighborFace (const Elem *elem, unsigned int side, THREAD_ID tid)
 Compute the values of the variables at all the current points.
 
virtual void reinitNeighbor (const Elem *elem, THREAD_ID tid)
 Compute the values of the variables at all the current points.
 
virtual void reinitLowerD (THREAD_ID tid)
 Compute the values of the variables on the lower dimensional element.
 
virtual void reinitNode (const Node *node, THREAD_ID tid)
 Reinit nodal assembly info.
 
virtual void reinitNodes (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of nodes.
 
virtual void reinitNodesNeighbor (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of neighbor nodes.
 
virtual void reinitScalars (THREAD_ID tid, bool reinit_for_derivative_reordering=false)
 Reinit scalar varaibles.
 
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.
 
const std::vector< MooseVariableFieldBase * > & getVariables (THREAD_ID tid)
 
const VariableWarehouse & variableWarehouse (THREAD_ID tid=0) const
 
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.
 
void removeVector (const std::string &name)
 Remove a vector from the system with the given name.
 
void removeVector (TagID tag_id)
 Remove a solution length vector from the system with the specified TagID.
 
NumericVector< Number > & addVector (const std::string &vector_name, const bool project, const libMesh::ParallelType type)
 Adds a solution length vector to the system.
 
NumericVector< Number > & addVector (TagID tag, const bool project, const libMesh::ParallelType type)
 Adds a solution length vector to the system with the specified TagID.
 
void closeTaggedVector (const TagID tag)
 Close vector with the given tag.
 
void closeTaggedVectors (const std::set< TagID > &tags)
 Close all vectors for given tags.
 
void zeroTaggedVector (const TagID tag)
 Zero vector with the given tag.
 
void zeroTaggedVectors (const std::set< TagID > &tags)
 Zero all vectors for given tags.
 
void setVariableGlobalDoFs (const std::string &var_name)
 set all the global dof indices for a variable
 
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
 
libMesh::SparseMatrix< Number > & addMatrix (TagID tag)
 Adds a matrix with a given tag.
 
void removeMatrix (TagID tag)
 Removes a matrix with a given tag.
 
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.
 
virtual void computeVariables (const NumericVector< Number > &)
 
void copyVars (libMesh::ExodusII_IO &io)
 
virtual void copySolutionsBackwards ()
 Copy current solution into old and older.
 
void copyStateHistoryBackwards ()
 Copy solution vectors and additional system-owned state into older states.
 
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.
 
void addScalingVector ()
 Add the scaling factor vector to the system.
 
bool solutionStatesInitialized () const
 Whether or not the solution states have been initialized via initSolutionState()
 
void clearAllDofIndices ()
 Clear all dof indices from moose variables.
 
void setActiveVariableCoupleableVectorTags (const std::set< TagID > &vtags, THREAD_ID tid)
 Set the active vector tags for the variables.
 
void setActiveScalarVariableCoupleableVectorTags (const std::set< TagID > &vtags, THREAD_ID tid)
 Set the active vector tags for the scalar variables.
 
Moose::VarKindType varKind () const
 
void copyTimeIntegrators (const SystemBase &other_sys)
 Copy time integrators from another system.
 
const TimeIntegrator & getTimeIntegrator (const unsigned int var_num) const
 Retrieve the time integrator that integrates the given variable's equation.
 
const TimeIntegrator * queryTimeIntegrator (const unsigned int var_num) const
 Retrieve the time integrator that integrates the given variable's equation.
 
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
 
void skipNextSolutionToOldCopy ()
 Skip the next copy from the solution vector to the old solution vector old -> older is still performed.
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
PerfGraph & perfGraph ()
 Get the PerfGraph.
 
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.
 
virtual std::vector< std::string > timeKernelVariableNames () override
 Returns the names of the variables that have time derivative kernels in the system.
 
MooseObjectTagWarehouse< ResidualObject > & getKokkosKernelWarehouse ()
 
MooseObjectTagWarehouse< ResidualObject > & getKokkosNodalKernelWarehouse ()
 
MooseObjectTagWarehouse< ResidualObject > & getKokkosNodalBCWarehouse ()
 
MooseObjectTagWarehouse< ResidualObject > & getKokkosIntegratedBCWarehouse ()
 
virtual NumericVector< Number > & getVector (const std::string &name)
 Get a raw NumericVector by name.
 
virtual const NumericVector< Number > & getVector (const std::string &name) const
 
virtual NumericVector< Number > & getVector (TagID tag)
 Get a raw NumericVector by tag.
 
virtual const NumericVector< Number > & getVector (TagID tag) const
 
virtual bool hasVariable (const std::string &var_name) const
 Query a system for a variable.
 
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.
 

Protected Member Functions

void computeScalingJacobian () override
 Compute a "Jacobian" for automatic scaling purposes.
 
void computeScalingResidual () override
 Compute a "residual" for automatic scaling purposes.
 
void computeResidualInternal (const std::set< TagID > &tags)
 Compute the residual for a given tag.
 
void computeKokkosResidual (const std::set< TagID > &tags)
 Compute residual with Kokkos objects.
 
void computeKokkosNodalBCsResidual (const std::set< TagID > &tags)
 Compute Kokkos nodal BCs.
 
void computeNodalBCsResidual (NumericVector< Number > &residual)
 Enforces nodal boundary conditions.
 
void computeNodalBCsResidual (NumericVector< Number > &residual, const std::set< TagID > &tags)
 Form a residual for BCs that at least has one of the given tags.
 
void computeNodalBCsResidual (const std::set< TagID > &tags)
 Form multiple tag-associated residual vectors for the given tags.
 
void computeNodalBCsJacobian (const std::set< TagID > &tags)
 Compute the Jacobian for nodal boundary conditions.
 
void computeNodalBCsResidualAndJacobian (const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
 Compute the residual and Jacobian together for nodal boundary conditions.
 
void computeJacobianInternal (const std::set< TagID > &tags)
 Form multiple matrices for all the tags.
 
void computeKokkosJacobian (const std::set< TagID > &tags)
 Compute Jacobian with Kokkos objects.
 
void computeDiracContributions (const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags, Moose::ComputeType compute_type)
 
void computeScalarKernelsJacobians (const std::set< TagID > &tags)
 
void enforceNodalConstraintsResidual (NumericVector< Number > &residual)
 Enforce nodal constraints.
 
bool enforceNodalConstraintsJacobian (const SparseMatrix< Number > &jacobian)
 Enforce nodal constraints in the Jacobian.
 
void mortarConstraints (Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
 Do mortar constraint residual/jacobian computations.
 
void assembleScalingVector ()
 Assemble the numeric vector of scaling factors such that it can be used during assembly of the system matrix.
 
virtual void postAddResidualObject (ResidualObject &)
 Called after any ResidualObject-derived objects are added to the system.
 
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 preSolve ()
 Perform some steps to get ready for the solver.
 
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.
 
virtual void copyAdditionalStateBackwards (Moose::SolutionIterationType, bool)
 Copy system-owned state not represented by solution vectors.
 
virtual void restoreAdditionalStates ()
 Restore system-owned state not represented by solution vectors.
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 Call to register a named section for timing.
 
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.
 
std::string timedSectionName (const std::string &section_name) const
 

Protected Attributes

std::set< VariableName > _eigen_var_names
 
bool _all_eigen_vars
 
std::set< dof_id_type > _eigen_var_indices
 
bool _active_on_old
 
unsigned int _eigen_kernel_counter
 counter of eigen kernels
 
libMesh::NonlinearImplicitSystem & _nl_implicit_sys
 
ComputeResidualFunctor _nl_residual_functor
 
ComputeFDResidualFunctor _fd_residual_functor
 
ComputeResidualAndJacobian _resid_and_jac_functor
 
NumericVector< Number > * _residual_ghosted
 ghosted form of the residual
 
std::unique_ptr< NumericVector< Number > > _residual_copy
 Copy of the residual vector, or nullptr if a copy is not needed.
 
Number _du_dot_du
 \( {du^dot}\over{du} \)
 
Number _du_dotdot_du
 \( {du^dotdot}\over{du} \)
 
TagID _Re_time_tag
 Tag for time contribution residual.
 
std::set< TagID > _nl_vector_tags
 Vector tags to temporarily store all tags associated with the current system.
 
std::set< TagID > _nl_matrix_tags
 Matrix tags to temporarily store all tags associated with the current system.
 
NumericVector< Number > * _Re_time
 residual vector for time contributions
 
TagID _Re_non_time_tag
 Tag for non-time contribution residual.
 
NumericVector< Number > * _Re_non_time
 residual vector for non-time contributions
 
TagID _Re_tag
 Used for the residual vector from PETSc.
 
TagID _Ke_non_time_tag
 Tag for non-time contribution Jacobian.
 
TagID _Ke_system_tag
 Tag for system contribution Jacobian.
 
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
 Dirac Kernel storage for each thread.
 
MooseObjectWarehouse< ElementDamper > _element_dampers
 Element Dampers for each thread.
 
MooseObjectWarehouse< NodalDamper > _nodal_dampers
 Nodal Dampers for each thread.
 
MooseObjectWarehouse< GeneralDamper > _general_dampers
 General Dampers.
 
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
 NodalKernels for each thread.
 
MooseObjectWarehouseBase< Split > _splits
 Decomposition splits.
 
ConstraintWarehouse _constraints
 Constraints storage object.
 
NumericVector< Number > * _increment_vec
 increment vector
 
std::shared_ptr< MoosePreconditioner > _preconditioner
 Preconditioner.
 
bool _use_finite_differenced_preconditioner
 Whether or not to use a finite differenced preconditioner.
 
MatFDColoring _fdcoloring
 
FieldSplitPreconditionerBase * _fsp
 The field split preconditioner if this sytem is using one.
 
bool _add_implicit_geometric_coupling_entries_to_jacobian
 Whether or not to add implicit geometric couplings to the Jacobian for FDP.
 
bool _assemble_constraints_separately
 Whether or not to assemble the residual and Jacobian after the application of each constraint.
 
bool _need_residual_ghosted
 Whether or not a ghosted copy of the residual needs to be made.
 
bool _debugging_residuals
 true if debugging residuals
 
bool _doing_dg
 true if DG is active (optimization reasons)
 
std::vector< std::string > _vecs_to_zero_for_residual
 vectors that will be zeroed before a residual computation
 
unsigned int _n_iters
 
unsigned int _n_linear_iters
 
unsigned int _n_residual_evaluations
 Total number of residual evaluations that have been performed.
 
Real _final_residual
 
std::shared_ptr< Predictor > _predictor
 If predictor is active, this is non-NULL.
 
bool _computing_pre_smo_residual
 
Real _pre_smo_residual
 The pre-SMO residual, see setPreSMOResidual for a detailed explanation.
 
Real _initial_residual
 The initial (i.e., 0th nonlinear iteration) residual, see setPreSMOResidual for a detailed explanation.
 
bool _use_pre_smo_residual
 Whether to use the pre-SMO initial residual in the relative convergence check.
 
bool _print_all_var_norms
 
bool _has_save_in
 If there is any Kernel or IntegratedBC having save_in.
 
bool _has_diag_save_in
 If there is any Kernel or IntegratedBC having diag_save_in.
 
bool _has_nodalbc_save_in
 If there is a nodal BC having save_in.
 
bool _has_nodalbc_diag_save_in
 If there is a nodal BC having diag_save_in.
 
bool _computed_scaling
 Flag used to indicate whether we have already computed the scaling Jacobian.
 
bool _compute_scaling_once
 Whether the scaling factors should only be computed once at the beginning of the simulation through an extra Jacobian evaluation.
 
Real _resid_vs_jac_scaling_param
 The param that indicates the weighting of the residual vs the Jacobian in determining variable scaling parameters.
 
std::vector< std::vector< std::string > > _scaling_group_variables
 A container of variable groupings that can be used in scaling calculations.
 
std::vector< bool > _variable_autoscaled
 Container to hold flag if variable is to participate in autoscaling.
 
std::vector< std::string > _ignore_variables_for_autoscaling
 A container for variables that do not partipate in autoscaling.
 
bool _off_diagonals_in_auto_scaling
 Whether to include off diagonals when determining automatic scaling factors.
 
std::unique_ptr< libMesh::DiagonalMatrix< Number > > _scaling_matrix
 A diagonal matrix used for computing scaling.
 
const NumericVector< Number > * _current_solution
 solution vector from solver
 
Moose::PCSideType _pc_side
 Preconditioning side.
 
Moose::MooseKSPNormType _ksp_norm
 KSP norm type.
 
bool _solution_is_invalid
 Boolean to see if solution is invalid.
 
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.
 
FEProblemBase & _fe_problem
 the governing finite element/volume problem
 
MooseApp & _app
 
Factory & _factory
 
MooseMesh & _mesh
 
std::string _name
 The name of this system.
 
std::vector< VariableWarehouse > _vars
 Variable warehouses (one for each thread)
 
std::map< unsigned int, std::set< SubdomainID > > _var_map
 Map of variables (variable id -> array of subdomains where it lives)
 
unsigned int _max_var_number
 Maximum variable number.
 
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
 
NumericVector< Number > * _u_dotdot
 solution vector for u^dotdot
 
NumericVector< Number > * _u_dot_old
 old solution vector for u^dot
 
NumericVector< Number > * _u_dotdot_old
 old solution vector for u^dotdot
 
std::vector< NumericVector< Number > * > _tagged_vectors
 Tagged vectors (pointer)
 
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
 Tagged matrices (pointer)
 
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.
 
std::vector< bool > _matrix_tag_active_flags
 Active flags for tagged matrices.
 
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
 
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.
 
size_t _max_var_n_dofs_per_node
 Maximum number of dofs for any one variable on any one node.
 
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
 Time integrator.
 
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
 Map variable number to its pointer.
 
bool _automatic_scaling
 Whether to automatically scale the variables.
 
bool _verbose
 True if printing out additional information.
 
bool _solution_states_initialized
 Whether or not the solution states have been initialized.
 
std::vector< dof_id_type > _var_all_dof_indices
 Container for the dof indices of a given variable.
 
std::unique_ptr< NumericVector< Number > > _serialized_solution
 Serialized version of the solution vector, or nullptr if a serialized solution is not needed.
 
const Parallel::Communicator & _communicator
 
MooseApp & _pg_moose_app
 The MooseApp that owns the PerfGraph.
 
const std::string _prefix
 A prefix to use for all sections.
 
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
 
MooseObjectTagWarehouse< ResidualObject > _kokkos_kernels
 
MooseObjectTagWarehouse< ResidualObject > _kokkos_integrated_bcs
 
MooseObjectTagWarehouse< ResidualObject > _kokkos_nodal_bcs
 
MooseObjectWarehouse< ResidualObject > _kokkos_preset_nodal_bcs
 
MooseObjectTagWarehouse< ResidualObject > _kokkos_nodal_kernels
 

Private Member Functions

void setupStandardFiniteDifferencedPreconditioner ()
 Form preconditioning matrix via a standard finite difference method column-by-column.
 
void setupColoringFiniteDifferencedPreconditioner ()
 According to the nonzero pattern provided in the matrix, a graph is constructed.
 
virtual bool matrixFromColoring () const override
 Whether a system matrix is formed from coloring.
 
std::vector< SetupInterface * > getFVSetupObjects (THREAD_ID tid)
 Retrieve every finite volume object belonging to this system on thread tid, as SetupInterfaces, so that the setup methods can be dispatched to all finite volume families with a single loop.
 
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.
 
void setupScalingData ()
 Setup group scaling containers.
 
std::vector< NumericVector< Number > * > & getSolutionStates (const Moose::SolutionIterationType iteration_type)
 Get all of the solution states (current, old, ...) for the given iteration type.
 
TagName oldSolutionStateVectorName (const unsigned int, Moose::SolutionIterationType iteration_type) const
 Gets the vector name used for an old (not current) solution state.
 

Private Attributes

bool _use_coloring_finite_difference
 
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.
 
std::vector< NumericVector< Number > * > _solution_state
 The current states of the solution (0 = current, 1 = old, etc)
 
bool _auto_scaling_initd
 Whether we've initialized the automatic scaling data structures.
 
std::unordered_map< unsigned int, unsigned int > _var_to_group_var
 A map from variable index to group variable index and it's associated (inverse) scaling factor.
 
std::size_t _num_scaling_groups
 The number of scaling groups.
 
ConvergenceName _convergence_name
 Associated convergence object name.
 
std::array< std::vector< NumericVector< Number > * >, static_cast< size_t >(Moose::SolutionIterationType::Count)> _solution_states
 2D array of solution state vector pointers.
 
std::vector< NumericVector< Number > * > _saved_solution_states
 The saved solution states (0 = current, 1 = old, 2 = older, etc)
 
bool _skip_next_solution_to_old_copy
 Whether to skip the next copy from the solution to the old vector.
 

Detailed Description

Definition at line 19 of file MooseEigenSystem.h.

Member Enumeration Documentation

◆ SYSTEMTAG

System or kernel tags.

Enumerator
ALL 
EIGEN 

Definition at line 44 of file MooseEigenSystem.h.

Constructor & Destructor Documentation

◆ MooseEigenSystem()

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

Definition at line 17 of file MooseEigenSystem.C.

18 : NonlinearSystem(fe_problem, name),
19 _all_eigen_vars(false),
20 _active_on_old(false),
22{
23}
unsigned int _eigen_kernel_counter
counter of eigen kernels
Nonlinear system to be solved.
virtual const std::string & name() const

◆ ~MooseEigenSystem()

MooseEigenSystem::~MooseEigenSystem ( )
virtual

Definition at line 25 of file MooseEigenSystem.C.

25{}

Member Function Documentation

◆ activateAllMatrixTags()

void SystemBase::activateAllMatrixTags ( )
virtualinherited

Make all existing matrices active.

Definition at line 1128 of file SystemBase.C.

1129{
1130 auto num_matrix_tags = _subproblem.numMatrixTags();
1131
1132 _matrix_tag_active_flags.resize(num_matrix_tags);
1134
1135 for (const auto tag : make_range(num_matrix_tags))
1136 if (hasMatrix(tag))
1137 {
1138 _matrix_tag_active_flags[tag] = true;
1139 _active_tagged_matrices.emplace(tag, &getMatrix(tag));
1140 }
1141 else
1142 _matrix_tag_active_flags[tag] = false;
1143}
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
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.
std::unordered_map< TagID, libMesh::SparseMatrix< Number > * > _active_tagged_matrices
Active tagged matrices. A matrix is active if its tag-matrix pair is present in the map....
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition SystemBase.h:388
IntRange< T > make_range(T beg, T end)

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

◆ activeOnOld()

bool MooseEigenSystem::activeOnOld ( )

Return if eigen kernels should be on old solution.

Definition at line 221 of file MooseEigenSystem.C.

222{
223 return _active_on_old;
224}

Referenced by EigenKernel::enabled().

◆ 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 515 of file NonlinearSystemBase.C.

518{
519 // ThreadID
520 THREAD_ID tid = 0;
521
522 // Create the object
523 std::shared_ptr<BoundaryCondition> bc =
524 _factory.create<BoundaryCondition>(bc_name, name, parameters, tid);
526
527 // Active BoundaryIDs for the object
528 const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
529 auto bc_var = dynamic_cast<const MooseVariableFieldBase *>(&bc->variable());
530 _vars[tid].addBoundaryVar(boundary_ids, bc_var);
531
532 // Cast to the various types of BCs
533 std::shared_ptr<NodalBCBase> nbc = std::dynamic_pointer_cast<NodalBCBase>(bc);
534 std::shared_ptr<IntegratedBCBase> ibc = std::dynamic_pointer_cast<IntegratedBCBase>(bc);
535
536 // NodalBCBase
537 if (nbc)
538 {
539 if (nbc->checkNodalVar() && !nbc->variable().isNodal())
540 mooseError("Trying to use nodal boundary condition '",
541 nbc->name(),
542 "' on a non-nodal variable '",
543 nbc->variable().name(),
544 "'.");
545
547 // Add to theWarehouse, a centralized storage for all moose objects
549 _vars[tid].addBoundaryVars(boundary_ids, nbc->getCoupledVars());
550
551 if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
553 if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
555
556 // DirichletBCs that are preset
557 std::shared_ptr<DirichletBCBase> dbc = std::dynamic_pointer_cast<DirichletBCBase>(bc);
558 if (dbc && dbc->preset())
560
561 std::shared_ptr<ADDirichletBCBase> addbc = std::dynamic_pointer_cast<ADDirichletBCBase>(bc);
562 if (addbc && addbc->preset())
564 }
565
566 // IntegratedBCBase
567 else if (ibc)
568 {
569 _integrated_bcs.addObject(ibc, tid);
570 // Add to theWarehouse, a centralized storage for all moose objects
572 _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
573
574 if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
575 _has_save_in = true;
576 if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
577 _has_diag_save_in = true;
578
579 for (tid = 1; tid < libMesh::n_threads(); tid++)
580 {
581 // Create the object
582 bc = _factory.create<BoundaryCondition>(bc_name, name, parameters, tid);
583
584 // Give users opportunity to set some parameters
586
587 // Active BoundaryIDs for the object
588 const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
589 _vars[tid].addBoundaryVar(boundary_ids, bc_var);
590
591 ibc = std::static_pointer_cast<IntegratedBCBase>(bc);
592
593 _integrated_bcs.addObject(ibc, tid);
594 _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
595 }
596 }
597
598 else
599 mooseError("Unknown BoundaryCondition type for object named ", bc->name());
600}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
unsigned int THREAD_ID
Definition MooseTypes.h:237
Base class for creating new types of boundary conditions.
TheWarehouse & theWarehouse() const
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters &parameters, THREAD_ID tid=0, bool print_deprecated=true)
Definition Factory.C:142
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
This class provides an interface for common operations on field variables of both FE and FV types wit...
MooseObjectWarehouse< ADDirichletBCBase > _ad_preset_nodal_bcs
MooseObjectWarehouse< DirichletBCBase > _preset_nodal_bcs
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
bool _has_nodalbc_save_in
If there is a nodal BC having save_in.
bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Factory & _factory
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
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...
unsigned int n_threads()

◆ 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 603 of file NonlinearSystemBase.C.

606{
607 std::shared_ptr<Constraint> constraint = _factory.create<Constraint>(c_name, name, parameters);
608 _constraints.addObject(constraint);
609 postAddResidualObject(*constraint);
610
612 if (constraint && constraint->addCouplingEntriesToJacobian())
614}
void addObject(std::shared_ptr< Constraint > object, THREAD_ID tid=0, bool recurse=true) override
Add Constraint object to the warehouse.
Base class for all Constraint types.
Definition Constraint.h:20
bool useHashTableMatrixAssembly() const
void addImplicitGeometricCouplingEntriesToJacobian(bool add=true)
If called with true this will add entries into the jacobian to link together degrees of freedom that ...
ConstraintWarehouse _constraints
Constraints storage object.

◆ 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 677 of file NonlinearSystemBase.C.

680{
681 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
682 {
683 std::shared_ptr<Damper> damper = _factory.create<Damper>(damper_name, name, parameters, tid);
684
685 // Attempt to cast to the damper types
686 std::shared_ptr<ElementDamper> ed = std::dynamic_pointer_cast<ElementDamper>(damper);
687 std::shared_ptr<NodalDamper> nd = std::dynamic_pointer_cast<NodalDamper>(damper);
688 std::shared_ptr<GeneralDamper> gd = std::dynamic_pointer_cast<GeneralDamper>(damper);
689
690 if (gd)
691 {
693 break; // not threaded
694 }
695 else if (ed)
697 else if (nd)
698 _nodal_dampers.addObject(nd, tid);
699 else
700 mooseError("Invalid damper type");
701 }
702}
Base class for deriving dampers.
Definition Damper.h:28
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.

◆ 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 633 of file NonlinearSystemBase.C.

636{
637 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
638 {
639 auto dg_kernel = _factory.create<DGKernelBase>(dg_kernel_name, name, parameters, tid);
640 _dg_kernels.addObject(dg_kernel, tid);
641 // Add to theWarehouse, a centralized storage for all moose objects
642 _fe_problem.theWarehouse().add(dg_kernel);
643 postAddResidualObject(*dg_kernel);
644 }
645
646 _doing_dg = true;
647
648 if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
649 _has_save_in = true;
650 if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
651 _has_diag_save_in = true;
652}
Serves as a base class for DGKernel and ADDGKernel.
bool _doing_dg
true if DG is active (optimization reasons)
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels

◆ 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 617 of file NonlinearSystemBase.C.

620{
621 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
622 {
623 std::shared_ptr<DiracKernelBase> kernel =
624 _factory.create<DiracKernelBase>(kernel_name, name, parameters, tid);
625 postAddResidualObject(*kernel);
626 _dirac_kernels.addObject(kernel, tid);
627 // Add to theWarehouse, a centralized storage for all moose objects
628 _fe_problem.theWarehouse().add(kernel);
629 }
630}
DiracKernelBase is the base class for all DiracKernel type classes.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.

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

1655{
1657 _u_dot = &addVector("u_dot", true, GHOSTED);
1659 _u_dot_old = &addVector("u_dot_old", true, GHOSTED);
1661 _u_dotdot = &addVector("u_dotdot", true, GHOSTED);
1663 _u_dotdot_old = &addVector("u_dotdot_old", true, GHOSTED);
1664}
virtual bool uDotRequested()
Get boolean flag to check whether solution time derivative needs to be stored.
virtual bool uDotOldRequested()
Get boolean flag to check whether old solution time derivative needs to be stored.
virtual bool uDotDotRequested()
Get boolean flag to check whether solution second time derivative needs to be stored.
virtual bool uDotDotOldRequested()
Get boolean flag to check whether old solution second time derivative needs to be stored.
NumericVector< Number > * _u_dot
solution vector for u^dot
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
Definition SystemBase.C:605

Referenced by DisplacedSystem::addDotVectors().

◆ 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 461 of file NonlinearSystemBase.C.

464{
465 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
466 {
467 // Create the kernel object via the factory and add to warehouse
468 auto kernel = _factory.create<HDGKernel>(kernel_name, name, parameters, tid);
469 _kernels.addObject(kernel, tid);
470 _hybridized_kernels.addObject(kernel, tid);
471 // Add to theWarehouse, a centralized storage for all moose objects
472 _fe_problem.theWarehouse().add(kernel);
473 postAddResidualObject(*kernel);
474 }
475}
Base kernel for hybridized finite element formulations.
Definition HDGKernel.h:18
MooseObjectTagWarehouse< KernelBase > _kernels
MooseObjectTagWarehouse< HDGKernel > _hybridized_kernels

◆ 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 2467 of file NonlinearSystemBase.C.

2468{
2469 if (!hasMatrix(systemMatrixTag()))
2470 mooseError("Need a system matrix ");
2471
2472 // At this point, have no idea how to make
2473 // this work with tag system
2474 auto & jacobian = getMatrix(systemMatrixTag());
2475
2476 std::unordered_map<dof_id_type, std::vector<dof_id_type>> graph;
2477
2478 findImplicitGeometricCouplingEntries(geom_search_data, graph);
2479
2480 for (const auto & it : graph)
2481 {
2482 dof_id_type dof = it.first;
2483 const auto & row = it.second;
2484
2485 for (const auto & coupled_dof : row)
2486 jacobian.add(dof, coupled_dof, 0);
2487 }
2488}
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.
uint8_t dof_id_type

Referenced by NonlinearSystemBase::computeJacobianInternal().

◆ 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 516 of file NonlinearSystemBase.h.

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

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

◆ 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 655 of file NonlinearSystemBase.C.

658{
659 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
660 {
661 std::shared_ptr<InterfaceKernelBase> interface_kernel =
662 _factory.create<InterfaceKernelBase>(interface_kernel_name, name, parameters, tid);
663 postAddResidualObject(*interface_kernel);
664
665 const std::set<BoundaryID> & boundary_ids = interface_kernel->boundaryIDs();
666 auto ik_var = dynamic_cast<const MooseVariableFieldBase *>(&interface_kernel->variable());
667 _vars[tid].addBoundaryVar(boundary_ids, ik_var);
668
669 _interface_kernels.addObject(interface_kernel, tid);
670 // Add to theWarehouse, a centralized storage for all moose objects
671 _fe_problem.theWarehouse().add(interface_kernel);
672 _vars[tid].addBoundaryVars(boundary_ids, interface_kernel->getCoupledVars());
673 }
674}
InterfaceKernelBase is the base class for all InterfaceKernel type classes.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels

◆ addKernel()

void MooseEigenSystem::addKernel ( const std::string &  kernel_name,
const std::string &  name,
InputParameters &  parameters 
)
virtual

Adds a kernel.

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

Reimplemented from NonlinearSystemBase.

Definition at line 28 of file MooseEigenSystem.C.

31{
32 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
33 {
34 // In the case of EigenKernels, we might need to add two to the system
35 if (parameters.have_parameter<bool>("eigen"))
36 {
37 {
38 // EigenKernel
39 parameters.set<bool>("implicit") = true;
40 std::shared_ptr<KernelBase> ekernel =
41 _factory.create<KernelBase>(kernel_name, name, parameters, tid);
42 if (parameters.get<bool>("eigen"))
43 markEigenVariable(parameters.get<NonlinearVariableName>("variable"));
44 _kernels.addObject(ekernel, tid);
45 }
46 if (parameters.get<bool>("eigen"))
47 {
48 // EigenKernel_old
49 parameters.set<bool>("implicit") = false;
50 std::string old_name(name + "_old");
51
52 std::shared_ptr<KernelBase> ekernel =
53 _factory.create<KernelBase>(kernel_name, old_name, parameters, tid);
54 _eigen_var_names.insert(parameters.get<NonlinearVariableName>("variable"));
55 _kernels.addObject(ekernel, tid);
57 }
58 }
59 else // Standard nonlinear system kernel
60 {
61 // Create the kernel object via the factory
62 std::shared_ptr<KernelBase> kernel =
63 _factory.create<KernelBase>(kernel_name, name, parameters, tid);
64 _kernels.addObject(kernel, tid);
65 }
66 }
67
68 if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
69 _has_save_in = true;
70 if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
71 _has_diag_save_in = true;
72}
bool have_parameter(std::string_view name) const
A wrapper around the Parameters base class method.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
This is the common base class for the three main kernel types implemented in MOOSE,...
Definition KernelBase.h:29
virtual void markEigenVariable(const VariableName &var_name)
Mark a variable as a variable of the eigen system.
std::set< VariableName > _eigen_var_names

◆ addKokkosBoundaryCondition()

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

Adds a Kokkos boundary condition.

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

◆ addKokkosKernel()

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

Adds a Kokkos kernel.

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

◆ addKokkosNodalKernel()

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

Adds a Kokkos nodal kernel.

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

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

568{
570 mooseError("Cannot add tagged matrix with TagID ",
571 tag,
572 " in system '",
573 name(),
574 "' because the tag does not exist in the problem");
575
576 if (hasMatrix(tag))
577 return getMatrix(tag);
578
579 const auto matrix_name = _subproblem.matrixTagName(tag);
580 SparseMatrix<Number> & mat = system().add_matrix(matrix_name);
581 associateMatrixToTag(mat, tag);
582
583 return mat;
584}
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition SubProblem.C:346
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition SubProblem.C:317
virtual void associateMatrixToTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
SparseMatrix< Number > & add_matrix(std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)

◆ 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 478 of file NonlinearSystemBase.C.

481{
482 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
483 {
484 // Create the kernel object via the factory and add to the warehouse
485 std::shared_ptr<NodalKernelBase> kernel =
486 _factory.create<NodalKernelBase>(kernel_name, name, parameters, tid);
487 _nodal_kernels.addObject(kernel, tid);
488 // Add to theWarehouse, a centralized storage for all moose objects
489 _fe_problem.theWarehouse().add(kernel);
490 postAddResidualObject(*kernel);
491 }
492
493 if (parameters.have_parameter<std::vector<AuxVariableName>>("save_in") &&
494 parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
495 _has_save_in = true;
496 if (parameters.have_parameter<std::vector<AuxVariableName>>("save_in") &&
497 parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
498 _has_diag_save_in = true;
499}
Base class for creating new types of nodal kernels.
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.

◆ 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 502 of file NonlinearSystemBase.C.

505{
506 std::shared_ptr<ScalarKernelBase> kernel =
507 _factory.create<ScalarKernelBase>(kernel_name, name, parameters);
508 postAddResidualObject(*kernel);
509 // Add to theWarehouse, a centralized storage for all moose objects
510 _fe_problem.theWarehouse().add(kernel);
512}
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
Base class shared by AD and non-AD scalar kernels.

◆ addScalingVector()

void SystemBase::addScalingVector ( )
inherited

Add the scaling factor vector to the system.

Definition at line 1579 of file SystemBase.C.

1580{
1581 addVector("scaling_factors", /*project=*/false, GHOSTED);
1583}
void hasScalingVector(const unsigned int nl_sys_num)
Tells this problem that the assembly associated with the given nonlinear system number involves a sca...
unsigned int number() const
Gets the number of this system.

Referenced by MooseVariableBase::initialSetup().

◆ 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 705 of file NonlinearSystemBase.C.

708{
709 std::shared_ptr<Split> split = _factory.create<Split>(split_name, name, parameters);
710 _splits.addObject(split);
711 // Add to theWarehouse, a centralized storage for all moose objects
713}
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true)
Adds an object to the storage structure.
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.
Base class for split-based preconditioners.
Definition Split.h:26
tbb::split split

◆ addTimeIntegrator()

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

Definition at line 1679 of file SystemBase.C.

1682{
1683 parameters.set<SystemBase *>("_sys") = this;
1684 _time_integrators.push_back(_factory.create<TimeIntegrator>(type, name, parameters));
1685}
Base class for a system (of equations)
Definition SystemBase.h:87
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
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 717 of file SystemBase.C.

720{
722
723 const auto components = parameters.get<unsigned int>("components");
724
725 // Convert the std::vector parameter provided by the user into a std::set for use by libMesh's
726 // System::add_variable method
727 std::set<SubdomainID> blocks;
728 const auto & block_param = parameters.get<std::vector<SubdomainName>>("block");
729 for (const auto & subdomain_name : block_param)
730 {
731 SubdomainID blk_id = _mesh.getSubdomainID(subdomain_name);
732 blocks.insert(blk_id);
733 }
734
735 const auto fe_type = MooseUtils::variableFEType(parameters);
736 const auto fe_field_type = FEInterface::field_type(fe_type);
737
738 unsigned int var_num;
739
740 if (var_type == "ArrayMooseVariable")
741 {
742 if (fe_field_type == libMesh::TYPE_VECTOR)
743 mooseError("Vector family type cannot be used in an array variable");
744
745 std::vector<std::string> array_var_component_names;
746 const bool has_array_names = parameters.isParamValid("array_var_component_names");
747 if (has_array_names)
748 {
749 array_var_component_names =
750 parameters.get<std::vector<std::string>>("array_var_component_names");
751 if (array_var_component_names.size() != components)
752 parameters.paramError("array_var_component_names",
753 "Must be the same size as 'components' (size ",
754 components,
755 ") for array variable '",
756 name,
757 "'");
758 }
759
760 // Build up the variable names
761 std::vector<std::string> var_names;
762 for (unsigned int i = 0; i < components; i++)
763 {
764 if (!has_array_names)
765 array_var_component_names.push_back(std::to_string(i));
766 var_names.push_back(name + "_" + array_var_component_names[i]);
767 }
768
769 // makes sure there is always a name, either the provided one or '1 2 3 ...'
770 parameters.set<std::vector<std::string>>("array_var_component_names") =
771 array_var_component_names;
772
773 // The number returned by libMesh is the _last_ variable number... we want to hold onto the
774 // _first_
775 var_num = system().add_variable_array(var_names, fe_type, &blocks) - (components - 1);
776
777 // Set as array variable
778 if (parameters.isParamSetByUser("array") && !parameters.get<bool>("array"))
779 parameters.paramError("array",
780 "Must be set to true for variable '",
781 name,
782 "' because 'components' > 1 (is an array variable)");
783 parameters.set<bool>("array") = true;
784 }
785 else
786 {
787 if (parameters.isParamSetByUser("array_var_component_names"))
788 parameters.paramError("array_var_component_names",
789 "Should not be set because this variable (",
790 name,
791 ") is a non-array variable");
792 var_num = system().add_variable(name, fe_type, &blocks);
793 }
794
795 parameters.set<unsigned int>("_var_num") = var_num;
796 parameters.set<SystemBase *>("_system_base") = this;
797
798 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
799 {
800 parameters.set<THREAD_ID>("tid") = tid;
801 std::shared_ptr<MooseVariableBase> var =
802 _factory.create<MooseVariableBase>(var_type, name, parameters, tid);
803
804 _vars[tid].add(name, var);
805
806 if (auto fe_var = dynamic_cast<MooseVariableFieldBase *>(var.get()))
807 {
808 auto required_size = var_num + components;
809 if (required_size > _numbered_vars[tid].size())
810 _numbered_vars[tid].resize(required_size);
811 for (MooseIndex(components) component = 0; component < components; ++component)
812 _numbered_vars[tid][var_num + component] = fe_var;
813
814 if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADReal> *>(fe_var))
815 _subproblem.addFunctor(name, *functor, tid);
816 else if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADRealVectorValue> *>(fe_var))
817 _subproblem.addFunctor(name, *functor, tid);
818 else if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADRealEigenVector> *>(fe_var))
819 _subproblem.addFunctor(name, *functor, tid);
820 else
821 mooseError("This should be a functor");
822 }
823
824 if (auto scalar_var = dynamic_cast<MooseVariableScalar *>(var.get()))
825 {
826 if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADReal> *>(scalar_var))
827 _subproblem.addFunctor(name, *functor, tid);
828 else
829 mooseError("Scalar variables should be functors");
830 }
831
832 if (var->blockRestricted())
833 for (const SubdomainID & id : var->blockIDs())
834 for (MooseIndex(components) component = 0; component < components; ++component)
835 _var_map[var_num + component].insert(id);
836 else
837 for (MooseIndex(components) component = 0; component < components; ++component)
838 _var_map[var_num + component] = std::set<SubdomainID>();
839 }
840
841 // getMaxVariableNumber is an API method used in Rattlesnake
842 if (var_num > _max_var_number)
843 _max_var_number = var_num;
844 _du_dot_du.resize(var_num + 1);
845}
subdomain_id_type SubdomainID
for(PetscInt i=0;i< nvars;++i)
char ** blocks
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
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.
void paramError(const std::string &param, Args... args) const
Emits a parameter error prefixed with the parameter location and object information if available.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another,...
SubdomainID getSubdomainID(const SubdomainName &subdomain_name) const
Get the associated subdomain ID for the subdomain name.
Definition MooseMesh.C:1678
Base variable class.
Class for scalar variables (they are different).
Base class template for functor objects.
void addFunctor(const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
add a functor to the problem functor container
std::vector< Real > _du_dot_du
Derivative of time derivative of u with respect to uj.
unsigned int _max_var_number
Maximum variable number.
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
MooseMesh & _mesh
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
Map variable number to its pointer.
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
unsigned int add_variable_array(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
libMesh::FEType variableFEType(const InputParameters &params)
Definition MooseUtils.C:98

Referenced by AuxiliarySystem::addVariable().

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

1175{
1176 _var_to_copy.push_back(VarCopyInfo(dest_name, source_name, timestep));
1177}
std::vector< VarCopyInfo > _var_to_copy
Information about variables that will be copied.
Definition SystemBase.h:68

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

◆ addVariableToZeroOnJacobian()

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

◆ addVariableToZeroOnResidual()

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

◆ 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.

Definition at line 605 of file SystemBase.C.

608{
609 if (hasVector(vector_name))
610 return getVector(vector_name);
611
612 NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
613 return vec;
614}
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition SystemBase.C:921
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition SystemBase.C:930
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)

Referenced by SystemBase::addDotVectors(), SystemBase::addScalingVector(), NonlinearTimeIntegratorInterface::addVector(), PicardSolve::allocateStorage(), SecantSolve::allocateStorage(), SteffensenSolve::allocateStorage(), NonlinearSystemBase::getResidualNonTimeVector(), NonlinearSystemBase::getResidualTimeVector(), LinearFVGradientManager::initializeLinearFVGradientHistoryStorage(), 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.

Definition at line 617 of file SystemBase.C.

618{
620 mooseError("Cannot add tagged vector with TagID ",
621 tag,
622 " in system '",
623 name(),
624 "' because the tag does not exist in the problem");
625
626 if (hasVector(tag))
627 {
628 auto & vec = getVector(tag);
629
630 if (type != AUTOMATIC && vec.type() != type)
631 mooseError("Cannot add tagged vector '",
633 "', in system '",
634 name(),
635 "' because a vector with the same name was found with a different parallel type");
636
637 return vec;
638 }
639
640 const auto vector_name = _subproblem.vectorTagName(tag);
641 NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
642 associateVectorToTag(vec, tag);
643
644 return vec;
645}
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition SubProblem.C:210
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition SubProblem.h:201
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition SystemBase.C:978

◆ advanceStateHistory()

void SystemBase::advanceStateHistory ( Moose::SolutionIterationType  iteration_type)
inherited

Advance solution vectors and additional system-owned state together.

Definition at line 1308 of file SystemBase.C.

1309{
1310 const bool skip_current_to_old =
1312 copyPreviousSolutions(iteration_type);
1313 copyAdditionalStateBackwards(iteration_type, skip_current_to_old);
1314}
void copyPreviousSolutions(const Moose::SolutionIterationType iteration_type)
Copy a specific type of solution back in time (current -> old -> older, etc).
bool _skip_next_solution_to_old_copy
Whether to skip the next copy from the solution to the old vector.
virtual void copyAdditionalStateBackwards(Moose::SolutionIterationType, bool)
Copy system-owned state not represented by solution vectors.

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

◆ applyFixedPointRelaxation()

void SolverSystem::applyFixedPointRelaxation ( const Real  relaxation_factor,
const Moose::SolutionIterationType  iteration_type 
)
inherited

Apply solution under/over-relaxation for fixed point iterations.

The relaxed update is: u <- relaxation_factor * u_new + (1 - relaxation_factor) * u_old

Parameters
[in]relaxation_factorThe factor applied to the new solution
[in]iteration_typeType of iteration; which "previous" value to use

Definition at line 77 of file SolverSystem.C.

79{
80 if (MooseUtils::absoluteFuzzyEqual(relaxation_factor, 1.0))
81 return;
82
83 mooseAssert(hasSolutionState(1, iteration_type),
84 "Fixed point relaxation was requested but the old fixed point solution was not "
85 "saved.");
86
87 // This might be paranoid but who knows, maybe someone requests nonghosted
88 mooseAssert(solutionStateParallelType(1, iteration_type) == solution().type(),
89 "Fixed point relaxation requires the previous fixed point solution state to have "
90 "the same parallel type as the system solution.");
91
92 auto & sol = solution();
93 sol.scale(relaxation_factor);
94 sol.add(1.0 - relaxation_factor, solutionState(1, iteration_type));
95 sol.close();
96 update();
97}
libMesh::ParallelType solutionStateParallelType(const unsigned int state, const Moose::SolutionIterationType iteration_type) const
Returns the parallel type of the given solution state.
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).
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,...
NumericVector< Number > & solution()
Definition SystemBase.h:212
void update()
Update the system (doing libMesh magic)

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

1530{
1531 for (MooseIndex(_vars) thread = 0; thread < _vars.size(); ++thread)
1532 {
1533 auto & field_variables = _vars[thread].fieldVariables();
1534 for (MooseIndex(field_variables) i = 0, p = 0; i < field_variables.size(); ++i)
1535 {
1536 auto factors = field_variables[i]->arrayScalingFactor();
1537 for (unsigned int j = 0; j < field_variables[i]->count(); ++j, ++p)
1538 factors[j] /= inverse_scaling_factors[p];
1539
1540 field_variables[i]->scalingFactor(factors);
1541 }
1542
1543 auto offset = field_variables.size();
1544
1545 auto & scalar_variables = _vars[thread].scalars();
1546 for (MooseIndex(scalar_variables) i = 0; i < scalar_variables.size(); ++i)
1547 scalar_variables[i]->scalingFactor(
1548 {1. / inverse_scaling_factors[offset + i] * scalar_variables[i]->scalingFactor()});
1549
1550 if (thread == 0 && _verbose)
1551 {
1552 _console << "Automatic scaling factors:\n";
1553 auto original_flags = _console.flags();
1554 auto original_precision = _console.precision();
1555 _console.unsetf(std::ios_base::floatfield);
1557
1558 for (const auto & field_variable : field_variables)
1559 {
1560 const auto & factors = field_variable->arrayScalingFactor();
1561 _console << " " << field_variable->name() << ":";
1562 for (const auto i : make_range(field_variable->count()))
1563 _console << " " << factors[i];
1564 _console << "\n";
1565 }
1566 for (const auto & scalar_variable : scalar_variables)
1567 _console << " " << scalar_variable->name() << ": " << scalar_variable->scalingFactor()
1568 << "\n";
1569 _console << "\n" << std::endl;
1570
1571 // restore state
1572 _console.flags(original_flags);
1573 _console.precision(original_precision);
1574 }
1575 }
1576}
unsigned int count
Definition MortarUtils.C:53
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
std::ios_base::fmtflags flags() const
Return the current flags.
std::streamsize precision() const
Return the current precision.
void unsetf(std::ios_base::fmtflags mask) const
Unset format flags.
bool _verbose
True if printing out additional information.

Referenced by NonlinearSystemBase::computeScaling().

◆ 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 526 of file NonlinearSystemBase.h.

527 {
529 }
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 4235 of file NonlinearSystemBase.C.

4236{
4237 if (!hasVector("scaling_factors"))
4238 // No variables have indicated they need scaling
4239 return;
4240
4241 auto & scaling_vector = getVector("scaling_factors");
4242
4243 const auto & lm_mesh = _mesh.getMesh();
4244 const auto & dof_map = dofMap();
4245
4246 const auto & field_variables = _vars[0].fieldVariables();
4247 const auto & scalar_variables = _vars[0].scalars();
4248
4249 std::vector<dof_id_type> dof_indices;
4250
4251 for (const Elem * const elem :
4252 as_range(lm_mesh.active_local_elements_begin(), lm_mesh.active_local_elements_end()))
4253 for (const auto * const field_var : field_variables)
4254 {
4255 const auto & factors = field_var->arrayScalingFactor();
4256 for (const auto i : make_range(field_var->count()))
4257 {
4258 dof_map.dof_indices(elem, dof_indices, field_var->number() + i);
4259 for (const auto dof : dof_indices)
4260 scaling_vector.set(dof, factors[i]);
4261 }
4262 }
4263
4264 for (const auto * const scalar_var : scalar_variables)
4265 {
4266 mooseAssert(scalar_var->count() == 1,
4267 "Scalar variables should always have only one component.");
4268 dof_map.SCALAR_dof_indices(dof_indices, scalar_var->number());
4269 for (const auto dof : dof_indices)
4270 scaling_vector.set(dof, scalar_var->scalingFactor());
4271 }
4272
4273 // Parallel assemble
4274 scaling_vector.close();
4275
4277 // copy into the corresponding displaced system vector because they should be the exact same
4278 displaced_problem->systemBaseNonlinear(number()).getVector("scaling_factors") = scaling_vector;
4279}
std::shared_ptr< DisplacedProblem > displaced_problem
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3512
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)

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

◆ assignMaxVarNDofsPerElem()

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

assign the maximum element dofs

Definition at line 625 of file SystemBase.h.

625{ _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.

◆ assignMaxVarNDofsPerNode()

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

assign the maximum node dofs

Definition at line 630 of file SystemBase.h.

630{ _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.

◆ associateMatrixToTag()

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

Associate a matrix to a tag.

Reimplemented in DisplacedSystem.

Definition at line 1073 of file SystemBase.C.

1074{
1075 if (!_subproblem.matrixTagExists(tag))
1076 mooseError("Cannot associate matrix to tag ", tag, " because that tag does not exist");
1077
1078 if (_tagged_matrices.size() < tag + 1)
1079 _tagged_matrices.resize(tag + 1);
1080
1081 _tagged_matrices[tag] = &matrix;
1082}
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)

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

◆ associateVectorToTag()

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

Associate a vector for a given tag.

Reimplemented in DisplacedSystem.

Definition at line 978 of file SystemBase.C.

979{
981 mooseError("Cannot associate vector to tag ", tag, " because that tag does not exist");
982
983 if (_tagged_vectors.size() < tag + 1)
984 _tagged_vectors.resize(tag + 1);
985
986 _tagged_vectors[tag] = &vec;
987}
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)

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

◆ attachPreconditioner()

void NonlinearSystem::attachPreconditioner ( libMesh::Preconditioner< Number > *  preconditioner)
overridevirtualinherited

Attach a customized preconditioner that requires physics knowledge.

Generic preconditioners should be implemented in PETSc, instead.

Implements NonlinearSystemBase.

Definition at line 352 of file NonlinearSystem.C.

353{
354 nonlinearSolver()->attach_preconditioner(preconditioner);
355}
virtual libMesh::NonlinearSolver< Number > * nonlinearSolver() override

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

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

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

◆ 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 3609 of file NonlinearSystemBase.C.

3612{
3614 {
3616
3617 std::unordered_map<dof_id_type, std::vector<dof_id_type>> graph;
3618
3620
3623 graph);
3624
3625 const dof_id_type first_dof_on_proc = dofMap().first_dof(processor_id());
3626 const dof_id_type end_dof_on_proc = dofMap().end_dof(processor_id());
3627
3628 // The total number of dofs on and off processor
3629 const dof_id_type n_dofs_on_proc = dofMap().n_local_dofs();
3630 const dof_id_type n_dofs_not_on_proc = dofMap().n_dofs() - dofMap().n_local_dofs();
3631
3632 for (const auto & git : graph)
3633 {
3634 dof_id_type dof = git.first;
3635 dof_id_type local_dof = dof - first_dof_on_proc;
3636
3637 if (dof < first_dof_on_proc || dof >= end_dof_on_proc)
3638 continue;
3639
3640 const auto & row = git.second;
3641
3642 SparsityPattern::Row & sparsity_row = sparsity[local_dof];
3643
3644 unsigned int original_row_length = sparsity_row.size();
3645
3646 sparsity_row.insert(sparsity_row.end(), row.begin(), row.end());
3647
3649 sparsity_row.begin(), sparsity_row.begin() + original_row_length, sparsity_row.end());
3650
3651 // Fix up nonzero arrays
3652 for (const auto & coupled_dof : row)
3653 {
3654 if (coupled_dof < first_dof_on_proc || coupled_dof >= end_dof_on_proc)
3655 {
3656 if (n_oz[local_dof] < n_dofs_not_on_proc)
3657 n_oz[local_dof]++;
3658 }
3659 else
3660 {
3661 if (n_nz[local_dof] < n_dofs_on_proc)
3662 n_nz[local_dof]++;
3663 }
3664 }
3665 }
3666 }
3667}
virtual GeometricSearchData & geomSearchData() override
virtual void updateGeomSearch(GeometricSearchData::GeometricSearchType type=GeometricSearchData::ALL) override
Update this object's geometric search data as well as the displaced problem's if it exists.
dof_id_type first_dof(const processor_id_type proc) const
dof_id_type end_dof(const processor_id_type proc) const
dof_id_type n_local_dofs(const unsigned int vn) const
dof_id_type n_dofs(const unsigned int vn) const
processor_id_type processor_id() const
static void sort_row(const BidirectionalIterator begin, BidirectionalIterator middle, const BidirectionalIterator end)
std::vector< dof_id_type, Threads::scalable_allocator< dof_id_type > > Row

◆ 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 123 of file SystemBase.h.

123{ return _automatic_scaling; }
bool _automatic_scaling
Whether to automatically scale the variables.

Referenced by SubProblem::automaticScaling(), and SubProblem::automaticScaling().

◆ 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 129 of file SystemBase.h.

129{ _automatic_scaling = automatic_scaling; }

◆ 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 731 of file NonlinearSystemBase.h.

732 {
733 _resid_vs_jac_scaling_param = resid_vs_jac_scaling_param;
734 }
Real _resid_vs_jac_scaling_param
The param that indicates the weighting of the residual vs the Jacobian in determining variable scalin...

◆ buildSystemDoFIndices()

void MooseEigenSystem::buildSystemDoFIndices ( SYSTEMTAG  tag = ALL)

Build DoF indices for a system.

Definition at line 227 of file MooseEigenSystem.C.

228{
229 if (tag == ALL)
230 {
231 }
232 else if (tag == EIGEN)
233 {
234 // build DoF indices for the eigen system
235 _eigen_var_indices.clear();
237 if (!_all_eigen_vars)
238 {
239 for (std::set<VariableName>::const_iterator it = getEigenVariableNames().begin();
240 it != getEigenVariableNames().end();
241 it++)
242 {
243 unsigned int i = sys().variable_number(*it);
244 std::set<dof_id_type> var_indices;
245 sys().local_dof_indices(i, var_indices);
246 _eigen_var_indices.insert(var_indices.begin(), var_indices.end());
247 }
248 }
249 }
250}
std::set< dof_id_type > _eigen_var_indices
const std::set< VariableName > & getEigenVariableNames() const
Get variable names of the eigen system.
virtual libMesh::NonlinearImplicitSystem & sys()
const std::vector< VariableName > & getVariableNames() const
Definition SystemBase.h:890
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
unsigned int variable_number(std::string_view var) const

Referenced by EigenExecutionerBase::init().

◆ checkInvalidSolution()

void SolverSystem::checkInvalidSolution ( )
protectedinherited

Definition at line 132 of file SolverSystem.C.

133{
134 auto & solution_invalidity = _app.solutionInvalidity();
135
136 // sync all solution invalid counts to rank 0 process
137 solution_invalidity.syncIteration();
138
139 if (solution_invalidity.hasInvalidSolution())
140 {
143 solution_invalidity.print(_console);
144 else
145 mooseWarning("The Solution Invalidity warnings are detected but silenced! "
146 "Use Problem/show_invalid_solution_console=true to show solution counts");
147 else
148 // output the occurrence of solution invalid in a summary table
150 solution_invalidity.print(_console);
151 }
152}
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition MooseError.h:345
bool acceptInvalidSolution() const
Whether or not to accept the solution based on its invalidity.
bool showInvalidSolutionConsole() const
Whether or not to print out the invalid solutions summary table in console.
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition MooseApp.h:185
void syncIteration()
Sync iteration counts to main processor Sum across all processors.
MooseApp & _app

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

◆ checkKernelCoverage()

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

System Integrity Checks

Definition at line 3731 of file NonlinearSystemBase.C.

3732{
3733 // Obtain all blocks and variables covered by all kernels
3734 std::set<SubdomainID> input_subdomains;
3735 std::set<std::string> kernel_variables;
3736
3737 bool global_kernels_exist = false;
3738 global_kernels_exist |= _scalar_kernels.hasActiveObjects();
3739 global_kernels_exist |= _nodal_kernels.hasActiveObjects();
3740
3741 _kernels.subdomainsCovered(input_subdomains, kernel_variables);
3742 _dg_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3743 _nodal_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3744 _scalar_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3745 _constraints.subdomainsCovered(input_subdomains, kernel_variables);
3746
3747#ifdef MOOSE_KOKKOS_ENABLED
3748 _kokkos_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3749 _kokkos_nodal_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3750#endif
3751
3752 if (_fe_problem.haveFV())
3753 {
3754 std::vector<FVElementalKernel *> fv_elemental_kernels;
3756 .query()
3757 .template condition<AttribSystem>("FVElementalKernel")
3758 .queryInto(fv_elemental_kernels);
3759
3760 for (auto fv_kernel : fv_elemental_kernels)
3761 {
3762 if (fv_kernel->blockRestricted())
3763 for (auto block_id : fv_kernel->blockIDs())
3764 input_subdomains.insert(block_id);
3765 else
3766 global_kernels_exist = true;
3767 kernel_variables.insert(fv_kernel->variable().name());
3768
3769 // Check for lagrange multiplier
3770 if (dynamic_cast<FVScalarLagrangeMultiplierConstraint *>(fv_kernel))
3771 kernel_variables.insert(dynamic_cast<FVScalarLagrangeMultiplierConstraint *>(fv_kernel)
3772 ->lambdaVariable()
3773 .name());
3774 }
3775
3776 std::vector<FVFluxKernel *> fv_flux_kernels;
3778 .query()
3779 .template condition<AttribSystem>("FVFluxKernel")
3780 .queryInto(fv_flux_kernels);
3781
3782 for (auto fv_kernel : fv_flux_kernels)
3783 {
3784 if (fv_kernel->blockRestricted())
3785 for (auto block_id : fv_kernel->blockIDs())
3786 input_subdomains.insert(block_id);
3787 else
3788 global_kernels_exist = true;
3789 kernel_variables.insert(fv_kernel->variable().name());
3790 }
3791
3792 std::vector<FVInterfaceKernel *> fv_interface_kernels;
3794 .query()
3795 .template condition<AttribSystem>("FVInterfaceKernel")
3796 .queryInto(fv_interface_kernels);
3797
3798 for (auto fvik : fv_interface_kernels)
3799 if (auto scalar_fvik = dynamic_cast<FVScalarLagrangeMultiplierInterface *>(fvik))
3800 kernel_variables.insert(scalar_fvik->lambdaVariable().name());
3801
3802 std::vector<FVFluxBC *> fv_flux_bcs;
3804 .query()
3805 .template condition<AttribSystem>("FVFluxBC")
3806 .queryInto(fv_flux_bcs);
3807
3808 for (auto fvbc : fv_flux_bcs)
3809 if (auto scalar_fvbc = dynamic_cast<FVBoundaryScalarLagrangeMultiplierConstraint *>(fvbc))
3810 kernel_variables.insert(scalar_fvbc->lambdaVariable().name());
3811 }
3812
3813 for (const auto & ibc : _integrated_bcs.getActiveObjects())
3814 {
3815 const auto additional_variables_covered = ibc->additionalROVariables();
3816 kernel_variables.insert(additional_variables_covered.begin(),
3817 additional_variables_covered.end());
3818 }
3819
3820 // Check kernel coverage of subdomains (blocks) in your mesh
3821 if (!global_kernels_exist)
3822 {
3823 std::set<SubdomainID> difference;
3824 std::set_difference(mesh_subdomains.begin(),
3825 mesh_subdomains.end(),
3826 input_subdomains.begin(),
3827 input_subdomains.end(),
3828 std::inserter(difference, difference.end()));
3829
3830 // there supposed to be no kernels on this lower-dimensional subdomain
3831 for (const auto & id : _mesh.interiorLowerDBlocks())
3832 difference.erase(id);
3833 for (const auto & id : _mesh.boundaryLowerDBlocks())
3834 difference.erase(id);
3835
3836 if (!difference.empty())
3837 {
3838 std::vector<SubdomainID> difference_vec =
3839 std::vector<SubdomainID>(difference.begin(), difference.end());
3840 std::vector<SubdomainName> difference_names = _mesh.getSubdomainNames(difference_vec);
3841 std::stringstream missing_block_names;
3842 std::copy(difference_names.begin(),
3843 difference_names.end(),
3844 std::ostream_iterator<std::string>(missing_block_names, " "));
3845 std::stringstream missing_block_ids;
3846 std::copy(difference.begin(),
3847 difference.end(),
3848 std::ostream_iterator<unsigned int>(missing_block_ids, " "));
3849
3850 mooseError("Each subdomain must contain at least one Kernel.\nThe following block(s) lack an "
3851 "active kernel: " +
3852 missing_block_names.str(),
3853 " (ids: ",
3854 missing_block_ids.str(),
3855 ")");
3856 }
3857 }
3858
3859 // Check kernel use of variables
3860 std::set<VariableName> variables(getVariableNames().begin(), getVariableNames().end());
3861
3862 std::set<VariableName> difference;
3863 std::set_difference(variables.begin(),
3864 variables.end(),
3865 kernel_variables.begin(),
3866 kernel_variables.end(),
3867 std::inserter(difference, difference.end()));
3868
3869 // skip checks for varaibles defined on lower-dimensional subdomain
3870 std::set<VariableName> vars(difference);
3871 for (auto & var_name : vars)
3872 {
3873 auto blks = getSubdomainsForVar(var_name);
3874 for (const auto & id : blks)
3875 if (_mesh.interiorLowerDBlocks().count(id) > 0 || _mesh.boundaryLowerDBlocks().count(id) > 0)
3876 difference.erase(var_name);
3877 }
3878
3879 if (!difference.empty())
3880 {
3881 std::stringstream missing_kernel_vars;
3882 std::copy(difference.begin(),
3883 difference.end(),
3884 std::ostream_iterator<std::string>(missing_kernel_vars, " "));
3885 mooseError("Each variable must be referenced by at least one active Kernel.\nThe following "
3886 "variable(s) lack an active kernel: " +
3887 missing_kernel_vars.str());
3888 }
3889}
char ** vars
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.
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
Base class for implementing constraints on boundaries for finite volume variables using scalar Lagran...
Base class for implementing constraints on finite volume variable elemental values using scalar Lagra...
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:1720
bool hasActiveObjects(THREAD_ID tid=0) 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< ResidualObject > _kokkos_kernels
MooseObjectTagWarehouse< ResidualObject > _kokkos_nodal_kernels
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
Definition SystemBase.h:791
std::vector< T * > & queryInto(std::vector< T * > &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse.

◆ clearAllDofIndices()

void SystemBase::clearAllDofIndices ( )
inherited

Clear all dof indices from moose variables.

Definition at line 1634 of file SystemBase.C.

1635{
1636 for (auto & var_warehouse : _vars)
1637 var_warehouse.clearAllDofIndices();
1638}
void clearAllDofIndices()
Clear all dof indices from moose variables.

Referenced by SubProblem::clearAllDofIndices().

◆ closeTaggedMatrices()

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

Close all matrices associated the tags.

Definition at line 1057 of file SystemBase.C.

1058{
1059 for (auto tag : tags)
1060 if (hasMatrix(tag))
1061 getMatrix(tag).close();
1062}

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

◆ closeTaggedVector()

void SystemBase::closeTaggedVector ( const TagID  tag)
inherited

Close vector with the given tag.

Definition at line 648 of file SystemBase.C.

649{
651 mooseError("Cannot close vector with TagID ",
652 tag,
653 " in system '",
654 name(),
655 "' because that tag does not exist in the problem");
656 else if (!hasVector(tag))
657 mooseError("Cannot close vector tag with name '",
659 "' in system '",
660 name(),
661 "' because there is no vector associated with that tag");
662 getVector(tag).close();
663}
virtual void close()=0

Referenced by SystemBase::closeTaggedVectors().

◆ closeTaggedVectors()

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

Close all vectors for given tags.

Definition at line 666 of file SystemBase.C.

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

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

◆ combineSystemSolution()

void MooseEigenSystem::combineSystemSolution ( SYSTEMTAG  tag,
const std::vector< Real > &  coefficients 
)

Linear combination of the solution vectors.

Parameters
tagSystem tag.
coefficientsCoefficients for current, old and older solutions.

Definition at line 104 of file MooseEigenSystem.C.

105{
106 mooseAssert(coefficients.size() > 0 && coefficients.size() <= 3, "Size error on coefficients");
107 if (tag == ALL)
108 {
109 solution().scale(coefficients[0]);
110 if (coefficients.size() > 1)
111 solution().add(coefficients[1], solutionOld());
112 if (coefficients.size() > 2)
113 solution().add(coefficients[2], solutionOlder());
114 }
115 else if (tag == EIGEN)
116 {
117 if (_all_eigen_vars)
118 {
119 solution().scale(coefficients[0]);
120 if (coefficients.size() > 1)
121 solution().add(coefficients[1], solutionOld());
122 if (coefficients.size() > 2)
123 solution().add(coefficients[2], solutionOlder());
124 }
125 else
126 {
127 if (coefficients.size() > 2)
128 {
129 for (const auto & dof : _eigen_var_indices)
130 {
131 Real t = solution()(dof) * coefficients[0];
132 t += solutionOld()(dof) * coefficients[1];
133 t += solutionOlder()(dof) * coefficients[2];
134 solution().set(dof, t);
135 }
136 }
137 else if (coefficients.size() > 1)
138 {
139 for (const auto & dof : _eigen_var_indices)
140 {
141 Real t = solution()(dof) * coefficients[0];
142 t += solutionOld()(dof) * coefficients[1];
143 solution().set(dof, t);
144 }
145 }
146 else
147 {
148 for (const auto & dof : _eigen_var_indices)
149 {
150 Real t = solution()(dof) * coefficients[0];
151 solution().set(dof, t);
152 }
153 }
154 }
155 }
156 solution().close();
157 update();
158}
NumericVector< Number > & solutionOld()
Definition SystemBase.h:213
NumericVector< Number > & solutionOlder()
Definition SystemBase.h:214
virtual void set(const numeric_index_type i, const T value)=0
virtual void scale(const T factor)=0
virtual void add(const numeric_index_type i, const T value)=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

Referenced by EigenExecutionerBase::chebyshev().

◆ 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 155 of file SolverSystem.C.

156{
157 // Let's try not to overcompute
158 bool compute_tds = false;
159 if (type == EXEC_LINEAR)
160 compute_tds = true;
161 else if (type == EXEC_NONLINEAR)
162 {
164 compute_tds = true;
165 }
166 else if ((type == EXEC_TIMESTEP_END) || (type == EXEC_FINAL))
167 {
169 // We likely don't have a final residual evaluation upon which we compute the time derivatives
170 // so we need to do so now
171 compute_tds = true;
172 }
173
174 // avoid division by dt which might be zero.
175 if (compute_tds && _fe_problem.dt() > 0.)
176 for (auto & ti : _time_integrators)
177 {
178 // Do things like compute integration weights
179 ti->preStep();
180 ti->computeTimeDerivatives();
181 }
182}
const ExecFlagType EXEC_TIMESTEP_END
Definition Moose.C:37
const ExecFlagType EXEC_LINEAR
Definition Moose.C:32
const ExecFlagType EXEC_NONLINEAR
Definition Moose.C:34
const ExecFlagType EXEC_FINAL
Definition Moose.C:49
void computingScalingJacobian(bool computing_scaling_jacobian)
Setter for whether we're computing the scaling jacobian.
virtual Real & dt() const
SolverParams & solverParams(unsigned int solver_sys_num=0)
Get the solver parameters.
virtual bool matrixFromColoring() const
Whether a system matrix is formed from coloring.
@ ST_LINEAR
Solving a linear problem.
Definition MooseTypes.h:902

◆ 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 3438 of file NonlinearSystemBase.C.

3440{
3441 // Default to no damping
3442 Real damping = 1.0;
3443 bool has_active_dampers = false;
3444
3445 try
3446 {
3448 {
3449 PARALLEL_TRY
3450 {
3451 TIME_SECTION("computeDampers", 3, "Computing Dampers");
3452 has_active_dampers = true;
3456 damping = std::min(cid.damping(), damping);
3457 }
3458 PARALLEL_CATCH;
3459 }
3460
3462 {
3463 PARALLEL_TRY
3464 {
3465 TIME_SECTION("computeDamping::element", 3, "Computing Element Damping");
3466
3467 has_active_dampers = true;
3471 damping = std::min(cndt.damping(), damping);
3472 }
3473 PARALLEL_CATCH;
3474 }
3475
3477 {
3478 PARALLEL_TRY
3479 {
3480 TIME_SECTION("computeDamping::general", 3, "Computing General Damping");
3481
3482 has_active_dampers = true;
3483 const auto & gdampers = _general_dampers.getActiveObjects();
3484 for (const auto & damper : gdampers)
3485 {
3486 Real gd_damping = damper->computeDamping(solution, update);
3487 try
3488 {
3489 damper->checkMinDamping(gd_damping);
3490 }
3491 catch (MooseException & e)
3492 {
3494 }
3495 damping = std::min(gd_damping, damping);
3496 }
3497 }
3498 PARALLEL_CATCH;
3499 }
3500 }
3501 catch (MooseException & e)
3502 {
3503 // The buck stops here, we have already handled the exception by
3504 // calling stopSolve(), it is now up to PETSc to return a
3505 // "diverged" reason during the next solve.
3506 }
3507 catch (std::exception & e)
3508 {
3509 // Allow the libmesh error/exception on negative jacobian
3510 const std::string & message = e.what();
3511 if (message.find("Jacobian") == std::string::npos)
3512 throw;
3513 }
3514
3515 _communicator.min(damping);
3516
3517 if (has_active_dampers && damping < 1.0)
3518 _console << " Damping factor: " << damping << std::endl;
3519
3520 return damping;
3521}
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class,...
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()
Provides a way for users to bail out of the current solve.
virtual const char * what() const
Get out the error message.
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.
NumericVector< Number > * _increment_vec
increment vector
void min(const T &r, T &o, Request &req) const
const Parallel::Communicator & _communicator
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())

Referenced by FEProblemBase::computeDamping().

◆ computeDiracContributions()

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

Definition at line 3524 of file NonlinearSystemBase.C.

3527{
3529
3530 std::set<const Elem *> dirac_elements;
3531
3533 {
3534 TIME_SECTION("computeDirac", 3, "Computing DiracKernels");
3535
3536 // TODO: Need a threading fix... but it's complicated!
3537 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
3538 {
3539 const auto & dkernels = _dirac_kernels.getActiveObjects(tid);
3540 for (const auto & dkernel : dkernels)
3541 {
3542 dkernel->clearPoints();
3543 dkernel->addPoints();
3544 }
3545 }
3546
3547 ComputeDiracThread cd(_fe_problem, vector_tags, matrix_tags, compute_type);
3548
3549 _fe_problem.getDiracElements(dirac_elements);
3550
3551 DistElemRange range(dirac_elements.begin(), dirac_elements.end(), 1);
3552 // TODO: Make Dirac work thread!
3553 // Threads::parallel_reduce(range, cd);
3554
3555 cd(range);
3556
3557 // AD DiracKernels computing the residual and Jacobian together cache their residual
3558 // contributions (via addResidualsAndJacobian), so those must be flushed too
3559 if (compute_type != Moose::ComputeType::Jacobian)
3560 for (const auto tid : make_range(libMesh::n_threads()))
3561 _fe_problem.addCachedResidual(tid);
3562
3563 if (compute_type != Moose::ComputeType::Residual)
3564 for (const auto tid : make_range(libMesh::n_threads()))
3565 _fe_problem.addCachedJacobian(tid);
3566 }
3567}
StoredRange< std::set< const Elem * >::const_iterator, const Elem * > DistElemRange
virtual void clearDiracInfo() override
Gets called before Dirac Kernels are asked to add the points they are supposed to be evaluated in.
virtual void getDiracElements(std::set< const Elem * > &elems) override
Fills "elems" with the elements that should be looped over for Dirac Kernels.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...

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

◆ computedScalingJacobian()

bool NonlinearSystemBase::computedScalingJacobian ( ) const
inlineinherited

Definition at line 79 of file NonlinearSystemBase.h.

79{ 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)
inherited

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

Definition at line 3265 of file NonlinearSystemBase.C.

3266{
3267 _nl_matrix_tags.clear();
3268
3269 auto & tags = _fe_problem.getMatrixTags();
3270
3271 for (auto & tag : tags)
3272 _nl_matrix_tags.insert(tag.second);
3273
3275}
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

◆ computeJacobian() [2/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 3278 of file NonlinearSystemBase.C.

3279{
3281
3282 computeJacobianTags(tags);
3283
3285}
void computeJacobianTags(const std::set< TagID > &tags)
Computes multiple (tag associated) Jacobian matricese.
virtual void disassociateMatrixFromTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.

Referenced by NonlinearSystemBase::computeJacobian().

◆ 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 3307 of file NonlinearSystemBase.C.

3308{
3309 _nl_matrix_tags.clear();
3310
3311 auto & tags = _fe_problem.getMatrixTags();
3312 for (auto & tag : tags)
3313 _nl_matrix_tags.insert(tag.second);
3314
3316}
void computeJacobianBlocks(std::vector< JacobianBlock * > &blocks)
Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditio...

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

◆ computeJacobianBlocks() [2/2]

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

Definition at line 3319 of file NonlinearSystemBase.C.

3321{
3322 TIME_SECTION("computeJacobianBlocks", 3);
3324
3325 for (unsigned int i = 0; i < blocks.size(); i++)
3326 {
3327 SparseMatrix<Number> & jacobian = blocks[i]->_jacobian;
3328
3329 LibmeshPetscCall(MatSetOption(cast_ref<PetscMatrix<Number> &>(jacobian).mat(),
3330 MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
3331 PETSC_TRUE));
3333 LibmeshPetscCall(MatSetOption(cast_ref<PetscMatrix<Number> &>(jacobian).mat(),
3334 MAT_NEW_NONZERO_ALLOCATION_ERR,
3335 PETSC_TRUE));
3336
3337 jacobian.zero();
3338 }
3339
3340 for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
3342
3343 PARALLEL_TRY
3344 {
3347 Threads::parallel_reduce(elem_range, cjb);
3348 }
3349 PARALLEL_CATCH;
3350
3351 for (unsigned int i = 0; i < blocks.size(); i++)
3352 blocks[i]->_jacobian.close();
3353
3354 for (unsigned int i = 0; i < blocks.size(); i++)
3355 {
3356 libMesh::System & precond_system = blocks[i]->_precond_system;
3357 SparseMatrix<Number> & jacobian = blocks[i]->_jacobian;
3358
3359 unsigned int ivar = blocks[i]->_ivar;
3360 unsigned int jvar = blocks[i]->_jvar;
3361
3362 // Dirichlet BCs
3363 std::vector<numeric_index_type> zero_rows;
3364 PARALLEL_TRY
3365 {
3367 for (const auto & bnode : bnd_nodes)
3368 {
3369 BoundaryID boundary_id = bnode->_bnd_id;
3370 Node * node = bnode->_node;
3371
3372 if (_nodal_bcs.hasActiveBoundaryObjects(boundary_id))
3373 {
3374 const auto & bcs = _nodal_bcs.getActiveBoundaryObjects(boundary_id);
3375
3376 if (node->processor_id() == processor_id())
3377 {
3378 _fe_problem.reinitNodeFace(node, boundary_id, 0);
3379
3380 for (const auto & bc : bcs)
3381 if (bc->variable().number() == ivar && bc->shouldApply())
3382 {
3383 // The first zero is for the variable number... there is only one variable in
3384 // each mini-system The second zero only works with Lagrange elements!
3385 zero_rows.push_back(node->dof_number(precond_system.number(), 0, 0));
3386 }
3387 }
3388 }
3389 }
3390 }
3391 PARALLEL_CATCH;
3392
3393 jacobian.close();
3394
3395 // This zeroes the rows corresponding to Dirichlet BCs and puts a 1.0 on the diagonal
3396 if (ivar == jvar)
3397 jacobian.zero_rows(zero_rows, 1.0);
3398 else
3399 jacobian.zero_rows(zero_rows, 0.0);
3400
3401 jacobian.close();
3402 }
3403}
boundary_id_type BoundaryID
Specialization for filling multiple "small" preconditioning matrices simulatenously.
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 reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
const ConstBndNodeRange & getCurrentAlgebraicBndNodeRange()
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
Scope guard for starting and stopping Floating Point Exception Trapping.
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
unsigned int number() const
StoredRange< MeshBase::const_element_iterator, const Elem * > ConstElemRange

◆ 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 3002 of file NonlinearSystemBase.C.

3003{
3004 TIME_SECTION("computeJacobianInternal", 3);
3005
3007
3008 // Make matrix ready to use
3010
3011 for (auto tag : tags)
3012 {
3013 if (!hasMatrix(tag))
3014 continue;
3015
3016 auto & jacobian = getMatrix(tag);
3017 // Necessary for speed
3018 if (auto petsc_matrix = dynamic_cast<PetscMatrix<Number> *>(&jacobian))
3019 {
3020 LibmeshPetscCall(MatSetOption(petsc_matrix->mat(),
3021 MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
3022 PETSC_TRUE));
3024 LibmeshPetscCall(
3025 MatSetOption(petsc_matrix->mat(), MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE));
3027 LibmeshPetscCall(MatSetOption(
3028 cast_ref<PetscMatrix<Number> &>(jacobian).mat(), MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE));
3029 }
3030 }
3031
3032 jacobianSetup();
3033
3034 // Jacobian contributions from UOs - for now this is used for ray tracing
3035 // and ray kernels that contribute to the Jacobian (think line sources)
3036 std::vector<UserObject *> uos;
3038 .query()
3039 .condition<AttribSystem>("UserObject")
3040 .condition<AttribExecOns>(EXEC_PRE_KERNELS)
3041 .queryInto(uos);
3042 for (auto & uo : uos)
3043 uo->jacobianSetup();
3044 for (auto & uo : uos)
3045 {
3046 uo->initialize();
3047 uo->execute();
3048 uo->finalize();
3049 }
3050
3051 // reinit scalar variables
3052 for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
3054
3055#ifdef MOOSE_KOKKOS_ENABLED
3058#endif
3059
3060 PARALLEL_TRY
3061 {
3062 // We would like to compute ScalarKernels, block NodalKernels, FVFluxKernels, and mortar objects
3063 // up front because we want these included whether we are computing an ordinary Jacobian or a
3064 // Jacobian for determining variable scaling factors
3066
3067 // Block restricted Nodal Kernels
3069 {
3072 Threads::parallel_reduce(range, cnkjt);
3073
3074 unsigned int n_threads = libMesh::n_threads();
3075 for (unsigned int i = 0; i < n_threads;
3076 i++) // Add any cached jacobians that might be hanging around
3078 }
3079
3080 using FVRange = StoredRange<MooseMesh::const_face_info_iterator, const FaceInfo *>;
3081 if (_fe_problem.haveFV())
3082 {
3083 // the same loop works for both residual and jacobians because it keys
3084 // off of FEProblem's _currently_computing_jacobian parameter
3086 _fe_problem, this->number(), tags, /*on_displaced=*/false);
3088 Threads::parallel_reduce(faces, fvj);
3089 }
3092 {
3094 _fe_problem, this->number(), tags, /*on_displaced=*/true);
3095 FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
3096 displaced_problem->mesh().ownedFaceInfoEnd());
3097 Threads::parallel_reduce(faces, fvr);
3098 }
3099
3101
3102 // Get our element range for looping over
3104
3106 {
3107 // Only compute Jacobians corresponding to the diagonals of volumetric compute objects
3108 // because this typically gives us a good representation of the physics. NodalBCs and
3109 // Constraints can introduce dramatically different scales (often order unity).
3110 // IntegratedBCs and/or InterfaceKernels may use penalty factors. DGKernels may be ok, but
3111 // they are almost always used in conjunction with Kernels
3113 Threads::parallel_reduce(elem_range, cj);
3114 unsigned int n_threads = libMesh::n_threads();
3115 for (unsigned int i = 0; i < n_threads;
3116 i++) // Add any Jacobian contributions still hanging around
3118
3119 // Check whether any exceptions were thrown and propagate this information for parallel
3120 // consistency before
3121 // 1) we do parallel communication when closing tagged matrices
3122 // 2) early returning before reaching our PARALLEL_CATCH below
3124
3125 closeTaggedMatrices(tags);
3126
3127 return;
3128 }
3129
3130 switch (_fe_problem.coupling())
3131 {
3133 {
3135 Threads::parallel_reduce(elem_range, cj);
3136
3137 unsigned int n_threads = libMesh::n_threads();
3138 for (unsigned int i = 0; i < n_threads;
3139 i++) // Add any Jacobian contributions still hanging around
3141
3142 // Boundary restricted Nodal Kernels
3144 {
3147
3148 Threads::parallel_reduce(bnd_range, cnkjt);
3149 unsigned int n_threads = libMesh::n_threads();
3150 for (unsigned int i = 0; i < n_threads;
3151 i++) // Add any cached jacobians that might be hanging around
3153 }
3154 }
3155 break;
3156
3157 default:
3159 {
3161 Threads::parallel_reduce(elem_range, cj);
3162 unsigned int n_threads = libMesh::n_threads();
3163
3164 for (unsigned int i = 0; i < n_threads; i++)
3166
3167 // Boundary restricted Nodal Kernels
3169 {
3172
3173 Threads::parallel_reduce(bnd_range, cnkjt);
3174 unsigned int n_threads = libMesh::n_threads();
3175 for (unsigned int i = 0; i < n_threads;
3176 i++) // Add any cached jacobians that might be hanging around
3178 }
3179 }
3180 break;
3181 }
3182
3184
3185 static bool first = true;
3186
3187 // This adds zeroes into geometric coupling entries to ensure they stay in the matrix
3188 if ((_fe_problem.restoreOriginalNonzeroPattern() || first) &&
3190 {
3191 first = false;
3193
3196 }
3197 }
3198 PARALLEL_CATCH;
3199
3200 // Have no idea how to have constraints work
3201 // with the tag system
3202 PARALLEL_TRY
3203 {
3204 // Add in Jacobian contributions from other Constraints
3205 if (_fe_problem._has_constraints && tags.count(systemMatrixTag()))
3206 {
3207 // Some constraints need to be able to read values from the Jacobian, which requires that it
3208 // be closed/assembled
3209 auto & system_matrix = getMatrix(systemMatrixTag());
3210 std::unique_ptr<SparseMatrix<Number>> hash_copy;
3211 const SparseMatrix<Number> * view_jac_ptr;
3212 auto make_readable_jacobian = [&]()
3213 {
3214#if PETSC_RELEASE_GREATER_EQUALS(3, 23, 0)
3215 if (system_matrix.use_hash_table())
3216 {
3217 hash_copy = cast_ref<PetscMatrix<Number> &>(system_matrix).copy_from_hash();
3218 view_jac_ptr = hash_copy.get();
3219 }
3220 else
3221 view_jac_ptr = &system_matrix;
3222#else
3223 view_jac_ptr = &system_matrix;
3224#endif
3225 if (view_jac_ptr == &system_matrix)
3226 system_matrix.close();
3227 };
3228
3229 make_readable_jacobian();
3230
3231 // Nodal Constraints
3232 const bool had_nodal_constraints = enforceNodalConstraintsJacobian(*view_jac_ptr);
3233 if (had_nodal_constraints)
3234 // We have to make a new readable Jacobian
3235 make_readable_jacobian();
3236
3237 // Undisplaced Constraints
3238 constraintJacobians(*view_jac_ptr, false);
3239
3240 // Displaced Constraints
3242 constraintJacobians(*view_jac_ptr, true);
3243 }
3244 }
3245 PARALLEL_CATCH;
3246
3248 closeTaggedMatrices(tags);
3249
3250 // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs
3251 // on boundary nodes
3254
3255 if (hasDiagSaveIn())
3257
3258 // Accumulate the occurrence of solution invalid warnings for the current iteration cumulative
3259 // counters
3262}
const ExecFlagType EXEC_PRE_KERNELS
Definition Moose.C:59
Key structure for APIs manipulating global vectors/matrices.
Definition Assembly.h:836
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
Definition Assembly.C:3835
bool restoreOriginalNonzeroPattern() const
AuxiliarySystem & getAuxiliarySystem()
virtual void addCachedJacobian(const THREAD_ID tid) override
bool hasKokkosResidualObjects() const
void setCurrentNonlinearSystem(const unsigned int nl_sys_num)
Moose::CouplingType coupling() const
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,...
virtual MooseMesh & mesh() override
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override
bool _has_constraints
Whether or not this system has any Constraints.
bool ignoreZerosInJacobian() const
Will return true if zeros in the Jacobian are to be dropped from the sparsity pattern.
face_info_iterator ownedFaceInfoEnd()
Definition MooseMesh.C:1467
face_info_iterator ownedFaceInfoBegin()
Iterators to owned faceInfo objects.
Definition MooseMesh.C:1458
bool hasActiveBlockObjects(THREAD_ID tid=0) const
void computeDiracContributions(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags, Moose::ComputeType compute_type)
virtual void jacobianSetup() override
void addImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data)
Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled th...
void computeScalarKernelsJacobians(const std::set< TagID > &tags)
void constraintJacobians(const SparseMatrix< Number > &jacobian_to_view, bool displaced)
Add jacobian contributions from Constraints.
bool hasDiagSaveIn() const
Weather or not the nonlinear system has diagonal Jacobian save-ins.
void computeKokkosJacobian(const std::set< TagID > &tags)
Compute Jacobian with Kokkos objects.
void mortarConstraints(Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Do mortar constraint residual/jacobian computations.
void computeNodalBCsJacobian(const std::set< TagID > &tags)
Compute the Jacobian for nodal boundary conditions.
bool enforceNodalConstraintsJacobian(const SparseMatrix< Number > &jacobian)
Enforce nodal constraints in the Jacobian.
void accumulateIterationIntoTimeStepOccurences()
Pass the number of solution invalid occurrences from current iteration to cumulative counters.
virtual void activateAllMatrixTags()
Make all existing matrices active.
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
@ COUPLING_DIAG
Definition MooseTypes.h:786
@ COUPLING_CUSTOM
Definition MooseTypes.h:788
StoredRange< MeshBase::const_node_iterator, const Node * > ConstNodeRange

Referenced by NonlinearSystemBase::computeJacobianTags().

◆ computeJacobianTags()

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

Computes multiple (tag associated) Jacobian matricese.

Definition at line 3288 of file NonlinearSystemBase.C.

3289{
3290 TIME_SECTION("computeJacobianTags", 5);
3291
3293
3294 try
3295 {
3297 }
3298 catch (MooseException & e)
3299 {
3300 // The buck stops here, we have already handled the exception by
3301 // calling stopSolve(), it is now up to PETSc to return a
3302 // "diverged" reason during the next solve.
3303 }
3304}
void computeJacobianInternal(const std::set< TagID > &tags)
Form multiple matrices for all the tags.

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

◆ computeKokkosJacobian()

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

Compute Jacobian with Kokkos objects.

Referenced by NonlinearSystemBase::computeJacobianInternal().

◆ computeKokkosNodalBCsResidual()

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

◆ computeKokkosResidual()

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

Compute residual with Kokkos objects.

Referenced by NonlinearSystemBase::computeResidualInternal().

◆ computeKokkosResidualAndJacobian()

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

◆ computeNodalBCsJacobian()

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

Compute the Jacobian for nodal boundary conditions.

Definition at line 2174 of file NonlinearSystemBase.C.

2175{
2176 // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs
2177 // on boundary nodes
2180
2181 MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
2182
2183 // Select nodal kernels
2184 if (tags.size() == _fe_problem.numMatrixTags() || !tags.size())
2185 nbc_warehouse = &_nodal_bcs;
2186 else if (tags.size() == 1)
2187 nbc_warehouse = &(_nodal_bcs.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2188 else
2189 nbc_warehouse = &(_nodal_bcs.getMatrixTagsObjectWarehouse(tags, 0));
2190
2191 // Return early if there is no nodal kernel
2192 if (!nbc_warehouse->hasActiveObjects())
2193 return;
2194
2195 PARALLEL_TRY
2196 {
2197 // We may be switching from add to set. Moreover, we rely on a call to MatZeroRows to enforce
2198 // the nodal boundary condition constraints which requires that the matrix be truly assembled
2199 // as opposed to just flushed. Consequently we can't do the following despite any desire to
2200 // keep our initial sparsity pattern honored (see https://gitlab.com/petsc/petsc/-/issues/852)
2201 //
2202 // flushTaggedMatrices(tags);
2203 closeTaggedMatrices(tags);
2204
2205 // Cache the information about which BCs are coupled to which
2206 // variables, so we don't have to figure it out for each node.
2207 std::map<std::string, std::set<unsigned int>> bc_involved_vars;
2208 const std::set<BoundaryID> & all_boundary_ids = _mesh.getBoundaryIDs();
2209 for (const auto & bid : all_boundary_ids)
2210 {
2211 // Get reference to all the NodalBCs for this ID. This is only
2212 // safe if there are NodalBCBases there to be gotten...
2213 if (nbc_warehouse->hasActiveBoundaryObjects(bid))
2214 {
2215 const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(bid);
2216 for (const auto & bc : bcs)
2217 {
2218 const std::vector<MooseVariableFEBase *> & coupled_moose_vars = bc->getCoupledMooseVars();
2219
2220 // Create the set of "involved" MOOSE nonlinear vars, which includes all coupled vars
2221 // and the BC's own variable
2222 std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2223 for (const auto & coupled_var : coupled_moose_vars)
2224 if (coupled_var->kind() == Moose::VAR_SOLVER)
2225 var_set.insert(coupled_var->number());
2226
2227 var_set.insert(bc->variable().number());
2228 }
2229 }
2230 }
2231
2232 // reinit scalar variables again. This reinit does not re-fill any of the scalar variable
2233 // solution arrays because that was done above. It only will reorder the derivative
2234 // information for AD calculations to be suitable for NodalBC calculations
2235 for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
2236 _fe_problem.reinitScalars(tid, true);
2237
2238 // Get variable coupling list. We do all the NodalBCBase stuff on
2239 // thread 0... The couplingEntries() data structure determines
2240 // which variables are "coupled" as far as the preconditioner is
2241 // concerned, not what variables a boundary condition specifically
2242 // depends on.
2243 auto & coupling_entries = _fe_problem.couplingEntries(/*_tid=*/0, this->number());
2244
2245 // Compute Jacobians for NodalBCBases
2247 for (const auto & bnode : bnd_nodes)
2248 {
2249 BoundaryID boundary_id = bnode->_bnd_id;
2250 Node * node = bnode->_node;
2251
2252 if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id) &&
2253 node->processor_id() == processor_id())
2254 {
2255 _fe_problem.reinitNodeFace(node, boundary_id, 0);
2256
2257 const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
2258 for (const auto & bc : bcs)
2259 {
2260 // Get the set of involved MOOSE vars for this BC
2261 std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2262
2263 // Loop over all the variables whose Jacobian blocks are
2264 // actually being computed, call computeOffDiagJacobian()
2265 // for each one which is actually coupled (otherwise the
2266 // value is zero.)
2267 for (const auto & it : coupling_entries)
2268 {
2269 unsigned int ivar = it.first->number(), jvar = it.second->number();
2270
2271 // We are only going to call computeOffDiagJacobian() if:
2272 // 1.) the BC's variable is ivar
2273 // 2.) jvar is "involved" with the BC (including jvar==ivar), and
2274 // 3.) the BC should apply.
2275 if ((bc->variable().number() == ivar) && var_set.count(jvar) && bc->shouldApply())
2276 bc->computeOffDiagJacobian(jvar);
2277 }
2278
2279 // only if this coupling is being used by the preconditioner (otherwise the value is
2280 // zero)
2281 const auto & coupled_scalar_vars = bc->getCoupledMooseScalarVars();
2282 for (const auto & jvariable : coupled_scalar_vars)
2283 if (hasScalarVariable(jvariable->name()) &&
2284 _fe_problem.areCoupled(bc->variable().number(), jvariable->number(), number()))
2285 bc->computeOffDiagJacobianScalar(jvariable->number());
2286 }
2287 }
2288 } // end loop over boundary nodes
2289
2290 // Set the cached NodalBCBase values in the Jacobian matrix
2292 }
2293 PARALLEL_CATCH;
2294}
void setCachedJacobian(GlobalDataKey)
Sets previously-cached Jacobian values via SparseMatrix::set() calls.
Definition Assembly.C:4511
std::vector< std::pair< MooseVariableFieldBase *, MooseVariableFieldBase * > > & couplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num)
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.
Definition MooseMesh.C:2990
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.
MooseObjectWarehouse< T > & getMatrixTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given matrix tag.
A storage container for MooseObjects that inherit from SetupInterface.
virtual bool hasScalarVariable(const std::string &var_name) const
Definition SystemBase.C:873
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
@ VAR_SOLVER
Definition MooseTypes.h:770

Referenced by NonlinearSystemBase::computeJacobianInternal().

◆ computeNodalBCsResidual() [1/3]

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

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

Definition at line 2113 of file NonlinearSystemBase.C.

2114{
2115#ifdef MOOSE_KOKKOS_ENABLED
2118#endif
2119
2120 // We need to close the diag_save_in variables on the aux system before NodalBCBases clear the
2121 // dofs on boundary nodes
2122 if (_has_save_in)
2124
2125 // Select nodal kernels
2126 MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
2127
2128 if (tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL) || !tags.size())
2129 nbc_warehouse = &_nodal_bcs;
2130 else if (tags.size() == 1)
2131 nbc_warehouse = &(_nodal_bcs.getVectorTagObjectWarehouse(*(tags.begin()), 0));
2132 else
2133 nbc_warehouse = &(_nodal_bcs.getVectorTagsObjectWarehouse(tags, 0));
2134
2135 // Return early if there is no nodal kernel
2136 if (!nbc_warehouse->hasActiveObjects())
2137 return;
2138
2139 PARALLEL_TRY
2140 {
2142
2143 if (!bnd_nodes.empty())
2144 {
2145 TIME_SECTION("NodalBCs", 3 /*, "Computing NodalBCs"*/);
2146
2147 for (const auto & bnode : bnd_nodes)
2148 {
2149 BoundaryID boundary_id = bnode->_bnd_id;
2150 Node * node = bnode->_node;
2151
2152 if (node->processor_id() == processor_id() &&
2153 nbc_warehouse->hasActiveBoundaryObjects(boundary_id))
2154 {
2155 // reinit variables in nodes
2156 _fe_problem.reinitNodeFace(node, boundary_id, 0);
2157
2158 const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
2159 for (const auto & nbc : bcs)
2160 if (nbc->shouldApply())
2161 nbc->computeResidual();
2162 }
2163 }
2164 }
2165 }
2166 PARALLEL_CATCH;
2167
2168 if (_Re_time)
2169 _Re_time->close();
2171}
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag.
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...
NumericVector< Number > * _Re_time
residual vector for time contributions
void computeResidual(NumericVector< Number > &residual, TagID tag_id)
Form a residual vector for a given tag.
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
void computeKokkosNodalBCsResidual(const std::set< TagID > &tags)
Compute Kokkos nodal BCs.
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:184
bool empty() const
@ VECTOR_TAG_RESIDUAL

◆ computeNodalBCsResidual() [2/3]

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

Enforces nodal boundary conditions.

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

Definition at line 2088 of file NonlinearSystemBase.C.

2089{
2090 _nl_vector_tags.clear();
2091
2092 const auto & residual_vector_tags = _fe_problem.getVectorTags(Moose::VECTOR_TAG_RESIDUAL);
2093 for (const auto & residual_vector_tag : residual_vector_tags)
2094 _nl_vector_tags.insert(residual_vector_tag._id);
2095
2099}
std::set< TagID > _nl_vector_tags
Vector tags to temporarily store all tags associated with the current system.
void computeNodalBCsResidual(NumericVector< Number > &residual)
Enforces nodal boundary conditions.
TagID residualVectorTag() const override
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition SubProblem.C:161
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
Definition SystemBase.C:990

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

◆ computeNodalBCsResidual() [3/3]

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

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

Definition at line 2102 of file NonlinearSystemBase.C.

2104{
2106
2108
2110}

◆ computeNodalBCsResidualAndJacobian()

void NonlinearSystemBase::computeNodalBCsResidualAndJacobian ( const std::set< TagID > &  vector_tags,
const std::set< TagID > &  matrix_tags 
)
protectedinherited

Compute the residual and Jacobian together for nodal boundary conditions.

Definition at line 2297 of file NonlinearSystemBase.C.

2300{
2301#ifdef MOOSE_KOKKOS_ENABLED
2303 computeKokkosNodalBCsResidual(vector_tags);
2304#endif
2305
2306 // Return early if there is no nodal kernel
2308 return;
2309
2310 PARALLEL_TRY
2311 {
2313
2314 if (!bnd_nodes.empty())
2315 {
2316 TIME_SECTION("NodalBCs", 3 /*, "Computing NodalBCs"*/);
2317
2318 for (const auto & bnode : bnd_nodes)
2319 {
2320 BoundaryID boundary_id = bnode->_bnd_id;
2321 Node * node = bnode->_node;
2322
2323 if (node->processor_id() == processor_id())
2324 {
2325 // reinit variables in nodes
2326 _fe_problem.reinitNodeFace(node, boundary_id, 0);
2327 if (_nodal_bcs.hasActiveBoundaryObjects(boundary_id))
2328 {
2329 const auto & bcs = _nodal_bcs.getActiveBoundaryObjects(boundary_id);
2330 for (const auto & nbc : bcs)
2331 if (nbc->shouldApply())
2332 nbc->computeResidualAndJacobian();
2333 }
2334 }
2335 }
2336 }
2337 }
2338 PARALLEL_CATCH;
2339
2340 // Set the cached NodalBCBase values in the Jacobian matrix
2342}

Referenced by NonlinearSystemBase::computeResidualAndJacobianTags().

◆ computeResidual()

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

Form a residual vector for a given tag.

Definition at line 791 of file NonlinearSystemBase.C.

792{
793 mooseDeprecated(" Please use computeResidualTag");
794
795 computeResidualTag(residual, tag_id);
796}
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition MooseError.h:363
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 1960 of file NonlinearSystemBase.C.

1962{
1963 TIME_SECTION("computeResidualAndJacobianInternal", 3);
1964
1965 // These residual objects are only computed in the separate residual/Jacobian paths. Erroring
1966 // here prevents them from being silently dropped, which would produce wrong answers
1968 mooseDocumentedError("moose",
1969 33531,
1970 "residual_and_jacobian_together does not yet support ScalarKernels. Their "
1971 "contributions would be silently dropped. Please use "
1972 "residual_and_jacobian_together = false");
1974 mooseDocumentedError("moose",
1975 33531,
1976 "residual_and_jacobian_together does not yet support NodalKernels. Their "
1977 "contributions would be silently dropped. Please use "
1978 "residual_and_jacobian_together = false");
1981 "moose",
1982 33531,
1983 "residual_and_jacobian_together does not yet support nodal constraints. Their "
1984 "contributions would be silently dropped. Please use "
1985 "residual_and_jacobian_together = false");
1986
1987 // Make matrix ready to use
1989
1990 for (auto tag : matrix_tags)
1991 {
1992 if (!hasMatrix(tag))
1993 continue;
1994
1995 auto & jacobian = getMatrix(tag);
1996 // Necessary for speed
1997 if (auto petsc_matrix = dynamic_cast<PetscMatrix<Number> *>(&jacobian))
1998 {
1999 LibmeshPetscCall(MatSetOption(petsc_matrix->mat(),
2000 MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2001 PETSC_TRUE));
2003 LibmeshPetscCall(
2004 MatSetOption(petsc_matrix->mat(), MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE));
2006 LibmeshPetscCall(MatSetOption(
2007 cast_ref<PetscMatrix<Number> &>(jacobian).mat(), MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE));
2008 }
2009 }
2010
2011 residualSetup();
2012
2013 // Residual contributions from UOs - for now this is used for ray tracing
2014 // and ray kernels that contribute to the residual (think line sources)
2015 std::vector<UserObject *> uos;
2017 .query()
2018 .condition<AttribSystem>("UserObject")
2019 .condition<AttribExecOns>(EXEC_PRE_KERNELS)
2020 .queryInto(uos);
2021 for (auto & uo : uos)
2022 uo->residualSetup();
2023 for (auto & uo : uos)
2024 {
2025 uo->initialize();
2026 uo->execute();
2027 uo->finalize();
2028 }
2029
2030 // reinit scalar variables
2031 for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
2033
2034#ifdef MOOSE_KOKKOS_ENABLED
2036 computeKokkosResidualAndJacobian(vector_tags, matrix_tags);
2037#endif
2038
2039 // residual contributions from the domain
2040 PARALLEL_TRY
2041 {
2042 TIME_SECTION("Kernels", 3 /*, "Computing Kernels"*/);
2043
2045
2046 ComputeResidualAndJacobianThread crj(_fe_problem, vector_tags, matrix_tags);
2047 Threads::parallel_reduce(elem_range, crj);
2048
2049 using FVRange = StoredRange<MooseMesh::const_face_info_iterator, const FaceInfo *>;
2050 if (_fe_problem.haveFV())
2051 {
2053 _fe_problem, this->number(), vector_tags, matrix_tags, /*on_displaced=*/false);
2055 Threads::parallel_reduce(faces, fvrj);
2056 }
2059 {
2061 _fe_problem, this->number(), vector_tags, matrix_tags, /*on_displaced=*/true);
2062 FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
2063 displaced_problem->mesh().ownedFaceInfoEnd());
2064 Threads::parallel_reduce(faces, fvr);
2065 }
2066
2068
2069 unsigned int n_threads = libMesh::n_threads();
2070 for (unsigned int i = 0; i < n_threads;
2071 i++) // Add any cached residuals that might be hanging around
2072 {
2075 }
2076 }
2077 PARALLEL_CATCH;
2078
2079 // residual and Jacobian contributions from DiracKernels, computed together in a single pass
2080 PARALLEL_TRY
2081 {
2083 }
2084 PARALLEL_CATCH;
2085}
void mooseDocumentedError(const std::string &repo_name, const unsigned int issue_num, Args &&... args)
Emit a documented error message with the given stringified, concatenated args and terminate the appli...
Definition MooseError.h:332
bool hasActiveNodalConstraints() const
Deterimine if active objects exist.
virtual void addCachedResidual(const THREAD_ID tid) override
void computeKokkosResidualAndJacobian(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
virtual void residualSetup() override

Referenced by NonlinearSystemBase::computeResidualAndJacobianTags().

◆ 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 879 of file NonlinearSystemBase.C.

881{
882 const bool required_residual =
883 vector_tags.find(residualVectorTag()) == vector_tags.end() ? false : true;
884
885 try
886 {
887 zeroTaggedVectors(vector_tags);
888 computeResidualAndJacobianInternal(vector_tags, matrix_tags);
889 closeTaggedVectors(vector_tags);
890 closeTaggedMatrices(matrix_tags);
891
892 if (required_residual)
893 {
894 auto & residual = getVector(residualVectorTag());
895 if (!_time_integrators.empty())
896 {
897 for (auto & ti : _time_integrators)
898 ti->postResidual(residual);
899 }
900 else
901 residual += *_Re_non_time;
902 residual.close();
903 }
904
905 computeNodalBCsResidualAndJacobian(vector_tags, matrix_tags);
906 closeTaggedVectors(vector_tags);
907 closeTaggedMatrices(matrix_tags);
908 }
909 catch (MooseException & e)
910 {
911 // The buck stops here, we have already handled the exception by
912 // calling stopSolve(), it is now up to PETSc to return a
913 // "diverged" reason during the next solve.
914 }
915}
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 computeNodalBCsResidualAndJacobian(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Compute the residual and Jacobian together for nodal boundary conditions.
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition SystemBase.C:692
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition SystemBase.C:666

Referenced by FEProblemBase::computeResidualAndJacobian().

◆ 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 1737 of file NonlinearSystemBase.C.

1738{
1739 parallel_object_only();
1740
1741 TIME_SECTION("computeResidualInternal", 3);
1742
1743 residualSetup();
1744
1745 // Residual contributions from UOs - for now this is used for ray tracing
1746 // and ray kernels that contribute to the residual (think line sources)
1747 std::vector<GeneralUserObject *> uos;
1749 .query()
1750 .condition<AttribSystem>("UserObject")
1751 .condition<AttribExecOns>(EXEC_PRE_KERNELS)
1752 .queryInto(uos);
1753 for (auto & uo : uos)
1754 uo->residualSetup();
1755 for (auto & uo : uos)
1756 {
1757 uo->initialize();
1758 uo->execute();
1759 uo->finalize();
1760 }
1761
1762 // reinit scalar variables
1763 for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
1765
1766#ifdef MOOSE_KOKKOS_ENABLED
1769#endif
1770
1771 // residual contributions from the domain
1772 PARALLEL_TRY
1773 {
1774 TIME_SECTION("Kernels", 3 /*, "Computing Kernels"*/);
1775
1777
1779 Threads::parallel_reduce(elem_range, cr);
1780
1781 // We pass face information directly to FV residual objects for their evaluation. Consequently
1782 // we must make sure to do separate threaded loops for 1) undisplaced face information objects
1783 // and undisplaced residual objects and 2) displaced face information objects and displaced
1784 // residual objects
1785 using FVRange = StoredRange<MooseMesh::const_face_info_iterator, const FaceInfo *>;
1786 if (_fe_problem.haveFV())
1787 {
1789 _fe_problem, this->number(), tags, /*on_displaced=*/false);
1791 Threads::parallel_reduce(faces, fvr);
1792 }
1795 {
1797 _fe_problem, this->number(), tags, /*on_displaced=*/true);
1798 FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
1799 displaced_problem->mesh().ownedFaceInfoEnd());
1800 Threads::parallel_reduce(faces, fvr);
1801 }
1802
1803 unsigned int n_threads = libMesh::n_threads();
1804 for (unsigned int i = 0; i < n_threads;
1805 i++) // Add any cached residuals that might be hanging around
1807 }
1808 PARALLEL_CATCH;
1809
1810 // residual contributions from the scalar kernels
1811 PARALLEL_TRY
1812 {
1813 // do scalar kernels (not sure how to thread this)
1815 {
1816 TIME_SECTION("ScalarKernels", 3 /*, "Computing ScalarKernels"*/);
1817
1818 MooseObjectWarehouse<ScalarKernelBase> * scalar_kernel_warehouse;
1819 // This code should be refactored once we can do tags for scalar
1820 // kernels
1821 // Should redo this based on Warehouse
1822 if (!tags.size() || tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL))
1823 scalar_kernel_warehouse = &_scalar_kernels;
1824 else if (tags.size() == 1)
1825 scalar_kernel_warehouse =
1826 &(_scalar_kernels.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1827 else
1828 // scalar_kernels is not threading
1829 scalar_kernel_warehouse = &(_scalar_kernels.getVectorTagsObjectWarehouse(tags, 0));
1830
1831 bool have_scalar_contributions = false;
1832 const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
1833 for (const auto & scalar_kernel : scalars)
1834 {
1835 scalar_kernel->reinit();
1836 const std::vector<dof_id_type> & dof_indices = scalar_kernel->variable().dofIndices();
1837 const DofMap & dof_map = scalar_kernel->variable().dofMap();
1838 const dof_id_type first_dof = dof_map.first_dof();
1839 const dof_id_type end_dof = dof_map.end_dof();
1840 for (dof_id_type dof : dof_indices)
1841 {
1842 if (dof >= first_dof && dof < end_dof)
1843 {
1844 scalar_kernel->computeResidual();
1845 have_scalar_contributions = true;
1846 break;
1847 }
1848 }
1849 }
1850 if (have_scalar_contributions)
1852 }
1853 }
1854 PARALLEL_CATCH;
1855
1856 // residual contributions from Block NodalKernels
1857 PARALLEL_TRY
1858 {
1860 {
1861 TIME_SECTION("NodalKernels", 3 /*, "Computing NodalKernels"*/);
1862
1864
1866
1867 if (range.begin() != range.end())
1868 {
1869 _fe_problem.reinitNode(*range.begin(), 0);
1870
1871 Threads::parallel_reduce(range, cnk);
1872
1873 unsigned int n_threads = libMesh::n_threads();
1874 for (unsigned int i = 0; i < n_threads;
1875 i++) // Add any cached residuals that might be hanging around
1877 }
1878 }
1879 }
1880 PARALLEL_CATCH;
1881
1883 // We computed the volumetric objects. We can return now before we get into
1884 // any strongly enforced constraint conditions or penalty-type objects
1885 // (DGKernels, IntegratedBCs, InterfaceKernels, Constraints)
1886 return;
1887
1888 // residual contributions from boundary NodalKernels
1889 PARALLEL_TRY
1890 {
1892 {
1893 TIME_SECTION("NodalKernelBCs", 3 /*, "Computing NodalKernelBCs"*/);
1894
1896
1898
1899 Threads::parallel_reduce(bnd_node_range, cnk);
1900
1901 unsigned int n_threads = libMesh::n_threads();
1902 for (unsigned int i = 0; i < n_threads;
1903 i++) // Add any cached residuals that might be hanging around
1905 }
1906 }
1907 PARALLEL_CATCH;
1908
1910
1911 if (_residual_copy.get())
1912 {
1915 }
1916
1918 {
1922 }
1923
1924 PARALLEL_TRY { computeDiracContributions(tags, {}, Moose::ComputeType::Residual); }
1925 PARALLEL_CATCH;
1926
1928 {
1930 PARALLEL_CATCH;
1932 }
1933
1934 // Add in Residual contributions from other Constraints
1936 {
1937 PARALLEL_TRY
1938 {
1939 // Undisplaced Constraints
1941
1942 // Displaced Constraints
1945
1948 }
1949 PARALLEL_CATCH;
1951 }
1952
1953 // Accumulate the occurrence of solution invalid warnings for the current iteration cumulative
1954 // counters
1957}
virtual void residualEnd(THREAD_ID tid=0) const
virtual void addResidualScalar(const THREAD_ID tid=0)
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
void computingScalingResidual(bool computing_scaling_residual)
Setter for whether we're computing the scaling residual.
void computingNonlinearResid(bool computing_nonlinear_residual) final
Set whether or not the problem is in the process of computing the nonlinear residual.
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
void computeKokkosResidual(const std::set< TagID > &tags)
Compute residual with Kokkos objects.
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
std::unique_ptr< NumericVector< Number > > _residual_copy
Copy of the residual vector, or nullptr if a copy is not needed.
void enforceNodalConstraintsResidual(NumericVector< Number > &residual)
Enforce nodal constraints.
void constraintResiduals(NumericVector< Number > &residual, bool displaced)
Add residual contributions from Constraints.
virtual void localize(std::vector< T > &v_local) const=0

Referenced by NonlinearSystemBase::computeResidualTags().

◆ 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 777 of file NonlinearSystemBase.C.

778{
779 _nl_vector_tags.clear();
780 _nl_vector_tags.insert(tag_id);
782
784
786
788}
void computeResidualTags(const std::set< TagID > &tags)
Form multiple tag-associated residual vectors for all the given tags.

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

◆ computeResidualTags()

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

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

Definition at line 799 of file NonlinearSystemBase.C.

800{
801 parallel_object_only();
802
803 TIME_SECTION("nl::computeResidualTags", 5);
804
807
808 bool required_residual = tags.find(residualVectorTag()) == tags.end() ? false : true;
809
811
812 // not suppose to do anythin on matrix
814
816
817 for (const auto & numeric_vec : _vecs_to_zero_for_residual)
818 if (hasVector(numeric_vec))
819 {
820 NumericVector<Number> & vec = getVector(numeric_vec);
821 vec.close();
822 vec.zero();
823 }
824
825 try
826 {
827 zeroTaggedVectors(tags);
829 closeTaggedVectors(tags);
830
831 if (required_residual)
832 {
833 auto & residual = getVector(residualVectorTag());
834 if (!_time_integrators.empty())
835 {
836 for (auto & ti : _time_integrators)
837 ti->postResidual(residual);
838 }
839 else
840 residual += *_Re_non_time;
841 residual.close();
842 }
844 // We don't want to do nodal bcs or anything else
845 return;
846
848 closeTaggedVectors(tags);
849
850 // If we are debugging residuals we need one more assignment to have the ghosted copy up to
851 // date
852 if (_need_residual_ghosted && _debugging_residuals && required_residual)
853 {
854 auto & residual = getVector(residualVectorTag());
855
856 *_residual_ghosted = residual;
858 }
859 // Need to close and update the aux system in case residuals were saved to it.
862 if (hasSaveIn())
864 }
865 catch (MooseException & e)
866 {
867 // The buck stops here, we have already handled the exception by
868 // calling stopSolve(), it is now up to PETSc to return a
869 // "diverged" reason during the next solve.
870 }
871
872 // not supposed to do anything on matrix
874
876}
void setCurrentlyComputingResidual(bool currently_computing_residual) final
Set whether or not the problem is in the process of computing the residual.
bool _debugging_residuals
true if debugging residuals
unsigned int _n_residual_evaluations
Total number of residual evaluations that have been performed.
std::vector< std::string > _vecs_to_zero_for_residual
vectors that will be zeroed before a residual computation
void computeResidualInternal(const std::set< TagID > &tags)
Compute the residual for a given tag.
bool hasSaveIn() const
Weather or not the nonlinear system has save-ins.
virtual void deactivateAllMatrixTags()
Make matrices inactive.

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

◆ computeScalarKernelsJacobians()

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

Definition at line 2917 of file NonlinearSystemBase.C.

2918{
2919 MooseObjectWarehouse<ScalarKernelBase> * scalar_kernel_warehouse;
2920
2921 if (!tags.size() || tags.size() == _fe_problem.numMatrixTags())
2922 scalar_kernel_warehouse = &_scalar_kernels;
2923 else if (tags.size() == 1)
2924 scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2925 else
2926 scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagsObjectWarehouse(tags, 0));
2927
2928 // Compute the diagonal block for scalar variables
2929 if (scalar_kernel_warehouse->hasActiveObjects())
2930 {
2931 const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
2932
2933 _fe_problem.reinitScalars(/*tid=*/0);
2934
2936
2937 bool have_scalar_contributions = false;
2938 for (const auto & kernel : scalars)
2939 {
2940 if (!kernel->computesJacobian())
2941 continue;
2942
2943 kernel->reinit();
2944 const std::vector<dof_id_type> & dof_indices = kernel->variable().dofIndices();
2945 const DofMap & dof_map = kernel->variable().dofMap();
2946 const dof_id_type first_dof = dof_map.first_dof();
2947 const dof_id_type end_dof = dof_map.end_dof();
2948 for (dof_id_type dof : dof_indices)
2949 {
2950 if (dof >= first_dof && dof < end_dof)
2951 {
2952 kernel->computeJacobian();
2953 _fe_problem.addJacobianOffDiagScalar(kernel->variable().number());
2954 have_scalar_contributions = true;
2955 break;
2956 }
2957 }
2958 }
2959
2960 if (have_scalar_contributions)
2962 }
2963}
virtual void addJacobianScalar(const THREAD_ID tid=0)
virtual void reinitOffDiagScalars(const THREAD_ID tid) override
virtual void addJacobianOffDiagScalar(unsigned int ivar, const THREAD_ID tid=0)

Referenced by NonlinearSystemBase::computeJacobianInternal().

◆ computeScaling()

bool NonlinearSystemBase::computeScaling ( )
inherited

Method used to obtain scaling factors for variables.

Returns
whether this method ran without exceptions

Definition at line 4074 of file NonlinearSystemBase.C.

4075{
4077 return true;
4078
4079 _console << "\nPerforming automatic scaling calculation\n" << std::endl;
4080
4081 TIME_SECTION("computeScaling", 3, "Computing Automatic Scaling");
4082
4083 // It's funny but we need to assemble our vector of scaling factors here otherwise we will be
4084 // applying scaling factors of 0 during Assembly of our scaling Jacobian
4086
4087 // container for repeated access of element global dof indices
4088 std::vector<dof_id_type> dof_indices;
4089
4092
4093 std::vector<Real> inverse_scaling_factors(_num_scaling_groups, 0);
4094 std::vector<Real> resid_inverse_scaling_factors(_num_scaling_groups, 0);
4095 std::vector<Real> jac_inverse_scaling_factors(_num_scaling_groups, 0);
4096 auto & dof_map = dofMap();
4097
4098 // what types of scaling do we want?
4099 bool jac_scaling = _resid_vs_jac_scaling_param < 1. - TOLERANCE;
4100 bool resid_scaling = _resid_vs_jac_scaling_param > TOLERANCE;
4101
4102 const NumericVector<Number> & scaling_residual = RHS();
4103
4104 if (jac_scaling)
4105 {
4106 // if (!_auto_scaling_initd)
4107 // We need to reinit this when the number of dofs changes
4108 // but there is no good way to track that
4109 // In theory, it is the job of libmesh system to track this,
4110 // but this special matrix is not owned by libMesh system
4111 // Let us reinit eveytime since it is not expensive
4112 {
4113 auto init_vector = NumericVector<Number>::build(this->comm());
4114 init_vector->init(system().n_dofs(), system().n_local_dofs(), /*fast=*/false, PARALLEL);
4115
4116 _scaling_matrix->clear();
4117 _scaling_matrix->init(*init_vector);
4118 }
4119
4121 // Dispatch to derived classes to ensure that we use the correct matrix tag
4124 }
4125
4126 if (resid_scaling)
4127 {
4130 // Dispatch to derived classes to ensure that we use the correct vector tag
4134 }
4135
4136 // Did something bad happen during residual/Jacobian scaling computation?
4138 return false;
4139
4140 auto examine_dof_indices = [this,
4141 jac_scaling,
4142 resid_scaling,
4143 &dof_map,
4144 &jac_inverse_scaling_factors,
4145 &resid_inverse_scaling_factors,
4146 &scaling_residual](const auto & dof_indices, const auto var_number)
4147 {
4148 for (auto dof_index : dof_indices)
4149 if (dof_map.local_index(dof_index))
4150 {
4151 if (jac_scaling)
4152 {
4153 // For now we will use the diagonal for determining scaling
4154 auto mat_value = (*_scaling_matrix)(dof_index, dof_index);
4155 auto & factor = jac_inverse_scaling_factors[_var_to_group_var[var_number]];
4156 factor = std::max(factor, std::abs(mat_value));
4157 }
4158 if (resid_scaling)
4159 {
4160 auto vec_value = scaling_residual(dof_index);
4161 auto & factor = resid_inverse_scaling_factors[_var_to_group_var[var_number]];
4162 factor = std::max(factor, std::abs(vec_value));
4163 }
4164 }
4165 };
4166
4167 // Compute our scaling factors for the spatial field variables
4168 for (const auto & elem : _fe_problem.getCurrentAlgebraicElementRange())
4169 for (const auto i : make_range(system().n_vars()))
4170 if (_variable_autoscaled[i] && system().variable_type(i).family != SCALAR)
4171 {
4172 dof_map.dof_indices(elem, dof_indices, i);
4173 examine_dof_indices(dof_indices, i);
4174 }
4175
4176 for (const auto i : make_range(system().n_vars()))
4177 if (_variable_autoscaled[i] && system().variable_type(i).family == SCALAR)
4178 {
4179 dof_map.SCALAR_dof_indices(dof_indices, i);
4180 examine_dof_indices(dof_indices, i);
4181 }
4182
4183 if (resid_scaling)
4184 _communicator.max(resid_inverse_scaling_factors);
4185 if (jac_scaling)
4186 _communicator.max(jac_inverse_scaling_factors);
4187
4188 if (jac_scaling && resid_scaling)
4189 for (MooseIndex(inverse_scaling_factors) i = 0; i < inverse_scaling_factors.size(); ++i)
4190 {
4191 // Be careful not to take log(0)
4192 if (!resid_inverse_scaling_factors[i])
4193 {
4194 if (!jac_inverse_scaling_factors[i])
4195 inverse_scaling_factors[i] = 1;
4196 else
4197 inverse_scaling_factors[i] = jac_inverse_scaling_factors[i];
4198 }
4199 else if (!jac_inverse_scaling_factors[i])
4200 // We know the resid is not zero
4201 inverse_scaling_factors[i] = resid_inverse_scaling_factors[i];
4202 else
4203 inverse_scaling_factors[i] =
4204 std::exp(_resid_vs_jac_scaling_param * std::log(resid_inverse_scaling_factors[i]) +
4205 (1 - _resid_vs_jac_scaling_param) * std::log(jac_inverse_scaling_factors[i]));
4206 }
4207 else if (jac_scaling)
4208 inverse_scaling_factors = jac_inverse_scaling_factors;
4209 else if (resid_scaling)
4210 inverse_scaling_factors = resid_inverse_scaling_factors;
4211 else
4212 mooseError("We shouldn't be calling this routine if we're not performing any scaling");
4213
4214 // We have to make sure that our scaling values are not zero
4215 for (auto & scaling_factor : inverse_scaling_factors)
4216 if (scaling_factor == 0)
4217 scaling_factor = 1;
4218
4219 // Now flatten the group scaling factors to the individual variable scaling factors
4220 std::vector<Real> flattened_inverse_scaling_factors(system().n_vars());
4221 for (const auto i : index_range(flattened_inverse_scaling_factors))
4222 flattened_inverse_scaling_factors[i] = inverse_scaling_factors[_var_to_group_var[i]];
4223
4224 // Now set the scaling factors for the variables
4225 applyScalingFactors(flattened_inverse_scaling_factors);
4227 displaced_problem->systemBaseNonlinear(number()).applyScalingFactors(
4228 flattened_inverse_scaling_factors);
4229
4230 _computed_scaling = true;
4231 return true;
4232}
bool getFailNextNonlinearConvergenceCheck() const
Whether it will skip further residual evaluations and fail the next nonlinear convergence check(s)
std::size_t _num_scaling_groups
The number of scaling groups.
virtual void computeScalingJacobian()=0
Compute a "Jacobian" for automatic scaling purposes.
void assembleScalingVector()
Assemble the numeric vector of scaling factors such that it can be used during assembly of the system...
bool _auto_scaling_initd
Whether we've initialized the automatic scaling data structures.
std::vector< bool > _variable_autoscaled
Container to hold flag if variable is to participate in autoscaling.
virtual NumericVector< Number > & RHS()=0
bool _compute_scaling_once
Whether the scaling factors should only be computed once at the beginning of the simulation through a...
void setupScalingData()
Setup group scaling containers.
virtual void computeScalingResidual()=0
Compute a "residual" for automatic scaling purposes.
std::unordered_map< unsigned int, unsigned int > _var_to_group_var
A map from variable index to group variable index and it's associated (inverse) scaling factor.
std::unique_ptr< libMesh::DiagonalMatrix< Number > > _scaling_matrix
A diagonal matrix used for computing scaling.
virtual libMesh::System & system() override
Get the reference to the libMesh system.
void applyScalingFactors(const std::vector< Real > &inverse_scaling_factors)
Applies scaling factors to the system's variables.
void max(const T &r, T &o, Request &req) const
const Parallel::Communicator & comm() const
auto index_range(const T &sizable)

Referenced by NonlinearSystemBase::preSolve().

◆ computeScalingJacobian()

void NonlinearSystem::computeScalingJacobian ( )
overrideprotectedvirtualinherited

Compute a "Jacobian" for automatic scaling purposes.

Implements NonlinearSystemBase.

Definition at line 358 of file NonlinearSystem.C.

359{
361}
virtual void computeJacobianSys(libMesh::NonlinearImplicitSystem &sys, const NumericVector< libMesh::Number > &soln, libMesh::SparseMatrix< libMesh::Number > &jacobian)
Form a Jacobian matrix.
libMesh::NonlinearImplicitSystem & _nl_implicit_sys
const NumericVector< Number > * _current_solution
solution vector from solver

◆ computeScalingOnce() [1/2]

bool NonlinearSystemBase::computeScalingOnce ( ) const
inlineinherited

Definition at line 720 of file NonlinearSystemBase.h.

720{ return _compute_scaling_once; }

◆ computeScalingOnce() [2/2]

void NonlinearSystemBase::computeScalingOnce ( bool  compute_scaling_once)
inlineinherited

Definition at line 721 of file NonlinearSystemBase.h.

722 {
723 _compute_scaling_once = compute_scaling_once;
724 }

◆ computeScalingResidual()

void NonlinearSystem::computeScalingResidual ( )
overrideprotectedvirtualinherited

Compute a "residual" for automatic scaling purposes.

Implements NonlinearSystemBase.

Definition at line 364 of file NonlinearSystem.C.

365{
367}
virtual void computeResidualSys(libMesh::NonlinearImplicitSystem &sys, const NumericVector< libMesh::Number > &soln, NumericVector< libMesh::Number > &residual)
This function is called by Libmesh to form a residual.
virtual NumericVector< Number > & RHS() override

◆ computeVariables()

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

Definition at line 899 of file SystemBase.h.

899{}

◆ 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 98 of file NonlinearSystemBase.h.

◆ computingScalingJacobian()

bool SystemBase::computingScalingJacobian ( ) const
inherited

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

Definition at line 1586 of file SystemBase.C.

1587{
1589}
virtual bool computingScalingJacobian() const =0
Getter for whether we're computing the scaling jacobian.

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

◆ 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 2491 of file NonlinearSystemBase.C.

2493{
2494 if (!hasMatrix(systemMatrixTag()))
2495 mooseError("A system matrix is required");
2496
2497 auto & jacobian = getMatrix(systemMatrixTag());
2498
2500 LibmeshPetscCall(MatSetOption(cast_ref<PetscMatrix<Number> &>(jacobian).mat(),
2501 MAT_NEW_NONZERO_ALLOCATION_ERR,
2502 PETSC_FALSE));
2504 LibmeshPetscCall(MatSetOption(
2505 cast_ref<PetscMatrix<Number> &>(jacobian).mat(), MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE));
2506
2507 std::vector<numeric_index_type> zero_rows;
2508
2509 if (displaced)
2510 mooseAssert(_fe_problem.getDisplacedProblem(),
2511 "If we're calling this method with displaced = true, then we better well have a "
2512 "displaced problem");
2513 auto & subproblem = displaced ? cast_ref<SubProblem &>(*_fe_problem.getDisplacedProblem())
2515 const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
2516
2517 bool constraints_applied;
2519 constraints_applied = false;
2520 for (const auto & it : penetration_locators)
2521 {
2523 {
2524 // Reset the constraint_applied flag before each new constraint, as they need to be
2525 // assembled separately
2526 constraints_applied = false;
2527 }
2528 PenetrationLocator & pen_loc = *(it.second);
2529
2530 std::vector<dof_id_type> & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
2531
2532 BoundaryID secondary_boundary = pen_loc._secondary_boundary;
2533 BoundaryID primary_boundary = pen_loc._primary_boundary;
2534
2535 zero_rows.clear();
2536 if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, displaced))
2537 {
2538 const auto & constraints =
2539 _constraints.getActiveNodeFaceConstraints(secondary_boundary, displaced);
2540
2541 for (const auto & secondary_node_num : secondary_nodes)
2542 {
2543 Node & secondary_node = _mesh.nodeRef(secondary_node_num);
2544
2545 if (secondary_node.processor_id() == processor_id())
2546 {
2547 if (pen_loc._penetration_info[secondary_node_num])
2548 {
2549 PenetrationInfo & info = *pen_loc._penetration_info[secondary_node_num];
2550
2551 reinitNodeFace(secondary_node, secondary_boundary, info, displaced);
2553
2554 for (const auto & nfc : constraints)
2555 {
2556 if (nfc->isExplicitConstraint())
2557 continue;
2558 // Return if this constraint does not correspond to the primary-secondary pair
2559 // prepared by the outer loops.
2560 // This continue statement is required when, e.g. one secondary surface constrains
2561 // more than one primary surface.
2562 if (nfc->secondaryBoundary() != secondary_boundary ||
2563 nfc->primaryBoundary() != primary_boundary)
2564 continue;
2565
2566 nfc->_jacobian = &jacobian_to_view;
2567
2568 if (nfc->shouldApply())
2569 {
2570 constraints_applied = true;
2571
2572 // Begin the diagonal node-face constraint accumulation phase for neighbor Jacobian
2573 // blocks.
2575
2576 nfc->prepareShapes(nfc->variable().number());
2577 nfc->prepareNeighborShapes(nfc->variable().number());
2578
2579 nfc->computeJacobian();
2580
2581 if (nfc->overwriteSecondaryJacobian())
2582 {
2583 // Add this variable's dof's row to be zeroed
2584 zero_rows.push_back(nfc->variable().nodalDofIndex());
2585 }
2586
2587 std::vector<dof_id_type> secondary_dofs(1, nfc->variable().nodalDofIndex());
2588
2589 // Assume that if the user is overwriting the secondary Jacobian, then they are
2590 // supplying Jacobians that do not correspond to their other physics
2591 // (e.g. Kernels), hence we should not apply a scalingFactor that is normally
2592 // based on the order of their other physics (e.g. Kernels)
2593 Real scaling_factor =
2594 nfc->overwriteSecondaryJacobian() ? 1. : nfc->variable().scalingFactor();
2595
2596 // Cache the jacobian block for the secondary side
2597 nfc->addJacobian(_fe_problem.assembly(0, number()),
2598 nfc->_Kee,
2599 secondary_dofs,
2600 nfc->_connected_dof_indices,
2601 scaling_factor);
2602
2603 // Cache Ken, Kne, Knn
2604 if (nfc->addCouplingEntriesToJacobian())
2605 {
2606 // Make sure we use a proper scaling factor (e.g. don't use an interior scaling
2607 // factor when we're overwriting secondary stuff)
2608 nfc->addJacobian(_fe_problem.assembly(0, number()),
2609 nfc->_Ken,
2610 secondary_dofs,
2611 nfc->primaryVariable().dofIndicesNeighbor(),
2612 scaling_factor);
2613
2614 // Use _connected_dof_indices to get all the correct columns
2615 nfc->addJacobian(_fe_problem.assembly(0, number()),
2616 nfc->_Kne,
2617 nfc->primaryVariable().dofIndicesNeighbor(),
2618 nfc->_connected_dof_indices,
2619 nfc->primaryVariable().scalingFactor());
2620
2621 // We've handled Ken and Kne, finally handle Knn
2623 }
2624
2625 // Do the off-diagonals next
2626 const std::vector<MooseVariableFEBase *> coupled_vars = nfc->getCoupledMooseVars();
2627 for (const auto & jvar : coupled_vars)
2628 {
2629 // Only compute jacobians for nonlinear variables
2630 if (jvar->kind() != Moose::VAR_SOLVER)
2631 continue;
2632
2633 // Only compute Jacobian entries if this coupling is being used by the
2634 // preconditioner
2635 if (nfc->variable().number() == jvar->number() ||
2637 nfc->variable().number(), jvar->number(), this->number()))
2638 continue;
2639
2640 // Begin the off-diagonal node-face constraint accumulation phase for
2641 // element and neighbor Jacobian blocks.
2644
2645 nfc->prepareShapes(nfc->variable().number());
2646 nfc->prepareNeighborShapes(jvar->number());
2647
2648 nfc->computeOffDiagJacobian(jvar->number());
2649
2650 // Cache the jacobian block for the secondary side
2651 nfc->addJacobian(_fe_problem.assembly(0, number()),
2652 nfc->_Kee,
2653 secondary_dofs,
2654 nfc->_connected_dof_indices,
2655 scaling_factor);
2656
2657 // Cache Ken, Kne, Knn
2658 if (nfc->addCouplingEntriesToJacobian())
2659 {
2660 // Make sure we use a proper scaling factor (e.g. don't use an interior scaling
2661 // factor when we're overwriting secondary stuff)
2662 nfc->addJacobian(_fe_problem.assembly(0, number()),
2663 nfc->_Ken,
2664 secondary_dofs,
2665 jvar->dofIndicesNeighbor(),
2666 scaling_factor);
2667
2668 // Use _connected_dof_indices to get all the correct columns
2669 nfc->addJacobian(_fe_problem.assembly(0, number()),
2670 nfc->_Kne,
2671 nfc->variable().dofIndicesNeighbor(),
2672 nfc->_connected_dof_indices,
2673 nfc->variable().scalingFactor());
2674
2675 // We've handled Ken and Kne, finally handle Knn
2677 }
2678 }
2679 }
2680 }
2681 }
2682 }
2683 }
2684 }
2686 {
2687 // See if constraints were applied anywhere
2688 _communicator.max(constraints_applied);
2689
2690 if (constraints_applied)
2691 {
2692 LibmeshPetscCall(MatSetOption(cast_ref<PetscMatrix<Number> &>(jacobian).mat(),
2693 MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2694 PETSC_TRUE));
2695
2696 jacobian.close();
2697 jacobian.zero_rows(zero_rows, 0.0);
2698 jacobian.close();
2700 jacobian.close();
2701 }
2702 }
2703 }
2705 {
2706 // See if constraints were applied anywhere
2707 _communicator.max(constraints_applied);
2708
2709 if (constraints_applied)
2710 {
2711 LibmeshPetscCall(MatSetOption(cast_ref<PetscMatrix<Number> &>(jacobian).mat(),
2712 MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2713 PETSC_TRUE));
2714
2715 jacobian.close();
2716 jacobian.zero_rows(zero_rows, 0.0);
2717 jacobian.close();
2719 jacobian.close();
2720 }
2721 }
2722
2723 THREAD_ID tid = 0;
2724 // go over element-element constraint interface
2725 const auto & element_pair_locators = subproblem.geomSearchData()._element_pair_locators;
2726 for (const auto & it : element_pair_locators)
2727 {
2728 ElementPairLocator & elem_pair_loc = *(it.second);
2729
2730 if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
2731 {
2732 // ElemElemConstraint objects
2733 const auto & element_constraints =
2734 _constraints.getActiveElemElemConstraints(it.first, displaced);
2735
2736 // go over pair elements
2737 const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
2738 elem_pair_loc.getElemPairs();
2739 for (const auto & pr : elem_pairs)
2740 {
2741 const Elem * elem1 = pr.first;
2742 const Elem * elem2 = pr.second;
2743
2744 if (elem1->processor_id() != processor_id())
2745 continue;
2746
2747 const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
2748
2749 // for each element process constraints on the
2750 for (const auto & ec : element_constraints)
2751 {
2753 subproblem.reinitElemPhys(elem1, info._elem1_constraint_q_point, tid);
2755 subproblem.reinitNeighborPhys(elem2, info._elem2_constraint_q_point, tid);
2756
2757 // Begin the element-element constraint accumulation phase for element and neighbor
2758 // Jacobian blocks.
2761
2762 ec->prepareShapes(ec->variable().number());
2763 ec->prepareNeighborShapes(ec->variable().number());
2764
2765 ec->reinit(info);
2766 ec->computeJacobian();
2769 }
2771 }
2772 }
2773 }
2774
2775 // go over NodeElemConstraints
2776 std::set<dof_id_type> unique_secondary_node_ids;
2777 constraints_applied = false;
2778 for (const auto & secondary_id : _mesh.meshSubdomains())
2779 {
2780 for (const auto & primary_id : _mesh.meshSubdomains())
2781 {
2782 if (_constraints.hasActiveNodeElemConstraints(secondary_id, primary_id, displaced))
2783 {
2784 const auto & constraints =
2785 _constraints.getActiveNodeElemConstraints(secondary_id, primary_id, displaced);
2786
2787 // get unique set of ids of all nodes on current block
2788 unique_secondary_node_ids.clear();
2789 const MeshBase & meshhelper = _mesh.getMesh();
2790 for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
2791 meshhelper.active_subdomain_elements_end(secondary_id)))
2792 {
2793 for (auto & n : elem->node_ref_range())
2794 unique_secondary_node_ids.insert(n.id());
2795 }
2796
2797 for (auto secondary_node_id : unique_secondary_node_ids)
2798 {
2799 const Node & secondary_node = _mesh.nodeRef(secondary_node_id);
2800 // check if secondary node is on current processor
2801 if (secondary_node.processor_id() == processor_id())
2802 {
2803 // This reinits the variables that exist on the secondary node
2804 _fe_problem.reinitNodeFace(&secondary_node, secondary_id, 0);
2805
2807
2808 for (const auto & nec : constraints)
2809 {
2810 if (nec->shouldApply())
2811 {
2812 constraints_applied = true;
2813
2814 // Begin the diagonal node-element constraint accumulation phase for
2815 // element and neighbor Jacobian blocks.
2818
2819 nec->_jacobian = &jacobian_to_view;
2820 nec->prepareShapes(nec->variable().number());
2821 nec->prepareNeighborShapes(nec->variable().number());
2822
2823 nec->computeJacobian();
2824
2825 if (nec->overwriteSecondaryJacobian())
2826 {
2827 // Add this variable's dof's row to be zeroed
2828 zero_rows.push_back(nec->variable().nodalDofIndex());
2829 }
2830
2831 std::vector<dof_id_type> secondary_dofs(1, nec->variable().nodalDofIndex());
2832
2833 // Cache the jacobian block for the secondary side
2834 nec->addJacobian(_fe_problem.assembly(0, number()),
2835 nec->_Kee,
2836 secondary_dofs,
2837 nec->_connected_dof_indices,
2838 nec->variable().scalingFactor());
2839
2840 // Cache the jacobian block for the primary side
2841 nec->addJacobian(_fe_problem.assembly(0, number()),
2842 nec->_Kne,
2843 nec->primaryVariable().dofIndicesNeighbor(),
2844 nec->_connected_dof_indices,
2845 nec->primaryVariable().scalingFactor());
2846
2849
2850 // Do the off-diagonals next
2851 const std::vector<MooseVariableFEBase *> coupled_vars = nec->getCoupledMooseVars();
2852 for (const auto & jvar : coupled_vars)
2853 {
2854 // Only compute jacobians for nonlinear variables
2855 if (jvar->kind() != Moose::VAR_SOLVER)
2856 continue;
2857
2858 // Only compute Jacobian entries if this coupling is being used by the
2859 // preconditioner
2860 if (nec->variable().number() == jvar->number() ||
2862 nec->variable().number(), jvar->number(), this->number()))
2863 continue;
2864
2865 // Begin the off-diagonal node-element constraint accumulation phase for
2866 // element and neighbor Jacobian blocks.
2869
2870 nec->prepareShapes(nec->variable().number());
2871 nec->prepareNeighborShapes(jvar->number());
2872
2873 nec->computeOffDiagJacobian(jvar->number());
2874
2875 // Cache the jacobian block for the secondary side
2876 nec->addJacobian(_fe_problem.assembly(0, number()),
2877 nec->_Kee,
2878 secondary_dofs,
2879 nec->_connected_dof_indices,
2880 nec->variable().scalingFactor());
2881
2882 // Cache the jacobian block for the primary side
2883 nec->addJacobian(_fe_problem.assembly(0, number()),
2884 nec->_Kne,
2885 nec->variable().dofIndicesNeighbor(),
2886 nec->_connected_dof_indices,
2887 nec->variable().scalingFactor());
2888
2891 }
2892 }
2893 }
2894 }
2895 }
2896 }
2897 }
2898 }
2899 // See if constraints were applied anywhere
2900 _communicator.max(constraints_applied);
2901
2902 if (constraints_applied)
2903 {
2904 LibmeshPetscCall(MatSetOption(cast_ref<PetscMatrix<Number> &>(jacobian).mat(),
2905 MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2906 PETSC_TRUE));
2907
2908 jacobian.close();
2909 jacobian.zero_rows(zero_rows, 0.0);
2910 jacobian.close();
2912 jacobian.close();
2913 }
2914}
const std::vector< std::shared_ptr< ElemElemConstraint > > & getActiveElemElemConstraints(InterfaceID interface_id, bool displaced) const
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
bool hasActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
bool hasActiveElemElemConstraints(const InterfaceID interface_id, bool displaced) const
const std::vector< std::shared_ptr< NodeElemConstraintBase > > & getActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
This is the ElementPairInfo class.
This is the ElementPairLocator class.
const ElementPairList & getElemPairs() const
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem * > elem_pair) const
bool areCoupled(const unsigned int ivar, const unsigned int jvar, const unsigned int nl_sys_num) const
virtual void cacheJacobianNeighbor(const THREAD_ID tid) override
virtual void cacheJacobian(const THREAD_ID tid) override
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
virtual void prepareAssembly(const THREAD_ID tid) override
virtual void prepareAssemblyNeighbor(const THREAD_ID tid)
Begin a fresh neighbor accumulation phase by sizing and zeroing the neighbor blocks.
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override
std::map< BoundaryID, std::shared_ptr< ElementPairLocator > > _element_pair_locators
std::map< std::pair< BoundaryID, BoundaryID >, PenetrationLocator * > _penetration_locators
virtual const Node & nodeRef(const dof_id_type i) const
Definition MooseMesh.C:846
std::vector< dof_id_type > _secondary_nodes
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.
Data structure used to hold penetration information.
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
NearestNodeLocator & _nearest_node
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid)=0
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
virtual GeometricSearchData & geomSearchData()=0
SubProblem & subproblem()
Definition SystemBase.h:102
MPI_Info info
Tnew cast_ref(Told &oldvar)

Referenced by NonlinearSystemBase::computeJacobianInternal().

◆ 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 1334 of file NonlinearSystemBase.C.

1335{
1336 // Make sure the residual is in a good state
1337 residual.close();
1338
1339 if (displaced)
1340 mooseAssert(_fe_problem.getDisplacedProblem(),
1341 "If we're calling this method with displaced = true, then we better well have a "
1342 "displaced problem");
1343 auto & subproblem = displaced ? cast_ref<SubProblem &>(*_fe_problem.getDisplacedProblem())
1345 const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
1346
1347 bool constraints_applied;
1348 bool residual_has_inserted_values = false;
1350 constraints_applied = false;
1351 for (const auto & it : penetration_locators)
1352 {
1354 {
1355 // Reset the constraint_applied flag before each new constraint, as they need to be
1356 // assembled separately
1357 constraints_applied = false;
1358 }
1359 PenetrationLocator & pen_loc = *(it.second);
1360
1361 std::vector<dof_id_type> & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
1362
1363 BoundaryID secondary_boundary = pen_loc._secondary_boundary;
1364 BoundaryID primary_boundary = pen_loc._primary_boundary;
1365
1366 bool has_writable_variables(false);
1367
1368 if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, displaced))
1369 {
1370 const auto & constraints =
1371 _constraints.getActiveNodeFaceConstraints(secondary_boundary, displaced);
1372
1373 for (unsigned int i = 0; i < secondary_nodes.size(); i++)
1374 {
1375 dof_id_type secondary_node_num = secondary_nodes[i];
1376 Node & secondary_node = _mesh.nodeRef(secondary_node_num);
1377
1378 if (secondary_node.processor_id() == processor_id())
1379 {
1380 if (pen_loc._penetration_info[secondary_node_num])
1381 {
1382 PenetrationInfo & info = *pen_loc._penetration_info[secondary_node_num];
1383
1384 reinitNodeFace(secondary_node, secondary_boundary, info, displaced);
1385
1386 for (const auto & nfc : constraints)
1387 {
1388 // Return if this constraint does not correspond to the primary-secondary pair
1389 // prepared by the outer loops.
1390 // This continue statement is required when, e.g. one secondary surface constrains
1391 // more than one primary surface.
1392 if (nfc->secondaryBoundary() != secondary_boundary ||
1393 nfc->primaryBoundary() != primary_boundary)
1394 continue;
1395
1396 if (nfc->shouldApply())
1397 {
1398 constraints_applied = true;
1399 nfc->computeResidual();
1400
1401 if (nfc->overwriteSecondaryResidual())
1402 {
1403 // The below will actually overwrite the residual for every single dof that
1404 // lives on the node. We definitely don't want to do that!
1405 // _fe_problem.setResidual(residual, 0);
1406
1407 const auto & secondary_var = nfc->variable();
1408 const auto & secondary_dofs = secondary_var.dofIndices();
1409 mooseAssert(secondary_dofs.size() == secondary_var.count(),
1410 "We are on a node so there should only be one dof per variable (for "
1411 "an ArrayVariable we should have a number of dofs equal to the "
1412 "number of components");
1413
1414 // Assume that if the user is overwriting the secondary residual, then they are
1415 // supplying residuals that do not correspond to their other physics
1416 // (e.g. Kernels), hence we should not apply a scalingFactor that is normally
1417 // based on the order of their other physics (e.g. Kernels)
1418 std::vector<Number> values = {nfc->secondaryResidual()};
1419 residual.insert(values, secondary_dofs);
1420 residual_has_inserted_values = true;
1421 }
1422 else
1425 }
1426 if (nfc->hasWritableCoupledVariables())
1427 {
1428 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1429 has_writable_variables = true;
1430 for (auto * var : nfc->getWritableCoupledVariables())
1431 {
1432 if (var->isNodalDefined())
1433 var->insert(_fe_problem.getAuxiliarySystem().solution());
1434 }
1435 }
1436 }
1437 }
1438 }
1439 }
1440 }
1441 _communicator.max(has_writable_variables);
1442
1443 if (has_writable_variables)
1444 {
1445 // Explicit contact dynamic constraints write to auxiliary variables and update the old
1446 // displacement solution on the constraint boundaries. Close solutions and update system
1447 // accordingly.
1450 solutionOld().close();
1451 }
1452
1454 {
1455 // Make sure that secondary contribution to primary are assembled, and ghosts have been
1456 // exchanged, as current primaries might become secondaries on next iteration and will need to
1457 // contribute their former secondaries' contributions to the future primaries. See if
1458 // constraints were applied anywhere
1459 _communicator.max(constraints_applied);
1460
1461 if (constraints_applied)
1462 {
1463 // If any of the above constraints inserted values in the residual, it needs to be
1464 // assembled before adding the cached residuals below.
1465 _communicator.max(residual_has_inserted_values);
1466 if (residual_has_inserted_values)
1467 {
1468 residual.close();
1469 residual_has_inserted_values = false;
1470 }
1472 residual.close();
1473
1475 *_residual_ghosted = residual;
1476 }
1477 }
1478 }
1480 {
1481 _communicator.max(constraints_applied);
1482
1483 if (constraints_applied)
1484 {
1485 // If any of the above constraints inserted values in the residual, it needs to be assembled
1486 // before adding the cached residuals below.
1487 _communicator.max(residual_has_inserted_values);
1488 if (residual_has_inserted_values)
1489 residual.close();
1490
1492 residual.close();
1493
1495 *_residual_ghosted = residual;
1496 }
1497 }
1498
1499 // go over element-element constraint interface
1500 THREAD_ID tid = 0;
1501 const auto & element_pair_locators = subproblem.geomSearchData()._element_pair_locators;
1502 for (const auto & it : element_pair_locators)
1503 {
1504 ElementPairLocator & elem_pair_loc = *(it.second);
1505
1506 if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
1507 {
1508 // ElemElemConstraint objects
1509 const auto & element_constraints =
1510 _constraints.getActiveElemElemConstraints(it.first, displaced);
1511
1512 // go over pair elements
1513 const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
1514 elem_pair_loc.getElemPairs();
1515 for (const auto & pr : elem_pairs)
1516 {
1517 const Elem * elem1 = pr.first;
1518 const Elem * elem2 = pr.second;
1519
1520 if (elem1->processor_id() != processor_id())
1521 continue;
1522
1523 const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
1524
1525 // for each element process constraints on the
1526 for (const auto & ec : element_constraints)
1527 {
1529 subproblem.reinitElemPhys(elem1, info._elem1_constraint_q_point, tid);
1531 subproblem.reinitNeighborPhys(elem2, info._elem2_constraint_q_point, tid);
1532
1533 ec->prepareShapes(ec->variable().number());
1534 ec->prepareNeighborShapes(ec->variable().number());
1535
1536 ec->reinit(info);
1537 ec->computeResidual();
1540 }
1542 }
1543 }
1544 }
1545
1546 // go over NodeElemConstraints
1547 std::set<dof_id_type> unique_secondary_node_ids;
1548
1549 constraints_applied = false;
1550 residual_has_inserted_values = false;
1551 bool has_writable_variables = false;
1552 for (const auto & secondary_id : _mesh.meshSubdomains())
1553 {
1554 for (const auto & primary_id : _mesh.meshSubdomains())
1555 {
1556 if (_constraints.hasActiveNodeElemConstraints(secondary_id, primary_id, displaced))
1557 {
1558 const auto & constraints =
1559 _constraints.getActiveNodeElemConstraints(secondary_id, primary_id, displaced);
1560
1561 // get unique set of ids of all nodes on current block
1562 unique_secondary_node_ids.clear();
1563 const MeshBase & meshhelper = _mesh.getMesh();
1564 for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
1565 meshhelper.active_subdomain_elements_end(secondary_id)))
1566 {
1567 for (auto & n : elem->node_ref_range())
1568 unique_secondary_node_ids.insert(n.id());
1569 }
1570
1571 for (auto secondary_node_id : unique_secondary_node_ids)
1572 {
1573 Node & secondary_node = _mesh.nodeRef(secondary_node_id);
1574 // check if secondary node is on current processor
1575 if (secondary_node.processor_id() == processor_id())
1576 {
1577 // This reinits the variables that exist on the secondary node
1578 _fe_problem.reinitNodeFace(&secondary_node, secondary_id, 0);
1579
1580 // This will set aside residual and jacobian space for the variables that have dofs
1581 // on the secondary node
1583
1584 for (const auto & nec : constraints)
1585 {
1586 if (nec->shouldApply())
1587 {
1588 constraints_applied = true;
1589 nec->computeResidual();
1590
1591 if (nec->overwriteSecondaryResidual())
1592 {
1593 _fe_problem.setResidual(residual, 0);
1594 residual_has_inserted_values = true;
1595 }
1596 else
1599 }
1600 if (nec->hasWritableCoupledVariables())
1601 {
1602 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1603 has_writable_variables = true;
1604 for (auto * var : nec->getWritableCoupledVariables())
1605 {
1606 if (var->isNodalDefined())
1607 var->insert(_fe_problem.getAuxiliarySystem().solution());
1608 }
1609 }
1610 }
1612 }
1613 }
1614 }
1615 }
1616 }
1617 _communicator.max(constraints_applied);
1618
1619 if (constraints_applied)
1620 {
1621 // If any of the above constraints inserted values in the residual, it needs to be assembled
1622 // before adding the cached residuals below.
1623 _communicator.max(residual_has_inserted_values);
1624 if (residual_has_inserted_values)
1625 residual.close();
1626
1628 residual.close();
1629
1631 *_residual_ghosted = residual;
1632 }
1633 _communicator.max(has_writable_variables);
1634
1635 if (has_writable_variables)
1636 {
1637 // Explicit contact dynamic constraints write to auxiliary variables and update the old
1638 // displacement solution on the constraint boundaries. Close solutions and update system
1639 // accordingly.
1642 solutionOld().close();
1643 }
1644
1645 // We may have additional tagged vectors that also need to be accumulated
1647}
std::array< Real, 2 > values
Definition MortarUtils.C:52
virtual libMesh::System & system() override
Get the reference to the libMesh system.
virtual void cacheResidual(const THREAD_ID tid) override
virtual void setResidual(NumericVector< libMesh::Number > &residual, const THREAD_ID tid) override
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 cacheResidualNeighbor(const THREAD_ID tid) override
virtual void insert(const T *v, const std::vector< numeric_index_type > &dof_indices)
virtual void update()
spin_mutex spin_mtx

Referenced by NonlinearSystemBase::computeResidualInternal().

◆ containsEigenKernel()

bool MooseEigenSystem::containsEigenKernel ( ) const

Weather or not the system contains eigen kernels.

Definition at line 253 of file MooseEigenSystem.C.

254{
255 return _eigen_kernel_counter > 0;
256}

Referenced by EigenExecutionerBase::checkIntegrity().

◆ containsTimeKernel()

bool NonlinearSystemBase::containsTimeKernel ( )
overridevirtualinherited

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

Implements SolverSystem.

Definition at line 3892 of file NonlinearSystemBase.C.

3893{
3894 auto & time_kernels = _kernels.getVectorTagObjectWarehouse(timeVectorTag(), 0);
3895
3896 return time_kernels.hasActiveObjects();
3897}
TagID timeVectorTag() const override
Ideally, we should not need this API.

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

◆ converged()

bool NonlinearSystem::converged ( )
overridevirtualinherited

Returns the convergence state.

Returns
true if converged, otherwise false

Implements SolverSystem.

Definition at line 335 of file NonlinearSystem.C.

336{
338 return false;
339 // When not computing the residual (for example at the beginning of a time step),
340 // we may be in the process of counting invalid solution warnings, so the call to
341 // acceptInvalidSolution() would fail due to lack of parallel synchronization
342 // TODO: think of a better solution
344 {
345 mooseWarning("The solution is not converged due to the solution being invalid.");
346 return false;
347 }
348 return _nl_implicit_sys.nonlinear_solver->converged;
349}
virtual bool hasException()
Whether or not an exception has occurred.
bool hasSynced() const
Whether the solution invalidity has synchronized iteration counts across MPI processes.
std::unique_ptr< NonlinearSolver< Number > > nonlinear_solver

◆ convergence()

Convergence & NonlinearSystemBase::convergence ( )
inherited

Retrieves the associated Convergence object.

Definition at line 4326 of file NonlinearSystemBase.C.

4327{
4329}
virtual Convergence & getConvergence(const std::string &name, const THREAD_ID tid=0) const
Gets a Convergence object.
ConvergenceName _convergence_name
Associated convergence object name.

Referenced by EigenExecutionerBase::getEigenSystemConvergence(), Moose::PetscSupport::petscNonlinearConverged(), and NonlinearSystemBase::preSolve().

◆ copyAdditionalStateBackwards()

virtual void SystemBase::copyAdditionalStateBackwards ( Moose::SolutionIterationType  ,
bool   
)
inlineprotectedvirtualinherited

Copy system-owned state not represented by solution vectors.

The first argument selects the solution history being advanced. The second indicates that state 0 must not overwrite state 1 while deeper states still shift; additional state must honor this to remain aligned with the solution history. Default implementation does nothing.

Reimplemented in AuxiliarySystem, and LinearSystem.

Definition at line 1015 of file SystemBase.h.

1015{}

Referenced by SystemBase::advanceStateHistory().

◆ copyOldSolutions()

void SystemBase::copyOldSolutions ( )
inherited

Copy the solution back in time (older -> old, etc).

Shifts the solutions backwards in time.

Definition at line 1320 of file SystemBase.C.

◆ copyPreviousSolutions()

void SystemBase::copyPreviousSolutions ( const Moose::SolutionIterationType  iteration_type)
inherited

Copy a specific type of solution back in time (current -> old -> older, etc).

Definition at line 1271 of file SystemBase.C.

1272{
1273 // Normally copy through old (index 1). For Time, optionally stop at older
1274 // and leave old unchanged.
1275 const bool skip_old =
1277
1278 const auto num_states = getNumSolutionStates(iteration_type);
1279 if (num_states > 1)
1280 {
1281 const std::size_t stop = skip_old ? 1 : 0;
1282 for (std::size_t i = num_states - 1; i > stop; --i)
1283 solutionState(i, iteration_type) = solutionState(i - 1, iteration_type);
1284 }
1285
1286 // Custom logic for changing state based on iteration type
1287 switch (iteration_type)
1288 {
1291 if (solutionUDotOld())
1293 if (solutionUDotDotOld())
1295 break;
1299 break;
1303 break;
1304 }
1305}
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
virtual NumericVector< Number > * solutionUDot()
Definition SystemBase.h:289
virtual NumericVector< Number > * solutionUDotOld()
Definition SystemBase.h:291
std::size_t getNumSolutionStates(const Moose::SolutionIterationType iteration_type) const
Get the number of solution states (0 = current, 1 = current + old, ...) for the given iteration type.
virtual const NumericVector< Number > * solutionPreviousNewton() const
virtual NumericVector< Number > * solutionUDotDotOld()
Definition SystemBase.h:292
virtual NumericVector< Number > * solutionUDotDot()
Definition SystemBase.h:290
void stop(const char *file, int line, const char *date, const char *time)

Referenced by SystemBase::advanceStateHistory(), SystemBase::copyOldSolutions(), and SystemBase::copySolutionsBackwards().

◆ copySolutionsBackwards()

void SystemBase::copySolutionsBackwards ( )
virtualinherited

Copy current solution into old and older.

Definition at line 1255 of file SystemBase.C.

◆ copyStateHistoryBackwards()

void SystemBase::copyStateHistoryBackwards ( )
inherited

Copy solution vectors and additional system-owned state into older states.

Definition at line 1263 of file SystemBase.C.

1264{
1265 system().update();
1268}
void advanceStateHistory(Moose::SolutionIterationType iteration_type)
Advance solution vectors and additional system-owned state together.

◆ copyTimeIntegrators()

void SystemBase::copyTimeIntegrators ( const SystemBase &  other_sys)
inherited

Copy time integrators from another system.

Definition at line 1688 of file SystemBase.C.

1689{
1691}

◆ copyVars()

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

Definition at line 1180 of file SystemBase.C.

1181{
1182 int n_steps = io.get_num_time_steps();
1183
1184 bool did_copy = false;
1185 for (const auto & vci : _var_to_copy)
1186 {
1187 int timestep = -1;
1188
1189 if (vci._timestep == "LATEST")
1190 // Use the last time step in the file from which to retrieve the solution
1191 timestep = n_steps;
1192 else
1193 {
1194 timestep = MooseUtils::convert<int>(vci._timestep);
1195 if (timestep > n_steps)
1196 mooseError("Invalid value passed as \"initial_from_file_timestep\". Expected \"LATEST\" or "
1197 "a valid integer between 1 and ",
1198 n_steps,
1199 " inclusive, received ",
1200 vci._timestep);
1201 }
1202
1203 did_copy = true;
1204
1205 if (hasVariable(vci._dest_name))
1206 {
1207 const auto & var = getVariable(0, vci._dest_name);
1208 if (var.isArray())
1209 {
1210 const auto & array_var = getFieldVariable<RealEigenVector>(0, vci._dest_name);
1211 for (MooseIndex(var.count()) i = 0; i < var.count(); ++i)
1212 {
1213 const auto & exodus_var = var.arrayVariableComponent(i);
1214 const auto & system_var = array_var.componentName(i);
1215 if (var.isNodal())
1216 io.copy_nodal_solution(system(), exodus_var, system_var, timestep);
1217 else
1218 io.copy_elemental_solution(system(), exodus_var, system_var, timestep);
1219 }
1220 }
1221 else
1222 {
1223 if (var.isNodal())
1224 io.copy_nodal_solution(system(), vci._dest_name, vci._source_name, timestep);
1225 else
1226 io.copy_elemental_solution(system(), vci._dest_name, vci._source_name, timestep);
1227 }
1228 }
1229 else if (hasScalarVariable(vci._dest_name))
1230 io.copy_scalar_solution(system(), {vci._dest_name}, {vci._source_name}, timestep);
1231 else
1232 mooseError("Unrecognized variable ", vci._dest_name, " in variables to copy.");
1233 }
1234
1235 if (did_copy)
1236 solution().close();
1237}
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition SystemBase.C:89
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition SystemBase.C:848
void copy_scalar_solution(System &system, std::vector< std::string > system_var_names, std::vector< std::string > exodus_var_names, unsigned int timestep=1)
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)

◆ 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 129 of file SolverSystem.h.

130{
131 return _current_solution;
132}

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

◆ customSetup()

void NonlinearSystemBase::customSetup ( const ExecFlagType &  exec_type)
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 396 of file NonlinearSystemBase.C.

397{
398 SolverSystem::customSetup(exec_type);
399
400 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
401 {
402 _kernels.customSetup(exec_type, tid);
403 _nodal_kernels.customSetup(exec_type, tid);
404 _dirac_kernels.customSetup(exec_type, tid);
405 if (_doing_dg)
406 _dg_kernels.customSetup(exec_type, tid);
407 _interface_kernels.customSetup(exec_type, tid);
408 _element_dampers.customSetup(exec_type, tid);
409 _nodal_dampers.customSetup(exec_type, tid);
410 _integrated_bcs.customSetup(exec_type, tid);
411
412 if (_fe_problem.haveFV())
413 for (auto * fv_object : getFVSetupObjects(tid))
414 fv_object->customSetup(exec_type);
415 }
416 _scalar_kernels.customSetup(exec_type);
417 _constraints.customSetup(exec_type);
418 _general_dampers.customSetup(exec_type);
419 _nodal_bcs.customSetup(exec_type);
422
423#ifdef MOOSE_KOKKOS_ENABLED
424 _kokkos_kernels.customSetup(exec_type);
428#endif
429}
virtual void customSetup(const ExecFlagType &exec_type, THREAD_ID tid=0) const
MooseObjectTagWarehouse< ResidualObject > _kokkos_nodal_bcs
MooseObjectTagWarehouse< ResidualObject > _kokkos_integrated_bcs
std::vector< SetupInterface * > getFVSetupObjects(THREAD_ID tid)
Retrieve every finite volume object belonging to this system on thread tid, as SetupInterfaces,...
virtual void customSetup(const ExecFlagType &exec_type) override
virtual void customSetup(const ExecFlagType &exec_type)

◆ deactivateAllMatrixTags()

void SystemBase::deactivateAllMatrixTags ( )
virtualinherited

Make matrices inactive.

Definition at line 1116 of file SystemBase.C.

1117{
1118 auto num_matrix_tags = _subproblem.numMatrixTags();
1119
1120 _matrix_tag_active_flags.resize(num_matrix_tags);
1121
1122 for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
1123 _matrix_tag_active_flags[tag] = false;
1125}

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

◆ debuggingResiduals()

void NonlinearSystemBase::debuggingResiduals ( bool  state)
inlineinherited

Definition at line 595 of file NonlinearSystemBase.h.

595{ _debugging_residuals = state; }

◆ defaultMatrixTags()

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

Get the default matrix tags associted with this system.

Reimplemented in DisplacedSystem, and NonlinearEigenSystem.

Definition at line 347 of file SystemBase.h.

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

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

◆ defaultVectorTags()

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

Get the default vector tags associated with this system.

Reimplemented in DisplacedSystem, and NonlinearEigenSystem.

Definition at line 340 of file SystemBase.h.

341 {
343 }
virtual TagID residualVectorTag() const
Definition SystemBase.h:335
virtual TagID timeVectorTag() const
Ideally, we should not need this API.
Definition SystemBase.h:320
virtual TagID nonTimeVectorTag() const
Definition SystemBase.h:330

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

◆ destroyColoring()

void NonlinearSystemBase::destroyColoring ( )
inherited

Destroy the coloring object if it exists.

Definition at line 4310 of file NonlinearSystemBase.C.

4311{
4312 if (matrixFromColoring())
4313 LibmeshPetscCall(MatFDColoringDestroy(&_fdcoloring));
4314}

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

◆ disassociateDefaultMatrixTags()

void SystemBase::disassociateDefaultMatrixTags ( )
virtualinherited

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

Reimplemented in DisplacedSystem.

Definition at line 1107 of file SystemBase.C.

1108{
1109 const auto tags = defaultMatrixTags();
1110 for (const auto tag : tags)
1111 if (_subproblem.matrixTagExists(tag))
1113}
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
Definition SystemBase.h:347

Referenced by DisplacedSystem::disassociateDefaultMatrixTags().

◆ disassociateDefaultVectorTags()

void SystemBase::disassociateDefaultVectorTags ( )
virtualinherited

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

Reimplemented in DisplacedSystem.

Definition at line 1012 of file SystemBase.C.

1013{
1014 const auto tags = defaultVectorTags();
1015 for (const auto tag : tags)
1016 if (_subproblem.vectorTagExists(tag))
1018}
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
Definition SystemBase.h:340

Referenced by DisplacedSystem::disassociateDefaultVectorTags().

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

1086{
1087 if (!_subproblem.matrixTagExists(tag))
1088 mooseError("Cannot disassociate matrix from tag ", tag, " because that tag does not exist");
1089 if (hasMatrix(tag) && &getMatrix(tag) != &matrix)
1090 mooseError("You can not disassociate a matrix from a tag which it was not associated to");
1091
1093}

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

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

1097{
1098 if (!_subproblem.matrixTagExists(tag))
1099 mooseError("Cannot disassociate matrix from tag ", tag, " because that tag does not exist");
1100
1101 if (_tagged_matrices.size() < tag + 1)
1102 _tagged_matrices.resize(tag + 1);
1103 _tagged_matrices[tag] = nullptr;
1104}

◆ disassociateVectorFromTag() [1/2]

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

1002{
1003 if (!_subproblem.vectorTagExists(tag))
1004 mooseError("Cannot disassociate vector from tag ", tag, " because that tag does not exist");
1005
1006 if (_tagged_vectors.size() < tag + 1)
1007 _tagged_vectors.resize(tag + 1);
1008 _tagged_vectors[tag] = nullptr;
1009}

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

1167{
1168 return system().get_dof_map();
1169}

◆ doingDG()

bool NonlinearSystemBase::doingDG ( ) const
inherited

Getter for _doing_dg.

Definition at line 3967 of file NonlinearSystemBase.C.

3968{
3969 return _doing_dg;
3970}

◆ duDotDotDu() [1/2]

virtual Number & SystemBase::duDotDotDu ( )
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 285 of file SystemBase.h.

285{ return _du_dotdot_du; }
Real _du_dotdot_du

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

◆ duDotDotDu() [2/2]

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

Reimplemented in DisplacedSystem.

Definition at line 287 of file SystemBase.h.

287{ return _du_dotdot_du; }

◆ duDotDu()

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

◆ duDotDus()

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

Reimplemented in DisplacedSystem.

Definition at line 284 of file SystemBase.h.

284{ return _du_dot_du; }

Referenced by DisplacedSystem::duDotDus().

◆ eigenKernelOnCurrent()

void MooseEigenSystem::eigenKernelOnCurrent ( )

Definition at line 214 of file MooseEigenSystem.C.

215{
216 _active_on_old = false;
217 _fe_problem.updateActiveObjects(); // update warehouse active objects
218}
virtual void updateActiveObjects()
Update the active objects in the warehouses.

Referenced by EigenExecutionerBase::nonlinearSolve().

◆ eigenKernelOnOld()

void MooseEigenSystem::eigenKernelOnOld ( )

Ask eigenkernels to operate on old or current solution vectors.

Definition at line 207 of file MooseEigenSystem.C.

208{
209 _active_on_old = true;
210 _fe_problem.updateActiveObjects(); // update warehouse active objects
211}

Referenced by EigenExecutionerBase::inversePowerIteration().

◆ enforceNodalConstraintsJacobian()

bool NonlinearSystemBase::enforceNodalConstraintsJacobian ( const SparseMatrix< Number > &  jacobian)
protectedinherited

Enforce nodal constraints in the Jacobian.

Parameters
jacobianThe Jacobian to read from while constructing the Jacobians corresponding to the nodal constraints
Returns
Whether there were active nodal constraints

Definition at line 1100 of file NonlinearSystemBase.C.

1101{
1102 if (!hasMatrix(systemMatrixTag()))
1103 mooseError(" A system matrix is required");
1104
1105 THREAD_ID tid = 0; // constraints are going to be done single-threaded
1106
1108 {
1109 const auto & ncs = _constraints.getActiveNodalConstraints();
1110 for (const auto & nc : ncs)
1111 {
1112 std::vector<dof_id_type> & secondary_node_ids = nc->getSecondaryNodeId();
1113 std::vector<dof_id_type> & primary_node_ids = nc->getPrimaryNodeId();
1114
1115 if ((secondary_node_ids.size() > 0) && (primary_node_ids.size() > 0))
1116 {
1117 nc->reinitConstraintNodes();
1118 nc->computeJacobian(jacobian_to_view);
1119 }
1120 }
1122
1123 return true;
1124 }
1125 else
1126 return false;
1127}
const std::vector< std::shared_ptr< NodalConstraint > > & getActiveNodalConstraints() const
Access methods for active objects.

Referenced by NonlinearSystemBase::computeJacobianInternal().

◆ enforceNodalConstraintsResidual()

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

Enforce nodal constraints.

Definition at line 1076 of file NonlinearSystemBase.C.

1077{
1078 THREAD_ID tid = 0; // constraints are going to be done single-threaded
1079 residual.close();
1081 {
1082 const auto & ncs = _constraints.getActiveNodalConstraints();
1083 for (const auto & nc : ncs)
1084 {
1085 std::vector<dof_id_type> & secondary_node_ids = nc->getSecondaryNodeId();
1086 std::vector<dof_id_type> & primary_node_ids = nc->getPrimaryNodeId();
1087
1088 if ((secondary_node_ids.size() > 0) && (primary_node_ids.size() > 0))
1089 {
1090 nc->reinitConstraintNodes();
1091 nc->computeResidual(residual);
1092 }
1093 }
1095 residual.close();
1096 }
1097}

Referenced by NonlinearSystemBase::computeResidualInternal().

◆ feProblem() [1/2]

FEProblemBase & SystemBase::feProblem ( )
inlineinherited

◆ feProblem() [2/2]

const FEProblemBase & SystemBase::feProblem ( ) const
inlineinherited

Definition at line 105 of file SystemBase.h.

105{ return _fe_problem; }

◆ finalNonlinearResidual()

virtual Real NonlinearSystemBase::finalNonlinearResidual ( ) const
inlinevirtualinherited

Return the final nonlinear residual.

Reimplemented in NonlinearEigenSystem.

Definition at line 581 of file NonlinearSystemBase.h.

◆ findImplicitGeometricCouplingEntries()

void NonlinearSystemBase::findImplicitGeometricCouplingEntries ( GeometricSearchData &  geom_search_data,
std::unordered_map< dof_id_type, std::vector< dof_id_type > > &  graph 
)
privateinherited

Finds the implicit sparsity graph between geometrically related dofs.

Definition at line 2358 of file NonlinearSystemBase.C.

2361{
2362 const auto & node_to_elem_map = _mesh.nodeToElemMap();
2363 const auto & nearest_node_locators = geom_search_data._nearest_node_locators;
2364 for (const auto & it : nearest_node_locators)
2365 {
2366 std::vector<dof_id_type> & secondary_nodes = it.second->_secondary_nodes;
2367
2368 for (const auto & secondary_node : secondary_nodes)
2369 {
2370 std::set<dof_id_type> unique_secondary_indices;
2371 std::set<dof_id_type> unique_primary_indices;
2372
2373 auto node_to_elem_pair = node_to_elem_map.find(secondary_node);
2374 if (node_to_elem_pair != node_to_elem_map.end())
2375 {
2376 const std::vector<dof_id_type> & elems = node_to_elem_pair->second;
2377
2378 // Get the dof indices from each elem connected to the node
2379 for (const auto & cur_elem : elems)
2380 {
2381 std::vector<dof_id_type> dof_indices;
2382 dofMap().dof_indices(_mesh.elemPtr(cur_elem), dof_indices);
2383
2384 for (const auto & dof : dof_indices)
2385 unique_secondary_indices.insert(dof);
2386 }
2387 }
2388
2389 std::vector<dof_id_type> primary_nodes = it.second->_neighbor_nodes[secondary_node];
2390
2391 for (const auto & primary_node : primary_nodes)
2392 {
2393 auto primary_node_to_elem_pair = node_to_elem_map.find(primary_node);
2394 mooseAssert(primary_node_to_elem_pair != node_to_elem_map.end(),
2395 "Missing entry in node to elem map");
2396 const std::vector<dof_id_type> & primary_node_elems = primary_node_to_elem_pair->second;
2397
2398 // Get the dof indices from each elem connected to the node
2399 for (const auto & cur_elem : primary_node_elems)
2400 {
2401 std::vector<dof_id_type> dof_indices;
2402 dofMap().dof_indices(_mesh.elemPtr(cur_elem), dof_indices);
2403
2404 for (const auto & dof : dof_indices)
2405 unique_primary_indices.insert(dof);
2406 }
2407 }
2408
2409 for (const auto & secondary_id : unique_secondary_indices)
2410 for (const auto & primary_id : unique_primary_indices)
2411 {
2412 graph[secondary_id].push_back(primary_id);
2413 graph[primary_id].push_back(secondary_id);
2414 }
2415 }
2416 }
2417
2418 // handle node-to-node constraints
2419 const auto & ncs = _constraints.getActiveNodalConstraints();
2420 for (const auto & nc : ncs)
2421 {
2422 std::vector<dof_id_type> primary_dofs;
2423 std::vector<dof_id_type> & primary_node_ids = nc->getPrimaryNodeId();
2424 for (const auto & node_id : primary_node_ids)
2425 {
2426 Node * node = _mesh.queryNodePtr(node_id);
2427 if (node && node->processor_id() == this->processor_id())
2428 {
2429 getNodeDofs(node_id, primary_dofs);
2430 }
2431 }
2432
2433 _communicator.allgather(primary_dofs);
2434
2435 std::vector<dof_id_type> secondary_dofs;
2436 std::vector<dof_id_type> & secondary_node_ids = nc->getSecondaryNodeId();
2437 for (const auto & node_id : secondary_node_ids)
2438 {
2439 Node * node = _mesh.queryNodePtr(node_id);
2440 if (node && node->processor_id() == this->processor_id())
2441 {
2442 getNodeDofs(node_id, secondary_dofs);
2443 }
2444 }
2445
2446 _communicator.allgather(secondary_dofs);
2447
2448 for (const auto & primary_id : primary_dofs)
2449 for (const auto & secondary_id : secondary_dofs)
2450 {
2451 graph[primary_id].push_back(secondary_id);
2452 graph[secondary_id].push_back(primary_id);
2453 }
2454 }
2455
2456 // Make every entry sorted and unique
2457 for (auto & it : graph)
2458 {
2459 std::vector<dof_id_type> & row = it.second;
2460 std::sort(row.begin(), row.end());
2461 std::vector<dof_id_type>::iterator uit = std::unique(row.begin(), row.end());
2462 row.resize(uit - row.begin());
2463 }
2464}
std::map< std::pair< BoundaryID, BoundaryID >, NearestNodeLocator * > _nearest_node_locators
const std::unordered_map< dof_id_type, std::vector< dof_id_type > > & nodeToElemMap()
If not already created, creates a map from every node to all elements to which they are connected.
Definition MooseMesh.C:1241
virtual const Node * queryNodePtr(const dof_id_type i) const
Definition MooseMesh.C:872
void getNodeDofs(dof_id_type node_id, std::vector< dof_id_type > &dofs)
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const

Referenced by NonlinearSystemBase::addImplicitGeometricCouplingEntries(), and NonlinearSystemBase::augmentSparsity().

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

1066{
1067 for (auto tag : tags)
1068 if (hasMatrix(tag))
1069 getMatrix(tag).flush();
1070}

◆ getActualFieldVariable() [1/2]

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

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

Definition at line 117 of file SystemBase.C.

118{
119 return *_vars[tid].getActualFieldVariable<T>(var_name);
120}

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

◆ getActualFieldVariable() [2/2]

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

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

Definition at line 138 of file SystemBase.C.

139{
140 return *_vars[tid].getActualFieldVariable<T>(var_number);
141}

◆ getConstraintWarehouse()

const ConstraintWarehouse & NonlinearSystemBase::getConstraintWarehouse ( ) const
inlineinherited

◆ getCurrentNonlinearIterationNumber()

virtual unsigned int NonlinearSystem::getCurrentNonlinearIterationNumber ( )
inlineoverridevirtualinherited

Returns the current nonlinear iteration number.

In libmesh, this is updated during the nonlinear solve, so it should be up-to-date.

Implements NonlinearSystemBase.

Definition at line 45 of file NonlinearSystem.h.

◆ getDGKernelWarehouse()

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

Definition at line 631 of file NonlinearSystemBase.h.

631{ return _dg_kernels; }

Referenced by ExplicitTimeIntegrator::initialSetup().

◆ getDiracKernelWarehouse()

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

Definition at line 636 of file NonlinearSystemBase.h.

636{ return _dirac_kernels; }

◆ getEigenVariableNames()

const std::set< VariableName > & MooseEigenSystem::getEigenVariableNames ( ) const
inline

Get variable names of the eigen system.

Definition at line 94 of file MooseEigenSystem.h.

94{ return _eigen_var_names; }

Referenced by buildSystemDoFIndices().

◆ getElementDamperWarehouse()

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

Definition at line 647 of file NonlinearSystemBase.h.

648 {
649 return _element_dampers;
650 }

Referenced by ComputeElemDampingThread::printGeneralExecutionInformation().

◆ getFieldSplitPreconditioner()

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

Definition at line 4317 of file NonlinearSystemBase.C.

4318{
4319 if (!_fsp)
4320 mooseError("No field split preconditioner is present for this system");
4321
4322 return *_fsp;
4323}
FieldSplitPreconditionerBase * _fsp
The field split preconditioner if this sytem is using one.

◆ getFieldVariable() [1/2]

template<typename T >
template MooseVariableFE< RealEigenVector > & SystemBase::getFieldVariable< RealEigenVector > ( 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 110 of file SystemBase.C.

111{
112 return *_vars[tid].getFieldVariable<T>(var_name);
113}

Referenced by Marker::getMarkerValue().

◆ getFieldVariable() [2/2]

template<typename T >
template MooseVariableFE< RealEigenVector > & SystemBase::getFieldVariable< RealEigenVector > ( 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 131 of file SystemBase.C.

132{
133 return *_vars[tid].getFieldVariable<T>(var_number);
134}

◆ getFVSetupObjects()

std::vector< SetupInterface * > NonlinearSystemBase::getFVSetupObjects ( THREAD_ID  tid)
privateinherited

Retrieve every finite volume object belonging to this system on thread tid, as SetupInterfaces, so that the setup methods can be dispatched to all finite volume families with a single loop.

Each family is queried through a MooseObject-derived base class to avoid runtime side-casts in TheWarehouse.

Definition at line 253 of file NonlinearSystemBase.C.

254{
255 std::vector<SetupInterface *> fv_objects;
256 auto & warehouse = _fe_problem.theWarehouse();
257
258 appendFVSetupObjects<FVElementalKernel>(
259 warehouse, "FVElementalKernel", number(), tid, fv_objects);
260 appendFVSetupObjects<FVFluxKernel>(warehouse, "FVFluxKernel", number(), tid, fv_objects);
261 appendFVSetupObjects<FVBoundaryCondition>(warehouse, "FVDirichletBC", number(), tid, fv_objects);
262 appendFVSetupObjects<FVBoundaryCondition>(warehouse, "FVFluxBC", number(), tid, fv_objects);
263 appendFVSetupObjects<FVInterfaceKernel>(
264 warehouse, "FVInterfaceKernel", number(), tid, fv_objects);
265
266 return fv_objects;
267}

Referenced by NonlinearSystemBase::customSetup(), NonlinearSystemBase::initialSetup(), and NonlinearSystemBase::timestepSetup().

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

125{
126 return *_vars[tid].getFVVariable<T>(var_name);
127}

◆ getHDGKernelWarehouse()

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

Definition at line 646 of file NonlinearSystemBase.h.

646{ return _hybridized_kernels; }

◆ getIntegratedBCWarehouse() [1/2]

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

Definition at line 637 of file NonlinearSystemBase.h.

637{ return _integrated_bcs; }

Referenced by BoundaryElemIntegrityCheckThread::operator()().

◆ getIntegratedBCWarehouse() [2/2]

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

Return the IntegratedBCBase warehouse.

Definition at line 665 of file NonlinearSystemBase.h.

666 {
667 return _integrated_bcs;
668 }

◆ getInterfaceKernelWarehouse()

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

Definition at line 632 of file NonlinearSystemBase.h.

633 {
634 return _interface_kernels;
635 }

◆ getKernelWarehouse() [1/2]

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

Access functions to Warehouses from outside NonlinearSystemBase.

Definition at line 629 of file NonlinearSystemBase.h.

629{ return _kernels; }

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

◆ getKernelWarehouse() [2/2]

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

Definition at line 630 of file NonlinearSystemBase.h.

630{ return _kernels; }

◆ getKokkosIntegratedBCWarehouse()

MooseObjectTagWarehouse< ResidualObject > & NonlinearSystemBase::getKokkosIntegratedBCWarehouse ( )
inlineinherited

Definition at line 682 of file NonlinearSystemBase.h.

683 {
685 }

◆ getKokkosKernelWarehouse()

MooseObjectTagWarehouse< ResidualObject > & NonlinearSystemBase::getKokkosKernelWarehouse ( )
inlineinherited

Return the Kokkos residual object warehouses

Definition at line 673 of file NonlinearSystemBase.h.

673{ return _kokkos_kernels; }

Referenced by ExplicitTimeIntegrator::initialSetup().

◆ getKokkosNodalBCWarehouse()

MooseObjectTagWarehouse< ResidualObject > & NonlinearSystemBase::getKokkosNodalBCWarehouse ( )
inlineinherited

Definition at line 678 of file NonlinearSystemBase.h.

679 {
680 return _kokkos_nodal_bcs;
681 }

◆ getKokkosNodalKernelWarehouse()

MooseObjectTagWarehouse< ResidualObject > & NonlinearSystemBase::getKokkosNodalKernelWarehouse ( )
inlineinherited

Definition at line 674 of file NonlinearSystemBase.h.

675 {
677 }

Referenced by ExplicitTimeIntegrator::initialSetup().

◆ getMatrix() [1/2]

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

Get a raw SparseMatrix.

Reimplemented in DisplacedSystem.

Definition at line 1021 of file SystemBase.C.

1022{
1023 if (!hasMatrix(tag))
1024 {
1025 if (!_subproblem.matrixTagExists(tag))
1026 mooseError("Cannot retrieve matrix with tag ", tag, " because that tag does not exist");
1027 else
1028 mooseError("Cannot retrieve matrix with tag ",
1029 tag,
1030 " in system '",
1031 name(),
1032 "'\nbecause a matrix has not been associated with that tag.");
1033 }
1034
1035 return *_tagged_matrices[tag];
1036}

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(), SystemBase::flushTaggedMatrices(), DisplacedSystem::getMatrix(), DisplacedSystem::getMatrix(), LinearSystemContributionObject::linkTaggedVectorsAndMatrices(), MooseVariableScalar::reinit(), Assembly::setCachedJacobian(), and Assembly::zeroCachedJacobian().

◆ getMatrix() [2/2]

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

Get a raw SparseMatrix.

Reimplemented in DisplacedSystem.

Definition at line 1039 of file SystemBase.C.

1040{
1041 if (!hasMatrix(tag))
1042 {
1043 if (!_subproblem.matrixTagExists(tag))
1044 mooseError("Cannot retrieve matrix with tag ", tag, " because that tag does not exist");
1045 else
1046 mooseError("Cannot retrieve matrix with tag ",
1047 tag,
1048 " in system '",
1049 name(),
1050 "'\nbecause a matrix has not been associated with that tag.");
1051 }
1052
1053 return *_tagged_matrices[tag];
1054}

◆ getMaxVariableNumber()

unsigned int SystemBase::getMaxVariableNumber ( ) const
inlineinherited

Returns the maximum number of all variables on the system.

Definition at line 897 of file SystemBase.h.

897{ return _max_var_number; }

◆ 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 613 of file SystemBase.h.

613{ return _max_var_n_dofs_per_elem; }

Referenced by Moose::globalDofIndexToDerivative().

◆ 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 620 of file SystemBase.h.

620{ return _max_var_n_dofs_per_node; }

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

241{
242 Order order = CONSTANT;
243 const std::vector<MooseVariableFieldBase *> & vars = _vars[0].fieldVariables();
244 for (const auto & var : vars)
245 {
246 FEType fe_type = var->feType();
247 if (fe_type.default_quadrature_order() > order)
248 order = fe_type.default_quadrature_order();
249 }
250
251 return order;
252}

◆ getMooseKSPNormType()

Moose::MooseKSPNormType SolverSystem::getMooseKSPNormType ( )
inlineinherited

Get the norm in which the linear convergence is measured.

Definition at line 99 of file SolverSystem.h.

99{ return _ksp_norm; }
Moose::MooseKSPNormType _ksp_norm
KSP norm type.

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

◆ getNodalBCWarehouse()

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

Return the NodalBCBase warehouse.

Definition at line 660 of file NonlinearSystemBase.h.

660{ return _nodal_bcs; }

◆ getNodalDamperWarehouse()

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

Definition at line 651 of file NonlinearSystemBase.h.

652 {
653 return _nodal_dampers;
654 }

Referenced by ComputeNodalDampingThread::printGeneralExecutionInformation().

◆ getNodalKernelWarehouse()

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

Definition at line 642 of file NonlinearSystemBase.h.

643 {
644 return _nodal_kernels;
645 }

Referenced by ExplicitTimeIntegrator::initialSetup().

◆ getNodeDofs()

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

Definition at line 2345 of file NonlinearSystemBase.C.

2346{
2347 const Node & node = _mesh.nodeRef(node_id);
2348 unsigned int s = number();
2349 if (node.has_dofs(s))
2350 {
2351 for (unsigned int v = 0; v < nVariables(); v++)
2352 for (unsigned int c = 0; c < node.n_comp(s, v); c++)
2353 dofs.push_back(node.dof_number(s, v, c));
2354 }
2355}
virtual unsigned int nVariables() const
Get the number of variables in this system.
Definition SystemBase.C:888

Referenced by NonlinearSystemBase::findImplicitGeometricCouplingEntries().

◆ getNumSolutionStates()

std::size_t SystemBase::getNumSolutionStates ( const Moose::SolutionIterationType  iteration_type) const
inlineinherited

Get the number of solution states (0 = current, 1 = current + old, ...) for the given iteration type.

Definition at line 1163 of file SystemBase.h.

1164{
1165 return getSolutionStates(iteration_type).size();
1166}
const std::vector< NumericVector< Number > * > & getSolutionStates(const Moose::SolutionIterationType iteration_type) const
Get all of the solution states (current, old, ...) for the given iteration type.

Referenced by SystemBase::copyPreviousSolutions(), SystemBase::hasSolutionState(), SystemBase::restoreOldSolutions(), SystemBase::saveOldSolutions(), and SystemBase::solutionState().

◆ getPCSide()

Moose::PCSideType SolverSystem::getPCSide ( )
inlineinherited

Get the current preconditioner side.

Definition at line 88 of file SolverSystem.h.

88{ return _pc_side; }
Moose::PCSideType _pc_side
Preconditioning side.

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

◆ getPreconditioner()

MoosePreconditioner const * NonlinearSystemBase::getPreconditioner ( ) const
inherited

Definition at line 3703 of file NonlinearSystemBase.C.

3704{
3705 return _preconditioner.get();
3706}
std::shared_ptr< MoosePreconditioner > _preconditioner
Preconditioner.

Referenced by ConsoleUtils::outputExecutionInformation().

◆ getPredictor()

Predictor * NonlinearSystemBase::getPredictor ( )
inlineinherited

Definition at line 600 of file NonlinearSystemBase.h.

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

Referenced by AB2PredictorCorrector::estimateTimeError().

◆ getResidualNonTimeVector()

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

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

Definition at line 1036 of file NonlinearSystemBase.C.

1037{
1038 if (!_Re_non_time)
1039 {
1041
1042 // Most applications don't need the expense of ghosting
1044 _Re_non_time = &addVector(_Re_non_time_tag, false, ptype);
1045 }
1046 else if (_need_residual_ghosted && _Re_non_time->type() == PARALLEL)
1047 {
1048 const auto vector_name = _subproblem.vectorTagName(_Re_non_time_tag);
1049
1050 // If an application changes its mind, the libMesh API lets us
1051 // change the vector.
1052 _Re_non_time = &system().add_vector(vector_name, false, GHOSTED);
1053 }
1054
1055 return *_Re_non_time;
1056}
TagID _Re_non_time_tag
Tag for non-time contribution residual.
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition SubProblem.C:81
ParallelType type() const

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

◆ getResidualTimeVector()

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

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

Definition at line 1013 of file NonlinearSystemBase.C.

1014{
1015 if (!_Re_time)
1016 {
1018
1019 // Most applications don't need the expense of ghosting
1021 _Re_time = &addVector(_Re_time_tag, false, ptype);
1022 }
1023 else if (_need_residual_ghosted && _Re_time->type() == PARALLEL)
1024 {
1025 const auto vector_name = _subproblem.vectorTagName(_Re_time_tag);
1026
1027 // If an application changes its mind, the libMesh API lets us
1028 // change the vector.
1029 _Re_time = &system().add_vector(vector_name, false, GHOSTED);
1030 }
1031
1032 return *_Re_time;
1033}
TagID _Re_time_tag
Tag for time contribution residual.

Referenced by NonlinearSystemBase::residualVector().

◆ getScalarKernelWarehouse()

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

Definition at line 638 of file NonlinearSystemBase.h.

639 {
640 return _scalar_kernels;
641 }

Referenced by ExplicitTimeIntegrator::initialSetup().

◆ getScalarVariable() [1/2]

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

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

154{
155 MooseVariableScalar * var =
156 dynamic_cast<MooseVariableScalar *>(_vars[tid].getVariable(var_number));
157 if (!var)
158 mooseError("variable #" + Moose::stringify(var_number) + " does not exist in this system");
159 return *var;
160}
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:65

◆ getScalarVariables()

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

◆ getSNES()

SNES NonlinearSystem::getSNES ( )
overridevirtualinherited

Implements NonlinearSystemBase.

Definition at line 370 of file NonlinearSystem.C.

371{
374
375 if (petsc_solver)
376 {
377 const char * snes_prefix = nullptr;
378 std::string snes_prefix_str;
379 if (system().prefix_with_name())
380 {
381 snes_prefix_str = system().prefix();
382 snes_prefix = snes_prefix_str.c_str();
383 }
384 return petsc_solver->snes(snes_prefix);
385 }
386 else
387 mooseError("It is not a petsc nonlinear solver");
388}
SNES snes(const char *name=nullptr)
void prefix_with_name(bool value)
std::string prefix() const

◆ getSolutionStates() [1/2]

std::vector< NumericVector< Number > * > & SystemBase::getSolutionStates ( const Moose::SolutionIterationType  iteration_type)
inlineprivateinherited

Get all of the solution states (current, old, ...) for the given iteration type.

Definition at line 1128 of file SystemBase.h.

1129 {
1130 return const_cast<std::vector<NumericVector<Number> *> &>(
1131 cast_ptr<const SystemBase *>(this)->getSolutionStates(iteration_type));
1132 }

◆ getSolutionStates() [2/2]

const std::vector< NumericVector< Number > * > & SystemBase::getSolutionStates ( const Moose::SolutionIterationType  iteration_type) const
inlineinherited

Get all of the solution states (current, old, ...) for the given iteration type.

Definition at line 1153 of file SystemBase.h.

1154{
1155 const auto iteration_type_index = static_cast<std::size_t>(iteration_type);
1156 mooseAssert(iteration_type_index < static_cast<std::size_t>(Moose::SolutionIterationType::Count),
1157 "Invalid solution iteration type");
1158 mooseAssert(iteration_type_index < _solution_states.size(), "_solution_states sized incorrectly");
1159 return _solution_states[iteration_type_index];
1160}
std::array< std::vector< NumericVector< Number > * >, static_cast< size_t >(Moose::SolutionIterationType::Count)> _solution_states
2D array of solution state vector pointers.

Referenced by SystemBase::getNumSolutionStates(), SystemBase::needSolutionState(), SystemBase::solutionState(), SystemBase::solutionState(), and SystemBase::solutionStateParallelType().

◆ 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 716 of file NonlinearSystemBase.C.

717{
719}
std::shared_ptr< T > getActiveObject(const std::string &name, THREAD_ID tid=0) const

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

◆ getSplits()

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

Retrieves all splits.

Definition at line 263 of file NonlinearSystemBase.h.

263{ return _splits; }

Referenced by ConsoleUtils::outputExecutionInformation().

◆ getStandardFieldVariableNames()

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

◆ getSubdomainsForVar() [1/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 1728 of file SystemBase.C.

1729{
1730 return getSubdomainsForVar(getVariable(0, var_name).number());
1731}

◆ getSubdomainsForVar() [2/2]

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

Definition at line 791 of file SystemBase.h.

792 {
793 return _var_map.at(var_number);
794 }

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

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

1705{
1706 const auto * const ti = queryTimeIntegrator(var_num);
1707
1708 if (ti)
1709 return *ti;
1710 else
1711 mooseError("No time integrator found that integrates variable number ",
1712 std::to_string(var_num));
1713}
const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable's equation.

Referenced by AB2PredictorCorrector::estimateTimeError().

◆ getTimeIntegrators()

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

Definition at line 1716 of file SystemBase.C.

1717{
1718 return _time_integrators;
1719}

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

90{
92 dynamic_cast<MooseVariableFieldBase *>(_vars[tid].getVariable(var_name));
93 if (!var)
94 mooseError("Variable '", var_name, "' does not exist in this system");
95 return *var;
96}

Referenced by AdaptivityAction::act(), Assembly::addJacobianBlockNonlocal(), FEProblemBase::addJacobianBlockTags(), LinearFVGradientManager::checkRestartedGradientHistory(), NonlocalIntegratedBC::computeNonlocalOffDiagJacobian(), NonlocalKernel::computeNonlocalOffDiagJacobian(), Assembly::copyFaceShapes(), Assembly::copyNeighborShapes(), Assembly::copyShapes(), SystemBase::copyVars(), DMMooseSetVariables(), FiniteDifferencePreconditioner::FiniteDifferencePreconditioner(), NodeElemConstraint::getConnectedDofIndices(), NodeFaceConstraint::getConnectedDofIndices(), SystemBase::getSubdomainsForVar(), ResidualObject::getVariable(), SubProblem::getVariableHelper(), NodalNormalsPreprocessor::initialize(), LinearSystem::initialSetup(), ExplicitTimeIntegrator::initialSetup(), Assembly::initNonlocalCoupling(), PNGOutput::makeMeshFunc(), MooseStaticCondensationPreconditioner::MooseStaticCondensationPreconditioner(), UpdateErrorVectorsThread::onElement(), FEProblemBase::prepare(), Assembly::prepareBlock(), Assembly::prepareBlockNonlocal(), NonlinearSystemBase::setupScalingData(), LinearFVGradientReader::stateComponents(), and VariableCondensationPreconditioner::VariableCondensationPreconditioner().

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

100{
101 if (var_number < _numbered_vars[tid].size())
102 if (_numbered_vars[tid][var_number])
103 return *_numbered_vars[tid][var_number];
104
105 mooseError("Variable #", Moose::stringify(var_number), " does not exist in this system");
106}

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

164{
165 mooseAssert(_var_map.find(var_number) != _var_map.end(), "Variable does not exist.");
166 if (_var_map[var_number].empty())
167 return nullptr;
168 else
169 return &_var_map[var_number];
170}

Referenced by PhysicsBasedPreconditioner::addSystem().

◆ 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 872 of file SystemBase.h.

872{ return _var_all_dof_indices; }
std::vector< dof_id_type > _var_all_dof_indices
Container for the dof indices of a given variable.

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

931{
932 return system().get_vector(name);
933}
const NumericVector< Number > & get_vector(std::string_view vec_name) const

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

◆ getVector() [2/4]

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

Reimplemented in DisplacedSystem.

Definition at line 936 of file SystemBase.C.

937{
938 return system().get_vector(name);
939}

◆ getVector() [3/4]

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

Get a raw NumericVector by tag.

Reimplemented in DisplacedSystem.

Definition at line 942 of file SystemBase.C.

943{
944 if (!hasVector(tag))
945 {
947 mooseError("Cannot retrieve vector with tag ", tag, " because that tag does not exist");
948 else
949 mooseError("Cannot retrieve vector with tag ",
950 tag,
951 " in system '",
952 name(),
953 "'\nbecause a vector has not been associated with that tag.");
954 }
955
956 return *_tagged_vectors[tag];
957}

◆ getVector() [4/4]

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

Reimplemented in DisplacedSystem.

Definition at line 960 of file SystemBase.C.

961{
962 if (!hasVector(tag))
963 {
965 mooseError("Cannot retrieve vector with tag ", tag, " because that tag does not exist");
966 else
967 mooseError("Cannot retrieve vector with tag ",
968 tag,
969 " in system '",
970 name(),
971 "'\nbecause a vector has not been associated with that tag.");
972 }
973
974 return *_tagged_vectors[tag];
975}

◆ hasDiagSaveIn()

bool NonlinearSystemBase::hasDiagSaveIn ( ) const
inlineinherited

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

Definition at line 699 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeJacobianInternal().

◆ hasMatrix()

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

◆ hasSaveIn()

bool NonlinearSystemBase::hasSaveIn ( ) const
inlineinherited

Weather or not the nonlinear system has save-ins.

Definition at line 694 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeResidualTags().

◆ hasScalarVariable()

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

◆ hasSolutionState()

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

◆ hasVarCopy()

bool SystemBase::hasVarCopy ( ) const
inlineinherited

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

Definition at line 918 of file SystemBase.h.

918{ return _var_to_copy.size() > 0; }

◆ hasVariable()

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

◆ 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 309 of file SystemBase.h.

310 {
311 return tag_id < _tagged_vectors.size() && _tagged_vectors[tag_id];
312 }

◆ haveFieldSplitPreconditioner()

bool NonlinearSystemBase::haveFieldSplitPreconditioner ( ) const
inlineinherited

Definition at line 113 of file NonlinearSystemBase.h.

113{ return _fsp; }

◆ haveFiniteDifferencedPreconditioner()

bool NonlinearSystemBase::haveFiniteDifferencedPreconditioner ( ) const
inlineinherited

Definition at line 109 of file NonlinearSystemBase.h.

110 {
112 }
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 742 of file NonlinearSystemBase.h.

743 {
744 _ignore_variables_for_autoscaling = ignore_variables_for_autoscaling;
745 }
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 174 of file SystemBase.h.

174{}

◆ initialResidual()

Real NonlinearSystemBase::initialResidual ( ) const
inherited

The initial residual.

Definition at line 755 of file NonlinearSystemBase.C.

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

Referenced by NonlinearSystemBase::referenceResidual().

◆ initialSetup()

void NonlinearSystemBase::initialSetup ( )
overridevirtualinherited

Setup Functions.

Reimplemented from SystemBase.

Definition at line 270 of file NonlinearSystemBase.C.

271{
272 TIME_SECTION("nlInitialSetup", 2, "Setting Up Nonlinear System");
273
275
276 {
277 TIME_SECTION("kernelsInitialSetup", 2, "Setting Up Kernels/BCs/Constraints");
278
279 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
280 {
284 if (_doing_dg)
287
291
292 if (_fe_problem.haveFV())
293 for (auto * fv_object : getFVSetupObjects(tid))
294 fv_object->initialSetup();
295 }
296
303
304#ifdef MOOSE_KOKKOS_ENABLED
309#endif
310 }
311
312 {
313 TIME_SECTION("mortarSetup", 2, "Initializing Mortar Interfaces");
314
315 auto create_mortar_functors = [this](const bool displaced)
316 {
317 // go over mortar interfaces and construct functors
318 const auto & mortar_interfaces = _fe_problem.getMortarInterfaces(displaced);
319 for (const auto & [primary_secondary_boundary_pair, interface_config] : mortar_interfaces)
320 {
321 if (!_constraints.hasActiveMortarConstraints(primary_secondary_boundary_pair, displaced))
322 continue;
323
324 auto & mortar_constraints =
325 _constraints.getActiveMortarConstraints(primary_secondary_boundary_pair, displaced);
326
327 auto & subproblem = displaced ? cast_ref<SubProblem &>(*_fe_problem.getDisplacedProblem())
329
330 auto & mortar_functors =
332
333 mortar_functors.emplace(primary_secondary_boundary_pair,
334 ComputeMortarFunctor(mortar_constraints,
335 *interface_config.amg,
338 displaced,
339 subproblem.assembly(0, number())));
340 }
341 };
342
343 create_mortar_functors(false);
344 create_mortar_functors(true);
345 }
346
348 {
350 _scaling_matrix = std::make_unique<OffDiagonalScalingMatrix<Number>>(_communicator);
351 else
352 _scaling_matrix = std::make_unique<libMesh::DiagonalMatrix<Number>>(_communicator);
353 }
354
355 if (_preconditioner)
356 _preconditioner->initialSetup();
357}
const std::vector< std::shared_ptr< MortarConstraintBase > > & getActiveMortarConstraints(const std::pair< BoundaryID, BoundaryID > &mortar_interface_key, bool displaced) const
bool hasActiveMortarConstraints(const std::pair< BoundaryID, BoundaryID > &mortar_interface_key, bool displaced) const
const std::unordered_map< std::pair< BoundaryID, BoundaryID >, MortarInterfaceConfig > & getMortarInterfaces(bool on_displaced) const
virtual void initialSetup(THREAD_ID tid=0) const
Convenience methods for calling object setup methods.
virtual void residualSetup(THREAD_ID tid=0) const
virtual void initialSetup() override
Setup Functions.
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _displaced_mortar_functors
Functors for computing displaced mortar constraints.
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _undisplaced_mortar_functors
Functors for computing undisplaced mortar constraints.
bool _off_diagonals_in_auto_scaling
Whether to include off diagonals when determining automatic scaling factors.
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
virtual void initialSetup()
Setup Functions.

◆ initSolutionState()

void SystemBase::initSolutionState ( )
virtualinherited

Initializes the solution state.

Reimplemented in AuxiliarySystem, DisplacedSystem, and LinearSystem.

Definition at line 1383 of file SystemBase.C.

1384{
1385 // Default is the current solution
1386 unsigned int state = 0;
1387
1388 // Add additional states as required by the variable states requested
1389 for (const auto & var : getVariables(/* tid = */ 0))
1390 state = std::max(state, var->oldestSolutionStateRequested());
1391 for (const auto & var : getScalarVariables(/* tid = */ 0))
1392 state = std::max(state, var->oldestSolutionStateRequested());
1393
1395
1397}
bool _solution_states_initialized
Whether or not the solution states have been initialized.
virtual void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time, libMesh::ParallelType parallel_type=GHOSTED)
Registers that the solution state state is needed.
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
Definition SystemBase.h:779
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
Definition SystemBase.h:786
auto max(const L &left, const R &right)

Referenced by AuxiliarySystem::AuxiliarySystem(), DisplacedSystem::initSolutionState(), and LinearSystem::initSolutionState().

◆ initSystemSolution()

void MooseEigenSystem::initSystemSolution ( SYSTEMTAG  tag,
Real  v 
)

Initialize the solution vector with a constant value.

Parameters
tagSystem tag.
vThe value.

Definition at line 161 of file MooseEigenSystem.C.

162{
163 if (tag == ALL)
164 {
165 solution() = v;
166 }
167 else if (tag == EIGEN)
168 {
169 if (_all_eigen_vars)
170 {
171 solution() = v;
172 }
173 else
174 {
175 for (const auto & dof : _eigen_var_indices)
176 solution().set(dof, v);
177 }
178 }
179 solution().close();
180 update();
181}

Referenced by EigenExecutionerBase::init().

◆ initSystemSolutionOld()

void MooseEigenSystem::initSystemSolutionOld ( SYSTEMTAG  tag,
Real  v 
)

Definition at line 184 of file MooseEigenSystem.C.

185{
186 if (tag == ALL)
187 {
188 solutionOld() = v;
189 }
190 else if (tag == EIGEN)
191 {
192 if (_all_eigen_vars)
193 {
194 solutionOld() = v;
195 }
196 else
197 {
198 for (const auto & dof : _eigen_var_indices)
199 solutionOld().set(dof, v);
200 }
201 }
202 solutionOld().close();
203 update();
204}

Referenced by EigenExecutionerBase::init().

◆ isArrayVariable()

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

If a variable is an array variable.

Definition at line 861 of file SystemBase.C.

862{
863 auto & names = getVariableNames();
864 if (!system().has_variable(var_name) &&
865 std::find(names.begin(), names.end(), var_name) != names.end())
866 // array variable
867 return true;
868 else
869 return false;
870}

◆ isScalarVariable()

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

Definition at line 882 of file SystemBase.C.

883{
884 return (system().variable(var_num).type().family == SCALAR);
885}

Referenced by Assembly::initNonlocalCoupling().

◆ jacobianSetup()

void NonlinearSystemBase::jacobianSetup ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 2966 of file NonlinearSystemBase.C.

2967{
2969
2970 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
2971 {
2975 if (_doing_dg)
2981 }
2988
2989#ifdef MOOSE_KOKKOS_ENABLED
2994#endif
2995
2996 // Avoid recursion
2997 if (this == &_fe_problem.currentNonlinearSystem())
2999}
void jacobianSetup() override
NonlinearSystemBase & currentNonlinearSystem()
virtual void jacobianSetup(THREAD_ID tid=0) const
virtual void jacobianSetup()

Referenced by NonlinearSystemBase::computeJacobianInternal().

◆ markEigenVariable()

void MooseEigenSystem::markEigenVariable ( const VariableName &  var_name)
virtual

Mark a variable as a variable of the eigen system.

Parameters
var_nameThe name of the variable.

Definition at line 75 of file MooseEigenSystem.C.

76{
77 _eigen_var_names.insert(var_name);
78}

Referenced by addKernel(), and AddVariableAction::addVariable().

◆ matrixFromColoring()

virtual bool NonlinearSystem::matrixFromColoring ( ) const
inlineoverrideprivatevirtualinherited

Whether a system matrix is formed from coloring.

This influences things like when to compute time derivatives

Reimplemented from SolverSystem.

Definition at line 104 of file NonlinearSystem.h.

◆ matrixTagActive()

bool SystemBase::matrixTagActive ( TagID  tag) const
virtualinherited

If or not a matrix tag is active.

Definition at line 1146 of file SystemBase.C.

1147{
1148 mooseAssert(_subproblem.matrixTagExists(tag), "Matrix tag " << tag << " does not exist");
1149
1150 return tag < _matrix_tag_active_flags.size() && _matrix_tag_active_flags[tag];
1151}

◆ mesh() [1/2]

MooseMesh & SystemBase::mesh ( )
inlineinherited

◆ mesh() [2/2]

const MooseMesh & SystemBase::mesh ( ) const
inlineinherited

Definition at line 101 of file SystemBase.h.

101{ return _mesh; }

◆ 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 3980 of file NonlinearSystemBase.C.

3983{
3984 parallel_object_only();
3985
3986 try
3987 {
3988 for (auto & map_pr : _undisplaced_mortar_functors)
3989 map_pr.second(compute_type, vector_tags, matrix_tags);
3990
3991 for (auto & map_pr : _displaced_mortar_functors)
3992 map_pr.second(compute_type, vector_tags, matrix_tags);
3993 }
3994 catch (MetaPhysicL::LogicError &)
3995 {
3996 mooseError(
3997 "We caught a MetaPhysicL error in NonlinearSystemBase::mortarConstraints. This is very "
3998 "likely due to AD not having a sufficiently large derivative container size. Please run "
3999 "MOOSE configure with the '--with-derivative-size=<n>' option");
4000 }
4001}

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

◆ name()

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

Definition at line 1359 of file SystemBase.C.

1360{
1361 return system().name();
1362}
const std::string & name() const

Referenced by NonlinearSystemBase::addBoundaryCondition(), NonlinearSystemBase::addConstraint(), NonlinearSystemBase::addDamper(), NonlinearSystemBase::addDGKernel(), NonlinearSystemBase::addDiracKernel(), NonlinearSystemBase::addHDGKernel(), NonlinearSystemBase::addInterfaceKernel(), AuxiliarySystem::addKernel(), addKernel(), NonlinearSystemBase::addKernel(), SystemBase::addMatrix(), NonlinearSystemBase::addNodalKernel(), Moose::PetscSupport::addPetscOptionsFromCommandline(), AuxiliarySystem::addScalarKernel(), NonlinearSystemBase::addScalarKernel(), NonlinearSystemBase::addSplit(), SystemBase::addTimeIntegrator(), AuxiliarySystem::addVariable(), SystemBase::addVector(), DiffusionLHDGAssemblyHelper::checkCoupling(), LinearFVGradientManager::checkRestartedGradientHistory(), SystemBase::closeTaggedVector(), LinearSystem::computeLinearSystemTags(), DisplacedProblem::DisplacedProblem(), SystemBase::getMatrix(), SystemBase::getMatrix(), NonlinearSystemBase::getSplit(), SystemBase::getVector(), DisplacedSystem::getVector(), DisplacedSystem::getVector(), SystemBase::getVector(), SystemBase::getVector(), SystemBase::hasVector(), LinearSystem::initialSetup(), NonlinearEigenSystem::postAddResidualObject(), MooseStaticCondensationPreconditioner::prefix(), SystemBase::removeMatrix(), SystemBase::removeVector(), SystemBase::removeVector(), LinearFVGradientManager::resizeGradientStateStorage(), NonlinearSystemBase::setupScalingData(), SystemBase::solutionState(), LinearSystem::solve(), LinearFVGradientReader::stateComponents(), NonlinearSystemBase::subdomainSetup(), LinearTimeIntegratorInterface::timeDerivativeMatrixContribution(), LinearTimeIntegratorInterface::timeDerivativeRHSContribution(), AuxiliarySystem::updateFVGradient(), LinearFVGradientManager::updateFVGradient(), and SystemBase::zeroTaggedVector().

◆ 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 3912 of file NonlinearSystemBase.C.

3913{
3914 // IntegratedBCs are for now the only objects we consider to be consuming
3915 // matprops on boundaries.
3917 for (const auto & bc : _integrated_bcs.getActiveBoundaryObjects(bnd_id, tid))
3918 if (std::static_pointer_cast<MaterialPropertyInterface>(bc)->getMaterialPropertyCalled())
3919 return true;
3920
3921 // Thin layer heat transfer in the heat_transfer module is being used on a boundary even though
3922 // it's an interface kernel. That boundary is external, on both sides of a gap in a mesh
3924 for (const auto & ik : _interface_kernels.getActiveBoundaryObjects(bnd_id, tid))
3925 if (std::static_pointer_cast<MaterialPropertyInterface>(ik)->getMaterialPropertyCalled())
3926 return true;
3927
3928 // Because MortarConstraints do not inherit from BoundaryRestrictable, they are not sorted
3929 // by boundary in the MooseObjectWarehouse. So for now, we return true for all boundaries
3930 // Note: constraints are not threaded at this time
3931 if (_constraints.hasActiveObjects(/*tid*/ 0))
3932 for (const auto & ct : _constraints.getActiveObjects(/*tid*/ 0))
3934 mpi && mpi->getMaterialPropertyCalled())
3935 return true;
3936 return false;
3937}
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.
An interface for accessing Materials.
virtual bool getMaterialPropertyCalled() const
Returns true if getMaterialProperty() has been called, false otherwise.

◆ 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 3940 of file NonlinearSystemBase.C.

3941{
3942 // InterfaceKernels are for now the only objects we consider to be consuming matprops on internal
3943 // boundaries.
3945 for (const auto & ik : _interface_kernels.getActiveBoundaryObjects(bnd_id, tid))
3946 if (std::static_pointer_cast<MaterialPropertyInterface>(ik)->getMaterialPropertyCalled())
3947 return true;
3948 return false;
3949}

◆ needInternalNeighborSideMaterial()

bool NonlinearSystemBase::needInternalNeighborSideMaterial ( 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 3952 of file NonlinearSystemBase.C.

3953{
3954 // DGKernels are for now the only objects we consider to be consuming matprops on
3955 // internal sides.
3956 if (_dg_kernels.hasActiveBlockObjects(subdomain_id, tid))
3957 for (const auto & dg : _dg_kernels.getActiveBlockObjects(subdomain_id, tid))
3958 if (std::static_pointer_cast<MaterialPropertyInterface>(dg)->getMaterialPropertyCalled())
3959 return true;
3960 // NOTE:
3961 // HDG kernels do not require face material properties on internal sides at this time.
3962 // The idea is to have element locality of HDG for hybridization
3963 return false;
3964}

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

1487{
1488 libmesh_parallel_only(this->comm());
1489 mooseAssert(!Threads::in_threads,
1490 "This routine is not thread-safe. Request the solution state before using it in "
1491 "a threaded region.");
1492
1493 if (hasSolutionState(state, iteration_type))
1494 return;
1495
1496 auto & solution_states = getSolutionStates(iteration_type);
1497 solution_states.resize(state + 1);
1498
1499 // The 0-th (current) solution state is owned by libMesh
1500 if (!solution_states[0])
1501 solution_states[0] = &solutionInternal();
1502 else
1503 mooseAssert(solution_states[0] == &solutionInternal(), "Inconsistent current solution");
1504
1505 // We will manually add all states past current
1506 for (unsigned int i = 1; i <= state; ++i)
1507 if (!solution_states[i])
1508 {
1509 auto tag = _subproblem.addVectorTag(oldSolutionStateVectorName(i, iteration_type),
1511 solution_states[i] = &addVector(tag, true, parallel_type);
1512 }
1513 else
1514 {
1515 // If the existing parallel type is PARALLEL and GHOSTED is now requested,
1516 // this would require an upgrade, which is risky if anybody has already
1517 // stored a pointer to the existing vector, since the upgrade would create
1518 // a new vector and make that pointer null. If the existing parallel type
1519 // is GHOSTED and PARALLEL is now requested, we don't need to do anything.
1520 if (parallel_type == GHOSTED && solutionStateParallelType(i, iteration_type) == PARALLEL)
1521 mooseError("The solution state has already been declared as PARALLEL");
1522
1523 mooseAssert(solution_states[i] == &getVector(oldSolutionStateVectorName(i, iteration_type)),
1524 "Inconsistent solution state");
1525 }
1526}
virtual NumericVector< Number > & solutionInternal() const =0
Internal getter for solution owned by libMesh.
TagName oldSolutionStateVectorName(const unsigned int, Moose::SolutionIterationType iteration_type) const
Gets the vector name used for an old (not current) solution state.
@ VECTOR_TAG_SOLUTION

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

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

898{
899 unsigned int n = 0;
900 for (auto & var : _vars[0].fieldVariables())
901 n += var->count();
902
903 return n;
904}

Referenced by SystemBase::nVariables().

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

908{
909 unsigned int n = 0;
910 for (auto & var : _vars[0].fieldVariables())
911 if (var->isFV())
912 n += var->count();
913
914 return n;
915}

◆ nLinearIterations()

virtual unsigned int NonlinearSystemBase::nLinearIterations ( ) const
inlinevirtualinherited

Return the number of linear iterations.

Reimplemented in NonlinearEigenSystem.

Definition at line 571 of file NonlinearSystemBase.h.

571{ return _n_linear_iters; }

Referenced by IterationAdaptiveDT::acceptStep().

◆ nNonlinearIterations()

virtual unsigned int NonlinearSystemBase::nNonlinearIterations ( ) const
inlinevirtualinherited

Return the number of non-linear iterations.

Reimplemented in NonlinearEigenSystem.

Definition at line 566 of file NonlinearSystemBase.h.

566{ return _n_iters; }

Referenced by IterationAdaptiveDT::acceptStep().

◆ nonlinearNorm()

Real NonlinearSystemBase::nonlinearNorm ( ) const
inlineinherited

Return the last nonlinear norm.

Returns
A Real containing the last computed residual norm

Definition at line 587 of file NonlinearSystemBase.h.

Referenced by Console::writeVariableNorms().

◆ nonlinearSolver()

virtual libMesh::NonlinearSolver< Number > * NonlinearSystem::nonlinearSolver ( )
inlineoverridevirtualinherited

◆ nonTimeVectorTag()

TagID NonlinearSystemBase::nonTimeVectorTag ( ) const
inlineoverridevirtualinherited

Reimplemented from SystemBase.

Definition at line 711 of file NonlinearSystemBase.h.

711{ return _Re_non_time_tag; }

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

◆ nResidualEvaluations()

unsigned int NonlinearSystemBase::nResidualEvaluations ( ) const
inlineinherited

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

Definition at line 576 of file NonlinearSystemBase.h.

576{ return _n_residual_evaluations; }

Referenced by NumResidualEvaluations::getValue().

◆ number()

unsigned int SystemBase::number ( ) const
inherited

Gets the number of this system.

Returns
The number of this system

Definition at line 1154 of file SystemBase.C.

1155{
1156 return system().number();
1157}

Referenced by SetupResidualDebugAction::act(), FEProblemBase::addCachedResidualDirectly(), FEProblemBase::addJacobian(), FEProblemBase::addJacobianBlockTags(), FEProblemBase::addJacobianLowerD(), FEProblemBase::addJacobianNeighbor(), FEProblemBase::addJacobianNeighborLowerD(), FEProblemBase::addJacobianOffDiagScalar(), FEProblemBase::addJacobianScalar(), FEProblemBase::addObjectParamsHelper(), FEProblemBase::addResidual(), FEProblemBase::addResidualLower(), FEProblemBase::addResidualNeighbor(), FEProblemBase::addResidualScalar(), SystemBase::addScalingVector(), ADKernelTempl< T >::ADKernelTempl(), ElementSubdomainModifierBase::applyIC(), ArrayKernel::ArrayKernel(), NonlinearSystemBase::assembleScalingVector(), NonlinearEigenSystem::attachPreconditioner(), DiffusionLHDGAssemblyHelper::checkCoupling(), FVFluxBC::checkFaceIntegrity(), SolverSystem::compute(), ComputeResidualAndJacobianThread::compute(), MooseVariableScalar::computeAD(), FEProblemBase::computeBounds(), Assembly::computeFaceMap(), InternalSideIndicatorBase::computeIndicator(), ArrayNodalBC::computeJacobian(), NodalBC::computeJacobian(), VectorNodalBC::computeJacobian(), MortarScalarBase::computeJacobian(), ODEKernel::computeJacobian(), FVInterfaceKernel::computeJacobian(), FVFluxKernel::computeJacobian(), FVBoundaryScalarLagrangeMultiplierConstraint::computeJacobian(), FEProblemBase::computeJacobianBlock(), NonlinearSystemBase::computeJacobianInternal(), LinearSystem::computeLinearSystemInternal(), FEProblemBase::computeNearNullSpace(), NonlinearSystemBase::computeNodalBCsJacobian(), NonlinearSystemBase::computeNodalBCsResidualAndJacobian(), FEProblemBase::computeNullSpace(), ArrayNodalBC::computeOffDiagJacobian(), NodalBC::computeOffDiagJacobian(), VectorNodalBC::computeOffDiagJacobian(), NodalKernel::computeOffDiagJacobian(), ComputeFullJacobianThread::computeOnBoundary(), ComputeFullJacobianThread::computeOnElement(), ComputeFullJacobianThread::computeOnInterface(), ComputeFullJacobianThread::computeOnInternalFace(), FEProblemBase::computePostCheck(), FVInterfaceKernel::computeResidual(), FVFluxKernel::computeResidual(), FVBoundaryScalarLagrangeMultiplierConstraint::computeResidual(), IntegratedBC::computeResidualAndJacobian(), NodalBC::computeResidualAndJacobian(), Kernel::computeResidualAndJacobian(), KernelScalarBase::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(), ComputeResidualAndJacobianThread::determineObjectWarehouses(), ComputeResidualThread::determineObjectWarehouses(), Moose::doDerivatives(), GreaterThanLessThanPostprocessor::execute(), VariableResidual::execute(), NodalNormalsCorner::execute(), NodalNormalsEvaluator::execute(), NodalNormalsPreprocessor::execute(), ExplicitTimeIntegrator::ExplicitTimeIntegrator(), InternalSideIndicatorBase::finalize(), NumNonlinearIterations::finalize(), NonlinearEigenSystem::finalNonlinearResidual(), FunctorNodalCorrector::FunctorNodalCorrector(), BoundsBase::getDoFIndex(), NonlinearSystemBase::getFVSetupObjects(), NonlinearSystemBase::getNodeDofs(), NonlinearEigenSystem::getSNES(), SystemBase::getSubdomainsForVar(), NumLinearIterations::getValue(), NumResidualEvaluations::getValue(), Residual::getValue(), Moose::globalDofIndexToDerivative(), FVBoundaryCondition::hasFaceSide(), ExplicitTimeIntegrator::init(), AttribSysNum::initFrom(), AuxKernelBase::initialSetup(), LinearSystem::initialSetup(), NonlinearSystemBase::initialSetup(), ExplicitTimeIntegrator::initialSetup(), ActivateElementsUserObjectBase::initSolutions(), EigenExecutionerBase::inversePowerIteration(), MooseMesh::isTranslatedPeriodic(), Kernel::Kernel(), MooseMesh::minPeriodicDistance(), MooseMesh::minPeriodicVector(), Moose::SlepcSupport::mooseSlepcEigenFormFunctionA(), Moose::SlepcSupport::mooseSlepcEigenFormFunctionAB(), Moose::SlepcSupport::mooseSlepcEigenFormFunctionB(), Moose::SlepcSupport::mooseSlepcEigenFormJacobianA(), MooseStaticCondensationPreconditioner::MooseStaticCondensationPreconditioner(), MoveNodesByParsedExpressionModifier::MoveNodesByParsedExpressionModifier(), NonlinearEigenSystem::nLinearIterations(), NonlinearEigenSystem::nNonlinearIterations(), EigenExecutionerBase::nonlinearSolve(), ComputeDiracThread::onElement(), ComputeNodalKernelBCJacobiansThread::onNode(), ComputeNodalKernelJacobiansThread::onNode(), VariableResidualNormsDebugOutput::output(), Moose::PetscSupport::petscLinearConverged(), PhysicsBasedPreconditioner::PhysicsBasedPreconditioner(), PointwiseRenormalizeVector::PointwiseRenormalizeVector(), FEProblemBase::prepare(), FEProblemBase::prepareAssembly(), FEProblemBase::prepareAssemblyNeighbor(), SystemBase::prepareFace(), FEProblemBase::prepareFaceShapes(), FEProblemBase::prepareNeighborShapes(), FEProblemBase::prepareShapes(), MooseMesh::queryPeriodicDimensions(), FEProblemBase::reinitDirac(), FEProblemBase::reinitNeighborPhys(), FEProblemBase::reinitNeighborPhys(), FEProblemBase::reinitOffDiagScalars(), NonlinearSystem::residualAndJacobianTogether(), FEProblemBase::setResidual(), FEProblemBase::setResidualNeighbor(), PhysicsBasedPreconditioner::setup(), FVInterfaceKernel::setupData(), NonlinearSystemBase::shouldEvaluatePreSMOResidual(), NonlinearEigenSystem::solve(), ActuallyExplicitEuler::solve(), AStableDirk4::solve(), ExplicitRK2::solve(), ExplicitTVDRK2::solve(), ImplicitMidpoint::solve(), LStableDirk2::solve(), LStableDirk3::solve(), LStableDirk4::solve(), ExplicitSSPRungeKutta::solveStage(), UserObjectBase::systemNumber(), MultiAppDofCopyTransfer::transferDofObject(), FVQpFluxBC::uOnGhost(), FVQpFluxBC::uOnUSub(), NodalDamper::variableDefinedOnNode(), and MortarConstraintBase::zeroInactiveLMDofs().

◆ nVariables()

unsigned int SystemBase::nVariables ( ) const
virtualinherited

Get the number of variables in this system.

Returns
the number of variables

Definition at line 888 of file SystemBase.C.

889{
890 unsigned int n = nFieldVariables();
891 n += _vars[0].scalars().size();
892
893 return n;
894}
unsigned int nFieldVariables() const
Get the number of field variables in this system.
Definition SystemBase.C:897

Referenced by AdaptivityAction::act(), FiniteDifferencePreconditioner::FiniteDifferencePreconditioner(), NonlinearSystemBase::getNodeDofs(), ExplicitTimeIntegrator::initialSetup(), MaxVarNDofsPerElem::onElement(), MaxVarNDofsPerNode::onNode(), PhysicsBasedPreconditioner::PhysicsBasedPreconditioner(), SingleMatrixPreconditioner::SingleMatrixPreconditioner(), and AuxiliarySystem::variableWiseRelativeSolutionDifferenceNorm().

◆ offDiagonalsInAutoScaling() [1/2]

bool NonlinearSystemBase::offDiagonalsInAutoScaling ( ) const
inlineinherited

◆ offDiagonalsInAutoScaling() [2/2]

void NonlinearSystemBase::offDiagonalsInAutoScaling ( bool  off_diagonals_in_auto_scaling)
inlineinherited

Definition at line 748 of file NonlinearSystemBase.h.

749 {
750 _off_diagonals_in_auto_scaling = off_diagonals_in_auto_scaling;
751 }

◆ oldSolutionStateVectorName()

TagName SystemBase::oldSolutionStateVectorName ( const unsigned int  state,
Moose::SolutionIterationType  iteration_type 
) const
privateinherited

Gets the vector name used for an old (not current) solution state.

Definition at line 1400 of file SystemBase.C.

1402{
1403 mooseAssert(state != 0, "Not an old state");
1404 mooseAssert(static_cast<unsigned short>(iteration_type) <
1405 static_cast<unsigned short>(Moose::SolutionIterationType::Count),
1406 "Invalid iteration_type");
1407
1408 switch (iteration_type)
1409 {
1411 if (state == 1)
1413 else if (state == 2)
1415 break;
1417 if (state == 1)
1419 break;
1421 if (state == 1)
1423 break;
1425 if (state == 1)
1427 break;
1429 break;
1430 }
1431
1432 return "solution_state_" + std::to_string(state) + "_" + Moose::stringify(iteration_type);
1433}
const TagName PREVIOUS_MULTISYSTEM_FP_SOLUTION_TAG
Definition MooseTypes.C:30
const TagName OLDER_SOLUTION_TAG
Definition MooseTypes.C:27
const TagName PREVIOUS_NL_SOLUTION_TAG
Definition MooseTypes.C:28
const TagName PREVIOUS_MULTIAPP_FP_SOLUTION_TAG
Definition MooseTypes.C:29
const TagName OLD_SOLUTION_TAG
Definition MooseTypes.C:26

Referenced by SystemBase::needSolutionState(), and SystemBase::solutionState().

◆ onTimestepBegin()

void NonlinearSystemBase::onTimestepBegin ( )
inherited

Called at the beginning of the time step.

Definition at line 918 of file NonlinearSystemBase.C.

919{
920 for (auto & ti : _time_integrators)
921 ti->preSolve();
922 if (_predictor.get())
923 _predictor->timestepSetup();
924}
bool preSolve()
Perform some steps to get ready for the solver.

◆ 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 1650 of file NonlinearSystemBase.C.

1651{
1652 // Overwrite results from integrator in case we have explicit dynamics contact constraints
1654 ? cast_ref<SubProblem &>(*_fe_problem.getDisplacedProblem())
1656 const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
1657
1658 for (const auto & it : penetration_locators)
1659 {
1660 PenetrationLocator & pen_loc = *(it.second);
1661
1662 const auto & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
1663 const BoundaryID secondary_boundary = pen_loc._secondary_boundary;
1664 const BoundaryID primary_boundary = pen_loc._primary_boundary;
1665
1666 if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, true))
1667 {
1668 const auto & constraints =
1669 _constraints.getActiveNodeFaceConstraints(secondary_boundary, true);
1670 for (const auto i : index_range(secondary_nodes))
1671 {
1672 const auto secondary_node_num = secondary_nodes[i];
1673 const Node & secondary_node = _mesh.nodeRef(secondary_node_num);
1674
1675 if (secondary_node.processor_id() == processor_id())
1676 if (pen_loc._penetration_info[secondary_node_num])
1677 for (const auto & nfc : constraints)
1678 {
1679 if (!nfc->isExplicitConstraint())
1680 continue;
1681
1682 // Return if this constraint does not correspond to the primary-secondary pair
1683 // prepared by the outer loops.
1684 // This continue statement is required when, e.g. one secondary surface constrains
1685 // more than one primary surface.
1686 if (nfc->secondaryBoundary() != secondary_boundary ||
1687 nfc->primaryBoundary() != primary_boundary)
1688 continue;
1689
1690 nfc->overwriteBoundaryVariables(soln, secondary_node);
1691 }
1692 }
1693 }
1694 }
1695 soln.close();
1696}

Referenced by ActuallyExplicitEuler::solve().

◆ perfGraph()

PerfGraph & PerfGraphInterface::perfGraph ( )
inherited

Get the PerfGraph.

Definition at line 86 of file PerfGraphInterface.C.

87{
88 return _pg_moose_app.perfGraph();
89}
PerfGraph & perfGraph()
Get the PerfGraph for this app.
Definition MooseApp.h:179
MooseApp & _pg_moose_app
The MooseApp that owns the PerfGraph.

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

◆ postAddResidualObject()

virtual void NonlinearSystemBase::postAddResidualObject ( ResidualObject &  )
inlineprotectedvirtualinherited

◆ postInit()

virtual void SystemBase::postInit ( )
inlinevirtualinherited

Reimplemented in NonlinearEigenSystem.

Definition at line 163 of file SystemBase.h.

163{}

Referenced by NonlinearEigenSystem::postInit().

◆ potentiallySetupFiniteDifferencing()

void NonlinearSystem::potentiallySetupFiniteDifferencing ( )
overridevirtualinherited

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

Definition at line 123 of file NonlinearSystem.C.

124{
126 {
129 }
130
132 cast_ref<libMesh::PetscNonlinearSolver<Real> &>(*_nl_implicit_sys.nonlinear_solver);
134
136}
bool useSNESMFReuseBase()
Return a flag that indicates if we are reusing the vector base.
virtual void setupFiniteDifferencedPreconditioner() override
ComputeFDResidualFunctor _fd_residual_functor
NonlinearImplicitSystem::ComputeResidual * mffd_residual_object
void set_snesmf_reuse_base(bool state)

Referenced by NonlinearSystem::solve().

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

1735{
1736 return system().prefix_with_name() ? system().prefix() : "";
1737}

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

◆ 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 218 of file NonlinearSystemBase.C.

219{
221
223 setupDampers();
224
225 if (_residual_copy.get())
226 _residual_copy->init(_sys.n_dofs(), false, SERIAL);
227
228#ifdef MOOSE_KOKKOS_ENABLED
231#endif
232}
bool hasDampers()
Whether or not this system has dampers.
void setupDampers()
Setup damping stuff (called before we actually start)
virtual void preInit() override
This is called prior to the libMesh system has been init'd.
void full_sparsity_pattern_needed()
dof_id_type n_dofs() const

◆ prepare()

void SystemBase::prepare ( THREAD_ID  tid)
virtualinherited

Prepare the system for use.

Parameters
tidID of the thread

Definition at line 255 of file SystemBase.C.

256{
258 {
259 const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
261 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
262 for (const auto & var : vars)
263 var->clearDofIndices();
264
265 for (const auto & var : active_elemental_moose_variables)
266 if (&(var->sys()) == this)
267 var->prepare();
268 }
269 else
270 {
271 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
272 for (const auto & var : vars)
273 var->prepare();
274 }
275}
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition SubProblem.C:443
virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition SubProblem.C:449
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:255

Referenced by SubProblem::reinitElemFaceRef().

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

279{
280 // We only need to do something if the element prepare was restricted
282 {
283 const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
285
286 std::vector<MooseVariableFieldBase *> newly_prepared_vars;
287
288 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
289 for (const auto & var : vars)
290 {
291 mooseAssert(&var->sys() == this,
292 "I will cry if we store variables in our warehouse that don't belong to us");
293
294 // If it wasn't in the active list, we need to prepare it. This has the potential to duplicate
295 // prepare if we have these conditions:
296 //
297 // 1. We have a displaced problem
298 // 2. We are using AD
299 // 3. We are not using global AD indexing
300 //
301 // But I think I would rather risk duplicate prepare than introduce an additional member set
302 // variable for tracking prepared variables. Set insertion is slow and some simulations have a
303 // ton of variables
304 if (!active_elemental_moose_variables.count(var))
305 {
306 var->prepare();
307 newly_prepared_vars.push_back(var);
308 }
309 }
310
311 // Make sure to resize the residual and jacobian datastructures for all the new variables
312 if (resize_data)
313 for (const auto var_ptr : newly_prepared_vars)
314 {
318 }
319 }
320}
void prepareVariableNonlocal(MooseVariableFieldBase *var)
Definition Assembly.C:2817
void prepareVariable(MooseVariableFieldBase *var)
Used for preparing the dense residual and jacobian blocks for one particular variable.
Definition Assembly.C:2787
virtual bool checkNonlocalCouplingRequirement() const =0

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

332{
333 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
334 for (const auto & var : vars)
335 var->prepareLowerD();
336}
virtual void prepareLowerD(THREAD_ID tid)
Prepare the system for use for lower dimensional elements.
Definition SystemBase.C:331

Referenced by SubProblem::reinitLowerDElem().

◆ prepareNeighbor()

void SystemBase::prepareNeighbor ( THREAD_ID  tid)
virtualinherited

Prepare the system for use.

Parameters
tidID of the thread

Definition at line 323 of file SystemBase.C.

324{
325 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
326 for (const auto & var : vars)
327 var->prepareNeighbor();
328}
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:323

Referenced by SubProblem::reinitNeighborFaceRef().

◆ preSMOResidual()

Real NonlinearSystemBase::preSMOResidual ( ) const
inherited

The pre-SMO residual.

Definition at line 746 of file NonlinearSystemBase.C.

747{
749 mooseError("pre-SMO residual is requested but not evaluated.");
750
751 return _pre_smo_residual;
752}
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.

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

◆ 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 4282 of file NonlinearSystemBase.C.

4283{
4284 // Clear the iteration counters
4285 _current_l_its.clear();
4286 _current_nl_its = 0;
4287
4288 // Initialize the solution vector using a predictor and known values from nodal bcs
4290
4291 // Now that the initial solution has ben set, potentially perform a residual/Jacobian evaluation
4292 // to determine variable scaling factors
4294 {
4295 const bool scaling_succeeded = computeScaling();
4296 if (!scaling_succeeded)
4297 return false;
4298 }
4299
4300 // We do not know a priori what variable a global degree of freedom corresponds to, so we need a
4301 // map from global dof to scaling factor. We just use a ghosted NumericVector for that mapping
4303
4305
4306 return true;
4307}
virtual void preSolve()
Method that gets called in each iteration before the solve.
Definition Convergence.h:58
Convergence & convergence()
Retrieves the associated Convergence object.
bool computeScaling()
Method used to obtain scaling factors for variables.
std::vector< unsigned int > _current_l_its

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

◆ 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 593 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 1694 of file SystemBase.C.

1695{
1696 for (auto & ti : _time_integrators)
1697 if (ti->integratesVar(var_num))
1698 return ti.get();
1699
1700 return nullptr;
1701}
const Elem & get(const ElemType type_in)

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

◆ referenceResidual()

Real NonlinearSystemBase::referenceResidual ( ) const
inherited

The reference residual used in relative convergence check.

Definition at line 740 of file NonlinearSystemBase.C.

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

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

◆ 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 61 of file PerfGraphInterface.C.

63{
64 const auto timed_section_name = timedSectionName(section_name);
65 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
66 return moose::internal::getPerfGraphRegistry().registerSection(timed_section_name, level);
67 else
68 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
69}
std::string timedSectionName(const std::string &section_name) const
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID @section_name The name of the section.
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
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 72 of file PerfGraphInterface.C.

76{
77 const auto timed_section_name = timedSectionName(section_name);
78 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
80 timedSectionName(section_name), level, live_message, print_dots);
81 else
82 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
83}

◆ 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 AuxiliarySystem, LinearSystem, and NonlinearEigenSystem.

Definition at line 169 of file SystemBase.h.

169{}

Referenced by NonlinearEigenSystem::reinit().

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

340{
342 {
343 const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
345 for (const auto & var : active_elemental_moose_variables)
346 if (&(var->sys()) == this)
347 var->computeElemValues();
348 }
349 else
350 {
351 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
352 for (const auto & var : vars)
353 var->computeElemValues();
354 }
355
356 if (system().has_static_condensation())
357 for (auto & [tag, matrix] : _active_tagged_matrices)
358 {
359 libmesh_ignore(tag);
360 cast_ptr<libMesh::StaticCondensation *>(matrix)->set_current_elem(*elem);
361 }
362}
void libmesh_ignore(const Args &...)

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

366{
367 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
368 for (const auto & var : vars)
369 var->computeElemValuesFace();
370}

Referenced by SubProblem::reinitElemFaceRef().

◆ 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 3723 of file NonlinearSystemBase.C.

3725{
3726 for (const auto & var : damped_vars)
3727 var->computeIncrementAtNode(*_increment_vec);
3728}

Referenced by ComputeNodalDampingThread::onNode().

◆ 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 3715 of file NonlinearSystemBase.C.

3717{
3718 for (const auto & var : damped_vars)
3719 var->computeIncrementAtQps(*_increment_vec);
3720}

Referenced by ComputeElemDampingThread::onElement().

◆ reinitLowerD()

void SystemBase::reinitLowerD ( THREAD_ID  tid)
virtualinherited

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

Definition at line 389 of file SystemBase.C.

390{
391 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
392 for (const auto & var : vars)
393 var->computeLowerDValues();
394}

Referenced by SubProblem::reinitLowerDElem().

◆ reinitMortarFunctors()

void NonlinearSystemBase::reinitMortarFunctors ( )
inherited

Update the mortar functors if the mesh has changed.

Definition at line 235 of file NonlinearSystemBase.C.

236{
237 // reinit is called on meshChanged() in FEProblemBase. We could implement meshChanged() instead.
238 // Subdomains might have changed
239 for (auto & functor : _displaced_mortar_functors)
240 functor.second.setupMortarMaterials();
241 for (auto & functor : _undisplaced_mortar_functors)
242 functor.second.setupMortarMaterials();
243}
void setupMortarMaterials(const Consumers &consumers, FEProblemBase &fe_problem, const AutomaticMortarGeneration &amg, const THREAD_ID tid, std::map< SubdomainID, std::deque< MaterialBase * > > &secondary_ip_sub_to_mats, std::map< SubdomainID, std::deque< MaterialBase * > > &primary_ip_sub_to_mats, std::deque< MaterialBase * > &secondary_boundary_mats)
This function creates containers of materials necessary to execute the mortar method for a supplied s...

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

382{
383 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
384 for (const auto & var : vars)
385 var->computeNeighborValues();
386}

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

374{
375 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
376 for (const auto & var : vars)
377 var->computeNeighborValuesFace();
378}

Referenced by SubProblem::reinitNeighborFaceRef().

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

398{
399 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
400 for (const auto & var : vars)
401 {
402 var->reinitNode();
403 if (var->isNodalDefined())
404 var->computeNodalValues();
405 }
406}

◆ reinitNodeFace() [1/2]

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 1130 of file NonlinearSystemBase.C.

1134{
1135 auto & subproblem = displaced ? cast_ref<SubProblem &>(*_fe_problem.getDisplacedProblem())
1137
1138 const Elem * primary_elem = info._elem;
1139 unsigned int primary_side = info._side_num;
1140 std::vector<Point> points;
1141 points.push_back(info._closest_point);
1142
1143 // *These next steps MUST be done in this order!*
1144 // ADL: This is a Chesterton's fence situation. I don't know which calls exactly the above comment
1145 // is referring to. If I had to guess I would guess just the reinitNodeFace and prepareAssembly
1146 // calls since the former will size the variable's dof indices and then the latter will resize the
1147 // residual/Jacobian based off the variable's cached dof indices size
1148
1149 // This reinits the variables that exist on the secondary node
1150 _fe_problem.reinitNodeFace(&secondary_node, secondary_boundary, 0);
1151
1152 // This will set aside residual and jacobian space for the variables that have dofs on
1153 // the secondary node
1155
1156 _fe_problem.setNeighborSubdomainID(primary_elem, 0);
1157
1158 //
1159 // Reinit material on undisplaced mesh
1160 //
1161
1162 const Elem * const undisplaced_primary_elem =
1163 displaced ? _mesh.elemPtr(primary_elem->id()) : primary_elem;
1164 const Point undisplaced_primary_physical_point =
1165 [&points, displaced, primary_elem, undisplaced_primary_elem]()
1166 {
1167 if (displaced)
1168 {
1169 const Point reference_point =
1170 FEMap::inverse_map(primary_elem->dim(), primary_elem, points[0]);
1171 return FEMap::map(primary_elem->dim(), undisplaced_primary_elem, reference_point);
1172 }
1173 else
1174 // If our penetration locator is on the reference mesh, then our undisplaced
1175 // physical point is simply the point coming from the penetration locator
1176 return points[0];
1177 }();
1178
1180 undisplaced_primary_elem, primary_side, {undisplaced_primary_physical_point}, 0);
1181 // Stateful material properties are only initialized for neighbor material data for internal faces
1182 // for discontinuous Galerkin methods or for conforming interfaces for interface kernels. We don't
1183 // have either of those use cases here where we likely have disconnected meshes
1184 _fe_problem.reinitMaterialsNeighbor(primary_elem->subdomain_id(), 0, /*swap_stateful=*/false);
1185
1186 // Reinit points for constraint enforcement
1187 if (displaced)
1188 subproblem.reinitNeighborPhys(primary_elem, primary_side, points, 0);
1189}
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid) override
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

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

◆ reinitNodeFace() [2/2]

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

Reimplemented from SystemBase.

Definition at line 742 of file SystemBase.C.

410{
411 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
412 for (const auto & var : vars)
413 {
414 var->reinitNode();
415 if (var->isNodalDefined())
416 var->computeNodalValues();
417 }
418}

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

422{
423 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
424 for (const auto & var : vars)
425 {
426 var->reinitNodes(nodes);
427 var->computeNodalValues();
428 }
429}

Referenced by SubProblem::reinitNodes().

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

433{
434 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
435 for (const auto & var : vars)
436 {
437 var->reinitNodesNeighbor(nodes);
438 var->computeNodalNeighborValues();
439 }
440}

Referenced by SubProblem::reinitNodesNeighbor().

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

444{
445 const std::vector<MooseVariableScalar *> & vars = _vars[tid].scalars();
446 for (const auto & var : vars)
447 var->reinit(reinit_for_derivative_reordering);
448}
virtual void reinit()
Reinitialize the system when the degrees of freedom in this system have changed.
Definition SystemBase.h:169

◆ removeMatrix()

void SystemBase::removeMatrix ( TagID  tag)
inherited

Removes a matrix with a given tag.

Parameters
tag_nameThe name of the tag

Definition at line 587 of file SystemBase.C.

588{
589 if (!_subproblem.matrixTagExists(tag_id))
590 mooseError("Cannot remove the matrix with TagID ",
591 tag_id,
592 "\nin system '",
593 name(),
594 "', because that tag does not exist in the problem");
595
596 if (hasMatrix(tag_id))
597 {
598 const auto matrix_name = _subproblem.matrixTagName(tag_id);
599 system().remove_matrix(matrix_name);
600 _tagged_matrices[tag_id] = nullptr;
601 }
602}
void remove_matrix(std::string_view mat_name)

◆ removeVector() [1/2]

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

Remove a vector from the system with the given name.

Definition at line 1353 of file SystemBase.C.

1354{
1356}
void remove_vector(std::string_view vec_name)

Referenced by SystemBase::restoreOldSolutions().

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

700{
701 if (!_subproblem.vectorTagExists(tag_id))
702 mooseError("Cannot remove the vector with TagID ",
703 tag_id,
704 "\nin system '",
705 name(),
706 "', because that tag does not exist in the problem");
707
708 if (hasVector(tag_id))
709 {
710 auto vector_name = _subproblem.vectorTagName(tag_id);
711 system().remove_vector(vector_name);
712 _tagged_vectors[tag_id] = nullptr;
713 }
714}

◆ residualAndJacobianTogether()

void NonlinearSystem::residualAndJacobianTogether ( )
overridevirtualinherited

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

Implements NonlinearSystemBase.

Definition at line 391 of file NonlinearSystem.C.

392{
395 "Evaluting the residual and Jacobian together does not make sense for a JFNK solve type in "
396 "which only function evaluations are required, e.g. there is no need to form a matrix");
397
398 nonlinearSolver()->residual_object = nullptr;
399 nonlinearSolver()->jacobian = nullptr;
400 nonlinearSolver()->residual_and_jacobian_object = &_resid_and_jac_functor;
401}
ComputeResidualAndJacobian _resid_and_jac_functor
@ ST_JFNK
Jacobian-Free Newton Krylov.
Definition MooseTypes.h:899

◆ residualCopy()

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

Reimplemented from SystemBase.

Definition at line 3570 of file NonlinearSystemBase.C.

3571{
3572 if (!_residual_copy.get())
3573 _residual_copy = NumericVector<Number>::build(_communicator);
3574
3575 return *_residual_copy;
3576}

◆ residualGhosted()

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

Reimplemented from SystemBase.

Definition at line 3579 of file NonlinearSystemBase.C.

3580{
3582 if (!_residual_ghosted)
3583 {
3584 // The first time we realize we need a ghosted residual vector,
3585 // we add it.
3586 _residual_ghosted = &addVector("residual_ghosted", false, GHOSTED);
3587
3588 // If we've already realized we need time and/or non-time
3589 // residual vectors, but we haven't yet realized they need to be
3590 // ghosted, fix that now.
3591 //
3592 // If an application changes its mind, the libMesh API lets us
3593 // change the vector.
3594 if (_Re_time)
3595 {
3596 const auto vector_name = _subproblem.vectorTagName(_Re_time_tag);
3597 _Re_time = &system().add_vector(vector_name, false, GHOSTED);
3598 }
3599 if (_Re_non_time)
3600 {
3601 const auto vector_name = _subproblem.vectorTagName(_Re_non_time_tag);
3602 _Re_non_time = &system().add_vector(vector_name, false, GHOSTED);
3603 }
3604 }
3605 return *_residual_ghosted;
3606}

◆ residualSetup()

void NonlinearSystemBase::residualSetup ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 1699 of file NonlinearSystemBase.C.

1700{
1701 TIME_SECTION("residualSetup", 3);
1702
1704
1705 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1706 {
1710 if (_doing_dg)
1716 }
1723
1724#ifdef MOOSE_KOKKOS_ENABLED
1729#endif
1730
1731 // Avoid recursion
1732 if (this == &_fe_problem.currentNonlinearSystem())
1734}
void residualSetup() override
virtual void residualSetup()

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

◆ residualVector()

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

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

Definition at line 1059 of file NonlinearSystemBase.C.

1060{
1061 mooseDeprecated("Please use getVector()");
1062 switch (tag)
1063 {
1064 case 0:
1065 return getResidualNonTimeVector();
1066
1067 case 1:
1068 return getResidualTimeVector();
1069
1070 default:
1071 mooseError("The required residual vector is not available");
1072 }
1073}
NumericVector< Number > & getResidualNonTimeVector()
Return a numeric vector that is associated with the nontime tag.
NumericVector< Number > & getResidualTimeVector()
Return a numeric vector that is associated with the time tag.

◆ residualVectorTag()

TagID NonlinearSystemBase::residualVectorTag ( ) const
inlineoverridevirtualinherited

◆ restoreAdditionalStates()

virtual void SystemBase::restoreAdditionalStates ( )
inlineprotectedvirtualinherited

Restore system-owned state not represented by solution vectors.

Default implementation does nothing.

Reimplemented in AuxiliarySystem, and LinearSystem.

Definition at line 1021 of file SystemBase.h.

1021{}

Referenced by SystemBase::restoreStateHistory().

◆ restoreOldSolutions()

void SystemBase::restoreOldSolutions ( )
virtualinherited

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

Definition at line 540 of file SystemBase.C.

541{
543 if (num_states > 1)
544 for (unsigned int i = 1; i <= num_states - 1; ++i)
546 {
548 removeVector("save_solution_state_" + std::to_string(i));
549 _saved_solution_states[i] = nullptr;
550 }
551
553 {
555 removeVector("save_solution_dot_old");
556 _saved_dot_old = nullptr;
557 }
559 {
561 removeVector("save_solution_dotdot_old");
562 _saved_dotdot_old = nullptr;
563 }
564}
void removeVector(const std::string &name)
Remove a vector from the system with the given name.
NumericVector< Real > * _saved_dotdot_old
NumericVector< Real > * _saved_dot_old
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)

◆ restoreSolutions()

void SolverSystem::restoreSolutions ( )
finaloverridevirtualinherited

Restore current solutions (call after your solve failed)

Reimplemented from SystemBase.

Definition at line 41 of file SolverSystem.C.

42{
43 // call parent
45 // and update _current_solution
47}
virtual void restoreSolutions()
Restore current solutions (call after your solve failed)
std::unique_ptr< NumericVector< Number > > current_local_solution

◆ restoreStateHistory()

void SystemBase::restoreStateHistory ( )
inherited

Restore solution vectors and additional system-owned state together.

Definition at line 1346 of file SystemBase.C.

1347{
1350}
virtual void restoreAdditionalStates()
Restore system-owned state not represented by solution vectors.

◆ RHS()

virtual NumericVector< Number > & NonlinearSystem::RHS ( )
inlineoverridevirtualinherited

Implements NonlinearSystemBase.

Definition at line 58 of file NonlinearSystem.h.

58{ return *_nl_implicit_sys.rhs; }
NumericVector< Number > * rhs

Referenced by NonlinearSystem::computeScalingResidual().

◆ saveOldSolutions()

void SystemBase::saveOldSolutions ( )
virtualinherited

Save the old and older solutions.

Definition at line 509 of file SystemBase.C.

510{
512 if (num_states > 1)
513 {
514 _saved_solution_states.resize(num_states);
515 for (unsigned int i = 1; i <= num_states - 1; ++i)
518 &addVector("save_solution_state_" + std::to_string(i), false, PARALLEL);
519
520 for (unsigned int i = 1; i <= num_states - 1; ++i)
522 }
523
525 _saved_dot_old = &addVector("save_solution_dot_old", false, PARALLEL);
527 _saved_dotdot_old = &addVector("save_solution_dotdot_old", false, PARALLEL);
528
529 if (solutionUDotOld())
531
532 if (solutionUDotDotOld())
534}

◆ scaleSystemSolution()

void MooseEigenSystem::scaleSystemSolution ( SYSTEMTAG  tag,
Real  scaling_factor 
)

Scale the solution vector.

Parameters
tagSystem tag.
factorThe scaling factor.

Definition at line 81 of file MooseEigenSystem.C.

82{
83 if (tag == ALL)
84 {
85 solution().scale(scaling_factor);
86 }
87 else if (tag == EIGEN)
88 {
90 {
91 solution().scale(scaling_factor);
92 }
93 else
94 {
95 for (const auto & dof : _eigen_var_indices)
96 solution().set(dof, solution()(dof) * scaling_factor);
97 }
98 }
99 solution().close();
100 update();
101}

Referenced by EigenExecutionerBase::makeBXConsistent(), and EigenExecutionerBase::normalizeSolution().

◆ scalingGroupVariables()

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

Definition at line 736 of file NonlinearSystemBase.h.

737 {
738 _scaling_group_variables = scaling_group_variables;
739 }
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 1667 of file SystemBase.C.

1668{
1669 if (!_serialized_solution.get())
1670 {
1671 _serialized_solution = NumericVector<Number>::build(_communicator);
1672 _serialized_solution->init(system().n_dofs(), false, SERIAL);
1673 }
1674
1675 return *_serialized_solution;
1676}
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed.

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

◆ serializeSolution()

void SolverSystem::serializeSolution ( )
inherited

Definition at line 50 of file SolverSystem.C.

51{
52 if (_serialized_solution.get())
53 {
54 if (!_serialized_solution->initialized() || _serialized_solution->size() != system().n_dofs())
55 {
56 _serialized_solution->clear();
57 _serialized_solution->init(system().n_dofs(), false, SERIAL);
58 }
59
61 }
62}

Referenced by SolverSystem::setSolution().

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

1649{
1650 _vars[tid].setActiveScalarVariableCoupleableVectorTags(vtags);
1651}

Referenced by SubProblem::setActiveScalarVariableCoupleableVectorTags().

◆ setActiveVariableCoupleableVectorTags()

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

Set the active vector tags for the variables.

Definition at line 1641 of file SystemBase.C.

1642{
1643 _vars[tid].setActiveVariableCoupleableVectorTags(vtags);
1644}

Referenced by SubProblem::setActiveFEVariableCoupleableVectorTags().

◆ setConstraintSecondaryValues()

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

Sets the value of constrained variables in the solution vector.

Definition at line 1192 of file NonlinearSystemBase.C.

1193{
1194
1195 if (displaced)
1196 mooseAssert(_fe_problem.getDisplacedProblem(),
1197 "If we're calling this method with displaced = true, then we better well have a "
1198 "displaced problem");
1199 auto & subproblem = displaced ? cast_ref<SubProblem &>(*_fe_problem.getDisplacedProblem())
1201 const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
1202
1203 bool constraints_applied = false;
1204
1205 for (const auto & it : penetration_locators)
1206 {
1207 PenetrationLocator & pen_loc = *(it.second);
1208
1209 std::vector<dof_id_type> & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
1210
1211 BoundaryID secondary_boundary = pen_loc._secondary_boundary;
1212 BoundaryID primary_boundary = pen_loc._primary_boundary;
1213
1214 if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, displaced))
1215 {
1216 const auto & constraints =
1217 _constraints.getActiveNodeFaceConstraints(secondary_boundary, displaced);
1218 std::unordered_set<unsigned int> needed_mat_props;
1219 for (const auto & constraint : constraints)
1220 {
1221 const auto & mp_deps = constraint->getMatPropDependencies();
1222 needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
1223 }
1224 _fe_problem.setActiveMaterialProperties(needed_mat_props, /*tid=*/0);
1225
1226 for (unsigned int i = 0; i < secondary_nodes.size(); i++)
1227 {
1228 dof_id_type secondary_node_num = secondary_nodes[i];
1229 Node & secondary_node = _mesh.nodeRef(secondary_node_num);
1230
1231 if (secondary_node.processor_id() == processor_id())
1232 {
1233 if (pen_loc._penetration_info[secondary_node_num])
1234 {
1235 PenetrationInfo & info = *pen_loc._penetration_info[secondary_node_num];
1236
1237 reinitNodeFace(secondary_node, secondary_boundary, info, displaced);
1238
1239 for (const auto & nfc : constraints)
1240 {
1241 if (nfc->isExplicitConstraint())
1242 continue;
1243 // Return if this constraint does not correspond to the primary-secondary pair
1244 // prepared by the outer loops.
1245 // This continue statement is required when, e.g. one secondary surface constrains
1246 // more than one primary surface.
1247 if (nfc->secondaryBoundary() != secondary_boundary ||
1248 nfc->primaryBoundary() != primary_boundary)
1249 continue;
1250
1251 if (nfc->shouldApply())
1252 {
1253 constraints_applied = true;
1254 nfc->computeSecondaryValue(solution);
1255 }
1256
1257 if (nfc->hasWritableCoupledVariables())
1258 {
1259 Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1260 for (auto * var : nfc->getWritableCoupledVariables())
1261 {
1262 if (var->isNodalDefined())
1263 var->insert(_fe_problem.getAuxiliarySystem().solution());
1264 }
1265 }
1266 }
1267 }
1268 }
1269 }
1270 }
1271 }
1272
1273 // go over NodeELemConstraints
1274 std::set<dof_id_type> unique_secondary_node_ids;
1275
1276 for (const auto & secondary_id : _mesh.meshSubdomains())
1277 {
1278 for (const auto & primary_id : _mesh.meshSubdomains())
1279 {
1280 if (_constraints.hasActiveNodeElemConstraints(secondary_id, primary_id, displaced))
1281 {
1282 const auto & constraints =
1283 _constraints.getActiveNodeElemConstraints(secondary_id, primary_id, displaced);
1284
1285 // get unique set of ids of all nodes on current block
1286 unique_secondary_node_ids.clear();
1287 const MeshBase & meshhelper = _mesh.getMesh();
1288 for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
1289 meshhelper.active_subdomain_elements_end(secondary_id)))
1290 {
1291 for (auto & n : elem->node_ref_range())
1292 unique_secondary_node_ids.insert(n.id());
1293 }
1294
1295 for (auto secondary_node_id : unique_secondary_node_ids)
1296 {
1297 Node & secondary_node = _mesh.nodeRef(secondary_node_id);
1298
1299 // check if secondary node is on current processor
1300 if (secondary_node.processor_id() == processor_id())
1301 {
1302 // This reinits the variables that exist on the secondary node
1303 _fe_problem.reinitNodeFace(&secondary_node, secondary_id, 0);
1304
1305 // This will set aside residual and jacobian space for the variables that have dofs
1306 // on the secondary node
1308
1309 for (const auto & nec : constraints)
1310 {
1311 if (nec->shouldApply())
1312 {
1313 constraints_applied = true;
1314 nec->computeSecondaryValue(solution);
1315 }
1316 }
1317 }
1318 }
1319 }
1320 }
1321 }
1322
1323 // See if constraints were applied anywhere
1324 _communicator.max(constraints_applied);
1325
1326 if (constraints_applied)
1327 {
1328 solution.close();
1329 update();
1330 }
1331}
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.

Referenced by NonlinearSystemBase::setInitialSolution().

◆ setConvergenceName()

void NonlinearSystemBase::setConvergenceName ( const ConvergenceName &  convergence_name)
inlineinherited

Sets the name of the associated Convergence object.

Definition at line 778 of file NonlinearSystemBase.h.

779 {
780 _convergence_name = convergence_name;
781 }

◆ setInitialResidual()

void NonlinearSystemBase::setInitialResidual ( Real  r)
inherited

Record the initial residual (for later relative convergence check)

Definition at line 761 of file NonlinearSystemBase.C.

762{
764}

Referenced by DefaultNonlinearConvergence::checkConvergence().

◆ setInitialSolution()

void NonlinearSystemBase::setInitialSolution ( )
inherited

Definition at line 927 of file NonlinearSystemBase.C.

928{
930
931 NumericVector<Number> & initial_solution(solution());
932 if (_predictor.get())
933 {
934 if (_predictor->shouldApply())
935 {
936 TIME_SECTION("applyPredictor", 2, "Applying Predictor");
937
938 _predictor->apply(initial_solution);
939 _fe_problem.predictorCleanup(initial_solution);
940 }
941 else
942 _console << " Skipping predictor this step" << std::endl;
943 }
944
945 // do nodal BC
946 {
947 TIME_SECTION("initialBCs", 2, "Applying BCs To Initial Condition");
948
950 for (const auto & bnode : bnd_nodes)
951 {
952 BoundaryID boundary_id = bnode->_bnd_id;
953 Node * node = bnode->_node;
954
955 if (node->processor_id() == processor_id())
956 {
957 bool has_preset_nodal_bcs = _preset_nodal_bcs.hasActiveBoundaryObjects(boundary_id);
958 bool has_ad_preset_nodal_bcs = _ad_preset_nodal_bcs.hasActiveBoundaryObjects(boundary_id);
959
960 // reinit variables in nodes
961 if (has_preset_nodal_bcs || has_ad_preset_nodal_bcs)
962 _fe_problem.reinitNodeFace(node, boundary_id, 0);
963
964 if (has_preset_nodal_bcs)
965 {
966 const auto & preset_bcs = _preset_nodal_bcs.getActiveBoundaryObjects(boundary_id);
967 for (const auto & preset_bc : preset_bcs)
968 preset_bc->computeValue(initial_solution);
969 }
970 if (has_ad_preset_nodal_bcs)
971 {
972 const auto & preset_bcs_res = _ad_preset_nodal_bcs.getActiveBoundaryObjects(boundary_id);
973 for (const auto & preset_bc : preset_bcs_res)
974 preset_bc->computeValue(initial_solution);
975 }
976 }
977 }
978 }
979
980#ifdef MOOSE_KOKKOS_ENABLED
983#endif
984
985 _sys.solution->close();
986 update();
987
988 // Set constraint secondary values
989 setConstraintSecondaryValues(initial_solution, false);
990
992 setConstraintSecondaryValues(initial_solution, true);
993}
virtual void predictorCleanup(NumericVector< libMesh::Number > &ghosted_solution)
Perform cleanup tasks after application of predictor to solution vector.
bool hasObjects(THREAD_ID tid=0) const
Convenience functions for determining if objects exist.
void setKokkosInitialSolution()
MooseObjectWarehouse< ResidualObject > _kokkos_preset_nodal_bcs
void setConstraintSecondaryValues(NumericVector< Number > &solution, bool displaced)
Sets the value of constrained variables in the solution vector.
std::unique_ptr< NumericVector< Number > > solution

Referenced by NonlinearSystemBase::preSolve().

◆ setKokkosInitialSolution()

void NonlinearSystemBase::setKokkosInitialSolution ( )
inherited

◆ 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 115 of file SolverSystem.C.

116{
117 if (kspnorm == "none")
119 else if (kspnorm == "preconditioned")
121 else if (kspnorm == "unpreconditioned")
123 else if (kspnorm == "natural")
125 else if (kspnorm == "default")
127 else
128 mooseError("Unknown ksp norm type specified.");
129}
@ KSPN_NONE
Definition MooseTypes.h:886
@ KSPN_PRECONDITIONED
Definition MooseTypes.h:887
@ KSPN_UNPRECONDITIONED
Definition MooseTypes.h:888
@ KSPN_DEFAULT
Use whatever we have in PETSc.
Definition MooseTypes.h:890
@ KSPN_NATURAL
Definition MooseTypes.h:889

Referenced by MoosePreconditioner::MoosePreconditioner().

◆ 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 100 of file SolverSystem.C.

101{
102 if (pcs == "left")
104 else if (pcs == "right")
106 else if (pcs == "symmetric")
108 else if (pcs == "default")
110 else
111 mooseError("Unknown PC side specified.");
112}
@ PCS_LEFT
Definition MooseTypes.h:875
@ PCS_DEFAULT
Use whatever we have in PETSc.
Definition MooseTypes.h:878
@ PCS_SYMMETRIC
Definition MooseTypes.h:877
@ PCS_RIGHT
Definition MooseTypes.h:876

Referenced by MoosePreconditioner::MoosePreconditioner().

◆ setPreconditioner()

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

Sets a preconditioner.

Parameters
pcThe preconditioner to be set

Definition at line 3694 of file NonlinearSystemBase.C.

3695{
3696 if (_preconditioner.get() != nullptr)
3697 mooseError("More than one active Preconditioner detected");
3698
3699 _preconditioner = pc;
3700}

Referenced by SetupPreconditionerAction::act().

◆ setPredictor()

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

Definition at line 996 of file NonlinearSystemBase.C.

997{
998 _predictor = predictor;
999}

Referenced by SetupPredictorAction::act().

◆ 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 287 of file NonlinearSystemBase.h.

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

Referenced by FEProblemSolve::FEProblemSolve().

◆ setPreviousNewtonSolution()

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

◆ 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 65 of file SolverSystem.C.

66{
67 _current_solution = &soln;
68
70 associateVectorToTag(const_cast<NumericVector<Number> &>(soln), tag);
71
72 if (_serialized_solution.get())
74}
void serializeSolution()
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition SubProblem.C:192
const TagName SOLUTION_TAG
Definition MooseTypes.C:25

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

◆ 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 3670 of file NonlinearSystemBase.C.

3671{
3672 *_u_dot = u_dot;
3673}

◆ 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 3676 of file NonlinearSystemBase.C.

3677{
3678 *_u_dotdot = u_dotdot;
3679}

◆ setSolutionUDotDotOld()

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

Definition at line 3688 of file NonlinearSystemBase.C.

3689{
3690 *_u_dotdot_old = u_dotdot_old;
3691}

◆ setSolutionUDotOld()

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

Definition at line 3682 of file NonlinearSystemBase.C.

3683{
3684 *_u_dot_old = u_dot_old;
3685}

◆ setupColoringFiniteDifferencedPreconditioner()

void NonlinearSystem::setupColoringFiniteDifferencedPreconditioner ( )
privateinherited

According to the nonzero pattern provided in the matrix, a graph is constructed.

A coloring algorithm is applied to the graph. The graph is partitioned into several independent subgraphs (colors), and a finte difference method is applied color-by-color to form a preconditioning matrix. If the number of colors is small, this method is much faster than the standard FD. But there is an issue. If the matrix provided by users does not represent the actual structure of the true Jacobian, the matrix computed via coloring could be wrong or inaccurate. In this case, users should switch to the standard finite difference method.

Definition at line 275 of file NonlinearSystem.C.

276{
277 // Make sure that libMesh isn't going to override our preconditioner
278 _nl_implicit_sys.nonlinear_solver->jacobian = nullptr;
279
280 libMesh::PetscNonlinearSolver<Number> & petsc_nonlinear_solver =
282
283 // Pointer to underlying PetscMatrix type
284 PetscMatrix<Number> * petsc_mat =
285 dynamic_cast<PetscMatrix<Number> *>(&_nl_implicit_sys.get_system_matrix());
286
288
289 if (!petsc_mat)
290 mooseError("Could not convert to Petsc matrix.");
291
292 petsc_mat->close();
293
294 ISColoring iscoloring;
295
296 // PETSc 3.5.x
297 MatColoring matcoloring;
298 LibmeshPetscCallA(_communicator.get(), MatColoringCreate(petsc_mat->mat(), &matcoloring));
299 LibmeshPetscCallA(_communicator.get(), MatColoringSetType(matcoloring, MATCOLORINGLF));
300 LibmeshPetscCallA(_communicator.get(), MatColoringSetFromOptions(matcoloring));
301 LibmeshPetscCallA(_communicator.get(), MatColoringApply(matcoloring, &iscoloring));
302 LibmeshPetscCallA(_communicator.get(), MatColoringDestroy(&matcoloring));
303
304 LibmeshPetscCallA(_communicator.get(),
305 MatFDColoringCreate(petsc_mat->mat(), iscoloring, &_fdcoloring));
306 LibmeshPetscCallA(_communicator.get(), MatFDColoringSetFromOptions(_fdcoloring));
307 // clang-format off
308#if PETSC_VERSION_LESS_THAN(3, 24, 0)
309 LibmeshPetscCallA(_communicator.get(),
310 MatFDColoringSetFunction(_fdcoloring,
311 (PetscErrorCode(*)(void))(void (*)(void))
313 &petsc_nonlinear_solver));
314#else
315 LibmeshPetscCallA(_communicator.get(),
316 MatFDColoringSetFunction(_fdcoloring,
317 (MatFDColoringFn*)
319 &petsc_nonlinear_solver));
320#endif
321 // clang-format on
322 LibmeshPetscCallA(_communicator.get(),
323 MatFDColoringSetUp(petsc_mat->mat(), iscoloring, _fdcoloring));
324 LibmeshPetscCallA(_communicator.get(),
325 SNESSetJacobian(petsc_nonlinear_solver.snes(),
326 petsc_mat->mat(),
327 petsc_mat->mat(),
328 SNESComputeJacobianDefaultColor,
329 _fdcoloring));
330 // PETSc >=3.3.0
331 LibmeshPetscCallA(_communicator.get(), ISColoringDestroy(&iscoloring));
332}
const SparseMatrix< Number > & get_system_matrix() const
void compute_jacobian(const NumericVector< Number > &soln, SparseMatrix< Number > &jacobian, NonlinearImplicitSystem &sys)
PetscErrorCode libmesh_petsc_snes_fd_residual(SNES, Vec x, Vec r, void *ctx)

Referenced by NonlinearSystem::setupFiniteDifferencedPreconditioner().

◆ setupDampers()

void NonlinearSystemBase::setupDampers ( )
inherited

Setup damping stuff (called before we actually start)

Definition at line 3709 of file NonlinearSystemBase.C.

3710{
3711 _increment_vec = &_sys.add_vector("u_increment", true, GHOSTED);
3712}

Referenced by NonlinearSystemBase::preInit().

◆ setupDM()

void NonlinearSystemBase::setupDM ( )
inherited

Setup the PETSc DM object (when appropriate)

Definition at line 432 of file NonlinearSystemBase.C.

433{
434 if (_fsp)
435 _fsp->setupDM();
436}
virtual void setupDM()=0
setup the data management data structure that manages the field split

Referenced by FEProblemBase::solve().

◆ setupFiniteDifferencedPreconditioner()

void NonlinearSystem::setupFiniteDifferencedPreconditioner ( )
overridevirtualinherited

Implements NonlinearSystemBase.

Definition at line 232 of file NonlinearSystem.C.

233{
234 std::shared_ptr<FiniteDifferencePreconditioner> fdp =
235 std::dynamic_pointer_cast<FiniteDifferencePreconditioner>(_preconditioner);
236 if (!fdp)
237 mooseError("Did not setup finite difference preconditioner, and please add a preconditioning "
238 "block with type = fdp");
239
240 if (fdp->finiteDifferenceType() == "coloring")
241 {
244 }
245
246 else if (fdp->finiteDifferenceType() == "standard")
247 {
250 }
251 else
252 mooseError("Unknown finite difference type");
253}
void setupColoringFiniteDifferencedPreconditioner()
According to the nonzero pattern provided in the matrix, a graph is constructed.
void setupStandardFiniteDifferencedPreconditioner()
Form preconditioning matrix via a standard finite difference method column-by-column.

Referenced by NonlinearSystem::potentiallySetupFiniteDifferencing().

◆ setupScalingData()

void NonlinearSystemBase::setupScalingData ( )
privateinherited

Setup group scaling containers.

Definition at line 4004 of file NonlinearSystemBase.C.

4005{
4007 return;
4008
4009 // Want the libMesh count of variables, not MOOSE, e.g. I don't care about array variable counts
4010 const auto n_vars = system().n_vars();
4011
4012 if (_scaling_group_variables.empty())
4013 {
4014 _var_to_group_var.reserve(n_vars);
4016
4017 for (const auto var_number : make_range(n_vars))
4018 _var_to_group_var.emplace(var_number, var_number);
4019 }
4020 else
4021 {
4022 std::set<unsigned int> var_numbers, var_numbers_covered, var_numbers_not_covered;
4023 for (const auto var_number : make_range(n_vars))
4024 var_numbers.insert(var_number);
4025
4027
4028 for (const auto group_index : index_range(_scaling_group_variables))
4029 for (const auto & var_name : _scaling_group_variables[group_index])
4030 {
4031 if (!hasVariable(var_name) && !hasScalarVariable(var_name))
4032 mooseError("'",
4033 var_name,
4034 "', provided to the 'scaling_group_variables' parameter, does not exist in "
4035 "the nonlinear system.");
4036
4037 const MooseVariableBase & var =
4038 hasVariable(var_name) ? cast_ref<MooseVariableBase &>(getVariable(0, var_name))
4039 : cast_ref<MooseVariableBase &>(getScalarVariable(0, var_name));
4040 auto map_pair = _var_to_group_var.emplace(var.number(), group_index);
4041 if (!map_pair.second)
4042 mooseError("Variable ", var_name, " is contained in multiple scaling grouplings");
4043 var_numbers_covered.insert(var.number());
4044 }
4045
4046 std::set_difference(var_numbers.begin(),
4047 var_numbers.end(),
4048 var_numbers_covered.begin(),
4049 var_numbers_covered.end(),
4050 std::inserter(var_numbers_not_covered, var_numbers_not_covered.begin()));
4051
4052 _num_scaling_groups = _scaling_group_variables.size() + var_numbers_not_covered.size();
4053
4054 auto index = static_cast<unsigned int>(_scaling_group_variables.size());
4055 for (auto var_number : var_numbers_not_covered)
4056 _var_to_group_var.emplace(var_number, index++);
4057 }
4058
4059 _variable_autoscaled.resize(n_vars, true);
4060 const auto & number_to_var_map = _vars[0].numberToVariableMap();
4061
4063 for (const auto i : index_range(_variable_autoscaled))
4066 libmesh_map_find(number_to_var_map, i)->name()) !=
4068 _variable_autoscaled[i] = false;
4069
4070 _auto_scaling_initd = true;
4071}
unsigned int number() const
Get variable number coming from libMesh.
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a scalar variable with specified number.
Definition SystemBase.C:144
unsigned int n_vars() const
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
Definition KokkosUtils.h:40

Referenced by NonlinearSystemBase::computeScaling().

◆ setupStandardFiniteDifferencedPreconditioner()

void NonlinearSystem::setupStandardFiniteDifferencedPreconditioner ( )
privateinherited

Form preconditioning matrix via a standard finite difference method column-by-column.

This method computes both diagonal and off-diagonal entrices regardless of the structure pattern of the Jacobian matrix.

Definition at line 256 of file NonlinearSystem.C.

257{
258 // Make sure that libMesh isn't going to override our preconditioner
259 _nl_implicit_sys.nonlinear_solver->jacobian = nullptr;
260
261 libMesh::PetscNonlinearSolver<Number> * petsc_nonlinear_solver =
262 cast_ptr<libMesh::PetscNonlinearSolver<Number> *>(_nl_implicit_sys.nonlinear_solver.get());
263
264 PetscMatrix<Number> * petsc_mat =
265 cast_ptr<PetscMatrix<Number> *>(&_nl_implicit_sys.get_system_matrix());
266
267 LibmeshPetscCall(SNESSetJacobian(petsc_nonlinear_solver->snes(),
268 petsc_mat->mat(),
269 petsc_mat->mat(),
270 SNESComputeJacobianDefault,
271 nullptr));
272}

Referenced by NonlinearSystem::setupFiniteDifferencedPreconditioner().

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

186{
187 AllLocalDofIndicesThread aldit(_subproblem, {var_name});
188 const ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
189 Threads::parallel_reduce(elem_range, aldit);
190
191 // Gather the dof indices across procs to get all the dof indices for var_name
192 aldit.dofIndicesSetUnion();
193
194 const auto & all_dof_indices = aldit.getDofIndices();
195 _var_all_dof_indices.assign(all_dof_indices.begin(), all_dof_indices.end());
196}
Grab all the (possibly semi)local dof indices for the variables passed in, in the system passed in.
const libMesh::ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems,...
Definition MooseMesh.C:1247

◆ setVerboseFlag()

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

Sets the verbose flag.

Parameters
[in]verboseVerbose flag

Definition at line 135 of file SystemBase.h.

135{ _verbose = verbose; }

Referenced by Executioner::Executioner().

◆ 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 722 of file NonlinearSystemBase.C.

723{
725 return false;
726
727 // The legacy behavior (#10464) _always_ performs the pre-SMO residual evaluation
728 // regardless of whether it is needed.
729 //
730 // This is not ideal and has been fixed by #23472. This legacy option ensures a smooth transition
731 // to the new behavior. Modules and Apps that want to migrate to the new behavior should set this
732 // parameter to false.
733 if (_app.parameters().get<bool>("use_legacy_initial_residual_evaluation_behavior"))
734 return true;
735
737}
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131

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

◆ sizeVariableMatrixData()

void SystemBase::sizeVariableMatrixData ( )
inherited

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

Definition at line 1740 of file SystemBase.C.

1741{
1742 for (const auto & warehouse : _vars)
1743 for (const auto & [var_num, var_ptr] : warehouse.numberToVariableMap())
1744 var_ptr->sizeMatrixTagData();
1745}

◆ skipNextSolutionToOldCopy()

void SystemBase::skipNextSolutionToOldCopy ( )
inlineinherited

Skip the next copy from the solution vector to the old solution vector old -> older is still performed.

Definition at line 1005 of file SystemBase.h.

◆ solution() [1/2]

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

Definition at line 212 of file SystemBase.h.

212{ return solutionState(0); }

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

◆ solution() [2/2]

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

Definition at line 215 of file SystemBase.h.

215{ return solutionState(0); }

◆ solutionInternal()

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

Internal getter for solution owned by libMesh.

Implements SystemBase.

Definition at line 135 of file SolverSystem.h.

136{
137 return *system().solution;
138}

◆ solutionOld() [1/2]

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

◆ solutionOld() [2/2]

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

Definition at line 216 of file SystemBase.h.

216{ return solutionState(1); }

◆ solutionOlder() [1/2]

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

◆ solutionOlder() [2/2]

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

Definition at line 217 of file SystemBase.h.

217{ return solutionState(2); }

◆ solutionPreviousNewton() [1/2]

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

Reimplemented in DisplacedSystem.

Definition at line 1365 of file SystemBase.C.

1366{
1369 else
1370 return nullptr;
1371}

◆ solutionPreviousNewton() [2/2]

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

Reimplemented in DisplacedSystem.

Definition at line 1374 of file SystemBase.C.

1375{
1378 else
1379 return nullptr;
1380}

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

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

1468{
1469 if (!hasSolutionState(state, iteration_type))
1470 needSolutionState(state, iteration_type);
1471 return *getSolutionStates(iteration_type)[state];
1472}

Referenced by SolverSystem::applyFixedPointRelaxation(), SystemBase::copyPreviousSolutions(), FunctorNodalCorrector::execute(), PointwiseRenormalizeVector::execute(), PointwiseRenormalizeVector::finalize(), MooseVariableBase::getSolution(), SystemBase::restoreOldSolutions(), SystemBase::saveOldSolutions(), SystemBase::solution(), SystemBase::solution(), SystemBase::solutionOld(), SystemBase::solutionOld(), SystemBase::solutionOlder(), SystemBase::solutionOlder(), DisplacedSystem::solutionState(), and DisplacedSystem::solutionState().

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

1438{
1439 if (!hasSolutionState(state, iteration_type))
1440 {
1441 const auto num_states = getNumSolutionStates(iteration_type);
1442 mooseError("For iteration type '",
1443 Moose::stringify(iteration_type),
1444 "': solution state ",
1445 state,
1446 " was requested in ",
1447 name(),
1448 " but only up to state ",
1449 (num_states == 0) ? 0 : num_states - 1,
1450 " is available.");
1451 }
1452
1453 const auto & solution_states = getSolutionStates(iteration_type);
1454
1455 if (state == 0)
1456 mooseAssert(solution_states[0] == &solutionInternal(), "Inconsistent current solution");
1457 else
1458 mooseAssert(solution_states[state] ==
1459 &getVector(oldSolutionStateVectorName(state, iteration_type)),
1460 "Inconsistent solution state");
1461
1462 return *solution_states[state];
1463}

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

1477{
1478 if (!hasSolutionState(state, iteration_type))
1479 mooseError("solutionStateParallelType() may only be called if the solution state exists.");
1480 return getSolutionStates(iteration_type)[state]->type();
1481}

Referenced by SolverSystem::applyFixedPointRelaxation(), and SystemBase::needSolutionState().

◆ 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 931 of file SystemBase.h.

Referenced by LinearFVGradientManager::computeGradients(), LinearFVGradientManager::resizeGradientStateStorage(), AuxScalarKernel::uOld(), and ScalarKernelBase::uOld().

◆ 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 293 of file SystemBase.h.

293{ return _u_dot; }

◆ 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 294 of file SystemBase.h.

294{ return _u_dotdot; }

◆ 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 296 of file SystemBase.h.

296{ return _u_dotdot_old; }

◆ 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 295 of file SystemBase.h.

295{ return _u_dot_old; }

◆ solve()

void NonlinearSystem::solve ( )
overridevirtualinherited

Solve the system (using libMesh magic)

Implements NonlinearSystemBase.

Definition at line 139 of file NonlinearSystem.C.

140{
141 // Only attach the postcheck function to the solver if we actually
142 // have dampers or if the FEProblemBase needs to update the solution,
143 // which is also done during the linesearch postcheck. It doesn't
144 // hurt to do this multiple times, it is just setting a pointer.
148
150 {
151 TIME_SECTION("nlPreSMOResidual", 3, "Computing Pre-SMO Residual");
152 // Calculate the pre-SMO residual for use in the convergence criterion.
158 _console << " * Nonlinear |R| = "
159 << Console::outputNorm(std::numeric_limits<Real>::max(), _pre_smo_residual)
160 << " (Before preset BCs, predictors, correctors, and constraints)\n";
161 _console << std::flush;
162 }
163
164 const bool presolve_succeeded = preSolve();
165 if (!presolve_succeeded)
166 return;
167
169
170 const bool time_integrator_solve = std::any_of(_time_integrators.begin(),
171 _time_integrators.end(),
172 [](auto & ti) { return ti->overridesSolve(); });
173 if (time_integrator_solve)
174 mooseAssert(_time_integrators.size() == 1,
175 "If solve is overridden, then there must be only one time integrator");
176
177 if (time_integrator_solve)
178 _time_integrators.front()->solve();
179 else
180 system().solve();
181
182 for (auto & ti : _time_integrators)
183 {
184 if (!ti->overridesSolve())
185 ti->setNumIterationsLastSolve();
186 ti->postSolve();
187 }
188
189 if (!_time_integrators.empty())
190 {
191 _n_iters = _time_integrators.front()->getNumNonlinearIterations();
192 _n_linear_iters = _time_integrators.front()->getNumLinearIterations();
193 }
194 else
195 {
197 _n_linear_iters = _nl_implicit_sys.nonlinear_solver->get_total_linear_iterations();
198 }
199
200 // store info about the solve
202
203 // determine whether solution invalid occurs in the converged solution
205
207 LibmeshPetscCall(MatFDColoringDestroy(&_fdcoloring));
208}
static std::string outputNorm(const Real &old_norm, const Real &norm, const unsigned int precision=6)
A helper function for outputting norms in color.
Definition Console.C:617
void needsPreviousNewtonIteration(bool state)
Set a flag that indicated that user required values for the previous Newton iterate.
virtual bool shouldUpdateSolution()
Check to see whether the problem should update the solution.
virtual void potentiallySetupFiniteDifferencing() override
Create finite differencing contexts for assembly of the Jacobian and/or approximating the action of t...
void checkInvalidSolution()
unsigned int n_nonlinear_iterations() const
virtual Real l2_norm() const=0
virtual void solve()
void compute_postcheck(const NumericVector< Number > &old_soln, NumericVector< Number > &search_direction, NumericVector< Number > &new_soln, bool &changed_search_direction, bool &changed_new_soln, NonlinearImplicitSystem &sys)

◆ stopSolve()

void NonlinearSystem::stopSolve ( const ExecFlagType &  exec_flag,
const std::set< TagID > &  vector_tags_to_close 
)
overridevirtualinherited

Quit the current solve as soon as possible.

Implements SolverSystem.

Definition at line 211 of file NonlinearSystem.C.

213{
215 cast_ref<libMesh::PetscNonlinearSolver<Real> &>(*sys().nonlinear_solver);
216
217 if (exec_flag == EXEC_LINEAR || exec_flag == EXEC_POSTCHECK)
218 {
219 LibmeshPetscCall(SNESSetFunctionDomainError(solver.snes()));
220
221 // Clean up by getting vectors into a valid state for a
222 // (possible) subsequent solve.
223 closeTaggedVectors(vector_tags_to_close);
224 }
225 else if (exec_flag == EXEC_NONLINEAR)
226 LibmeshPetscCall(SNESSetJacobianDomainError(solver.snes()));
227 else
228 mooseError("Unsupported execute flag: ", Moose::stringify(exec_flag));
229}
const ExecFlagType EXEC_POSTCHECK
Definition Moose.C:36

◆ subdomainSetup() [1/2]

void SystemBase::subdomainSetup ( )
virtualinherited

Reimplemented from SystemBase.

Definition at line 937 of file SystemBase.C.

1614{
1615 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1616 _vars[tid].subdomainSetup();
1617}
virtual void subdomainSetup()

◆ subdomainSetup() [2/2]

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 1002 of file NonlinearSystemBase.C.

1003{
1005
1006 _kernels.subdomainSetup(subdomain, tid);
1007 _nodal_kernels.subdomainSetup(subdomain, tid);
1008 _element_dampers.subdomainSetup(subdomain, tid);
1009 _nodal_dampers.subdomainSetup(subdomain, tid);
1010}
virtual void subdomainSetup(THREAD_ID tid=0) const
virtual void subdomainSetup()

◆ subproblem() [1/2]

SubProblem & SystemBase::subproblem ( )
inlineinherited

◆ subproblem() [2/2]

const SubProblem & SystemBase::subproblem ( ) const
inlineinherited

Definition at line 103 of file SystemBase.h.

103{ return _subproblem; }

◆ sys()

virtual libMesh::NonlinearImplicitSystem & NonlinearSystem::sys ( )
inlinevirtualinherited

Definition at line 67 of file NonlinearSystem.h.

67{ return _nl_implicit_sys; }

Referenced by buildSystemDoFIndices(), and NonlinearSystem::stopSolve().

◆ system() [1/2]

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

Implements SystemBase.

Definition at line 702 of file NonlinearSystemBase.h.

702{ return _sys; }

◆ system() [2/2]

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

Get the reference to the libMesh system.

Implements SystemBase.

Definition at line 701 of file NonlinearSystemBase.h.

701{ return _sys; }

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

◆ 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 55 of file PerfGraphInterface.C.

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

Referenced by PerfGraphInterface::registerTimedSection(), and PerfGraphInterface::registerTimedSection().

◆ 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 3900 of file NonlinearSystemBase.C.

3901{
3902 std::vector<std::string> variable_names;
3903 const auto & time_kernels = _kernels.getVectorTagObjectWarehouse(timeVectorTag(), 0);
3904 if (time_kernels.hasActiveObjects())
3905 for (const auto & kernel : time_kernels.getObjects())
3906 variable_names.push_back(kernel->variable().name());
3907
3908 return variable_names;
3909}

◆ timestepSetup()

void NonlinearSystemBase::timestepSetup ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 360 of file NonlinearSystemBase.C.

361{
363
364 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
365 {
369 if (_doing_dg)
375
376 if (_fe_problem.haveFV())
377 for (auto * fv_object : getFVSetupObjects(tid))
378 fv_object->timestepSetup();
379 }
386
387#ifdef MOOSE_KOKKOS_ENABLED
392#endif
393}
virtual void timestepSetup(THREAD_ID tid=0) const
virtual void timestepSetup() override
virtual void timestepSetup()

◆ 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 710 of file NonlinearSystemBase.h.

710{ return _Re_time_tag; }

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

◆ turnOffJacobian()

void NonlinearSystemBase::turnOffJacobian ( )
virtualinherited

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

Reimplemented in NonlinearEigenSystem.

Definition at line 246 of file NonlinearSystemBase.C.

247{
249 nonlinearSolver()->jacobian = NULL;
250}
virtual libMesh::NonlinearSolver< Number > * nonlinearSolver()=0
void set_basic_system_only()

◆ update()

void SystemBase::update ( )
inherited

◆ updateActive()

void NonlinearSystemBase::updateActive ( THREAD_ID  tid)
inherited

Update active objects of Warehouses owned by NonlinearSystemBase.

Definition at line 3406 of file NonlinearSystemBase.C.

3407{
3416
3417 if (tid == 0)
3418 {
3426
3427#ifdef MOOSE_KOKKOS_ENABLED
3433#endif
3434 }
3435}
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.
virtual void updateActive(THREAD_ID tid=0)
Updates the active objects storage.
virtual void updateActive(THREAD_ID tid=0) override
Update the active status of Kernels.

◆ 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 500 of file NonlinearSystemBase.h.

500{ _fsp = fsp; }

◆ 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 492 of file NonlinearSystemBase.h.

Referenced by FiniteDifferencePreconditioner::FiniteDifferencePreconditioner().

◆ usePreSMOResidual()

const bool & NonlinearSystemBase::usePreSMOResidual ( ) const
inlineinherited

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

Definition at line 290 of file NonlinearSystemBase.h.

290{ return _use_pre_smo_residual; }

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

◆ validParams()

InputParameters PerfGraphInterface::validParams ( )
staticinherited

Definition at line 16 of file PerfGraphInterface.C.

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

Referenced by Convergence::validParams().

◆ variableWarehouse()

const VariableWarehouse & SystemBase::variableWarehouse ( THREAD_ID  tid = 0) const
inlineinherited

Definition at line 784 of file SystemBase.h.

784{ return _vars[tid]; }

Referenced by AuxiliarySystem::updateFVGradient().

◆ varKind()

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

Definition at line 959 of file SystemBase.h.

959{ return _var_kind; }
Moose::VarKindType _var_kind
default kind of variables in this system

Referenced by Coupleable::coupled().

◆ zeroTaggedVector()

void SystemBase::zeroTaggedVector ( const TagID  tag)
inherited

Zero vector with the given tag.

Definition at line 673 of file SystemBase.C.

674{
676 mooseError("Cannot zero vector with TagID ",
677 tag,
678 " in system '",
679 name(),
680 "' because that tag does not exist in the problem");
681 else if (!hasVector(tag))
682 mooseError("Cannot zero vector tag with name '",
684 "' in system '",
685 name(),
686 "' because there is no vector associated with that tag");
688 getVector(tag).zero();
689}
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:144
virtual void zero()=0

Referenced by SystemBase::zeroTaggedVectors().

◆ zeroTaggedVectors()

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

Zero all vectors for given tags.

Definition at line 692 of file SystemBase.C.

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

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

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

200{
201 if (vars_to_be_zeroed.size() > 0)
202 {
203 NumericVector<Number> & solution = this->solution();
204
205 auto problem = dynamic_cast<FEProblemBase *>(&_subproblem);
206 if (!problem)
207 mooseError("System needs to be registered in FEProblemBase for using zeroVariables.");
208
209 AllLocalDofIndicesThread aldit(*problem, vars_to_be_zeroed, true);
210 const ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
211 Threads::parallel_reduce(elem_range, aldit);
212
213 const auto & dof_indices_to_zero = aldit.getDofIndices();
214
215 solution.close();
216
217 for (const auto & dof : dof_indices_to_zero)
218 solution.set(dof, 0);
219
220 solution.close();
221
222 // Call update to update the current_local_solution for this system
223 system().update();
224 }
225}
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.

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

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

235{
237}
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:199

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

◆ zeroVectorForResidual()

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

Definition at line 767 of file NonlinearSystemBase.C.

768{
769 for (unsigned int i = 0; i < _vecs_to_zero_for_residual.size(); ++i)
770 if (vector_name == _vecs_to_zero_for_residual[i])
771 return;
772
773 _vecs_to_zero_for_residual.push_back(vector_name);
774}

Member Data Documentation

◆ _active_on_old

bool MooseEigenSystem::_active_on_old
protected

Definition at line 106 of file MooseEigenSystem.h.

Referenced by activeOnOld(), eigenKernelOnCurrent(), and eigenKernelOnOld().

◆ _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 1072 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 1011 of file NonlinearSystemBase.h.

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

◆ _all_eigen_vars

bool MooseEigenSystem::_all_eigen_vars
protected

◆ _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 1014 of file NonlinearSystemBase.h.

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

◆ _auto_scaling_initd

bool NonlinearSystemBase::_auto_scaling_initd
privateinherited

Whether we've initialized the automatic scaling data structures.

Definition at line 1126 of file NonlinearSystemBase.h.

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

◆ _automatic_scaling

bool SystemBase::_automatic_scaling
protectedinherited

Whether to automatically scale the variables.

Definition at line 1102 of file SystemBase.h.

Referenced by SystemBase::automaticScaling(), 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 1069 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeScaling(), NonlinearSystemBase::computeScalingOnce(), 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 1064 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(), MaterialOutputAction::act(), MeshOnlyAction::act(), SetupDebugAction::act(), FEProblemBase::adaptMesh(), Adaptivity::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::checkNonConformingFaces(), MeshDiagnosticsGenerator::checkNonMatchingEdges(), MeshDiagnosticsGenerator::checkNonPlanarSides(), MeshDiagnosticsGenerator::checkPolygons(), FEProblemBase::checkProblemIntegrity(), ReferenceResidualConvergence::checkResidualConvergence(), MeshDiagnosticsGenerator::checkSidesetsOrientation(), MeshDiagnosticsGenerator::checkWatertightNodesets(), MeshDiagnosticsGenerator::checkWatertightSidesets(), CoarsenSurfaceMeshAlongSidesetGenerator::coarsenAlongSidesets(), IterationAdaptiveDT::computeAdaptiveDT(), TransientBase::computeConstrainedDT(), DefaultMultiAppFixedPointConvergence::computeCustomConvergencePostprocessor(), NonlinearSystemBase::computeDamping(), FixedPointIterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeFailedDT(), IterationAdaptiveDT::computeInitialDT(), IterationAdaptiveDT::computeInterpolationDT(), FEProblemBase::computeLinearSystemTags(), LinearSystem::computeLinearSystemTags(), NonlinearSystemBase::computeScaling(), Problem::console(), TimeStepper::constrainStep(), IterationAdaptiveDT::constrainStep(), MultiApp::createApp(), FEProblemBase::execMultiApps(), FEProblemBase::execMultiAppTransfers(), Eigenvalue::execute(), SteadyBase::execute(), MFEMSteady::execute(), MessageFromInput::execute(), ActionWarehouse::executeActionsWithAction(), ActionWarehouse::executeAllActions(), MeshGeneratorSystem::executeMeshGenerators(), SidesetAroundSubdomainUpdater::finalize(), ElementQualityChecker::finalize(), FEProblemBase::finishMultiAppStep(), MeshRepairGenerator::fixOverlappingNodes(), SurfaceSubdomainsDelaunayRemesher::General2DDelaunay(), CoarsenBlockGenerator::generate(), CoarsenSurfaceMeshAlongSidesetGenerator::generate(), OrientSurfaceMeshGenerator::generate(), PolyLineMeshFollowingNodeSetGenerator::generate(), MeshGenerator::generateInternal(), VariableCondensationPreconditioner::getDofToCondense(), InversePowerMethod::init(), NonlinearEigen::init(), FEProblemBase::initialAdaptMesh(), DefaultMultiAppFixedPointConvergence::initialize(), SubProblem::initialSetup(), EigenExecutionerBase::inversePowerIteration(), FEProblemBase::joinAndFinalize(), TransientBase::keepGoing(), IterationAdaptiveDT::limitDTByFunction(), IterationAdaptiveDT::limitDTToPostprocessorValue(), FEProblemBase::logAdd(), EigenExecutionerBase::makeBXConsistent(), Console::meshChanged(), SurfaceDelaunayGeneratorBase::meshNormalDeviation2D(), MooseBase::mooseDeprecated(), MooseBase::mooseDeprecatedNoTrace(), MooseBase::mooseInfo(), MooseBase::mooseWarning(), MooseBase::mooseWarningNonPrefixed(), ReferenceResidualConvergence::nonlinearConvergenceSetup(), Console::output(), DOFMapOutput::output(), MaterialPropertyDebugOutput::output(), PerfGraphOutput::output(), ReporterDebugOutput::output(), SolutionInvalidityOutput::output(), VariableResidualNormsDebugOutput::output(), ControlOutput::outputActiveObjects(), ControlOutput::outputChangedControls(), ControlOutput::outputControls(), Console::outputInput(), WebServerControl::outputMessage(), Console::outputPostprocessors(), PseudoTimestep::outputPseudoTimestep(), Console::outputReporters(), DefaultMultiAppFixedPointConvergence::outputResidualNorm(), Console::outputScalarVariables(), Console::outputSystemInformation(), FEProblemBase::possiblyRebuildGeomSearchPatches(), EigenExecutionerBase::postExecute(), AB2PredictorCorrector::postSolve(), ActionWarehouse::printActionDependencySets(), BlockRestrictionDebugOutput::printBlockRestrictionGroups(), BlockRestrictionDebugOutput::printBlockRestrictionMap(), BlockRestrictionDebugOutput::printBoundaryRestrictionGroups(), SolutionInvalidity::printDebug(), EigenExecutionerBase::printEigenvalue(), PicardSolve::printFixedPointConvergenceHistory(), SecantSolve::printFixedPointConvergenceHistory(), SteffensenSolve::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(), FEProblemSolve::solve(), FixedPointSolve::solve(), LinearSystem::solve(), NonlinearSystem::solve(), AStableDirk4::solve(), ExplicitRK2::solve(), ExplicitTVDRK2::solve(), ImplicitMidpoint::solve(), LStableDirk2::solve(), LStableDirk3::solve(), LStableDirk4::solve(), EigenProblem::solve(), FixedPointSolve::solveStep(), TransientMultiApp::solveStep(), MeshRepairGenerator::splitNonConvexPolygons(), PerfGraphLivePrint::start(), WebServerControl::startServer(), AB2PredictorCorrector::step(), NonlinearEigen::takeStep(), TransientBase::takeStep(), MFEMTransient::takeStep(), TerminateChainControl::terminate(), SubProblem::timestepSetup(), FEProblemBase::updateMeshXFEM(), Convergence::verboseOutput(), Console::writeTimestepInformation(), Console::writeVariableNorms(), and FEProblemBase::~FEProblemBase().

◆ _constraints

ConstraintWarehouse NonlinearSystemBase::_constraints
protectedinherited

◆ _convergence_name

ConvergenceName NonlinearSystemBase::_convergence_name
privateinherited

Associated convergence object name.

Definition at line 1135 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::convergence(), and NonlinearSystemBase::setConvergenceName().

◆ _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 1019 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

◆ _displaced_mortar_functors

std::unordered_map<std::pair<BoundaryID, BoundaryID>, ComputeMortarFunctor> NonlinearSystemBase::_displaced_mortar_functors
privateinherited

Functors for computing displaced mortar constraints.

Definition at line 1120 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::initialSetup(), NonlinearSystemBase::mortarConstraints(), and NonlinearSystemBase::reinitMortarFunctors().

◆ _doing_dg

bool NonlinearSystemBase::_doing_dg
protectedinherited

◆ _du_dot_du

Number NonlinearSystemBase::_du_dot_du
protectedinherited

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

Definition at line 918 of file NonlinearSystemBase.h.

◆ _du_dotdot_du

Number NonlinearSystemBase::_du_dotdot_du
protectedinherited

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

Definition at line 920 of file NonlinearSystemBase.h.

◆ _eigen_kernel_counter

unsigned int MooseEigenSystem::_eigen_kernel_counter
protected

counter of eigen kernels

Definition at line 109 of file MooseEigenSystem.h.

Referenced by addKernel(), and containsEigenKernel().

◆ _eigen_var_indices

std::set<dof_id_type> MooseEigenSystem::_eigen_var_indices
protected

◆ _eigen_var_names

std::set<VariableName> MooseEigenSystem::_eigen_var_names
protected

Definition at line 102 of file MooseEigenSystem.h.

Referenced by addKernel(), getEigenVariableNames(), and markEigenVariable().

◆ _element_dampers

MooseObjectWarehouse<ElementDamper> NonlinearSystemBase::_element_dampers
protectedinherited

◆ _factory

Factory& SystemBase::_factory
protectedinherited

◆ _fd_residual_functor

ComputeFDResidualFunctor NonlinearSystem::_fd_residual_functor
protectedinherited

◆ _fdcoloring

MatFDColoring NonlinearSystemBase::_fdcoloring
protectedinherited

◆ _fe_problem

FEProblemBase& SystemBase::_fe_problem
protectedinherited

the governing finite element/volume problem

Definition at line 1033 of file SystemBase.h.

Referenced by NonlinearSystemBase::addBoundaryCondition(), NonlinearSystemBase::addConstraint(), NonlinearSystemBase::addDGKernel(), NonlinearSystemBase::addDiracKernel(), SystemBase::addDotVectors(), NonlinearSystemBase::addHDGKernel(), NonlinearSystemBase::addInterfaceKernel(), NonlinearSystemBase::addKernel(), NonlinearSystemBase::addNodalKernel(), NonlinearSystemBase::addScalarKernel(), NonlinearSystemBase::addSplit(), NonlinearSystemBase::assembleScalingVector(), NonlinearSystemBase::augmentSparsity(), SolverSystem::checkInvalidSolution(), NonlinearSystemBase::checkKernelCoverage(), AuxiliarySystem::clearScalarVariableCoupleableTags(), AuxiliarySystem::compute(), LinearSystem::compute(), SolverSystem::compute(), NonlinearSystemBase::computeDamping(), NonlinearSystemBase::computeDiracContributions(), AuxiliarySystem::computeElementalVarsHelper(), NonlinearSystemBase::computeJacobian(), NonlinearSystemBase::computeJacobianBlocks(), NonlinearSystemBase::computeJacobianBlocks(), NonlinearSystemBase::computeJacobianInternal(), LinearSystem::computeLinearSystemInternal(), LinearSystem::computeLinearSystemTags(), AuxiliarySystem::computeMortarNodalVars(), NonlinearSystemBase::computeNodalBCsJacobian(), NonlinearSystemBase::computeNodalBCsResidual(), NonlinearSystemBase::computeNodalBCsResidual(), 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::convergence(), NonlinearSystemBase::customSetup(), eigenKernelOnCurrent(), eigenKernelOnOld(), NonlinearSystemBase::enforceNodalConstraintsJacobian(), NonlinearSystemBase::enforceNodalConstraintsResidual(), SystemBase::feProblem(), SystemBase::feProblem(), NonlinearSystemBase::getFVSetupObjects(), NonlinearSystemBase::getResidualNonTimeVector(), NonlinearSystemBase::getResidualTimeVector(), LinearSystem::initialSetup(), NonlinearSystemBase::initialSetup(), NonlinearSystemBase::jacobianSetup(), LinearSystem::LinearSystem(), NonlinearSystemBase::NonlinearSystemBase(), NonlinearSystemBase::overwriteNodeFace(), NonlinearSystem::potentiallySetupFiniteDifferencing(), LinearSystem::preInit(), 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

◆ _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 1085 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 1043 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 943 of file NonlinearSystemBase.h.

◆ _Ke_system_tag

TagID NonlinearSystemBase::_Ke_system_tag
protectedinherited

Tag for system contribution Jacobian.

Definition at line 946 of file NonlinearSystemBase.h.

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

◆ _kernels

MooseObjectTagWarehouse<KernelBase> NonlinearSystemBase::_kernels
protectedinherited

◆ _kokkos_integrated_bcs

MooseObjectTagWarehouse<ResidualObject> NonlinearSystemBase::_kokkos_integrated_bcs
protectedinherited

◆ _kokkos_kernels

MooseObjectTagWarehouse<ResidualObject> NonlinearSystemBase::_kokkos_kernels
protectedinherited

◆ _kokkos_nodal_bcs

MooseObjectTagWarehouse<ResidualObject> NonlinearSystemBase::_kokkos_nodal_bcs
protectedinherited

◆ _kokkos_nodal_kernels

MooseObjectTagWarehouse<ResidualObject> NonlinearSystemBase::_kokkos_nodal_kernels
protectedinherited

◆ _kokkos_preset_nodal_bcs

MooseObjectWarehouse<ResidualObject> NonlinearSystemBase::_kokkos_preset_nodal_bcs
protectedinherited

◆ _ksp_norm

Moose::MooseKSPNormType SolverSystem::_ksp_norm
protectedinherited

KSP norm type.

Definition at line 122 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 1074 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 1090 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 1093 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 1047 of file SystemBase.h.

Referenced by 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 1031 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 1040 of file SystemBase.h.

◆ _need_residual_ghosted

bool NonlinearSystemBase::_need_residual_ghosted
protectedinherited

◆ _nl_implicit_sys

libMesh::NonlinearImplicitSystem& NonlinearSystem::_nl_implicit_sys
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 929 of file NonlinearSystemBase.h.

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

◆ _nl_residual_functor

ComputeResidualFunctor NonlinearSystem::_nl_residual_functor
protectedinherited

Definition at line 80 of file NonlinearSystem.h.

Referenced by NonlinearSystem::NonlinearSystem().

◆ _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 926 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeNodalBCsResidual(), and 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 597 of file NonlinearSystemBase.h.

◆ _num_scaling_groups

std::size_t NonlinearSystemBase::_num_scaling_groups
privateinherited

The number of scaling groups.

Definition at line 1132 of file NonlinearSystemBase.h.

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

◆ _numbered_vars

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

Map variable number to its pointer.

Definition at line 1099 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 1088 of file NonlinearSystemBase.h.

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

◆ _pc_side

Moose::PCSideType SolverSystem::_pc_side
protectedinherited

Preconditioning side.

Definition at line 120 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 135 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 1041 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 138 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 1047 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::printAllVariableNorms().

◆ _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 940 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_and_jac_functor

ComputeResidualAndJacobian NonlinearSystem::_resid_and_jac_functor
protectedinherited

Definition at line 82 of file NonlinearSystem.h.

Referenced by NonlinearSystem::residualAndJacobianTogether().

◆ _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 1074 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 915 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 1081 of file SystemBase.h.

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

◆ _saved_dotdot_old

NumericVector<Real>* SystemBase::_saved_dotdot_old
protectedinherited

Definition at line 1082 of file SystemBase.h.

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

◆ _saved_old

NumericVector<Real>* SystemBase::_saved_old
protectedinherited

Definition at line 1077 of file SystemBase.h.

◆ _saved_older

NumericVector<Real>* SystemBase::_saved_older
protectedinherited

Definition at line 1078 of file SystemBase.h.

◆ _saved_solution_states

std::vector<NumericVector<Number> *> SystemBase::_saved_solution_states
privateinherited

The saved solution states (0 = current, 1 = old, 2 = older, etc)

Definition at line 1147 of file SystemBase.h.

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

◆ _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 1079 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 1115 of file SystemBase.h.

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

◆ _skip_next_solution_to_old_copy

bool SystemBase::_skip_next_solution_to_old_copy
privateinherited

Whether to skip the next copy from the solution to the old vector.

Definition at line 1149 of file SystemBase.h.

Referenced by SystemBase::advanceStateHistory(), SystemBase::copyPreviousSolutions(), and SystemBase::skipNextSolutionToOldCopy().

◆ _solution_is_invalid

bool SolverSystem::_solution_is_invalid
protectedinherited

Boolean to see if solution is invalid.

Definition at line 125 of file SolverSystem.h.

◆ _solution_state

std::vector<NumericVector<Number> *> NonlinearSystemBase::_solution_state
privateinherited

The current states of the solution (0 = current, 1 = old, etc)

Definition at line 1123 of file NonlinearSystemBase.h.

◆ _solution_states

std::array<std::vector<NumericVector<Number> *>, static_cast<size_t>(Moose::SolutionIterationType::Count)> SystemBase::_solution_states
privateinherited

2D array of solution state vector pointers.

Outer (array) index: SolutionIterationType (Time, Nonlinear, ...) Inner (vector) index: State (0=current, 1=old, ...)

Should only be accessed through getSolutionStates() when possible for bounds checking.

Definition at line 1145 of file SystemBase.h.

Referenced by SystemBase::getSolutionStates().

◆ _solution_states_initialized

bool SystemBase::_solution_states_initialized
protectedinherited

Whether or not the solution states have been initialized.

Definition at line 1108 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

◆ _u_dot_old

NumericVector<Number>* SystemBase::_u_dot_old
protectedinherited

◆ _u_dotdot

NumericVector<Number>* SystemBase::_u_dotdot
protectedinherited

◆ _u_dotdot_old

NumericVector<Number>* SystemBase::_u_dotdot_old
protectedinherited

◆ _undisplaced_mortar_functors

std::unordered_map<std::pair<BoundaryID, BoundaryID>, ComputeMortarFunctor> NonlinearSystemBase::_undisplaced_mortar_functors
privateinherited

Functors for computing undisplaced mortar constraints.

Definition at line 1116 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::initialSetup(), NonlinearSystemBase::mortarConstraints(), and NonlinearSystemBase::reinitMortarFunctors().

◆ _use_coloring_finite_difference

bool NonlinearSystem::_use_coloring_finite_difference
privateinherited

◆ _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 1045 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 1111 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 1085 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 1045 of file SystemBase.h.

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

◆ _var_to_copy

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

◆ _var_to_group_var

std::unordered_map<unsigned int, unsigned int> NonlinearSystemBase::_var_to_group_var
privateinherited

A map from variable index to group variable index and it's associated (inverse) scaling factor.

Definition at line 1129 of file NonlinearSystemBase.h.

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

◆ _variable_autoscaled

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

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

Definition at line 1082 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 1043 of file SystemBase.h.

Referenced by NonlinearSystemBase::addBoundaryCondition(), NonlinearSystemBase::addInterfaceKernel(), AuxiliarySystem::addVariable(), SystemBase::applyScalingFactors(), NonlinearSystemBase::assembleScalingVector(), SystemBase::clearAllDofIndices(), AuxiliarySystem::compute(), SystemBase::customSetup(), SystemBase::getActualFieldVariable(), SystemBase::getActualFieldVariable(), SystemBase::getFieldVariable(), SystemBase::getFieldVariable(), SystemBase::getFVVariable(), SystemBase::getMinQuadratureOrder(), AuxiliarySystem::getMinQuadratureOrder(), SystemBase::getScalarVariable(), SystemBase::getScalarVariable(), SystemBase::getScalarVariables(), SystemBase::getVariable(), SystemBase::getVariableNames(), SystemBase::getVariables(), SystemBase::initialSetup(), LinearSystem::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(), SystemBase::timestepSetup(), and SystemBase::variableWarehouse().

◆ _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 1025 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 1105 of file SystemBase.h.

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


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