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

#include <MooseEigenSystem.h>

Inheritance diagram for MooseEigenSystem:
[legend]

Public Types

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

Public Member Functions

 MooseEigenSystem (FEProblemBase &problem, const std::string &name)
 
virtual ~MooseEigenSystem ()
 
virtual void addKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a kernel. More...
 
virtual void markEigenVariable (const VariableName &var_name)
 Mark a variable as a variable of the eigen system. More...
 
void scaleSystemSolution (SYSTEMTAG tag, Real scaling_factor)
 Scale the solution vector. More...
 
void combineSystemSolution (SYSTEMTAG tag, const std::vector< Real > &coefficients)
 Linear combination of the solution vectors. More...
 
void initSystemSolution (SYSTEMTAG tag, Real v)
 Initialize the solution vector with a constant value. More...
 
void initSystemSolutionOld (SYSTEMTAG tag, Real v)
 
void eigenKernelOnOld ()
 Ask eigenkernels to operate on old or current solution vectors. More...
 
void eigenKernelOnCurrent ()
 
void buildSystemDoFIndices (SYSTEMTAG tag=ALL)
 Build DoF indices for a system. More...
 
bool activeOnOld ()
 Return if eigen kernels should be on old solution. More...
 
const std::set< VariableName > & getEigenVariableNames () const
 Get variable names of the eigen system. More...
 
bool containsEigenKernel () const
 Weather or not the system contains eigen kernels. More...
 
virtual SparseMatrix< Number > & addMatrix (TagID tag) override
 Adds a jacobian sized vector. More...
 
virtual void solve () override
 Solve the system (using libMesh magic) More...
 
virtual void stopSolve () 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
 
virtual NonlinearSolver< Number > * nonlinearSolver () override
 
virtual NumericVector< Number > & solutionOld () override
 
virtual NumericVector< Number > & solutionOlder () override
 
virtual TransientNonlinearImplicitSystem & sys ()
 
virtual void init () override
 Initialize the system. More...
 
void turnOffJacobian ()
 Turn off the Jacobian (must be called before equation system initialization) More...
 
virtual void addExtraVectors () override
 Method called during initialSetup to add extra system vector if they are required by the simulation. More...
 
virtual void restoreSolutions () override
 Restore current solutions (call after your solve failed) More...
 
virtual bool computingInitialResidual ()
 Returns true if this system is currently computing the initial residual for a solve. More...
 
virtual void initialSetup ()
 
virtual void timestepSetup ()
 
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 >)
 
void addDotVectors ()
 Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator. 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 setConstraintSlaveValues (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 computeResidual (NumericVector< Number > &residual, TagID tag_id)
 Form a residual vector for a given tag. More...
 
void findImplicitGeometricCouplingEntries (GeometricSearchData &geom_search_data, std::map< dof_id_type, std::vector< dof_id_type >> &graph)
 Finds the implicit sparsity graph between geometrically related dofs. 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 setVariableGlobalDoFs (const std::string &var_name)
 set all the global dof indices for a nonlinear variable More...
 
const std::vector< dof_id_type > & getVariableGlobalDoFs ()
 
void computeJacobianTags (const std::set< TagID > &tags)
 Computes multiple (tag associated) Jacobian matricese. 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 ()
 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 setSolution (const NumericVector< Number > &soln)
 
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...
 
virtual NumericVector< Number > * solutionUDot () override
 
virtual NumericVector< Number > * solutionUDotDot () override
 
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 const NumericVector< Number > *& currentSolution () override
 The solution vector that is currently being operated on. More...
 
virtual void serializeSolution ()
 
virtual NumericVector< Number > & serializedSolution () override
 Returns a reference to a serialized version of the solution vector for this subproblem. 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...
 
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 ()
 
void setPCSide (MooseEnum pcs)
 
Moose::PCSideType getPCSide ()
 
void setMooseKSPNormType (MooseEnum kspnorm)
 
Moose::MooseKSPNormType getMooseKSPNormType ()
 
bool needBoundaryMaterialOnSide (BoundaryID bnd_id, THREAD_ID tid) const
 Indicated whether this system needs material properties on boundaries. 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 NumericVector< Number > & solution () override
 
virtual System & system () override
 Get the reference to the libMesh system. More...
 
virtual const System & system () const override
 
virtual NumericVector< Number > * solutionUDotOld () override
 
virtual NumericVector< Number > * solutionUDotDotOld () override
 
virtual NumericVector< Number > * solutionPreviousNewton () 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)
 
virtual TagID timeVectorTag () override
 Ideally, we should not need this API. More...
 
virtual TagID nonTimeVectorTag () override
 
virtual TagID residualVectorTag () override
 
virtual TagID systemMatrixTag () override
 Return the Matrix Tag ID for System. More...
 
virtual unsigned int number () const
 Gets the number of this system. More...
 
virtual MooseMeshmesh ()
 
virtual SubProblemsubproblem ()
 
virtual DofMap & dofMap ()
 Gets the dof map. More...
 
virtual void initializeObjects ()
 Called only once, just before the solve begins so objects can do some precalculations. More...
 
virtual void update ()
 Update the system (doing libMesh magic) More...
 
virtual void copyOldSolutions ()
 Shifts the solutions backwards in time. More...
 
virtual Number & duDotDu ()
 
virtual Number & duDotDotDu ()
 
virtual void saveOldSolutions ()
 Save the old and older solutions. More...
 
virtual void restoreOldSolutions ()
 Restore the old and older solutions when the saved solutions present. More...
 
bool hasVector (const std::string &tag_name) const
 Check if the named vector exists in the system. More...
 
virtual bool hasVector (TagID tag_id)
 Check if the tagged vector exists in the system. More...
 
virtual TagID timeMatrixTag ()
 Return the Matrix Tag ID for Time. More...
 
virtual NumericVector< Number > & getVector (const std::string &name)
 Get a raw NumericVector. More...
 
virtual NumericVector< Number > & getVector (TagID tag)
 Get a raw NumericVector. More...
 
virtual void associateVectorToTag (NumericVector< Number > &vec, TagID tag)
 Associate a vector for a given tag. More...
 
virtual void disassociateVectorFromTag (NumericVector< Number > &vec, TagID tag)
 Associate a vector for a given tag. More...
 
virtual void disassociateAllTaggedVectors ()
 Disassociate all vectors, and then hasVector() will return false. More...
 
virtual bool hasMatrix (TagID tag)
 Check if the tagged matrix exists in the system. More...
 
virtual SparseMatrix< Number > & getMatrix (TagID tag)
 Get a raw SparseMatrix. More...
 
virtual void activeAllMatrixTags ()
 Make all exsiting matrices ative. More...
 
virtual void activeMatrixTag (TagID tag)
 Active a matrix for tag. More...
 
virtual bool matrixTagActive (TagID tag)
 If or not a matrix tag is active. More...
 
virtual void deactiveMatrixTag (TagID tag)
 deactive a matrix for tag More...
 
virtual void deactiveAllMatrixTags ()
 Make matrices inactive. More...
 
void closeTaggedMatrices (const std::set< TagID > &tags)
 Close all matrices associated the tags. More...
 
virtual void associateMatrixToTag (SparseMatrix< Number > &matrix, TagID tag)
 associate a matirx to a tag More...
 
virtual void disassociateMatrixFromTag (SparseMatrix< Number > &matrix, TagID tag)
 disassociate a matirx from a tag More...
 
virtual void disassociateAllTaggedMatrices ()
 Clear all tagged matrices. More...
 
virtual 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_name, const FEType &type, Real scale_factor, const std::set< SubdomainID > *const active_subdomains=NULL)
 Adds a variable to the system. More...
 
virtual bool isScalarVariable (unsigned int var_name) const
 
MooseVariableFEBasegetVariable (THREAD_ID tid, const std::string &var_name)
 Gets a reference to a variable of with specified name. More...
 
MooseVariableFEBasegetVariable (THREAD_ID tid, unsigned int var_number)
 Gets a reference to a variable with specified number. More...
 
template<typename T >
MooseVariableFE< T > & getFieldVariable (THREAD_ID tid, const std::string &var_name)
 Gets a reference to a variable of with specified name. More...
 
template<typename T >
MooseVariableFE< T > & getFieldVariable (THREAD_ID tid, unsigned int var_number)
 Gets a reference to a variable with specified number. More...
 
virtual MooseVariableScalargetScalarVariable (THREAD_ID tid, const std::string &var_name)
 Gets a reference to a scalar variable with specified number. More...
 
virtual MooseVariableScalargetScalarVariable (THREAD_ID tid, unsigned int var_number)
 Gets a reference to a variable with specified number. More...
 
virtual const std::set< SubdomainID > * getVariableBlocks (unsigned int var_number)
 Get the block where a variable of this system is defined. More...
 
virtual unsigned int nVariables () const
 Get the number of variables in this system. More...
 
size_t getMaxVarNDofsPerElem ()
 Gets the maximum number of dofs used by any one variable on any one element. More...
 
size_t getMaxVarNDofsPerNode ()
 Gets the maximum number of dofs used by any one variable on any one node. More...
 
void assignMaxVarNDofsPerElem (const size_t &max_dofs)
 assign the maximum element dofs More...
 
void assignMaxVarNDofsPerNode (const 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 reinitElem (const Elem *elem, THREAD_ID tid)
 Reinit an element assembly info. More...
 
virtual void reinitElemFace (const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
 Reinit assembly info for a side of an element. More...
 
virtual void reinitNeighborFace (const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
 Compute the values of the variables at all the current points. More...
 
virtual void reinitNeighbor (const Elem *elem, THREAD_ID tid)
 Compute the values of the variables at all the current points. More...
 
virtual void reinitNode (const Node *node, THREAD_ID tid)
 Reinit nodal assembly info. More...
 
virtual void reinitNodeFace (const Node *node, BoundaryID bnd_id, THREAD_ID tid)
 Reinit nodal assembly info on a face. More...
 
virtual void reinitNodes (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of nodes. More...
 
virtual void reinitNodesNeighbor (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of neighbor nodes. More...
 
virtual void reinitScalars (THREAD_ID tid)
 Reinit scalar varaibles. More...
 
virtual void addVariableToCopy (const std::string &dest_name, const std::string &source_name, const std::string &timestep)
 Add info about variable that will be copied. More...
 
const std::vector< MooseVariableFEBase * > & getVariables (THREAD_ID tid)
 
const std::vector< MooseVariableScalar * > & getScalarVariables (THREAD_ID tid)
 
const std::set< SubdomainID > & getSubdomainsForVar (unsigned int var_number) const
 
virtual void removeVector (const std::string &name)
 Remove a vector from the system with the given name. More...
 
virtual void removeVector (TagID tag_id)
 Remove a solution length vector from the system with the specified TagID. More...
 
virtual NumericVector< Number > & addVector (const std::string &vector_name, const bool project, const ParallelType type)
 Adds a solution length vector to the system. More...
 
NumericVector< Number > & addVector (TagID tag, const bool project, const ParallelType type)
 Adds a solution length vector to the system with the specified TagID. More...
 
virtual void closeTaggedVectors (const std::set< TagID > &tags)
 Close all vectors for given tags. More...
 
virtual void zeroTaggedVectors (const std::set< TagID > &tags)
 Zero all vectors for given tags. More...
 
virtual void removeMatrix (TagID)
 Removes a jacobian sized vector. More...
 
virtual const std::string & name () const
 
virtual void addScalarVariable (const std::string &var_name, Order order, Real scale_factor, const std::set< SubdomainID > *const active_subdomains=NULL)
 Adds a scalar variable. More...
 
const std::vector< VariableName > & getVariableNames () const
 
virtual void computeVariables (const NumericVector< Number > &)
 
void copyVars (ExodusII_IO &io)
 
virtual void copySolutionsBackwards ()
 Copy current solution into old and older. More...
 
TimeIntegratorgetTimeIntegrator ()
 
std::shared_ptr< TimeIntegratorgetSharedTimeIntegrator ()
 
void checkKernelCoverage (const std::set< SubdomainID > &mesh_subdomains) const
 
bool containsTimeKernel ()
 
MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse ()
 Access functions to Warehouses from outside NonlinearSystemBase. More...
 
MooseObjectTagWarehouse< KernelBase > & getADJacobianKernelWarehouse ()
 
MooseObjectTagWarehouse< DGKernel > & getDGKernelWarehouse ()
 
MooseObjectTagWarehouse< InterfaceKernel > & getInterfaceKernelWarehouse ()
 
MooseObjectTagWarehouse< DiracKernel > & getDiracKernelWarehouse ()
 
MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse ()
 
const MooseObjectWarehouse< ElementDamper > & getElementDamperWarehouse () const
 
const MooseObjectWarehouse< NodalDamper > & getNodalDamperWarehouse () const
 
const ConstraintWarehousegetConstraintWarehouse () 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
 

Public Attributes

unsigned int _num_residual_evaluations
 
FEProblemBase_fe_problem
 
System & _sys
 
Real _last_rnorm
 
Real _last_nl_rnorm
 
Real _l_abs_step_tol
 
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

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 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 getNodeDofs (dof_id_type node_id, std::vector< dof_id_type > &dofs)
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level)
 Call to register a named section for timing. More...
 

Protected Attributes

std::set< VariableName > _eigen_var_names
 
bool _all_eigen_vars
 
std::set< dof_id_type > _eigen_var_indices
 
bool _active_on_old
 
unsigned int _eigen_kernel_counter
 counter of eigen kernels More...
 
TransientNonlinearImplicitSystem & _transient_sys
 
ComputeResidualFunctor _nl_residual_functor
 
ComputeFDResidualFunctor _fd_residual_functor
 
const NumericVector< Number > * _current_solution
 solution vector from nonlinear solver More...
 
NumericVector< Number > * _residual_ghosted
 ghosted form of the residual More...
 
NumericVector< Number > & _serialized_solution
 Serialized version of the solution vector. More...
 
NumericVector< Number > * _solution_previous_nl
 Solution vector of the previous nonlinear iterate. More...
 
NumericVector< Number > & _residual_copy
 Copy of the residual vector. More...
 
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...
 
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< DiracKernel_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< NodalKernel_nodal_kernels
 NodalKernels for each thread. More...
 
MooseObjectWarehouseBase< Split_splits
 Decomposition splits. More...
 
ConstraintWarehouse _constraints
 Constraints storage object. More...
 
NumericVector< Number > * _increment_vec
 increment vector More...
 
std::shared_ptr< MoosePreconditioner_preconditioner
 Preconditioner. More...
 
Moose::PCSideType _pc_side
 Preconditioning side. More...
 
Moose::MooseKSPNormType _ksp_norm
 KSP norm type. 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_serialized_solution
 Whether or not a copy of the residual needs to be made. More...
 
bool _need_residual_copy
 Whether or not a copy of the residual needs to be made. 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...
 
std::vector< dof_id_type > _var_all_dof_indices
 
PerfID _compute_residual_tags_timer
 Timers. More...
 
PerfID _compute_residual_internal_timer
 
PerfID _kernels_timer
 
PerfID _scalar_kernels_timer
 
PerfID _nodal_kernels_timer
 
PerfID _nodal_kernel_bcs_timer
 
PerfID _nodal_bcs_timer
 
PerfID _compute_jacobian_tags_timer
 
PerfID _compute_jacobian_blocks_timer
 
PerfID _compute_dampers_timer
 
PerfID _compute_dirac_timer
 
SubProblem_subproblem
 
MooseApp_app
 
Factory_factory
 
MooseMesh_mesh
 
std::string _name
 The name of this system. More...
 
std::vector< VariableWarehouse_vars
 Variable warehouses (one for each thread) More...
 
std::map< unsigned int, std::set< SubdomainID > > _var_map
 Map of variables (variable id -> array of subdomains where it lives) More...
 
std::vector< std::string > _vars_to_be_zeroed_on_residual
 
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
 
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...
 
const InputParameters_pg_params
 Params. More...
 
PerfGraph_perf_graph
 The performance graph to add to. More...
 
std::string _prefix
 A prefix to use for all sections. More...
 
MooseObjectTagWarehouse< KernelBase_kernels
 
MooseObjectTagWarehouse< KernelBase_ad_jacobian_kernels
 
MooseObjectTagWarehouse< ScalarKernel_scalar_kernels
 
MooseObjectTagWarehouse< DGKernel_dg_kernels
 
MooseObjectTagWarehouse< InterfaceKernel_interface_kernels
 
MooseObjectTagWarehouse< IntegratedBCBase_integrated_bcs
 
MooseObjectTagWarehouse< NodalBCBase_nodal_bcs
 
MooseObjectWarehouse< PresetNodalBC_preset_nodal_bcs
 

Detailed Description

Definition at line 20 of file MooseEigenSystem.h.

Member Enumeration Documentation

◆ SYSTEMTAG

System or kernel tags.

Enumerator
ALL 
EIGEN 

Definition at line 44 of file MooseEigenSystem.h.

Constructor & Destructor Documentation

◆ MooseEigenSystem()

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

Definition at line 16 of file MooseEigenSystem.C.

17  : NonlinearSystem(fe_problem, name),
18  _all_eigen_vars(false),
19  _active_on_old(false),
21 {
22 }
unsigned int _eigen_kernel_counter
counter of eigen kernels
NonlinearSystem(FEProblemBase &problem, const std::string &name)
virtual const std::string & name() const
Definition: SystemBase.C:1022

◆ ~MooseEigenSystem()

MooseEigenSystem::~MooseEigenSystem ( )
virtual

Definition at line 24 of file MooseEigenSystem.C.

24 {}

Member Function Documentation

◆ activeAllMatrixTags()

void SystemBase::activeAllMatrixTags ( )
virtualinherited

Make all exsiting matrices ative.

Definition at line 865 of file SystemBase.C.

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

866 {
867  auto num_matrix_tags = _subproblem.numMatrixTags();
868 
869  _matrix_tag_active_flags.resize(num_matrix_tags);
870 
871  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
872  if (hasMatrix(tag))
873  _matrix_tag_active_flags[tag] = true;
874  else
875  _matrix_tag_active_flags[tag] = false;
876 }
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:781
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:719
SubProblem & _subproblem
Definition: SystemBase.h:694
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:152

◆ activeMatrixTag()

void SystemBase::activeMatrixTag ( TagID  tag)
virtualinherited

Active a matrix for tag.

Definition at line 830 of file SystemBase.C.

831 {
832  mooseAssert(_subproblem.matrixTagExists(tag),
833  "Cannot active Matrix with matrix_tag : " << tag << "that does not exist");
834 
835  if (_matrix_tag_active_flags.size() < tag + 1)
836  _matrix_tag_active_flags.resize(tag + 1);
837 
838  _matrix_tag_active_flags[tag] = true;
839 }
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:119
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:719
SubProblem & _subproblem
Definition: SystemBase.h:694

◆ activeOnOld()

bool MooseEigenSystem::activeOnOld ( )

Return if eigen kernels should be on old solution.

Definition at line 220 of file MooseEigenSystem.C.

Referenced by EigenKernel::enabled().

221 {
222  return _active_on_old;
223 }

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

389 {
390  // ThreadID
391  THREAD_ID tid = 0;
392 
393  // Create the object
394  std::shared_ptr<BoundaryCondition> bc =
395  _factory.create<BoundaryCondition>(bc_name, name, parameters, tid);
396 
397  // Active BoundaryIDs for the object
398  const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
399  _vars[tid].addBoundaryVar(boundary_ids, &bc->variable());
400 
401  // Cast to the various types of BCs
402  std::shared_ptr<NodalBCBase> nbc = std::dynamic_pointer_cast<NodalBCBase>(bc);
403  std::shared_ptr<IntegratedBCBase> ibc = std::dynamic_pointer_cast<IntegratedBCBase>(bc);
404 
405  // NodalBCBase
406  if (nbc)
407  {
408  _nodal_bcs.addObject(nbc);
409  _vars[tid].addBoundaryVars(boundary_ids, nbc->getCoupledVars());
410 
411  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
412  _has_nodalbc_save_in = true;
413  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
415 
416  // PresetNodalBC
417  std::shared_ptr<PresetNodalBC> pnbc = std::dynamic_pointer_cast<PresetNodalBC>(bc);
418  if (pnbc)
420  }
421 
422  // IntegratedBCBase
423  else if (ibc)
424  {
425  _integrated_bcs.addObject(ibc, tid);
426  _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
427 
428  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
429  _has_save_in = true;
430  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
431  _has_diag_save_in = true;
432 
433  for (tid = 1; tid < libMesh::n_threads(); tid++)
434  {
435  // Create the object
436  bc = _factory.create<BoundaryCondition>(bc_name, name, parameters, tid);
437 
438  // Active BoundaryIDs for the object
439  const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
440  _vars[tid].addBoundaryVar(boundary_ids, &bc->variable());
441 
442  ibc = std::static_pointer_cast<IntegratedBCBase>(bc);
443 
444  _integrated_bcs.addObject(ibc, tid);
445  _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
446  }
447  }
448 
449  else
450  mooseError("Unknown BoundaryCondition type for object named ", bc->name());
451 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
Factory & _factory
Definition: SystemBase.h:697
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)
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
virtual const std::string & name() const
Definition: SystemBase.C:1022
Base class for deriving any boundary condition that works at nodes.
Definition: NodalBCBase.h:33
Base class for creating new types of boundary conditions.
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:704
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
Base class for deriving any boundary condition of a integrated type.
virtual const std::set< BoundaryID > & boundaryIDs() const
Return the boundary IDs for this object.
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:126
MooseObjectWarehouse< PresetNodalBC > _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 454 of file NonlinearSystemBase.C.

457 {
458  std::shared_ptr<Constraint> constraint = _factory.create<Constraint>(c_name, name, parameters);
459  _constraints.addObject(constraint);
460 
461  if (constraint && constraint->addCouplingEntriesToJacobian())
463 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
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:39
Factory & _factory
Definition: SystemBase.h:697
virtual const std::string & name() const
Definition: SystemBase.C:1022
ConstraintWarehouse _constraints
Constraints storage object.
void addObject(std::shared_ptr< Constraint > object, THREAD_ID tid=0, bool recurse=true)
Add Constraint object to the warehouse.

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

520 {
521  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
522  {
523  std::shared_ptr<Damper> damper = _factory.create<Damper>(damper_name, name, parameters, tid);
524 
525  // Attempt to cast to the damper types
526  std::shared_ptr<ElementDamper> ed = std::dynamic_pointer_cast<ElementDamper>(damper);
527  std::shared_ptr<NodalDamper> nd = std::dynamic_pointer_cast<NodalDamper>(damper);
528  std::shared_ptr<GeneralDamper> gd = std::dynamic_pointer_cast<GeneralDamper>(damper);
529 
530  if (gd)
531  {
533  break; // not threaded
534  }
535  else if (ed)
536  _element_dampers.addObject(ed, tid);
537  else if (nd)
538  _nodal_dampers.addObject(nd, tid);
539  else
540  mooseError("Invalid damper type");
541  }
542 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Base class for deriving general dampers.
Definition: GeneralDamper.h:27
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
Factory & _factory
Definition: SystemBase.h:697
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)
virtual const std::string & name() const
Definition: SystemBase.C:1022
Base class for deriving nodal dampers.
Definition: NodalDamper.h:33
Base class for deriving element dampers.
Definition: ElementDamper.h:34
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
Base class for deriving dampers.
Definition: Damper.h:30
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:126

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

482 {
483  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
484  {
485  std::shared_ptr<DGKernel> dg_kernel =
486  _factory.create<DGKernel>(dg_kernel_name, name, parameters, tid);
487  _dg_kernels.addObject(dg_kernel, tid);
488  }
489 
490  _doing_dg = true;
491 
492  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
493  _has_save_in = true;
494  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
495  _has_diag_save_in = true;
496 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
MooseObjectTagWarehouse< DGKernel > _dg_kernels
Factory & _factory
Definition: SystemBase.h:697
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
virtual const std::string & name() const
Definition: SystemBase.C:1022
bool _doing_dg
true if DG is active (optimization reasons)
The DGKernel class is responsible for calculating the residuals for various physics on internal sides...
Definition: DGKernel.h:42
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
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:126

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

469 {
470  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
471  {
472  std::shared_ptr<DiracKernel> kernel =
473  _factory.create<DiracKernel>(kernel_name, name, parameters, tid);
474  _dirac_kernels.addObject(kernel, tid);
475  }
476 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Factory & _factory
Definition: SystemBase.h:697
virtual const std::string & name() const
Definition: SystemBase.C:1022
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
A DiracKernel is used when you need to add contributions to the residual by means of multiplying some...
Definition: DiracKernel.h:46
MooseObjectTagWarehouse< DiracKernel > _dirac_kernels
Dirac Kernel storage for each thread.
unsigned int THREAD_ID
Definition: MooseTypes.h:126

◆ addDotVectors()

void NonlinearSystemBase::addDotVectors ( )
inherited

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

Definition at line 217 of file NonlinearSystemBase.C.

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

◆ addExtraVectors()

void NonlinearSystemBase::addExtraVectors ( )
overridevirtualinherited

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

Reimplemented from SystemBase.

Definition at line 237 of file NonlinearSystemBase.C.

238 {
240  _solution_previous_nl = &addVector("u_previous_newton", true, GHOSTED);
241 }
virtual NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const ParallelType type)
Adds a solution length vector to the system.
Definition: SystemBase.C:526
FEProblemBase & _fe_problem
void needsPreviousNewtonIteration(bool state)
Set a flag that indicated that user required values for the previous Newton iterate.
NumericVector< Number > * _solution_previous_nl
Solution vector of the previous nonlinear iterate.

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

Referenced by NonlinearSystemBase::computeJacobianInternal().

1659 {
1660  if (!hasMatrix(systemMatrixTag()))
1661  mooseError("Need a system matrix ");
1662 
1663  // At this point, have no idea how to make
1664  // this work with tag system
1665  auto & jacobian = getMatrix(systemMatrixTag());
1666 
1667  std::map<dof_id_type, std::vector<dof_id_type>> graph;
1668 
1669  findImplicitGeometricCouplingEntries(geom_search_data, graph);
1670 
1671  for (const auto & it : graph)
1672  {
1673  dof_id_type dof = it.first;
1674  const std::vector<dof_id_type> & row = it.second;
1675 
1676  for (const auto & coupled_dof : row)
1677  jacobian.add(dof, coupled_dof, 0);
1678  }
1679 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:781
void findImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data, std::map< dof_id_type, std::vector< dof_id_type >> &graph)
Finds the implicit sparsity graph between geometrically related dofs.
virtual TagID systemMatrixTag() override
Return the Matrix Tag ID for System.
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:787

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

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

433  {
435  }
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 499 of file NonlinearSystemBase.C.

502 {
503  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
504  {
505  std::shared_ptr<InterfaceKernel> interface_kernel =
506  _factory.create<InterfaceKernel>(interface_kernel_name, name, parameters, tid);
507 
508  const std::set<BoundaryID> & boundary_ids = interface_kernel->boundaryIDs();
509  _vars[tid].addBoundaryVar(boundary_ids, &interface_kernel->variable());
510 
511  _interface_kernels.addObject(interface_kernel, tid);
512  _vars[tid].addBoundaryVars(boundary_ids, interface_kernel->getCoupledVars());
513  }
514 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
MooseObjectTagWarehouse< InterfaceKernel > _interface_kernels
Factory & _factory
Definition: SystemBase.h:697
virtual const std::string & name() const
Definition: SystemBase.C:1022
InterfaceKernel is responsible for interfacing physics across subdomains.
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:704
virtual const std::set< BoundaryID > & boundaryIDs() const
Return the boundary IDs for this object.
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:126

◆ addKernel()

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

Adds a kernel.

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

Reimplemented from NonlinearSystemBase.

Definition at line 27 of file MooseEigenSystem.C.

30 {
31  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
32  {
33  // In the case of EigenKernels, we might need to add two to the system
34  if (parameters.have_parameter<bool>("eigen"))
35  {
36  {
37  // EigenKernel
38  parameters.set<bool>("implicit") = true;
39  std::shared_ptr<KernelBase> ekernel =
40  _factory.create<KernelBase>(kernel_name, name, parameters, tid);
41  if (parameters.get<bool>("eigen"))
42  markEigenVariable(parameters.get<NonlinearVariableName>("variable"));
43  _kernels.addObject(ekernel, tid);
44  }
45  if (parameters.get<bool>("eigen"))
46  {
47  // EigenKernel_old
48  parameters.set<bool>("implicit") = false;
49  std::string old_name(name + "_old");
50 
51  std::shared_ptr<KernelBase> ekernel =
52  _factory.create<KernelBase>(kernel_name, old_name, parameters, tid);
53  _eigen_var_names.insert(parameters.get<NonlinearVariableName>("variable"));
54  _kernels.addObject(ekernel, tid);
56  }
57  }
58  else // Standard nonlinear system kernel
59  {
60  // Create the kernel object via the factory
61  std::shared_ptr<KernelBase> kernel =
62  _factory.create<KernelBase>(kernel_name, name, parameters, tid);
63  _kernels.addObject(kernel, tid);
64  }
65  }
66 
67  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
68  _has_save_in = true;
69  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
70  _has_diag_save_in = true;
71 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
unsigned int _eigen_kernel_counter
counter of eigen kernels
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Factory & _factory
Definition: SystemBase.h:697
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
virtual const std::string & name() const
Definition: SystemBase.C:1022
This is the common base class for the two main kernel types implemented in MOOSE, EigenKernel and Ker...
Definition: KernelBase.h:45
MooseObjectTagWarehouse< KernelBase > _kernels
virtual void markEigenVariable(const VariableName &var_name)
Mark a variable as a variable of the eigen system.
std::set< VariableName > _eigen_var_names
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
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:126

◆ addMatrix()

SparseMatrix< Number > & NonlinearSystem::addMatrix ( TagID  )
overridevirtualinherited

Adds a jacobian sized vector.

Parameters
tag_nameThe name of the tag

Reimplemented from SystemBase.

Definition at line 116 of file NonlinearSystem.C.

117 {
118  if (!_subproblem.matrixTagExists(tag))
119  mooseError("Cannot add a tagged matrix with matrix_tag, ",
120  tag,
121  ", that tag does not exist in System ",
122  name());
123 
124  if (hasMatrix(tag))
125  return getMatrix(tag);
126 
127  auto matrix_name = _subproblem.matrixTagName(tag);
128 
129  SparseMatrix<Number> * mat = &_transient_sys.add_matrix(matrix_name);
130 
131  if (_tagged_matrices.size() < tag + 1)
132  _tagged_matrices.resize(tag + 1);
133 
134  _tagged_matrices[tag] = mat;
135 
136  return *mat;
137 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:717
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:781
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:119
virtual const std::string & name() const
Definition: SystemBase.C:1022
SubProblem & _subproblem
Definition: SystemBase.h:694
TransientNonlinearImplicitSystem & _transient_sys
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:787
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:148

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

360 {
361  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
362  {
363  // Create the kernel object via the factory and add to the warehouse
364  std::shared_ptr<NodalKernel> kernel =
365  _factory.create<NodalKernel>(kernel_name, name, parameters, tid);
366  _nodal_kernels.addObject(kernel, tid);
367  }
368 
369  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
370  _has_save_in = true;
371  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
372  _has_diag_save_in = true;
373 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Factory & _factory
Definition: SystemBase.h:697
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
virtual const std::string & name() const
Definition: SystemBase.C:1022
MooseObjectTagWarehouse< NodalKernel > _nodal_kernels
NodalKernels for each thread.
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
Base class for creating new types of boundary conditions.
Definition: NodalKernel.h:49
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:126

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

379 {
380  std::shared_ptr<ScalarKernel> kernel =
381  _factory.create<ScalarKernel>(kernel_name, name, parameters);
382  _scalar_kernels.addObject(kernel);
383 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Factory & _factory
Definition: SystemBase.h:697
virtual const std::string & name() const
Definition: SystemBase.C:1022
MooseObjectTagWarehouse< ScalarKernel > _scalar_kernels
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.

◆ addScalarVariable()

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

Adds a scalar variable.

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

Definition at line 628 of file SystemBase.C.

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

632 {
633  FEType type(order, SCALAR);
634  unsigned int var_num = system().add_variable(var_name, type, active_subdomains);
635  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
636  {
637  // FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in
638  // MooseVariableBase.
639  MooseVariableScalar * var =
640  new MooseVariableScalar(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
641  var->scalingFactor(scale_factor);
642  _vars[tid].add(var_name, var);
643  }
644  if (active_subdomains == nullptr)
645  _var_map[var_num] = std::set<SubdomainID>();
646  else
647  for (const auto subdomain_id : *active_subdomains)
648  _var_map[var_num].insert(subdomain_id);
649 }
virtual Assembly & assembly(THREAD_ID tid)=0
SubProblem & _subproblem
Definition: SystemBase.h:694
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:730
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:706
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:704
MatType type
Class for scalar variables (they are different).
unsigned int THREAD_ID
Definition: MooseTypes.h:126
void scalingFactor(Real factor)
Set the scaling factor for this variable.

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

548 {
549  std::shared_ptr<Split> split = _factory.create<Split>(split_name, name, parameters);
551 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Base class for split-based preconditioners.
Definition: Split.h:30
Factory & _factory
Definition: SystemBase.h:697
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.
std::vector< std::string > split(const std::string &str, const std::string &delimiter)
Python like split function for strings.
Definition: MooseUtils.C:784
virtual const std::string & name() const
Definition: SystemBase.C:1022
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 323 of file NonlinearSystemBase.C.

326 {
327  parameters.set<SystemBase *>("_sys") = this;
328 
329  std::shared_ptr<TimeIntegrator> ti = _factory.create<TimeIntegrator>(type, name, parameters);
330  _time_integrator = ti;
331 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Factory & _factory
Definition: SystemBase.h:697
Base class for a system (of equations)
Definition: SystemBase.h:93
virtual const std::string & name() const
Definition: SystemBase.C:1022
MatType type
Base class for time integrators.
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:741

◆ addTimeIntegrator() [2/4]

virtual void SystemBase::addTimeIntegrator
inlineinherited

Definition at line 681 of file SystemBase.h.

684  {
685  }

◆ addTimeIntegrator() [3/4]

virtual void SystemBase::addTimeIntegrator
inlineinherited

Definition at line 687 of file SystemBase.h.

687 {}

◆ addTimeIntegrator() [4/4]

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

Reimplemented in DisplacedSystem.

Definition at line 687 of file SystemBase.h.

687 {}

◆ addVariable()

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

Adds a variable to the system.

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

Reimplemented in AuxiliarySystem.

Definition at line 597 of file SystemBase.C.

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

601 {
602  unsigned int var_num = system().add_variable(var_name, type, active_subdomains);
603  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
604  {
605  // FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in
606  // MooseVariableBase.
607  MooseVariableBase * var;
608  if (type == FEType(0, MONOMIAL))
609  var = new MooseVariableConstMonomial(
610  var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
611  else if (type == FEType(FIRST, NEDELEC_ONE) || type.family == LAGRANGE_VEC)
612  var =
613  new VectorMooseVariable(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
614  else
615  var = new MooseVariable(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
616 
617  var->scalingFactor(scale_factor);
618  _vars[tid].add(var_name, var);
619  }
620  if (active_subdomains == nullptr)
621  _var_map[var_num] = std::set<SubdomainID>();
622  else
623  for (const auto subdomain_id : *active_subdomains)
624  _var_map[var_num].insert(subdomain_id);
625 }
virtual Assembly & assembly(THREAD_ID tid)=0
MooseVariableFE< Real > MooseVariable
Definition: Adaptivity.h:30
SubProblem & _subproblem
Definition: SystemBase.h:694
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:730
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:706
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:704
MatType type
MooseVariableFE< VectorValue< Real > > VectorMooseVariable
Definition: Adaptivity.h:32
unsigned int THREAD_ID
Definition: MooseTypes.h:126
void scalingFactor(Real factor)
Set the scaling factor for this variable.

◆ addVariableToCopy()

void SystemBase::addVariableToCopy ( const std::string &  dest_name,
const std::string &  source_name,
const std::string &  timestep 
)
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 906 of file SystemBase.C.

909 {
910  _var_to_copy.push_back(VarCopyInfo(dest_name, source_name, timestep));
911 }
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:732
Information about variables that will be copied.
Definition: SystemBase.h:75

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

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

185 {
186  _vars_to_be_zeroed_on_jacobian.push_back(var_name);
187 }
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
Definition: SystemBase.h:709

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

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

179 {
180  _vars_to_be_zeroed_on_residual.push_back(var_name);
181 }
std::vector< std::string > _vars_to_be_zeroed_on_residual
Definition: SystemBase.h:708

◆ addVector() [1/2]

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

Adds a solution length vector to the system.

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

Reimplemented in AuxiliarySystem.

Definition at line 526 of file SystemBase.C.

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

527 {
528  if (hasVector(vector_name))
529  return getVector(vector_name);
530 
531  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
532  return vec;
533 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:685
virtual System & system()=0
Get the reference to the libMesh system.
MatType type
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:735

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

537 {
538  if (!_subproblem.vectorTagExists(tag))
539  mooseError("Cannot add a tagged vector with vector_tag, ",
540  tag,
541  ", that tag does not exist in System ",
542  name());
543 
544  if (hasVector(tag))
545  return getVector(tag);
546 
547  auto vector_name = _subproblem.vectorTagName(tag);
548 
549  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
550 
551  if (_tagged_vectors.size() < tag + 1)
552  _tagged_vectors.resize(tag + 1);
553 
554  _tagged_vectors[tag] = &vec;
555 
556  return vec;
557 }
virtual TagName vectorTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:96
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:685
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
virtual const std::string & name() const
Definition: SystemBase.C:1022
SubProblem & _subproblem
Definition: SystemBase.h:694
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:107
virtual System & system()=0
Get the reference to the libMesh system.
MatType type
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:715
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:735

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

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

◆ assignMaxVarNDofsPerElem()

void SystemBase::assignMaxVarNDofsPerElem ( const size_t &  max_dofs)
inlineinherited

assign the maximum element dofs

Definition at line 425 of file SystemBase.h.

425 { _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:735

◆ assignMaxVarNDofsPerNode()

void SystemBase::assignMaxVarNDofsPerNode ( const size_t &  max_dofs)
inlineinherited

assign the maximum node dofs

Definition at line 430 of file SystemBase.h.

430 { _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:738

◆ associateMatrixToTag()

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

associate a matirx to a tag

Reimplemented in DisplacedSystem.

Definition at line 803 of file SystemBase.C.

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

804 {
805  mooseAssert(_subproblem.matrixTagExists(tag),
806  "Cannot associate Matrix with matrix_tag : " << tag << "that does not exist");
807 
808  if (_tagged_matrices.size() < tag + 1)
809  _tagged_matrices.resize(tag + 1);
810 
811  _tagged_matrices[tag] = &matrix;
812 }
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:717
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:119
SubProblem & _subproblem
Definition: SystemBase.h:694

◆ associateVectorToTag()

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

Associate a vector for a given tag.

Reimplemented in DisplacedSystem.

Definition at line 749 of file SystemBase.C.

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

750 {
751  mooseAssert(_subproblem.vectorTagExists(tag),
752  "You can't associate a tag that does not exist " << tag);
753  if (_tagged_vectors.size() < tag + 1)
754  _tagged_vectors.resize(tag + 1);
755 
756  _tagged_vectors[tag] = &vec;
757 }
SubProblem & _subproblem
Definition: SystemBase.h:694
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:107
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:715

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

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

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

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

2789 {
2791  {
2793 
2794  std::map<dof_id_type, std::vector<dof_id_type>> graph;
2795 
2797 
2800  graph);
2801 
2802  const dof_id_type first_dof_on_proc = dofMap().first_dof(processor_id());
2803  const dof_id_type end_dof_on_proc = dofMap().end_dof(processor_id());
2804 
2805  // The total number of dofs on and off processor
2806  const dof_id_type n_dofs_on_proc = dofMap().n_local_dofs();
2807  const dof_id_type n_dofs_not_on_proc = dofMap().n_dofs() - dofMap().n_local_dofs();
2808 
2809  for (const auto & git : graph)
2810  {
2811  dof_id_type dof = git.first;
2812  dof_id_type local_dof = dof - first_dof_on_proc;
2813 
2814  if (dof < first_dof_on_proc || dof >= end_dof_on_proc)
2815  continue;
2816 
2817  const std::vector<dof_id_type> & row = git.second;
2818 
2819  SparsityPattern::Row & sparsity_row = sparsity[local_dof];
2820 
2821  unsigned int original_row_length = sparsity_row.size();
2822 
2823  sparsity_row.insert(sparsity_row.end(), row.begin(), row.end());
2824 
2825  SparsityPattern::sort_row(
2826  sparsity_row.begin(), sparsity_row.begin() + original_row_length, sparsity_row.end());
2827 
2828  // Fix up nonzero arrays
2829  for (const auto & coupled_dof : row)
2830  {
2831  if (coupled_dof < first_dof_on_proc || coupled_dof >= end_dof_on_proc)
2832  {
2833  if (n_oz[local_dof] < n_dofs_not_on_proc)
2834  n_oz[local_dof]++;
2835  }
2836  else
2837  {
2838  if (n_nz[local_dof] < n_dofs_on_proc)
2839  n_nz[local_dof]++;
2840  }
2841  }
2842  }
2843  }
2844 }
void findImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data, std::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 the dof map.
Definition: SystemBase.C:900
FEProblemBase & _fe_problem
virtual std::shared_ptr< DisplacedProblem > getDisplacedProblem()
const std::vector< numeric_index_type > & n_nz
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.
const std::vector< numeric_index_type > & n_oz

◆ buildSystemDoFIndices()

void MooseEigenSystem::buildSystemDoFIndices ( SYSTEMTAG  tag = ALL)

Build DoF indices for a system.

Definition at line 226 of file MooseEigenSystem.C.

Referenced by EigenExecutionerBase::init().

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

◆ checkKernelCoverage()

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

System Integrity Checks

Definition at line 2936 of file NonlinearSystemBase.C.

2937 {
2938  // Check kernel coverage of subdomains (blocks) in your mesh
2939  std::set<SubdomainID> input_subdomains;
2940  std::set<std::string> kernel_variables;
2941 
2942  bool global_kernels_exist = _kernels.hasActiveBlockObjects(Moose::ANY_BLOCK_ID);
2943  global_kernels_exist |= _scalar_kernels.hasActiveObjects();
2944  global_kernels_exist |= _nodal_kernels.hasActiveObjects();
2945 
2946  _kernels.subdomainsCovered(input_subdomains, kernel_variables);
2947  _nodal_kernels.subdomainsCovered(input_subdomains, kernel_variables);
2948  _scalar_kernels.subdomainsCovered(input_subdomains, kernel_variables);
2949  _constraints.subdomainsCovered(input_subdomains, kernel_variables);
2950 
2951  if (!global_kernels_exist)
2952  {
2953  std::set<SubdomainID> difference;
2954  std::set_difference(mesh_subdomains.begin(),
2955  mesh_subdomains.end(),
2956  input_subdomains.begin(),
2957  input_subdomains.end(),
2958  std::inserter(difference, difference.end()));
2959 
2960  if (!difference.empty())
2961  {
2962  std::stringstream missing_block_ids;
2963  std::copy(difference.begin(),
2964  difference.end(),
2965  std::ostream_iterator<unsigned int>(missing_block_ids, " "));
2966  mooseError("Each subdomain must contain at least one Kernel.\nThe following block(s) lack an "
2967  "active kernel: " +
2968  missing_block_ids.str());
2969  }
2970  }
2971 
2972  std::set<VariableName> variables(getVariableNames().begin(), getVariableNames().end());
2973 
2974  std::set<VariableName> difference;
2975  std::set_difference(variables.begin(),
2976  variables.end(),
2977  kernel_variables.begin(),
2978  kernel_variables.end(),
2979  std::inserter(difference, difference.end()));
2980 
2981  if (!difference.empty())
2982  {
2983  std::stringstream missing_kernel_vars;
2984  std::copy(difference.begin(),
2985  difference.end(),
2986  std::ostream_iterator<std::string>(missing_kernel_vars, " "));
2987  mooseError("Each variable must be referenced by at least one active Kernel.\nThe following "
2988  "variable(s) lack an active kernel: " +
2989  missing_kernel_vars.str());
2990  }
2991 }
bool hasActiveBlockObjects(THREAD_ID tid=0) const
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
MooseObjectTagWarehouse< ScalarKernel > _scalar_kernels
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
ConstraintWarehouse _constraints
Constraints storage object.
MooseObjectTagWarehouse< NodalKernel > _nodal_kernels
NodalKernels for each thread.
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:15
bool hasActiveObjects(THREAD_ID tid=0) const
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:670
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.

◆ closeTaggedMatrices()

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

Close all matrices associated the tags.

Definition at line 795 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

796 {
797  for (auto tag : tags)
798  if (hasMatrix(tag))
799  getMatrix(tag).close();
800 }
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:781
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:787

◆ closeTaggedVectors()

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

Close all vectors for given tags.

Definition at line 560 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTags().

561 {
562  for (auto & tag : tags)
563  {
564  mooseAssert(_subproblem.vectorTagExists(tag), "Tag: " << tag << " does not exsit");
565  getVector(tag).close();
566  }
567 }
SubProblem & _subproblem
Definition: SystemBase.h:694
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:107
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:735

◆ combineSystemSolution()

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

Linear combination of the solution vectors.

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

Definition at line 103 of file MooseEigenSystem.C.

Referenced by EigenExecutionerBase::chebyshev().

104 {
105  mooseAssert(coefficients.size() > 0 && coefficients.size() <= 3, "Size error on coefficients");
106  if (tag == ALL)
107  {
108  solution().scale(coefficients[0]);
109  if (coefficients.size() > 1)
110  solution().add(coefficients[1], solutionOld());
111  if (coefficients.size() > 2)
112  solution().add(coefficients[2], solutionOlder());
113  }
114  else if (tag == EIGEN)
115  {
116  if (_all_eigen_vars)
117  {
118  solution().scale(coefficients[0]);
119  if (coefficients.size() > 1)
120  solution().add(coefficients[1], solutionOld());
121  if (coefficients.size() > 2)
122  solution().add(coefficients[2], solutionOlder());
123  }
124  else
125  {
126  if (coefficients.size() > 2)
127  {
128  for (const auto & dof : _eigen_var_indices)
129  {
130  Real t = solution()(dof) * coefficients[0];
131  t += solutionOld()(dof) * coefficients[1];
132  t += solutionOlder()(dof) * coefficients[2];
133  solution().set(dof, t);
134  }
135  }
136  else if (coefficients.size() > 1)
137  {
138  for (const auto & dof : _eigen_var_indices)
139  {
140  Real t = solution()(dof) * coefficients[0];
141  t += solutionOld()(dof) * coefficients[1];
142  solution().set(dof, t);
143  }
144  }
145  else
146  {
147  for (const auto & dof : _eigen_var_indices)
148  {
149  Real t = solution()(dof) * coefficients[0];
150  solution().set(dof, t);
151  }
152  }
153  }
154  }
155  solution().close();
156  update();
157 }
virtual NumericVector< Number > & solutionOld() override
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:954
virtual NumericVector< Number > & solution() override
virtual NumericVector< Number > & solutionOlder() override
std::set< dof_id_type > _eigen_var_indices

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

2679 {
2680  // Default to no damping
2681  Real damping = 1.0;
2682  bool has_active_dampers = false;
2683 
2685  {
2686  TIME_SECTION(_compute_dampers_timer);
2687 
2688  has_active_dampers = true;
2691  Threads::parallel_reduce(*_mesh.getActiveLocalElementRange(), cid);
2692  damping = std::min(cid.damping(), damping);
2693  }
2694 
2696  {
2697  TIME_SECTION(_compute_dampers_timer);
2698 
2699  has_active_dampers = true;
2702  Threads::parallel_reduce(*_mesh.getLocalNodeRange(), cndt);
2703  damping = std::min(cndt.damping(), damping);
2704  }
2705 
2707  {
2708  TIME_SECTION(_compute_dampers_timer);
2709 
2710  has_active_dampers = true;
2711  const auto & gdampers = _general_dampers.getActiveObjects();
2712  for (const auto & damper : gdampers)
2713  {
2714  Real gd_damping = damper->computeDamping(solution, update);
2715  try
2716  {
2717  damper->checkMinDamping(gd_damping);
2718  }
2719  catch (MooseException & e)
2720  {
2722  }
2723  damping = std::min(gd_damping, damping);
2724  }
2725  }
2726 
2727  _communicator.min(damping);
2728 
2729  if (has_active_dampers && damping < 1.0)
2730  _console << " Damping factor: " << damping << "\n";
2731 
2732  return damping;
2733 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:738
virtual const char * what() const
Get out the error message.
virtual void setException(const std::string &message)
Set an exception.
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
ConstNodeRange * getLocalNodeRange()
Definition: MooseMesh.C:775
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:954
virtual NumericVector< Number > & solution() override
FEProblemBase & _fe_problem
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...
Provides a way for users to bail out of the current solve.
MooseMesh & _mesh
Definition: SystemBase.h:699
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.

◆ computeDiracContributions()

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

Definition at line 2736 of file NonlinearSystemBase.C.

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

2737 {
2739 
2740  std::set<const Elem *> dirac_elements;
2741 
2743  {
2744  TIME_SECTION(_compute_dirac_timer);
2745 
2746  // TODO: Need a threading fix... but it's complicated!
2747  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
2748  {
2749  const auto & dkernels = _dirac_kernels.getActiveObjects(tid);
2750  for (const auto & dkernel : dkernels)
2751  {
2752  dkernel->clearPoints();
2753  dkernel->addPoints();
2754  }
2755  }
2756 
2757  ComputeDiracThread cd(_fe_problem, tags, is_jacobian);
2758 
2759  _fe_problem.getDiracElements(dirac_elements);
2760 
2761  DistElemRange range(dirac_elements.begin(), dirac_elements.end(), 1);
2762  // TODO: Make Dirac work thread!
2763  // Threads::parallel_reduce(range, cd);
2764 
2765  cd(range);
2766  }
2767 }
virtual void getDiracElements(std::set< const Elem *> &elems) override
Fills "elems" with the elements that should be looped over for Dirac Kernels.
FEProblemBase & _fe_problem
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...
StoredRange< std::set< const Elem * >::const_iterator, const Elem * > DistElemRange
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectTagWarehouse< DiracKernel > _dirac_kernels
Dirac Kernel storage for each thread.
unsigned int THREAD_ID
Definition: MooseTypes.h:126

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

Referenced by NonlinearSystemBase::computeJacobian().

2510 {
2512 
2513  computeJacobianTags(tags);
2514 
2516 }
virtual TagID systemMatrixTag() 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 matirx to a tag
Definition: SystemBase.C:803
virtual void disassociateMatrixFromTag(SparseMatrix< Number > &matrix, TagID tag)
disassociate a matirx from a tag
Definition: SystemBase.C:815

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

2497 {
2498  _nl_matrix_tags.clear();
2499 
2500  auto & tags = _fe_problem.getMatrixTags();
2501 
2502  for (auto & tag : tags)
2503  _nl_matrix_tags.insert(tag.second);
2504 
2505  computeJacobian(jacobian, _nl_matrix_tags);
2506 }
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.
FEProblemBase & _fe_problem
virtual std::map< TagName, TagID > & getMatrixTags()
Return all matrix tags in the sytem, where a tag is represented by a map from name to ID...
Definition: SubProblem.h:157

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

2539 {
2540  _nl_matrix_tags.clear();
2541 
2542  auto & tags = _fe_problem.getMatrixTags();
2543  for (auto & tag : tags)
2544  _nl_matrix_tags.insert(tag.second);
2545 
2547 }
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.
FEProblemBase & _fe_problem
virtual std::map< TagName, TagID > & getMatrixTags()
Return all matrix tags in the sytem, where a tag is represented by a map from name to ID...
Definition: SubProblem.h:157

◆ computeJacobianBlocks() [2/2]

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

Definition at line 2550 of file NonlinearSystemBase.C.

2552 {
2553  TIME_SECTION(_compute_jacobian_blocks_timer);
2554 
2555  FloatingPointExceptionGuard fpe_guard(_app);
2556 
2557  for (unsigned int i = 0; i < blocks.size(); i++)
2558  {
2559  SparseMatrix<Number> & jacobian = blocks[i]->_jacobian;
2560 
2561 #ifdef LIBMESH_HAVE_PETSC
2562 // Necessary for speed
2563 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
2564  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
2565 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
2566  // In Petsc 3.0.0, MatSetOption has three args...the third arg
2567  // determines whether the option is set (true) or unset (false)
2568  MatSetOption(
2569  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
2570 #else
2571  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2572  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2573  PETSC_TRUE);
2574 #endif
2575 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
2576 #else
2578  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2579  MAT_NEW_NONZERO_ALLOCATION_ERR,
2580  PETSC_FALSE);
2581 #endif
2582 
2583 #endif
2584 
2585  jacobian.zero();
2586  }
2587 
2588  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
2590 
2591  PARALLEL_TRY
2592  {
2593  ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
2594  ComputeJacobianBlocksThread cjb(_fe_problem, blocks, tags);
2595  Threads::parallel_reduce(elem_range, cjb);
2596  }
2597  PARALLEL_CATCH;
2598 
2599  for (unsigned int i = 0; i < blocks.size(); i++)
2600  blocks[i]->_jacobian.close();
2601 
2602  for (unsigned int i = 0; i < blocks.size(); i++)
2603  {
2604  libMesh::System & precond_system = blocks[i]->_precond_system;
2605  SparseMatrix<Number> & jacobian = blocks[i]->_jacobian;
2606 
2607  unsigned int ivar = blocks[i]->_ivar;
2608  unsigned int jvar = blocks[i]->_jvar;
2609 
2610  // Dirichlet BCs
2611  std::vector<numeric_index_type> zero_rows;
2612  PARALLEL_TRY
2613  {
2614  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
2615  for (const auto & bnode : bnd_nodes)
2616  {
2617  BoundaryID boundary_id = bnode->_bnd_id;
2618  Node * node = bnode->_node;
2619 
2620  if (_nodal_bcs.hasActiveBoundaryObjects(boundary_id))
2621  {
2622  const auto & bcs = _nodal_bcs.getActiveBoundaryObjects(boundary_id);
2623 
2624  if (node->processor_id() == processor_id())
2625  {
2626  _fe_problem.reinitNodeFace(node, boundary_id, 0);
2627 
2628  for (const auto & bc : bcs)
2629  if (bc->variable().number() == ivar && bc->shouldApply())
2630  {
2631  // The first zero is for the variable number... there is only one variable in each
2632  // mini-system
2633  // The second zero only works with Lagrange elements!
2634  zero_rows.push_back(node->dof_number(precond_system.number(), 0, 0));
2635  }
2636  }
2637  }
2638  }
2639  }
2640  PARALLEL_CATCH;
2641 
2642  jacobian.close();
2643 
2644  // This zeroes the rows corresponding to Dirichlet BCs and puts a 1.0 on the diagonal
2645  if (ivar == jvar)
2646  jacobian.zero_rows(zero_rows, 1.0);
2647  else
2648  jacobian.zero_rows(zero_rows, 0.0);
2649 
2650  jacobian.close();
2651  }
2652 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:738
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
FEProblemBase & _fe_problem
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 reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid) override
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
MooseApp & _app
Definition: SystemBase.h:696
virtual void reinitScalars(THREAD_ID tid) override
MooseMesh & _mesh
Definition: SystemBase.h:699
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:1268
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:789
boundary_id_type BoundaryID
Definition: MooseTypes.h:122

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

Referenced by NonlinearSystemBase::computeJacobianTags().

2199 {
2200  // Make matrix ready to use
2202 
2203  for (auto tag : tags)
2204  {
2205  if (!hasMatrix(tag))
2206  continue;
2207 
2208  auto & jacobian = getMatrix(tag);
2209 #ifdef LIBMESH_HAVE_PETSC
2210 // Necessary for speed
2211 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
2212  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
2213 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
2214  // In Petsc 3.0.0, MatSetOption has three args...the third arg
2215  // determines whether the option is set (true) or unset (false)
2216  MatSetOption(
2217  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
2218 #else
2219  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2220  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2221  PETSC_TRUE);
2222 #endif
2223 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
2224 #else
2226  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2227  MAT_NEW_NONZERO_ALLOCATION_ERR,
2228  PETSC_FALSE);
2229 #endif
2230 
2231 #endif
2232  }
2233  // jacobianSetup /////
2234  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
2235  {
2236  _kernels.jacobianSetup(tid);
2240  if (_doing_dg)
2246  }
2251 
2252  // reinit scalar variables
2253  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
2255 
2256  PARALLEL_TRY
2257  {
2258  ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
2259  switch (_fe_problem.coupling())
2260  {
2261  case Moose::COUPLING_DIAG:
2262  {
2264  Threads::parallel_reduce(elem_range, cj);
2265 
2266  unsigned int n_threads = libMesh::n_threads();
2267  for (unsigned int i = 0; i < n_threads;
2268  i++) // Add any Jacobian contributions still hanging around
2270 
2271  // Block restricted Nodal Kernels
2273  {
2275  ConstNodeRange & range = *_mesh.getLocalNodeRange();
2276  Threads::parallel_reduce(range, cnkjt);
2277 
2278  unsigned int n_threads = libMesh::n_threads();
2279  for (unsigned int i = 0; i < n_threads;
2280  i++) // Add any cached jacobians that might be hanging around
2282  }
2283 
2284  // Boundary restricted Nodal Kernels
2286  {
2288  ConstBndNodeRange & bnd_range = *_mesh.getBoundaryNodeRange();
2289 
2290  Threads::parallel_reduce(bnd_range, cnkjt);
2291  unsigned int n_threads = libMesh::n_threads();
2292  for (unsigned int i = 0; i < n_threads;
2293  i++) // Add any cached jacobians that might be hanging around
2295  }
2296  }
2297  break;
2298 
2299  default:
2301  {
2303  Threads::parallel_reduce(elem_range, cj);
2304  unsigned int n_threads = libMesh::n_threads();
2305 
2306  for (unsigned int i = 0; i < n_threads; i++)
2308 
2309  // Block restricted Nodal Kernels
2311  {
2313  ConstNodeRange & range = *_mesh.getLocalNodeRange();
2314  Threads::parallel_reduce(range, cnkjt);
2315 
2316  unsigned int n_threads = libMesh::n_threads();
2317  for (unsigned int i = 0; i < n_threads;
2318  i++) // Add any cached jacobians that might be hanging around
2320  }
2321 
2322  // Boundary restricted Nodal Kernels
2324  {
2326  ConstBndNodeRange & bnd_range = *_mesh.getBoundaryNodeRange();
2327 
2328  Threads::parallel_reduce(bnd_range, cnkjt);
2329 
2330  unsigned int n_threads = libMesh::n_threads();
2331  for (unsigned int i = 0; i < n_threads;
2332  i++) // Add any cached jacobians that might be hanging around
2334  }
2335  }
2336  break;
2337  }
2338 
2339  computeDiracContributions(tags, true);
2340 
2342 
2343  static bool first = true;
2344 
2345  // This adds zeroes into geometric coupling entries to ensure they stay in the matrix
2347  {
2348  first = false;
2350 
2353  }
2354  }
2355  PARALLEL_CATCH;
2356 
2357  closeTaggedMatrices(tags);
2358 
2359  // Have no idea how to have constraints work
2360  // with the tag system
2361  PARALLEL_TRY
2362  {
2363  // Add in Jacobian contributions from Constraints
2365  {
2366  // Nodal Constraints
2368 
2369  // Undisplaced Constraints
2370  constraintJacobians(false);
2371 
2372  // Displaced Constraints
2374  constraintJacobians(true);
2375  }
2376  }
2377  PARALLEL_CATCH;
2379  closeTaggedMatrices(tags);
2380 
2381  // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs on
2382  // boundary nodes
2383  if (_has_diag_save_in)
2385 
2386  PARALLEL_TRY
2387  {
2388  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
2389  // Select nodal kernels
2390  if (tags.size() == _fe_problem.numMatrixTags() || !tags.size())
2391  nbc_warehouse = &_nodal_bcs;
2392  else if (tags.size() == 1)
2393  nbc_warehouse = &(_nodal_bcs.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2394  else
2395  nbc_warehouse = &(_nodal_bcs.getMatrixTagsObjectWarehouse(tags, 0));
2396 
2397  // Cache the information about which BCs are coupled to which
2398  // variables, so we don't have to figure it out for each node.
2399  std::map<std::string, std::set<unsigned int>> bc_involved_vars;
2400  const std::set<BoundaryID> & all_boundary_ids = _mesh.getBoundaryIDs();
2401  for (const auto & bid : all_boundary_ids)
2402  {
2403  // Get reference to all the NodalBCs for this ID. This is only
2404  // safe if there are NodalBCBases there to be gotten...
2405  if (nbc_warehouse->hasActiveBoundaryObjects(bid))
2406  {
2407  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(bid);
2408  for (const auto & bc : bcs)
2409  {
2410  const std::vector<MooseVariableFEBase *> & coupled_moose_vars = bc->getCoupledMooseVars();
2411 
2412  // Create the set of "involved" MOOSE nonlinear vars, which includes all coupled vars and
2413  // the BC's own variable
2414  std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2415  for (const auto & coupled_var : coupled_moose_vars)
2416  if (coupled_var->kind() == Moose::VAR_NONLINEAR)
2417  var_set.insert(coupled_var->number());
2418 
2419  var_set.insert(bc->variable().number());
2420  }
2421  }
2422  }
2423 
2424  // Get variable coupling list. We do all the NodalBCBase stuff on
2425  // thread 0... The couplingEntries() data structure determines
2426  // which variables are "coupled" as far as the preconditioner is
2427  // concerned, not what variables a boundary condition specifically
2428  // depends on.
2429  std::vector<std::pair<MooseVariableFEBase *, MooseVariableFEBase *>> & coupling_entries =
2430  _fe_problem.couplingEntries(/*_tid=*/0);
2431 
2432  // Compute Jacobians for NodalBCBases
2433  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
2434  for (const auto & bnode : bnd_nodes)
2435  {
2436  BoundaryID boundary_id = bnode->_bnd_id;
2437  Node * node = bnode->_node;
2438 
2439  if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id) &&
2440  node->processor_id() == processor_id())
2441  {
2442  _fe_problem.reinitNodeFace(node, boundary_id, 0);
2443 
2444  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
2445  for (const auto & bc : bcs)
2446  {
2447  // Get the set of involved MOOSE vars for this BC
2448  std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2449 
2450  // Loop over all the variables whose Jacobian blocks are
2451  // actually being computed, call computeOffDiagJacobian()
2452  // for each one which is actually coupled (otherwise the
2453  // value is zero.)
2454  for (const auto & it : coupling_entries)
2455  {
2456  unsigned int ivar = it.first->number(), jvar = it.second->number();
2457 
2458  // We are only going to call computeOffDiagJacobian() if:
2459  // 1.) the BC's variable is ivar
2460  // 2.) jvar is "involved" with the BC (including jvar==ivar), and
2461  // 3.) the BC should apply.
2462  if ((bc->variable().number() == ivar) && var_set.count(jvar) && bc->shouldApply())
2463  bc->computeOffDiagJacobian(jvar);
2464  }
2465  }
2466  }
2467  } // end loop over boundary nodes
2468 
2469  // Set the cached NodalBCBase values in the Jacobian matrix
2471  }
2472  PARALLEL_CATCH;
2473 
2474  closeTaggedMatrices(tags);
2475 
2476  // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs on
2477  // boundary nodes
2480 
2481  if (hasDiagSaveIn())
2483 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:738
MooseObjectTagWarehouse< DGKernel > _dg_kernels
bool hasActiveBlockObjects(THREAD_ID tid=0) const
virtual Assembly & assembly(THREAD_ID tid) override
MooseObjectTagWarehouse< InterfaceKernel > _interface_kernels
bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:781
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
bool hasDiagSaveIn() const
Weather or not the nonlinear system has diagonal Jacobian save-ins.
ConstNodeRange * getLocalNodeRange()
Definition: MooseMesh.C:775
std::vector< std::pair< MooseVariableFEBase *, MooseVariableFEBase * > > & couplingEntries(THREAD_ID tid)
virtual GeometricSearchData & geomSearchData() override
MooseObjectTagWarehouse< KernelBase > _ad_jacobian_kernels
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:954
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
Definition: SystemBase.C:795
virtual void addCachedJacobian(THREAD_ID tid) override
bool _doing_dg
true if DG is active (optimization reasons)
FEProblemBase & _fe_problem
virtual std::shared_ptr< DisplacedProblem > getDisplacedProblem()
void computeDiracContributions(const std::set< TagID > &tags, bool is_jacobian)
MooseObjectTagWarehouse< ScalarKernel > _scalar_kernels
void addImplicitGeometricCouplingEntries(GeometricSearchData &geom_search_data)
Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled th...
MooseObjectTagWarehouse< KernelBase > _kernels
MooseObjectWarehouse< T > & getMatrixTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given matrix tag...
bool errorOnJacobianNonzeroReallocation() const
Will return True if the user wants to get an error when a nonzero is reallocated in the Jacobian by P...
virtual void activeAllMatrixTags()
Make all exsiting matrices ative.
Definition: SystemBase.C:865
AuxiliarySystem & getAuxiliarySystem()
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid) override
virtual void jacobianSetup(THREAD_ID tid=0) const
ConstraintWarehouse _constraints
Constraints storage object.
MooseObjectTagWarehouse< NodalKernel > _nodal_kernels
NodalKernels for each thread.
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 NumericVector< Number > & solution() override
virtual void reinitScalars(THREAD_ID tid) override
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
void constraintJacobians(bool displaced)
Add jacobian contributions from Constraints.
MooseMesh & _mesh
Definition: SystemBase.h:699
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:787
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)
Moose::CouplingType coupling()
void addCachedJacobianContributions()
Adds previously-cached Jacobian values via SparseMatrix::add() calls.
Definition: Assembly.C:2981
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:2148
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:1268
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:152
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:789
MooseObjectTagWarehouse< DiracKernel > _dirac_kernels
Dirac Kernel storage for each thread.
boundary_id_type BoundaryID
Definition: MooseTypes.h:122
unsigned int THREAD_ID
Definition: MooseTypes.h:126
void setCachedJacobianContributions()
Sets previously-cached Jacobian values via SparseMatrix::set() calls.
Definition: Assembly.C:2947

◆ computeJacobianTags()

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

Computes multiple (tag associated) Jacobian matricese.

Definition at line 2519 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobian().

2520 {
2521  TIME_SECTION(_compute_jacobian_tags_timer);
2522 
2523  FloatingPointExceptionGuard fpe_guard(_app);
2524 
2525  try
2526  {
2528  }
2529  catch (MooseException & e)
2530  {
2531  // The buck stops here, we have already handled the exception by
2532  // calling stopSolve(), it is now up to PETSc to return a
2533  // "diverged" reason during the next solve.
2534  }
2535 }
Scope guard for starting and stopping Floating Point Exception Trapping.
MooseApp & _app
Definition: SystemBase.h:696
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 1458 of file NonlinearSystemBase.C.

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

1459 {
1460  _nl_vector_tags.clear();
1461 
1462  auto & tags = _fe_problem.getVectorTags();
1463  for (auto & tag : tags)
1464  _nl_vector_tags.insert(tag.second);
1465 
1467  computeNodalBCs(residual, _nl_vector_tags);
1469 }
virtual std::map< TagName, TagID > & getVectorTags()
Return all vector tags, where a tag is represented by a map from name to ID.
Definition: SubProblem.h:102
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:760
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:749
virtual TagID residualVectorTag() override
FEProblemBase & _fe_problem
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 1472 of file NonlinearSystemBase.C.

1473 {
1475 
1476  computeNodalBCs(tags);
1477 
1479 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:760
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:749
virtual TagID residualVectorTag() 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 1482 of file NonlinearSystemBase.C.

1483 {
1484  // We need to close the diag_save_in variables on the aux system before NodalBCBases clear the
1485  // dofs on boundary nodes
1486  if (_has_save_in)
1488 
1489  PARALLEL_TRY
1490  {
1491  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
1492 
1493  if (!bnd_nodes.empty())
1494  {
1495  TIME_SECTION(_nodal_bcs_timer);
1496 
1497  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
1498 
1499  // Select nodal kernels
1500  if (tags.size() == _fe_problem.numVectorTags() || !tags.size())
1501  nbc_warehouse = &_nodal_bcs;
1502  else if (tags.size() == 1)
1503  nbc_warehouse = &(_nodal_bcs.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1504  else
1505  nbc_warehouse = &(_nodal_bcs.getVectorTagsObjectWarehouse(tags, 0));
1506 
1507  for (const auto & bnode : bnd_nodes)
1508  {
1509  BoundaryID boundary_id = bnode->_bnd_id;
1510  Node * node = bnode->_node;
1511 
1512  if (node->processor_id() == processor_id())
1513  {
1514  // reinit variables in nodes
1515  _fe_problem.reinitNodeFace(node, boundary_id, 0);
1516  if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id))
1517  {
1518  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
1519  for (const auto & nbc : bcs)
1520  if (nbc->shouldApply())
1521  nbc->computeResidual();
1522  }
1523  }
1524  }
1525  }
1526  }
1527  PARALLEL_CATCH;
1528 
1529  if (_Re_time)
1530  _Re_time->close();
1531  _Re_non_time->close();
1532 }
NumericVector< Number > * _Re_time
residual vector for time contributions
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
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...
virtual unsigned int numVectorTags()
The total number of tags.
Definition: SubProblem.h:117
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
FEProblemBase & _fe_problem
AuxiliarySystem & getAuxiliarySystem()
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid) override
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
virtual NumericVector< Number > & solution() override
MooseMesh & _mesh
Definition: SystemBase.h:699
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:1268
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:789
boundary_id_type BoundaryID
Definition: MooseTypes.h:122

◆ computeResidual()

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

Form a residual vector for a given tag.

Definition at line 585 of file NonlinearSystemBase.C.

586 {
587  mooseDeprecated(" Please use computeResidualTag");
588 
589  computeResidualTag(residual, tag_id);
590 }
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:237
void computeResidualTag(NumericVector< Number > &residual, TagID tag_id)
Computes residual for a given tag.

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

Referenced by NonlinearSystemBase::computeResidualTags().

1279 {
1280  TIME_SECTION(_compute_residual_internal_timer);
1281 
1282  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1283  {
1284  _kernels.residualSetup(tid);
1287  if (_doing_dg)
1293  }
1298 
1299  // reinit scalar variables
1300  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
1302 
1303  // residual contributions from the domain
1304  PARALLEL_TRY
1305  {
1306  TIME_SECTION(_kernels_timer);
1307 
1308  ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
1309 
1311 
1312  Threads::parallel_reduce(elem_range, cr);
1313 
1314  unsigned int n_threads = libMesh::n_threads();
1315  for (unsigned int i = 0; i < n_threads;
1316  i++) // Add any cached residuals that might be hanging around
1318  }
1319  PARALLEL_CATCH;
1320 
1321  // residual contributions from the scalar kernels
1322  PARALLEL_TRY
1323  {
1324  // do scalar kernels (not sure how to thread this)
1326  {
1327  TIME_SECTION(_scalar_kernels_timer);
1328 
1329  MooseObjectWarehouse<ScalarKernel> * scalar_kernel_warehouse;
1330  // This code should be refactored once we can do tags for scalar
1331  // kernels
1332  // Should redo this based on Warehouse
1333  if (!tags.size() || tags.size() == _fe_problem.numVectorTags())
1334  scalar_kernel_warehouse = &_scalar_kernels;
1335  else if (tags.size() == 1)
1336  scalar_kernel_warehouse =
1337  &(_scalar_kernels.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1338  else
1339  // scalar_kernels is not threading
1340  scalar_kernel_warehouse = &(_scalar_kernels.getVectorTagsObjectWarehouse(tags, 0));
1341 
1342  bool have_scalar_contributions = false;
1343  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
1344  for (const auto & scalar_kernel : scalars)
1345  {
1346  scalar_kernel->reinit();
1347  const std::vector<dof_id_type> & dof_indices = scalar_kernel->variable().dofIndices();
1348  const DofMap & dof_map = scalar_kernel->variable().dofMap();
1349  const dof_id_type first_dof = dof_map.first_dof();
1350  const dof_id_type end_dof = dof_map.end_dof();
1351  for (dof_id_type dof : dof_indices)
1352  {
1353  if (dof >= first_dof && dof < end_dof)
1354  {
1355  scalar_kernel->computeResidual();
1356  have_scalar_contributions = true;
1357  break;
1358  }
1359  }
1360  }
1361  if (have_scalar_contributions)
1363  }
1364  }
1365  PARALLEL_CATCH;
1366 
1367  // residual contributions from Block NodalKernels
1368  PARALLEL_TRY
1369  {
1371  {
1372  TIME_SECTION(_nodal_kernels_timer);
1373 
1375 
1376  ConstNodeRange & range = *_mesh.getLocalNodeRange();
1377 
1378  if (range.begin() != range.end())
1379  {
1380  _fe_problem.reinitNode(*range.begin(), 0);
1381 
1382  Threads::parallel_reduce(range, cnk);
1383 
1384  unsigned int n_threads = libMesh::n_threads();
1385  for (unsigned int i = 0; i < n_threads;
1386  i++) // Add any cached residuals that might be hanging around
1388  }
1389  }
1390  }
1391  PARALLEL_CATCH;
1392 
1393  // residual contributions from boundary NodalKernels
1394  PARALLEL_TRY
1395  {
1397  {
1398  TIME_SECTION(_nodal_kernel_bcs_timer);
1399 
1401 
1402  ConstBndNodeRange & bnd_node_range = *_mesh.getBoundaryNodeRange();
1403 
1404  Threads::parallel_reduce(bnd_node_range, cnk);
1405 
1406  unsigned int n_threads = libMesh::n_threads();
1407  for (unsigned int i = 0; i < n_threads;
1408  i++) // Add any cached residuals that might be hanging around
1410  }
1411  }
1412  PARALLEL_CATCH;
1413 
1414  if (_need_residual_copy)
1415  {
1416  _Re_non_time->close();
1417  _Re_non_time->localize(_residual_copy);
1418  }
1419 
1421  {
1422  _Re_non_time->close();
1424  _residual_ghosted->close();
1425  }
1426 
1427  PARALLEL_TRY { computeDiracContributions(tags, false); }
1428  PARALLEL_CATCH;
1429 
1431  {
1432  PARALLEL_TRY { enforceNodalConstraintsResidual(*_Re_non_time); }
1433  PARALLEL_CATCH;
1434  _Re_non_time->close();
1435  }
1436 
1437  // Add in Residual contributions from Constraints
1439  {
1440  PARALLEL_TRY
1441  {
1442  // Undisplaced Constraints
1444 
1445  // Displaced Constraints
1448 
1451  }
1452  PARALLEL_CATCH;
1453  _Re_non_time->close();
1454  }
1455 }
virtual void residualSetup(THREAD_ID tid=0) const
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:738
MooseObjectTagWarehouse< DGKernel > _dg_kernels
bool hasActiveBlockObjects(THREAD_ID tid=0) const
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
MooseObjectTagWarehouse< InterfaceKernel > _interface_kernels
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 & computingNonlinearResid()
Check whether residual being evaulated is non-linear.
Definition: SubProblem.h:516
virtual unsigned int numVectorTags()
The total number of tags.
Definition: SubProblem.h:117
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
ConstNodeRange * getLocalNodeRange()
Definition: MooseMesh.C:775
virtual void addResidualScalar(THREAD_ID tid=0)
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.
NumericVector< Number > & _residual_copy
Copy of the residual vector.
bool _doing_dg
true if DG is active (optimization reasons)
FEProblemBase & _fe_problem
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 std::shared_ptr< DisplacedProblem > getDisplacedProblem()
void computeDiracContributions(const std::set< TagID > &tags, bool is_jacobian)
virtual void addCachedResidual(THREAD_ID tid) override
DofMap & dof_map
MooseObjectTagWarehouse< ScalarKernel > _scalar_kernels
MooseObjectTagWarehouse< KernelBase > _kernels
ConstraintWarehouse _constraints
Constraints storage object.
MooseObjectTagWarehouse< NodalKernel > _nodal_kernels
NodalKernels for each thread.
virtual void reinitScalars(THREAD_ID tid) override
MooseMesh & _mesh
Definition: SystemBase.h:699
bool _need_residual_copy
Whether or not a copy of the residual needs to be made.
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
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...
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:1268
virtual void reinitNode(const Node *node, THREAD_ID tid) override
void enforceNodalConstraintsResidual(NumericVector< Number > &residual)
Enforce nodal constraints.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:789
MooseObjectTagWarehouse< DiracKernel > _dirac_kernels
Dirac Kernel storage for each thread.
virtual void residualEnd(THREAD_ID tid=0) const
unsigned int THREAD_ID
Definition: MooseTypes.h:126

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

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

571 {
572 
573  _nl_vector_tags.clear();
574  _nl_vector_tags.insert(tag_id);
576 
578 
580 
582 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:760
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:749
void computeResidualTags(const std::set< TagID > &tags)
Form multiple tag-associated residual vectors for all the given tags.
virtual TagID residualVectorTag() 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 593 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTag().

594 {
595  TIME_SECTION(_compute_residual_tags_timer);
596 
597  bool required_residual = tags.find(residualVectorTag()) == tags.end() ? false : true;
598 
600 
601  // not suppose to do anythin on matrix
603 
605 
606  for (const auto & numeric_vec : _vecs_to_zero_for_residual)
607  if (hasVector(numeric_vec))
608  {
609  NumericVector<Number> & vec = getVector(numeric_vec);
610  vec.close();
611  vec.zero();
612  }
613 
614  try
615  {
616  zeroTaggedVectors(tags);
618  closeTaggedVectors(tags);
619 
620  if (required_residual)
621  {
622  auto & residual = getVector(residualVectorTag());
623  if (_time_integrator)
624  _time_integrator->postResidual(residual);
625  else
626  residual += *_Re_non_time;
627  residual.close();
628  }
629  computeNodalBCs(tags);
630  closeTaggedVectors(tags);
631 
632  // If we are debugging residuals we need one more assignment to have the ghosted copy up to date
633  if (_need_residual_ghosted && _debugging_residuals && required_residual)
634  {
635  auto & residual = getVector(residualVectorTag());
636 
637  *_residual_ghosted = residual;
638  _residual_ghosted->close();
639  }
640  // Need to close and update the aux system in case residuals were saved to it.
643  if (hasSaveIn())
645  }
646  catch (MooseException & e)
647  {
648  // The buck stops here, we have already handled the exception by
649  // calling stopSolve(), it is now up to PETSc to return a
650  // "diverged" reason during the next solve.
651  }
652 
653  // not supposed to do anything on matrix
655 }
virtual void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition: SystemBase.C:570
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:685
bool _debugging_residuals
true if debugging residuals
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
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 update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:954
bool _need_residual_ghosted
Whether or not a ghosted copy of the residual needs to be made.
virtual TagID residualVectorTag() override
virtual void deactiveAllMatrixTags()
Make matrices inactive.
Definition: SystemBase.C:854
FEProblemBase & _fe_problem
PerfID _compute_residual_tags_timer
Timers.
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:865
AuxiliarySystem & getAuxiliarySystem()
virtual void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition: SystemBase.C:560
void computeResidualInternal(const std::set< TagID > &tags)
Compute the residual for a given tag.
virtual NumericVector< Number > & solution() override
MooseApp & _app
Definition: SystemBase.h:696
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:741
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.
Definition: SystemBase.C:735

◆ computeScalarKernelsJacobians()

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

Definition at line 2154 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

2155 {
2156  MooseObjectWarehouse<ScalarKernel> * scalar_kernel_warehouse;
2157 
2158  if (!tags.size() || tags.size() == _fe_problem.numMatrixTags())
2159  scalar_kernel_warehouse = &_scalar_kernels;
2160  else if (tags.size() == 1)
2161  scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2162  else
2163  scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagsObjectWarehouse(tags, 0));
2164 
2165  // Compute the diagonal block for scalar variables
2166  if (scalar_kernel_warehouse->hasActiveObjects())
2167  {
2168  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
2169 
2170  _fe_problem.reinitScalars(/*tid=*/0);
2171 
2172  bool have_scalar_contributions = false;
2173  for (const auto & kernel : scalars)
2174  {
2175  kernel->reinit();
2176  const std::vector<dof_id_type> & dof_indices = kernel->variable().dofIndices();
2177  const DofMap & dof_map = kernel->variable().dofMap();
2178  const dof_id_type first_dof = dof_map.first_dof();
2179  const dof_id_type end_dof = dof_map.end_dof();
2180  for (dof_id_type dof : dof_indices)
2181  {
2182  if (dof >= first_dof && dof < end_dof)
2183  {
2184  kernel->computeJacobian();
2185  _fe_problem.addJacobianOffDiagScalar(kernel->variable().number());
2186  have_scalar_contributions = true;
2187  break;
2188  }
2189  }
2190  }
2191 
2192  if (have_scalar_contributions)
2194  }
2195 }
virtual void addJacobianOffDiagScalar(unsigned int ivar, THREAD_ID tid=0)
FEProblemBase & _fe_problem
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...
DofMap & dof_map
MooseObjectTagWarehouse< ScalarKernel > _scalar_kernels
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 void addJacobianScalar(THREAD_ID tid=0)
virtual void reinitScalars(THREAD_ID tid) override
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 unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:152

◆ computeTimeDerivatives()

void NonlinearSystemBase::computeTimeDerivatives ( )
inherited

Computes the time derivative vector.

Definition at line 765 of file NonlinearSystemBase.C.

766 {
767  if (_time_integrator)
768  {
769  _time_integrator->preStep();
770  _time_integrator->computeTimeDerivatives();
771  }
772 }
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:741

◆ computeVariables()

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

Definition at line 672 of file SystemBase.h.

672 {}

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

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

Referenced by NonlinearSystemBase::computeJacobianInternal().

1683 {
1684  if (!hasMatrix(systemMatrixTag()))
1685  mooseError("A system matrix is required");
1686 
1687  auto & jacobian = getMatrix(systemMatrixTag());
1688 
1689 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
1690 #else
1692  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
1693  MAT_NEW_NONZERO_ALLOCATION_ERR,
1694  PETSC_FALSE);
1696  MatSetOption(
1697  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE);
1698 #endif
1699 
1700  std::vector<numeric_index_type> zero_rows;
1701  std::map<std::pair<unsigned int, unsigned int>, PenetrationLocator *> * penetration_locators =
1702  NULL;
1703 
1704  if (!displaced)
1705  {
1706  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
1707  penetration_locators = &geom_search_data._penetration_locators;
1708  }
1709  else
1710  {
1711  GeometricSearchData & displaced_geom_search_data =
1712  _fe_problem.getDisplacedProblem()->geomSearchData();
1713  penetration_locators = &displaced_geom_search_data._penetration_locators;
1714  }
1715 
1716  bool constraints_applied;
1718  constraints_applied = false;
1719  for (const auto & it : *penetration_locators)
1720  {
1722  {
1723  // Reset the constraint_applied flag before each new constraint, as they need to be assembled
1724  // separately
1725  constraints_applied = false;
1726  }
1727  PenetrationLocator & pen_loc = *(it.second);
1728 
1729  std::vector<dof_id_type> & slave_nodes = pen_loc._nearest_node._slave_nodes;
1730 
1731  BoundaryID slave_boundary = pen_loc._slave_boundary;
1732 
1733  zero_rows.clear();
1734  if (_constraints.hasActiveNodeFaceConstraints(slave_boundary, displaced))
1735  {
1736  const auto & constraints =
1737  _constraints.getActiveNodeFaceConstraints(slave_boundary, displaced);
1738 
1739  for (const auto & slave_node_num : slave_nodes)
1740  {
1741  Node & slave_node = _mesh.nodeRef(slave_node_num);
1742 
1743  if (slave_node.processor_id() == processor_id())
1744  {
1745  if (pen_loc._penetration_info[slave_node_num])
1746  {
1747  PenetrationInfo & info = *pen_loc._penetration_info[slave_node_num];
1748 
1749  const Elem * master_elem = info._elem;
1750  unsigned int master_side = info._side_num;
1751 
1752  // reinit variables at the node
1753  _fe_problem.reinitNodeFace(&slave_node, slave_boundary, 0);
1754 
1757 
1758  std::vector<Point> points;
1759  points.push_back(info._closest_point);
1760 
1761  // reinit variables on the master element's face at the contact point
1762  _fe_problem.setNeighborSubdomainID(master_elem, 0);
1763  _fe_problem.reinitNeighborPhys(master_elem, master_side, points, 0);
1764  for (const auto & nfc : constraints)
1765  {
1766  nfc->_jacobian = &jacobian;
1767 
1768  if (nfc->shouldApply())
1769  {
1770  constraints_applied = true;
1771 
1772  nfc->subProblem().prepareShapes(nfc->variable().number(), 0);
1773  nfc->subProblem().prepareNeighborShapes(nfc->variable().number(), 0);
1774 
1775  nfc->computeJacobian();
1776 
1777  if (nfc->overwriteSlaveJacobian())
1778  {
1779  // Add this variable's dof's row to be zeroed
1780  zero_rows.push_back(nfc->variable().nodalDofIndex());
1781  }
1782 
1783  std::vector<dof_id_type> slave_dofs(1, nfc->variable().nodalDofIndex());
1784 
1785  // Cache the jacobian block for the slave side
1787  slave_dofs,
1788  nfc->_connected_dof_indices,
1789  nfc->variable().scalingFactor());
1790 
1791  // Cache the jacobian block for the master side
1792  if (nfc->addCouplingEntriesToJacobian())
1794  nfc->_Kne,
1795  nfc->masterVariable().dofIndicesNeighbor(),
1796  nfc->_connected_dof_indices,
1797  nfc->variable().scalingFactor());
1798 
1800  if (nfc->addCouplingEntriesToJacobian())
1802 
1803  // Do the off-diagonals next
1804  const std::vector<MooseVariableFEBase *> coupled_vars = nfc->getCoupledMooseVars();
1805  for (const auto & jvar : coupled_vars)
1806  {
1807  // Only compute jacobians for nonlinear variables
1808  if (jvar->kind() != Moose::VAR_NONLINEAR)
1809  continue;
1810 
1811  // Only compute Jacobian entries if this coupling is being used by the
1812  // preconditioner
1813  if (nfc->variable().number() == jvar->number() ||
1814  !_fe_problem.areCoupled(nfc->variable().number(), jvar->number()))
1815  continue;
1816 
1817  // Need to zero out the matrices first
1819 
1820  nfc->subProblem().prepareShapes(nfc->variable().number(), 0);
1821  nfc->subProblem().prepareNeighborShapes(jvar->number(), 0);
1822 
1823  nfc->computeOffDiagJacobian(jvar->number());
1824 
1825  // Cache the jacobian block for the slave side
1827  slave_dofs,
1828  nfc->_connected_dof_indices,
1829  nfc->variable().scalingFactor());
1830 
1831  // Cache the jacobian block for the master side
1832  if (nfc->addCouplingEntriesToJacobian())
1834  nfc->variable().dofIndicesNeighbor(),
1835  nfc->_connected_dof_indices,
1836  nfc->variable().scalingFactor());
1837 
1839  if (nfc->addCouplingEntriesToJacobian())
1841  }
1842  }
1843  }
1844  }
1845  }
1846  }
1847  }
1849  {
1850  // See if constraints were applied anywhere
1851  _communicator.max(constraints_applied);
1852 
1853  if (constraints_applied)
1854  {
1855 #ifdef LIBMESH_HAVE_PETSC
1856 // Necessary for speed
1857 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
1858  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
1859 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
1860  // In Petsc 3.0.0, MatSetOption has three args...the third arg
1861  // determines whether the option is set (true) or unset (false)
1862  MatSetOption(
1863  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
1864 #else
1865  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
1866  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
1867  PETSC_TRUE);
1868 #endif
1869 #endif
1870 
1871  jacobian.close();
1872  jacobian.zero_rows(zero_rows, 0.0);
1873  jacobian.close();
1875  jacobian.close();
1876  }
1877  }
1878  }
1880  {
1881  // See if constraints were applied anywhere
1882  _communicator.max(constraints_applied);
1883 
1884  if (constraints_applied)
1885  {
1886 #ifdef LIBMESH_HAVE_PETSC
1887 // Necessary for speed
1888 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
1889  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
1890 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
1891  // In Petsc 3.0.0, MatSetOption has three args...the third arg
1892  // determines whether the option is set (true) or unset (false)
1893  MatSetOption(
1894  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
1895 #else
1896  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
1897  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
1898  PETSC_TRUE);
1899 #endif
1900 #endif
1901 
1902  jacobian.close();
1903  jacobian.zero_rows(zero_rows, 0.0);
1904  jacobian.close();
1906  jacobian.close();
1907  }
1908  }
1909 
1910  THREAD_ID tid = 0;
1911  // go over mortar interfaces
1912  auto & ifaces = _mesh.getMortarInterfaces();
1913  for (const auto & iface : ifaces)
1914  {
1915  if (_constraints.hasActiveMortarConstraints(iface->_name))
1916  {
1917  // MortarConstraint objects
1918  const auto & face_constraints = _constraints.getActiveMortarConstraints(iface->_name);
1919 
1920  // go over elements on that interface
1921  const std::vector<Elem *> & elems = iface->_elems;
1922  for (const auto & elem : elems)
1923  {
1924  // for each element process constraints on the
1925  for (const auto & ffc : face_constraints)
1926  {
1928  _fe_problem.prepare(elem, tid);
1929  _fe_problem.reinitElem(elem, tid);
1930  ffc->reinit();
1931  ffc->subProblem().prepareShapes(ffc->variable().number(), tid);
1932  ffc->computeJacobian();
1934 
1935  ffc->reinitSide(Moose::Master);
1936  ffc->computeJacobianSide(Moose::Master);
1938 
1939  ffc->reinitSide(Moose::Slave);
1940  ffc->computeJacobianSide(Moose::Slave);
1942  }
1943 
1945  }
1946  }
1947  }
1948 
1949  // go over element-element constraint interface
1950  std::map<unsigned int, std::shared_ptr<ElementPairLocator>> * element_pair_locators = nullptr;
1951 
1952  if (!displaced)
1953  {
1954  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
1955  element_pair_locators = &geom_search_data._element_pair_locators;
1956  }
1957  else
1958  {
1959  GeometricSearchData & displaced_geom_search_data =
1960  _fe_problem.getDisplacedProblem()->geomSearchData();
1961  element_pair_locators = &displaced_geom_search_data._element_pair_locators;
1962  }
1963 
1964  for (const auto & it : *element_pair_locators)
1965  {
1966  ElementPairLocator & elem_pair_loc = *(it.second);
1967 
1968  if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
1969  {
1970  // ElemElemConstraint objects
1971  const auto & _element_constraints =
1972  _constraints.getActiveElemElemConstraints(it.first, displaced);
1973 
1974  // go over pair elements
1975  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
1976  elem_pair_loc.getElemPairs();
1977  for (const auto & pr : elem_pairs)
1978  {
1979  const Elem * elem1 = pr.first;
1980  const Elem * elem2 = pr.second;
1981 
1982  if (elem1->processor_id() != processor_id())
1983  continue;
1984 
1985  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
1986 
1987  // for each element process constraints on the
1988  for (const auto & ec : _element_constraints)
1989  {
1990  _fe_problem.setCurrentSubdomainID(elem1, tid);
1992  _fe_problem.setNeighborSubdomainID(elem2, tid);
1994 
1995  ec->subProblem().prepareShapes(ec->variable().number(), tid);
1996  ec->subProblem().prepareNeighborShapes(ec->variable().number(), tid);
1997 
1998  ec->reinit(info);
1999  ec->computeJacobian();
2002  }
2004  }
2005  }
2006  }
2007 
2008  // go over NodeELemConstraints
2009  std::set<dof_id_type> unique_slave_node_ids;
2010  constraints_applied = false;
2011  for (const auto & slave_id : _mesh.meshSubdomains())
2012  {
2013  for (const auto & master_id : _mesh.meshSubdomains())
2014  {
2015  if (_constraints.hasActiveNodeElemConstraints(slave_id, master_id, displaced))
2016  {
2017  const auto & constraints =
2018  _constraints.getActiveNodeElemConstraints(slave_id, master_id, displaced);
2019 
2020  // get unique set of ids of all nodes on current block
2021  unique_slave_node_ids.clear();
2022  const MeshBase & meshhelper = _mesh.getMesh();
2023  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(slave_id),
2024  meshhelper.active_subdomain_elements_end(slave_id)))
2025  {
2026  for (auto & n : elem->node_ref_range())
2027  unique_slave_node_ids.insert(n.id());
2028  }
2029 
2030  for (auto slave_node_id : unique_slave_node_ids)
2031  {
2032  const Node & slave_node = _mesh.nodeRef(slave_node_id);
2033  // check if slave node is on current processor
2034  if (slave_node.processor_id() == processor_id())
2035  {
2036  // This reinits the variables that exist on the slave node
2037  _fe_problem.reinitNodeFace(&slave_node, slave_id, 0);
2038 
2039  // This will set aside residual and jacobian space for the variables that have dofs
2040  // on the slave node
2043 
2044  for (const auto & nec : constraints)
2045  {
2046  if (nec->shouldApply())
2047  {
2048  constraints_applied = true;
2049 
2050  nec->_jacobian = &jacobian;
2051  nec->subProblem().prepareShapes(nec->variable().number(), 0);
2052  nec->subProblem().prepareNeighborShapes(nec->variable().number(), 0);
2053 
2054  nec->computeJacobian();
2055 
2056  if (nec->overwriteSlaveJacobian())
2057  {
2058  // Add this variable's dof's row to be zeroed
2059  zero_rows.push_back(nec->variable().nodalDofIndex());
2060  }
2061 
2062  std::vector<dof_id_type> slave_dofs(1, nec->variable().nodalDofIndex());
2063 
2064  // Cache the jacobian block for the slave side
2066  slave_dofs,
2067  nec->_connected_dof_indices,
2068  nec->variable().scalingFactor());
2069 
2070  // Cache the jacobian block for the master side
2072  nec->_Kne,
2073  nec->masterVariable().dofIndicesNeighbor(),
2074  nec->_connected_dof_indices,
2075  nec->variable().scalingFactor());
2076 
2079 
2080  // Do the off-diagonals next
2081  const std::vector<MooseVariableFEBase *> coupled_vars = nec->getCoupledMooseVars();
2082  for (const auto & jvar : coupled_vars)
2083  {
2084  // Only compute jacobians for nonlinear variables
2085  if (jvar->kind() != Moose::VAR_NONLINEAR)
2086  continue;
2087 
2088  // Only compute Jacobian entries if this coupling is being used by the
2089  // preconditioner
2090  if (nec->variable().number() == jvar->number() ||
2091  !_fe_problem.areCoupled(nec->variable().number(), jvar->number()))
2092  continue;
2093 
2094  // Need to zero out the matrices first
2096 
2097  nec->subProblem().prepareShapes(nec->variable().number(), 0);
2098  nec->subProblem().prepareNeighborShapes(jvar->number(), 0);
2099 
2100  nec->computeOffDiagJacobian(jvar->number());
2101 
2102  // Cache the jacobian block for the slave side
2104  slave_dofs,
2105  nec->_connected_dof_indices,
2106  nec->variable().scalingFactor());
2107 
2108  // Cache the jacobian block for the master side
2110  nec->variable().dofIndicesNeighbor(),
2111  nec->_connected_dof_indices,
2112  nec->variable().scalingFactor());
2113 
2116  }
2117  }
2118  }
2119  }
2120  }
2121  }
2122  }
2123  }
2124  // See if constraints were applied anywhere
2125  _communicator.max(constraints_applied);
2126 
2127  if (constraints_applied)
2128  {
2129 #ifdef LIBMESH_HAVE_PETSC
2130 // Necessary for speed
2131 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
2132  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
2133 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
2134  // In Petsc 3.0.0, MatSetOption has three args...the third arg
2135  // determines whether the option is set (true) or unset (false)
2136  MatSetOption(
2137  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
2138 #else
2139  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2140  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2141  PETSC_TRUE);
2142 #endif
2143 #endif
2144 
2145  jacobian.close();
2146  jacobian.zero_rows(zero_rows, 0.0);
2147  jacobian.close();
2149  jacobian.close();
2150  }
2151 }
virtual void prepare(const Elem *elem, THREAD_ID tid) override
bool _assemble_constraints_separately
Whether or not to assemble the residual and Jacobian after the application of each constraint...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
Data structure used to hold penetration information.
virtual Assembly & assembly(THREAD_ID tid) override
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
bool hasActiveMortarConstraints(const std::string &interface) const
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem *> elem_pair) const
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:781
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
virtual void reinitElem(const Elem *elem, THREAD_ID tid) override
const std::vector< std::shared_ptr< MortarConstraint > > & getActiveMortarConstraints(const std::string &interface) const
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:437
virtual TagID systemMatrixTag() override
Return the Matrix Tag ID for System.
virtual GeometricSearchData & geomSearchData() override
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
std::vector< std::unique_ptr< MooseMesh::MortarInterface > > & getMortarInterfaces()
Definition: MooseMesh.h:815
virtual void addCachedJacobian(THREAD_ID tid) override
FEProblemBase & _fe_problem
std::vector< dof_id_type > _slave_nodes
virtual std::shared_ptr< DisplacedProblem > getDisplacedProblem()
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2562
std::vector< Point > _elem1_constraint_q_point
const ElementPairList & getElemPairs() const
const Elem * _elem
virtual void cacheJacobian(THREAD_ID tid) override
std::map< unsigned int, std::shared_ptr< ElementPairLocator > > _element_pair_locators
unsigned int _side_num
bool areCoupled(unsigned int ivar, unsigned int jvar)
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.
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid) override
ConstraintWarehouse _constraints
Constraints storage object.
std::map< std::pair< unsigned int, unsigned int >, PenetrationLocator * > _penetration_locators
const std::vector< std::shared_ptr< NodeElemConstraint > > & getActiveNodeElemConstraints(SubdomainID slave_id, SubdomainID master_id, bool displaced) const
virtual void prepareAssembly(THREAD_ID tid) override
void cacheJacobianBlock(DenseMatrix< Number > &jac_block, std::vector< dof_id_type > &idof_indices, std::vector< dof_id_type > &jdof_indices, Real scaling_factor, TagID tag=0)
Definition: Assembly.C:2542
MooseMesh & _mesh
Definition: SystemBase.h:699
virtual void setCurrentSubdomainID(const Elem *elem, THREAD_ID tid) override
PetscInt n
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:787
virtual void cacheJacobianNeighbor(THREAD_ID tid) override
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, THREAD_ID tid, bool suppress_displaced_init=false) override
bool hasActiveElemElemConstraints(const InterfaceID interface_id, bool displaced) const
bool hasActiveNodeElemConstraints(SubdomainID slave_id, SubdomainID master_id, bool displaced) const
bool ignoreZerosInJacobian() const
std::vector< Point > _elem2_constraint_q_point
virtual void reinitOffDiagScalars(THREAD_ID tid) override
const std::vector< std::shared_ptr< ElemElemConstraint > > & getActiveElemElemConstraints(InterfaceID interface_id, bool displaced) const
unsigned int THREAD_ID
Definition: MooseTypes.h:126
boundary_id_type BoundaryID
Definition: MooseTypes.h:122
NearestNodeLocator & _nearest_node
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, THREAD_ID tid) override
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:2311
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, 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 960 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualInternal().

961 {
962  // Make sure the residual is in a good state
963  residual.close();
964 
965  std::map<std::pair<unsigned int, unsigned int>, PenetrationLocator *> * penetration_locators =
966  NULL;
967 
968  if (!displaced)
969  {
970  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
971  penetration_locators = &geom_search_data._penetration_locators;
972  }
973  else
974  {
975  GeometricSearchData & displaced_geom_search_data =
976  _fe_problem.getDisplacedProblem()->geomSearchData();
977  penetration_locators = &displaced_geom_search_data._penetration_locators;
978  }
979 
980  bool constraints_applied;
981  bool residual_has_inserted_values = false;
983  constraints_applied = false;
984  for (const auto & it : *penetration_locators)
985  {
987  {
988  // Reset the constraint_applied flag before each new constraint, as they need to be assembled
989  // separately
990  constraints_applied = false;
991  }
992  PenetrationLocator & pen_loc = *(it.second);
993 
994  std::vector<dof_id_type> & slave_nodes = pen_loc._nearest_node._slave_nodes;
995 
996  BoundaryID slave_boundary = pen_loc._slave_boundary;
997 
998  if (_constraints.hasActiveNodeFaceConstraints(slave_boundary, displaced))
999  {
1000  const auto & constraints =
1001  _constraints.getActiveNodeFaceConstraints(slave_boundary, displaced);
1002 
1003  for (unsigned int i = 0; i < slave_nodes.size(); i++)
1004  {
1005  dof_id_type slave_node_num = slave_nodes[i];
1006  Node & slave_node = _mesh.nodeRef(slave_node_num);
1007 
1008  if (slave_node.processor_id() == processor_id())
1009  {
1010  if (pen_loc._penetration_info[slave_node_num])
1011  {
1012  PenetrationInfo & info = *pen_loc._penetration_info[slave_node_num];
1013 
1014  const Elem * master_elem = info._elem;
1015  unsigned int master_side = info._side_num;
1016 
1017  // *These next steps MUST be done in this order!*
1018 
1019  // This reinits the variables that exist on the slave node
1020  _fe_problem.reinitNodeFace(&slave_node, slave_boundary, 0);
1021 
1022  // This will set aside residual and jacobian space for the variables that have dofs on
1023  // the slave node
1025 
1026  std::vector<Point> points;
1027  points.push_back(info._closest_point);
1028 
1029  // reinit variables on the master element's face at the contact point
1030  _fe_problem.setNeighborSubdomainID(master_elem, 0);
1031  _fe_problem.reinitNeighborPhys(master_elem, master_side, points, 0);
1032 
1033  for (const auto & nfc : constraints)
1034  if (nfc->shouldApply())
1035  {
1036  constraints_applied = true;
1037  nfc->computeResidual();
1038 
1039  if (nfc->overwriteSlaveResidual())
1040  {
1041  _fe_problem.setResidual(residual, 0);
1042  residual_has_inserted_values = true;
1043  }
1044  else
1047  }
1048  }
1049  }
1050  }
1051  }
1053  {
1054  // Make sure that slave contribution to master are assembled, and ghosts have been exchanged,
1055  // as current masters might become slaves on next iteration
1056  // and will need to contribute their former slaves' contributions
1057  // to the future masters.
1058  // See if constraints were applied anywhere
1059  _communicator.max(constraints_applied);
1060 
1061  if (constraints_applied)
1062  {
1063  // If any of the above constraints inserted values in the residual, it needs to be assembled
1064  // before adding the cached residuals below.
1065  _communicator.max(residual_has_inserted_values);
1066  if (residual_has_inserted_values)
1067  {
1068  residual.close();
1069  residual_has_inserted_values = false;
1070  }
1072  residual.close();
1073 
1075  *_residual_ghosted = residual;
1076  }
1077  }
1078  }
1080  {
1081  _communicator.max(constraints_applied);
1082 
1083  if (constraints_applied)
1084  {
1085  // If any of the above constraints inserted values in the residual, it needs to be assembled
1086  // before adding the cached residuals below.
1087  _communicator.max(residual_has_inserted_values);
1088  if (residual_has_inserted_values)
1089  residual.close();
1090 
1092  residual.close();
1093 
1095  *_residual_ghosted = residual;
1096  }
1097  }
1098 
1099  THREAD_ID tid = 0;
1100  // go over mortar interfaces
1101  auto & ifaces = _mesh.getMortarInterfaces();
1102  for (const auto & iface : ifaces)
1103  {
1104  if (_constraints.hasActiveMortarConstraints(iface->_name))
1105  {
1106  const auto & face_constraints = _constraints.getActiveMortarConstraints(iface->_name);
1107 
1108  // go over elements on that interface
1109  const std::vector<Elem *> & elems = iface->_elems;
1110  for (const auto & elem : elems)
1111  {
1112  // for each element process constraints on the
1114  _fe_problem.prepare(elem, tid);
1115  _fe_problem.reinitElem(elem, tid);
1116 
1117  for (const auto & ffc : face_constraints)
1118  {
1119  ffc->reinit();
1120  ffc->computeResidual();
1121  }
1123 
1124  // evaluate residuals that go into master and slave side
1125  for (const auto & ffc : face_constraints)
1126  {
1127  ffc->reinitSide(Moose::Master);
1128  ffc->computeResidualSide(Moose::Master);
1130 
1131  ffc->reinitSide(Moose::Slave);
1132  ffc->computeResidualSide(Moose::Slave);
1134  }
1135  }
1137  }
1138  }
1139 
1140  // go over element-element constraint interface
1141  std::map<unsigned int, std::shared_ptr<ElementPairLocator>> * element_pair_locators = nullptr;
1142 
1143  if (!displaced)
1144  {
1145  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
1146  element_pair_locators = &geom_search_data._element_pair_locators;
1147  }
1148  else
1149  {
1150  GeometricSearchData & displaced_geom_search_data =
1151  _fe_problem.getDisplacedProblem()->geomSearchData();
1152  element_pair_locators = &displaced_geom_search_data._element_pair_locators;
1153  }
1154 
1155  for (const auto & it : *element_pair_locators)
1156  {
1157  ElementPairLocator & elem_pair_loc = *(it.second);
1158 
1159  if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
1160  {
1161  // ElemElemConstraint objects
1162  const auto & _element_constraints =
1163  _constraints.getActiveElemElemConstraints(it.first, displaced);
1164 
1165  // go over pair elements
1166  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
1167  elem_pair_loc.getElemPairs();
1168  for (const auto & pr : elem_pairs)
1169  {
1170  const Elem * elem1 = pr.first;
1171  const Elem * elem2 = pr.second;
1172 
1173  if (elem1->processor_id() != processor_id())
1174  continue;
1175 
1176  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
1177 
1178  // for each element process constraints on the
1179  for (const auto & ec : _element_constraints)
1180  {
1181  _fe_problem.setCurrentSubdomainID(elem1, tid);
1183  _fe_problem.setNeighborSubdomainID(elem2, tid);
1185 
1186  ec->subProblem().prepareShapes(ec->variable().number(), tid);
1187  ec->subProblem().prepareNeighborShapes(ec->variable().number(), tid);
1188 
1189  ec->reinit(info);
1190  ec->computeResidual();
1193  }
1195  }
1196  }
1197  }
1198 
1199  // go over NodeELemConstraints
1200  std::set<dof_id_type> unique_slave_node_ids;
1201 
1202  constraints_applied = false;
1203  residual_has_inserted_values = false;
1204  for (const auto & slave_id : _mesh.meshSubdomains())
1205  {
1206  for (const auto & master_id : _mesh.meshSubdomains())
1207  {
1208  if (_constraints.hasActiveNodeElemConstraints(slave_id, master_id, displaced))
1209  {
1210  const auto & constraints =
1211  _constraints.getActiveNodeElemConstraints(slave_id, master_id, displaced);
1212 
1213  // get unique set of ids of all nodes on current block
1214  unique_slave_node_ids.clear();
1215  const MeshBase & meshhelper = _mesh.getMesh();
1216  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(slave_id),
1217  meshhelper.active_subdomain_elements_end(slave_id)))
1218  {
1219  for (auto & n : elem->node_ref_range())
1220  unique_slave_node_ids.insert(n.id());
1221  }
1222 
1223  for (auto slave_node_id : unique_slave_node_ids)
1224  {
1225  Node & slave_node = _mesh.nodeRef(slave_node_id);
1226  // check if slave node is on current processor
1227  if (slave_node.processor_id() == processor_id())
1228  {
1229  // This reinits the variables that exist on the slave node
1230  _fe_problem.reinitNodeFace(&slave_node, slave_id, 0);
1231 
1232  // This will set aside residual and jacobian space for the variables that have dofs
1233  // on the slave node
1235 
1236  for (const auto & nec : constraints)
1237  {
1238  if (nec->shouldApply())
1239  {
1240  constraints_applied = true;
1241  nec->computeResidual();
1242 
1243  if (nec->overwriteSlaveResidual())
1244  {
1245  _fe_problem.setResidual(residual, 0);
1246  residual_has_inserted_values = true;
1247  }
1248  else
1251  }
1252  }
1254  }
1255  }
1256  }
1257  }
1258  }
1259  _communicator.max(constraints_applied);
1260 
1261  if (constraints_applied)
1262  {
1263  // If any of the above constraints inserted values in the residual, it needs to be assembled
1264  // before adding the cached residuals below.
1265  _communicator.max(residual_has_inserted_values);
1266  if (residual_has_inserted_values)
1267  residual.close();
1268 
1270  residual.close();
1271 
1273  *_residual_ghosted = residual;
1274  }
1275 }
virtual void addCachedResidualDirectly(NumericVector< Number > &residual, THREAD_ID tid)
Allows for all the residual contributions that are currently cached to be added directly into the vec...
virtual void prepare(const Elem *elem, THREAD_ID tid) override
bool _assemble_constraints_separately
Whether or not to assemble the residual and Jacobian after the application of each constraint...
Data structure used to hold penetration information.
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
bool hasActiveMortarConstraints(const std::string &interface) const
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem *> elem_pair) const
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
virtual void reinitElem(const Elem *elem, THREAD_ID tid) override
const std::vector< std::shared_ptr< MortarConstraint > > & getActiveMortarConstraints(const std::string &interface) const
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:437
virtual GeometricSearchData & geomSearchData() override
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.
std::vector< std::unique_ptr< MooseMesh::MortarInterface > > & getMortarInterfaces()
Definition: MooseMesh.h:815
FEProblemBase & _fe_problem
std::vector< dof_id_type > _slave_nodes
virtual std::shared_ptr< DisplacedProblem > getDisplacedProblem()
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2562
std::vector< Point > _elem1_constraint_q_point
const ElementPairList & getElemPairs() const
const Elem * _elem
virtual void addCachedResidual(THREAD_ID tid) override
std::map< unsigned int, std::shared_ptr< ElementPairLocator > > _element_pair_locators
unsigned int _side_num
This is the ElementPairLocator class.
This is the ElementPairInfo class.
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid) override
ConstraintWarehouse _constraints
Constraints storage object.
std::map< std::pair< unsigned int, unsigned int >, PenetrationLocator * > _penetration_locators
const std::vector< std::shared_ptr< NodeElemConstraint > > & getActiveNodeElemConstraints(SubdomainID slave_id, SubdomainID master_id, bool displaced) const
virtual void prepareAssembly(THREAD_ID tid) override
MooseMesh & _mesh
Definition: SystemBase.h:699
virtual void setCurrentSubdomainID(const Elem *elem, THREAD_ID tid) override
PetscInt n
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, THREAD_ID tid, bool suppress_displaced_init=false) override
bool hasActiveElemElemConstraints(const InterfaceID interface_id, bool displaced) const
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
bool hasActiveNodeElemConstraints(SubdomainID slave_id, SubdomainID master_id, bool displaced) const
std::vector< Point > _elem2_constraint_q_point
virtual void cacheResidual(THREAD_ID tid) override
const std::vector< std::shared_ptr< ElemElemConstraint > > & getActiveElemElemConstraints(InterfaceID interface_id, bool displaced) const
unsigned int THREAD_ID
Definition: MooseTypes.h:126
boundary_id_type BoundaryID
Definition: MooseTypes.h:122
NearestNodeLocator & _nearest_node
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, THREAD_ID tid) override
virtual void setResidual(NumericVector< Number > &residual, THREAD_ID tid) override
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:2311
virtual void cacheResidualNeighbor(THREAD_ID tid) override
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, THREAD_ID tid) override

◆ containsEigenKernel()

bool MooseEigenSystem::containsEigenKernel ( ) const

Weather or not the system contains eigen kernels.

Definition at line 252 of file MooseEigenSystem.C.

Referenced by EigenExecutionerBase::checkIntegrity().

253 {
254  return _eigen_kernel_counter > 0;
255 }
unsigned int _eigen_kernel_counter
counter of eigen kernels

◆ containsTimeKernel()

bool NonlinearSystemBase::containsTimeKernel ( )
inherited

Definition at line 2994 of file NonlinearSystemBase.C.

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

2995 {
2996  auto & time_kernels = _kernels.getVectorTagObjectWarehouse(timeVectorTag(), 0);
2997 
2998  return time_kernels.hasActiveObjects();
2999 }
MooseObjectTagWarehouse< KernelBase > _kernels
virtual TagID timeVectorTag() 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()

bool NonlinearSystem::converged ( )
overridevirtualinherited

Returns the convergence state.

Returns
true if converged, otherwise false

Implements NonlinearSystemBase.

Definition at line 384 of file NonlinearSystem.C.

385 {
387  return false;
388 
389  return _transient_sys.nonlinear_solver->converged;
390 }
FEProblemBase & _fe_problem
TransientNonlinearImplicitSystem & _transient_sys
virtual bool hasException()
Whether or not an exception has occurred.

◆ copyOldSolutions()

void SystemBase::copyOldSolutions ( )
virtualinherited

Shifts the solutions backwards in time.

Definition at line 986 of file SystemBase.C.

Referenced by EigenExecutionerBase::inversePowerIteration().

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

◆ copySolutionsBackwards()

void SystemBase::copySolutionsBackwards ( )
virtualinherited

Copy current solution into old and older.

Definition at line 969 of file SystemBase.C.

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

◆ copyVars()

void SystemBase::copyVars ( ExodusII_IO &  io)
inherited

Definition at line 914 of file SystemBase.C.

915 {
916  int n_steps = io.get_num_time_steps();
917 
918  bool did_copy = false;
919  for (const auto & vci : _var_to_copy)
920  {
921  int timestep = -1;
922 
923  if (vci._timestep == "LATEST")
924  // Use the last time step in the file from which to retrieve the solution
925  timestep = n_steps;
926  else
927  {
928  timestep = MooseUtils::convert<int>(vci._timestep);
929  if (timestep > n_steps)
930  mooseError("Invalid value passed as \"initial_from_file_timestep\". Expected \"LATEST\" or "
931  "a valid integer between 1 and ",
932  n_steps,
933  " inclusive, received ",
934  vci._timestep);
935  }
936 
937  did_copy = true;
938  if (getVariable(0, vci._dest_name).isNodal())
939  io.copy_nodal_solution(system(), vci._dest_name, vci._source_name, timestep);
940  else
941  io.copy_elemental_solution(system(), vci._dest_name, vci._source_name, timestep);
942  }
943 
944  if (did_copy)
945  solution().close();
946 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
MooseVariableFEBase & getVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:105
virtual bool isNodal() const =0
Is this variable nodal.
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:732
int convert< int >(const std::string &str, bool throw_on_failure)
Definition: MooseUtils.C:658
virtual System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > & solution()=0

◆ currentSolution()

virtual const NumericVector<Number>*& NonlinearSystemBase::currentSolution ( )
inlineoverridevirtualinherited

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

Referenced by Transient::keepGoing(), DT2::preSolve(), Transient::relativeSolutionDifferenceNorm(), DT2::step(), AB2PredictorCorrector::step(), DisplacedProblem::syncSolutions(), and DisplacedProblem::updateMesh().

383 { return _current_solution; }
const NumericVector< Number > * _current_solution
solution vector from nonlinear solver

◆ deactiveAllMatrixTags()

void SystemBase::deactiveAllMatrixTags ( )
virtualinherited

Make matrices inactive.

Definition at line 854 of file SystemBase.C.

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

855 {
856  auto num_matrix_tags = _subproblem.numMatrixTags();
857 
858  _matrix_tag_active_flags.resize(num_matrix_tags);
859 
860  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
861  _matrix_tag_active_flags[tag] = false;
862 }
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:719
SubProblem & _subproblem
Definition: SystemBase.h:694
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:152

◆ deactiveMatrixTag()

void SystemBase::deactiveMatrixTag ( TagID  tag)
virtualinherited

deactive a matrix for tag

Definition at line 842 of file SystemBase.C.

843 {
844  mooseAssert(_subproblem.matrixTagExists(tag),
845  "Cannot deactivate Matrix with matrix_tag : " << tag << "that does not exist");
846 
847  if (_matrix_tag_active_flags.size() < tag + 1)
848