www.mooseframework.org
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
NonlinearEigenSystem Class Reference

Nonlinear eigenvalue system to be solved. More...

#include <NonlinearEigenSystem.h>

Inheritance diagram for NonlinearEigenSystem:
[legend]

Public Member Functions

 NonlinearEigenSystem (EigenProblem &problem, const std::string &name)
 
virtual void solve () override
 Solve the system (using libMesh magic) More...
 
virtual void stopSolve (const ExecFlagType &exec_flag) override
 Quit the current solve as soon as possible. More...
 
virtual unsigned int getCurrentNonlinearIterationNumber () override
 Returns the current nonlinear iteration number. More...
 
virtual void setupFiniteDifferencedPreconditioner () override
 
virtual bool converged () override
 Returns the convergence state. More...
 
virtual NumericVector< Number > & RHS () override
 
NumericVector< Number > & residualVectorAX ()
 
NumericVector< Number > & residualVectorBX ()
 
void attachSLEPcCallbacks ()
 
unsigned int getNumConvergedEigenvalues () const
 Get the number of converged eigenvalues. More...
 
virtual NonlinearSolver< Number > * nonlinearSolver () override
 
virtual SNES getSNES () override
 Retrieve snes from slepc eigen solver. More...
 
virtual EPS getEPS ()
 Retrieve EPS (SLEPc eigen solver) More...
 
EigenSystem & sys ()
 
void checkIntegrity ()
 For eigenvalue problems (including standard and generalized), inhomogeneous (Dirichlet or Neumann) boundary conditions are not allowed. More...
 
std::pair< Real, RealgetConvergedEigenvalue (dof_id_type n) const
 Return the Nth converged eigenvalue. More...
 
std::pair< Real, RealgetConvergedEigenpair (dof_id_type n) const
 Return the Nth converged eigenvalue and copies the respective eigen vector to the solution vector. More...
 
const std::vector< std::pair< Real, Real > > & getAllConvergedEigenvalues () const
 Get the number of converged eigenvalues. More...
 
TagID eigenVectorTag () const
 Vector tag ID of right hand side. More...
 
TagID nonEigenVectorTag () const
 Vector tag ID of left hand side. More...
 
TagID eigenMatrixTag () const
 Matrix tag ID of right hand side. More...
 
TagID nonEigenMatrixTag () const
 Matrix tag ID of left hand side. More...
 
std::set< TagIDdefaultVectorTags () const override
 Get the default vector tags associated with this system. More...
 
std::set< TagIDdefaultMatrixTags () const override
 Get the default matrix tags associted with this system. More...
 
void precondMatrixIncludesEigenKernels (bool precond_matrix_includes_eigen)
 If the preconditioning matrix includes eigen kernels. More...
 
bool precondMatrixIncludesEigenKernels () const
 
TagID precondMatrixTag () const
 
virtual void attachPreconditioner (Preconditioner< Number > *preconditioner) override
 Attach a customized preconditioner that requires physics knowledge. More...
 
Preconditioner< Number > * preconditioner () const
 
virtual void turnOffJacobian () override
 Turn off the Jacobian (must be called before equation system initialization) More...
 
void residualAndJacobianTogether () override
 Call this method if you want the residual and Jacobian to be computed simultaneously. More...
 
 NonlinearEigenSystem (EigenProblem &problem, const std::string &name)
 
bool converged ()
 Returns the convergence state. More...
 
void checkIntegrity ()
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
virtual void init () override
 Initialize the system. More...
 
bool computedScalingJacobian () const
 
virtual bool computingInitialResidual ()
 Returns true if this system is currently computing the initial residual for a solve. More...
 
virtual void initialSetup () override
 Setup Functions. More...
 
virtual void timestepSetup () override
 
virtual void customSetup (const ExecFlagType &exec_type) override
 
virtual void residualSetup () override
 
virtual void jacobianSetup () override
 
void setupFieldDecomposition ()
 
bool haveFiniteDifferencedPreconditioner () const
 
bool haveFieldSplitPreconditioner () const
 
void addTimeIntegrator (const std::string &type, const std::string &name, InputParameters &parameters) override
 Add a time integrator. More...
 
virtual void addTimeIntegrator (const std::string &, const std::string &, InputParameters &)
 
virtual void addTimeIntegrator (std::shared_ptr< TimeIntegrator >)
 
virtual void addTimeIntegrator (std::shared_ptr< TimeIntegrator >)
 
virtual void addKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a kernel. More...
 
virtual void addNodalKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a NodalKernel. More...
 
void addScalarKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a scalar kernel. More...
 
void addBoundaryCondition (const std::string &bc_name, const std::string &name, InputParameters &parameters)
 Adds a boundary condition. More...
 
void addConstraint (const std::string &c_name, const std::string &name, InputParameters &parameters)
 Adds a Constraint. More...
 
void addDiracKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 Adds a Dirac kernel. More...
 
void addDGKernel (std::string dg_kernel_name, const std::string &name, InputParameters &parameters)
 Adds a DG kernel. More...
 
void addInterfaceKernel (std::string interface_kernel_name, const std::string &name, InputParameters &parameters)
 Adds an interface kernel. More...
 
void addDamper (const std::string &damper_name, const std::string &name, InputParameters &parameters)
 Adds a damper. More...
 
void addSplit (const std::string &split_name, const std::string &name, InputParameters &parameters)
 Adds a split. More...
 
std::shared_ptr< SplitgetSplit (const std::string &name)
 Retrieves a split by name. More...
 
void zeroVectorForResidual (const std::string &vector_name)
 
void setInitialSolution ()
 
void setConstraintSecondaryValues (NumericVector< Number > &solution, bool displaced)
 Sets the value of constrained variables in the solution vector. More...
 
void constraintResiduals (NumericVector< Number > &residual, bool displaced)
 Add residual contributions from Constraints. More...
 
void computeResidualTag (NumericVector< Number > &residual, TagID tag_id)
 Computes residual for a given tag. More...
 
void computeResidualTags (const std::set< TagID > &tags)
 Form multiple tag-associated residual vectors for all the given tags. More...
 
void computeResidualAndJacobianTags (const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
 Form possibly multiple tag-associated vectors and matrices. More...
 
void computeResidualAndJacobianInternal (const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
 Compute residual and Jacobian from contributions not related to constraints, such as nodal boundary conditions. More...
 
void computeResidual (NumericVector< Number > &residual, TagID tag_id)
 Form a residual vector for a given tag. More...
 
void addImplicitGeometricCouplingEntries (GeometricSearchData &geom_search_data)
 Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled that are related geometrically (i.e. More...
 
void constraintJacobians (bool displaced)
 Add jacobian contributions from Constraints. More...
 
void computeJacobianTags (const std::set< TagID > &tags)
 Computes multiple (tag associated) Jacobian matricese. More...
 
bool computeScaling ()
 Method used to obtain scaling factors for variables. More...
 
void computeJacobian (SparseMatrix< Number > &jacobian, const std::set< TagID > &tags)
 Associate jacobian to systemMatrixTag, and then form a matrix for all the tags. More...
 
void computeJacobian (SparseMatrix< Number > &jacobian)
 Take all tags in the system, and form a matrix for all tags in the system. More...
 
void computeJacobianBlocks (std::vector< JacobianBlock *> &blocks)
 Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditioning matrices. More...
 
void computeJacobianBlocks (std::vector< JacobianBlock *> &blocks, const std::set< TagID > &tags)
 
Real computeDamping (const NumericVector< Number > &solution, const NumericVector< Number > &update)
 Compute damping. More...
 
void computeTimeDerivatives (bool jacobian_calculation=false)
 Computes the time derivative vector. More...
 
void onTimestepBegin ()
 Called at the beginning of the time step. More...
 
virtual void subdomainSetup (SubdomainID subdomain, THREAD_ID tid)
 Called from assembling when we hit a new subdomain. More...
 
virtual void subdomainSetup ()
 
virtual void subdomainSetup ()
 
void overwriteNodeFace (NumericVector< Number > &soln)
 Called from explicit time stepping to overwrite boundary positions (explicit dynamics). More...
 
void updateActive (THREAD_ID tid)
 Update active objects of Warehouses owned by NonlinearSystemBase. More...
 
virtual void setSolutionUDot (const NumericVector< Number > &udot)
 Set transient term used by residual and Jacobian evaluation. More...
 
virtual void setSolutionUDotDot (const NumericVector< Number > &udotdot)
 Set transient term used by residual and Jacobian evaluation. More...
 
NumericVector< Number > & getResidualTimeVector ()
 Return a numeric vector that is associated with the time tag. More...
 
NumericVector< Number > & getResidualNonTimeVector ()
 Return a numeric vector that is associated with the nontime tag. More...
 
NumericVector< Number > & residualVector (TagID tag)
 Return a residual vector that is associated with the residual tag. More...
 
virtual NumericVector< Number > & residualCopy () override
 
virtual NumericVector< Number > & residualGhosted () override
 
virtual void augmentSparsity (SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz) override
 Will modify the sparsity pattern to add logical geometric connections. More...
 
void setPreconditioner (std::shared_ptr< MoosePreconditioner > pc)
 Sets a preconditioner. More...
 
MoosePreconditioner const * getPreconditioner () const
 
void useFiniteDifferencedPreconditioner (bool use=true)
 If called with true this system will use a finite differenced form of the Jacobian as the preconditioner. More...
 
void setDecomposition (const std::vector< std::string > &decomposition)
 If called with a single string, it is used as the name of a the top-level decomposition split. More...
 
void useFieldSplitPreconditioner (bool use=true)
 If called with true this system will use a field split preconditioner matrix. More...
 
void addImplicitGeometricCouplingEntriesToJacobian (bool add=true)
 If called with true this will add entries into the jacobian to link together degrees of freedom that are found to be related through the geometric search system. More...
 
void assembleConstraintsSeparately (bool separately=true)
 Indicates whether to assemble residual and Jacobian after each constraint application. More...
 
void setupDampers ()
 Setup damping stuff (called before we actually start) More...
 
void reinitIncrementAtQpsForDampers (THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
 Compute the incremental change in variables at QPs for dampers. More...
 
void reinitIncrementAtNodeForDampers (THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
 Compute the incremental change in variables at nodes for dampers. More...
 
unsigned int nNonlinearIterations () const
 Return the number of non-linear iterations. More...
 
unsigned int nLinearIterations () const
 Return the number of linear iterations. More...
 
unsigned int nResidualEvaluations () const
 Return the total number of residual evaluations done so far in this calculation. More...
 
Real finalNonlinearResidual () const
 Return the final nonlinear residual. More...
 
Real nonlinearNorm () const
 Return the last nonlinear norm. More...
 
void printAllVariableNorms (bool state)
 Force the printing of all variable norms after each solve. More...
 
void debuggingResiduals (bool state)
 
void setPredictor (std::shared_ptr< Predictor > predictor)
 
PredictorgetPredictor ()
 
bool needBoundaryMaterialOnSide (BoundaryID bnd_id, THREAD_ID tid) const
 Indicated whether this system needs material properties on boundaries. More...
 
bool needInterfaceMaterialOnSide (BoundaryID bnd_id, THREAD_ID tid) const
 Indicated whether this system needs material properties on interfaces. More...
 
bool needSubdomainMaterialOnSide (SubdomainID subdomain_id, THREAD_ID tid) const
 Indicates whether this system needs material properties on internal sides. More...
 
bool doingDG () const
 Getter for _doing_dg. More...
 
bool hasSaveIn () const
 Weather or not the nonlinear system has save-ins. More...
 
bool hasDiagSaveIn () const
 Weather or not the nonlinear system has diagonal Jacobian save-ins. More...
 
virtual System & system () override
 Get the reference to the libMesh system. More...
 
virtual const 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. More...
 
TagID nonTimeVectorTag () const override
 
TagID residualVectorTag () const override
 
TagID systemMatrixTag () const override
 Return the Matrix Tag ID for System. More...
 
bool computeScalingOnce () const
 
void computeScalingOnce (bool compute_scaling_once)
 
void autoScalingParam (Real resid_vs_jac_scaling_param)
 Sets the param that indicates the weighting of the residual vs the Jacobian in determining variable scaling parameters. More...
 
void scalingGroupVariables (const std::vector< std::vector< std::string >> &scaling_group_variables)
 
void ignoreVariablesForAutoscaling (const std::vector< std::string > &ignore_variables_for_autoscaling)
 
bool offDiagonalsInAutoScaling () const
 
void offDiagonalsInAutoScaling (bool off_diagonals_in_auto_scaling)
 
void setupDM ()
 Setup the PETSc DM object (when appropriate) More...
 
virtual void reinitNodeFace (const Node *node, BoundaryID bnd_id, THREAD_ID tid)
 Reinit nodal assembly info on a face. More...
 
virtual void reinitNodeFace (const Node *node, BoundaryID bnd_id, THREAD_ID tid)
 Reinit nodal assembly info on a face. More...
 
virtual void restoreSolutions () override final
 Restore current solutions (call after your solve failed) More...
 
void serializeSolution ()
 
void setSolution (const NumericVector< Number > &soln)
 Set the solution to a given vector. More...
 
void setPCSide (MooseEnum pcs)
 Set the side on which the preconditioner is applied to. More...
 
Moose::PCSideType getPCSide ()
 Get the current preconditioner side. More...
 
void setMooseKSPNormType (MooseEnum kspnorm)
 Set the norm in which the linear convergence will be measured. More...
 
Moose::MooseKSPNormType getMooseKSPNormType ()
 Get the norm in which the linear convergence is measured. More...
 
virtual const NumericVector< Number > *const & currentSolution () const override final
 The solution vector that is currently being operated on. More...
 
unsigned int number () const
 Gets the number of this system. More...
 
MooseMeshmesh ()
 
const MooseMeshmesh () const
 
SubProblemsubproblem ()
 
const SubProblemsubproblem () const
 
FEProblemBasefeProblem ()
 
const FEProblemBasefeProblem () const
 
void applyScalingFactors (const std::vector< Real > &inverse_scaling_factors)
 Applies scaling factors to the system's variables. More...
 
bool computingScalingJacobian () const
 Whether we are computing an initial Jacobian for automatic variable scaling. More...
 
bool automaticScaling () const
 Getter for whether we are performing automatic scaling. More...
 
void automaticScaling (bool automatic_scaling)
 Setter for whether we are performing automatic scaling. More...
 
void setVerboseFlag (const bool &verbose)
 Sets the verbose flag. More...
 
virtual DofMap & dofMap ()
 Gets writeable reference to the dof map. More...
 
virtual const DofMap & dofMap () const
 Gets const reference to the dof map. More...
 
virtual void initializeObjects ()
 Called only once, just before the solve begins so objects can do some precalculations. More...
 
virtual void update (bool update_libmesh_system=true)
 Update the system (doing libMesh magic) More...
 
virtual void copyOldSolutions ()
 Shifts the solutions backwards in time. More...
 
NumericVector< Number > & solution ()
 
const NumericVector< Number > & solution () const
 
NumericVector< Number > & solutionOld ()
 
const NumericVector< Number > & solutionOld () const
 
NumericVector< Number > & solutionOlder ()
 
const NumericVector< Number > & solutionOlder () const
 
virtual const NumericVector< Number > * solutionPreviousNewton () const
 
virtual NumericVector< Number > * solutionPreviousNewton ()
 
virtual void initSolutionState ()
 Initializes the solution state. More...
 
virtual NumericVector< Number > & solutionState (const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
 Get a state of the solution (0 = current, 1 = old, 2 = older, etc). More...
 
virtual const NumericVector< Number > & solutionState (const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
 Get a state of the solution (0 = current, 1 = old, 2 = older, etc). More...
 
virtual void needSolutionState (const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
 Registers that the solution state state is needed. More...
 
virtual bool hasSolutionState (const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
 Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc). More...
 
virtual void addDotVectors ()
 Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator. More...
 
virtual NumberduDotDu ()
 
virtual const NumberduDotDu () const
 
virtual NumberduDotDotDu ()
 
virtual const NumberduDotDotDu () const
 
virtual NumericVector< Number > * solutionUDot ()
 
virtual const NumericVector< Number > * solutionUDot () const
 
virtual NumericVector< Number > * solutionUDotDot ()
 
virtual const NumericVector< Number > * solutionUDotDot () const
 
virtual NumericVector< Number > * solutionUDotOld ()
 
virtual const NumericVector< Number > * solutionUDotOld () const
 
virtual NumericVector< Number > * solutionUDotDotOld ()
 
virtual const NumericVector< Number > * solutionUDotDotOld () const
 
virtual void saveOldSolutions ()
 Save the old and older solutions. More...
 
virtual void restoreOldSolutions ()
 Restore the old and older solutions when the saved solutions present. More...
 
bool hasVector (const std::string &tag_name) const
 Check if the named vector exists in the system. More...
 
virtual bool hasVector (TagID tag_id) const
 Check if the tagged vector exists in the system. More...
 
virtual void associateVectorToTag (NumericVector< Number > &vec, TagID tag)
 Associate a vector for a given tag. More...
 
virtual void disassociateVectorFromTag (NumericVector< Number > &vec, TagID tag)
 Disassociate a given vector from a given tag. More...
 
virtual void disassociateVectorFromTag (TagID tag)
 Disassociate any vector that is associated with a given tag. More...
 
virtual void disassociateDefaultVectorTags ()
 Disassociate the vectors associated with the default vector tags of this system. More...
 
virtual bool hasMatrix (TagID tag) const
 Check if the tagged matrix exists in the system. More...
 
virtual SparseMatrix< Number > & getMatrix (TagID tag)
 Get a raw SparseMatrix. More...
 
virtual const SparseMatrix< Number > & getMatrix (TagID tag) const
 Get a raw SparseMatrix. More...
 
virtual void activeAllMatrixTags ()
 Make all exsiting matrices ative. More...
 
virtual void activeMatrixTag (TagID tag)
 Active a matrix for tag. More...
 
virtual bool matrixTagActive (TagID tag) const
 If or not a matrix tag is active. More...
 
virtual void deactiveMatrixTag (TagID tag)
 deactive a matrix for tag More...
 
virtual void deactiveAllMatrixTags ()
 Make matrices inactive. More...
 
void closeTaggedMatrices (const std::set< TagID > &tags)
 Close all matrices associated the tags. More...
 
void flushTaggedMatrices (const std::set< TagID > &tags)
 flushes all matrices associated to tags. More...
 
virtual void associateMatrixToTag (SparseMatrix< Number > &matrix, TagID tag)
 Associate a matrix to a tag. More...
 
virtual void disassociateMatrixFromTag (SparseMatrix< Number > &matrix, TagID tag)
 Disassociate a matrix from a tag. More...
 
virtual void disassociateMatrixFromTag (TagID tag)
 Disassociate any matrix that is associated with a given tag. More...
 
virtual void disassociateDefaultMatrixTags ()
 Disassociate the matrices associated with the default matrix tags of this system. More...
 
virtual NumericVector< Number > & serializedSolution ()
 Returns a reference to a serialized version of the solution vector for this subproblem. More...
 
virtual void augmentSendList (std::vector< dof_id_type > &send_list)
 Will modify the send_list to add all of the extra ghosted dofs for this system. More...
 
virtual void addVariable (const std::string &var_type, const std::string &var_name, InputParameters &parameters)
 Canonical method for adding a variable. More...
 
virtual bool isArrayVariable (const std::string &var_name) const
 If a variable is an array variable. More...
 
virtual bool isScalarVariable (unsigned int var_name) const
 
MooseVariableFieldBasegetVariable (THREAD_ID tid, const std::string &var_name) const
 Gets a reference to a variable of with specified name. More...
 
MooseVariableFieldBasegetVariable (THREAD_ID tid, unsigned int var_number) const
 Gets a reference to a variable with specified number. More...
 
template<typename T >
MooseVariableFE< T > & getFieldVariable (THREAD_ID tid, const std::string &var_name)
 Gets a reference to a variable of with specified name. More...
 
template<typename T >
MooseVariableFE< T > & getFieldVariable (THREAD_ID tid, unsigned int var_number)
 Gets a reference to a variable with specified number. More...
 
template<typename T >
MooseVariableField< T > & getActualFieldVariable (THREAD_ID tid, const std::string &var_name)
 Returns a field variable pointer - this includes finite volume variables. More...
 
template<typename T >
MooseVariableField< T > & getActualFieldVariable (THREAD_ID tid, unsigned int var_number)
 Returns a field variable pointer - this includes finite volume variables. More...
 
template<typename T >
MooseVariableFV< T > & getFVVariable (THREAD_ID tid, const std::string &var_name)
 Return a finite volume variable. More...
 
virtual MooseVariableScalargetScalarVariable (THREAD_ID tid, const std::string &var_name) const
 Gets a reference to a scalar variable with specified number. More...
 
virtual MooseVariableScalargetScalarVariable (THREAD_ID tid, unsigned int var_number) const
 Gets a reference to a variable with specified number. More...
 
virtual const std::set< SubdomainID > * getVariableBlocks (unsigned int var_number)
 Get the block where a variable of this system is defined. More...
 
virtual unsigned int nVariables () const
 Get the number of variables in this system. More...
 
unsigned int nFieldVariables () const
 Get the number of field variables in this system. More...
 
unsigned int nFVVariables () const
 Get the number of finite volume variables in this system. More...
 
std::size_t getMaxVarNDofsPerElem () const
 Gets the maximum number of dofs used by any one variable on any one element. More...
 
std::size_t getMaxVarNDofsPerNode () const
 Gets the maximum number of dofs used by any one variable on any one node. More...
 
void assignMaxVarNDofsPerElem (std::size_t max_dofs)
 assign the maximum element dofs More...
 
void assignMaxVarNDofsPerNode (std::size_t max_dofs)
 assign the maximum node dofs More...
 
virtual void addVariableToZeroOnResidual (std::string var_name)
 Adds this variable to the list of variables to be zeroed during each residual evaluation. More...
 
virtual void addVariableToZeroOnJacobian (std::string var_name)
 Adds this variable to the list of variables to be zeroed during each Jacobian evaluation. More...
 
virtual void zeroVariables (std::vector< std::string > &vars_to_be_zeroed)
 Zero out the solution for the list of variables passed in. More...
 
virtual void zeroVariablesForResidual ()
 Zero out the solution for the variables that were registered as needing to have their solutions zeroed on out on residual evaluation by a call to addVariableToZeroOnResidual() More...
 
virtual void zeroVariablesForJacobian ()
 Zero out the solution for the variables that were registered as needing to have their solutions zeroed on out on Jacobian evaluation by a call to addVariableToZeroOnResidual() More...
 
virtual Order getMinQuadratureOrder ()
 Get minimal quadrature order needed for integrating variables in this system. More...
 
virtual void prepare (THREAD_ID tid)
 Prepare the system for use. More...
 
virtual void prepareFace (THREAD_ID tid, bool resize_data)
 Prepare the system for use on sides. More...
 
virtual void prepareNeighbor (THREAD_ID tid)
 Prepare the system for use. More...
 
virtual void prepareLowerD (THREAD_ID tid)
 Prepare the system for use for lower dimensional elements. More...
 
virtual void reinitElem (const Elem *elem, THREAD_ID tid)
 Reinit an element assembly info. More...
 
virtual void reinitElemFace (const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
 Reinit assembly info for a side of an element. More...
 
virtual void reinitNeighborFace (const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
 Compute the values of the variables at all the current points. More...
 
virtual void reinitNeighbor (const Elem *elem, THREAD_ID tid)
 Compute the values of the variables at all the current points. More...
 
virtual void reinitLowerD (THREAD_ID tid)
 Compute the values of the variables on the lower dimensional element. More...
 
virtual void reinitNode (const Node *node, THREAD_ID tid)
 Reinit nodal assembly info. More...
 
virtual void reinitNodes (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of nodes. More...
 
virtual void reinitNodesNeighbor (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of neighbor nodes. More...
 
virtual void reinitScalars (THREAD_ID tid, bool reinit_for_derivative_reordering=false)
 Reinit scalar varaibles. More...
 
virtual void addVariableToCopy (const std::string &dest_name, const std::string &source_name, const std::string &timestep)
 Add info about variable that will be copied. More...
 
const std::vector< MooseVariableFieldBase * > & getVariables (THREAD_ID tid)
 
const std::vector< MooseVariableScalar * > & getScalarVariables (THREAD_ID tid)
 
const std::set< SubdomainID > & getSubdomainsForVar (unsigned int var_number) const
 
const std::set< SubdomainID > & getSubdomainsForVar (const std::string &var_name) const
 Get the block where a variable of this system is defined. More...
 
void removeVector (const std::string &name)
 Remove a vector from the system with the given name. More...
 
void removeVector (TagID tag_id)
 Remove a solution length vector from the system with the specified TagID. More...
 
NumericVector< Number > & addVector (const std::string &vector_name, const bool project, const ParallelType type)
 Adds a solution length vector to the system. More...
 
NumericVector< Number > & addVector (TagID tag, const bool project, const ParallelType type)
 Adds a solution length vector to the system with the specified TagID. More...
 
void closeTaggedVector (const TagID tag)
 Close vector with the given tag. More...
 
void closeTaggedVectors (const std::set< TagID > &tags)
 Close all vectors for given tags. More...
 
void zeroTaggedVector (const TagID tag)
 Zero vector with the given tag. More...
 
void zeroTaggedVectors (const std::set< TagID > &tags)
 Zero all vectors for given tags. More...
 
void setVariableGlobalDoFs (const std::string &var_name)
 set all the global dof indices for a variable More...
 
const std::vector< dof_id_type > & getVariableGlobalDoFs ()
 Get the global dof indices of a variable, this needs to be called after the indices have been set by setVariableGlobalDoFs More...
 
SparseMatrix< Number > & addMatrix (TagID tag)
 Adds a matrix with a given tag. More...
 
void removeMatrix (TagID tag)
 Removes a matrix with a given tag. More...
 
virtual const std::string & name () const
 
const std::vector< VariableName > & getVariableNames () const
 
void getStandardFieldVariableNames (std::vector< VariableName > &std_field_variables) const
 
unsigned int getMaxVariableNumber () const
 Returns the maximum number of all variables on the system. More...
 
virtual void computeVariables (const NumericVector< Number > &)
 
void copyVars (ExodusII_IO &io)
 
virtual void copySolutionsBackwards ()
 Copy current solution into old and older. More...
 
TimeIntegratorgetTimeIntegrator ()
 
const TimeIntegratorgetTimeIntegrator () const
 
std::shared_ptr< TimeIntegratorgetSharedTimeIntegrator ()
 
bool hasVarCopy () const
 Whether or not there are variables to be restarted from an Exodus mesh file. More...
 
void addScalingVector ()
 Add the scaling factor vector to the system. More...
 
bool solutionStatesInitialized () const
 Whether or not the solution states have been initialized via initSolutionState() More...
 
void clearAllDofIndices ()
 Clear all dof indices from moose variables. More...
 
void setActiveVariableCoupleableVectorTags (const std::set< TagID > &vtags, THREAD_ID tid)
 Set the active vector tags for the variables. More...
 
void setActiveScalarVariableCoupleableVectorTags (const std::set< TagID > &vtags, THREAD_ID tid)
 Set the active vector tags for the scalar variables. More...
 
Moose::VarKindType varKind () const
 
std::vector< std::unique_ptr< NumericVector< Number > > > & gradientContainer ()
 Reference to the container vector which hold gradients at dofs (if it can be interpreted). More...
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
PerfGraphperfGraph ()
 Get the PerfGraph. More...
 
void checkKernelCoverage (const std::set< SubdomainID > &mesh_subdomains) const
 
bool containsTimeKernel ()
 
MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse ()
 Access functions to Warehouses from outside NonlinearSystemBase. More...
 
MooseObjectTagWarehouse< DGKernelBase > & getDGKernelWarehouse ()
 
MooseObjectTagWarehouse< InterfaceKernelBase > & getInterfaceKernelWarehouse ()
 
MooseObjectTagWarehouse< DiracKernelBase > & getDiracKernelWarehouse ()
 
MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse ()
 
const MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse () const
 Return the IntegratedBCBase warehouse. More...
 
const MooseObjectWarehouse< ElementDamper > & getElementDamperWarehouse () const
 
const MooseObjectWarehouse< NodalDamper > & getNodalDamperWarehouse () const
 
const ConstraintWarehousegetConstraintWarehouse () const
 
const MooseObjectTagWarehouse< NodalBCBase > & getNodalBCWarehouse () const
 Return the NodalBCBase warehouse. More...
 
virtual NumericVector< Number > & getVector (const std::string &name)
 Get a raw NumericVector by name. More...
 
virtual const NumericVector< Number > & getVector (const std::string &name) const
 
virtual NumericVector< Number > & getVector (TagID tag)
 Get a raw NumericVector by tag. More...
 
virtual const NumericVector< Number > & getVector (TagID tag) const
 
virtual bool hasVariable (const std::string &var_name) const
 Query a system for a variable. More...
 
virtual bool hasScalarVariable (const std::string &var_name) const
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

unsigned int _num_residual_evaluations
 
System & _sys
 
Real _last_nl_rnorm
 
Real _initial_residual_before_preset_bcs
 
Real _initial_residual_after_preset_bcs
 
std::vector< unsigned int_current_l_its
 
unsigned int _current_nl_its
 
bool _compute_initial_residual_before_preset_bcs
 
const ConsoleStream _console
 An instance of helper class to write streams to the Console objects. More...
 

Protected Member Functions

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

Protected Attributes

EigenSystem & _eigen_sys
 
EigenProblem_eigen_problem
 
std::unique_ptr< SlepcEigenSolverConfiguration_solver_configuration
 
std::vector< std::pair< Real, Real > > _eigen_values
 
unsigned int _n_eigen_pairs_required
 
NumericVector< Number > & _work_rhs_vector_AX
 
NumericVector< Number > & _work_rhs_vector_BX
 
TagID _Ax_tag
 
TagID _Bx_tag
 
TagID _A_tag
 
TagID _B_tag
 
TagID _precond_tag
 
bool _precond_matrix_includes_eigen
 
Preconditioner< Number > * _preconditioner
 
const Parallel::Communicator & _communicator
 
NumericVector< Number > * _residual_ghosted
 ghosted form of the residual More...
 
std::unique_ptr< NumericVector< Number > > _residual_copy
 Copy of the residual vector, or nullptr if a copy is not needed. More...
 
Number _du_dot_du
 \( {du^dot}\over{du} \) More...
 
Number _du_dotdot_du
 \( {du^dotdot}\over{du} \) More...
 
TagID _Re_time_tag
 Tag for time contribution residual. More...
 
std::set< TagID_nl_vector_tags
 Vector tags to temporarily store all tags associated with the current system. More...
 
std::set< TagID_nl_matrix_tags
 Matrix tags to temporarily store all tags associated with the current system. More...
 
NumericVector< Number > * _Re_time
 residual vector for time contributions More...
 
TagID _Re_non_time_tag
 Tag for non-time contribution residual. More...
 
NumericVector< Number > * _Re_non_time
 residual vector for non-time contributions More...
 
TagID _Re_tag
 Used for the residual vector from PETSc. More...
 
TagID _Ke_non_time_tag
 Tag for non-time contribution Jacobian. More...
 
TagID _Ke_system_tag
 Tag for system contribution Jacobian. More...
 
MooseObjectTagWarehouse< DiracKernelBase_dirac_kernels
 Dirac Kernel storage for each thread. More...
 
MooseObjectWarehouse< ElementDamper_element_dampers
 Element Dampers for each thread. More...
 
MooseObjectWarehouse< NodalDamper_nodal_dampers
 Nodal Dampers for each thread. More...
 
MooseObjectWarehouse< GeneralDamper_general_dampers
 General Dampers. More...
 
MooseObjectTagWarehouse< NodalKernelBase_nodal_kernels
 NodalKernels for each thread. More...
 
MooseObjectWarehouseBase< Split_splits
 Decomposition splits. More...
 
ConstraintWarehouse _constraints
 Constraints storage object. More...
 
NumericVector< Number > * _increment_vec
 increment vector More...
 
bool _use_finite_differenced_preconditioner
 Whether or not to use a finite differenced preconditioner. More...
 
MatFDColoring _fdcoloring
 
bool _have_decomposition
 Whether or not the system can be decomposed into splits. More...
 
std::string _decomposition_split
 Name of the top-level split of the decomposition. More...
 
bool _use_field_split_preconditioner
 Whether or not to use a FieldSplitPreconditioner matrix based on the decomposition. More...
 
bool _add_implicit_geometric_coupling_entries_to_jacobian
 Whether or not to add implicit geometric couplings to the Jacobian for FDP. More...
 
bool _assemble_constraints_separately
 Whether or not to assemble the residual and Jacobian after the application of each constraint. More...
 
bool _need_residual_ghosted
 Whether or not a ghosted copy of the residual needs to be made. More...
 
bool _debugging_residuals
 true if debugging residuals More...
 
bool _doing_dg
 true if DG is active (optimization reasons) More...
 
std::vector< std::string > _vecs_to_zero_for_residual
 vectors that will be zeroed before a residual computation More...
 
unsigned int _n_iters
 
unsigned int _n_linear_iters
 
unsigned int _n_residual_evaluations
 Total number of residual evaluations that have been performed. More...
 
Real _final_residual
 
std::shared_ptr< Predictor_predictor
 If predictor is active, this is non-NULL. More...
 
bool _computing_initial_residual
 
bool _print_all_var_norms
 
bool _has_save_in
 If there is any Kernel or IntegratedBC having save_in. More...
 
bool _has_diag_save_in
 If there is any Kernel or IntegratedBC having diag_save_in. More...
 
bool _has_nodalbc_save_in
 If there is a nodal BC having save_in. More...
 
bool _has_nodalbc_diag_save_in
 If there is a nodal BC having diag_save_in. More...
 
bool _computed_scaling
 Flag used to indicate whether we have already computed the scaling Jacobian. More...
 
bool _compute_scaling_once
 Whether the scaling factors should only be computed once at the beginning of the simulation through an extra Jacobian evaluation. More...
 
Real _resid_vs_jac_scaling_param
 The param that indicates the weighting of the residual vs the Jacobian in determining variable scaling parameters. More...
 
std::vector< std::vector< std::string > > _scaling_group_variables
 A container of variable groupings that can be used in scaling calculations. More...
 
std::vector< bool > _variable_autoscaled
 Container to hold flag if variable is to participate in autoscaling. More...
 
std::vector< std::string > _ignore_variables_for_autoscaling
 A container for variables that do not partipate in autoscaling. More...
 
bool _off_diagonals_in_auto_scaling
 Whether to include off diagonals when determining automatic scaling factors. More...
 
std::unique_ptr< DiagonalMatrix< Number > > _scaling_matrix
 A diagonal matrix used for computing scaling. More...
 
const NumericVector< Number > * _current_solution
 solution vector from solver More...
 
Moose::PCSideType _pc_side
 Preconditioning side. More...
 
Moose::MooseKSPNormType _ksp_norm
 KSP norm type. More...
 
bool _solution_is_invalid
 Boolean to see if solution is invalid. More...
 
SubProblem_subproblem
 The subproblem for whom this class holds variable data, etc; this can either be the governing finite element/volume problem or a subjugate displaced problem. More...
 
FEProblemBase_fe_problem
 the governing finite element/volume problem More...
 
MooseApp_app
 
Factory_factory
 
MooseMesh_mesh
 
std::string _name
 The name of this system. More...
 
std::vector< VariableWarehouse_vars
 Variable warehouses (one for each thread) More...
 
std::map< unsigned int, std::set< SubdomainID > > _var_map
 Map of variables (variable id -> array of subdomains where it lives) More...
 
unsigned int _max_var_number
 Maximum variable number. More...
 
std::vector< std::string > _vars_to_be_zeroed_on_residual
 
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
 
NumericVector< Number > * _u_dot
 solution vector for u^dot More...
 
NumericVector< Number > * _u_dotdot
 solution vector for u^dotdot More...
 
NumericVector< Number > * _u_dot_old
 old solution vector for u^dot More...
 
NumericVector< Number > * _u_dotdot_old
 old solution vector for u^dotdot More...
 
std::vector< NumericVector< Number > * > _tagged_vectors
 Tagged vectors (pointer) More...
 
std::vector< SparseMatrix< Number > * > _tagged_matrices
 Tagged matrices (pointer) More...
 
std::vector< bool > _matrix_tag_active_flags
 Active flags for tagged matrices. More...
 
NumericVector< Real > * _saved_old
 
NumericVector< Real > * _saved_older
 
NumericVector< Real > * _saved_dot_old
 
NumericVector< Real > * _saved_dotdot_old
 
Moose::VarKindType _var_kind
 default kind of variables in this system More...
 
std::vector< VarCopyInfo_var_to_copy
 
size_t _max_var_n_dofs_per_elem
 Maximum number of dofs for any one variable on any one element. More...
 
size_t _max_var_n_dofs_per_node
 Maximum number of dofs for any one variable on any one node. More...
 
std::shared_ptr< TimeIntegrator_time_integrator
 Time integrator. More...
 
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
 Map variable number to its pointer. More...
 
bool _automatic_scaling
 Whether to automatically scale the variables. More...
 
bool _verbose
 True if printing out additional information. More...
 
bool _solution_states_initialized
 Whether or not the solution states have been initialized. More...
 
std::vector< dof_id_type_var_all_dof_indices
 Container for the dof indices of a given variable. More...
 
std::unique_ptr< NumericVector< Number > > _serialized_solution
 Serialized version of the solution vector, or nullptr if a serialized solution is not needed. More...
 
std::vector< std::unique_ptr< NumericVector< Number > > > _raw_grad_container
 A cache for storing gradients at dof locations. More...
 
const Parallel::Communicator & _communicator
 
MooseApp_pg_moose_app
 The MooseApp that owns the PerfGraph. More...
 
const std::string _prefix
 A prefix to use for all sections. More...
 
MooseObjectTagWarehouse< KernelBase_kernels
 
MooseObjectTagWarehouse< ScalarKernelBase_scalar_kernels
 
MooseObjectTagWarehouse< DGKernelBase_dg_kernels
 
MooseObjectTagWarehouse< InterfaceKernelBase_interface_kernels
 
MooseObjectTagWarehouse< IntegratedBCBase_integrated_bcs
 
MooseObjectTagWarehouse< NodalBCBase_nodal_bcs
 
MooseObjectWarehouse< DirichletBCBase_preset_nodal_bcs
 
MooseObjectWarehouse< ADDirichletBCBase_ad_preset_nodal_bcs
 

Detailed Description

Nonlinear eigenvalue system to be solved.

Definition at line 29 of file NonlinearEigenSystem.h.

Constructor & Destructor Documentation

◆ NonlinearEigenSystem() [1/2]

NonlinearEigenSystem::NonlinearEigenSystem ( EigenProblem problem,
const std::string &  name 
)

Definition at line 101 of file NonlinearEigenSystem.C.

102  : NonlinearSystemBase(eigen_problem, eigen_problem.es().add_system<EigenSystem>(name), name),
103  _eigen_sys(eigen_problem.es().get_system<EigenSystem>(name)),
104  _eigen_problem(eigen_problem),
105  _solver_configuration(nullptr),
106  _n_eigen_pairs_required(eigen_problem.getNEigenPairsRequired()),
107  _work_rhs_vector_AX(addVector("work_rhs_vector_Ax", false, PARALLEL)),
108  _work_rhs_vector_BX(addVector("work_rhs_vector_Bx", false, PARALLEL)),
110  _preconditioner(nullptr)
111 {
112  sys().attach_assemble_function(Moose::assemble_matrix);
113 
114  SlepcEigenSolver<Number> * solver =
115  cast_ptr<SlepcEigenSolver<Number> *>(_eigen_sys.eigen_solver.get());
116 
117  if (!solver)
118  mooseError("A slepc eigen solver is required");
119 
120  // setup of our class @SlepcSolverConfiguration
121  _solver_configuration = std::make_unique<SlepcEigenSolverConfiguration>(eigen_problem, *solver);
122 
123  solver->set_solver_configuration(*_solver_configuration);
124 
125  _Ax_tag = eigen_problem.addVectorTag("Ax_tag");
126 
127  _Bx_tag = eigen_problem.addVectorTag("Eigen");
128 
129  _A_tag = eigen_problem.addMatrixTag("A_tag");
130 
131  _B_tag = eigen_problem.addMatrixTag("Eigen");
132 
133  // By default, _precond_tag and _A_tag will share the same
134  // objects. If we want to include eigen contributions to
135  // the preconditioning matrix, and then _precond_tag will
136  // point to part of "B" objects
137  _precond_tag = eigen_problem.addMatrixTag("Eigen_precond");
138 }
std::unique_ptr< SlepcEigenSolverConfiguration > _solver_configuration
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type)
Adds a solution length vector to the system.
Definition: SystemBase.C:604
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
NumericVector< Number > & _work_rhs_vector_AX
Preconditioner< Number > * _preconditioner
NumericVector< Number > & _work_rhs_vector_BX
virtual const std::string & name() const
Definition: SystemBase.C:1304
void assemble_matrix(EquationSystems &es, const std::string &system_name)
NonlinearSystemBase(FEProblemBase &problem, System &sys, const std::string &name)
unsigned int _n_eigen_pairs_required

◆ NonlinearEigenSystem() [2/2]

NonlinearEigenSystem::NonlinearEigenSystem ( EigenProblem problem,
const std::string &  name 
)

Member Function Documentation

◆ activeAllMatrixTags()

void SystemBase::activeAllMatrixTags ( )
virtualinherited

Make all exsiting matrices ative.

Definition at line 1110 of file SystemBase.C.

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

1111 {
1112  auto num_matrix_tags = _subproblem.numMatrixTags();
1113 
1114  _matrix_tag_active_flags.resize(num_matrix_tags);
1115 
1116  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
1117  if (hasMatrix(tag))
1118  _matrix_tag_active_flags[tag] = true;
1119  else
1120  _matrix_tag_active_flags[tag] = false;
1121 }
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:985
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:220

◆ activeMatrixTag()

void SystemBase::activeMatrixTag ( TagID  tag)
virtualinherited

Active a matrix for tag.

Definition at line 1075 of file SystemBase.C.

1076 {
1077  mooseAssert(_subproblem.matrixTagExists(tag),
1078  "Cannot active Matrix with matrix_tag : " << tag << "that does not exist");
1079 
1080  if (_matrix_tag_active_flags.size() < tag + 1)
1081  _matrix_tag_active_flags.resize(tag + 1);
1082 
1083  _matrix_tag_active_flags[tag] = true;
1084 }
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:985
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:306

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

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

◆ addConstraint()

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

Adds a Constraint.

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

Definition at line 585 of file NonlinearSystemBase.C.

588 {
589  std::shared_ptr<Constraint> constraint = _factory.create<Constraint>(c_name, name, parameters);
590  _constraints.addObject(constraint);
591  postAddResidualObject(*constraint);
592 
593  if (constraint && constraint->addCouplingEntriesToJacobian())
595 }
void addImplicitGeometricCouplingEntriesToJacobian(bool add=true)
If called with true this will add entries into the jacobian to link together degrees of freedom that ...
Base class for all Constraint types.
Definition: Constraint.h:19
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:110
Factory & _factory
Definition: SystemBase.h:951
virtual const std::string & name() const
Definition: SystemBase.C:1304
ConstraintWarehouse _constraints
Constraints storage object.
void addObject(std::shared_ptr< Constraint > object, THREAD_ID tid=0, bool recurse=true) override
Add Constraint object to the warehouse.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.

◆ addDamper()

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

Adds a damper.

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

Definition at line 652 of file NonlinearSystemBase.C.

655 {
656  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
657  {
658  std::shared_ptr<Damper> damper = _factory.create<Damper>(damper_name, name, parameters, tid);
659 
660  // Attempt to cast to the damper types
661  std::shared_ptr<ElementDamper> ed = std::dynamic_pointer_cast<ElementDamper>(damper);
662  std::shared_ptr<NodalDamper> nd = std::dynamic_pointer_cast<NodalDamper>(damper);
663  std::shared_ptr<GeneralDamper> gd = std::dynamic_pointer_cast<GeneralDamper>(damper);
664 
665  if (gd)
666  {
668  break; // not threaded
669  }
670  else if (ed)
671  _element_dampers.addObject(ed, tid);
672  else if (nd)
673  _nodal_dampers.addObject(nd, tid);
674  else
675  mooseError("Invalid damper type");
676  }
677 }
Base class for deriving general dampers.
Definition: GeneralDamper.h:21
unsigned int n_threads()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
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:110
Factory & _factory
Definition: SystemBase.h:951
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
virtual const std::string & name() const
Definition: SystemBase.C:1304
Base class for deriving nodal dampers.
Definition: NodalDamper.h:27
Base class for deriving element dampers.
Definition: ElementDamper.h:28
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
Base class for deriving dampers.
Definition: Damper.h:24
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:198

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

615 {
616  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
617  {
618  auto dg_kernel = _factory.create<DGKernelBase>(dg_kernel_name, name, parameters, tid);
619  _dg_kernels.addObject(dg_kernel, tid);
620  postAddResidualObject(*dg_kernel);
621  }
622 
623  _doing_dg = true;
624 
625  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
626  _has_save_in = true;
627  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
628  _has_diag_save_in = true;
629 }
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
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:110
Factory & _factory
Definition: SystemBase.h:951
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
Serves as a base class for DGKernel and ADDGKernel.
Definition: DGKernelBase.h:32
virtual const std::string & name() const
Definition: SystemBase.C:1304
bool _doing_dg
true if DG is active (optimization reasons)
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:198

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

601 {
602  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
603  {
604  std::shared_ptr<DiracKernelBase> kernel =
605  _factory.create<DiracKernelBase>(kernel_name, name, parameters, tid);
606  postAddResidualObject(*kernel);
607  _dirac_kernels.addObject(kernel, tid);
608  }
609 }
unsigned int n_threads()
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:110
Factory & _factory
Definition: SystemBase.h:951
virtual const std::string & name() const
Definition: SystemBase.C:1304
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
DiracKernelBase is the base class for all DiracKernel type classes.
unsigned int THREAD_ID
Definition: MooseTypes.h:198

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

Referenced by DisplacedSystem::addDotVectors().

1570 {
1571  if (_fe_problem.uDotRequested())
1572  _u_dot = &addVector("u_dot", true, GHOSTED);
1574  _u_dot_old = &addVector("u_dot_old", true, GHOSTED);
1576  _u_dotdot = &addVector("u_dotdot", true, GHOSTED);
1578  _u_dotdot_old = &addVector("u_dotdot_old", true, GHOSTED);
1579 }
virtual bool uDotDotOldRequested()
Get boolean flag to check whether old solution second time derivative needs to be stored...
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type)
Adds a solution length vector to the system.
Definition: SystemBase.C:604
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
Definition: SystemBase.h:973
virtual bool uDotRequested()
Get boolean flag to check whether solution time derivative needs to be stored.
virtual bool uDotDotRequested()
Get boolean flag to check whether solution second time derivative needs to be stored.
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
Definition: SystemBase.h:970
virtual bool uDotOldRequested()
Get boolean flag to check whether old solution time derivative needs to be stored.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
NumericVector< Number > * _u_dot
solution vector for u^dot
Definition: SystemBase.h:968
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
Definition: SystemBase.h:975

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

Referenced by NonlinearSystemBase::computeJacobianInternal().

2174 {
2175  if (!hasMatrix(systemMatrixTag()))
2176  mooseError("Need a system matrix ");
2177 
2178  // At this point, have no idea how to make
2179  // this work with tag system
2180  auto & jacobian = getMatrix(systemMatrixTag());
2181 
2182  std::unordered_map<dof_id_type, std::vector<dof_id_type>> graph;
2183 
2184  findImplicitGeometricCouplingEntries(geom_search_data, graph);
2185 
2186  for (const auto & it : graph)
2187  {
2188  dof_id_type dof = it.first;
2189  const auto & row = it.second;
2190 
2191  for (const auto & coupled_dof : row)
2192  jacobian.add(dof, coupled_dof, 0);
2193  }
2194 }
void findImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data, std::unordered_map< dof_id_type, std::vector< dof_id_type >> &graph)
Finds the implicit sparsity graph between geometrically related dofs.
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:980
uint8_t dof_id_type

◆ addImplicitGeometricCouplingEntriesToJacobian()

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

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

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

Definition at line 439 of file NonlinearSystemBase.h.

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

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

◆ addInterfaceKernel()

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

Adds an interface kernel.

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

Definition at line 632 of file NonlinearSystemBase.C.

635 {
636  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
637  {
638  std::shared_ptr<InterfaceKernelBase> interface_kernel =
639  _factory.create<InterfaceKernelBase>(interface_kernel_name, name, parameters, tid);
640  postAddResidualObject(*interface_kernel);
641 
642  const std::set<BoundaryID> & boundary_ids = interface_kernel->boundaryIDs();
643  auto ik_var = dynamic_cast<const MooseVariableFieldBase *>(&interface_kernel->variable());
644  _vars[tid].addBoundaryVar(boundary_ids, ik_var);
645 
646  _interface_kernels.addObject(interface_kernel, tid);
647  _vars[tid].addBoundaryVars(boundary_ids, interface_kernel->getCoupledVars());
648  }
649 }
unsigned int n_threads()
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:110
Factory & _factory
Definition: SystemBase.h:951
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual const std::string & name() const
Definition: SystemBase.C:1304
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
InterfaceKernelBase is the base class for all InterfaceKernel type classes.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:198

◆ addKernel()

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

Adds a kernel.

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

Reimplemented in MooseEigenSystem.

Definition at line 450 of file NonlinearSystemBase.C.

453 {
454  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
455  {
456  // Create the kernel object via the factory and add to warehouse
457  std::shared_ptr<KernelBase> kernel =
458  _factory.create<KernelBase>(kernel_name, name, parameters, tid);
459  _kernels.addObject(kernel, tid);
460  postAddResidualObject(*kernel);
461  }
462 
463  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
464  _has_save_in = true;
465  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
466  _has_diag_save_in = true;
467 }
unsigned int n_threads()
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:110
Factory & _factory
Definition: SystemBase.h:951
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
virtual const std::string & name() const
Definition: SystemBase.C:1304
This is the common base class for the three main kernel types implemented in MOOSE, Kernel, VectorKernel and ArrayKernel.
Definition: KernelBase.h:22
MooseObjectTagWarehouse< KernelBase > _kernels
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:198

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

567 {
568  if (!_subproblem.matrixTagExists(tag))
569  mooseError("Cannot add tagged matrix with TagID ",
570  tag,
571  " in system '",
572  name(),
573  "' because the tag does not exist in the problem");
574 
575  if (hasMatrix(tag))
576  return getMatrix(tag);
577 
578  const auto matrix_name = _subproblem.matrixTagName(tag);
579  SparseMatrix<Number> & mat = system().add_matrix(matrix_name);
580  associateMatrixToTag(mat, tag);
581 
582  return mat;
583 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
virtual const std::string & name() const
Definition: SystemBase.C:1304
virtual void associateMatrixToTag(SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
Definition: SystemBase.C:1032
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual System & system()=0
Get the reference to the libMesh system.
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:980
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:306
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:335

◆ addNodalKernel()

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

Adds a NodalKernel.

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

Definition at line 470 of file NonlinearSystemBase.C.

473 {
474  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
475  {
476  // Create the kernel object via the factory and add to the warehouse
477  std::shared_ptr<NodalKernelBase> kernel =
478  _factory.create<NodalKernelBase>(kernel_name, name, parameters, tid);
479  _nodal_kernels.addObject(kernel, tid);
480  postAddResidualObject(*kernel);
481  }
482 
483  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
484  _has_save_in = true;
485  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
486  _has_diag_save_in = true;
487 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
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:110
Factory & _factory
Definition: SystemBase.h:951
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
virtual const std::string & name() const
Definition: SystemBase.C:1304
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
Base class for creating new types of nodal kernels.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:198

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

493 {
494  std::shared_ptr<ScalarKernelBase> kernel =
495  _factory.create<ScalarKernelBase>(kernel_name, name, parameters);
496  postAddResidualObject(*kernel);
497  _scalar_kernels.addObject(kernel);
498 }
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:110
Factory & _factory
Definition: SystemBase.h:951
virtual const std::string & name() const
Definition: SystemBase.C:1304
Base class shared by AD and non-AD scalar kernels.
virtual void postAddResidualObject(ResidualObject &)
Called after any ResidualObject-derived objects are added to the system.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels

◆ addScalingVector()

void SystemBase::addScalingVector ( )
inherited

Add the scaling factor vector to the system.

Definition at line 1481 of file SystemBase.C.

Referenced by MooseVariableBase::initialSetup().

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

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

683 {
684  std::shared_ptr<Split> split = _factory.create<Split>(split_name, name, parameters);
686 }
Base class for split-based preconditioners.
Definition: Split.h:25
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:110
Factory & _factory
Definition: SystemBase.h:951
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.
virtual const std::string & name() const
Definition: SystemBase.C:1304
tbb::split split
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true)
Adds an object to the storage structure.

◆ addTimeIntegrator() [1/4]

void NonlinearSystemBase::addTimeIntegrator ( const std::string &  type,
const std::string &  name,
InputParameters parameters 
)
overridevirtualinherited

Add a time integrator.

Parameters
typeType of the integrator
nameThe name of the integrator
parametersIntegrator params

Reimplemented from SystemBase.

Definition at line 439 of file NonlinearSystemBase.C.

442 {
443  parameters.set<SystemBase *>("_sys") = this;
444 
445  std::shared_ptr<TimeIntegrator> ti = _factory.create<TimeIntegrator>(type, name, parameters);
446  _time_integrator = ti;
447 }
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
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:110
Factory & _factory
Definition: SystemBase.h:951
Base class for a system (of equations)
Definition: SystemBase.h:85
virtual const std::string & name() const
Definition: SystemBase.C:1304
Base class for time integrators.
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:1007

◆ addTimeIntegrator() [2/4]

virtual void SystemBase::addTimeIntegrator
inlineinherited

Definition at line 871 of file SystemBase.h.

874  {
875  }

◆ addTimeIntegrator() [3/4]

virtual void SystemBase::addTimeIntegrator
inlineinherited

Definition at line 877 of file SystemBase.h.

877 {}

◆ addTimeIntegrator() [4/4]

virtual void SystemBase::addTimeIntegrator ( std::shared_ptr< TimeIntegrator )
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 877 of file SystemBase.h.

877 {}

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

Referenced by AuxiliarySystem::addVariable().

718 {
720 
721  auto components = parameters.get<unsigned int>("components");
722 
723  // Convert the std::vector parameter provided by the user into a std::set for use by libMesh's
724  // System::add_variable method
725  std::set<SubdomainID> blocks;
726  const auto & block_param = parameters.get<std::vector<SubdomainName>>("block");
727  for (const auto & subdomain_name : block_param)
728  {
729  SubdomainID blk_id = _mesh.getSubdomainID(subdomain_name);
730  blocks.insert(blk_id);
731  }
732 
733  auto fe_type = FEType(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")),
734  Utility::string_to_enum<FEFamily>(parameters.get<MooseEnum>("family")));
735 
736  unsigned int var_num;
737 
738  if (var_type == "ArrayMooseVariable")
739  {
740  if (fe_type.family == NEDELEC_ONE || fe_type.family == LAGRANGE_VEC ||
741  fe_type.family == MONOMIAL_VEC || fe_type.family == RAVIART_THOMAS)
742  mooseError("Vector family type cannot be used in an array variable");
743 
744  // Build up the variable names
745  std::vector<std::string> var_names;
746  for (unsigned int i = 0; i < components; i++)
747  var_names.push_back(SubProblem::arrayVariableComponent(name, i));
748 
749  // The number returned by libMesh is the _last_ variable number... we want to hold onto the
750  // _first_
751  var_num = system().add_variables(var_names, fe_type, &blocks) - (components - 1);
752 
753  // Set as array variable
754  if (parameters.isParamSetByUser("array") && !parameters.get<bool>("array"))
755  mooseError("Variable '",
756  name,
757  "' is an array variable ('components' > 1) but 'array' is set to false.");
758  parameters.set<bool>("array") = true;
759  }
760  else
761  var_num = system().add_variable(name, fe_type, &blocks);
762 
763  parameters.set<unsigned int>("_var_num") = var_num;
764  parameters.set<SystemBase *>("_system_base") = this;
765 
766  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
767  {
768  parameters.set<THREAD_ID>("tid") = tid;
769  std::shared_ptr<MooseVariableBase> var =
770  _factory.create<MooseVariableBase>(var_type, name, parameters, tid);
771 
772  _vars[tid].add(name, var);
773 
774  if (auto fe_var = dynamic_cast<MooseVariableFieldBase *>(var.get()))
775  {
776  auto required_size = var_num + components;
777  if (required_size > _numbered_vars[tid].size())
778  _numbered_vars[tid].resize(required_size);
779  for (MooseIndex(components) component = 0; component < components; ++component)
780  _numbered_vars[tid][var_num + component] = fe_var;
781 
782  if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADReal> *>(fe_var))
783  _subproblem.addFunctor(name, *functor, tid);
784  else if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADRealVectorValue> *>(fe_var))
785  _subproblem.addFunctor(name, *functor, tid);
786  else if (auto * const functor = dynamic_cast<Moose::FunctorBase<RealEigenVector> *>(fe_var))
787  _subproblem.addFunctor(name, *functor, tid);
788  else
789  mooseError("This should be a functor");
790  }
791 
792  if (var->blockRestricted())
793  for (const SubdomainID & id : var->blockIDs())
794  for (MooseIndex(components) component = 0; component < components; ++component)
795  _var_map[var_num + component].insert(id);
796  else
797  for (MooseIndex(components) component = 0; component < components; ++component)
798  _var_map[var_num + component] = std::set<SubdomainID>();
799  }
800 
801  // getMaxVariableNumber is an API method used in Rattlesnake
802  if (var_num > _max_var_number)
803  _max_var_number = var_num;
804 }
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
Map variable number to its pointer.
Definition: SystemBase.h:1010
unsigned int n_threads()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
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:110
void addFunctor(const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
add a functor to the problem functor container
Definition: SubProblem.h:1329
Factory & _factory
Definition: SystemBase.h:951
Base class for a system (of equations)
Definition: SystemBase.h:85
virtual const std::string & name() const
Definition: SystemBase.C:1304
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
subdomain_id_type SubdomainID
virtual System & system()=0
Get the reference to the libMesh system.
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
Definition: SystemBase.h:960
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was by the user.
static std::string arrayVariableComponent(const std::string &var_name, unsigned int i)
Returns the variable name of a component of an array variable.
Definition: SubProblem.h:271
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958
MooseMesh & _mesh
Definition: SystemBase.h:953
unsigned int _max_var_number
Maximum variable number.
Definition: SystemBase.h:962
unsigned int THREAD_ID
Definition: MooseTypes.h:198
SubdomainID getSubdomainID(const SubdomainName &subdomain_name) const
Get the associated subdomain ID for the subdomain name.
Definition: MooseMesh.C:1514

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

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

1153 {
1154  _var_to_copy.push_back(VarCopyInfo(dest_name, source_name, timestep));
1155 }
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:998
Information about variables that will be copied.
Definition: SystemBase.h:67

◆ addVariableToZeroOnJacobian()

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

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

Parameters
var_nameThe name of the variable to be zeroed.

Reimplemented in DisplacedSystem.

Definition at line 176 of file SystemBase.C.

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

177 {
178  _vars_to_be_zeroed_on_jacobian.push_back(var_name);
179 }
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
Definition: SystemBase.h:965

◆ addVariableToZeroOnResidual()

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

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

Parameters
var_nameThe name of the variable to be zeroed.

Reimplemented in DisplacedSystem.

Definition at line 170 of file SystemBase.C.

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

171 {
172  _vars_to_be_zeroed_on_residual.push_back(var_name);
173 }
std::vector< std::string > _vars_to_be_zeroed_on_residual
Definition: SystemBase.h:964

◆ addVector() [1/2]

NumericVector< Number > & SystemBase::addVector ( const std::string &  vector_name,
const bool  project,
const 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 604 of file SystemBase.C.

Referenced by SystemBase::addDotVectors(), SystemBase::addScalingVector(), SteffensenSolve::allocateStorage(), SecantSolve::allocateStorage(), PicardSolve::allocateStorage(), AStableDirk4::AStableDirk4(), ExplicitTimeIntegrator::ExplicitTimeIntegrator(), NonlinearSystemBase::getResidualNonTimeVector(), NonlinearSystemBase::getResidualTimeVector(), CentralDifference::initialSetup(), LStableDirk3::LStableDirk3(), LStableDirk4::LStableDirk4(), SystemBase::needSolutionState(), NonlinearSystemBase::residualGhosted(), and SystemBase::saveOldSolutions().

605 {
606  if (hasVector(vector_name))
607  return getVector(vector_name);
608 
609  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
610  return vec;
611 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
virtual System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

◆ addVector() [2/2]

NumericVector< Number > & SystemBase::addVector ( TagID  tag,
const bool  project,
const 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 614 of file SystemBase.C.

615 {
616  if (!_subproblem.vectorTagExists(tag))
617  mooseError("Cannot add tagged vector with TagID ",
618  tag,
619  " in system '",
620  name(),
621  "' because the tag does not exist in the problem");
622 
623  if (hasVector(tag))
624  {
625  auto & vec = getVector(tag);
626 
627  if (type != ParallelType::AUTOMATIC && vec.type() != type)
628  mooseError("Cannot add tagged vector '",
630  "', in system '",
631  name(),
632  "' because a vector with the same name was found with a different parallel type");
633 
634  return vec;
635  }
636 
637  const auto vector_name = _subproblem.vectorTagName(tag);
638  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
639  associateVectorToTag(vec, tag);
640 
641  return vec;
642 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:937
virtual const std::string & name() const
Definition: SystemBase.C:1304
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:173
virtual System & system()=0
Get the reference to the libMesh system.
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:199
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

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

Referenced by NonlinearSystemBase::computeScaling().

1432 {
1433  for (MooseIndex(_vars) thread = 0; thread < _vars.size(); ++thread)
1434  {
1435  auto & field_variables = _vars[thread].fieldVariables();
1436  for (MooseIndex(field_variables) i = 0, p = 0; i < field_variables.size(); ++i)
1437  {
1438  auto factors = field_variables[i]->arrayScalingFactor();
1439  for (unsigned int j = 0; j < field_variables[i]->count(); ++j, ++p)
1440  factors[j] /= inverse_scaling_factors[p];
1441 
1442  field_variables[i]->scalingFactor(factors);
1443  }
1444 
1445  auto offset = field_variables.size();
1446 
1447  auto & scalar_variables = _vars[thread].scalars();
1448  for (MooseIndex(scalar_variables) i = 0; i < scalar_variables.size(); ++i)
1449  scalar_variables[i]->scalingFactor(
1450  {1. / inverse_scaling_factors[offset + i] * scalar_variables[i]->scalingFactor()});
1451 
1452  if (thread == 0 && _verbose)
1453  {
1454  _console << "Automatic scaling factors:\n";
1455  auto original_flags = _console.flags();
1456  auto original_precision = _console.precision();
1457  _console.unsetf(std::ios_base::floatfield);
1458  _console.precision(6);
1459 
1460  for (const auto & field_variable : field_variables)
1461  {
1462  const auto & factors = field_variable->arrayScalingFactor();
1463  _console << " " << field_variable->name() << ":";
1464  for (const auto i : make_range(field_variable->count()))
1465  _console << " " << factors[i];
1466  _console << "\n";
1467  }
1468  for (const auto & scalar_variable : scalar_variables)
1469  _console << " " << scalar_variable->name() << ": " << scalar_variable->scalingFactor()
1470  << "\n";
1471  _console << "\n" << std::endl;
1472 
1473  // restore state
1474  _console.flags(original_flags);
1475  _console.precision(original_precision);
1476  }
1477  }
1478 }
std::ios_base::fmtflags flags() const
Return the current flags.
Definition: ConsoleStream.C:58
void unsetf(std::ios_base::fmtflags mask) const
Unset format flags.
Definition: ConsoleStream.C:40
std::streamsize precision() const
Return the current precision.
Definition: ConsoleStream.C:46
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958
bool _verbose
True if printing out additional information.
Definition: SystemBase.h:1016
IntRange< T > make_range(T beg, T end)
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.

◆ assembleConstraintsSeparately()

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

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

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

Definition at line 449 of file NonlinearSystemBase.h.

450  {
452  }
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 3902 of file NonlinearSystemBase.C.

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

3903 {
3904  if (!hasVector("scaling_factors"))
3905  // No variables have indicated they need scaling
3906  return;
3907 
3908  auto & scaling_vector = getVector("scaling_factors");
3909 
3910  const auto & lm_mesh = _mesh.getMesh();
3911  const auto & dof_map = dofMap();
3912 
3913  const auto & field_variables = _vars[0].fieldVariables();
3914  const auto & scalar_variables = _vars[0].scalars();
3915 
3916  std::vector<dof_id_type> dof_indices;
3917 
3918  for (const Elem * const elem :
3919  as_range(lm_mesh.active_local_elements_begin(), lm_mesh.active_local_elements_end()))
3920  for (const auto * const field_var : field_variables)
3921  {
3922  const auto & factors = field_var->arrayScalingFactor();
3923  for (const auto i : make_range(field_var->count()))
3924  {
3925  dof_map.dof_indices(elem, dof_indices, field_var->number() + i);
3926  for (const auto dof : dof_indices)
3927  scaling_vector.set(dof, factors[i]);
3928  }
3929  }
3930 
3931  for (const auto * const scalar_var : scalar_variables)
3932  {
3933  mooseAssert(scalar_var->count() == 1,
3934  "Scalar variables should always have only one component.");
3935  dof_map.SCALAR_dof_indices(dof_indices, scalar_var->number());
3936  for (const auto dof : dof_indices)
3937  scaling_vector.set(dof, scalar_var->scalingFactor());
3938  }
3939 
3940  // Parallel assemble
3941  scaling_vector.close();
3942 
3943  if (auto * displaced_problem = _fe_problem.getDisplacedProblem().get())
3944  // copy into the corresponding displaced system vector because they should be the exact same
3945  displaced_problem->systemBaseNonlinear(number()).getVector("scaling_factors") = scaling_vector;
3946 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
virtual DofMap & dofMap()
Gets writeable reference to the dof map.
Definition: SystemBase.C:1138
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3199
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1132
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
MooseMesh & _mesh
Definition: SystemBase.h:953
IntRange< T > make_range(T beg, T end)
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

◆ assignMaxVarNDofsPerElem()

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

assign the maximum element dofs

Definition at line 585 of file SystemBase.h.

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

◆ assignMaxVarNDofsPerNode()

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

assign the maximum node dofs

Definition at line 590 of file SystemBase.h.

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

◆ associateMatrixToTag()

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

Associate a matrix to a tag.

Reimplemented in DisplacedSystem.

Definition at line 1032 of file SystemBase.C.

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

1033 {
1034  if (!_subproblem.matrixTagExists(tag))
1035  mooseError("Cannot associate matrix to tag ", tag, " because that tag does not exist");
1036 
1037  if (_tagged_matrices.size() < tag + 1)
1038  _tagged_matrices.resize(tag + 1);
1039 
1040  _tagged_matrices[tag] = &matrix;
1041 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:983
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:306

◆ associateVectorToTag()

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

Associate a vector for a given tag.

Reimplemented in DisplacedSystem.

Definition at line 937 of file SystemBase.C.

Referenced by SystemBase::addVector(), DisplacedSystem::associateVectorToTag(), FEProblemBase::computeLinearSystemTags(), NonlinearSystemBase::computeNodalBCs(), FEProblemBase::computeResidual(), FEProblemBase::computeResidualAndJacobian(), FEProblemBase::computeResidualInternal(), NonlinearSystemBase::computeResidualTag(), FEProblemBase::computeResidualTag(), FEProblemBase::computeResidualType(), and SolverSystem::setSolution().

938 {
939  if (!_subproblem.vectorTagExists(tag))
940  mooseError("Cannot associate vector to tag ", tag, " because that tag does not exist");
941 
942  if (_tagged_vectors.size() < tag + 1)
943  _tagged_vectors.resize(tag + 1);
944 
945  _tagged_vectors[tag] = &vec;
946 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:173
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:981

◆ attachPreconditioner()

void NonlinearEigenSystem::attachPreconditioner ( Preconditioner< Number > *  preconditioner)
overridevirtual

Attach a customized preconditioner that requires physics knowledge.

Generic preconditioners should be implemented in PETSc, instead.

Implements NonlinearSystemBase.

Definition at line 430 of file NonlinearEigenSystem.C.

431 {
433 
434  // If we have a customized preconditioner,
435  // We need to let PETSc know that
436  if (_preconditioner)
437  {
439  // Mark this, and then we can setup correct petsc options
442  }
443 }
SolverParams & solverParams()
Get the solver parameters.
bool _customized_pc_for_eigen
Definition: SolverParams.h:29
Preconditioner< Number > * _preconditioner
Jacobian-Free Newton Krylov.
Definition: MooseTypes.h:758
Moose::SolveType _type
Definition: SolverParams.h:19
Preconditioner< Number > * preconditioner() const
PETSC_EXTERN PetscErrorCode registerPCToPETSc()
Let PETSc know there is a preconditioner.

◆ attachSLEPcCallbacks()

void NonlinearEigenSystem::attachSLEPcCallbacks ( )

Definition at line 233 of file NonlinearEigenSystem.C.

234 {
235  // Tell libmesh not close matrices before solve
236  _eigen_sys.get_eigen_solver().set_close_matrix_before_solve(false);
237 
238  // Matrix A
239  if (_eigen_sys.has_matrix_A())
240  {
241  Mat mat = static_cast<PetscMatrix<Number> &>(_eigen_sys.get_matrix_A()).mat();
242 
244  }
245 
246  // Matrix B
247  if (_eigen_sys.has_matrix_B())
248  {
249  Mat mat = static_cast<PetscMatrix<Number> &>(_eigen_sys.get_matrix_B()).mat();
250 
252  }
253 
254  // Shell matrix A
255  if (_eigen_sys.has_shell_matrix_A())
256  {
257  Mat mat = static_cast<PetscShellMatrix<Number> &>(_eigen_sys.get_shell_matrix_A()).mat();
258 
259  // Attach callbacks for nonlinear eigenvalue solver
261 
262  // Set MatMult operations for shell
264  }
265 
266  // Shell matrix B
267  if (_eigen_sys.has_shell_matrix_B())
268  {
269  Mat mat = static_cast<PetscShellMatrix<Number> &>(_eigen_sys.get_shell_matrix_B()).mat();
270 
272 
273  // Set MatMult operations for shell
275  }
276 
277  // Preconditioning matrix
278  if (_eigen_sys.has_precond_matrix())
279  {
280  Mat mat = static_cast<PetscMatrix<Number> &>(_eigen_sys.get_precond_matrix()).mat();
281 
283  }
284 
285  // Shell preconditioning matrix
286  if (_eigen_sys.has_shell_precond_matrix())
287  {
288  Mat mat = static_cast<PetscShellMatrix<Number> &>(_eigen_sys.get_shell_precond_matrix()).mat();
289 
291  }
292 }
void attachCallbacksToMat(EigenProblem &eigen_problem, Mat mat, bool eigen)
Attach call backs to mat.
Definition: SlepcSupport.C:982
void setOperationsForShellMat(EigenProblem &eigen_problem, Mat mat, bool eigen)
Set operations to shell mat.

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

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

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

◆ augmentSparsity()

void NonlinearSystemBase::augmentSparsity ( 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 3338 of file NonlinearSystemBase.C.

3341 {
3343  {
3345 
3346  std::unordered_map<dof_id_type, std::vector<dof_id_type>> graph;
3347 
3349 
3352  graph);
3353 
3354  const dof_id_type first_dof_on_proc = dofMap().first_dof(processor_id());
3355  const dof_id_type end_dof_on_proc = dofMap().end_dof(processor_id());
3356 
3357  // The total number of dofs on and off processor
3358  const dof_id_type n_dofs_on_proc = dofMap().n_local_dofs();
3359  const dof_id_type n_dofs_not_on_proc = dofMap().n_dofs() - dofMap().n_local_dofs();
3360 
3361  for (const auto & git : graph)
3362  {
3363  dof_id_type dof = git.first;
3364  dof_id_type local_dof = dof - first_dof_on_proc;
3365 
3366  if (dof < first_dof_on_proc || dof >= end_dof_on_proc)
3367  continue;
3368 
3369  const auto & row = git.second;
3370 
3371  SparsityPattern::Row & sparsity_row = sparsity[local_dof];
3372 
3373  unsigned int original_row_length = sparsity_row.size();
3374 
3375  sparsity_row.insert(sparsity_row.end(), row.begin(), row.end());
3376 
3377  SparsityPattern::sort_row(
3378  sparsity_row.begin(), sparsity_row.begin() + original_row_length, sparsity_row.end());
3379 
3380  // Fix up nonzero arrays
3381  for (const auto & coupled_dof : row)
3382  {
3383  if (coupled_dof < first_dof_on_proc || coupled_dof >= end_dof_on_proc)
3384  {
3385  if (n_oz[local_dof] < n_dofs_not_on_proc)
3386  n_oz[local_dof]++;
3387  }
3388  else
3389  {
3390  if (n_nz[local_dof] < n_dofs_on_proc)
3391  n_nz[local_dof]++;
3392  }
3393  }
3394  }
3395  }
3396 }
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.
virtual GeometricSearchData & geomSearchData() override
virtual DofMap & dofMap()
Gets writeable reference to the dof map.
Definition: SystemBase.C:1138
virtual void updateGeomSearch(GeometricSearchData::GeometricSearchType type=GeometricSearchData::ALL) override
bool _add_implicit_geometric_coupling_entries_to_jacobian
Whether or not to add implicit geometric couplings to the Jacobian for FDP.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
processor_id_type processor_id() const
uint8_t dof_id_type

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

Referenced by SubProblem::automaticScaling().

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

◆ 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; }
bool _automatic_scaling
Whether to automatically scale the variables.
Definition: SystemBase.h:1013

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

Referenced by FEProblemSolve::FEProblemSolve().

625  {
626  _resid_vs_jac_scaling_param = resid_vs_jac_scaling_param;
627  }
Real _resid_vs_jac_scaling_param
The param that indicates the weighting of the residual vs the Jacobian in determining variable scalin...

◆ checkIntegrity() [1/2]

void NonlinearEigenSystem::checkIntegrity ( )

For eigenvalue problems (including standard and generalized), inhomogeneous (Dirichlet or Neumann) boundary conditions are not allowed.

Definition at line 372 of file NonlinearEigenSystem.C.

373 {
375  {
376  const auto & nodal_bcs = _nodal_bcs.getActiveObjects();
377  for (const auto & nodal_bc : nodal_bcs)
378  {
379  // If this is a dirichlet boundary condition
380  auto nbc = std::dynamic_pointer_cast<DirichletBC>(nodal_bc);
381  // If this is a eigen Dirichlet boundary condition
382  auto eigen_nbc = std::dynamic_pointer_cast<EigenDirichletBC>(nodal_bc);
383  // ArrayDirichletBC
384  auto anbc = std::dynamic_pointer_cast<ArrayDirichletBC>(nodal_bc);
385  // EigenArrayDirichletBC
386  auto aeigen_nbc = std::dynamic_pointer_cast<EigenArrayDirichletBC>(nodal_bc);
387  // If it is a Dirichlet boundary condition, then value has to be zero
388  if (nbc && nbc->variable().eigen() && nbc->getParam<Real>("value"))
389  mooseError(
390  "Can't set an inhomogeneous Dirichlet boundary condition for eigenvalue problems.");
391  // If it is an array Dirichlet boundary condition, all values should be zero
392  else if (anbc)
393  {
394  auto & values = anbc->getParam<RealEigenVector>("values");
395  for (MooseIndex(values) i = 0; i < values.size(); i++)
396  {
397  if (values(i))
398  mooseError("Can't set an inhomogeneous array Dirichlet boundary condition for "
399  "eigenvalue problems.");
400  }
401  }
402  else if (!nbc && !eigen_nbc && !anbc && !aeigen_nbc)
403  mooseError(
404  "Invalid NodalBC for eigenvalue problems, please use homogeneous (array) Dirichlet.");
405  }
406  }
407 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
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.
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...
Boundary condition of a Dirichlet type.
Definition: DirichletBC.h:19
Set Dirichlet boundary condition for eigenvalue problems.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool hasActiveObjects(THREAD_ID tid=0) const
Boundary condition of a Dirichlet type for the eigen side.
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealEigenVector
Definition: MooseTypes.h:138
Boundary condition of a Dirichlet type.

◆ checkIntegrity() [2/2]

void NonlinearEigenSystem::checkIntegrity ( )
inline

Definition at line 207 of file NonlinearEigenSystem.h.

207 {}

◆ checkInvalidSolution()

void SolverSystem::checkInvalidSolution ( )
protectedinherited

Definition at line 108 of file SolverSystem.C.

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

109 {
110  // determine whether solution invalid occurs in the converged solution
112 
113  // output the solution invalid summary
115  {
116  // sync all solution invalid counts to rank 0 process
118 
120  mooseWarning("The Solution Invalidity warnings are detected but silenced! "
121  "Use Problem/allow_invalid_solution=false to activate ");
122  else
123  // output the occurrence of solution invalid in a summary table
125  }
126 }
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:333
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:138
bool allowInvalidSolution() const
Whether or not the invalid solutions are allowed.
bool _solution_is_invalid
Boolean to see if solution is invalid.
Definition: SolverSystem.h:85
bool solutionInvalid() const
Loop over all the tracked objects and determine whether solution invalid is detected.
MooseApp & _app
Definition: SystemBase.h:950
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
void print(const ConsoleStream &console) const
Print the summary table of Solution Invalid warnings.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.

◆ checkKernelCoverage()

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

System Integrity Checks

Definition at line 3460 of file NonlinearSystemBase.C.

3461 {
3462  // Obtain all blocks and variables covered by all kernels
3463  std::set<SubdomainID> input_subdomains;
3464  std::set<std::string> kernel_variables;
3465 
3466  bool global_kernels_exist = false;
3467  global_kernels_exist |= _scalar_kernels.hasActiveObjects();
3468  global_kernels_exist |= _nodal_kernels.hasActiveObjects();
3469 
3470  _kernels.subdomainsCovered(input_subdomains, kernel_variables);
3471  _dg_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3472  _nodal_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3473  _scalar_kernels.subdomainsCovered(input_subdomains, kernel_variables);
3474  _constraints.subdomainsCovered(input_subdomains, kernel_variables);
3475 
3476  if (_fe_problem.haveFV())
3477  {
3478  std::vector<FVElementalKernel *> fv_elemental_kernels;
3480  .query()
3481  .template condition<AttribSystem>("FVElementalKernel")
3482  .queryInto(fv_elemental_kernels);
3483 
3484  for (auto fv_kernel : fv_elemental_kernels)
3485  {
3486  if (fv_kernel->blockRestricted())
3487  for (auto block_id : fv_kernel->blockIDs())
3488  input_subdomains.insert(block_id);
3489  else
3490  global_kernels_exist = true;
3491  kernel_variables.insert(fv_kernel->variable().name());
3492 
3493  // Check for lagrange multiplier
3494  if (dynamic_cast<FVScalarLagrangeMultiplierConstraint *>(fv_kernel))
3495  kernel_variables.insert(dynamic_cast<FVScalarLagrangeMultiplierConstraint *>(fv_kernel)
3496  ->lambdaVariable()
3497  .name());
3498  }
3499 
3500  std::vector<FVFluxKernel *> fv_flux_kernels;
3502  .query()
3503  .template condition<AttribSystem>("FVFluxKernel")
3504  .queryInto(fv_flux_kernels);
3505 
3506  for (auto fv_kernel : fv_flux_kernels)
3507  {
3508  if (fv_kernel->blockRestricted())
3509  for (auto block_id : fv_kernel->blockIDs())
3510  input_subdomains.insert(block_id);
3511  else
3512  global_kernels_exist = true;
3513  kernel_variables.insert(fv_kernel->variable().name());
3514  }
3515 
3516  std::vector<FVInterfaceKernel *> fv_interface_kernels;
3518  .query()
3519  .template condition<AttribSystem>("FVInterfaceKernel")
3520  .queryInto(fv_interface_kernels);
3521 
3522  for (auto fvik : fv_interface_kernels)
3523  if (auto scalar_fvik = dynamic_cast<FVScalarLagrangeMultiplierInterface *>(fvik))
3524  kernel_variables.insert(scalar_fvik->lambdaVariable().name());
3525 
3526  std::vector<FVFluxBC *> fv_flux_bcs;
3528  .query()
3529  .template condition<AttribSystem>("FVFluxBC")
3530  .queryInto(fv_flux_bcs);
3531 
3532  for (auto fvbc : fv_flux_bcs)
3533  if (auto scalar_fvbc = dynamic_cast<FVBoundaryScalarLagrangeMultiplierConstraint *>(fvbc))
3534  kernel_variables.insert(scalar_fvbc->lambdaVariable().name());
3535  }
3536 
3537  // Check kernel coverage of subdomains (blocks) in your mesh
3538  if (!global_kernels_exist)
3539  {
3540  std::set<SubdomainID> difference;
3541  std::set_difference(mesh_subdomains.begin(),
3542  mesh_subdomains.end(),
3543  input_subdomains.begin(),
3544  input_subdomains.end(),
3545  std::inserter(difference, difference.end()));
3546 
3547  // there supposed to be no kernels on this lower-dimensional subdomain
3548  difference.erase(Moose::INTERNAL_SIDE_LOWERD_ID);
3549  difference.erase(Moose::BOUNDARY_SIDE_LOWERD_ID);
3550 
3551  if (!difference.empty())
3552  {
3553  std::vector<SubdomainID> difference_vec =
3554  std::vector<SubdomainID>(difference.begin(), difference.end());
3555  std::vector<SubdomainName> difference_names = _mesh.getSubdomainNames(difference_vec);
3556  std::stringstream missing_block_names;
3557  std::copy(difference_names.begin(),
3558  difference_names.end(),
3559  std::ostream_iterator<std::string>(missing_block_names, " "));
3560  std::stringstream missing_block_ids;
3561  std::copy(difference.begin(),
3562  difference.end(),
3563  std::ostream_iterator<unsigned int>(missing_block_ids, " "));
3564 
3565  mooseError("Each subdomain must contain at least one Kernel.\nThe following block(s) lack an "
3566  "active kernel: " +
3567  missing_block_names.str(),
3568  " (ids: ",
3569  missing_block_ids.str(),
3570  ")");
3571  }
3572  }
3573 
3574  // Check kernel use of variables
3575  std::set<VariableName> variables(getVariableNames().begin(), getVariableNames().end());
3576 
3577  std::set<VariableName> difference;
3578  std::set_difference(variables.begin(),
3579  variables.end(),
3580  kernel_variables.begin(),
3581  kernel_variables.end(),
3582  std::inserter(difference, difference.end()));
3583 
3584  // skip checks for varaibles defined on lower-dimensional subdomain
3585  std::set<VariableName> vars(difference);
3586  for (auto & var_name : vars)
3587  {
3588  auto blks = getSubdomainsForVar(var_name);
3589  if (blks.count(Moose::INTERNAL_SIDE_LOWERD_ID) || blks.count(Moose::BOUNDARY_SIDE_LOWERD_ID))
3590  difference.erase(var_name);
3591  }
3592 
3593  if (!difference.empty())
3594  {
3595  std::stringstream missing_kernel_vars;
3596  std::copy(difference.begin(),
3597  difference.end(),
3598  std::ostream_iterator<std::string>(missing_kernel_vars, " "));
3599  mooseError("Each variable must be referenced by at least one active Kernel.\nThe following "
3600  "variable(s) lack an active kernel: " +
3601  missing_kernel_vars.str());
3602  }
3603 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
const SubdomainID BOUNDARY_SIDE_LOWERD_ID
Definition: MooseTypes.C:21
TheWarehouse & theWarehouse() const
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Populates a set of covered subdomains and the associated variable names.
MooseObjectTagWarehouse< KernelBase > _kernels
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:1544
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
MooseMesh & _mesh
Definition: SystemBase.h:953
bool hasActiveObjects(THREAD_ID tid=0) const
const SubdomainID INTERNAL_SIDE_LOWERD_ID
Definition: MooseTypes.C:20
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:853
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
Definition: SystemBase.h:752
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Update supplied subdomain and variable coverate containters.
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels

◆ clearAllDofIndices()

void SystemBase::clearAllDofIndices ( )
inherited

Clear all dof indices from moose variables.

Definition at line 1549 of file SystemBase.C.

Referenced by SubProblem::clearAllDofIndices().

1550 {
1551  for (auto & var_warehouse : _vars)
1552  var_warehouse.clearAllDofIndices();
1553 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

◆ closeTaggedMatrices()

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

Close all matrices associated the tags.

Definition at line 1016 of file SystemBase.C.

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

1017 {
1018  for (auto tag : tags)
1019  if (hasMatrix(tag))
1020  getMatrix(tag).close();
1021 }
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
virtual void close()=0
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:980

◆ closeTaggedVector()

void SystemBase::closeTaggedVector ( const TagID  tag)
inherited

Close vector with the given tag.

Definition at line 645 of file SystemBase.C.

Referenced by SystemBase::closeTaggedVectors().

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

◆ closeTaggedVectors()

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

Close all vectors for given tags.

Definition at line 664 of file SystemBase.C.

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

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

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

Referenced by FEProblemBase::computeDamping().

3188 {
3189  // Default to no damping
3190  Real damping = 1.0;
3191  bool has_active_dampers = false;
3192 
3193  try
3194  {
3196  {
3197  PARALLEL_TRY
3198  {
3199  TIME_SECTION("computeDampers", 3, "Computing Dampers");
3200  has_active_dampers = true;
3203  Threads::parallel_reduce(*_mesh.getActiveLocalElementRange(), cid);
3204  damping = std::min(cid.damping(), damping);
3205  }
3206  PARALLEL_CATCH;
3207  }
3208 
3210  {
3211  PARALLEL_TRY
3212  {
3213  TIME_SECTION("computeDamping::element", 3, "Computing Element Damping");
3214 
3215  has_active_dampers = true;
3218  Threads::parallel_reduce(*_mesh.getLocalNodeRange(), cndt);
3219  damping = std::min(cndt.damping(), damping);
3220  }
3221  PARALLEL_CATCH;
3222  }
3223 
3225  {
3226  PARALLEL_TRY
3227  {
3228  TIME_SECTION("computeDamping::general", 3, "Computing General Damping");
3229 
3230  has_active_dampers = true;
3231  const auto & gdampers = _general_dampers.getActiveObjects();
3232  for (const auto & damper : gdampers)
3233  {
3234  Real gd_damping = damper->computeDamping(solution, update);
3235  try
3236  {
3237  damper->checkMinDamping(gd_damping);
3238  }
3239  catch (MooseException & e)
3240  {
3242  }
3243  damping = std::min(gd_damping, damping);
3244  }
3245  }
3246  PARALLEL_CATCH;
3247  }
3248  }
3249  catch (MooseException & e)
3250  {
3251  // The buck stops here, we have already handled the exception by
3252  // calling stopSolve(), it is now up to PETSc to return a
3253  // "diverged" reason during the next solve.
3254  }
3255 
3256  _communicator.min(damping);
3257 
3258  if (has_active_dampers && damping < 1.0)
3259  _console << " Damping factor: " << damping << std::endl;
3260 
3261  return damping;
3262 }
virtual void update(bool update_libmesh_system=true)
Update the system (doing libMesh magic)
Definition: SystemBase.C:1218
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:1041
virtual const char * what() const
Get out the error message.
NumericVector< Number > & solution()
Definition: SystemBase.h:182
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
const Parallel::Communicator & _communicator
ConstNodeRange * getLocalNodeRange()
Definition: MooseMesh.C:1078
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
void min(const T &r, T &o, Request &req) const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
Provides a way for users to bail out of the current solve.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseMesh & _mesh
Definition: SystemBase.h:953
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
NumericVector< Number > * _increment_vec
increment vector
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
auto min(const L &left, const R &right)

◆ computeDiracContributions()

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

Definition at line 3265 of file NonlinearSystemBase.C.

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

3266 {
3268 
3269  std::set<const Elem *> dirac_elements;
3270 
3272  {
3273  TIME_SECTION("computeDirac", 3, "Computing DiracKernels");
3274 
3275  // TODO: Need a threading fix... but it's complicated!
3276  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
3277  {
3278  const auto & dkernels = _dirac_kernels.getActiveObjects(tid);
3279  for (const auto & dkernel : dkernels)
3280  {
3281  dkernel->clearPoints();
3282  dkernel->addPoints();
3283  }
3284  }
3285 
3286  ComputeDiracThread cd(_fe_problem, tags, is_jacobian);
3287 
3288  _fe_problem.getDiracElements(dirac_elements);
3289 
3290  DistElemRange range(dirac_elements.begin(), dirac_elements.end(), 1);
3291  // TODO: Make Dirac work thread!
3292  // Threads::parallel_reduce(range, cd);
3293 
3294  cd(range);
3295  }
3296 }
unsigned int n_threads()
virtual void getDiracElements(std::set< const Elem *> &elems) override
Fills "elems" with the elements that should be looped over for Dirac Kernels.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
virtual void clearDiracInfo() override
Gets called before Dirac Kernels are asked to add the points they are supposed to be evaluated in...
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
StoredRange< std::set< const Elem * >::const_iterator, const Elem * > DistElemRange
bool hasActiveObjects(THREAD_ID tid=0) const
unsigned int THREAD_ID
Definition: MooseTypes.h:198

◆ computedScalingJacobian()

bool NonlinearSystemBase::computedScalingJacobian ( ) const
inlineinherited

Definition at line 73 of file NonlinearSystemBase.h.

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

◆ computeJacobian() [1/2]

void NonlinearSystemBase::computeJacobian ( 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 3036 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobian().

3037 {
3039 
3040  computeJacobianTags(tags);
3041 
3043 }
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
void computeJacobianTags(const std::set< TagID > &tags)
Computes multiple (tag associated) Jacobian matricese.
virtual void associateMatrixToTag(SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
Definition: SystemBase.C:1032
virtual void disassociateMatrixFromTag(SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
Definition: SystemBase.C:1044

◆ computeJacobian() [2/2]

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

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

Definition at line 3023 of file NonlinearSystemBase.C.

3024 {
3025  _nl_matrix_tags.clear();
3026 
3027  auto & tags = _fe_problem.getMatrixTags();
3028 
3029  for (auto & tag : tags)
3030  _nl_matrix_tags.insert(tag.second);
3031 
3032  computeJacobian(jacobian, _nl_matrix_tags);
3033 }
void computeJacobian(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:225
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948

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

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

3066 {
3067  _nl_matrix_tags.clear();
3068 
3069  auto & tags = _fe_problem.getMatrixTags();
3070  for (auto & tag : tags)
3071  _nl_matrix_tags.insert(tag.second);
3072 
3074 }
void computeJacobianBlocks(std::vector< JacobianBlock *> &blocks)
Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditio...
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:225
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948

◆ computeJacobianBlocks() [2/2]

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

Definition at line 3077 of file NonlinearSystemBase.C.

3079 {
3080  TIME_SECTION("computeJacobianBlocks", 3);
3081  FloatingPointExceptionGuard fpe_guard(_app);
3082 
3083  for (unsigned int i = 0; i < blocks.size(); i++)
3084  {
3085  SparseMatrix<Number> & jacobian = blocks[i]->_jacobian;
3086 
3087  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
3088  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
3089  PETSC_TRUE);
3091  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
3092  MAT_NEW_NONZERO_ALLOCATION_ERR,
3093  PETSC_TRUE);
3094 
3095  jacobian.zero();
3096  }
3097 
3098  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
3100 
3101  PARALLEL_TRY
3102  {
3104  ComputeJacobianBlocksThread cjb(_fe_problem, blocks, tags);
3105  Threads::parallel_reduce(elem_range, cjb);
3106  }
3107  PARALLEL_CATCH;
3108 
3109  for (unsigned int i = 0; i < blocks.size(); i++)
3110  blocks[i]->_jacobian.close();
3111 
3112  for (unsigned int i = 0; i < blocks.size(); i++)
3113  {
3114  libMesh::System & precond_system = blocks[i]->_precond_system;
3115  SparseMatrix<Number> & jacobian = blocks[i]->_jacobian;
3116 
3117  unsigned int ivar = blocks[i]->_ivar;
3118  unsigned int jvar = blocks[i]->_jvar;
3119 
3120  // Dirichlet BCs
3121  std::vector<numeric_index_type> zero_rows;
3122  PARALLEL_TRY
3123  {
3124  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
3125  for (const auto & bnode : bnd_nodes)
3126  {
3127  BoundaryID boundary_id = bnode->_bnd_id;
3128  Node * node = bnode->_node;
3129 
3130  if (_nodal_bcs.hasActiveBoundaryObjects(boundary_id))
3131  {
3132  const auto & bcs = _nodal_bcs.getActiveBoundaryObjects(boundary_id);
3133 
3134  if (node->processor_id() == processor_id())
3135  {
3136  _fe_problem.reinitNodeFace(node, boundary_id, 0);
3137 
3138  for (const auto & bc : bcs)
3139  if (bc->variable().number() == ivar && bc->shouldApply())
3140  {
3141  // The first zero is for the variable number... there is only one variable in
3142  // each mini-system The second zero only works with Lagrange elements!
3143  zero_rows.push_back(node->dof_number(precond_system.number(), 0, 0));
3144  }
3145  }
3146  }
3147  }
3148  }
3149  PARALLEL_CATCH;
3150 
3151  jacobian.close();
3152 
3153  // This zeroes the rows corresponding to Dirichlet BCs and puts a 1.0 on the diagonal
3154  if (ivar == jvar)
3155  jacobian.zero_rows(zero_rows, 1.0);
3156  else
3157  jacobian.zero_rows(zero_rows, 0.0);
3158 
3159  jacobian.close();
3160  }
3161 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:1041
unsigned int n_threads()
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
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
Scope guard for starting and stopping Floating Point Exception Trapping.
Specialization for filling multiple "small" preconditioning matrices simulatenously.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
unsigned int number() const
virtual void zero()=0
boundary_id_type BoundaryID
virtual void zero_rows(std::vector< numeric_index_type > &rows, Number diag_value=0.0)
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
MooseApp & _app
Definition: SystemBase.h:950
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual void close()=0
MooseMesh & _mesh
Definition: SystemBase.h:953
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:2026
processor_id_type processor_id() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:1092

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

Referenced by NonlinearSystemBase::computeJacobianTags().

2682 {
2683  TIME_SECTION("computeJacobianInternal", 3);
2684 
2686 
2687  // Make matrix ready to use
2689 
2690  for (auto tag : tags)
2691  {
2692  if (!hasMatrix(tag))
2693  continue;
2694 
2695  auto & jacobian = getMatrix(tag);
2696  // Necessary for speed
2697  if (auto petsc_matrix = dynamic_cast<PetscMatrix<Number> *>(&jacobian))
2698  {
2699  MatSetOption(petsc_matrix->mat(),
2700  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2701  PETSC_TRUE);
2703  MatSetOption(petsc_matrix->mat(), MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
2704  }
2705  }
2706 
2707  jacobianSetup();
2708 
2709  // Jacobian contributions from UOs - for now this is used for ray tracing
2710  // and ray kernels that contribute to the Jacobian (think line sources)
2711  std::vector<UserObject *> uos;
2713  .query()
2714  .condition<AttribSystem>("UserObject")
2715  .condition<AttribExecOns>(EXEC_PRE_KERNELS)
2716  .queryInto(uos);
2717  for (auto & uo : uos)
2718  uo->jacobianSetup();
2719  for (auto & uo : uos)
2720  {
2721  uo->initialize();
2722  uo->execute();
2723  uo->finalize();
2724  }
2725 
2726  // reinit scalar variables
2727  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
2729 
2730  PARALLEL_TRY
2731  {
2732  // We would like to compute ScalarKernels, block NodalKernels, FVFluxKernels, and mortar objects
2733  // up front because we want these included whether we are computing an ordinary Jacobian or a
2734  // Jacobian for determining variable scaling factors
2736 
2737  // Block restricted Nodal Kernels
2739  {
2741  ConstNodeRange & range = *_mesh.getLocalNodeRange();
2742  Threads::parallel_reduce(range, cnkjt);
2743 
2744  unsigned int n_threads = libMesh::n_threads();
2745  for (unsigned int i = 0; i < n_threads;
2746  i++) // Add any cached jacobians that might be hanging around
2748  }
2749 
2750  using FVRange = StoredRange<MooseMesh::const_face_info_iterator, const FaceInfo *>;
2751  if (_fe_problem.haveFV())
2752  {
2753  // the same loop works for both residual and jacobians because it keys
2754  // off of FEProblem's _currently_computing_jacobian parameter
2756  _fe_problem, this->number(), tags, /*on_displaced=*/false);
2758  Threads::parallel_reduce(faces, fvj);
2759  }
2760  if (auto displaced_problem = _fe_problem.getDisplacedProblem();
2761  displaced_problem && displaced_problem->haveFV())
2762  {
2764  _fe_problem, this->number(), tags, /*on_displaced=*/true);
2765  FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
2766  displaced_problem->mesh().ownedFaceInfoEnd());
2767  Threads::parallel_reduce(faces, fvr);
2768  }
2769 
2771 
2772  // Get our element range for looping over
2774 
2776  {
2777  // Only compute Jacobians corresponding to the diagonals of volumetric compute objects
2778  // because this typically gives us a good representation of the physics. NodalBCs and
2779  // Constraints can introduce dramatically different scales (often order unity).
2780  // IntegratedBCs and/or InterfaceKernels may use penalty factors. DGKernels may be ok, but
2781  // they are almost always used in conjunction with Kernels
2783  Threads::parallel_reduce(elem_range, cj);
2784  unsigned int n_threads = libMesh::n_threads();
2785  for (unsigned int i = 0; i < n_threads;
2786  i++) // Add any Jacobian contributions still hanging around
2788 
2789  // Check whether any exceptions were thrown and propagate this information for parallel
2790  // consistency before
2791  // 1) we do parallel communication when closing tagged matrices
2792  // 2) early returning before reaching our PARALLEL_CATCH below
2794 
2795  closeTaggedMatrices(tags);
2796 
2797  return;
2798  }
2799 
2800  switch (_fe_problem.coupling())
2801  {
2802  case Moose::COUPLING_DIAG:
2803  {
2805  Threads::parallel_reduce(elem_range, cj);
2806 
2807  unsigned int n_threads = libMesh::n_threads();
2808  for (unsigned int i = 0; i < n_threads;
2809  i++) // Add any Jacobian contributions still hanging around
2811 
2812  // Boundary restricted Nodal Kernels
2814  {
2816  ConstBndNodeRange & bnd_range = *_mesh.getBoundaryNodeRange();
2817 
2818  Threads::parallel_reduce(bnd_range, cnkjt);
2819  unsigned int n_threads = libMesh::n_threads();
2820  for (unsigned int i = 0; i < n_threads;
2821  i++) // Add any cached jacobians that might be hanging around
2823  }
2824  }
2825  break;
2826 
2827  default:
2829  {
2831  Threads::parallel_reduce(elem_range, cj);
2832  unsigned int n_threads = libMesh::n_threads();
2833 
2834  for (unsigned int i = 0; i < n_threads; i++)
2836 
2837  // Boundary restricted Nodal Kernels
2839  {
2841  ConstBndNodeRange & bnd_range = *_mesh.getBoundaryNodeRange();
2842 
2843  Threads::parallel_reduce(bnd_range, cnkjt);
2844  unsigned int n_threads = libMesh::n_threads();
2845  for (unsigned int i = 0; i < n_threads;
2846  i++) // Add any cached jacobians that might be hanging around
2848  }
2849  }
2850  break;
2851  }
2852 
2853  computeDiracContributions(tags, true);
2854 
2855  static bool first = true;
2856 
2857  // This adds zeroes into geometric coupling entries to ensure they stay in the matrix
2859  {
2860  first = false;
2862 
2865  }
2866  }
2867  PARALLEL_CATCH;
2868 
2869  // Have no idea how to have constraints work
2870  // with the tag system
2871  PARALLEL_TRY
2872  {
2873  // Add in Jacobian contributions from other Constraints
2874  if (_fe_problem._has_constraints && tags.count(systemMatrixTag()))
2875  {
2876  // Some constraints need values from the Jacobian
2877  closeTaggedMatrices(tags);
2878 
2879  // Nodal Constraints
2881 
2882  // Undisplaced Constraints
2883  constraintJacobians(false);
2884 
2885  // Displaced Constraints
2887  constraintJacobians(true);
2888  }
2889  }
2890  PARALLEL_CATCH;
2891 
2892  // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs
2893  // on boundary nodes
2894  if (_has_diag_save_in)
2896 
2897  PARALLEL_TRY
2898  {
2899  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
2900  // Select nodal kernels
2901  if (tags.size() == _fe_problem.numMatrixTags() || !tags.size())
2902  nbc_warehouse = &_nodal_bcs;
2903  else if (tags.size() == 1)
2904  nbc_warehouse = &(_nodal_bcs.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2905  else
2906  nbc_warehouse = &(_nodal_bcs.getMatrixTagsObjectWarehouse(tags, 0));
2907 
2908  if (nbc_warehouse->hasActiveObjects())
2909  {
2910  // We may be switching from add to set. Moreover, we rely on a call to MatZeroRows to enforce
2911  // the nodal boundary condition constraints which requires that the matrix be truly assembled
2912  // as opposed to just flushed. Consequently we can't do the following despite any desire to
2913  // keep our initial sparsity pattern honored (see https://gitlab.com/petsc/petsc/-/issues/852)
2914  //
2915  // flushTaggedMatrices(tags);
2916  closeTaggedMatrices(tags);
2917 
2918  // Cache the information about which BCs are coupled to which
2919  // variables, so we don't have to figure it out for each node.
2920  std::map<std::string, std::set<unsigned int>> bc_involved_vars;
2921  const std::set<BoundaryID> & all_boundary_ids = _mesh.getBoundaryIDs();
2922  for (const auto & bid : all_boundary_ids)
2923  {
2924  // Get reference to all the NodalBCs for this ID. This is only
2925  // safe if there are NodalBCBases there to be gotten...
2926  if (nbc_warehouse->hasActiveBoundaryObjects(bid))
2927  {
2928  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(bid);
2929  for (const auto & bc : bcs)
2930  {
2931  const std::vector<MooseVariableFEBase *> & coupled_moose_vars =
2932  bc->getCoupledMooseVars();
2933 
2934  // Create the set of "involved" MOOSE nonlinear vars, which includes all coupled vars
2935  // and the BC's own variable
2936  std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2937  for (const auto & coupled_var : coupled_moose_vars)
2938  if (coupled_var->kind() == Moose::VAR_SOLVER)
2939  var_set.insert(coupled_var->number());
2940 
2941  var_set.insert(bc->variable().number());
2942  }
2943  }
2944  }
2945 
2946  // reinit scalar variables again. This reinit does not re-fill any of the scalar variable
2947  // solution arrays because that was done above. It only will reorder the derivative
2948  // information for AD calculations to be suitable for NodalBC calculations
2949  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
2950  _fe_problem.reinitScalars(tid, true);
2951 
2952  // Get variable coupling list. We do all the NodalBCBase stuff on
2953  // thread 0... The couplingEntries() data structure determines
2954  // which variables are "coupled" as far as the preconditioner is
2955  // concerned, not what variables a boundary condition specifically
2956  // depends on.
2957  auto & coupling_entries = _fe_problem.couplingEntries(/*_tid=*/0, this->number());
2958 
2959  // Compute Jacobians for NodalBCBases
2960  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
2961  for (const auto & bnode : bnd_nodes)
2962  {
2963  BoundaryID boundary_id = bnode->_bnd_id;
2964  Node * node = bnode->_node;
2965 
2966  if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id) &&
2967  node->processor_id() == processor_id())
2968  {
2969  _fe_problem.reinitNodeFace(node, boundary_id, 0);
2970 
2971  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
2972  for (const auto & bc : bcs)
2973  {
2974  // Get the set of involved MOOSE vars for this BC
2975  std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2976 
2977  // Loop over all the variables whose Jacobian blocks are
2978  // actually being computed, call computeOffDiagJacobian()
2979  // for each one which is actually coupled (otherwise the
2980  // value is zero.)
2981  for (const auto & it : coupling_entries)
2982  {
2983  unsigned int ivar = it.first->number(), jvar = it.second->number();
2984 
2985  // We are only going to call computeOffDiagJacobian() if:
2986  // 1.) the BC's variable is ivar
2987  // 2.) jvar is "involved" with the BC (including jvar==ivar), and
2988  // 3.) the BC should apply.
2989  if ((bc->variable().number() == ivar) && var_set.count(jvar) && bc->shouldApply())
2990  bc->computeOffDiagJacobian(jvar);
2991  }
2992 
2993  const auto & coupled_scalar_vars = bc->getCoupledMooseScalarVars();
2994  for (const auto & jvariable : coupled_scalar_vars)
2995  if (hasScalarVariable(jvariable->name()))
2996  bc->computeOffDiagJacobianScalar(jvariable->number());
2997  }
2998  }
2999  } // end loop over boundary nodes
3000 
3001  // Set the cached NodalBCBase values in the Jacobian matrix
3003  }
3004  }
3005  PARALLEL_CATCH;
3006 
3007  closeTaggedMatrices(tags);
3008 
3009  // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs
3010  // on boundary nodes
3013 
3014  if (hasDiagSaveIn())
3016 
3017  // Accumulate the occurrence of solution invalid warnings for the current iteration cumulative
3018  // counters
3020 }
virtual void update(bool update_libmesh_system=true)
Update the system (doing libMesh magic)
Definition: SystemBase.C:1218
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:1041
std::vector< std::pair< MooseVariableFEBase *, MooseVariableFEBase * > > & couplingEntries(const THREAD_ID tid, const unsigned int nl_sys_num)
unsigned int n_threads()
bool hasActiveBlockObjects(THREAD_ID tid=0) const
virtual void checkExceptionAndStopSolve(bool print_message=true)
Check to see if an exception has occurred on any processor and, if possible, force the solve to fail...
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
NumericVector< Number > & solution()
Definition: SystemBase.h:182
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
face_info_iterator ownedFaceInfoBegin()
Iterators to owned faceInfo objects.
Definition: MooseMesh.C:1293
bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
bool hasDiagSaveIn() const
Weather or not the nonlinear system has diagonal Jacobian save-ins.
void computingScalingJacobian(bool computing_scaling_jacobian)
Setter for whether we&#39;re computing the scaling jacobian.
ConstNodeRange * getLocalNodeRange()
Definition: MooseMesh.C:1078
virtual GeometricSearchData & geomSearchData() override
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
Definition: SystemBase.C:1016
void solutionInvalidAccumulation()
Pass the number of solution invalid occurrences from current iteration to cumulative counters...
void setCurrentNonlinearSystem(const unsigned int nl_sys_num)
void computeDiracContributions(const std::set< TagID > &tags, bool is_jacobian)
TheWarehouse & theWarehouse() const
boundary_id_type BoundaryID
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:138
void addImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data)
Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled th...
MooseObjectWarehouse< T > & getMatrixTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given matrix tag...
StoredRange< MeshBase::const_node_iterator, const Node *> ConstNodeRange
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
virtual void activeAllMatrixTags()
Make all exsiting matrices ative.
Definition: SystemBase.C:1110
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1132
AuxiliarySystem & getAuxiliarySystem()
virtual void close()=0
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
bool _add_implicit_geometric_coupling_entries_to_jacobian
Whether or not to add implicit geometric couplings to the Jacobian for FDP.
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:220
MooseApp & _app
Definition: SystemBase.h:950
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
void constraintJacobians(bool displaced)
Add jacobian contributions from Constraints.
MooseMesh & _mesh
Definition: SystemBase.h:953
bool hasActiveObjects(THREAD_ID tid=0) const
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:980
MooseObjectWarehouse< T > & getMatrixTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has one of the given matrix tags...
void computeScalarKernelsJacobians(const std::set< TagID > &tags)
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
virtual MooseMesh & mesh() override
void setCachedJacobian(GlobalDataKey)
Sets previously-cached Jacobian values via SparseMatrix::set() calls.
Definition: Assembly.C:4486
Moose::CouplingType coupling()
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:2720
const ExecFlagType EXEC_PRE_KERNELS
Definition: Moose.C:48
void mortarConstraints(Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Do mortar constraint residual/jacobian computations.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:284
face_info_iterator ownedFaceInfoEnd()
Definition: MooseMesh.C:1302
bool _has_constraints
Whether or not this system has any Constraints.
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:2026
virtual bool hasScalarVariable(const std::string &var_name) const
Definition: SystemBase.C:832
processor_id_type processor_id() const
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
Definition: Assembly.C:3811
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
virtual void jacobianSetup() override
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:1092
virtual void addCachedJacobian(const THREAD_ID tid) override
Key structure for APIs manipulating global vectors/matrices.
Definition: Assembly.h:794

◆ computeJacobianTags()

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

Computes multiple (tag associated) Jacobian matricese.

Definition at line 3046 of file NonlinearSystemBase.C.

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

3047 {
3048  TIME_SECTION("computeJacobianTags", 5);
3049 
3050  FloatingPointExceptionGuard fpe_guard(_app);
3051 
3052  try
3053  {
3055  }
3056  catch (MooseException & e)
3057  {
3058  // The buck stops here, we have already handled the exception by
3059  // calling stopSolve(), it is now up to PETSc to return a
3060  // "diverged" reason during the next solve.
3061  }
3062 }
Scope guard for starting and stopping Floating Point Exception Trapping.
MooseApp & _app
Definition: SystemBase.h:950
Provides a way for users to bail out of the current solve.
void computeJacobianInternal(const std::set< TagID > &tags)
Form multiple matrices for all the tags.

◆ computeNodalBCs() [1/3]

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

Enforces nodal boundary conditions.

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

Definition at line 1937 of file NonlinearSystemBase.C.

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

1938 {
1939  _nl_vector_tags.clear();
1940 
1941  const auto & residual_vector_tags = _fe_problem.getVectorTags(Moose::VECTOR_TAG_RESIDUAL);
1942  for (const auto & residual_vector_tag : residual_vector_tags)
1943  _nl_vector_tags.insert(residual_vector_tag._id);
1944 
1946  computeNodalBCs(residual, _nl_vector_tags);
1948 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
Definition: SystemBase.C:949
std::set< TagID > _nl_vector_tags
Vector tags to temporarily store all tags associated with the current system.
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:937
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition: SubProblem.C:150
TagID residualVectorTag() const override
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
void computeNodalBCs(NumericVector< Number > &residual)
Enforces nodal boundary conditions.

◆ computeNodalBCs() [2/3]

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

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

Definition at line 1951 of file NonlinearSystemBase.C.

1952 {
1954 
1955  computeNodalBCs(tags);
1956 
1958 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
Definition: SystemBase.C:949
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:937
TagID residualVectorTag() const override
void computeNodalBCs(NumericVector< Number > &residual)
Enforces nodal boundary conditions.

◆ computeNodalBCs() [3/3]

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

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

Definition at line 1961 of file NonlinearSystemBase.C.

1962 {
1963  // We need to close the diag_save_in variables on the aux system before NodalBCBases clear the
1964  // dofs on boundary nodes
1965  if (_has_save_in)
1967 
1968  PARALLEL_TRY
1969  {
1970  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
1971 
1972  if (!bnd_nodes.empty())
1973  {
1974  TIME_SECTION("NodalBCs", 3 /*, "Computing NodalBCs"*/);
1975 
1976  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
1977 
1978  // Select nodal kernels
1979  if (tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL) || !tags.size())
1980  nbc_warehouse = &_nodal_bcs;
1981  else if (tags.size() == 1)
1982  nbc_warehouse = &(_nodal_bcs.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1983  else
1984  nbc_warehouse = &(_nodal_bcs.getVectorTagsObjectWarehouse(tags, 0));
1985 
1986  for (const auto & bnode : bnd_nodes)
1987  {
1988  BoundaryID boundary_id = bnode->_bnd_id;
1989  Node * node = bnode->_node;
1990 
1991  if (node->processor_id() == processor_id())
1992  {
1993  // reinit variables in nodes
1994  _fe_problem.reinitNodeFace(node, boundary_id, 0);
1995  if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id))
1996  {
1997  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
1998  for (const auto & nbc : bcs)
1999  if (nbc->shouldApply())
2000  nbc->computeResidual();
2001  }
2002  }
2003  }
2004  }
2005  }
2006  PARALLEL_CATCH;
2007 
2008  if (_Re_time)
2009  _Re_time->close();
2010  _Re_non_time->close();
2011 }
NumericVector< Number > * _Re_time
residual vector for time contributions
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
NumericVector< Number > & solution()
Definition: SystemBase.h:182
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< T > & getVectorTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object at least has one of the given vector ta...
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
boundary_id_type BoundaryID
AuxiliarySystem & getAuxiliarySystem()
virtual void close()=0
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
MooseMesh & _mesh
Definition: SystemBase.h:953
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:173
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:2026
processor_id_type processor_id() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:1092

◆ computeNodalBCsResidualAndJacobian()

void NonlinearSystemBase::computeNodalBCsResidualAndJacobian ( )
protectedinherited

compute the residual and Jacobian for nodal boundary conditions

Definition at line 2014 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualAndJacobianTags().

2015 {
2016  PARALLEL_TRY
2017  {
2018  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
2019 
2020  if (!bnd_nodes.empty())
2021  {
2022  TIME_SECTION("NodalBCs", 3 /*, "Computing NodalBCs"*/);
2023 
2024  for (const auto & bnode : bnd_nodes)
2025  {
2026  BoundaryID boundary_id = bnode->_bnd_id;
2027  Node * node = bnode->_node;
2028 
2029  if (node->processor_id() == processor_id())
2030  {
2031  // reinit variables in nodes
2032  _fe_problem.reinitNodeFace(node, boundary_id, 0);
2033  if (_nodal_bcs.hasActiveBoundaryObjects(boundary_id))
2034  {
2035  const auto & bcs = _nodal_bcs.getActiveBoundaryObjects(boundary_id);
2036  for (const auto & nbc : bcs)
2037  if (nbc->shouldApply())
2038  nbc->computeResidualAndJacobian();
2039  }
2040  }
2041  }
2042  }
2043  }
2044  PARALLEL_CATCH;
2045 
2046  // Set the cached NodalBCBase values in the Jacobian matrix
2048 }
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
boundary_id_type BoundaryID
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1132
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
MooseMesh & _mesh
Definition: SystemBase.h:953
void setCachedJacobian(GlobalDataKey)
Sets previously-cached Jacobian values via SparseMatrix::set() calls.
Definition: Assembly.C:4486
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:2026
processor_id_type processor_id() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:1092
Key structure for APIs manipulating global vectors/matrices.
Definition: Assembly.h:794

◆ computeResidual()

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

Form a residual vector for a given tag.

Definition at line 719 of file NonlinearSystemBase.C.

720 {
721  mooseDeprecated(" Please use computeResidualTag");
722 
723  computeResidualTag(residual, tag_id);
724 }
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:350
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 1847 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualAndJacobianTags().

1849 {
1850  TIME_SECTION("computeResidualAndJacobianInternal", 3);
1851 
1852  // Make matrix ready to use
1854 
1855  for (auto tag : matrix_tags)
1856  {
1857  if (!hasMatrix(tag))
1858  continue;
1859 
1860  auto & jacobian = getMatrix(tag);
1861  // Necessary for speed
1862  if (auto petsc_matrix = dynamic_cast<PetscMatrix<Number> *>(&jacobian))
1863  {
1864  MatSetOption(petsc_matrix->mat(),
1865  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
1866  PETSC_TRUE);
1868  MatSetOption(petsc_matrix->mat(), MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
1869  }
1870  }
1871 
1872  residualSetup();
1873 
1874  // Residual contributions from UOs - for now this is used for ray tracing
1875  // and ray kernels that contribute to the residual (think line sources)
1876  std::vector<UserObject *> uos;
1878  .query()
1879  .condition<AttribSystem>("UserObject")
1880  .condition<AttribExecOns>(EXEC_PRE_KERNELS)
1881  .queryInto(uos);
1882  for (auto & uo : uos)
1883  uo->residualSetup();
1884  for (auto & uo : uos)
1885  {
1886  uo->initialize();
1887  uo->execute();
1888  uo->finalize();
1889  }
1890 
1891  // reinit scalar variables
1892  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
1894 
1895  // residual contributions from the domain
1896  PARALLEL_TRY
1897  {
1898  TIME_SECTION("Kernels", 3 /*, "Computing Kernels"*/);
1899 
1901 
1902  ComputeResidualAndJacobianThread crj(_fe_problem, vector_tags, matrix_tags);
1903  Threads::parallel_reduce(elem_range, crj);
1904 
1905  using FVRange = StoredRange<MooseMesh::const_face_info_iterator, const FaceInfo *>;
1906  if (_fe_problem.haveFV())
1907  {
1909  _fe_problem, this->number(), vector_tags, matrix_tags, /*on_displaced=*/false);
1911  Threads::parallel_reduce(faces, fvrj);
1912  }
1913  if (auto displaced_problem = _fe_problem.getDisplacedProblem();
1914  displaced_problem && displaced_problem->haveFV())
1915  {
1917  _fe_problem, this->number(), vector_tags, matrix_tags, /*on_displaced=*/true);
1918  FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
1919  displaced_problem->mesh().ownedFaceInfoEnd());
1920  Threads::parallel_reduce(faces, fvr);
1921  }
1922 
1924 
1925  unsigned int n_threads = libMesh::n_threads();
1926  for (unsigned int i = 0; i < n_threads;
1927  i++) // Add any cached residuals that might be hanging around
1928  {
1931  }
1932  }
1933  PARALLEL_CATCH;
1934 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:1041
unsigned int n_threads()
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
face_info_iterator ownedFaceInfoBegin()
Iterators to owned faceInfo objects.
Definition: MooseMesh.C:1293
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 bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
TheWarehouse & theWarehouse() const
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
virtual void activeAllMatrixTags()
Make all exsiting matrices ative.
Definition: SystemBase.C:1110
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1132
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
MooseMesh & _mesh
Definition: SystemBase.h:953
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:980
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
virtual MooseMesh & mesh() override
const ExecFlagType EXEC_PRE_KERNELS
Definition: Moose.C:48
void mortarConstraints(Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Do mortar constraint residual/jacobian computations.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:284
face_info_iterator ownedFaceInfoEnd()
Definition: MooseMesh.C:1302
virtual void addCachedResidual(const THREAD_ID tid) override
virtual void addCachedJacobian(const THREAD_ID tid) override
virtual void residualSetup() override

◆ computeResidualAndJacobianTags()

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

Form possibly multiple tag-associated vectors and matrices.

Definition at line 804 of file NonlinearSystemBase.C.

Referenced by FEProblemBase::computeResidualAndJacobian().

806 {
807  const bool required_residual =
808  vector_tags.find(residualVectorTag()) == vector_tags.end() ? false : true;
809 
810  try
811  {
812  zeroTaggedVectors(vector_tags);
813  computeResidualAndJacobianInternal(vector_tags, matrix_tags);
814  closeTaggedVectors(vector_tags);
815  closeTaggedMatrices(matrix_tags);
816 
817  if (required_residual)
818  {
819  auto & residual = getVector(residualVectorTag());
820  if (_time_integrator)
821  _time_integrator->postResidual(residual);
822  else
823  residual += *_Re_non_time;
824  residual.close();
825  }
826 
828  closeTaggedVectors(vector_tags);
829  closeTaggedMatrices(matrix_tags);
830  }
831  catch (MooseException & e)
832  {
833  // The buck stops here, we have already handled the exception by
834  // calling stopSolve(), it is now up to PETSc to return a
835  // "diverged" reason during the next solve.
836  }
837 }
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition: SystemBase.C:690
void computeNodalBCsResidualAndJacobian()
compute the residual and Jacobian for nodal boundary conditions
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
void computeResidualAndJacobianInternal(const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Compute residual and Jacobian from contributions not related to constraints, such as nodal boundary c...
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
Definition: SystemBase.C:1016
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition: SystemBase.C:664
virtual void close()=0
TagID residualVectorTag() const override
Provides a way for users to bail out of the current solve.
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:1007
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

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

Referenced by NonlinearSystemBase::computeResidualTags().

1629 {
1630  parallel_object_only();
1631 
1632  TIME_SECTION("computeResidualInternal", 3);
1633 
1634  residualSetup();
1635 
1636  const auto vector_tag_data = _fe_problem.getVectorTags(tags);
1637 
1638  // Residual contributions from UOs - for now this is used for ray tracing
1639  // and ray kernels that contribute to the residual (think line sources)
1640  std::vector<UserObject *> uos;
1642  .query()
1643  .condition<AttribSystem>("UserObject")
1644  .condition<AttribExecOns>(EXEC_PRE_KERNELS)
1645  .queryInto(uos);
1646  for (auto & uo : uos)
1647  uo->residualSetup();
1648  for (auto & uo : uos)
1649  {
1650  uo->initialize();
1651  uo->execute();
1652  uo->finalize();
1653  }
1654 
1655  // reinit scalar variables
1656  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
1658 
1659  // residual contributions from the domain
1660  PARALLEL_TRY
1661  {
1662  TIME_SECTION("Kernels", 3 /*, "Computing Kernels"*/);
1663 
1665 
1667  Threads::parallel_reduce(elem_range, cr);
1668 
1669  // We pass face information directly to FV residual objects for their evaluation. Consequently
1670  // we must make sure to do separate threaded loops for 1) undisplaced face information objects
1671  // and undisplaced residual objects and 2) displaced face information objects and displaced
1672  // residual objects
1673  using FVRange = StoredRange<MooseMesh::const_face_info_iterator, const FaceInfo *>;
1674  if (_fe_problem.haveFV())
1675  {
1677  _fe_problem, this->number(), tags, /*on_displaced=*/false);
1679  Threads::parallel_reduce(faces, fvr);
1680  }
1681  if (auto displaced_problem = _fe_problem.getDisplacedProblem();
1682  displaced_problem && displaced_problem->haveFV())
1683  {
1685  _fe_problem, this->number(), tags, /*on_displaced=*/true);
1686  FVRange faces(displaced_problem->mesh().ownedFaceInfoBegin(),
1687  displaced_problem->mesh().ownedFaceInfoEnd());
1688  Threads::parallel_reduce(faces, fvr);
1689  }
1690 
1691  unsigned int n_threads = libMesh::n_threads();
1692  for (unsigned int i = 0; i < n_threads;
1693  i++) // Add any cached residuals that might be hanging around
1695  }
1696  PARALLEL_CATCH;
1697 
1698  // residual contributions from the scalar kernels
1699  PARALLEL_TRY
1700  {
1701  // do scalar kernels (not sure how to thread this)
1703  {
1704  TIME_SECTION("ScalarKernels", 3 /*, "Computing ScalarKernels"*/);
1705 
1706  MooseObjectWarehouse<ScalarKernelBase> * scalar_kernel_warehouse;
1707  // This code should be refactored once we can do tags for scalar
1708  // kernels
1709  // Should redo this based on Warehouse
1710  if (!tags.size() || tags.size() == _fe_problem.numVectorTags(Moose::VECTOR_TAG_RESIDUAL))
1711  scalar_kernel_warehouse = &_scalar_kernels;
1712  else if (tags.size() == 1)
1713  scalar_kernel_warehouse =
1714  &(_scalar_kernels.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1715  else
1716  // scalar_kernels is not threading
1717  scalar_kernel_warehouse = &(_scalar_kernels.getVectorTagsObjectWarehouse(tags, 0));
1718 
1719  bool have_scalar_contributions = false;
1720  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
1721  for (const auto & scalar_kernel : scalars)
1722  {
1723  scalar_kernel->reinit();
1724  const std::vector<dof_id_type> & dof_indices = scalar_kernel->variable().dofIndices();
1725  const DofMap & dof_map = scalar_kernel->variable().dofMap();
1726  const dof_id_type first_dof = dof_map.first_dof();
1727  const dof_id_type end_dof = dof_map.end_dof();
1728  for (dof_id_type dof : dof_indices)
1729  {
1730  if (dof >= first_dof && dof < end_dof)
1731  {
1732  scalar_kernel->computeResidual();
1733  have_scalar_contributions = true;
1734  break;
1735  }
1736  }
1737  }
1738  if (have_scalar_contributions)
1740  }
1741  }
1742  PARALLEL_CATCH;
1743 
1744  // residual contributions from Block NodalKernels
1745  PARALLEL_TRY
1746  {
1748  {
1749  TIME_SECTION("NodalKernels", 3 /*, "Computing NodalKernels"*/);
1750 
1752 
1753  ConstNodeRange & range = *_mesh.getLocalNodeRange();
1754 
1755  if (range.begin() != range.end())
1756  {
1757  _fe_problem.reinitNode(*range.begin(), 0);
1758 
1759  Threads::parallel_reduce(range, cnk);
1760 
1761  unsigned int n_threads = libMesh::n_threads();
1762  for (unsigned int i = 0; i < n_threads;
1763  i++) // Add any cached residuals that might be hanging around
1765  }
1766  }
1767  }
1768  PARALLEL_CATCH;
1769 
1771  // We computed the volumetric objects. We can return now before we get into
1772  // any strongly enforced constraint conditions or penalty-type objects
1773  // (DGKernels, IntegratedBCs, InterfaceKernels, Constraints)
1774  return;
1775 
1776  // residual contributions from boundary NodalKernels
1777  PARALLEL_TRY
1778  {
1780  {
1781  TIME_SECTION("NodalKernelBCs", 3 /*, "Computing NodalKernelBCs"*/);
1782 
1784 
1785  ConstBndNodeRange & bnd_node_range = *_mesh.getBoundaryNodeRange();
1786 
1787  Threads::parallel_reduce(bnd_node_range, cnk);
1788 
1789  unsigned int n_threads = libMesh::n_threads();
1790  for (unsigned int i = 0; i < n_threads;
1791  i++) // Add any cached residuals that might be hanging around
1793  }
1794  }
1795  PARALLEL_CATCH;
1796 
1798 
1799  if (_residual_copy.get())
1800  {
1801  _Re_non_time->close();
1803  }
1804 
1806  {
1807  _Re_non_time->close();
1810  }
1811 
1812  PARALLEL_TRY { computeDiracContributions(tags, false); }
1813  PARALLEL_CATCH;
1814 
1816  {
1817  PARALLEL_TRY { enforceNodalConstraintsResidual(*_Re_non_time); }
1818  PARALLEL_CATCH;
1819  _Re_non_time->close();
1820  }
1821 
1822  // Add in Residual contributions from other Constraints
1824  {
1825  PARALLEL_TRY
1826  {
1827  // Undisplaced Constraints
1829 
1830  // Displaced Constraints
1833 
1836  }
1837  PARALLEL_CATCH;
1838  _Re_non_time->close();
1839  }
1840 
1841  // Accumulate the occurrence of solution invalid warnings for the current iteration cumulative
1842  // counters
1844 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:1041
unsigned int n_threads()
bool hasActiveBlockObjects(THREAD_ID tid=0) const
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
face_info_iterator ownedFaceInfoBegin()
Iterators to owned faceInfo objects.
Definition: MooseMesh.C:1293
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
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...
ConstNodeRange * getLocalNodeRange()
Definition: MooseMesh.C:1078
void constraintResiduals(NumericVector< Number > &residual, bool displaced)
Add residual contributions from Constraints.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
void solutionInvalidAccumulation()
Pass the number of solution invalid occurrences from current iteration to cumulative counters...
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
void computeDiracContributions(const std::set< TagID > &tags, bool is_jacobian)
TheWarehouse & theWarehouse() const
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:138
void computingScalingResidual(bool computing_scaling_residual)
Setter for whether we&#39;re computing the scaling residual.
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition: SubProblem.C:150
StoredRange< MeshBase::const_node_iterator, const Node *> ConstNodeRange
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1132
virtual void close()=0
ConstraintWarehouse _constraints
Constraints storage object.
void computingNonlinearResid(bool computing_nonlinear_residual) final
Set whether or not the problem is in the process of computing the nonlinear residual.
MooseApp & _app
Definition: SystemBase.h:950
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
std::unique_ptr< NumericVector< Number > > _residual_copy
Copy of the residual vector, or nullptr if a copy is not needed.
MooseMesh & _mesh
Definition: SystemBase.h:953
bool hasActiveObjects(THREAD_ID tid=0) const
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
virtual MooseMesh & mesh() override
virtual unsigned int numVectorTags(const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const
The total number of tags, which can be limited to the tag type.
Definition: SubProblem.C:173
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...
const ExecFlagType EXEC_PRE_KERNELS
Definition: Moose.C:48
void mortarConstraints(Moose::ComputeType compute_type, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags)
Do mortar constraint residual/jacobian computations.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
Definition: TheWarehouse.h:284
face_info_iterator ownedFaceInfoEnd()
Definition: MooseMesh.C:1302
bool _has_constraints
Whether or not this system has any Constraints.
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:2026
void enforceNodalConstraintsResidual(NumericVector< Number > &residual)
Enforce nodal constraints.
virtual void addResidualScalar(const THREAD_ID tid=0)
virtual void addCachedResidual(const THREAD_ID tid) override
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:1092
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
virtual void residualEnd(THREAD_ID tid=0) const
uint8_t dof_id_type
virtual void residualSetup() override
virtual void localize(std::vector< Number > &v_local) const =0

◆ computeResidualTag()

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

Computes residual for a given tag.

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

Definition at line 705 of file NonlinearSystemBase.C.

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

706 {
707  _nl_vector_tags.clear();
708  _nl_vector_tags.insert(tag_id);
710 
712 
714 
716 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
Definition: SystemBase.C:949
std::set< TagID > _nl_vector_tags
Vector tags to temporarily store all tags associated with the current system.
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:937
void computeResidualTags(const std::set< TagID > &tags)
Form multiple tag-associated residual vectors for all the given tags.
TagID residualVectorTag() const override

◆ computeResidualTags()

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

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

Definition at line 727 of file NonlinearSystemBase.C.

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

728 {
729  parallel_object_only();
730 
731  TIME_SECTION("nl::computeResidualTags", 5);
732 
735 
736  bool required_residual = tags.find(residualVectorTag()) == tags.end() ? false : true;
737 
739 
740  // not suppose to do anythin on matrix
742 
744 
745  for (const auto & numeric_vec : _vecs_to_zero_for_residual)
746  if (hasVector(numeric_vec))
747  {
748  NumericVector<Number> & vec = getVector(numeric_vec);
749  vec.close();
750  vec.zero();
751  }
752 
753  try
754  {
755  zeroTaggedVectors(tags);
757  closeTaggedVectors(tags);
758 
759  if (required_residual)
760  {
761  auto & residual = getVector(residualVectorTag());
762  if (_time_integrator)
763  _time_integrator->postResidual(residual);
764  else
765  residual += *_Re_non_time;
766  residual.close();
767  }
769  // We don't want to do nodal bcs or anything else
770  return;
771 
772  computeNodalBCs(tags);
773  closeTaggedVectors(tags);
774 
775  // If we are debugging residuals we need one more assignment to have the ghosted copy up to
776  // date
777  if (_need_residual_ghosted && _debugging_residuals && required_residual)
778  {
779  auto & residual = getVector(residualVectorTag());
780 
781  *_residual_ghosted = residual;
783  }
784  // Need to close and update the aux system in case residuals were saved to it.
787  if (hasSaveIn())
789  }
790  catch (MooseException & e)
791  {
792  // The buck stops here, we have already handled the exception by
793  // calling stopSolve(), it is now up to PETSc to return a
794  // "diverged" reason during the next solve.
795  }
796 
797  // not supposed to do anything on matrix
799 
801 }
virtual void update(bool update_libmesh_system=true)
Update the system (doing libMesh magic)
Definition: SystemBase.C:1218
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition: SystemBase.C:690
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
bool _debugging_residuals
true if debugging residuals
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
NumericVector< Number > & solution()
Definition: SystemBase.h:182
void setCurrentlyComputingResidual(bool currently_computing_residual) final
Set whether or not the problem is in the process of computing the residual.
bool _has_nodalbc_save_in
If there is a nodal BC having save_in.
Scope guard for starting and stopping Floating Point Exception Trapping.
virtual void zero()=0
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
virtual void deactiveAllMatrixTags()
Make matrices inactive.
Definition: SystemBase.C:1099
void setCurrentNonlinearSystem(const unsigned int nl_sys_num)
void computingScalingResidual(bool computing_scaling_residual)
Setter for whether we&#39;re computing the scaling residual.
std::vector< std::string > _vecs_to_zero_for_residual
vectors that will be zeroed before a residual computation
virtual void activeAllMatrixTags()
Make all exsiting matrices ative.
Definition: SystemBase.C:1110
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1132
AuxiliarySystem & getAuxiliarySystem()
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition: SystemBase.C:664
void computeResidualInternal(const std::set< TagID > &tags)
Compute the residual for a given tag.
virtual void close()=0
TagID residualVectorTag() const override
MooseApp & _app
Definition: SystemBase.h:950
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
Provides a way for users to bail out of the current solve.
unsigned int _n_residual_evaluations
Total number of residual evaluations that have been performed.
bool hasSaveIn() const
Weather or not the nonlinear system has save-ins.
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:1007
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
void computeNodalBCs(NumericVector< Number > &residual)
Enforces nodal boundary conditions.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

◆ computeScalarKernelsJacobians()

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

Definition at line 2607 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

2608 {
2609  MooseObjectWarehouse<ScalarKernelBase> * scalar_kernel_warehouse;
2610 
2611  if (!tags.size() || tags.size() == _fe_problem.numMatrixTags())
2612  scalar_kernel_warehouse = &_scalar_kernels;
2613  else if (tags.size() == 1)
2614  scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2615  else
2616  scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagsObjectWarehouse(tags, 0));
2617 
2618  // Compute the diagonal block for scalar variables
2619  if (scalar_kernel_warehouse->hasActiveObjects())
2620  {
2621  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
2622 
2623  _fe_problem.reinitScalars(/*tid=*/0);
2624 
2625  _fe_problem.reinitOffDiagScalars(/*_tid*/ 0);
2626 
2627  bool have_scalar_contributions = false;
2628  for (const auto & kernel : scalars)
2629  {
2630  kernel->reinit();
2631  const std::vector<dof_id_type> & dof_indices = kernel->variable().dofIndices();
2632  const DofMap & dof_map = kernel->variable().dofMap();
2633  const dof_id_type first_dof = dof_map.first_dof();
2634  const dof_id_type end_dof = dof_map.end_dof();
2635  for (dof_id_type dof : dof_indices)
2636  {
2637  if (dof >= first_dof && dof < end_dof)
2638  {
2639  kernel->computeJacobian();
2640  _fe_problem.addJacobianOffDiagScalar(kernel->variable().number());
2641  have_scalar_contributions = true;
2642  break;
2643  }
2644  }
2645  }
2646 
2647  if (have_scalar_contributions)
2649  }
2650 }
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
virtual void addJacobianOffDiagScalar(unsigned int ivar, const THREAD_ID tid=0)
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
MooseObjectWarehouse< T > & getMatrixTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given matrix tag...
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:220
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< T > & getMatrixTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has one of the given matrix tags...
virtual void reinitOffDiagScalars(const THREAD_ID tid) override
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
uint8_t dof_id_type
virtual void addJacobianScalar(const THREAD_ID tid=0)

◆ computeScaling()

bool NonlinearSystemBase::computeScaling ( )
inherited

Method used to obtain scaling factors for variables.

Returns
whether this method ran without exceptions

Definition at line 3741 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::preSolve().

3742 {
3744  return true;
3745 
3746  _console << "\nPerforming automatic scaling calculation\n" << std::endl;
3747 
3748  TIME_SECTION("computeScaling", 3, "Computing Automatic Scaling");
3749 
3750  // It's funny but we need to assemble our vector of scaling factors here otherwise we will be
3751  // applying scaling factors of 0 during Assembly of our scaling Jacobian
3753 
3754  // container for repeated access of element global dof indices
3755  std::vector<dof_id_type> dof_indices;
3756 
3757  if (!_auto_scaling_initd)
3758  setupScalingData();
3759 
3760  std::vector<Real> inverse_scaling_factors(_num_scaling_groups, 0);
3761  std::vector<Real> resid_inverse_scaling_factors(_num_scaling_groups, 0);
3762  std::vector<Real> jac_inverse_scaling_factors(_num_scaling_groups, 0);
3763  auto & dof_map = dofMap();
3764 
3765  // what types of scaling do we want?
3766  bool jac_scaling = _resid_vs_jac_scaling_param < 1. - TOLERANCE;
3767  bool resid_scaling = _resid_vs_jac_scaling_param > TOLERANCE;
3768 
3769  const NumericVector<Number> & scaling_residual = RHS();
3770 
3771  if (jac_scaling)
3772  {
3773  // if (!_auto_scaling_initd)
3774  // We need to reinit this when the number of dofs changes
3775  // but there is no good way to track that
3776  // In theory, it is the job of libmesh system to track this,
3777  // but this special matrix is not owned by libMesh system
3778  // Let us reinit eveytime since it is not expensive
3779  {
3780  auto init_vector = NumericVector<Number>::build(this->comm());
3781  init_vector->init(system().n_dofs(), system().n_local_dofs(), /*fast=*/false, PARALLEL);
3782 
3783  _scaling_matrix->clear();
3784  _scaling_matrix->init(*init_vector);
3785  }
3786 
3788  // Dispatch to derived classes to ensure that we use the correct matrix tag
3791  }
3792 
3793  if (resid_scaling)
3794  {
3797  // Dispatch to derived classes to ensure that we use the correct vector tag
3801  }
3802 
3803  // Did something bad happen during residual/Jacobian scaling computation?
3805  return false;
3806 
3807  auto examine_dof_indices = [this,
3808  jac_scaling,
3809  resid_scaling,
3810  &dof_map,
3811  &jac_inverse_scaling_factors,
3812  &resid_inverse_scaling_factors,
3813  &scaling_residual](const auto & dof_indices, const auto var_number)
3814  {
3815  for (auto dof_index : dof_indices)
3816  if (dof_map.local_index(dof_index))
3817  {
3818  if (jac_scaling)
3819  {
3820  // For now we will use the diagonal for determining scaling
3821  auto mat_value = (*_scaling_matrix)(dof_index, dof_index);
3822  auto & factor = jac_inverse_scaling_factors[_var_to_group_var[var_number]];
3823  factor = std::max(factor, std::abs(mat_value));
3824  }
3825  if (resid_scaling)
3826  {
3827  auto vec_value = scaling_residual(dof_index);
3828  auto & factor = resid_inverse_scaling_factors[_var_to_group_var[var_number]];
3829  factor = std::max(factor, std::abs(vec_value));
3830  }
3831  }
3832  };
3833 
3834  // Compute our scaling factors for the spatial field variables
3835  for (const auto & elem : *mesh().getActiveLocalElementRange())
3836  for (const auto i : make_range(system().n_vars()))
3837  if (_variable_autoscaled[i] && system().variable_type(i).family != SCALAR)
3838  {
3839  dof_map.dof_indices(elem, dof_indices, i);
3840  examine_dof_indices(dof_indices, i);
3841  }
3842 
3843  for (const auto i : make_range(system().n_vars()))
3844  if (_variable_autoscaled[i] && system().variable_type(i).family == SCALAR)
3845  {
3846  dof_map.SCALAR_dof_indices(dof_indices, i);
3847  examine_dof_indices(dof_indices, i);
3848  }
3849 
3850  if (resid_scaling)
3851  _communicator.max(resid_inverse_scaling_factors);
3852  if (jac_scaling)
3853  _communicator.max(jac_inverse_scaling_factors);
3854 
3855  if (jac_scaling && resid_scaling)
3856  for (MooseIndex(inverse_scaling_factors) i = 0; i < inverse_scaling_factors.size(); ++i)
3857  {
3858  // Be careful not to take log(0)
3859  if (!resid_inverse_scaling_factors[i])
3860  {
3861  if (!jac_inverse_scaling_factors[i])
3862  inverse_scaling_factors[i] = 1;
3863  else
3864  inverse_scaling_factors[i] = jac_inverse_scaling_factors[i];
3865  }
3866  else if (!jac_inverse_scaling_factors[i])
3867  // We know the resid is not zero
3868  inverse_scaling_factors[i] = resid_inverse_scaling_factors[i];
3869  else
3870  inverse_scaling_factors[i] =
3871  std::exp(_resid_vs_jac_scaling_param * std::log(resid_inverse_scaling_factors[i]) +
3872  (1 - _resid_vs_jac_scaling_param) * std::log(jac_inverse_scaling_factors[i]));
3873  }
3874  else if (jac_scaling)
3875  inverse_scaling_factors = jac_inverse_scaling_factors;
3876  else if (resid_scaling)
3877  inverse_scaling_factors = resid_inverse_scaling_factors;
3878  else
3879  mooseError("We shouldn't be calling this routine if we're not performing any scaling");
3880 
3881  // We have to make sure that our scaling values are not zero
3882  for (auto & scaling_factor : inverse_scaling_factors)
3883  if (scaling_factor == 0)
3884  scaling_factor = 1;
3885 
3886  // Now flatten the group scaling factors to the individual variable scaling factors
3887  std::vector<Real> flattened_inverse_scaling_factors(system().n_vars());
3888  for (const auto i : index_range(flattened_inverse_scaling_factors))
3889  flattened_inverse_scaling_factors[i] = inverse_scaling_factors[_var_to_group_var[i]];
3890 
3891  // Now set the scaling factors for the variables
3892  applyScalingFactors(flattened_inverse_scaling_factors);
3893  if (auto displaced_problem = _fe_problem.getDisplacedProblem().get())
3894  displaced_problem->systemBaseNonlinear(number()).applyScalingFactors(
3895  flattened_inverse_scaling_factors);
3896 
3897  _computed_scaling = true;
3898  return true;
3899 }
std::unique_ptr< DiagonalMatrix< Number > > _scaling_matrix
A diagonal matrix used for computing scaling.
MooseMesh & mesh()
Definition: SystemBase.h:100
std::vector< bool > _variable_autoscaled
Container to hold flag if variable is to participate in autoscaling.
void applyScalingFactors(const std::vector< Real > &inverse_scaling_factors)
Applies scaling factors to the system&#39;s variables.
Definition: SystemBase.C:1431
auto exp(const T &)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
const Parallel::Communicator & comm() const
const Parallel::Communicator & _communicator
std::size_t _num_scaling_groups
The number of scaling groups.
void computingScalingJacobian(bool computing_scaling_jacobian)
Setter for whether we&#39;re computing the scaling jacobian.
bool _compute_scaling_once
Whether the scaling factors should only be computed once at the beginning of the simulation through a...
auto max(const L &left, const R &right)
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
Real _resid_vs_jac_scaling_param
The param that indicates the weighting of the residual vs the Jacobian in determining variable scalin...
bool _auto_scaling_initd
Whether we&#39;ve initialized the automatic scaling data structures.
virtual void computeScalingResidual()=0
Compute a "residual" for automatic scaling purposes.
virtual DofMap & dofMap()
Gets writeable reference to the dof map.
Definition: SystemBase.C:1138
std::unordered_map< unsigned int, unsigned int > _var_to_group_var
A map from variable index to group variable index and it&#39;s associated (inverse) scaling factor...
unsigned int n_vars
void computingScalingResidual(bool computing_scaling_residual)
Setter for whether we&#39;re computing the scaling residual.
virtual void computeScalingJacobian()=0
Compute a "Jacobian" for automatic scaling purposes.
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1132
void setupScalingData()
Setup group scaling containers.
auto log(const T &)
static std::unique_ptr< NumericVector< Number > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
void computingNonlinearResid(bool computing_nonlinear_residual) final
Set whether or not the problem is in the process of computing the nonlinear residual.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual NumericVector< Number > & RHS()=0
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
void max(const T &r, T &o, Request &req) const
virtual System & system() override
Get the reference to the libMesh system.
bool getFailNextNonlinearConvergenceCheck() const
Whether it will skip further residual evaluations and fail the next nonlinear convergence check...
IntRange< T > make_range(T beg, T end)
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
bool _computed_scaling
Flag used to indicate whether we have already computed the scaling Jacobian.
auto index_range(const T &sizable)
void assembleScalingVector()
Assemble the numeric vector of scaling factors such that it can be used during assembly of the system...

◆ computeScalingJacobian()

void NonlinearEigenSystem::computeScalingJacobian ( )
overrideprotectedvirtual

Compute a "Jacobian" for automatic scaling purposes.

Implements NonlinearSystemBase.

Definition at line 461 of file NonlinearEigenSystem.C.

462 {
464 }
std::unique_ptr< DiagonalMatrix< Number > > _scaling_matrix
A diagonal matrix used for computing scaling.
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:77
virtual void computeJacobianTag(const NumericVector< Number > &soln, SparseMatrix< Number > &jacobian, TagID tag) override
Form a Jacobian matrix for all kernels and BCs with a given tag.
Definition: EigenProblem.C:166

◆ computeScalingOnce() [1/2]

bool NonlinearSystemBase::computeScalingOnce ( ) const
inlineinherited

Definition at line 613 of file NonlinearSystemBase.h.

Referenced by FEProblemSolve::FEProblemSolve().

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

◆ computeScalingOnce() [2/2]

void NonlinearSystemBase::computeScalingOnce ( bool  compute_scaling_once)
inlineinherited

Definition at line 614 of file NonlinearSystemBase.h.

615  {
616  _compute_scaling_once = compute_scaling_once;
617  }
bool _compute_scaling_once
Whether the scaling factors should only be computed once at the beginning of the simulation through a...

◆ computeScalingResidual()

void NonlinearEigenSystem::computeScalingResidual ( )
overrideprotectedvirtual

Compute a "residual" for automatic scaling purposes.

Implements NonlinearSystemBase.

Definition at line 467 of file NonlinearEigenSystem.C.

468 {
470 }
virtual void computeResidualTag(const NumericVector< Number > &soln, NumericVector< Number > &residual, TagID tag) override
Form a vector for all kernels and BCs with a given tag.
Definition: EigenProblem.C:283
TagID nonEigenVectorTag() const
Vector tag ID of left hand side.
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:77
virtual NumericVector< Number > & RHS() override

◆ computeTimeDerivatives()

void NonlinearSystemBase::computeTimeDerivatives ( bool  jacobian_calculation = false)
inherited

Computes the time derivative vector.

Definition at line 984 of file NonlinearSystemBase.C.

Referenced by FEProblemBase::computeJacobianTags(), and ExplicitSSPRungeKutta::solveStage().

985 {
986  // If we're doing any Jacobian calculation other than the initial Jacobian calculation for
987  // automatic variable scaling, then we can just return because the residual function evaluation
988  // has already done this work for us
989  if (jacobian_calculation && !_fe_problem.computingScalingJacobian())
990  return;
991 
992  if (_time_integrator)
993  {
994  _time_integrator->preStep();
995  _time_integrator->computeTimeDerivatives();
996  }
997 }
void computingScalingJacobian(bool computing_scaling_jacobian)
Setter for whether we&#39;re computing the scaling jacobian.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:1007

◆ computeVariables()

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

Definition at line 862 of file SystemBase.h.

862 {}

◆ computingInitialResidual()

virtual bool NonlinearSystemBase::computingInitialResidual ( )
inlinevirtualinherited

Returns true if this system is currently computing the initial residual for a solve.

Returns
Whether or not we are currently computing the initial residual.

Definition at line 92 of file NonlinearSystemBase.h.

◆ computingScalingJacobian()

bool SystemBase::computingScalingJacobian ( ) const
inherited

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

Definition at line 1488 of file SystemBase.C.

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

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

◆ constraintJacobians()

void NonlinearSystemBase::constraintJacobians ( bool  displaced)
inherited

Add jacobian contributions from Constraints.

Parameters
jacobianreference to the Jacobian matrix
displacedControls whether to do the displaced Constraints or non-displaced

Definition at line 2197 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

2198 {
2199  if (!hasMatrix(systemMatrixTag()))
2200  mooseError("A system matrix is required");
2201 
2202  auto & jacobian = getMatrix(systemMatrixTag());
2203 
2205  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2206  MAT_NEW_NONZERO_ALLOCATION_ERR,
2207  PETSC_FALSE);
2209  MatSetOption(
2210  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE);
2211 
2212  std::vector<numeric_index_type> zero_rows;
2213 
2214  if (displaced)
2215  mooseAssert(_fe_problem.getDisplacedProblem(),
2216  "If we're calling this method with displaced = true, then we better well have a "
2217  "displaced problem");
2218  auto & subproblem = displaced ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
2219  : static_cast<SubProblem &>(_fe_problem);
2220  const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
2221 
2222  bool constraints_applied;
2224  constraints_applied = false;
2225  for (const auto & it : penetration_locators)
2226  {
2228  {
2229  // Reset the constraint_applied flag before each new constraint, as they need to be
2230  // assembled separately
2231  constraints_applied = false;
2232  }
2233  PenetrationLocator & pen_loc = *(it.second);
2234 
2235  std::vector<dof_id_type> & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
2236 
2237  BoundaryID secondary_boundary = pen_loc._secondary_boundary;
2238  BoundaryID primary_boundary = pen_loc._primary_boundary;
2239 
2240  zero_rows.clear();
2241  if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, displaced))
2242  {
2243  const auto & constraints =
2244  _constraints.getActiveNodeFaceConstraints(secondary_boundary, displaced);
2245 
2246  for (const auto & secondary_node_num : secondary_nodes)
2247  {
2248  Node & secondary_node = _mesh.nodeRef(secondary_node_num);
2249 
2250  if (secondary_node.processor_id() == processor_id())
2251  {
2252  if (pen_loc._penetration_info[secondary_node_num])
2253  {
2254  PenetrationInfo & info = *pen_loc._penetration_info[secondary_node_num];
2255 
2256  reinitNodeFace(secondary_node, secondary_boundary, info, displaced);
2258 
2259  for (const auto & nfc : constraints)
2260  {
2261  if (nfc->isExplicitConstraint())
2262  continue;
2263  // Return if this constraint does not correspond to the primary-secondary pair
2264  // prepared by the outer loops.
2265  // This continue statement is required when, e.g. one secondary surface constrains
2266  // more than one primary surface.
2267  if (nfc->secondaryBoundary() != secondary_boundary ||
2268  nfc->primaryBoundary() != primary_boundary)
2269  continue;
2270 
2271  nfc->_jacobian = &jacobian;
2272 
2273  if (nfc->shouldApply())
2274  {
2275  constraints_applied = true;
2276 
2277  nfc->prepareShapes(nfc->variable().number());
2278  nfc->prepareNeighborShapes(nfc->variable().number());
2279 
2280  nfc->computeJacobian();
2281 
2282  if (nfc->overwriteSecondaryJacobian())
2283  {
2284  // Add this variable's dof's row to be zeroed
2285  zero_rows.push_back(nfc->variable().nodalDofIndex());
2286  }
2287 
2288  std::vector<dof_id_type> secondary_dofs(1, nfc->variable().nodalDofIndex());
2289 
2290  // Assume that if the user is overwriting the secondary Jacobian, then they are
2291  // supplying Jacobians that do not correspond to their other physics
2292  // (e.g. Kernels), hence we should not apply a scalingFactor that is normally
2293  // based on the order of their other physics (e.g. Kernels)
2294  Real scaling_factor =
2295  nfc->overwriteSecondaryJacobian() ? 1. : nfc->variable().scalingFactor();
2296 
2297  // Cache the jacobian block for the secondary side
2298  nfc->addJacobian(_fe_problem.assembly(0, number()),
2299  nfc->_Kee,
2300  secondary_dofs,
2301  nfc->_connected_dof_indices,
2302  scaling_factor);
2303 
2304  // Cache Ken, Kne, Knn
2305  if (nfc->addCouplingEntriesToJacobian())
2306  {
2307  // Make sure we use a proper scaling factor (e.g. don't use an interior scaling
2308  // factor when we're overwriting secondary stuff)
2309  nfc->addJacobian(_fe_problem.assembly(0, number()),
2310  nfc->_Ken,
2311  secondary_dofs,
2312  nfc->primaryVariable().dofIndicesNeighbor(),
2313  scaling_factor);
2314 
2315  // Use _connected_dof_indices to get all the correct columns
2316  nfc->addJacobian(_fe_problem.assembly(0, number()),
2317  nfc->_Kne,
2318  nfc->primaryVariable().dofIndicesNeighbor(),
2319  nfc->_connected_dof_indices,
2320  nfc->variable().scalingFactor());
2321 
2322  // We've handled Ken and Kne, finally handle Knn
2324  }
2325 
2326  // Do the off-diagonals next
2327  const std::vector<MooseVariableFEBase *> coupled_vars = nfc->getCoupledMooseVars();
2328  for (const auto & jvar : coupled_vars)
2329  {
2330  // Only compute jacobians for nonlinear variables
2331  if (jvar->kind() != Moose::VAR_SOLVER)
2332  continue;
2333 
2334  // Only compute Jacobian entries if this coupling is being used by the
2335  // preconditioner
2336  if (nfc->variable().number() == jvar->number() ||
2338  nfc->variable().number(), jvar->number(), this->number()))
2339  continue;
2340 
2341  // Need to zero out the matrices first
2343 
2344  nfc->prepareShapes(nfc->variable().number());
2345  nfc->prepareNeighborShapes(jvar->number());
2346 
2347  nfc->computeOffDiagJacobian(jvar->number());
2348 
2349  // Cache the jacobian block for the secondary side
2350  nfc->addJacobian(_fe_problem.assembly(0, number()),
2351  nfc->_Kee,
2352  secondary_dofs,
2353  nfc->_connected_dof_indices,
2354  scaling_factor);
2355 
2356  // Cache Ken, Kne, Knn
2357  if (nfc->addCouplingEntriesToJacobian())
2358  {
2359  // Make sure we use a proper scaling factor (e.g. don't use an interior scaling
2360  // factor when we're overwriting secondary stuff)
2361  nfc->addJacobian(_fe_problem.assembly(0, number()),
2362  nfc->_Ken,
2363  secondary_dofs,
2364  jvar->dofIndicesNeighbor(),
2365  scaling_factor);
2366 
2367  // Use _connected_dof_indices to get all the correct columns
2368  nfc->addJacobian(_fe_problem.assembly(0, number()),
2369  nfc->_Kne,
2370  nfc->variable().dofIndicesNeighbor(),
2371  nfc->_connected_dof_indices,
2372  nfc->variable().scalingFactor());
2373 
2374  // We've handled Ken and Kne, finally handle Knn
2376  }
2377  }
2378  }
2379  }
2380  }
2381  }
2382  }
2383  }
2385  {
2386  // See if constraints were applied anywhere
2387  _communicator.max(constraints_applied);
2388 
2389  if (constraints_applied)
2390  {
2391  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2392  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2393  PETSC_TRUE);
2394 
2395  jacobian.close();
2396  jacobian.zero_rows(zero_rows, 0.0);
2397  jacobian.close();
2399  jacobian.close();
2400  }
2401  }
2402  }
2404  {
2405  // See if constraints were applied anywhere
2406  _communicator.max(constraints_applied);
2407 
2408  if (constraints_applied)
2409  {
2410  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2411  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2412  PETSC_TRUE);
2413 
2414  jacobian.close();
2415  jacobian.zero_rows(zero_rows, 0.0);
2416  jacobian.close();
2418  jacobian.close();
2419  }
2420  }
2421 
2422  THREAD_ID tid = 0;
2423  // go over element-element constraint interface
2424  const auto & element_pair_locators = subproblem.geomSearchData()._element_pair_locators;
2425  for (const auto & it : element_pair_locators)
2426  {
2427  ElementPairLocator & elem_pair_loc = *(it.second);
2428 
2429  if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
2430  {
2431  // ElemElemConstraint objects
2432  const auto & _element_constraints =
2433  _constraints.getActiveElemElemConstraints(it.first, displaced);
2434 
2435  // go over pair elements
2436  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
2437  elem_pair_loc.getElemPairs();
2438  for (const auto & pr : elem_pairs)
2439  {
2440  const Elem * elem1 = pr.first;
2441  const Elem * elem2 = pr.second;
2442 
2443  if (elem1->processor_id() != processor_id())
2444  continue;
2445 
2446  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
2447 
2448  // for each element process constraints on the
2449  for (const auto & ec : _element_constraints)
2450  {
2451  _fe_problem.setCurrentSubdomainID(elem1, tid);
2452  subproblem.reinitElemPhys(elem1, info._elem1_constraint_q_point, tid);
2453  _fe_problem.setNeighborSubdomainID(elem2, tid);
2454  subproblem.reinitNeighborPhys(elem2, info._elem2_constraint_q_point, tid);
2455 
2456  ec->prepareShapes(ec->variable().number());
2457  ec->prepareNeighborShapes(ec->variable().number());
2458 
2459  ec->reinit(info);
2460  ec->computeJacobian();
2463  }
2465  }
2466  }
2467  }
2468 
2469  // go over NodeELemConstraints
2470  std::set<dof_id_type> unique_secondary_node_ids;
2471  constraints_applied = false;
2472  for (const auto & secondary_id : _mesh.meshSubdomains())
2473  {
2474  for (const auto & primary_id : _mesh.meshSubdomains())
2475  {
2476  if (_constraints.hasActiveNodeElemConstraints(secondary_id, primary_id, displaced))
2477  {
2478  const auto & constraints =
2479  _constraints.getActiveNodeElemConstraints(secondary_id, primary_id, displaced);
2480 
2481  // get unique set of ids of all nodes on current block
2482  unique_secondary_node_ids.clear();
2483  const MeshBase & meshhelper = _mesh.getMesh();
2484  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
2485  meshhelper.active_subdomain_elements_end(secondary_id)))
2486  {
2487  for (auto & n : elem->node_ref_range())
2488  unique_secondary_node_ids.insert(n.id());
2489  }
2490 
2491  for (auto secondary_node_id : unique_secondary_node_ids)
2492  {
2493  const Node & secondary_node = _mesh.nodeRef(secondary_node_id);
2494  // check if secondary node is on current processor
2495  if (secondary_node.processor_id() == processor_id())
2496  {
2497  // This reinits the variables that exist on the secondary node
2498  _fe_problem.reinitNodeFace(&secondary_node, secondary_id, 0);
2499 
2500  // This will set aside residual and jacobian space for the variables that have dofs
2501  // on the secondary node
2504 
2505  for (const auto & nec : constraints)
2506  {
2507  if (nec->shouldApply())
2508  {
2509  constraints_applied = true;
2510 
2511  nec->_jacobian = &jacobian;
2512  nec->prepareShapes(nec->variable().number());
2513  nec->prepareNeighborShapes(nec->variable().number());
2514 
2515  nec->computeJacobian();
2516 
2517  if (nec->overwriteSecondaryJacobian())
2518  {
2519  // Add this variable's dof's row to be zeroed
2520  zero_rows.push_back(nec->variable().nodalDofIndex());
2521  }
2522 
2523  std::vector<dof_id_type> secondary_dofs(1, nec->variable().nodalDofIndex());
2524 
2525  // Cache the jacobian block for the secondary side
2526  nec->addJacobian(_fe_problem.assembly(0, number()),
2527  nec->_Kee,
2528  secondary_dofs,
2529  nec->_connected_dof_indices,
2530  nec->variable().scalingFactor());
2531 
2532  // Cache the jacobian block for the primary side
2533  nec->addJacobian(_fe_problem.assembly(0, number()),
2534  nec->_Kne,
2535  nec->primaryVariable().dofIndicesNeighbor(),
2536  nec->_connected_dof_indices,
2537  nec->variable().scalingFactor());
2538 
2541 
2542  // Do the off-diagonals next
2543  const std::vector<MooseVariableFEBase *> coupled_vars = nec->getCoupledMooseVars();
2544  for (const auto & jvar : coupled_vars)
2545  {
2546  // Only compute jacobians for nonlinear variables
2547  if (jvar->kind() != Moose::VAR_SOLVER)
2548  continue;
2549 
2550  // Only compute Jacobian entries if this coupling is being used by the
2551  // preconditioner
2552  if (nec->variable().number() == jvar->number() ||
2554  nec->variable().number(), jvar->number(), this->number()))
2555  continue;
2556 
2557  // Need to zero out the matrices first
2559 
2560  nec->prepareShapes(nec->variable().number());
2561  nec->prepareNeighborShapes(jvar->number());
2562 
2563  nec->computeOffDiagJacobian(jvar->number());
2564 
2565  // Cache the jacobian block for the secondary side
2566  nec->addJacobian(_fe_problem.assembly(0, number()),
2567  nec->_Kee,
2568  secondary_dofs,
2569  nec->_connected_dof_indices,
2570  nec->variable().scalingFactor());
2571 
2572  // Cache the jacobian block for the primary side
2573  nec->addJacobian(_fe_problem.assembly(0, number()),
2574  nec->_Kne,
2575  nec->variable().dofIndicesNeighbor(),
2576  nec->_connected_dof_indices,
2577  nec->variable().scalingFactor());
2578 
2581  }
2582  }
2583  }
2584  }
2585  }
2586  }
2587  }
2588  }
2589  // See if constraints were applied anywhere
2590  _communicator.max(constraints_applied);
2591 
2592  if (constraints_applied)
2593  {
2594  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2595  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2596  PETSC_TRUE);
2597 
2598  jacobian.close();
2599  jacobian.zero_rows(zero_rows, 0.0);
2600  jacobian.close();
2602  jacobian.close();
2603  }
2604 }
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
std::map< std::pair< BoundaryID, BoundaryID >, PenetrationLocator * > _penetration_locators
BoundaryID _secondary_boundary
bool _assemble_constraints_separately
Whether or not to assemble the residual and Jacobian after the application of each constraint...
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
MPI_Info info
bool areCoupled(const unsigned int ivar, const unsigned int jvar, const unsigned int nl_sys_num) const
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
Data structure used to hold penetration information.
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem *> elem_pair) const
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
const Parallel::Communicator & _communicator
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
bool hasActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
virtual void cacheJacobianNeighbor(const THREAD_ID tid) override
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:637
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num) override
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
std::vector< dof_id_type > _secondary_nodes
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3199
const ElementPairList & getElemPairs() const
boundary_id_type BoundaryID
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
SubProblem & subproblem()
Definition: SystemBase.h:102
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
This is the ElementPairLocator class.
This is the ElementPairInfo class.
std::map< BoundaryID, std::shared_ptr< ElementPairLocator > > _element_pair_locators
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1132
virtual GeometricSearchData & geomSearchData()=0
virtual void prepareAssembly(const THREAD_ID tid) override
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid)=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
MooseMesh & _mesh
Definition: SystemBase.h:953
void max(const T &r, T &o, Request &req) const
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:980
bool hasActiveElemElemConstraints(const InterfaceID interface_id, bool displaced) const
void reinitNodeFace(const Node &secondary_node, const BoundaryID secondary_boundary, const PenetrationInfo &info, const bool displaced)
Reinitialize quantities such as variables, residuals, Jacobians, materials for node-face constraints...
bool ignoreZerosInJacobian() const
const std::vector< std::shared_ptr< NodeElemConstraint > > & getActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
processor_id_type processor_id() const
const std::vector< std::shared_ptr< ElemElemConstraint > > & getActiveElemElemConstraints(InterfaceID interface_id, bool displaced) const
virtual void cacheJacobian(const THREAD_ID tid) override
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
virtual void reinitOffDiagScalars(const THREAD_ID tid) override
BoundaryID _primary_boundary
unsigned int THREAD_ID
Definition: MooseTypes.h:198
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override
NearestNodeLocator & _nearest_node
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:2922
virtual void addCachedJacobian(const THREAD_ID tid) override

◆ constraintResiduals()

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

Add residual contributions from Constraints.

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

Definition at line 1255 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualInternal().

1256 {
1257  // Make sure the residual is in a good state
1258  residual.close();
1259 
1260  if (displaced)
1261  mooseAssert(_fe_problem.getDisplacedProblem(),
1262  "If we're calling this method with displaced = true, then we better well have a "
1263  "displaced problem");
1264  auto & subproblem = displaced ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
1265  : static_cast<SubProblem &>(_fe_problem);
1266  const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
1267 
1268  bool constraints_applied;
1269  bool residual_has_inserted_values = false;
1271  constraints_applied = false;
1272  for (const auto & it : penetration_locators)
1273  {
1275  {
1276  // Reset the constraint_applied flag before each new constraint, as they need to be
1277  // assembled separately
1278  constraints_applied = false;
1279  }
1280  PenetrationLocator & pen_loc = *(it.second);
1281 
1282  std::vector<dof_id_type> & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
1283 
1284  BoundaryID secondary_boundary = pen_loc._secondary_boundary;
1285  BoundaryID primary_boundary = pen_loc._primary_boundary;
1286 
1287  bool has_writable_variables(false);
1288 
1289  if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, displaced))
1290  {
1291  const auto & constraints =
1292  _constraints.getActiveNodeFaceConstraints(secondary_boundary, displaced);
1293 
1294  for (unsigned int i = 0; i < secondary_nodes.size(); i++)
1295  {
1296  dof_id_type secondary_node_num = secondary_nodes[i];
1297  Node & secondary_node = _mesh.nodeRef(secondary_node_num);
1298 
1299  if (secondary_node.processor_id() == processor_id())
1300  {
1301  if (pen_loc._penetration_info[secondary_node_num])
1302  {
1303  PenetrationInfo & info = *pen_loc._penetration_info[secondary_node_num];
1304 
1305  reinitNodeFace(secondary_node, secondary_boundary, info, displaced);
1306 
1307  for (const auto & nfc : constraints)
1308  {
1309  // Return if this constraint does not correspond to the primary-secondary pair
1310  // prepared by the outer loops.
1311  // This continue statement is required when, e.g. one secondary surface constrains
1312  // more than one primary surface.
1313  if (nfc->secondaryBoundary() != secondary_boundary ||
1314  nfc->primaryBoundary() != primary_boundary)
1315  continue;
1316 
1317  if (nfc->shouldApply())
1318  {
1319  constraints_applied = true;
1320  nfc->computeResidual();
1321 
1322  if (nfc->overwriteSecondaryResidual())
1323  {
1324  // The below will actually overwrite the residual for every single dof that
1325  // lives on the node. We definitely don't want to do that!
1326  // _fe_problem.setResidual(residual, 0);
1327 
1328  const auto & secondary_var = nfc->variable();
1329  const auto & secondary_dofs = secondary_var.dofIndices();
1330  mooseAssert(secondary_dofs.size() == secondary_var.count(),
1331  "We are on a node so there should only be one dof per variable (for "
1332  "an ArrayVariable we should have a number of dofs equal to the "
1333  "number of components");
1334 
1335  // Assume that if the user is overwriting the secondary residual, then they are
1336  // supplying residuals that do not correspond to their other physics
1337  // (e.g. Kernels), hence we should not apply a scalingFactor that is normally
1338  // based on the order of their other physics (e.g. Kernels)
1339  std::vector<Number> values = {nfc->secondaryResidual()};
1340  residual.insert(values, secondary_dofs);
1341  residual_has_inserted_values = true;
1342  }
1343  else
1346  }
1347  if (nfc->hasWritableCoupledVariables())
1348  {
1349  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1350  has_writable_variables = true;
1351  for (auto * var : nfc->getWritableCoupledVariables())
1352  {
1353  if (var->isNodalDefined())
1354  var->insert(_fe_problem.getAuxiliarySystem().solution());
1355  }
1356  }
1357  }
1358  }
1359  }
1360  }
1361  }
1362  _communicator.max(has_writable_variables);
1363 
1364  if (has_writable_variables)
1365  {
1366  // Explicit contact dynamic constraints write to auxiliary variables and update the old
1367  // displacement solution on the constraint boundaries. Close solutions and update system
1368  // accordingly.
1370  _fe_problem.getAuxiliarySystem().system().update();
1371  solutionOld().close();
1372  }
1373 
1375  {
1376  // Make sure that secondary contribution to primary are assembled, and ghosts have been
1377  // exchanged, as current primaries might become secondaries on next iteration and will need to
1378  // contribute their former secondaries' contributions to the future primaries. See if
1379  // constraints were applied anywhere
1380  _communicator.max(constraints_applied);
1381 
1382  if (constraints_applied)
1383  {
1384  // If any of the above constraints inserted values in the residual, it needs to be
1385  // assembled before adding the cached residuals below.
1386  _communicator.max(residual_has_inserted_values);
1387  if (residual_has_inserted_values)
1388  {
1389  residual.close();
1390  residual_has_inserted_values = false;
1391  }
1393  residual.close();
1394 
1396  *_residual_ghosted = residual;
1397  }
1398  }
1399  }
1401  {
1402  _communicator.max(constraints_applied);
1403 
1404  if (constraints_applied)
1405  {
1406  // If any of the above constraints inserted values in the residual, it needs to be assembled
1407  // before adding the cached residuals below.
1408  _communicator.max(residual_has_inserted_values);
1409  if (residual_has_inserted_values)
1410  residual.close();
1411 
1413  residual.close();
1414 
1416  *_residual_ghosted = residual;
1417  }
1418  }
1419 
1420  // go over element-element constraint interface
1421  THREAD_ID tid = 0;
1422  const auto & element_pair_locators = subproblem.geomSearchData()._element_pair_locators;
1423  for (const auto & it : element_pair_locators)
1424  {
1425  ElementPairLocator & elem_pair_loc = *(it.second);
1426 
1427  if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
1428  {
1429  // ElemElemConstraint objects
1430  const auto & _element_constraints =
1431  _constraints.getActiveElemElemConstraints(it.first, displaced);
1432 
1433  // go over pair elements
1434  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
1435  elem_pair_loc.getElemPairs();
1436  for (const auto & pr : elem_pairs)
1437  {
1438  const Elem * elem1 = pr.first;
1439  const Elem * elem2 = pr.second;
1440 
1441  if (elem1->processor_id() != processor_id())
1442  continue;
1443 
1444  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
1445 
1446  // for each element process constraints on the
1447  for (const auto & ec : _element_constraints)
1448  {
1449  _fe_problem.setCurrentSubdomainID(elem1, tid);
1450  subproblem.reinitElemPhys(elem1, info._elem1_constraint_q_point, tid);
1451  _fe_problem.setNeighborSubdomainID(elem2, tid);
1452  subproblem.reinitNeighborPhys(elem2, info._elem2_constraint_q_point, tid);
1453 
1454  ec->prepareShapes(ec->variable().number());
1455  ec->prepareNeighborShapes(ec->variable().number());
1456 
1457  ec->reinit(info);
1458  ec->computeResidual();
1461  }
1463  }
1464  }
1465  }
1466 
1467  // go over NodeELemConstraints
1468  std::set<dof_id_type> unique_secondary_node_ids;
1469 
1470  constraints_applied = false;
1471  residual_has_inserted_values = false;
1472  for (const auto & secondary_id : _mesh.meshSubdomains())
1473  {
1474  for (const auto & primary_id : _mesh.meshSubdomains())
1475  {
1476  if (_constraints.hasActiveNodeElemConstraints(secondary_id, primary_id, displaced))
1477  {
1478  const auto & constraints =
1479  _constraints.getActiveNodeElemConstraints(secondary_id, primary_id, displaced);
1480 
1481  // get unique set of ids of all nodes on current block
1482  unique_secondary_node_ids.clear();
1483  const MeshBase & meshhelper = _mesh.getMesh();
1484  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
1485  meshhelper.active_subdomain_elements_end(secondary_id)))
1486  {
1487  for (auto & n : elem->node_ref_range())
1488  unique_secondary_node_ids.insert(n.id());
1489  }
1490 
1491  for (auto secondary_node_id : unique_secondary_node_ids)
1492  {
1493  Node & secondary_node = _mesh.nodeRef(secondary_node_id);
1494  // check if secondary node is on current processor
1495  if (secondary_node.processor_id() == processor_id())
1496  {
1497  // This reinits the variables that exist on the secondary node
1498  _fe_problem.reinitNodeFace(&secondary_node, secondary_id, 0);
1499 
1500  // This will set aside residual and jacobian space for the variables that have dofs
1501  // on the secondary node
1503 
1504  for (const auto & nec : constraints)
1505  {
1506  if (nec->shouldApply())
1507  {
1508  constraints_applied = true;
1509  nec->computeResidual();
1510 
1511  if (nec->overwriteSecondaryResidual())
1512  {
1513  _fe_problem.setResidual(residual, 0);
1514  residual_has_inserted_values = true;
1515  }
1516  else
1519  }
1520  }
1522  }
1523  }
1524  }
1525  }
1526  }
1527  _communicator.max(constraints_applied);
1528 
1529  if (constraints_applied)
1530  {
1531  // If any of the above constraints inserted values in the residual, it needs to be assembled
1532  // before adding the cached residuals below.
1533  _communicator.max(residual_has_inserted_values);
1534  if (residual_has_inserted_values)
1535  residual.close();
1536 
1538  residual.close();
1539 
1541  *_residual_ghosted = residual;
1542  }
1543 
1544  // We may have additional tagged vectors that also need to be accumulated
1546 }
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
virtual void insert(const Number *v, const std::vector< numeric_index_type > &dof_indices)
std::map< std::pair< BoundaryID, BoundaryID >, PenetrationLocator * > _penetration_locators
virtual void cacheResidualNeighbor(const THREAD_ID tid) override
BoundaryID _secondary_boundary
bool _assemble_constraints_separately
Whether or not to assemble the residual and Jacobian after the application of each constraint...
MPI_Info info
NumericVector< Number > & solution()
Definition: SystemBase.h:182
Data structure used to hold penetration information.
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem *> elem_pair) const
const Parallel::Communicator & _communicator
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
bool hasActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:637
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
virtual void addCachedResidualDirectly(NumericVector< 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 setResidual(NumericVector< Number > &residual, const THREAD_ID tid) override
std::vector< dof_id_type > _secondary_nodes
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3199
const ElementPairList & getElemPairs() const
boundary_id_type BoundaryID
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
SubProblem & subproblem()
Definition: SystemBase.h:102
virtual void cacheResidual(const THREAD_ID tid) override
This is the ElementPairLocator class.
This is the ElementPairInfo class.
std::map< BoundaryID, std::shared_ptr< ElementPairLocator > > _element_pair_locators
virtual GeometricSearchData & geomSearchData()=0
AuxiliarySystem & getAuxiliarySystem()
virtual void prepareAssembly(const THREAD_ID tid) override
virtual void setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
virtual void close()=0
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid)=0
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
MooseMesh & _mesh
Definition: SystemBase.h:953
void max(const T &r, T &o, Request &req) const
virtual System & system() override
Get the reference to the libMesh system.
bool hasActiveElemElemConstraints(const InterfaceID interface_id, bool displaced) const
void reinitNodeFace(const Node &secondary_node, const BoundaryID secondary_boundary, const PenetrationInfo &info, const bool displaced)
Reinitialize quantities such as variables, residuals, Jacobians, materials for node-face constraints...
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
const std::vector< std::shared_ptr< NodeElemConstraint > > & getActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
NumericVector< Number > & solutionOld()
Definition: SystemBase.h:183
processor_id_type processor_id() const
const std::vector< std::shared_ptr< ElemElemConstraint > > & getActiveElemElemConstraints(InterfaceID interface_id, bool displaced) const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
virtual void addCachedResidual(const THREAD_ID tid) override
BoundaryID _primary_boundary
unsigned int THREAD_ID
Definition: MooseTypes.h:198
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override
uint8_t dof_id_type
NearestNodeLocator & _nearest_node
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:2922

◆ containsTimeKernel()

bool NonlinearSystemBase::containsTimeKernel ( )
inherited

Definition at line 3606 of file NonlinearSystemBase.C.

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

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

◆ converged() [1/2]

bool NonlinearEigenSystem::converged ( )
overridevirtual

Returns the convergence state.

Returns
true if converged, otherwise false

Implements NonlinearSystemBase.

Definition at line 307 of file NonlinearEigenSystem.C.

308 {
309  return _eigen_sys.get_n_converged();
310 }

◆ converged() [2/2]

bool NonlinearEigenSystem::converged ( )
inlinevirtual

Returns the convergence state.

Returns
true if converged, otherwise false

Implements NonlinearSystemBase.

Definition at line 205 of file NonlinearEigenSystem.h.

205 { return false; }

◆ copyOldSolutions()

void SystemBase::copyOldSolutions ( )
virtualinherited

Shifts the solutions backwards in time.

Definition at line 1261 of file SystemBase.C.

Referenced by EigenExecutionerBase::inversePowerIteration().

1262 {
1263  const auto states =
1264  _solution_states[static_cast<unsigned short>(Moose::SolutionIterationType::Time)].size();
1265  if (states > 1)
1266  for (unsigned int i = states - 1; i > 0; --i)
1267  solutionState(i) = solutionState(i - 1);
1268 
1269  if (solutionUDotOld())
1270  *solutionUDotOld() = *solutionUDot();
1271  if (solutionUDotDotOld())
1273  if (solutionPreviousNewton())
1275 }
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.C:1391
virtual NumericVector< Number > * solutionUDotDotOld()
Definition: SystemBase.h:242
virtual NumericVector< Number > * solutionUDot()
Definition: SystemBase.h:239
virtual NumericVector< Number > * solutionUDotOld()
Definition: SystemBase.h:241
std::array< std::vector< NumericVector< Number > * >, 2 > _solution_states
The solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1041
virtual const NumericVector< Number > * solutionPreviousNewton() const
Definition: SystemBase.C:1319
virtual NumericVector< Number > * solutionUDotDot()
Definition: SystemBase.h:240

◆ copySolutionsBackwards()

void SystemBase::copySolutionsBackwards ( )
virtualinherited

Copy current solution into old and older.

Definition at line 1234 of file SystemBase.C.

1235 {
1236  system().update();
1237 
1238  // Copying the solutions backward so the current solution will become the old, and the old will
1239  // become older. The same applies to the nonlinear iterates.
1240  for (const auto iteration_index : index_range(_solution_states))
1241  {
1242  const auto states = _solution_states[iteration_index].size();
1243  if (states > 1)
1244  for (unsigned int i = states - 1; i > 0; --i)
1245  solutionState(i, Moose::SolutionIterationType(iteration_index)) =
1246  solutionState(i - 1, Moose::SolutionIterationType(iteration_index));
1247  }
1248 
1249  if (solutionUDotOld())
1250  *solutionUDotOld() = *solutionUDot();
1251  if (solutionUDotDotOld())
1253  if (solutionPreviousNewton())
1255 }
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.C:1391
virtual NumericVector< Number > * solutionUDotDotOld()
Definition: SystemBase.h:242
virtual NumericVector< Number > * solutionUDot()
Definition: SystemBase.h:239
virtual NumericVector< Number > * solutionUDotOld()
Definition: SystemBase.h:241
virtual System & system()=0
Get the reference to the libMesh system.
std::array< std::vector< NumericVector< Number > * >, 2 > _solution_states
The solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1041
virtual const NumericVector< Number > * solutionPreviousNewton() const
Definition: SystemBase.C:1319
virtual NumericVector< Number > * solutionUDotDot()
Definition: SystemBase.h:240
auto index_range(const T &sizable)
SolutionIterationType
Definition: MooseTypes.h:229

◆ copyVars()

void SystemBase::copyVars ( ExodusII_IO &  io)
inherited

Definition at line 1158 of file SystemBase.C.

1159 {
1160  int n_steps = io.get_num_time_steps();
1161 
1162  bool did_copy = false;
1163  for (const auto & vci : _var_to_copy)
1164  {
1165  int timestep = -1;
1166 
1167  if (vci._timestep == "LATEST")
1168  // Use the last time step in the file from which to retrieve the solution
1169  timestep = n_steps;
1170  else
1171  {
1172  timestep = MooseUtils::convert<int>(vci._timestep);
1173  if (timestep > n_steps)
1174  mooseError("Invalid value passed as \"initial_from_file_timestep\". Expected \"LATEST\" or "
1175  "a valid integer between 1 and ",
1176  n_steps,
1177  " inclusive, received ",
1178  vci._timestep);
1179  }
1180 
1181  did_copy = true;
1182 
1183  if (hasVariable(vci._dest_name))
1184  {
1185  const auto & var = getVariable(0, vci._dest_name);
1186  if (var.isArray())
1187  {
1188  const auto & array_var = getFieldVariable<RealEigenVector>(0, vci._dest_name);
1189  for (MooseIndex(var.count()) i = 0; i < var.count(); ++i)
1190  {
1191  const auto exodus_var = _subproblem.arrayVariableComponent(vci._source_name, i);
1192  const auto system_var = array_var.componentName(i);
1193  if (var.isNodal())
1194  io.copy_nodal_solution(system(), exodus_var, system_var, timestep);
1195  else
1196  io.copy_elemental_solution(system(), exodus_var, system_var, timestep);
1197  }
1198  }
1199  else
1200  {
1201  if (var.isNodal())
1202  io.copy_nodal_solution(system(), vci._dest_name, vci._source_name, timestep);
1203  else
1204  io.copy_elemental_solution(system(), vci._dest_name, vci._source_name, timestep);
1205  }
1206  }
1207  else if (hasScalarVariable(vci._dest_name))
1208  io.copy_scalar_solution(system(), {vci._dest_name}, {vci._source_name}, timestep);
1209  else
1210  mooseError("Unrecognized variable ", vci._dest_name, " in variables to copy.");
1211  }
1212 
1213  if (did_copy)
1214  solution().close();
1215 }
NumericVector< Number > & solution()
Definition: SystemBase.h:182
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:998
int convert< int >(const std::string &str, bool throw_on_failure)
Definition: MooseUtils.C:999
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual System & system()=0
Get the reference to the libMesh system.
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition: SystemBase.C:807
virtual void close()=0
static std::string arrayVariableComponent(const std::string &var_name, unsigned int i)
Returns the variable name of a component of an array variable.
Definition: SubProblem.h:271
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:86
virtual bool hasScalarVariable(const std::string &var_name) const
Definition: SystemBase.C:832

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

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

90 {
91  return _current_solution;
92 }
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:77

◆ customSetup()

void NonlinearSystemBase::customSetup ( const ExecFlagType exec_type)
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 352 of file NonlinearSystemBase.C.

353 {
354  SolverSystem::customSetup(exec_type);
355 
356  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
357  {
358  _kernels.customSetup(exec_type, tid);
359  _nodal_kernels.customSetup(exec_type, tid);
360  _dirac_kernels.customSetup(exec_type, tid);
361  if (_doing_dg)
362  _dg_kernels.customSetup(exec_type, tid);
363  _interface_kernels.customSetup(exec_type, tid);
364  _element_dampers.customSetup(exec_type, tid);
365  _nodal_dampers.customSetup(exec_type, tid);
366  _integrated_bcs.customSetup(exec_type, tid);
367 
368  if (_fe_problem.haveFV())
369  {
370  std::vector<FVFluxBC *> bcs;
372  .query()
373  .template condition<AttribSystem>("FVFluxBC")
374  .template condition<AttribThread>(tid)
375  .queryInto(bcs);
376 
377  std::vector<FVInterfaceKernel *> iks;
379  .query()
380  .template condition<AttribSystem>("FVInterfaceKernel")
381  .template condition<AttribThread>(tid)
382  .queryInto(iks);
383 
384  std::vector<FVFluxKernel *> kernels;
386  .query()
387  .template condition<AttribSystem>("FVFluxKernel")
388  .template condition<AttribThread>(tid)
389  .queryInto(kernels);
390 
391  for (auto * bc : bcs)
392  bc->customSetup(exec_type);
393  for (auto * ik : iks)
394  ik->customSetup(exec_type);
395  for (auto * kernel : kernels)
396  kernel->customSetup(exec_type);
397  }
398  }
399  _scalar_kernels.customSetup(exec_type);
400  _constraints.customSetup(exec_type);
401  _general_dampers.customSetup(exec_type);
402  _nodal_bcs.customSetup(exec_type);
403 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
std::vector< T * > & queryInto(std::vector< T *> &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
Definition: TheWarehouse.h:311
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
virtual void customSetup(const ExecFlagType &exec_type, THREAD_ID tid=0) const
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
bool _doing_dg
true if DG is active (optimization reasons)
TheWarehouse & theWarehouse() const
MooseObjectTagWarehouse< KernelBase > _kernels
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
virtual void customSetup(const ExecFlagType &exec_type)
Definition: SystemBase.C:1521
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
unsigned int THREAD_ID
Definition: MooseTypes.h:198

◆ deactiveAllMatrixTags()

void SystemBase::deactiveAllMatrixTags ( )
virtualinherited

Make matrices inactive.

Definition at line 1099 of file SystemBase.C.

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

1100 {
1101  auto num_matrix_tags = _subproblem.numMatrixTags();
1102 
1103  _matrix_tag_active_flags.resize(num_matrix_tags);
1104 
1105  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
1106  _matrix_tag_active_flags[tag] = false;
1107 }
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:985
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:220

◆ deactiveMatrixTag()

void SystemBase::deactiveMatrixTag ( TagID  tag)
virtualinherited

deactive a matrix for tag

Definition at line 1087 of file SystemBase.C.

1088 {
1089  mooseAssert(_subproblem.matrixTagExists(tag),
1090  "Cannot deactivate Matrix with matrix_tag : " << tag << "that does not exist");
1091 
1092  if (_matrix_tag_active_flags.size() < tag + 1)
1093  _matrix_tag_active_flags.resize(tag + 1);
1094 
1095  _matrix_tag_active_flags[tag] = false;
1096 }
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:985
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:306

◆ debuggingResiduals()

void NonlinearSystemBase::debuggingResiduals ( bool  state)
inlineinherited

Definition at line 517 of file NonlinearSystemBase.h.

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

◆ defaultMatrixTags()

std::set< TagID > NonlinearEigenSystem::defaultMatrixTags ( ) const
overridevirtual

Get the default matrix tags associted with this system.

Reimplemented from SystemBase.

Definition at line 482 of file NonlinearEigenSystem.C.

483 {
485  tags.insert(eigenMatrixTag());
486  tags.insert(nonEigenMatrixTag());
487  return tags;
488 }
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
Definition: SystemBase.h:297
TagID eigenMatrixTag() const
Matrix tag ID of right hand side.
TagID nonEigenMatrixTag() const
Matrix tag ID of left hand side.

◆ defaultVectorTags()

std::set< TagID > NonlinearEigenSystem::defaultVectorTags ( ) const
overridevirtual

Get the default vector tags associated with this system.

Reimplemented from SystemBase.

Definition at line 473 of file NonlinearEigenSystem.C.

474 {
476  tags.insert(eigenVectorTag());
477  tags.insert(nonEigenVectorTag());
478  return tags;
479 }
TagID nonEigenVectorTag() const
Vector tag ID of left hand side.
TagID eigenVectorTag() const
Vector tag ID of right hand side.
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
Definition: SystemBase.h:290

◆ disassociateDefaultMatrixTags()

void SystemBase::disassociateDefaultMatrixTags ( )
virtualinherited

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

Reimplemented in DisplacedSystem.

Definition at line 1066 of file SystemBase.C.

Referenced by DisplacedSystem::disassociateDefaultMatrixTags().

1067 {
1068  const auto tags = defaultMatrixTags();
1069  for (const auto tag : tags)
1070  if (_subproblem.matrixTagExists(tag))
1072 }
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
Definition: SystemBase.h:297
virtual void disassociateMatrixFromTag(SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
Definition: SystemBase.C:1044
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:306

◆ disassociateDefaultVectorTags()

void SystemBase::disassociateDefaultVectorTags ( )
virtualinherited

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

Reimplemented in DisplacedSystem.

Definition at line 971 of file SystemBase.C.

Referenced by DisplacedSystem::disassociateDefaultVectorTags().

972 {
973  const auto tags = defaultVectorTags();
974  for (const auto tag : tags)
975  if (_subproblem.vectorTagExists(tag))
977 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
Definition: SystemBase.C:949
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:173
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
Definition: SystemBase.h:290

◆ disassociateMatrixFromTag() [1/2]

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

Disassociate a matrix from a tag.

Reimplemented in DisplacedSystem.

Definition at line 1044 of file SystemBase.C.

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

1045 {
1046  if (!_subproblem.matrixTagExists(tag))
1047  mooseError("Cannot disassociate matrix from tag ", tag, " because that tag does not exist");
1048  if (hasMatrix(tag) && &getMatrix(tag) != &matrix)
1049  mooseError("You can not disassociate a matrix from a tag which it was not associated to");
1050 
1052 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual void disassociateMatrixFromTag(SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
Definition: SystemBase.C:1044
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:980
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:306

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

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

◆ disassociateVectorFromTag() [1/2]

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

Disassociate a given vector from a given tag.

Reimplemented in DisplacedSystem.

Definition at line 949 of file SystemBase.C.

Referenced by FEProblemBase::computeLinearSystemTags(), NonlinearSystemBase::computeNodalBCs(), FEProblemBase::computeResidualAndJacobian(), FEProblemBase::computeResidualInternal(), NonlinearSystemBase::computeResidualTag(), FEProblemBase::computeResidualTag(), FEProblemBase::computeResidualType(), SystemBase::disassociateDefaultVectorTags(), DisplacedSystem::disassociateVectorFromTag(), and CentralDifference::initialSetup().

950 {
951  if (!_subproblem.vectorTagExists(tag))
952  mooseError("Cannot disassociate vector from tag ", tag, " because that tag does not exist");
953  if (hasVector(tag) && &getVector(tag) != &vec)
954  mooseError("You can not disassociate a vector from a tag which it was not associated to");
955 
957 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
Definition: SystemBase.C:949
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:173
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

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

961 {
962  if (!_subproblem.vectorTagExists(tag))
963  mooseError("Cannot disassociate vector from tag ", tag, " because that tag does not exist");
964 
965  if (_tagged_vectors.size() < tag + 1)
966  _tagged_vectors.resize(tag + 1);
967  _tagged_vectors[tag] = nullptr;
968 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:173
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:981

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

1145 {
1146  return system().get_dof_map();
1147 }
virtual System & system()=0
Get the reference to the libMesh system.

◆ doingDG()

bool NonlinearSystemBase::doingDG ( ) const
inherited

Getter for _doing_dg.

Definition at line 3633 of file NonlinearSystemBase.C.

3634 {
3635  return _doing_dg;
3636 }
bool _doing_dg
true if DG is active (optimization reasons)

◆ duDotDotDu() [1/2]

virtual Number& SystemBase::duDotDotDu ( )
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 235 of file SystemBase.h.

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

235 { return _du_dotdot_du; }
Real _du_dotdot_du
Definition: SystemBase.h:978

◆ duDotDotDu() [2/2]

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

Reimplemented in DisplacedSystem.

Definition at line 237 of file SystemBase.h.

237 { return _du_dotdot_du; }
Real _du_dotdot_du
Definition: SystemBase.h:978

◆ duDotDu() [1/2]

virtual Number& SystemBase::duDotDu ( )
inlinevirtualinherited

Reimplemented in DisplacedSystem.

Definition at line 234 of file SystemBase.h.

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

234 { return _du_dot_du; }
Real _du_dot_du
Definition: SystemBase.h:977

◆ duDotDu() [2/2]

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

Reimplemented in DisplacedSystem.

Definition at line 236 of file SystemBase.h.

236 { return _du_dot_du; }
Real _du_dot_du
Definition: SystemBase.h:977

◆ eigenMatrixTag()

TagID NonlinearEigenSystem::eigenMatrixTag ( ) const
inline

◆ eigenVectorTag()

TagID NonlinearEigenSystem::eigenVectorTag ( ) const
inline

◆ enforceNodalConstraintsJacobian()

void NonlinearSystemBase::enforceNodalConstraintsJacobian ( )
protectedinherited

Definition at line 1025 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

1026 {
1027  if (!hasMatrix(systemMatrixTag()))
1028  mooseError(" A system matrix is required");
1029 
1030  auto & jacobian = getMatrix(systemMatrixTag());
1031  THREAD_ID tid = 0; // constraints are going to be done single-threaded
1032 
1034  {
1035  const auto & ncs = _constraints.getActiveNodalConstraints();
1036  for (const auto & nc : ncs)
1037  {
1038  std::vector<dof_id_type> & secondary_node_ids = nc->getSecondaryNodeId();
1039  std::vector<dof_id_type> & primary_node_ids = nc->getPrimaryNodeId();
1040 
1041  if ((secondary_node_ids.size() > 0) && (primary_node_ids.size() > 0))
1042  {
1043  _fe_problem.reinitNodes(primary_node_ids, tid);
1044  _fe_problem.reinitNodesNeighbor(secondary_node_ids, tid);
1045  nc->computeJacobian(jacobian);
1046  }
1047  }
1049  jacobian.close();
1050  }
1051 }
TagID systemMatrixTag() const override
Return the Matrix Tag ID for System.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
const std::vector< std::shared_ptr< NodalConstraint > > & getActiveNodalConstraints() const
Access methods for active objects.
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
bool hasActiveNodalConstraints() const
Deterimine if active objects exist.
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:980
unsigned int THREAD_ID
Definition: MooseTypes.h:198
virtual void addCachedJacobian(const THREAD_ID tid) override

◆ enforceNodalConstraintsResidual()

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

Enforce nodal constraints.

Definition at line 1000 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualInternal().

1001 {
1002  THREAD_ID tid = 0; // constraints are going to be done single-threaded
1003  residual.close();
1005  {
1006  const auto & ncs = _constraints.getActiveNodalConstraints();
1007  for (const auto & nc : ncs)
1008  {
1009  std::vector<dof_id_type> & secondary_node_ids = nc->getSecondaryNodeId();
1010  std::vector<dof_id_type> & primary_node_ids = nc->getPrimaryNodeId();
1011 
1012  if ((secondary_node_ids.size() > 0) && (primary_node_ids.size() > 0))
1013  {
1014  _fe_problem.reinitNodes(primary_node_ids, tid);
1015  _fe_problem.reinitNodesNeighbor(secondary_node_ids, tid);
1016  nc->computeResidual(residual);
1017  }
1018  }
1019  _fe_problem.addCachedResidualDirectly(residual, tid);
1020  residual.close();
1021  }
1022 }
const std::vector< std::shared_ptr< NodalConstraint > > & getActiveNodalConstraints() const
Access methods for active objects.
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
bool hasActiveNodalConstraints() const
Deterimine if active objects exist.
virtual void addCachedResidualDirectly(NumericVector< Number > &residual, const THREAD_ID tid)
Allows for all the residual contributions that are currently cached to be added directly into the vec...
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
virtual void close()=0
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
unsigned int THREAD_ID
Definition: MooseTypes.h:198

◆ feProblem() [1/2]

FEProblemBase& SystemBase::feProblem ( )
inlineinherited

Definition at line 104 of file SystemBase.h.

Referenced by DMMooseGetEmbedding_Private(), DMSetFromOptions_Moose(), and DMSetUp_Moose_Pre().

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

◆ feProblem() [2/2]

const FEProblemBase& SystemBase::feProblem ( ) const
inlineinherited

Definition at line 105 of file SystemBase.h.

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

◆ finalNonlinearResidual()

Real NonlinearSystemBase::finalNonlinearResidual ( ) const
inlineinherited

Return the final nonlinear residual.

Definition at line 503 of file NonlinearSystemBase.h.

503 { return _final_residual; }

◆ flushTaggedMatrices()

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

flushes all matrices associated to tags.

Flush assembles the matrix but doesn't shrink memory allocation

Definition at line 1024 of file SystemBase.C.

1025 {
1026  for (auto tag : tags)
1027  if (hasMatrix(tag))
1028  getMatrix(tag).flush();
1029 }
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
virtual void flush()
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:980

◆ getActualFieldVariable() [1/2]

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

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

Definition at line 114 of file SystemBase.C.

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

115 {
116  return *_vars[tid].getActualFieldVariable<T>(var_name);
117 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

◆ getActualFieldVariable() [2/2]

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

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

Definition at line 135 of file SystemBase.C.

136 {
137  return *_vars[tid].getActualFieldVariable<T>(var_number);
138 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

◆ getAllConvergedEigenvalues()

const std::vector<std::pair<Real, Real> >& NonlinearEigenSystem::getAllConvergedEigenvalues ( ) const
inline

Get the number of converged eigenvalues.

Returns
all converged eigenvalues as complex numbers

Definition at line 123 of file NonlinearEigenSystem.h.

Referenced by Eigenvalues::execute().

124  {
125  return _eigen_values;
126  }
std::vector< std::pair< Real, Real > > _eigen_values

◆ getConstraintWarehouse()

const ConstraintWarehouse& NonlinearSystemBase::getConstraintWarehouse ( ) const
inlineinherited

Definition at line 567 of file NonlinearSystemBase.h.

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

◆ getConvergedEigenpair()

std::pair< Real, Real > NonlinearEigenSystem::getConvergedEigenpair ( dof_id_type  n) const

Return the Nth converged eigenvalue and copies the respective eigen vector to the solution vector.

Returns
The Nth converged eigenvalue as a complex number, i.e. the first and the second number is the real and the imaginary part of the eigenvalue, respectively.

Definition at line 419 of file NonlinearEigenSystem.C.

Referenced by solve().

420 {
421  unsigned int n_converged_eigenvalues = getNumConvergedEigenvalues();
422 
423  if (n >= n_converged_eigenvalues)
424  mooseError(n, " not in [0, ", n_converged_eigenvalues, ")");
425 
426  return _eigen_sys.get_eigenpair(n);
427 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
unsigned int getNumConvergedEigenvalues() const
Get the number of converged eigenvalues.

◆ getConvergedEigenvalue()

std::pair< Real, Real > NonlinearEigenSystem::getConvergedEigenvalue ( dof_id_type  n) const

Return the Nth converged eigenvalue.

Returns
The Nth converged eigenvalue as a complex number, i.e. the first and the second number is the real and the imaginary part of the eigenvalue, respectively.

Definition at line 410 of file NonlinearEigenSystem.C.

Referenced by solve().

411 {
412  unsigned int n_converged_eigenvalues = getNumConvergedEigenvalues();
413  if (n >= n_converged_eigenvalues)
414  mooseError(n, " not in [0, ", n_converged_eigenvalues, ")");
415  return _eigen_sys.get_eigenvalue(n);
416 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
unsigned int getNumConvergedEigenvalues() const
Get the number of converged eigenvalues.

◆ getCurrentNonlinearIterationNumber()

unsigned int NonlinearEigenSystem::getCurrentNonlinearIterationNumber ( )
overridevirtual

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 313 of file NonlinearEigenSystem.C.

314 {
315  mooseError("did not implement yet \n");
316  return 0;
317 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299

◆ getDGKernelWarehouse()

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

Definition at line 552 of file NonlinearSystemBase.h.

552 { return _dg_kernels; }
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels

◆ getDiracKernelWarehouse()

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

Definition at line 557 of file NonlinearSystemBase.h.

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

◆ getElementDamperWarehouse()

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

Definition at line 559 of file NonlinearSystemBase.h.

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

560  {
561  return _element_dampers;
562  }
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.

◆ getEPS()

EPS NonlinearEigenSystem::getEPS ( )
virtual

Retrieve EPS (SLEPc eigen solver)

Definition at line 360 of file NonlinearEigenSystem.C.

Referenced by getSNES(), Moose::SlepcSupport::mooseSlepcEigenFormFunctionA(), Moose::SlepcSupport::mooseSlepcEigenFormFunctionAB(), Moose::SlepcSupport::mooseSlepcEigenFormFunctionB(), and Moose::SlepcSupport::mooseSlepcEigenFormJacobianA().

361 {
362  SlepcEigenSolver<Number> * solver =
363  cast_ptr<SlepcEigenSolver<Number> *>(&(*_eigen_sys.eigen_solver));
364 
365  if (!solver)
366  mooseError("Unable to retrieve eigen solver");
367 
368  return solver->eps();
369 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299

◆ getFieldVariable() [1/2]

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

Gets a reference to a variable of with specified name.

This excludes and cannot return finite volume variables.

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

Definition at line 107 of file SystemBase.C.

Referenced by Marker::getMarkerValue().

108 {
109  return *_vars[tid].getFieldVariable<T>(var_name);
110 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

◆ getFieldVariable() [2/2]

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

Gets a reference to a variable with specified number.

This excludes and cannot return finite volume variables.

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

Definition at line 128 of file SystemBase.C.

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

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

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

◆ getIntegratedBCWarehouse() [1/2]

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

Definition at line 558 of file NonlinearSystemBase.h.

Referenced by BoundaryElemIntegrityCheckThread::operator()().

558 { return _integrated_bcs; }
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs

◆ getIntegratedBCWarehouse() [2/2]

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

Return the IntegratedBCBase warehouse.

Definition at line 577 of file NonlinearSystemBase.h.

578  {
579  return _integrated_bcs;
580  }
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs

◆ getInterfaceKernelWarehouse()

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

Definition at line 553 of file NonlinearSystemBase.h.

554  {
555  return _interface_kernels;
556  }
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels

◆ getKernelWarehouse()

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

Access functions to Warehouses from outside NonlinearSystemBase.

Definition at line 551 of file NonlinearSystemBase.h.

Referenced by DOFMapOutput::output().

551 { return _kernels; }
MooseObjectTagWarehouse< KernelBase > _kernels

◆ getMatrix() [1/2]

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

Get a raw SparseMatrix.

Reimplemented in DisplacedSystem.

Definition at line 980 of file SystemBase.C.

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

981 {
982  if (!hasMatrix(tag))
983  {
984  if (!_subproblem.matrixTagExists(tag))
985  mooseError("Cannot retreive matrix with tag ", tag, " because that tag does not exist");
986  else
987  mooseError("Cannot retreive matrix with tag ",
988  tag,
989  " in system '",
990  name(),
991  "'\nbecause a matrix has not been associated with that tag.");
992  }
993 
994  return *_tagged_matrices[tag];
995 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:983
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
virtual const std::string & name() const
Definition: SystemBase.C:1304
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:306

◆ getMatrix() [2/2]

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

Get a raw SparseMatrix.

Reimplemented in DisplacedSystem.

Definition at line 998 of file SystemBase.C.

999 {
1000  if (!hasMatrix(tag))
1001  {
1002  if (!_subproblem.matrixTagExists(tag))
1003  mooseError("Cannot retreive matrix with tag ", tag, " because that tag does not exist");
1004  else
1005  mooseError("Cannot retreive matrix with tag ",
1006  tag,
1007  " in system '",
1008  name(),
1009  "'\nbecause a matrix has not been associated with that tag.");
1010  }
1011 
1012  return *_tagged_matrices[tag];
1013 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:983
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
virtual const std::string & name() const
Definition: SystemBase.C:1304
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:306

◆ getMaxVariableNumber()

unsigned int SystemBase::getMaxVariableNumber ( ) const
inlineinherited

Returns the maximum number of all variables on the system.

Definition at line 860 of file SystemBase.h.

860 { return _max_var_number; }
unsigned int _max_var_number
Maximum variable number.
Definition: SystemBase.h:962

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

Referenced by Moose::globalDofIndexToDerivative().

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

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

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

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

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

◆ getMooseKSPNormType()

Moose::MooseKSPNormType SolverSystem::getMooseKSPNormType ( )
inlineinherited

Get the norm in which the linear convergence is measured.

Definition at line 67 of file SolverSystem.h.

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

67 { return _ksp_norm; }
Moose::MooseKSPNormType _ksp_norm
KSP norm type.
Definition: SolverSystem.h:82

◆ getNodalBCWarehouse()

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

Return the NodalBCBase warehouse.

Definition at line 572 of file NonlinearSystemBase.h.

572 { return _nodal_bcs; }
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs

◆ getNodalDamperWarehouse()

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

Definition at line 563 of file NonlinearSystemBase.h.

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

564  {
565  return _nodal_dampers;
566  }
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.

◆ getNodeDofs()

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

Definition at line 2051 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::findImplicitGeometricCouplingEntries().

2052 {
2053  const Node & node = _mesh.nodeRef(node_id);
2054  unsigned int s = number();
2055  if (node.has_dofs(s))
2056  {
2057  for (unsigned int v = 0; v < nVariables(); v++)
2058  for (unsigned int c = 0; c < node.n_comp(s, v); c++)
2059  dofs.push_back(node.dof_number(s, v, c));
2060  }
2061 }
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:637
virtual unsigned int nVariables() const
Get the number of variables in this system.
Definition: SystemBase.C:847
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1132
MooseMesh & _mesh
Definition: SystemBase.h:953

◆ getNumConvergedEigenvalues()

unsigned int NonlinearEigenSystem::getNumConvergedEigenvalues ( ) const
inline

Get the number of converged eigenvalues.

Returns
The number of converged eigenvalues

Definition at line 75 of file NonlinearEigenSystem.h.

Referenced by getConvergedEigenpair(), getConvergedEigenvalue(), and solve().

75 { return _eigen_sys.get_n_converged(); };

◆ getPCSide()

Moose::PCSideType SolverSystem::getPCSide ( )
inlineinherited

Get the current preconditioner side.

Definition at line 56 of file SolverSystem.h.

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

56 { return _pc_side; }
Moose::PCSideType _pc_side
Preconditioning side.
Definition: SolverSystem.h:80

◆ getPreconditioner()

MoosePreconditioner const * NonlinearSystemBase::getPreconditioner ( ) const
inherited

Definition at line 3432 of file NonlinearSystemBase.C.

Referenced by ConsoleUtils::outputExecutionInformation().

3433 {
3434  return _preconditioner.get();
3435 }
std::shared_ptr< MoosePreconditioner > _preconditioner
Preconditioner.

◆ getPredictor()

Predictor* NonlinearSystemBase::getPredictor ( )
inlineinherited

Definition at line 522 of file NonlinearSystemBase.h.

Referenced by AB2PredictorCorrector::estimateTimeError().

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

◆ getResidualNonTimeVector()

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

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

Definition at line 944 of file NonlinearSystemBase.C.

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

945 {
946  if (!_Re_non_time)
947  {
949 
950  // Most applications don't need the expense of ghosting
952  _Re_non_time = &addVector(_Re_non_time_tag, false, ptype);
953  }
955  {
956  const auto vector_name = _subproblem.vectorTagName(_Re_non_time_tag);
957 
958  // If an application changes its mind, the libMesh API lets us
959  // change the vector.
960  _Re_non_time = &system().add_vector(vector_name, false, GHOSTED);
961  }
962 
963  return *_Re_non_time;
964 }
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
PARALLEL
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type)
Adds a solution length vector to the system.
Definition: SystemBase.C:604
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition: SubProblem.C:82
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
TagID _Re_non_time_tag
Tag for non-time contribution residual.
GHOSTED
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
ParallelType type() const
virtual System & system() override
Get the reference to the libMesh system.
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:199
ParallelType

◆ getResidualTimeVector()

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

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

Definition at line 921 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::residualVector().

922 {
923  if (!_Re_time)
924  {
926 
927  // Most applications don't need the expense of ghosting
929  _Re_time = &addVector(_Re_time_tag, false, ptype);
930  }
931  else if (_need_residual_ghosted && _Re_time->type() == PARALLEL)
932  {
933  const auto vector_name = _subproblem.vectorTagName(_Re_time_tag);
934 
935  // If an application changes its mind, the libMesh API lets us
936  // change the vector.
937  _Re_time = &system().add_vector(vector_name, false, GHOSTED);
938  }
939 
940  return *_Re_time;
941 }
NumericVector< Number > * _Re_time
residual vector for time contributions
TagID _Re_time_tag
Tag for time contribution residual.
PARALLEL
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type)
Adds a solution length vector to the system.
Definition: SystemBase.C:604
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition: SubProblem.C:82
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
GHOSTED
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
ParallelType type() const
virtual System & system() override
Get the reference to the libMesh system.
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:199
ParallelType

◆ getScalarVariable() [1/2]

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

Gets a reference to a scalar variable with specified number.

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

Definition at line 141 of file SystemBase.C.

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

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

◆ getScalarVariable() [2/2]

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

Gets a reference to a variable with specified number.

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

Definition at line 150 of file SystemBase.C.

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

◆ getScalarVariables()

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

◆ getSharedTimeIntegrator()

std::shared_ptr<TimeIntegrator> SystemBase::getSharedTimeIntegrator ( )
inlineinherited

Definition at line 882 of file SystemBase.h.

Referenced by DisplacedProblem::DisplacedProblem().

882 { return _time_integrator; }
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:1007

◆ getSNES()

SNES NonlinearEigenSystem::getSNES ( )
overridevirtual

Retrieve snes from slepc eigen solver.

It is valid for only nonlinear eigen solver. You should see a big error if you do this for linear solver.

Implements NonlinearSystemBase.

Definition at line 345 of file NonlinearEigenSystem.C.

Referenced by Moose::SlepcSupport::mooseEPSFormMatrices(), and Moose::SlepcSupport::mooseSlepcEigenFormFunctionMFFD().

346 {
347  EPS eps = getEPS();
348 
350  {
351  SNES snes = nullptr;
353  return snes;
354  }
355  else
356  mooseError("There is no SNES in linear eigen solver");
357 }
int eps(unsigned int i, unsigned int j)
2D version
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
bool isNonlinearEigenvalueSolver() const
Definition: EigenProblem.C:636
virtual EPS getEPS()
Retrieve EPS (SLEPc eigen solver)
PetscErrorCode mooseSlepcEPSGetSNES(EPS eps, SNES *snes)
Retrieve SNES from EPS.

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

Referenced by Split::setup(), and NonlinearSystemBase::setupFieldDecomposition().

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

◆ getStandardFieldVariableNames()

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

◆ getSubdomainsForVar() [1/2]

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

Definition at line 752 of file SystemBase.h.

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

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

◆ getSubdomainsForVar() [2/2]

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

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

764  {
765  return getSubdomainsForVar(getVariable(0, var_name).number());
766  }
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1132
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
Definition: SystemBase.h:752
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:86

◆ getTimeIntegrator() [1/2]

TimeIntegrator* SystemBase::getTimeIntegrator ( )
inlineinherited

◆ getTimeIntegrator() [2/2]

const TimeIntegrator* SystemBase::getTimeIntegrator ( ) const
inlineinherited

Definition at line 880 of file SystemBase.h.

880 { return _time_integrator.get(); }
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:1007

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

Referenced by AdaptivityAction::act(), Assembly::addJacobianBlock(), Assembly::addJacobianBlockNonlocal(), FEProblemBase::addJacobianBlockTags(), Assembly::addJacobianNeighbor(), NonlocalKernel::computeNonlocalOffDiagJacobian(), NonlocalIntegratedBC::computeNonlocalOffDiagJacobian(), Assembly::copyFaceShapes(), Assembly::copyNeighborShapes(), Assembly::copyShapes(), SystemBase::copyVars(), DMMooseSetVariables(), FieldSplitPreconditioner::FieldSplitPreconditioner(), FiniteDifferencePreconditioner::FiniteDifferencePreconditioner(), NodeElemConstraint::getConnectedDofIndices(), NodeFaceConstraint::getConnectedDofIndices(), SystemBase::getSubdomainsForVar(), ResidualObject::getVariable(), SubProblem::getVariableHelper(), Assembly::init(), NodalNormalsPreprocessor::initialize(), ReferenceResidualProblem::initialSetup(), LinearSystem::initialSetup(), Assembly::initNonlocalCoupling(), PNGOutput::makeMeshFunc(), FEProblemBase::prepare(), Assembly::prepareBlock(), Assembly::prepareBlockNonlocal(), AddPeriodicBCAction::setPeriodicVars(), NonlinearSystemBase::setupScalingData(), UpdateErrorVectorsThread::UpdateErrorVectorsThread(), and VariableCondensationPreconditioner::VariableCondensationPreconditioner().

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

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

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

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

Referenced by PhysicsBasedPreconditioner::addSystem().

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

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

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

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

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

890 {
891  return system().get_vector(name);
892 }
virtual const std::string & name() const
Definition: SystemBase.C:1304
virtual System & system()=0
Get the reference to the libMesh system.

◆ getVector() [2/4]

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

Reimplemented in DisplacedSystem.

Definition at line 895 of file SystemBase.C.

896 {
897  return system().get_vector(name);
898 }
virtual const std::string & name() const
Definition: SystemBase.C:1304
virtual System & system()=0
Get the reference to the libMesh system.

◆ getVector() [3/4]

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

Get a raw NumericVector by tag.

Reimplemented in DisplacedSystem.

Definition at line 901 of file SystemBase.C.

902 {
903  if (!hasVector(tag))
904  {
905  if (!_subproblem.vectorTagExists(tag))
906  mooseError("Cannot retreive vector with tag ", tag, " because that tag does not exist");
907  else
908  mooseError("Cannot retreive vector with tag ",
909  tag,
910  " in system '",
911  name(),
912  "'\nbecause a vector has not been associated with that tag.");
913  }
914 
915  return *_tagged_vectors[tag];
916 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
virtual const std::string & name() const
Definition: SystemBase.C:1304
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:173
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:981

◆ getVector() [4/4]

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

Reimplemented in DisplacedSystem.

Definition at line 919 of file SystemBase.C.

920 {
921  if (!hasVector(tag))
922  {
923  if (!_subproblem.vectorTagExists(tag))
924  mooseError("Cannot retreive vector with tag ", tag, " because that tag does not exist");
925  else
926  mooseError("Cannot retreive vector with tag ",
927  tag,
928  " in system '",
929  name(),
930  "'\nbecause a vector has not been associated with that tag.");
931  }
932 
933  return *_tagged_vectors[tag];
934 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
virtual const std::string & name() const
Definition: SystemBase.C:1304
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:173
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:981

◆ gradientContainer()

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

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

Mainly used for finite volume systems.

Definition at line 932 of file SystemBase.h.

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

◆ hasDiagSaveIn()

bool NonlinearSystemBase::hasDiagSaveIn ( ) const
inlineinherited

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

Definition at line 592 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeJacobianInternal().

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

◆ hasMatrix()

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

Check if the tagged matrix exists in the system.

Reimplemented in DisplacedSystem.

Definition at line 338 of file SystemBase.h.

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

339  {
340  return tag < _tagged_matrices.size() && _tagged_matrices[tag];
341  }
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:983

◆ hasSaveIn()

bool NonlinearSystemBase::hasSaveIn ( ) const
inlineinherited

Weather or not the nonlinear system has save-ins.

Definition at line 587 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeResidualTags().

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

◆ hasScalarVariable()

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

Definition at line 832 of file SystemBase.C.

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

833 {
834  if (system().has_variable(var_name))
835  return system().variable_type(var_name).family == SCALAR;
836  else
837  return false;
838 }
SCALAR
virtual System & system()=0
Get the reference to the libMesh system.

◆ hasSolutionState()

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

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

Reimplemented in DisplacedSystem.

Definition at line 1047 of file SystemBase.h.

Referenced by PointwiseRenormalizeVector::execute(), PointwiseRenormalizeVector::finalize(), DisplacedSystem::hasSolutionState(), SystemBase::needSolutionState(), SystemBase::restoreSolutions(), ElementSubdomainModifier::setOldAndOlderSolutionsForMovedNodes(), and SystemBase::solutionState().

1049 {
1050  return _solution_states[static_cast<unsigned short>(iteration_type)].size() > state;
1051 }
std::array< std::vector< NumericVector< Number > * >, 2 > _solution_states
The solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1041

◆ hasVarCopy()

bool SystemBase::hasVarCopy ( ) const
inlineinherited

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

Definition at line 885 of file SystemBase.h.

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

◆ hasVariable()

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

Query a system for a variable.

Parameters
var_namename of the variable
Returns
true if the variable exists

Definition at line 807 of file SystemBase.C.

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

808 {
809  auto & names = getVariableNames();
810  if (system().has_variable(var_name))
811  return system().variable_type(var_name).family != SCALAR;
812  if (std::find(names.begin(), names.end(), var_name) != names.end())
813  // array variable
814  return true;
815  else
816  return false;
817 }
SCALAR
virtual System & system()=0
Get the reference to the libMesh system.
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:853

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

260  {
261  return tag_id < _tagged_vectors.size() && _tagged_vectors[tag_id];
262  }
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:981

◆ haveFieldSplitPreconditioner()

bool NonlinearSystemBase::haveFieldSplitPreconditioner ( ) const
inlineinherited

Definition at line 108 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::setupDM().

bool _use_field_split_preconditioner
Whether or not to use a FieldSplitPreconditioner matrix based on the decomposition.

◆ haveFiniteDifferencedPreconditioner()

bool NonlinearSystemBase::haveFiniteDifferencedPreconditioner ( ) const
inlineinherited

Definition at line 104 of file NonlinearSystemBase.h.

105  {
107  }
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 635 of file NonlinearSystemBase.h.

Referenced by FEProblemSolve::FEProblemSolve().

636  {
637  _ignore_variables_for_autoscaling = ignore_variables_for_autoscaling;
638  }
std::vector< std::string > _ignore_variables_for_autoscaling
A container for variables that do not partipate in autoscaling.

◆ init()

void NonlinearSystemBase::init ( )
overridevirtualinherited

Initialize the system.

Reimplemented from SolverSystem.

Reimplemented in NonlinearSystem.

Definition at line 178 of file NonlinearSystemBase.C.

Referenced by NonlinearSystem::init().

179 {
181 
182  if (_fe_problem.hasDampers())
183  setupDampers();
184 
185  if (_residual_copy.get())
186  _residual_copy->init(_sys.n_dofs(), false, SERIAL);
187 }
void setupDampers()
Setup damping stuff (called before we actually start)
bool hasDampers()
Whether or not this system has dampers.
SERIAL
virtual void init() override
Initialize the system.
Definition: SolverSystem.C:29
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
std::unique_ptr< NumericVector< Number > > _residual_copy
Copy of the residual vector, or nullptr if a copy is not needed.

◆ initializeObjects()

virtual void SystemBase::initializeObjects ( )
inlinevirtualinherited

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

Definition at line 161 of file SystemBase.h.

161 {};

◆ initialSetup()

void NonlinearSystemBase::initialSetup ( )
overridevirtualinherited

Setup Functions.

Reimplemented from SystemBase.

Definition at line 197 of file NonlinearSystemBase.C.

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

◆ initSolutionState()

void SystemBase::initSolutionState ( )
virtualinherited

Initializes the solution state.

Reimplemented in DisplacedSystem.

Definition at line 1328 of file SystemBase.C.

Referenced by DisplacedSystem::initSolutionState().

1329 {
1330  // Default is the current solution
1331  unsigned int state = 0;
1332 
1333  // Add additional states as required by the variable states requested
1334  for (const auto & var : getVariables(/* tid = */ 0))
1335  state = std::max(state, var->oldestSolutionStateRequested());
1336  for (const auto & var : getScalarVariables(/* tid = */ 0))
1337  state = std::max(state, var->oldestSolutionStateRequested());
1338 
1340 
1342 }
virtual void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Registers that the solution state state is needed.
Definition: SystemBase.C:1400
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
Definition: SystemBase.h:742
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
Definition: SystemBase.h:747
bool _solution_states_initialized
Whether or not the solution states have been initialized.
Definition: SystemBase.h:1019
auto max(const L &left, const R &right)

◆ isArrayVariable()

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

If a variable is an array variable.

Definition at line 820 of file SystemBase.C.

821 {
822  auto & names = getVariableNames();
823  if (!system().has_variable(var_name) &&
824  std::find(names.begin(), names.end(), var_name) != names.end())
825  // array variable
826  return true;
827  else
828  return false;
829 }
virtual System & system()=0
Get the reference to the libMesh system.
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:853

◆ isScalarVariable()

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

Definition at line 841 of file SystemBase.C.

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

842 {
843  return (system().variable(var_num).type().family == SCALAR);
844 }
virtual System & system()=0
Get the reference to the libMesh system.

◆ jacobianSetup()

void NonlinearSystemBase::jacobianSetup ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 2653 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

2654 {
2656 
2657  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
2658  {
2659  _kernels.jacobianSetup(tid);
2662  if (_doing_dg)
2668  }
2673 
2674  // Avoid recursion
2675  if (this == &_fe_problem.currentNonlinearSystem())
2678 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
virtual void jacobianSetup()
Definition: SystemBase.C:1542
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
bool _doing_dg
true if DG is active (optimization reasons)
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:138
NonlinearSystemBase & currentNonlinearSystem()
MooseObjectTagWarehouse< KernelBase > _kernels
virtual void jacobianSetup(THREAD_ID tid=0) const
ConstraintWarehouse _constraints
Constraints storage object.
MooseApp & _app
Definition: SystemBase.h:950
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
void resetSolutionInvalidCurrentIteration()
Reset the number of solution invalid occurrences back to zero.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
void jacobianSetup() override
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
unsigned int THREAD_ID
Definition: MooseTypes.h:198

◆ matrixTagActive()

bool SystemBase::matrixTagActive ( TagID  tag) const
virtualinherited

If or not a matrix tag is active.

Definition at line 1124 of file SystemBase.C.

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

◆ 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; }
MooseMesh & _mesh
Definition: SystemBase.h:953

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

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

3649 {
3650  parallel_object_only();
3651 
3652  try
3653  {
3654  for (auto & map_pr : _undisplaced_mortar_functors)
3655  map_pr.second(compute_type, vector_tags, matrix_tags);
3656 
3657  for (auto & map_pr : _displaced_mortar_functors)
3658  map_pr.second(compute_type, vector_tags, matrix_tags);
3659  }
3660  catch (MetaPhysicL::LogicError &)
3661  {
3662  mooseError(
3663  "We caught a MetaPhysicL error in NonlinearSystemBase::mortarConstraints. This is very "
3664  "likely due to AD not having a sufficiently large derivative container size. Please run "
3665  "MOOSE configure with the '--with-derivative-size=<n>' option");
3666  }
3667 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _undisplaced_mortar_functors
Functors for computing undisplaced mortar constraints.
std::unordered_map< std::pair< BoundaryID, BoundaryID >, ComputeMortarFunctor > _displaced_mortar_functors
Functors for computing displaced mortar constraints.

◆ name()

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

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

3615 {
3616  return _integrated_bcs.hasActiveBoundaryObjects(bnd_id, tid);
3617 }
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs

◆ needInterfaceMaterialOnSide()

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

Indicated whether this system needs material properties on interfaces.

Returns
Boolean if IntegratedBCs are active

Definition at line 3620 of file NonlinearSystemBase.C.

3621 {
3622  return _interface_kernels.hasActiveBoundaryObjects(bnd_id, tid);
3623 }
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels

◆ needSolutionState()

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

Registers that the solution state state is needed.

Reimplemented in DisplacedSystem.

Definition at line 1400 of file SystemBase.C.

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

1402 {
1403  libmesh_parallel_only(this->comm());
1404 
1405  if (hasSolutionState(state, iteration_type))
1406  return;
1407 
1408  auto & solution_states = _solution_states[static_cast<unsigned short>(iteration_type)];
1409  solution_states.resize(state + 1);
1410 
1411  // The 0-th (current) solution state is owned by libMesh
1412  if (!solution_states[0])
1413  solution_states[0] = &solutionInternal();
1414  else
1415  mooseAssert(solution_states[0] == &solutionInternal(), "Inconsistent current solution");
1416 
1417  // We will manually add all states past current
1418  for (unsigned int i = 1; i <= state; ++i)
1419  if (!solution_states[i])
1420  {
1421  auto tag = _subproblem.addVectorTag(oldSolutionStateVectorName(i, iteration_type),
1423  solution_states[i] = &addVector(tag, true, GHOSTED);
1424  }
1425  else
1426  mooseAssert(solution_states[i] == &getVector(oldSolutionStateVectorName(i, iteration_type)),
1427  "Inconsistent solution state");
1428 }
virtual NumericVector< Number > & solutionInternal() const =0
Internal getter for solution owned by libMesh.
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type)
Adds a solution length vector to the system.
Definition: SystemBase.C:604
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition: SubProblem.C:82
const Parallel::Communicator & comm() const
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.h:1047
TagName oldSolutionStateVectorName(const unsigned int, Moose::SolutionIterationType iteration_type) const
Gets the vector name used for an old (not current) solution state.
Definition: SystemBase.C:1345
std::array< std::vector< NumericVector< Number > * >, 2 > _solution_states
The solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1041
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

◆ needSubdomainMaterialOnSide()

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

Indicates whether this system needs material properties on internal sides.

Returns
Boolean if DGKernels are active

Definition at line 3626 of file NonlinearSystemBase.C.

3628 {
3629  return _doing_dg;
3630 }
bool _doing_dg
true if DG is active (optimization reasons)

◆ nFieldVariables()

unsigned int SystemBase::nFieldVariables ( ) const
inherited

Get the number of field variables in this system.

Returns
the number of field variables

Definition at line 856 of file SystemBase.C.

Referenced by SystemBase::nVariables().

857 {
858  unsigned int n = 0;
859  for (auto & var : _vars[0].fieldVariables())
860  n += var->count();
861 
862  return n;
863 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

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

Referenced by MooseMesh::cacheFVElementalDoFs().

867 {
868  unsigned int n = 0;
869  for (auto & var : _vars[0].fieldVariables())
870  if (var->isFV())
871  n += var->count();
872 
873  return n;
874 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

◆ nLinearIterations()

unsigned int NonlinearSystemBase::nLinearIterations ( ) const
inlineinherited

Return the number of linear iterations.

Definition at line 493 of file NonlinearSystemBase.h.

Referenced by IterationAdaptiveDT::acceptStep().

493 { return _n_linear_iters; }

◆ nNonlinearIterations()

unsigned int NonlinearSystemBase::nNonlinearIterations ( ) const
inlineinherited

Return the number of non-linear iterations.

Definition at line 488 of file NonlinearSystemBase.h.

Referenced by IterationAdaptiveDT::acceptStep().

488 { return _n_iters; }

◆ nonEigenMatrixTag()

TagID NonlinearEigenSystem::nonEigenMatrixTag ( ) const
inline

◆ nonEigenVectorTag()

TagID NonlinearEigenSystem::nonEigenVectorTag ( ) const
inline

◆ nonlinearNorm()

Real NonlinearSystemBase::nonlinearNorm ( ) const
inlineinherited

Return the last nonlinear norm.

Returns
A Real containing the last computed residual norm

Definition at line 509 of file NonlinearSystemBase.h.

Referenced by Console::writeVariableNorms().

509 { return _last_nl_rnorm; }

◆ nonlinearSolver()

NonlinearSolver< Number > * NonlinearEigenSystem::nonlinearSolver ( )
overridevirtual

Implements NonlinearSystemBase.

Definition at line 338 of file NonlinearEigenSystem.C.

339 {
340  mooseError("did not implement yet \n");
341  return NULL;
342 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299

◆ nonTimeVectorTag()

TagID NonlinearSystemBase::nonTimeVectorTag ( ) const
inlineoverridevirtualinherited

Reimplemented from SystemBase.

Definition at line 604 of file NonlinearSystemBase.h.

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

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

◆ nResidualEvaluations()

unsigned int NonlinearSystemBase::nResidualEvaluations ( ) const
inlineinherited

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

Definition at line 498 of file NonlinearSystemBase.h.

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

◆ number()

unsigned int SystemBase::number ( ) const
inherited

Gets the number of this system.

Returns
The number of this system

Definition at line 1132 of file SystemBase.C.

Referenced by FEProblemBase::addCachedResidualDirectly(), FEProblemBase::addJacobian(), FEProblemBase::addJacobianBlockTags(), FEProblemBase::addJacobianLowerD(), FEProblemBase::addJacobianNeighbor(), FEProblemBase::addJacobianNeighborLowerD(), FEProblemBase::addJacobianOffDiagScalar(), FEProblemBase::addJacobianScalar(), LinearFVElementalKernel::addMatrixContribution(), LinearFVFluxKernel::addMatrixContribution(), FEProblemBase::addResidual(), FEProblemBase::addResidualLower(), FEProblemBase::addResidualNeighbor(), FEProblemBase::addResidualScalar(), LinearFVFluxKernel::addRightHandSideContribution(), LinearFVElementalKernel::addRightHandSideContribution(), SystemBase::addScalingVector(), ADKernelTempl< T >::ADKernelTempl(), ArrayKernel::ArrayKernel(), NonlinearSystemBase::assembleScalingVector(), MooseMesh::cacheFaceInfoVariableOwnership(), MooseVariableScalar::computeAD(), FEProblemBase::computeBounds(), Assembly::computeFaceMap(), VectorNodalBC::computeJacobian(), ArrayNodalBC::computeJacobian(), NodalBC::computeJacobian(), FVBoundaryScalarLagrangeMultiplierConstraint::computeJacobian(), FVFluxBC::computeJacobian(), FVFluxKernel::computeJacobian(), FVInterfaceKernel::computeJacobian(), FEProblemBase::computeJacobianBlock(), NonlinearSystemBase::computeJacobianInternal(), FEProblemBase::computeNearNullSpace(), NonlinearSystemBase::computeNodalBCsResidualAndJacobian(), FEProblemBase::computeNullSpace(), VectorNodalBC::computeOffDiagJacobian(), ArrayNodalBC::computeOffDiagJacobian(), NodalBC::computeOffDiagJacobian(), NodalKernel::computeOffDiagJacobian(), ComputeFullJacobianThread::computeOnBoundary(), ComputeFullJacobianThread::computeOnElement(), ComputeFullJacobianThread::computeOnInterface(), ComputeFullJacobianThread::computeOnInternalFace(), FEProblemBase::computePostCheck(), EqualValueEmbeddedConstraint::computeQpJacobian(), EqualValueEmbeddedConstraint::computeQpOffDiagJacobian(), FVOrthogonalBoundaryDiffusion::computeQpResidual(), FVBoundaryScalarLagrangeMultiplierConstraint::computeResidual(), FVFluxBC::computeResidual(), FVFluxKernel::computeResidual(), FVInterfaceKernel::computeResidual(), Kernel::computeResidualAndJacobian(), NodalBC::computeResidualAndJacobian(), IntegratedBC::computeResidualAndJacobian(), NonlinearSystemBase::computeResidualAndJacobianInternal(), NonlinearSystemBase::computeResidualInternal(), NonlinearSystemBase::computeResidualTags(), NonlinearSystemBase::computeScaling(), Assembly::computeSinglePointMapAD(), FEProblemBase::computeTransposeNullSpace(), DebugResidualAux::computeValue(), NearestNodeValueAux::computeValue(), NonlinearSystemBase::constraintJacobians(), Coupleable::coupled(), FEProblemBase::currentLinearSysNum(), FEProblemBase::currentNlSysNum(), PseudoTimestep::currentResidualNorm(), ComputeResidualThread::determineObjectWarehouses(), ComputeResidualAndJacobianThread::determineObjectWarehouses(), Moose::doDerivatives(), VariableResidual::execute(), NodalNormalsCorner::execute(), GreaterThanLessThanPostprocessor::execute(), NodalNormalsEvaluator::execute(), NodalNormalsPreprocessor::execute(), ComputeLinearFVElementalThread::fetchSystemContributionObjects(), ComputeLinearFVFaceThread::fetchSystemContributionObjects(), ElementSubdomainModifier::finalize(), NumNonlinearIterations::finalize(), BoundsBase::getDoFIndex(), NonlinearSystemBase::getNodeDofs(), SystemBase::getSubdomainsForVar(), NumLinearIterations::getValue(), Residual::getValue(), NumResidualEvaluations::getValue(), Moose::globalDofIndexToDerivative(), LinearFVFluxKernel::hasFaceSide(), LinearFVBoundaryCondition::hasFaceSide(), FVBoundaryCondition::hasFaceSide(), NonlinearSystemBase::initialSetup(), ActivateElementsUserObjectBase::initSolutions(), EigenExecutionerBase::inversePowerIteration(), Kernel::Kernel(), MooseVariableInterface< Real >::MooseVariableInterface(), EigenExecutionerBase::nonlinearSolve(), ComputeDiracThread::onElement(), ComputeNodalKernelBCJacobiansThread::onNode(), ComputeNodalKernelJacobiansThread::onNode(), PointwiseRenormalizeVector::PointwiseRenormalizeVector(), FEProblemBase::prepare(), FEProblemBase::prepareAssembly(), SystemBase::prepareFace(), FEProblemBase::prepareFaceShapes(), FEProblemBase::prepareNeighborShapes(), FEProblemBase::prepareShapes(), EqualValueEmbeddedConstraint::reinitConstraint(), FEProblemBase::reinitDirac(), FEProblemBase::reinitNeighborPhys(), FEProblemBase::reinitOffDiagScalars(), LinearFVFluxKernel::setCurrentFaceInfo(), FEProblemBase::setResidual(), FEProblemBase::setResidualNeighbor(), PhysicsBasedPreconditioner::setup(), FVInterfaceKernel::setupData(), FEProblemSolve::solve(), ActuallyExplicitEuler::solve(), LStableDirk2::solve(), LStableDirk3::solve(), ImplicitMidpoint::solve(), ExplicitTVDRK2::solve(), AStableDirk4::solve(), LStableDirk4::solve(), ExplicitRK2::solve(), ExplicitSSPRungeKutta::solveStage(), NonlinearThread::subdomainChanged(), UserObject::systemNumber(), MultiAppDofCopyTransfer::transferDofObject(), FVFluxBC::uOnGhost(), FVFluxBC::uOnUSub(), and MortarConstraintBase::zeroInactiveLMDofs().

1133 {
1134  return system().number();
1135 }
virtual System & system()=0
Get the reference to the libMesh system.

◆ nVariables()

unsigned int SystemBase::nVariables ( ) const
virtualinherited

Get the number of variables in this system.

Returns
the number of variables

Definition at line 847 of file SystemBase.C.

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

848 {
849  unsigned int n = nFieldVariables();
850  n += _vars[0].scalars().size();
851 
852  return n;
853 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958
unsigned int nFieldVariables() const
Get the number of field variables in this system.
Definition: SystemBase.C:856

◆ offDiagonalsInAutoScaling() [1/2]

bool NonlinearSystemBase::offDiagonalsInAutoScaling ( ) const
inlineinherited

Definition at line 640 of file NonlinearSystemBase.h.

Referenced by ComputeJacobianForScalingThread::computeOnElement(), and FEProblemSolve::FEProblemSolve().

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

◆ offDiagonalsInAutoScaling() [2/2]

void NonlinearSystemBase::offDiagonalsInAutoScaling ( bool  off_diagonals_in_auto_scaling)
inlineinherited

Definition at line 641 of file NonlinearSystemBase.h.

642  {
643  _off_diagonals_in_auto_scaling = off_diagonals_in_auto_scaling;
644  }
bool _off_diagonals_in_auto_scaling
Whether to include off diagonals when determining automatic scaling factors.

◆ onTimestepBegin()

void NonlinearSystemBase::onTimestepBegin ( )
inherited

Called at the beginning of the time step.

Definition at line 840 of file NonlinearSystemBase.C.

841 {
842  if (_time_integrator)
843  _time_integrator->preSolve();
844  if (_predictor.get())
845  _predictor->timestepSetup();
846 }
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:1007
std::shared_ptr< Predictor > _predictor
If predictor is active, this is non-NULL.

◆ overwriteNodeFace()

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

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

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

Definition at line 1549 of file NonlinearSystemBase.C.

Referenced by ActuallyExplicitEuler::solve().

1550 {
1551  // Overwrite results from integrator in case we have explicit dynamics contact constraints
1553  ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
1554  : static_cast<SubProblem &>(_fe_problem);
1555  const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
1556 
1557  for (const auto & it : penetration_locators)
1558  {
1559  PenetrationLocator & pen_loc = *(it.second);
1560 
1561  const auto & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
1562  const BoundaryID secondary_boundary = pen_loc._secondary_boundary;
1563  const BoundaryID primary_boundary = pen_loc._primary_boundary;
1564 
1565  if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, true))
1566  {
1567  const auto & constraints =
1568  _constraints.getActiveNodeFaceConstraints(secondary_boundary, true);
1569  for (const auto i : index_range(secondary_nodes))
1570  {
1571  const auto secondary_node_num = secondary_nodes[i];
1572  const Node & secondary_node = _mesh.nodeRef(secondary_node_num);
1573 
1574  if (secondary_node.processor_id() == processor_id())
1575  if (pen_loc._penetration_info[secondary_node_num])
1576  for (const auto & nfc : constraints)
1577  {
1578  if (!nfc->isExplicitConstraint())
1579  continue;
1580 
1581  // Return if this constraint does not correspond to the primary-secondary pair
1582  // prepared by the outer loops.
1583  // This continue statement is required when, e.g. one secondary surface constrains
1584  // more than one primary surface.
1585  if (nfc->secondaryBoundary() != secondary_boundary ||
1586  nfc->primaryBoundary() != primary_boundary)
1587  continue;
1588 
1589  nfc->overwriteBoundaryVariables(soln, secondary_node);
1590  }
1591  }
1592  }
1593  }
1594  soln.close();
1595 }
std::map< std::pair< BoundaryID, BoundaryID >, PenetrationLocator * > _penetration_locators
BoundaryID _secondary_boundary
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:637
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
std::vector< dof_id_type > _secondary_nodes
boundary_id_type BoundaryID
SubProblem & subproblem()
Definition: SystemBase.h:102
virtual GeometricSearchData & geomSearchData()=0
virtual void close()=0
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
MooseMesh & _mesh
Definition: SystemBase.h:953
processor_id_type processor_id() const
auto index_range(const T &sizable)
BoundaryID _primary_boundary
NearestNodeLocator & _nearest_node

◆ perfGraph()

PerfGraph & PerfGraphInterface::perfGraph ( )
inherited

Get the PerfGraph.

Definition at line 78 of file PerfGraphInterface.C.

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

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

◆ postAddResidualObject()

void NonlinearEigenSystem::postAddResidualObject ( ResidualObject )
overrideprotectedvirtual

Called after any ResidualObject-derived objects are added to the system.

Reimplemented from NonlinearSystemBase.

Definition at line 141 of file NonlinearEigenSystem.C.

142 {
143  // If it is an eigen dirichlet boundary condition, we should skip it because their
144  // contributions should be zero. If we do not skip it, preconditioning matrix will
145  // be singular because boundary elements are zero.
146  if (_precond_matrix_includes_eigen && !dynamic_cast<EigenDirichletBC *>(&object) &&
147  !dynamic_cast<EigenArrayDirichletBC *>(&object))
148  object.useMatrixTag(_precond_tag, {});
149 
150  auto & vtags = object.getVectorTags({});
151  auto & mtags = object.getMatrixTags({});
152  // If it is an eigen kernel, mark its variable as eigen
153  if (vtags.find(_Bx_tag) != vtags.end() || mtags.find(_B_tag) != mtags.end())
154  {
155  // Note: the object may be on the displaced system
156  auto sys = object.parameters().get<SystemBase *>("_sys");
157  auto vname = object.variable().name();
158  if (hasScalarVariable(vname))
159  sys->getScalarVariable(0, vname).eigen(true);
160  else
161  sys->getVariable(0, vname).eigen(true);
162  }
163 
164  // If this is not an eigen kernel
165  // If there is no vector eigen tag and no matrix eigen tag,
166  // then we consider this as noneigen kernel
167  if (vtags.find(_Bx_tag) == vtags.end() && mtags.find(_B_tag) == mtags.end())
168  {
169  // Noneigen Vector tag
170  object.useVectorTag(_Ax_tag, {});
171  // Noneigen Matrix tag
172  object.useMatrixTag(_A_tag, {});
173  // Noneigen Kernels
174  object.useMatrixTag(_precond_tag, {});
175  }
176  else
177  {
178  // Associate the eigen matrix tag and the vector tag
179  // if this is a eigen kernel
180  object.useMatrixTag(_B_tag, {});
181  object.useVectorTag(_Bx_tag, {});
182  }
183 }
Base class for a system (of equations)
Definition: SystemBase.h:85
virtual const std::string & name() const
Definition: SystemBase.C:1304
virtual bool hasScalarVariable(const std::string &var_name) const
Definition: SystemBase.C:832

◆ preconditioner()

Preconditioner<Number>* NonlinearEigenSystem::preconditioner ( ) const
inline

◆ precondMatrixIncludesEigenKernels() [1/2]

void NonlinearEigenSystem::precondMatrixIncludesEigenKernels ( bool  precond_matrix_includes_eigen)
inline

If the preconditioning matrix includes eigen kernels.

Definition at line 154 of file NonlinearEigenSystem.h.

Referenced by Eigenvalue::Eigenvalue().

155  {
156  _precond_matrix_includes_eigen = precond_matrix_includes_eigen;
157  }

◆ precondMatrixIncludesEigenKernels() [2/2]

bool NonlinearEigenSystem::precondMatrixIncludesEigenKernels ( ) const
inline

Definition at line 159 of file NonlinearEigenSystem.h.

◆ precondMatrixTag()

TagID NonlinearEigenSystem::precondMatrixTag ( ) const
inline

◆ prepare()

void SystemBase::prepare ( THREAD_ID  tid)
virtualinherited

Prepare the system for use.

Parameters
tidID of the thread

Definition at line 252 of file SystemBase.C.

Referenced by SubProblem::reinitElemFaceRef().

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

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

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

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

Referenced by SubProblem::reinitLowerDElem().

329 {
330  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
331  for (const auto & var : vars)
332  var->prepareLowerD();
333 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

◆ prepareNeighbor()

void SystemBase::prepareNeighbor ( THREAD_ID  tid)
virtualinherited

Prepare the system for use.

Parameters
tidID of the thread

Definition at line 320 of file SystemBase.C.

Referenced by SubProblem::reinitNeighborFaceRef().

321 {
322  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
323  for (const auto & var : vars)
324  var->prepareNeighbor();
325 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

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

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

3950 {
3951  // Clear the iteration counters
3952  _current_l_its.clear();
3953  _current_nl_its = 0;
3954 
3955  // Initialize the solution vector using a predictor and known values from nodal bcs
3957 
3958  // Now that the initial solution has ben set, potentially perform a residual/Jacobian evaluation
3959  // to determine variable scaling factors
3960  if (_automatic_scaling)
3961  {
3962  const bool scaling_succeeded = computeScaling();
3963  if (!scaling_succeeded)
3964  return false;
3965  }
3966 
3967  // We do not know a priori what variable a global degree of freedom corresponds to, so we need a
3968  // map from global dof to scaling factor. We just use a ghosted NumericVector for that mapping
3970 
3971  return true;
3972 }
std::vector< unsigned int > _current_l_its
bool _automatic_scaling
Whether to automatically scale the variables.
Definition: SystemBase.h:1013
bool computeScaling()
Method used to obtain scaling factors for variables.
void assembleScalingVector()
Assemble the numeric vector of scaling factors such that it can be used during assembly of the system...

◆ printAllVariableNorms()

void NonlinearSystemBase::printAllVariableNorms ( bool  state)
inlineinherited

Force the printing of all variable norms after each solve.

Definition at line 515 of file NonlinearSystemBase.h.

◆ registerTimedSection() [1/2]

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

Call to register a named section for timing.

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

Definition at line 53 of file PerfGraphInterface.C.

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

◆ registerTimedSection() [2/2]

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

Call to register a named section for timing.

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

Definition at line 64 of file PerfGraphInterface.C.

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

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

337 {
338 
340  {
341  const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
343  for (const auto & var : active_elemental_moose_variables)
344  if (&(var->sys()) == this)
345  var->computeElemValues();
346  }
347  else
348  {
349  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
350  for (const auto & var : vars)
351  var->computeElemValues();
352  }
353 }
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:432
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958
virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition: SubProblem.C:438

◆ reinitElemFace()

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

Reinit assembly info for a side of an element.

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

Reimplemented in AuxiliarySystem.

Definition at line 356 of file SystemBase.C.

Referenced by SubProblem::reinitElemFaceRef().

360 {
361  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
362  for (const auto & var : vars)
363  var->computeElemValuesFace();
364 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

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

Referenced by ComputeNodalDampingThread::onNode().

3454 {
3455  for (const auto & var : damped_vars)
3456  var->computeIncrementAtNode(*_increment_vec);
3457 }
NumericVector< Number > * _increment_vec
increment vector

◆ reinitIncrementAtQpsForDampers()

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

Compute the incremental change in variables at QPs for dampers.

Called before we use damping

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

Definition at line 3444 of file NonlinearSystemBase.C.

Referenced by ComputeElemDampingThread::onElement().

3446 {
3447  for (const auto & var : damped_vars)
3448  var->computeIncrementAtQps(*_increment_vec);
3449 }
NumericVector< Number > * _increment_vec
increment vector

◆ reinitLowerD()

void SystemBase::reinitLowerD ( THREAD_ID  tid)
virtualinherited

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

Definition at line 386 of file SystemBase.C.

Referenced by SubProblem::reinitLowerDElem().

387 {
388  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
389  for (const auto & var : vars)
390  var->computeLowerDValues();
391 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

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

379 {
380  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
381  for (const auto & var : vars)
382  var->computeNeighborValues();
383 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

◆ reinitNeighborFace()

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

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

Definition at line 367 of file SystemBase.C.

Referenced by SubProblem::reinitNeighborFaceRef().

371 {
372  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
373  for (const auto & var : vars)
374  var->computeNeighborValuesFace();
375 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

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

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

◆ reinitNodeFace() [1/3]

void SystemBase::reinitNodeFace
inherited

Reinit nodal assembly info on a face.

Parameters
nodeNode to reinit
bnd_idBoundary ID
tidThread ID

Definition at line 406 of file SystemBase.C.

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

◆ reinitNodeFace() [2/3]

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

Reinit nodal assembly info on a face.

Parameters
nodeNode to reinit
bnd_idBoundary ID
tidThread ID

Definition at line 406 of file SystemBase.C.

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

◆ reinitNodeFace() [3/3]

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

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

Definition at line 1054 of file NonlinearSystemBase.C.

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

1058 {
1059  auto & subproblem = displaced ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
1060  : static_cast<SubProblem &>(_fe_problem);
1061 
1062  const Elem * primary_elem = info._elem;
1063  unsigned int primary_side = info._side_num;
1064  std::vector<Point> points;
1065  points.push_back(info._closest_point);
1066 
1067  // *These next steps MUST be done in this order!*
1068  // ADL: This is a Chesterton's fence situation. I don't know which calls exactly the above comment
1069  // is referring to. If I had to guess I would guess just the reinitNodeFace and prepareAssembly
1070  // calls since the former will size the variable's dof indices and then the latter will resize the
1071  // residual/Jacobian based off the variable's cached dof indices size
1072 
1073  // This reinits the variables that exist on the secondary node
1074  _fe_problem.reinitNodeFace(&secondary_node, secondary_boundary, 0);
1075 
1076  // This will set aside residual and jacobian space for the variables that have dofs on
1077  // the secondary node
1079 
1080  _fe_problem.setNeighborSubdomainID(primary_elem, 0);
1081 
1082  //
1083  // Reinit material on undisplaced mesh
1084  //
1085 
1086  const Elem * const undisplaced_primary_elem =
1087  displaced ? _mesh.elemPtr(primary_elem->id()) : primary_elem;
1088  const Point undisplaced_primary_physical_point =
1089  [&points, displaced, primary_elem, undisplaced_primary_elem]()
1090  {
1091  if (displaced)
1092  {
1093  const Point reference_point =
1094  FEMap::inverse_map(primary_elem->dim(), primary_elem, points[0]);
1095  return FEMap::map(primary_elem->dim(), undisplaced_primary_elem, reference_point);
1096  }
1097  else
1098  // If our penetration locator is on the reference mesh, then our undisplaced
1099  // physical point is simply the point coming from the penetration locator
1100  return points[0];
1101  }();
1102 
1104  undisplaced_primary_elem, primary_side, {undisplaced_primary_physical_point}, 0);
1105  _fe_problem.reinitMaterialsNeighbor(primary_elem->subdomain_id(), 0);
1106 
1107  // Reinit points for constraint enforcement
1108  if (displaced)
1109  subproblem.reinitNeighborPhys(primary_elem, primary_side, points, 0);
1110 }
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid)=0
virtual Elem * elemPtr(const dof_id_type i)
Definition: MooseMesh.C:2864
MPI_Info info
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
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid) override
SubProblem & subproblem()
Definition: SystemBase.h:102
virtual void prepareAssembly(const THREAD_ID tid) override
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
MooseMesh & _mesh
Definition: SystemBase.h:953
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override

◆ reinitNodes()

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

Reinit variables at a set of nodes.

Parameters
nodesList of node ids to reinit
tidThread ID

Definition at line 418 of file SystemBase.C.

419 {
420  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
421  for (const auto & var : vars)
422  {
423  var->reinitNodes(nodes);
424  var->computeNodalValues();
425  }
426 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

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

430 {
431  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
432  for (const auto & var : vars)
433  {
434  var->reinitNodesNeighbor(nodes);
435  var->computeNodalNeighborValues();
436  }
437 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

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

441 {
442  const std::vector<MooseVariableScalar *> & vars = _vars[tid].scalars();
443  for (const auto & var : vars)
444  var->reinit(reinit_for_derivative_reordering);
445 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

◆ removeMatrix()

void SystemBase::removeMatrix ( TagID  tag)
inherited

Removes a matrix with a given tag.

Parameters
tag_nameThe name of the tag

Definition at line 586 of file SystemBase.C.

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

◆ removeVector() [1/2]

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

Remove a vector from the system with the given name.

Definition at line 1298 of file SystemBase.C.

Referenced by SystemBase::restoreOldSolutions().

1299 {
1300  system().remove_vector(name);
1301 }
virtual const std::string & name() const
Definition: SystemBase.C:1304
virtual System & system()=0
Get the reference to the libMesh system.

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

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

◆ residualAndJacobianTogether()

void NonlinearEigenSystem::residualAndJacobianTogether ( )
overridevirtual

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

Implements NonlinearSystemBase.

Definition at line 452 of file NonlinearEigenSystem.C.

453 {
454  mooseError(
455  "NonlinearEigenSystem::residualAndJacobianTogether is not implemented. It might even be "
456  "nonsensical. If it is sensical and you want this capability, please contact a MOOSE "
457  "developer.");
458 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299

◆ residualCopy()

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

Reimplemented from SystemBase.

Definition at line 3299 of file NonlinearSystemBase.C.

3300 {
3301  if (!_residual_copy.get())
3303 
3304  return *_residual_copy;
3305 }
const Parallel::Communicator & _communicator
static std::unique_ptr< NumericVector< Number > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
std::unique_ptr< NumericVector< Number > > _residual_copy
Copy of the residual vector, or nullptr if a copy is not needed.

◆ residualGhosted()

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

Reimplemented from SystemBase.

Definition at line 3308 of file NonlinearSystemBase.C.

3309 {
3310  _need_residual_ghosted = true;
3311  if (!_residual_ghosted)
3312  {
3313  // The first time we realize we need a ghosted residual vector,
3314  // we add it.
3315  _residual_ghosted = &addVector("residual_ghosted", false, GHOSTED);
3316 
3317  // If we've already realized we need time and/or non-time
3318  // residual vectors, but we haven't yet realized they need to be
3319  // ghosted, fix that now.
3320  //
3321  // If an application changes its mind, the libMesh API lets us
3322  // change the vector.
3323  if (_Re_time)
3324  {
3325  const auto vector_name = _subproblem.vectorTagName(_Re_time_tag);
3326  _Re_time = &system().add_vector(vector_name, false, GHOSTED);
3327  }
3328  if (_Re_non_time)
3329  {
3330  const auto vector_name = _subproblem.vectorTagName(_Re_non_time_tag);
3331  _Re_non_time = &system().add_vector(vector_name, false, GHOSTED);
3332  }
3333  }
3334  return *_residual_ghosted;
3335 }
NumericVector< Number > * _Re_time
residual vector for time contributions
TagID _Re_time_tag
Tag for time contribution residual.
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type)
Adds a solution length vector to the system.
Definition: SystemBase.C:604
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
TagID _Re_non_time_tag
Tag for non-time contribution residual.
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual System & system() override
Get the reference to the libMesh system.
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:199

◆ residualSetup()

void NonlinearSystemBase::residualSetup ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 1598 of file NonlinearSystemBase.C.

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

1599 {
1600  TIME_SECTION("residualSetup", 3);
1601 
1603 
1604  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1605  {
1606  _kernels.residualSetup(tid);
1609  if (_doing_dg)
1615  }
1620 
1621  // Avoid recursion
1622  if (this == &_fe_problem.currentNonlinearSystem())
1625 }
virtual void residualSetup(THREAD_ID tid=0) const
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
void residualSetup() override
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
bool _doing_dg
true if DG is active (optimization reasons)
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:138
NonlinearSystemBase & currentNonlinearSystem()
MooseObjectTagWarehouse< KernelBase > _kernels
ConstraintWarehouse _constraints
Constraints storage object.
MooseApp & _app
Definition: SystemBase.h:950
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
void resetSolutionInvalidCurrentIteration()
Reset the number of solution invalid occurrences back to zero.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
virtual void residualSetup()
Definition: SystemBase.C:1535
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
unsigned int THREAD_ID
Definition: MooseTypes.h:198

◆ residualVector()

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

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

Definition at line 967 of file NonlinearSystemBase.C.

968 {
969  mooseDeprecated("Please use getVector()");
970  switch (tag)
971  {
972  case 0:
973  return getResidualNonTimeVector();
974 
975  case 1:
976  return getResidualTimeVector();
977 
978  default:
979  mooseError("The required residual vector is not available");
980  }
981 }
NumericVector< Number > & getResidualTimeVector()
Return a numeric vector that is associated with the time tag.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:350
NumericVector< Number > & getResidualNonTimeVector()
Return a numeric vector that is associated with the nontime tag.

◆ residualVectorAX()

NumericVector< Number > & NonlinearEigenSystem::residualVectorAX ( )

Definition at line 326 of file NonlinearEigenSystem.C.

327 {
328  return _work_rhs_vector_AX;
329 }
NumericVector< Number > & _work_rhs_vector_AX

◆ residualVectorBX()

NumericVector< Number > & NonlinearEigenSystem::residualVectorBX ( )

Definition at line 332 of file NonlinearEigenSystem.C.

333 {
334  return _work_rhs_vector_BX;
335 }
NumericVector< Number > & _work_rhs_vector_BX

◆ residualVectorTag()

TagID NonlinearSystemBase::residualVectorTag ( ) const
inlineoverridevirtualinherited

◆ restoreOldSolutions()

void SystemBase::restoreOldSolutions ( )
virtualinherited

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

Definition at line 538 of file SystemBase.C.

539 {
540  const auto states =
541  _solution_states[static_cast<unsigned short>(Moose::SolutionIterationType::Time)].size();
542  if (states > 1)
543  for (unsigned int i = 1; i <= states - 1; ++i)
544  if (_saved_solution_states[i])
545  {
547  removeVector("save_solution_state_" + std::to_string(i));
548  _saved_solution_states[i] = nullptr;
549  }
550 
552  {
554  removeVector("save_solution_dot_old");
555  _saved_dot_old = nullptr;
556  }
558  {
560  removeVector("save_solution_dotdot_old");
561  _saved_dotdot_old = nullptr;
562  }
563 }
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.C:1391
virtual NumericVector< Number > * solutionUDotDotOld()
Definition: SystemBase.h:242
virtual NumericVector< Number > * solutionUDotOld()
Definition: SystemBase.h:241
NumericVector< Real > * _saved_dot_old
Definition: SystemBase.h:992
void removeVector(const std::string &name)
Remove a vector from the system with the given name.
Definition: SystemBase.C:1298
std::array< std::vector< NumericVector< Number > * >, 2 > _solution_states
The solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1041
NumericVector< Real > * _saved_dotdot_old
Definition: SystemBase.h:993
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1043

◆ restoreSolutions()

void SolverSystem::restoreSolutions ( )
finaloverridevirtualinherited

Restore current solutions (call after your solve failed)

Reimplemented from SystemBase.

Definition at line 40 of file SolverSystem.C.

41 {
42  // call parent
44  // and update _current_solution
45  _current_solution = system().current_local_solution.get();
46 }
virtual System & system()=0
Get the reference to the libMesh system.
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:77
virtual void restoreSolutions()
Restore current solutions (call after your solve failed)
Definition: SystemBase.C:1281

◆ RHS()

NumericVector< Number > & NonlinearEigenSystem::RHS ( )
overridevirtual

Implements NonlinearSystemBase.

Definition at line 320 of file NonlinearEigenSystem.C.

Referenced by computeScalingResidual().

321 {
322  return _work_rhs_vector_BX;
323 }
NumericVector< Number > & _work_rhs_vector_BX

◆ saveOldSolutions()

void SystemBase::saveOldSolutions ( )
virtualinherited

Save the old and older solutions.

Definition at line 506 of file SystemBase.C.

507 {
508  const auto states =
509  _solution_states[static_cast<unsigned short>(Moose::SolutionIterationType::Time)].size();
510  if (states > 1)
511  {
512  _saved_solution_states.resize(states);
513  for (unsigned int i = 1; i <= states - 1; ++i)
514  if (!_saved_solution_states[i])
516  &addVector("save_solution_state_" + std::to_string(i), false, PARALLEL);
517 
518  for (unsigned int i = 1; i <= states - 1; ++i)
520  }
521 
523  _saved_dot_old = &addVector("save_solution_dot_old", false, PARALLEL);
525  _saved_dotdot_old = &addVector("save_solution_dotdot_old", false, PARALLEL);
526 
527  if (solutionUDotOld())
529 
530  if (solutionUDotDotOld())
532 }
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type)
Adds a solution length vector to the system.
Definition: SystemBase.C:604
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.C:1391
virtual NumericVector< Number > * solutionUDotDotOld()
Definition: SystemBase.h:242
virtual NumericVector< Number > * solutionUDotOld()
Definition: SystemBase.h:241
NumericVector< Real > * _saved_dot_old
Definition: SystemBase.h:992
std::array< std::vector< NumericVector< Number > * >, 2 > _solution_states
The solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1041
NumericVector< Real > * _saved_dotdot_old
Definition: SystemBase.h:993
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1043

◆ scalingGroupVariables()

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

Definition at line 629 of file NonlinearSystemBase.h.

Referenced by FEProblemSolve::FEProblemSolve().

630  {
631  _scaling_group_variables = scaling_group_variables;
632  }
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 1582 of file SystemBase.C.

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

1583 {
1584  if (!_serialized_solution.get())
1585  {
1587  _serialized_solution->init(system().n_dofs(), false, SERIAL);
1588  }
1589 
1590  return *_serialized_solution;
1591 }
const Parallel::Communicator & _communicator
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed...
Definition: SystemBase.h:1026
virtual System & system()=0
Get the reference to the libMesh system.
static std::unique_ptr< NumericVector< Number > > build(const Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())

◆ serializeSolution()

void SolverSystem::serializeSolution ( )
inherited

Definition at line 49 of file SolverSystem.C.

Referenced by SolverSystem::setSolution().

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

◆ setActiveScalarVariableCoupleableVectorTags()

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

Set the active vector tags for the scalar variables.

Definition at line 1562 of file SystemBase.C.

Referenced by SubProblem::setActiveScalarVariableCoupleableVectorTags().

1564 {
1565  _vars[tid].setActiveScalarVariableCoupleableVectorTags(vtags);
1566 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

◆ setActiveVariableCoupleableVectorTags()

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

Set the active vector tags for the variables.

Definition at line 1556 of file SystemBase.C.

Referenced by SubProblem::setActiveFEVariableCoupleableVectorTags().

1557 {
1558  _vars[tid].setActiveVariableCoupleableVectorTags(vtags);
1559 }
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958

◆ setConstraintSecondaryValues()

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

Sets the value of constrained variables in the solution vector.

Definition at line 1113 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::setInitialSolution().

1114 {
1115 
1116  if (displaced)
1117  mooseAssert(_fe_problem.getDisplacedProblem(),
1118  "If we're calling this method with displaced = true, then we better well have a "
1119  "displaced problem");
1120  auto & subproblem = displaced ? static_cast<SubProblem &>(*_fe_problem.getDisplacedProblem())
1121  : static_cast<SubProblem &>(_fe_problem);
1122  const auto & penetration_locators = subproblem.geomSearchData()._penetration_locators;
1123 
1124  bool constraints_applied = false;
1125 
1126  for (const auto & it : penetration_locators)
1127  {
1128  PenetrationLocator & pen_loc = *(it.second);
1129 
1130  std::vector<dof_id_type> & secondary_nodes = pen_loc._nearest_node._secondary_nodes;
1131 
1132  BoundaryID secondary_boundary = pen_loc._secondary_boundary;
1133  BoundaryID primary_boundary = pen_loc._primary_boundary;
1134 
1135  if (_constraints.hasActiveNodeFaceConstraints(secondary_boundary, displaced))
1136  {
1137  const auto & constraints =
1138  _constraints.getActiveNodeFaceConstraints(secondary_boundary, displaced);
1139  std::unordered_set<unsigned int> needed_mat_props;
1140  for (const auto & constraint : constraints)
1141  {
1142  const auto & mp_deps = constraint->getMatPropDependencies();
1143  needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
1144  }
1145  _fe_problem.setActiveMaterialProperties(needed_mat_props, /*tid=*/0);
1146 
1147  for (unsigned int i = 0; i < secondary_nodes.size(); i++)
1148  {
1149  dof_id_type secondary_node_num = secondary_nodes[i];
1150  Node & secondary_node = _mesh.nodeRef(secondary_node_num);
1151 
1152  if (secondary_node.processor_id() == processor_id())
1153  {
1154  if (pen_loc._penetration_info[secondary_node_num])
1155  {
1156  PenetrationInfo & info = *pen_loc._penetration_info[secondary_node_num];
1157 
1158  reinitNodeFace(secondary_node, secondary_boundary, info, displaced);
1159 
1160  for (const auto & nfc : constraints)
1161  {
1162  if (nfc->isExplicitConstraint())
1163  continue;
1164  // Return if this constraint does not correspond to the primary-secondary pair
1165  // prepared by the outer loops.
1166  // This continue statement is required when, e.g. one secondary surface constrains
1167  // more than one primary surface.
1168  if (nfc->secondaryBoundary() != secondary_boundary ||
1169  nfc->primaryBoundary() != primary_boundary)
1170  continue;
1171 
1172  if (nfc->shouldApply())
1173  {
1174  constraints_applied = true;
1175  nfc->computeSecondaryValue(solution);
1176  }
1177 
1178  if (nfc->hasWritableCoupledVariables())
1179  {
1180  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1181  for (auto * var : nfc->getWritableCoupledVariables())
1182  {
1183  if (var->isNodalDefined())
1184  var->insert(_fe_problem.getAuxiliarySystem().solution());
1185  }
1186  }
1187  }
1188  }
1189  }
1190  }
1191  }
1192  }
1193 
1194  // go over NodeELemConstraints
1195  std::set<dof_id_type> unique_secondary_node_ids;
1196 
1197  for (const auto & secondary_id : _mesh.meshSubdomains())
1198  {
1199  for (const auto & primary_id : _mesh.meshSubdomains())
1200  {
1201  if (_constraints.hasActiveNodeElemConstraints(secondary_id, primary_id, displaced))
1202  {
1203  const auto & constraints =
1204  _constraints.getActiveNodeElemConstraints(secondary_id, primary_id, displaced);
1205 
1206  // get unique set of ids of all nodes on current block
1207  unique_secondary_node_ids.clear();
1208  const MeshBase & meshhelper = _mesh.getMesh();
1209  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(secondary_id),
1210  meshhelper.active_subdomain_elements_end(secondary_id)))
1211  {
1212  for (auto & n : elem->node_ref_range())
1213  unique_secondary_node_ids.insert(n.id());
1214  }
1215 
1216  for (auto secondary_node_id : unique_secondary_node_ids)
1217  {
1218  Node & secondary_node = _mesh.nodeRef(secondary_node_id);
1219 
1220  // check if secondary node is on current processor
1221  if (secondary_node.processor_id() == processor_id())
1222  {
1223  // This reinits the variables that exist on the secondary node
1224  _fe_problem.reinitNodeFace(&secondary_node, secondary_id, 0);
1225 
1226  // This will set aside residual and jacobian space for the variables that have dofs
1227  // on the secondary node
1229 
1230  for (const auto & nec : constraints)
1231  {
1232  if (nec->shouldApply())
1233  {
1234  constraints_applied = true;
1235  nec->computeSecondaryValue(solution);
1236  }
1237  }
1238  }
1239  }
1240  }
1241  }
1242  }
1243 
1244  // See if constraints were applied anywhere
1245  _communicator.max(constraints_applied);
1246 
1247  if (constraints_applied)
1248  {
1249  solution.close();
1250  update();
1251  }
1252 }
virtual void update(bool update_libmesh_system=true)
Update the system (doing libMesh magic)
Definition: SystemBase.C:1218
void setActiveMaterialProperties(const std::unordered_set< unsigned int > &mat_prop_ids, const THREAD_ID tid)
Record and set the material properties required by the current computing thread.
std::map< std::pair< BoundaryID, BoundaryID >, PenetrationLocator * > _penetration_locators
BoundaryID _secondary_boundary
MPI_Info info
NumericVector< Number > & solution()
Definition: SystemBase.h:182
Data structure used to hold penetration information.
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
const Parallel::Communicator & _communicator
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
bool hasActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:637
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
std::vector< dof_id_type > _secondary_nodes
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3199
boundary_id_type BoundaryID
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
SubProblem & subproblem()
Definition: SystemBase.h:102
virtual GeometricSearchData & geomSearchData()=0
AuxiliarySystem & getAuxiliarySystem()
virtual void prepareAssembly(const THREAD_ID tid) override
virtual void close()=0
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
MooseMesh & _mesh
Definition: SystemBase.h:953
void max(const T &r, T &o, Request &req) const
void reinitNodeFace(const Node &secondary_node, const BoundaryID secondary_boundary, const PenetrationInfo &info, const bool displaced)
Reinitialize quantities such as variables, residuals, Jacobians, materials for node-face constraints...
const std::vector< std::shared_ptr< NodeElemConstraint > > & getActiveNodeElemConstraints(SubdomainID secondary_id, SubdomainID primary_id, bool displaced) const
processor_id_type processor_id() const
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
BoundaryID _primary_boundary
uint8_t dof_id_type
NearestNodeLocator & _nearest_node
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:2922

◆ setDecomposition()

void NonlinearSystemBase::setDecomposition ( const std::vector< std::string > &  decomposition)
inherited

If called with a single string, it is used as the name of a the top-level decomposition split.

If the array is empty, no decomposition is used. In all other cases an error occurs.

Although a single top-level split is allowed in Problem, treat it as a list of splits for conformity with the Split input syntax.

Definition at line 413 of file NonlinearSystemBase.C.

Referenced by FEProblemSolve::FEProblemSolve(), and FieldSplitPreconditioner::FieldSplitPreconditioner().

414 {
416  if (splits.size() && splits.size() != 1)
417  mooseError("Only a single top-level split is allowed in a Problem's decomposition.");
418 
419  if (splits.size())
420  {
421  _decomposition_split = splits[0];
422  _have_decomposition = true;
423  }
424  else
425  _have_decomposition = false;
426 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
bool _have_decomposition
Whether or not the system can be decomposed into splits.
std::string _decomposition_split
Name of the top-level split of the decomposition.

◆ setInitialSolution()

void NonlinearSystemBase::setInitialSolution ( )
inherited

Definition at line 849 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::preSolve().

850 {
852 
853  NumericVector<Number> & initial_solution(solution());
854  if (_predictor.get() && _predictor->shouldApply())
855  {
856  TIME_SECTION("applyPredictor", 2, "Applying Predictor");
857 
858  _predictor->apply(initial_solution);
859  _fe_problem.predictorCleanup(initial_solution);
860  }
861 
862  // do nodal BC
863  {
864  TIME_SECTION("initialBCs", 2, "Applying BCs To Initial Condition");
865 
867  for (const auto & bnode : bnd_nodes)
868  {
869  BoundaryID boundary_id = bnode->_bnd_id;
870  Node * node = bnode->_node;
871 
872  if (node->processor_id() == processor_id())
873  {
874  // reinit variables in nodes
875  _fe_problem.reinitNodeFace(node, boundary_id, 0);
876 
878  {
879  const auto & preset_bcs = _preset_nodal_bcs.getActiveBoundaryObjects(boundary_id);
880  for (const auto & preset_bc : preset_bcs)
881  preset_bc->computeValue(initial_solution);
882  }
884  {
885  const auto & preset_bcs_res = _ad_preset_nodal_bcs.getActiveBoundaryObjects(boundary_id);
886  for (const auto & preset_bc : preset_bcs_res)
887  preset_bc->computeValue(initial_solution);
888  }
889  }
890  }
891  }
892 
893  _sys.solution->close();
894  update();
895 
896  // Set constraint secondary values
897  setConstraintSecondaryValues(initial_solution, false);
898 
900  setConstraintSecondaryValues(initial_solution, true);
901 }
virtual void update(bool update_libmesh_system=true)
Update the system (doing libMesh magic)
Definition: SystemBase.C:1218
NumericVector< Number > & solution()
Definition: SystemBase.h:182
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
virtual void deactiveAllMatrixTags()
Make matrices inactive.
Definition: SystemBase.C:1099
MooseObjectWarehouse< DirichletBCBase > _preset_nodal_bcs
boundary_id_type BoundaryID
virtual void predictorCleanup(NumericVector< Number > &ghosted_solution)
Perform cleanup tasks after application of predictor to solution vector.
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
MooseMesh & _mesh
Definition: SystemBase.h:953
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:2026
processor_id_type processor_id() const
std::shared_ptr< Predictor > _predictor
If predictor is active, this is non-NULL.
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:1092
void setConstraintSecondaryValues(NumericVector< Number > &solution, bool displaced)
Sets the value of constrained variables in the solution vector.
MooseObjectWarehouse< ADDirichletBCBase > _ad_preset_nodal_bcs

◆ setMooseKSPNormType()

void SolverSystem::setMooseKSPNormType ( MooseEnum  kspnorm)
inherited

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

Parameters
kspnormThe required norm

Definition at line 91 of file SolverSystem.C.

Referenced by MoosePreconditioner::MoosePreconditioner().

92 {
93  if (kspnorm == "none")
95  else if (kspnorm == "preconditioned")
97  else if (kspnorm == "unpreconditioned")
99  else if (kspnorm == "natural")
101  else if (kspnorm == "default")
103  else
104  mooseError("Unknown ksp norm type specified.");
105 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
Use whatever we have in PETSc.
Definition: MooseTypes.h:749
Moose::MooseKSPNormType _ksp_norm
KSP norm type.
Definition: SolverSystem.h:82

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

Referenced by MoosePreconditioner::MoosePreconditioner().

77 {
78  if (pcs == "left")
80  else if (pcs == "right")
82  else if (pcs == "symmetric")
84  else if (pcs == "default")
86  else
87  mooseError("Unknown PC side specified.");
88 }
Moose::PCSideType _pc_side
Preconditioning side.
Definition: SolverSystem.h:80
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
Use whatever we have in PETSc.
Definition: MooseTypes.h:737

◆ setPreconditioner()

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

Sets a preconditioner.

Parameters
pcThe preconditioner to be set

Definition at line 3423 of file NonlinearSystemBase.C.

Referenced by SetupPreconditionerAction::act().

3424 {
3425  if (_preconditioner.get() != nullptr)
3426  mooseError("More than one active Preconditioner detected");
3427 
3428  _preconditioner = pc;
3429 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
std::shared_ptr< MoosePreconditioner > _preconditioner
Preconditioner.

◆ setPredictor()

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

Definition at line 904 of file NonlinearSystemBase.C.

Referenced by SetupPredictorAction::act().

905 {
906  _predictor = predictor;
907 }
std::shared_ptr< Predictor > _predictor
If predictor is active, this is non-NULL.

◆ setPreviousNewtonSolution()

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

Definition at line 3639 of file NonlinearSystemBase.C.

Referenced by FEProblemBase::computePostCheck().

3640 {
3643 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
const TagName PREVIOUS_NL_SOLUTION_TAG
Definition: MooseTypes.C:30
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

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

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

65 {
66  _current_solution = &soln;
67 
69  associateVectorToTag(const_cast<NumericVector<Number> &>(soln), tag);
70 
71  if (_serialized_solution.get())
73 }
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition: SubProblem.C:181
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:937
void serializeSolution()
Definition: SolverSystem.C:49
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed...
Definition: SystemBase.h:1026
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:77
const TagName SOLUTION_TAG
Definition: MooseTypes.C:27

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

3400 {
3401  *_u_dot = u_dot;
3402 }
NumericVector< Number > * _u_dot
solution vector for u^dot
Definition: SystemBase.h:968

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

3406 {
3407  *_u_dotdot = u_dotdot;
3408 }
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
Definition: SystemBase.h:970

◆ setSolutionUDotDotOld()

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

Definition at line 3417 of file NonlinearSystemBase.C.

3418 {
3419  *_u_dotdot_old = u_dotdot_old;
3420 }
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
Definition: SystemBase.h:975

◆ setSolutionUDotOld()

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

Definition at line 3411 of file NonlinearSystemBase.C.

3412 {
3413  *_u_dot_old = u_dot_old;
3414 }
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
Definition: SystemBase.h:973

◆ setupDampers()

void NonlinearSystemBase::setupDampers ( )
inherited

Setup damping stuff (called before we actually start)

Definition at line 3438 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::init().

3439 {
3440  _increment_vec = &_sys.add_vector("u_increment", true, GHOSTED);
3441 }
NumericVector< Number > * _increment_vec
increment vector

◆ setupDM()

void NonlinearSystemBase::setupDM ( )
inherited

Setup the PETSc DM object (when appropriate)

Definition at line 406 of file NonlinearSystemBase.C.

Referenced by FEProblemBase::solve().

407 {
410 }
void petscSetupDM(NonlinearSystemBase &nl, const std::string &dm_name)
Setup the PETSc DM object.
Definition: PetscSupport.C:176
bool haveFieldSplitPreconditioner() const
std::string _decomposition_split
Name of the top-level split of the decomposition.

◆ setupFieldDecomposition()

void NonlinearSystemBase::setupFieldDecomposition ( )
inherited

Definition at line 429 of file NonlinearSystemBase.C.

Referenced by FieldSplitPreconditioner::FieldSplitPreconditioner().

430 {
431  if (!_have_decomposition)
432  return;
433 
434  std::shared_ptr<Split> top_split = getSplit(_decomposition_split);
435  top_split->setup(*this);
436 }
bool _have_decomposition
Whether or not the system can be decomposed into splits.
std::shared_ptr< Split > getSplit(const std::string &name)
Retrieves a split by name.
std::string _decomposition_split
Name of the top-level split of the decomposition.

◆ setupFiniteDifferencedPreconditioner()

void NonlinearEigenSystem::setupFiniteDifferencedPreconditioner ( )
overridevirtual

Implements NonlinearSystemBase.

Definition at line 301 of file NonlinearEigenSystem.C.

302 {
303  mooseError("did not implement yet \n");
304 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299

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

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

◆ setVerboseFlag()

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

Sets the verbose flag.

Parameters
[in]verboseVerbose flag

Definition at line 135 of file SystemBase.h.

Referenced by Executioner::Executioner().

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

◆ solution() [1/2]

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

Definition at line 182 of file SystemBase.h.

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

182 { return solutionState(0); }
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.C:1391

◆ solution() [2/2]

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

Definition at line 185 of file SystemBase.h.

185 { return solutionState(0); }
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.C:1391

◆ solutionInternal()

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

Internal getter for solution owned by libMesh.

Implements SystemBase.

Definition at line 95 of file SolverSystem.h.

96 {
97  return *system().solution;
98 }
virtual System & system()=0
Get the reference to the libMesh system.

◆ solutionOld() [1/2]

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

◆ solutionOld() [2/2]

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

Definition at line 186 of file SystemBase.h.

186 { return solutionState(1); }
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.C:1391

◆ solutionOlder() [1/2]

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

Definition at line 184 of file SystemBase.h.

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

184 { return solutionState(2); }
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.C:1391

◆ solutionOlder() [2/2]

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

Definition at line 187 of file SystemBase.h.

187 { return solutionState(2); }
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.C:1391

◆ solutionPreviousNewton() [1/2]

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

Reimplemented in DisplacedSystem.

Definition at line 1319 of file SystemBase.C.

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

1320 {
1323  else
1324  return nullptr;
1325 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
const TagName PREVIOUS_NL_SOLUTION_TAG
Definition: MooseTypes.C:30
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

◆ solutionPreviousNewton() [2/2]

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

Reimplemented in DisplacedSystem.

Definition at line 1310 of file SystemBase.C.

1311 {
1314  else
1315  return nullptr;
1316 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
const TagName PREVIOUS_NL_SOLUTION_TAG
Definition: MooseTypes.C:30
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

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

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

1393 {
1394  if (!hasSolutionState(state, iteration_type))
1395  needSolutionState(state, iteration_type);
1396  return *_solution_states[static_cast<unsigned short>(iteration_type)][state];
1397 }
virtual void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Registers that the solution state state is needed.
Definition: SystemBase.C:1400
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.h:1047
std::array< std::vector< NumericVector< Number > * >, 2 > _solution_states
The solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1041

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

1366 {
1367  if (!hasSolutionState(state, iteration_type))
1368  mooseError("For iteration type '",
1369  Moose::stringify(iteration_type),
1370  "': solution state ",
1371  state,
1372  " was requested in ",
1373  name(),
1374  " but only up to state ",
1375  _solution_states[static_cast<unsigned short>(iteration_type)].size() - 1,
1376  " is available.");
1377 
1378  const auto & solution_states = _solution_states[static_cast<unsigned short>(iteration_type)];
1379 
1380  if (state == 0)
1381  mooseAssert(solution_states[0] == &solutionInternal(), "Inconsistent current solution");
1382  else
1383  mooseAssert(solution_states[state] ==
1384  &getVector(oldSolutionStateVectorName(state, iteration_type)),
1385  "Inconsistent solution state");
1386 
1387  return *solution_states[state];
1388 }
virtual NumericVector< Number > & solutionInternal() const =0
Internal getter for solution owned by libMesh.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
virtual const std::string & name() const
Definition: SystemBase.C:1304
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
Definition: SystemBase.h:1047
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:62
TagName oldSolutionStateVectorName(const unsigned int, Moose::SolutionIterationType iteration_type) const
Gets the vector name used for an old (not current) solution state.
Definition: SystemBase.C:1345
std::array< std::vector< NumericVector< Number > * >, 2 > _solution_states
The solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1041
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

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

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

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

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

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

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

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

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

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

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

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

◆ solve()

void NonlinearEigenSystem::solve ( )
overridevirtual

Solve the system (using libMesh magic)

Implements NonlinearSystemBase.

Definition at line 186 of file NonlinearEigenSystem.C.

187 {
188  const bool presolve_succeeded = preSolve();
189  if (!presolve_succeeded)
190  return;
191 
192 // In DEBUG mode, Libmesh will check the residual automatically. This may cause
193 // an error because B does not need to assembly by default.
194 // When PETSc is older than 3.13, we always need to do an extra assembly,
195 // so we do not do "close" here
196 #if DEBUG && !PETSC_RELEASE_LESS_THAN(3, 13, 0)
197  if (sys().has_matrix_B())
198  sys().get_matrix_B().close();
199 #endif
200 
201  // We apply initial guess for only nonlinear solver
203  _eigen_sys.set_initial_space(solution());
204 
205  // Solve the transient problem if we have a time integrator; the
206  // steady problem if not.
207  if (_time_integrator)
208  {
209  _time_integrator->solve();
210  _time_integrator->postSolve();
211  }
212  else
213  system().solve();
214 
215  // store eigenvalues
216  unsigned int n_converged_eigenvalues = getNumConvergedEigenvalues();
217 
219 
220  if (_n_eigen_pairs_required < n_converged_eigenvalues)
221  n_converged_eigenvalues = _n_eigen_pairs_required;
222 
223  _eigen_values.resize(n_converged_eigenvalues);
224  for (unsigned int n = 0; n < n_converged_eigenvalues; n++)
226 
227  // Update the solution vector to the active eigenvector
228  if (n_converged_eigenvalues)
230 }
unsigned int activeEigenvalueIndex() const
Which eigenvalue is active.
Definition: EigenProblem.h:179
NumericVector< Number > & solution()
Definition: SystemBase.h:182
bool isNonlinearEigenvalueSolver() const
Definition: EigenProblem.C:636
unsigned int getNumConvergedEigenvalues() const
Get the number of converged eigenvalues.
unsigned int getNEigenPairsRequired() const
Definition: EigenProblem.h:40
std::pair< Real, Real > getConvergedEigenpair(dof_id_type n) const
Return the Nth converged eigenvalue and copies the respective eigen vector to the solution vector...
virtual System & system() override
Get the reference to the libMesh system.
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:1007
std::pair< Real, Real > getConvergedEigenvalue(dof_id_type n) const
Return the Nth converged eigenvalue.
bool preSolve()
Perform some steps to get ready for the solver.
std::vector< std::pair< Real, Real > > _eigen_values
unsigned int _n_eigen_pairs_required

◆ stopSolve()

void NonlinearEigenSystem::stopSolve ( const ExecFlagType exec_flag)
overridevirtual

Quit the current solve as soon as possible.

Implements SolverSystem.

Definition at line 295 of file NonlinearEigenSystem.C.

296 {
297  mooseError("did not implement yet \n");
298 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299

◆ subdomainSetup() [1/3]

void SystemBase::subdomainSetup
inherited

Definition at line 1528 of file SystemBase.C.

1529 {
1530  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1531  _vars[tid].subdomainSetup();
1532 }
unsigned int n_threads()
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958
virtual void subdomainSetup()
Definition: SystemBase.C:1528
unsigned int THREAD_ID
Definition: MooseTypes.h:198

◆ subdomainSetup() [2/3]

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

Called from assembling when we hit a new subdomain.

Parameters
subdomainID of the new subdomain
tidThread ID

Definition at line 910 of file NonlinearSystemBase.C.

911 {
913 
914  _kernels.subdomainSetup(subdomain, tid);
915  _nodal_kernels.subdomainSetup(subdomain, tid);
916  _element_dampers.subdomainSetup(subdomain, tid);
917  _nodal_dampers.subdomainSetup(subdomain, tid);
918 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
MooseObjectTagWarehouse< KernelBase > _kernels
virtual void subdomainSetup()
Definition: SystemBase.C:1528
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
virtual void subdomainSetup(THREAD_ID tid=0) const

◆ subdomainSetup() [3/3]

void SystemBase::subdomainSetup ( )
virtualinherited

Reimplemented in AuxiliarySystem.

Definition at line 1528 of file SystemBase.C.

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

1529 {
1530  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1531  _vars[tid].subdomainSetup();
1532 }
unsigned int n_threads()
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:958
virtual void subdomainSetup()
Definition: SystemBase.C:1528
unsigned int THREAD_ID
Definition: MooseTypes.h:198

◆ 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; }
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945

◆ sys()

EigenSystem& NonlinearEigenSystem::sys ( )
inline

Definition at line 90 of file NonlinearEigenSystem.h.

Referenced by NonlinearEigenSystem(), postAddResidualObject(), and solve().

90 { return _eigen_sys; }

◆ system() [1/2]

virtual System& NonlinearSystemBase::system ( )
inlineoverridevirtualinherited

Get the reference to the libMesh system.

Implements SystemBase.

Definition at line 594 of file NonlinearSystemBase.h.

Referenced by Adaptivity::adaptMesh(), PhysicsBasedPreconditioner::addSystem(), PhysicsBasedPreconditioner::apply(), NonlinearSystemBase::computeScaling(), PseudoTimestep::currentResidualNorm(), DMCreateGlobalVector_Moose(), DMCreateMatrix_Moose(), DMMooseFunction(), DMMooseGetEmbedding_Private(), DMMooseGetMeshBlocks_Private(), DMMooseJacobian(), DMSetFromOptions_Moose(), DMSetUp_Moose_Pre(), VariableResidual::execute(), NonlinearSystemBase::getResidualNonTimeVector(), NonlinearSystemBase::getResidualTimeVector(), ReferenceResidualProblem::initialSetup(), Moose::SlepcSupport::mooseMatMult(), Moose::SlepcSupport::moosePetscSNESFormFunction(), Moose::SlepcSupport::moosePetscSNESFormMatricesTags(), Moose::SlepcSupport::moosePetscSNESFormMatrixTag(), Moose::SlepcSupport::mooseSlepcEigenFormFunctionAB(), ConsoleUtils::outputNonlinearSystemInformation(), PhysicsBasedPreconditioner::PhysicsBasedPreconditioner(), NonlinearSystemBase::residualGhosted(), PhysicsBasedPreconditioner::setup(), NonlinearSystemBase::setupScalingData(), SingleMatrixPreconditioner::SingleMatrixPreconditioner(), NonlinearSystem::solve(), solve(), LStableDirk2::solve(), LStableDirk3::solve(), ImplicitMidpoint::solve(), ExplicitTVDRK2::solve(), AStableDirk4::solve(), LStableDirk4::solve(), ExplicitRK2::solve(), TimeIntegrator::solve(), Moose::PetscSupport::storePetscOptions(), NonlinearSystemBase::turnOffJacobian(), ReferenceResidualProblem::updateReferenceResidual(), VariableCondensationPreconditioner::VariableCondensationPreconditioner(), and Console::writeVariableNorms().

594 { return _sys; }

◆ system() [2/2]

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

Implements SystemBase.

Definition at line 595 of file NonlinearSystemBase.h.

595 { return _sys; }

◆ systemMatrixTag()

TagID NonlinearSystemBase::systemMatrixTag ( ) const
inlineoverridevirtualinherited

◆ timedSectionName()

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

Optionally adds a prefix if one is defined.

Definition at line 47 of file PerfGraphInterface.C.

Referenced by PerfGraphInterface::registerTimedSection().

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

◆ timestepSetup()

void NonlinearSystemBase::timestepSetup ( )
overridevirtualinherited

Reimplemented from SystemBase.

Definition at line 298 of file NonlinearSystemBase.C.

299 {
301 
302  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
303  {
304  _kernels.timestepSetup(tid);
307  if (_doing_dg)
313 
314  if (_fe_problem.haveFV())
315  {
316  std::vector<FVFluxBC *> bcs;
318  .query()
319  .template condition<AttribSystem>("FVFluxBC")
320  .template condition<AttribThread>(tid)
321  .queryInto(bcs);
322 
323  std::vector<FVInterfaceKernel *> iks;
325  .query()
326  .template condition<AttribSystem>("FVInterfaceKernel")
327  .template condition<AttribThread>(tid)
328  .queryInto(iks);
329 
330  std::vector<FVFluxKernel *> kernels;
332  .query()
333  .template condition<AttribSystem>("FVFluxKernel")
334  .template condition<AttribThread>(tid)
335  .queryInto(kernels);
336 
337  for (auto * bc : bcs)
338  bc->timestepSetup();
339  for (auto * ik : iks)
340  ik->timestepSetup();
341  for (auto * kernel : kernels)
342  kernel->timestepSetup();
343  }
344  }
349 }
MooseObjectTagWarehouse< NodalKernelBase > _nodal_kernels
NodalKernels for each thread.
unsigned int n_threads()
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
std::vector< T * > & queryInto(std::vector< T *> &results, Args &&... args)
queryInto executes the query and stores the results in the given vector.
Definition: TheWarehouse.h:311
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
MooseObjectTagWarehouse< DiracKernelBase > _dirac_kernels
Dirac Kernel storage for each thread.
bool _doing_dg
true if DG is active (optimization reasons)
TheWarehouse & theWarehouse() const
virtual void timestepSetup(THREAD_ID tid=0) const
MooseObjectTagWarehouse< KernelBase > _kernels
ConstraintWarehouse _constraints
Constraints storage object.
FEProblemBase & _fe_problem
the governing finite element/volume problem
Definition: SystemBase.h:948
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
Definition: TheWarehouse.h:466
MooseObjectTagWarehouse< InterfaceKernelBase > _interface_kernels
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
MooseObjectTagWarehouse< ScalarKernelBase > _scalar_kernels
unsigned int THREAD_ID
Definition: MooseTypes.h:198
virtual void timestepSetup()
Definition: SystemBase.C:1514

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

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

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

◆ turnOffJacobian()

void NonlinearEigenSystem::turnOffJacobian ( )
overridevirtual

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

Reimplemented from NonlinearSystemBase.

Definition at line 446 of file NonlinearEigenSystem.C.

447 {
448  // Let us do nothing at the current moment
449 }

◆ update()

void SystemBase::update ( bool  update_libmesh_system = true)
virtualinherited

◆ updateActive()

void NonlinearSystemBase::updateActive ( THREAD_ID  tid)
inherited

Update active objects of Warehouses owned by NonlinearSystemBase.

Definition at line 3164 of file NonlinearSystemBase.C.

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

◆ useFieldSplitPreconditioner()

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

If called with true this system will use a field split preconditioner matrix.

Definition at line 429 of file NonlinearSystemBase.h.

Referenced by FieldSplitPreconditioner::FieldSplitPreconditioner().

bool _use_field_split_preconditioner
Whether or not to use a FieldSplitPreconditioner matrix based on the decomposition.

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

Referenced by FiniteDifferencePreconditioner::FiniteDifferencePreconditioner().

415  {
417  }
bool _use_finite_differenced_preconditioner
Whether or not to use a finite differenced preconditioner.

◆ validParams()

InputParameters PerfGraphInterface::validParams ( )
staticinherited

Definition at line 16 of file PerfGraphInterface.C.

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

◆ varKind()

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

Definition at line 926 of file SystemBase.h.

Referenced by Coupleable::coupled(), and UserObject::UserObject().

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

◆ zeroTaggedVector()

void SystemBase::zeroTaggedVector ( const TagID  tag)
inherited

Zero vector with the given tag.

Definition at line 671 of file SystemBase.C.

Referenced by SystemBase::zeroTaggedVectors().

672 {
673  if (!_subproblem.vectorTagExists(tag))
674  mooseError("Cannot zero vector with TagID ",
675  tag,
676  " in system '",
677  name(),
678  "' because that tag does not exist in the problem");
679  else if (!hasVector(tag))
680  mooseError("Cannot zero vector tag with name '",
682  "' in system '",
683  name(),
684  "' because there is no vector associated with that tag");
685 
686  getVector(tag).zero();
687 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
virtual void zero()=0
virtual const std::string & name() const
Definition: SystemBase.C:1304
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
Definition: SystemBase.h:945
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:173
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:199
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition: SystemBase.C:889

◆ zeroTaggedVectors()

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

Zero all vectors for given tags.

Definition at line 690 of file SystemBase.C.

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

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

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

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

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

◆ zeroVariablesForJacobian()

void SystemBase::zeroVariablesForJacobian ( )
virtualinherited

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

Definition at line 231 of file SystemBase.C.

232 {
234 }
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
Definition: SystemBase.h:965
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:196

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

226 {
228 }
std::vector< std::string > _vars_to_be_zeroed_on_residual
Definition: SystemBase.h:964
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:196

◆ zeroVectorForResidual()

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

Definition at line 695 of file NonlinearSystemBase.C.

696 {
697  for (unsigned int i = 0; i < _vecs_to_zero_for_residual.size(); ++i)
698  if (vector_name == _vecs_to_zero_for_residual[i])
699  return;
700 
701  _vecs_to_zero_for_residual.push_back(vector_name);
702 }
std::vector< std::string > _vecs_to_zero_for_residual
vectors that will be zeroed before a residual computation

Member Data Documentation

◆ _A_tag

TagID NonlinearEigenSystem::_A_tag
protected

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

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

◆ _app

MooseApp& SystemBase::_app
protectedinherited

◆ _assemble_constraints_separately

bool NonlinearSystemBase::_assemble_constraints_separately
protectedinherited

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

Definition at line 850 of file NonlinearSystemBase.h.

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

◆ _automatic_scaling

bool SystemBase::_automatic_scaling
protectedinherited

Whether to automatically scale the variables.

Definition at line 1013 of file SystemBase.h.

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

◆ _Ax_tag

TagID NonlinearEigenSystem::_Ax_tag
protected

◆ _B_tag

TagID NonlinearEigenSystem::_B_tag
protected

◆ _Bx_tag

TagID NonlinearEigenSystem::_Bx_tag
protected

◆ _compute_initial_residual_before_preset_bcs

bool NonlinearSystemBase::_compute_initial_residual_before_preset_bcs
inherited

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

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

◆ _computed_scaling

bool NonlinearSystemBase::_computed_scaling
protectedinherited

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

Definition at line 893 of file NonlinearSystemBase.h.

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

◆ _computing_initial_residual

bool NonlinearSystemBase::_computing_initial_residual
protectedinherited

◆ _console

const ConsoleStream ConsoleStreamInterface::_console
inherited

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

Definition at line 31 of file ConsoleStreamInterface.h.

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

◆ _constraints

ConstraintWarehouse NonlinearSystemBase::_constraints
protectedinherited

◆ _current_l_its

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

◆ _current_nl_its

unsigned int NonlinearSystemBase::_current_nl_its
inherited

◆ _current_solution

const NumericVector<Number>* SolverSystem::_current_solution
protectedinherited

◆ _debugging_residuals

bool NonlinearSystemBase::_debugging_residuals
protectedinherited

true if debugging residuals

Definition at line 855 of file NonlinearSystemBase.h.

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

◆ _decomposition_split

std::string NonlinearSystemBase::_decomposition_split
protectedinherited

Name of the top-level split of the decomposition.

Definition at line 842 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::setDecomposition(), NonlinearSystemBase::setupDM(), and NonlinearSystemBase::setupFieldDecomposition().

◆ _dg_kernels

MooseObjectTagWarehouse<DGKernelBase> NonlinearSystemBase::_dg_kernels
protectedinherited

◆ _dirac_kernels

MooseObjectTagWarehouse<DiracKernelBase> NonlinearSystemBase::_dirac_kernels
protectedinherited

◆ _doing_dg

bool NonlinearSystemBase::_doing_dg
protectedinherited

◆ _du_dot_du

Number NonlinearSystemBase::_du_dot_du
protectedinherited

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

Definition at line 761 of file NonlinearSystemBase.h.

◆ _du_dotdot_du

Number NonlinearSystemBase::_du_dotdot_du
protectedinherited

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

Definition at line 763 of file NonlinearSystemBase.h.

◆ _eigen_problem

EigenProblem& NonlinearEigenSystem::_eigen_problem
protected

◆ _eigen_sys

EigenSystem& NonlinearEigenSystem::_eigen_sys
protected

◆ _eigen_values

std::vector<std::pair<Real, Real> > NonlinearEigenSystem::_eigen_values
protected

Definition at line 180 of file NonlinearEigenSystem.h.

Referenced by getAllConvergedEigenvalues(), and solve().

◆ _element_dampers

MooseObjectWarehouse<ElementDamper> NonlinearSystemBase::_element_dampers
protectedinherited

◆ _factory

Factory& SystemBase::_factory
protectedinherited

◆ _fdcoloring

MatFDColoring NonlinearSystemBase::_fdcoloring
protectedinherited

◆ _fe_problem

FEProblemBase& SystemBase::_fe_problem
protectedinherited

the governing finite element/volume problem

Definition at line 948 of file SystemBase.h.

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

◆ _final_residual

Real NonlinearSystemBase::_final_residual
protectedinherited

◆ _general_dampers

MooseObjectWarehouse<GeneralDamper> NonlinearSystemBase::_general_dampers
protectedinherited

◆ _has_diag_save_in

bool NonlinearSystemBase::_has_diag_save_in
protectedinherited

◆ _has_nodalbc_diag_save_in

bool NonlinearSystemBase::_has_nodalbc_diag_save_in
protectedinherited

◆ _has_nodalbc_save_in

bool NonlinearSystemBase::_has_nodalbc_save_in
protectedinherited

If there is a nodal BC having save_in.

Definition at line 885 of file NonlinearSystemBase.h.

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

◆ _has_save_in

bool NonlinearSystemBase::_has_save_in
protectedinherited

◆ _have_decomposition

bool NonlinearSystemBase::_have_decomposition
protectedinherited

Whether or not the system can be decomposed into splits.

Definition at line 840 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::setDecomposition(), and NonlinearSystemBase::setupFieldDecomposition().

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

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

◆ _increment_vec

NumericVector<Number>* NonlinearSystemBase::_increment_vec
protectedinherited

◆ _initial_residual_after_preset_bcs

Real NonlinearSystemBase::_initial_residual_after_preset_bcs
inherited

Definition at line 650 of file NonlinearSystemBase.h.

Referenced by FEProblemBase::checkNonlinearConvergence().

◆ _initial_residual_before_preset_bcs

Real NonlinearSystemBase::_initial_residual_before_preset_bcs
inherited

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

◆ _Ke_system_tag

TagID NonlinearSystemBase::_Ke_system_tag
protectedinherited

Tag for system contribution Jacobian.

Definition at line 789 of file NonlinearSystemBase.h.

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

◆ _kernels

MooseObjectTagWarehouse<KernelBase> NonlinearSystemBase::_kernels
protectedinherited

◆ _ksp_norm

Moose::MooseKSPNormType SolverSystem::_ksp_norm
protectedinherited

KSP norm type.

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

◆ _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 1001 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 1004 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 962 of file SystemBase.h.

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

◆ _mesh

MooseMesh& SystemBase::_mesh
protectedinherited

◆ _n_eigen_pairs_required

unsigned int NonlinearEigenSystem::_n_eigen_pairs_required
protected

Definition at line 181 of file NonlinearEigenSystem.h.

Referenced by solve().

◆ _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 867 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 955 of file SystemBase.h.

◆ _need_residual_ghosted

bool NonlinearSystemBase::_need_residual_ghosted
protectedinherited

◆ _nl_matrix_tags

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

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

Definition at line 772 of file NonlinearSystemBase.h.

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

◆ _nl_vector_tags

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

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

Definition at line 769 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::computeNodalBCs(), 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 519 of file NonlinearSystemBase.h.

◆ _numbered_vars

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

Map variable number to its pointer.

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

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

◆ _pc_side

Moose::PCSideType SolverSystem::_pc_side
protectedinherited

Preconditioning side.

Definition at line 80 of file SolverSystem.h.

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

◆ _pg_moose_app

MooseApp& PerfGraphInterface::_pg_moose_app
protectedinherited

The MooseApp that owns the PerfGraph.

Definition at line 124 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::perfGraph().

◆ _precond_matrix_includes_eigen

bool NonlinearEigenSystem::_precond_matrix_includes_eigen
protected

◆ _precond_tag

TagID NonlinearEigenSystem::_precond_tag
protected

◆ _preconditioner

Preconditioner<Number>* NonlinearEigenSystem::_preconditioner
protected

Definition at line 191 of file NonlinearEigenSystem.h.

Referenced by attachPreconditioner(), and preconditioner().

◆ _predictor

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

◆ _prefix

const std::string PerfGraphInterface::_prefix
protectedinherited

A prefix to use for all sections.

Definition at line 127 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::timedSectionName().

◆ _preset_nodal_bcs

MooseObjectWarehouse<DirichletBCBase> NonlinearSystemBase::_preset_nodal_bcs
protectedinherited

◆ _print_all_var_norms

bool NonlinearSystemBase::_print_all_var_norms
protectedinherited

Definition at line 876 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::printAllVariableNorms().

◆ _raw_grad_container

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

A cache for storing gradients at dof locations.

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

Definition at line 1031 of file SystemBase.h.

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

◆ _Re_non_time

NumericVector<Number>* NonlinearSystemBase::_Re_non_time
protectedinherited

◆ _Re_non_time_tag

TagID NonlinearSystemBase::_Re_non_time_tag
protectedinherited

◆ _Re_tag

TagID NonlinearSystemBase::_Re_tag
protectedinherited

Used for the residual vector from PETSc.

Definition at line 783 of file NonlinearSystemBase.h.

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

◆ _Re_time

NumericVector<Number>* NonlinearSystemBase::_Re_time
protectedinherited

◆ _Re_time_tag

TagID NonlinearSystemBase::_Re_time_tag
protectedinherited

◆ _resid_vs_jac_scaling_param

Real NonlinearSystemBase::_resid_vs_jac_scaling_param
protectedinherited

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

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

Definition at line 903 of file NonlinearSystemBase.h.

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

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

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

◆ _residual_ghosted

NumericVector<Number>* NonlinearSystemBase::_residual_ghosted
protectedinherited

◆ _saved_dot_old

NumericVector<Real>* SystemBase::_saved_dot_old
protectedinherited

Definition at line 992 of file SystemBase.h.

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

◆ _saved_dotdot_old

NumericVector<Real>* SystemBase::_saved_dotdot_old
protectedinherited

Definition at line 993 of file SystemBase.h.

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

◆ _saved_old

NumericVector<Real>* SystemBase::_saved_old
protectedinherited

Definition at line 988 of file SystemBase.h.

◆ _saved_older

NumericVector<Real>* SystemBase::_saved_older
protectedinherited

Definition at line 989 of file SystemBase.h.

◆ _scalar_kernels

MooseObjectTagWarehouse<ScalarKernelBase> NonlinearSystemBase::_scalar_kernels
protectedinherited

◆ _scaling_group_variables

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

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

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

Definition at line 908 of file NonlinearSystemBase.h.

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

◆ _scaling_matrix

std::unique_ptr<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 1026 of file SystemBase.h.

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

◆ _solution_is_invalid

bool SolverSystem::_solution_is_invalid
protectedinherited

Boolean to see if solution is invalid.

Definition at line 85 of file SolverSystem.h.

Referenced by SolverSystem::checkInvalidSolution(), and NonlinearSystem::converged().

◆ _solution_states_initialized

bool SystemBase::_solution_states_initialized
protectedinherited

Whether or not the solution states have been initialized.

Definition at line 1019 of file SystemBase.h.

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

◆ _solver_configuration

std::unique_ptr<SlepcEigenSolverConfiguration> NonlinearEigenSystem::_solver_configuration
protected

Definition at line 179 of file NonlinearEigenSystem.h.

Referenced by NonlinearEigenSystem().

◆ _splits

MooseObjectWarehouseBase<Split> NonlinearSystemBase::_splits
protectedinherited

Decomposition splits.

Definition at line 824 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::addSplit(), and NonlinearSystemBase::getSplit().

◆ _subproblem

SubProblem& SystemBase::_subproblem
protectedinherited

◆ _sys

System& NonlinearSystemBase::_sys
inherited

◆ _tagged_matrices

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

◆ _tagged_vectors

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

◆ _time_integrator

std::shared_ptr<TimeIntegrator> SystemBase::_time_integrator
protectedinherited

◆ _u_dot

NumericVector<Number>* SystemBase::_u_dot
protectedinherited

solution vector for u^dot

Definition at line 968 of file SystemBase.h.

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

◆ _u_dot_old

NumericVector<Number>* SystemBase::_u_dot_old
protectedinherited

old solution vector for u^dot

Definition at line 973 of file SystemBase.h.

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

◆ _u_dotdot

NumericVector<Number>* SystemBase::_u_dotdot
protectedinherited

solution vector for u^dotdot

Definition at line 970 of file SystemBase.h.

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

◆ _u_dotdot_old

NumericVector<Number>* SystemBase::_u_dotdot_old
protectedinherited

old solution vector for u^dotdot

Definition at line 975 of file SystemBase.h.

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

◆ _use_field_split_preconditioner

bool NonlinearSystemBase::_use_field_split_preconditioner
protectedinherited

Whether or not to use a FieldSplitPreconditioner matrix based on the decomposition.

Definition at line 844 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::haveFieldSplitPreconditioner(), and NonlinearSystemBase::useFieldSplitPreconditioner().

◆ _use_finite_differenced_preconditioner

bool NonlinearSystemBase::_use_finite_differenced_preconditioner
protectedinherited

Whether or not to use a finite differenced preconditioner.

Definition at line 835 of file NonlinearSystemBase.h.

Referenced by NonlinearSystemBase::haveFiniteDifferencedPreconditioner(), NonlinearSystem::solve(), and NonlinearSystemBase::useFiniteDifferencedPreconditioner().

◆ _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 1022 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 996 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 960 of file SystemBase.h.

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

◆ _var_to_copy

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

◆ _variable_autoscaled

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

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

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

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

◆ _vars_to_be_zeroed_on_jacobian

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

◆ _vars_to_be_zeroed_on_residual

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

◆ _vecs_to_zero_for_residual

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

vectors that will be zeroed before a residual computation

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

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

◆ _work_rhs_vector_AX

NumericVector<Number>& NonlinearEigenSystem::_work_rhs_vector_AX
protected

Definition at line 182 of file NonlinearEigenSystem.h.

Referenced by residualVectorAX().

◆ _work_rhs_vector_BX

NumericVector<Number>& NonlinearEigenSystem::_work_rhs_vector_BX
protected

Definition at line 183 of file NonlinearEigenSystem.h.

Referenced by residualVectorBX(), and RHS().


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