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

Nonlinear eigenvalue system to be solved. More...

#include <NonlinearEigenSystem.h>

Inheritance diagram for NonlinearEigenSystem:
[legend]

Public Member Functions

 NonlinearEigenSystem (EigenProblem &problem, const std::string &name)
 
virtual void solve () override
 Solve the system (using libMesh magic) More...
 
virtual void stopSolve () 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
 
template<typename T >
void addEigenTagToMooseObjects (MooseObjectTagWarehouse< T > &warehouse)
 Add the eigen tag to the right kernels. More...
 
virtual void initialSetup () override
 
virtual unsigned int getNumConvergedEigenvalues () const
 Get the number of converged eigenvalues. More...
 
virtual NonlinearSolver< Number > * nonlinearSolver () override
 
virtual NumericVector< Number > & solutionOld () override
 
virtual NumericVector< Number > & solutionOlder () override
 
virtual TransientEigenSystem & sys ()
 
void checkIntegrity ()
 For eigenvalue problems (including standard and generalized), inhomogeneous (Dirichlet or Neumann) boundary conditions are not allowed. More...
 
virtual const std::pair< Real, Real > getNthConvergedEigenvalue (dof_id_type n)
 Return the Nth converged eigenvalue. More...
 
virtual const std::vector< std::pair< Real, Real > > & getAllConvergedEigenvalues ()
 Get the number of converged eigenvalues. More...
 
TagID eigenVectorTag ()
 Vector tag ID of right hand side. More...
 
TagID nonEigenVectorTag ()
 Vector tag ID of left hand side. More...
 
TagID eigenMatrixTag ()
 Matrix tag ID of right hand side. More...
 
TagID nonEigenMatrixTag ()
 Matrix tag ID of left hand side. More...
 
 NonlinearEigenSystem (EigenProblem &problem, const std::string &name)
 
bool converged ()
 Returns the convergence state. More...
 
void checkIntegrity ()
 
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 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 addKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a kernel. More...
 
virtual void addNodalKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a NodalKernel. More...
 
void addScalarKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a scalar kernel. More...
 
void addBoundaryCondition (const std::string &bc_name, const std::string &name, InputParameters parameters)
 Adds a boundary condition. More...
 
void addConstraint (const std::string &c_name, const std::string &name, InputParameters parameters)
 Adds a Constraint. More...
 
void addDiracKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a Dirac kernel. More...
 
void addDGKernel (std::string dg_kernel_name, const std::string &name, InputParameters parameters)
 Adds a DG kernel. More...
 
void addInterfaceKernel (std::string interface_kernel_name, const std::string &name, InputParameters parameters)
 Adds an interface kernel. More...
 
void addDamper (const std::string &damper_name, const std::string &name, InputParameters parameters)
 Adds a damper. More...
 
void addSplit (const std::string &split_name, const std::string &name, InputParameters parameters)
 Adds a split. More...
 
std::shared_ptr< SplitgetSplit (const std::string &name)
 Retrieves a split by name. More...
 
void zeroVectorForResidual (const std::string &vector_name)
 
void setInitialSolution ()
 
void 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 SparseMatrix< Number > & addMatrix (TagID)
 Adds a jacobian sized vector. More...
 
virtual void removeMatrix (TagID)
 Removes a jacobian sized vector. More...
 
virtual const std::string & name () const
 
virtual void addScalarVariable (const std::string &var_name, Order order, Real scale_factor, const std::set< SubdomainID > *const active_subdomains=NULL)
 Adds a scalar variable. More...
 
const std::vector< VariableName > & getVariableNames () const
 
virtual void computeVariables (const NumericVector< Number > &)
 
void copyVars (ExodusII_IO &io)
 
virtual void copySolutionsBackwards ()
 Copy current solution into old and older. More...
 
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< DGKernelBase > & 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

TransientEigenSystem & _transient_sys
 
EigenProblem_eigen_problem
 
std::vector< std::pair< Real, Real > > _eigen_values
 
unsigned int _n_eigen_pairs_required
 
TagID _Ax_tag
 
TagID _Bx_tag
 
TagID _A_tag
 
TagID _B_tag
 
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< DGKernelBase_dg_kernels
 
MooseObjectTagWarehouse< InterfaceKernel_interface_kernels
 
MooseObjectTagWarehouse< IntegratedBCBase_integrated_bcs
 
MooseObjectTagWarehouse< NodalBCBase_nodal_bcs
 
MooseObjectWarehouse< PresetNodalBC_preset_nodal_bcs
 

Detailed Description

Nonlinear eigenvalue system to be solved.

Definition at line 29 of file NonlinearEigenSystem.h.

Constructor & Destructor Documentation

◆ NonlinearEigenSystem() [1/2]

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

Definition at line 121 of file NonlinearEigenSystem.C.

123  eigen_problem, eigen_problem.es().add_system<TransientEigenSystem>(name), name),
124  _transient_sys(eigen_problem.es().get_system<TransientEigenSystem>(name)),
125  _eigen_problem(eigen_problem),
126  _n_eigen_pairs_required(eigen_problem.getNEigenPairsRequired())
127 {
128  sys().attach_assemble_function(Moose::assemble_matrix);
129 
130  _Ax_tag = eigen_problem.addVectorTag("Ax_tag");
131 
132  _Bx_tag = eigen_problem.addVectorTag("Eigen");
133 
134  _A_tag = eigen_problem.addMatrixTag("A_tag");
135 
136  _B_tag = eigen_problem.addMatrixTag("Eigen");
137 }
virtual TransientEigenSystem & sys()
virtual const std::string & name() const
Definition: SystemBase.C:1049
void assemble_matrix(EquationSystems &es, const std::string &system_name)
NonlinearSystemBase(FEProblemBase &problem, System &sys, const std::string &name)
TransientEigenSystem & _transient_sys
unsigned int _n_eigen_pairs_required

◆ NonlinearEigenSystem() [2/2]

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

Member Function Documentation

◆ activeAllMatrixTags()

void SystemBase::activeAllMatrixTags ( )
virtualinherited

Make all exsiting matrices ative.

Definition at line 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:157

◆ 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:128
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:719
SubProblem & _subproblem
Definition: SystemBase.h:694

◆ 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:1049
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:162
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:1049
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 516 of file NonlinearSystemBase.C.

519 {
520  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
521  {
522  std::shared_ptr<Damper> damper = _factory.create<Damper>(damper_name, name, parameters, tid);
523 
524  // Attempt to cast to the damper types
525  std::shared_ptr<ElementDamper> ed = std::dynamic_pointer_cast<ElementDamper>(damper);
526  std::shared_ptr<NodalDamper> nd = std::dynamic_pointer_cast<NodalDamper>(damper);
527  std::shared_ptr<GeneralDamper> gd = std::dynamic_pointer_cast<GeneralDamper>(damper);
528 
529  if (gd)
530  {
532  break; // not threaded
533  }
534  else if (ed)
535  _element_dampers.addObject(ed, tid);
536  else if (nd)
537  _nodal_dampers.addObject(nd, tid);
538  else
539  mooseError("Invalid damper type");
540  }
541 }
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:1049
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:162

◆ 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  auto dg_kernel = _factory.create<DGKernelBase>(dg_kernel_name, name, parameters, tid);
486  _dg_kernels.addObject(dg_kernel, tid);
487  }
488 
489  _doing_dg = true;
490 
491  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
492  _has_save_in = true;
493  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
494  _has_diag_save_in = true;
495 }
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< DGKernelBase > _dg_kernels
Factory & _factory
Definition: SystemBase.h:697
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
Serves as a base class for DGKernel and ADDGKernel.
Definition: DGKernelBase.h:47
virtual const std::string & name() const
Definition: SystemBase.C:1049
bool _doing_dg
true if DG is active (optimization reasons)
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
virtual void 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:162

◆ 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:1049
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:162

◆ 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

◆ addEigenTagToMooseObjects()

template<typename T >
void NonlinearEigenSystem::addEigenTagToMooseObjects ( MooseObjectTagWarehouse< T > &  warehouse)

Add the eigen tag to the right kernels.

Definition at line 151 of file NonlinearEigenSystem.C.

Referenced by initialSetup().

152 {
153  for (THREAD_ID tid = 0; tid < warehouse.numThreads(); tid++)
154  {
155  auto & objects = warehouse.getObjects(tid);
156 
157  for (auto & object : objects)
158  {
159  auto & vtags = object->getVectorTags();
160  // If this is not an eigen kernel
161  if (vtags.find(_Bx_tag) == vtags.end())
162  object->useVectorTag(_Ax_tag);
163  else // also associate eigen matrix tag if this is a eigen kernel
164  object->useMatrixTag(_B_tag);
165 
166  auto & mtags = object->getMatrixTags();
167  if (mtags.find(_B_tag) == mtags.end())
168  object->useMatrixTag(_A_tag);
169  else
170  object->useVectorTag(_Bx_tag);
171  }
172  }
173 }
THREAD_ID numThreads()
Return the number of threads.
const std::vector< std::shared_ptr< T > > & getObjects(THREAD_ID tid=0) const
Retrieve complete vector to the all/block/boundary restricted objects for a given thread...
unsigned int THREAD_ID
Definition: MooseTypes.h:162

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

Referenced by NonlinearSystemBase::computeJacobianInternal().

1658 {
1659  if (!hasMatrix(systemMatrixTag()))
1660  mooseError("Need a system matrix ");
1661 
1662  // At this point, have no idea how to make
1663  // this work with tag system
1664  auto & jacobian = getMatrix(systemMatrixTag());
1665 
1666  std::map<dof_id_type, std::vector<dof_id_type>> graph;
1667 
1668  findImplicitGeometricCouplingEntries(geom_search_data, graph);
1669 
1670  for (const auto & it : graph)
1671  {
1672  dof_id_type dof = it.first;
1673  const std::vector<dof_id_type> & row = it.second;
1674 
1675  for (const auto & coupled_dof : row)
1676  jacobian.add(dof, coupled_dof, 0);
1677  }
1678 }
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 498 of file NonlinearSystemBase.C.

501 {
502  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
503  {
504  std::shared_ptr<InterfaceKernel> interface_kernel =
505  _factory.create<InterfaceKernel>(interface_kernel_name, name, parameters, tid);
506 
507  const std::set<BoundaryID> & boundary_ids = interface_kernel->boundaryIDs();
508  _vars[tid].addBoundaryVar(boundary_ids, &interface_kernel->variable());
509 
510  _interface_kernels.addObject(interface_kernel, tid);
511  _vars[tid].addBoundaryVars(boundary_ids, interface_kernel->getCoupledVars());
512  }
513 }
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:1049
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:162

◆ addKernel()

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

Adds a kernel.

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

Reimplemented in MooseEigenSystem.

Definition at line 334 of file NonlinearSystemBase.C.

337 {
338  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
339  {
340  // Create the kernel object via the factory and add to warehouse
341  std::shared_ptr<KernelBase> kernel =
342  _factory.create<KernelBase>(kernel_name, name, parameters, tid);
345  _ad_jacobian_kernels.addObject(kernel, tid);
346  else
347  _kernels.addObject(kernel, tid);
348  }
349 
350  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
351  _has_save_in = true;
352  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
353  _has_diag_save_in = true;
354 }
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
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.
MooseObjectTagWarehouse< KernelBase > _ad_jacobian_kernels
virtual const std::string & name() const
Definition: SystemBase.C:1049
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
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:162

◆ addMatrix()

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

Adds a jacobian sized vector.

Parameters
tag_nameThe name of the tag

Reimplemented in NonlinearSystem.

Definition at line 642 of file SystemBase.h.

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

◆ 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:1049
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:162

◆ 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:1049
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:162
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 544 of file NonlinearSystemBase.C.

547 {
548  std::shared_ptr<Split> split = _factory.create<Split>(split_name, name, parameters);
550 }
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:1049
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:1049
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 687 of file SystemBase.h.

687 {}

◆ addTimeIntegrator() [3/4]

virtual void SystemBase::addTimeIntegrator
inlineinherited

Definition at line 681 of file SystemBase.h.

684  {
685  }

◆ 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:162
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(), DGKernelBase::DGKernelBase(), 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(), DGKernelBase::DGKernelBase(), 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(), NonlinearSystemBase::getResidualNonTimeVector(), NonlinearSystemBase::getResidualTimeVector(), FEProblemBase::initNullSpaceVectors(), LStableDirk3::LStableDirk3(), LStableDirk4::LStableDirk4(), PicardSolve::PicardSolve(), 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:105
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:1049
SubProblem & _subproblem
Definition: SystemBase.h:694
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:112
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:128
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:112
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:2269
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:505
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 2785 of file NonlinearSystemBase.C.

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

◆ checkIntegrity() [1/2]

void NonlinearEigenSystem::checkIntegrity ( )

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

Definition at line 253 of file NonlinearEigenSystem.C.

254 {
256  mooseError("Can't set an inhomogeneous integrated boundary condition for eigenvalue problems.");
257 
259  {
260  const auto & nodal_bcs = _nodal_bcs.getActiveObjects();
261  for (const auto & nodal_bc : nodal_bcs)
262  {
263  auto nbc = std::dynamic_pointer_cast<DirichletBC>(nodal_bc);
264  auto eigen_nbc = std::dynamic_pointer_cast<EigenDirichletBC>(nodal_bc);
265  if (nbc && nbc->getParam<Real>("value"))
266  mooseError(
267  "Can't set an inhomogeneous Dirichlet boundary condition for eigenvalue problems.");
268  else if (!nbc && !eigen_nbc)
269  mooseError("Invalid NodalBC for eigenvalue problems, please use homogeneous Dirichlet.");
270  }
271  }
272 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
Boundary condition of a Dirichlet type.
Definition: DirichletBC.h:25
Set Dirichlet boundary condition for eigenvalue problems.
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs

◆ checkIntegrity() [2/2]

void NonlinearEigenSystem::checkIntegrity ( )
inline

Definition at line 160 of file NonlinearEigenSystem.h.

160 {}

◆ checkKernelCoverage()

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

System Integrity Checks

Definition at line 2935 of file NonlinearSystemBase.C.

2936 {
2937  // Check kernel coverage of subdomains (blocks) in your mesh
2938  std::set<SubdomainID> input_subdomains;
2939  std::set<std::string> kernel_variables;
2940 
2941  bool global_kernels_exist = _kernels.hasActiveBlockObjects(Moose::ANY_BLOCK_ID);
2942  global_kernels_exist |= _scalar_kernels.hasActiveObjects();
2943  global_kernels_exist |= _nodal_kernels.hasActiveObjects();
2944 
2945  _kernels.subdomainsCovered(input_subdomains, kernel_variables);
2946  _nodal_kernels.subdomainsCovered(input_subdomains, kernel_variables);
2947  _scalar_kernels.subdomainsCovered(input_subdomains, kernel_variables);
2948  _constraints.subdomainsCovered(input_subdomains, kernel_variables);
2949 
2950  if (!global_kernels_exist)
2951  {
2952  std::set<SubdomainID> difference;
2953  std::set_difference(mesh_subdomains.begin(),
2954  mesh_subdomains.end(),
2955  input_subdomains.begin(),
2956  input_subdomains.end(),
2957  std::inserter(difference, difference.end()));
2958 
2959  if (!difference.empty())
2960  {
2961  std::stringstream missing_block_ids;
2962  std::copy(difference.begin(),
2963  difference.end(),
2964  std::ostream_iterator<unsigned int>(missing_block_ids, " "));
2965  mooseError("Each subdomain must contain at least one Kernel.\nThe following block(s) lack an "
2966  "active kernel: " +
2967  missing_block_ids.str());
2968  }
2969  }
2970 
2971  std::set<VariableName> variables(getVariableNames().begin(), getVariableNames().end());
2972 
2973  std::set<VariableName> difference;
2974  std::set_difference(variables.begin(),
2975  variables.end(),
2976  kernel_variables.begin(),
2977  kernel_variables.end(),
2978  std::inserter(difference, difference.end()));
2979 
2980  if (!difference.empty())
2981  {
2982  std::stringstream missing_kernel_vars;
2983  std::copy(difference.begin(),
2984  difference.end(),
2985  std::ostream_iterator<std::string>(missing_kernel_vars, " "));
2986  mooseError("Each variable must be referenced by at least one active Kernel.\nThe following "
2987  "variable(s) lack an active kernel: " +
2988  missing_kernel_vars.str());
2989  }
2990 }
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:112
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:735

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

2678 {
2679  // Default to no damping
2680  Real damping = 1.0;
2681  bool has_active_dampers = false;
2682 
2684  {
2685  TIME_SECTION(_compute_dampers_timer);
2686 
2687  has_active_dampers = true;
2690  Threads::parallel_reduce(*_mesh.getActiveLocalElementRange(), cid);
2691  damping = std::min(cid.damping(), damping);
2692  }
2693 
2695  {
2696  TIME_SECTION(_compute_dampers_timer);
2697 
2698  has_active_dampers = true;
2701  Threads::parallel_reduce(*_mesh.getLocalNodeRange(), cndt);
2702  damping = std::min(cndt.damping(), damping);
2703  }
2704 
2706  {
2707  TIME_SECTION(_compute_dampers_timer);
2708 
2709  has_active_dampers = true;
2710  const auto & gdampers = _general_dampers.getActiveObjects();
2711  for (const auto & damper : gdampers)
2712  {
2713  Real gd_damping = damper->computeDamping(solution, update);
2714  try
2715  {
2716  damper->checkMinDamping(gd_damping);
2717  }
2718  catch (MooseException & e)
2719  {
2721  }
2722  damping = std::min(gd_damping, damping);
2723  }
2724  }
2725 
2726  _communicator.min(damping);
2727 
2728  if (has_active_dampers && damping < 1.0)
2729  _console << " Damping factor: " << damping << "\n";
2730 
2731  return damping;
2732 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:739
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:776
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:981
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 2735 of file NonlinearSystemBase.C.

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

2736 {
2738 
2739  std::set<const Elem *> dirac_elements;
2740 
2742  {
2743  TIME_SECTION(_compute_dirac_timer);
2744 
2745  // TODO: Need a threading fix... but it's complicated!
2746  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
2747  {
2748  const auto & dkernels = _dirac_kernels.getActiveObjects(tid);
2749  for (const auto & dkernel : dkernels)
2750  {
2751  dkernel->clearPoints();
2752  dkernel->addPoints();
2753  }
2754  }
2755 
2756  ComputeDiracThread cd(_fe_problem, tags, is_jacobian);
2757 
2758  _fe_problem.getDiracElements(dirac_elements);
2759 
2760  DistElemRange range(dirac_elements.begin(), dirac_elements.end(), 1);
2761  // TODO: Make Dirac work thread!
2762  // Threads::parallel_reduce(range, cd);
2763 
2764  cd(range);
2765  }
2766 }
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:162

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

Referenced by NonlinearSystemBase::computeJacobian().

2509 {
2511 
2512  computeJacobianTags(tags);
2513 
2515 }
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 2495 of file NonlinearSystemBase.C.

2496 {
2497  _nl_matrix_tags.clear();
2498 
2499  auto & tags = _fe_problem.getMatrixTags();
2500 
2501  for (auto & tag : tags)
2502  _nl_matrix_tags.insert(tag.second);
2503 
2504  computeJacobian(jacobian, _nl_matrix_tags);
2505 }
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:162

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

2538 {
2539  _nl_matrix_tags.clear();
2540 
2541  auto & tags = _fe_problem.getMatrixTags();
2542  for (auto & tag : tags)
2543  _nl_matrix_tags.insert(tag.second);
2544 
2546 }
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:162

◆ computeJacobianBlocks() [2/2]

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

Definition at line 2549 of file NonlinearSystemBase.C.

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

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

Referenced by NonlinearSystemBase::computeJacobianTags().

2198 {
2199  // Make matrix ready to use
2201 
2202  for (auto tag : tags)
2203  {
2204  if (!hasMatrix(tag))
2205  continue;
2206 
2207  auto & jacobian = getMatrix(tag);
2208 #ifdef LIBMESH_HAVE_PETSC
2209 // Necessary for speed
2210 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
2211  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
2212 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
2213  // In Petsc 3.0.0, MatSetOption has three args...the third arg
2214  // determines whether the option is set (true) or unset (false)
2215  MatSetOption(
2216  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
2217 #else
2218  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2219  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2220  PETSC_TRUE);
2221 #endif
2222 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
2223 #else
2225  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2226  MAT_NEW_NONZERO_ALLOCATION_ERR,
2227  PETSC_FALSE);
2228 #endif
2229 
2230 #endif
2231  }
2232  // jacobianSetup /////
2233  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
2234  {
2235  _kernels.jacobianSetup(tid);
2239  if (_doing_dg)
2245  }
2250 
2251  // reinit scalar variables
2252  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
2254 
2255  PARALLEL_TRY
2256  {
2257  ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
2258  switch (_fe_problem.coupling())
2259  {
2260  case Moose::COUPLING_DIAG:
2261  {
2263  Threads::parallel_reduce(elem_range, cj);
2264 
2265  unsigned int n_threads = libMesh::n_threads();
2266  for (unsigned int i = 0; i < n_threads;
2267  i++) // Add any Jacobian contributions still hanging around
2269 
2270  // Block restricted Nodal Kernels
2272  {
2274  ConstNodeRange & range = *_mesh.getLocalNodeRange();
2275  Threads::parallel_reduce(range, cnkjt);
2276 
2277  unsigned int n_threads = libMesh::n_threads();
2278  for (unsigned int i = 0; i < n_threads;
2279  i++) // Add any cached jacobians that might be hanging around
2281  }
2282 
2283  // Boundary restricted Nodal Kernels
2285  {
2287  ConstBndNodeRange & bnd_range = *_mesh.getBoundaryNodeRange();
2288 
2289  Threads::parallel_reduce(bnd_range, cnkjt);
2290  unsigned int n_threads = libMesh::n_threads();
2291  for (unsigned int i = 0; i < n_threads;
2292  i++) // Add any cached jacobians that might be hanging around
2294  }
2295  }
2296  break;
2297 
2298  default:
2300  {
2302  Threads::parallel_reduce(elem_range, cj);
2303  unsigned int n_threads = libMesh::n_threads();
2304 
2305  for (unsigned int i = 0; i < n_threads; i++)
2307 
2308  // Block restricted Nodal Kernels
2310  {
2312  ConstNodeRange & range = *_mesh.getLocalNodeRange();
2313  Threads::parallel_reduce(range, cnkjt);
2314 
2315  unsigned int n_threads = libMesh::n_threads();
2316  for (unsigned int i = 0; i < n_threads;
2317  i++) // Add any cached jacobians that might be hanging around
2319  }
2320 
2321  // Boundary restricted Nodal Kernels
2323  {
2325  ConstBndNodeRange & bnd_range = *_mesh.getBoundaryNodeRange();
2326 
2327  Threads::parallel_reduce(bnd_range, cnkjt);
2328 
2329  unsigned int n_threads = libMesh::n_threads();
2330  for (unsigned int i = 0; i < n_threads;
2331  i++) // Add any cached jacobians that might be hanging around
2333  }
2334  }
2335  break;
2336  }
2337 
2338  computeDiracContributions(tags, true);
2339 
2341 
2342  static bool first = true;
2343 
2344  // This adds zeroes into geometric coupling entries to ensure they stay in the matrix
2346  {
2347  first = false;
2349 
2352  }
2353  }
2354  PARALLEL_CATCH;
2355 
2356  closeTaggedMatrices(tags);
2357 
2358  // Have no idea how to have constraints work
2359  // with the tag system
2360  PARALLEL_TRY
2361  {
2362  // Add in Jacobian contributions from Constraints
2364  {
2365  // Nodal Constraints
2367 
2368  // Undisplaced Constraints
2369  constraintJacobians(false);
2370 
2371  // Displaced Constraints
2373  constraintJacobians(true);
2374  }
2375  }
2376  PARALLEL_CATCH;
2378  closeTaggedMatrices(tags);
2379 
2380  // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs on
2381  // boundary nodes
2382  if (_has_diag_save_in)
2384 
2385  PARALLEL_TRY
2386  {
2387  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
2388  // Select nodal kernels
2389  if (tags.size() == _fe_problem.numMatrixTags() || !tags.size())
2390  nbc_warehouse = &_nodal_bcs;
2391  else if (tags.size() == 1)
2392  nbc_warehouse = &(_nodal_bcs.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2393  else
2394  nbc_warehouse = &(_nodal_bcs.getMatrixTagsObjectWarehouse(tags, 0));
2395 
2396  // Cache the information about which BCs are coupled to which
2397  // variables, so we don't have to figure it out for each node.
2398  std::map<std::string, std::set<unsigned int>> bc_involved_vars;
2399  const std::set<BoundaryID> & all_boundary_ids = _mesh.getBoundaryIDs();
2400  for (const auto & bid : all_boundary_ids)
2401  {
2402  // Get reference to all the NodalBCs for this ID. This is only
2403  // safe if there are NodalBCBases there to be gotten...
2404  if (nbc_warehouse->hasActiveBoundaryObjects(bid))
2405  {
2406  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(bid);
2407  for (const auto & bc : bcs)
2408  {
2409  const std::vector<MooseVariableFEBase *> & coupled_moose_vars = bc->getCoupledMooseVars();
2410 
2411  // Create the set of "involved" MOOSE nonlinear vars, which includes all coupled vars and
2412  // the BC's own variable
2413  std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2414  for (const auto & coupled_var : coupled_moose_vars)
2415  if (coupled_var->kind() == Moose::VAR_NONLINEAR)
2416  var_set.insert(coupled_var->number());
2417 
2418  var_set.insert(bc->variable().number());
2419  }
2420  }
2421  }
2422 
2423  // Get variable coupling list. We do all the NodalBCBase stuff on
2424  // thread 0... The couplingEntries() data structure determines
2425  // which variables are "coupled" as far as the preconditioner is
2426  // concerned, not what variables a boundary condition specifically
2427  // depends on.
2428  std::vector<std::pair<MooseVariableFEBase *, MooseVariableFEBase *>> & coupling_entries =
2429  _fe_problem.couplingEntries(/*_tid=*/0);
2430 
2431  // Compute Jacobians for NodalBCBases
2432  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
2433  for (const auto & bnode : bnd_nodes)
2434  {
2435  BoundaryID boundary_id = bnode->_bnd_id;
2436  Node * node = bnode->_node;
2437 
2438  if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id) &&
2439  node->processor_id() == processor_id())
2440  {
2441  _fe_problem.reinitNodeFace(node, boundary_id, 0);
2442 
2443  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
2444  for (const auto & bc : bcs)
2445  {
2446  // Get the set of involved MOOSE vars for this BC
2447  std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2448 
2449  // Loop over all the variables whose Jacobian blocks are
2450  // actually being computed, call computeOffDiagJacobian()
2451  // for each one which is actually coupled (otherwise the
2452  // value is zero.)
2453  for (const auto & it : coupling_entries)
2454  {
2455  unsigned int ivar = it.first->number(), jvar = it.second->number();
2456 
2457  // We are only going to call computeOffDiagJacobian() if:
2458  // 1.) the BC's variable is ivar
2459  // 2.) jvar is "involved" with the BC (including jvar==ivar), and
2460  // 3.) the BC should apply.
2461  if ((bc->variable().number() == ivar) && var_set.count(jvar) && bc->shouldApply())
2462  bc->computeOffDiagJacobian(jvar);
2463  }
2464  }
2465  }
2466  } // end loop over boundary nodes
2467 
2468  // Set the cached NodalBCBase values in the Jacobian matrix
2470  }
2471  PARALLEL_CATCH;
2472 
2473  closeTaggedMatrices(tags);
2474 
2475  // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs on
2476  // boundary nodes
2479 
2480  if (hasDiagSaveIn())
2482 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:739
bool hasActiveBlockObjects(THREAD_ID tid=0) const
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
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:776
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:981
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:2979
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:2155
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:1292
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:157
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:790
MooseObjectTagWarehouse< DiracKernel > _dirac_kernels
Dirac Kernel storage for each thread.
boundary_id_type BoundaryID
Definition: MooseTypes.h:158
unsigned int THREAD_ID
Definition: MooseTypes.h:162
void setCachedJacobianContributions()
Sets previously-cached Jacobian values via SparseMatrix::set() calls.
Definition: Assembly.C:2943

◆ computeJacobianTags()

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

Computes multiple (tag associated) Jacobian matricese.

Definition at line 2518 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobian().

2519 {
2520  TIME_SECTION(_compute_jacobian_tags_timer);
2521 
2522  FloatingPointExceptionGuard fpe_guard(_app);
2523 
2524  try
2525  {
2527  }
2528  catch (MooseException & e)
2529  {
2530  // The buck stops here, we have already handled the exception by
2531  // calling stopSolve(), it is now up to PETSc to return a
2532  // "diverged" reason during the next solve.
2533  }
2534 }
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 1457 of file NonlinearSystemBase.C.

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

1458 {
1459  _nl_vector_tags.clear();
1460 
1461  auto & tags = _fe_problem.getVectorTags();
1462  for (auto & tag : tags)
1463  _nl_vector_tags.insert(tag.second);
1464 
1466  computeNodalBCs(residual, _nl_vector_tags);
1468 }
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:107
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 1471 of file NonlinearSystemBase.C.

1472 {
1474 
1475  computeNodalBCs(tags);
1476 
1478 }
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 1481 of file NonlinearSystemBase.C.

1482 {
1483  // We need to close the diag_save_in variables on the aux system before NodalBCBases clear the
1484  // dofs on boundary nodes
1485  if (_has_save_in)
1487 
1488  PARALLEL_TRY
1489  {
1490  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
1491 
1492  if (!bnd_nodes.empty())
1493  {
1494  TIME_SECTION(_nodal_bcs_timer);
1495 
1496  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
1497 
1498  // Select nodal kernels
1499  if (tags.size() == _fe_problem.numVectorTags() || !tags.size())
1500  nbc_warehouse = &_nodal_bcs;
1501  else if (tags.size() == 1)
1502  nbc_warehouse = &(_nodal_bcs.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1503  else
1504  nbc_warehouse = &(_nodal_bcs.getVectorTagsObjectWarehouse(tags, 0));
1505 
1506  for (const auto & bnode : bnd_nodes)
1507  {
1508  BoundaryID boundary_id = bnode->_bnd_id;
1509  Node * node = bnode->_node;
1510 
1511  if (node->processor_id() == processor_id())
1512  {
1513  // reinit variables in nodes
1514  _fe_problem.reinitNodeFace(node, boundary_id, 0);
1515  if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id))
1516  {
1517  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
1518  for (const auto & nbc : bcs)
1519  if (nbc->shouldApply())
1520  nbc->computeResidual();
1521  }
1522  }
1523  }
1524  }
1525  }
1526  PARALLEL_CATCH;
1527 
1528  if (_Re_time)
1529  _Re_time->close();
1530  _Re_non_time->close();
1531 }
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:122
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:1292
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:790
boundary_id_type BoundaryID
Definition: MooseTypes.h:158

◆ computeResidual()

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

Form a residual vector for a given tag.

Definition at line 584 of file NonlinearSystemBase.C.

585 {
586  mooseDeprecated(" Please use computeResidualTag");
587 
588  computeResidualTag(residual, tag_id);
589 }
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 1277 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTags().

1278 {
1279  TIME_SECTION(_compute_residual_internal_timer);
1280 
1281  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1282  {
1283  _kernels.residualSetup(tid);
1286  if (_doing_dg)
1292  }
1297 
1298  // reinit scalar variables
1299  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
1301 
1302  // residual contributions from the domain
1303  PARALLEL_TRY
1304  {
1305  TIME_SECTION(_kernels_timer);
1306 
1307  ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
1308 
1310 
1311  Threads::parallel_reduce(elem_range, cr);
1312 
1313  unsigned int n_threads = libMesh::n_threads();
1314  for (unsigned int i = 0; i < n_threads;
1315  i++) // Add any cached residuals that might be hanging around
1317  }
1318  PARALLEL_CATCH;
1319 
1320  // residual contributions from the scalar kernels
1321  PARALLEL_TRY
1322  {
1323  // do scalar kernels (not sure how to thread this)
1325  {
1326  TIME_SECTION(_scalar_kernels_timer);
1327 
1328  MooseObjectWarehouse<ScalarKernel> * scalar_kernel_warehouse;
1329  // This code should be refactored once we can do tags for scalar
1330  // kernels
1331  // Should redo this based on Warehouse
1332  if (!tags.size() || tags.size() == _fe_problem.numVectorTags())
1333  scalar_kernel_warehouse = &_scalar_kernels;
1334  else if (tags.size() == 1)
1335  scalar_kernel_warehouse =
1336  &(_scalar_kernels.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1337  else
1338  // scalar_kernels is not threading
1339  scalar_kernel_warehouse = &(_scalar_kernels.getVectorTagsObjectWarehouse(tags, 0));
1340 
1341  bool have_scalar_contributions = false;
1342  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
1343  for (const auto & scalar_kernel : scalars)
1344  {
1345  scalar_kernel->reinit();
1346  const std::vector<dof_id_type> & dof_indices = scalar_kernel->variable().dofIndices();
1347  const DofMap & dof_map = scalar_kernel->variable().dofMap();
1348  const dof_id_type first_dof = dof_map.first_dof();
1349  const dof_id_type end_dof = dof_map.end_dof();
1350  for (dof_id_type dof : dof_indices)
1351  {
1352  if (dof >= first_dof && dof < end_dof)
1353  {
1354  scalar_kernel->computeResidual();
1355  have_scalar_contributions = true;
1356  break;
1357  }
1358  }
1359  }
1360  if (have_scalar_contributions)
1362  }
1363  }
1364  PARALLEL_CATCH;
1365 
1366  // residual contributions from Block NodalKernels
1367  PARALLEL_TRY
1368  {
1370  {
1371  TIME_SECTION(_nodal_kernels_timer);
1372 
1374 
1375  ConstNodeRange & range = *_mesh.getLocalNodeRange();
1376 
1377  if (range.begin() != range.end())
1378  {
1379  _fe_problem.reinitNode(*range.begin(), 0);
1380 
1381  Threads::parallel_reduce(range, cnk);
1382 
1383  unsigned int n_threads = libMesh::n_threads();
1384  for (unsigned int i = 0; i < n_threads;
1385  i++) // Add any cached residuals that might be hanging around
1387  }
1388  }
1389  }
1390  PARALLEL_CATCH;
1391 
1392  // residual contributions from boundary NodalKernels
1393  PARALLEL_TRY
1394  {
1396  {
1397  TIME_SECTION(_nodal_kernel_bcs_timer);
1398 
1400 
1401  ConstBndNodeRange & bnd_node_range = *_mesh.getBoundaryNodeRange();
1402 
1403  Threads::parallel_reduce(bnd_node_range, cnk);
1404 
1405  unsigned int n_threads = libMesh::n_threads();
1406  for (unsigned int i = 0; i < n_threads;
1407  i++) // Add any cached residuals that might be hanging around
1409  }
1410  }
1411  PARALLEL_CATCH;
1412 
1413  if (_need_residual_copy)
1414  {
1415  _Re_non_time->close();
1416  _Re_non_time->localize(_residual_copy);
1417  }
1418 
1420  {
1421  _Re_non_time->close();
1423  _residual_ghosted->close();
1424  }
1425 
1426  PARALLEL_TRY { computeDiracContributions(tags, false); }
1427  PARALLEL_CATCH;
1428 
1430  {
1431  PARALLEL_TRY { enforceNodalConstraintsResidual(*_Re_non_time); }
1432  PARALLEL_CATCH;
1433  _Re_non_time->close();
1434  }
1435 
1436  // Add in Residual contributions from Constraints
1438  {
1439  PARALLEL_TRY
1440  {
1441  // Undisplaced Constraints
1443 
1444  // Displaced Constraints
1447 
1450  }
1451  PARALLEL_CATCH;
1452  _Re_non_time->close();
1453  }
1454 }
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:739
bool hasActiveBlockObjects(THREAD_ID tid=0) const
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
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:521
virtual unsigned int numVectorTags()
The total number of tags.
Definition: SubProblem.h:122
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
ConstNodeRange * getLocalNodeRange()
Definition: MooseMesh.C:776
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:1292
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:790
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:162

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

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

570 {
571 
572  _nl_vector_tags.clear();
573  _nl_vector_tags.insert(tag_id);
575 
577 
579 
581 }
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 592 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTag().

593 {
594  TIME_SECTION(_compute_residual_tags_timer);
595 
596  bool required_residual = tags.find(residualVectorTag()) == tags.end() ? false : true;
597 
599 
600  // not suppose to do anythin on matrix
602 
604 
605  for (const auto & numeric_vec : _vecs_to_zero_for_residual)
606  if (hasVector(numeric_vec))
607  {
608  NumericVector<Number> & vec = getVector(numeric_vec);
609  vec.close();
610  vec.zero();
611  }
612 
613  try
614  {
615  zeroTaggedVectors(tags);
617  closeTaggedVectors(tags);
618 
619  if (required_residual)
620  {
621  auto & residual = getVector(residualVectorTag());
622  if (_time_integrator)
623  _time_integrator->postResidual(residual);
624  else
625  residual += *_Re_non_time;
626  residual.close();
627  }
628  computeNodalBCs(tags);
629  closeTaggedVectors(tags);
630 
631  // If we are debugging residuals we need one more assignment to have the ghosted copy up to date
632  if (_need_residual_ghosted && _debugging_residuals && required_residual)
633  {
634  auto & residual = getVector(residualVectorTag());
635 
636  *_residual_ghosted = residual;
637  _residual_ghosted->close();
638  }
639  // Need to close and update the aux system in case residuals were saved to it.
642  if (hasSaveIn())
644  }
645  catch (MooseException & e)
646  {
647  // The buck stops here, we have already handled the exception by
648  // calling stopSolve(), it is now up to PETSc to return a
649  // "diverged" reason during the next solve.
650  }
651 
652  // not supposed to do anything on matrix
654 }
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:981
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 2153 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

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

◆ computeTimeDerivatives()

void NonlinearSystemBase::computeTimeDerivatives ( )
inherited

Computes the time derivative vector.

Definition at line 764 of file NonlinearSystemBase.C.

765 {
766  if (_time_integrator)
767  {
768  _time_integrator->preStep();
769  _time_integrator->computeTimeDerivatives();
770  }
771 }
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 1681 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

1682 {
1683  if (!hasMatrix(systemMatrixTag()))
1684  mooseError("A system matrix is required");
1685 
1686  auto & jacobian = getMatrix(systemMatrixTag());
1687 
1688 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
1689 #else
1691  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
1692  MAT_NEW_NONZERO_ALLOCATION_ERR,
1693  PETSC_FALSE);
1695  MatSetOption(
1696  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE);
1697 #endif
1698 
1699  std::vector<numeric_index_type> zero_rows;
1700  std::map<std::pair<unsigned int, unsigned int>, PenetrationLocator *> * penetration_locators =
1701  NULL;
1702 
1703  if (!displaced)
1704  {
1705  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
1706  penetration_locators = &geom_search_data._penetration_locators;
1707  }
1708  else
1709  {
1710  GeometricSearchData & displaced_geom_search_data =
1711  _fe_problem.getDisplacedProblem()->geomSearchData();
1712  penetration_locators = &displaced_geom_search_data._penetration_locators;
1713  }
1714 
1715  bool constraints_applied;
1717  constraints_applied = false;
1718  for (const auto & it : *penetration_locators)
1719  {
1721  {
1722  // Reset the constraint_applied flag before each new constraint, as they need to be assembled
1723  // separately
1724  constraints_applied = false;
1725  }
1726  PenetrationLocator & pen_loc = *(it.second);
1727 
1728  std::vector<dof_id_type> & slave_nodes = pen_loc._nearest_node._slave_nodes;
1729 
1730  BoundaryID slave_boundary = pen_loc._slave_boundary;
1731 
1732  zero_rows.clear();
1733  if (_constraints.hasActiveNodeFaceConstraints(slave_boundary, displaced))
1734  {
1735  const auto & constraints =
1736  _constraints.getActiveNodeFaceConstraints(slave_boundary, displaced);
1737 
1738  for (const auto & slave_node_num : slave_nodes)
1739  {
1740  Node & slave_node = _mesh.nodeRef(slave_node_num);
1741 
1742  if (slave_node.processor_id() == processor_id())
1743  {
1744  if (pen_loc._penetration_info[slave_node_num])
1745  {
1746  PenetrationInfo & info = *pen_loc._penetration_info[slave_node_num];
1747 
1748  const Elem * master_elem = info._elem;
1749  unsigned int master_side = info._side_num;
1750 
1751  // reinit variables at the node
1752  _fe_problem.reinitNodeFace(&slave_node, slave_boundary, 0);
1753 
1756 
1757  std::vector<Point> points;
1758  points.push_back(info._closest_point);
1759 
1760  // reinit variables on the master element's face at the contact point
1761  _fe_problem.setNeighborSubdomainID(master_elem, 0);
1762  _fe_problem.reinitNeighborPhys(master_elem, master_side, points, 0);
1763  for (const auto & nfc : constraints)
1764  {
1765  nfc->_jacobian = &jacobian;
1766 
1767  if (nfc->shouldApply())
1768  {
1769  constraints_applied = true;
1770 
1771  nfc->subProblem().prepareShapes(nfc->variable().number(), 0);
1772  nfc->subProblem().prepareNeighborShapes(nfc->variable().number(), 0);
1773 
1774  nfc->computeJacobian();
1775 
1776  if (nfc->overwriteSlaveJacobian())
1777  {
1778  // Add this variable's dof's row to be zeroed
1779  zero_rows.push_back(nfc->variable().nodalDofIndex());
1780  }
1781 
1782  std::vector<dof_id_type> slave_dofs(1, nfc->variable().nodalDofIndex());
1783 
1784  // Cache the jacobian block for the slave side
1786  slave_dofs,
1787  nfc->_connected_dof_indices,
1788  nfc->variable().scalingFactor());
1789 
1790  // Cache the jacobian block for the master side
1791  if (nfc->addCouplingEntriesToJacobian())
1793  nfc->_Kne,
1794  nfc->masterVariable().dofIndicesNeighbor(),
1795  nfc->_connected_dof_indices,
1796  nfc->variable().scalingFactor());
1797 
1799  if (nfc->addCouplingEntriesToJacobian())
1801 
1802  // Do the off-diagonals next
1803  const std::vector<MooseVariableFEBase *> coupled_vars = nfc->getCoupledMooseVars();
1804  for (const auto & jvar : coupled_vars)
1805  {
1806  // Only compute jacobians for nonlinear variables
1807  if (jvar->kind() != Moose::VAR_NONLINEAR)
1808  continue;
1809 
1810  // Only compute Jacobian entries if this coupling is being used by the
1811  // preconditioner
1812  if (nfc->variable().number() == jvar->number() ||
1813  !_fe_problem.areCoupled(nfc->variable().number(), jvar->number()))
1814  continue;
1815 
1816  // Need to zero out the matrices first
1818 
1819  nfc->subProblem().prepareShapes(nfc->variable().number(), 0);
1820  nfc->subProblem().prepareNeighborShapes(jvar->number(), 0);
1821 
1822  nfc->computeOffDiagJacobian(jvar->number());
1823 
1824  // Cache the jacobian block for the slave side
1826  slave_dofs,
1827  nfc->_connected_dof_indices,
1828  nfc->variable().scalingFactor());
1829 
1830  // Cache the jacobian block for the master side
1831  if (nfc->addCouplingEntriesToJacobian())
1833  nfc->variable().dofIndicesNeighbor(),
1834  nfc->_connected_dof_indices,
1835  nfc->variable().scalingFactor());
1836 
1838  if (nfc->addCouplingEntriesToJacobian())
1840  }
1841  }
1842  }
1843  }
1844  }
1845  }
1846  }
1848  {
1849  // See if constraints were applied anywhere
1850  _communicator.max(constraints_applied);
1851 
1852  if (constraints_applied)
1853  {
1854 #ifdef LIBMESH_HAVE_PETSC
1855 // Necessary for speed
1856 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
1857  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
1858 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
1859  // In Petsc 3.0.0, MatSetOption has three args...the third arg
1860  // determines whether the option is set (true) or unset (false)
1861  MatSetOption(
1862  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
1863 #else
1864  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
1865  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
1866  PETSC_TRUE);
1867 #endif
1868 #endif
1869 
1870  jacobian.close();
1871  jacobian.zero_rows(zero_rows, 0.0);
1872  jacobian.close();
1874  jacobian.close();
1875  }
1876  }
1877  }
1879  {
1880  // See if constraints were applied anywhere
1881  _communicator.max(constraints_applied);
1882 
1883  if (constraints_applied)
1884  {
1885 #ifdef LIBMESH_HAVE_PETSC
1886 // Necessary for speed
1887 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
1888  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
1889 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
1890  // In Petsc 3.0.0, MatSetOption has three args...the third arg
1891  // determines whether the option is set (true) or unset (false)
1892  MatSetOption(
1893  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
1894 #else
1895  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
1896  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
1897  PETSC_TRUE);
1898 #endif
1899 #endif
1900 
1901  jacobian.close();
1902  jacobian.zero_rows(zero_rows, 0.0);
1903  jacobian.close();
1905  jacobian.close();
1906  }
1907  }
1908 
1909  THREAD_ID tid = 0;
1910  // go over mortar interfaces
1911  auto & ifaces = _mesh.getMortarInterfaces();
1912  for (const auto & iface : ifaces)
1913  {
1914  if (_constraints.hasActiveMortarConstraints(iface->_name))
1915  {
1916  // MortarConstraint objects
1917  const auto & face_constraints = _constraints.getActiveMortarConstraints(iface->_name);
1918 
1919  // go over elements on that interface
1920  const std::vector<Elem *> & elems = iface->_elems;
1921  for (const auto & elem : elems)
1922  {
1923  // for each element process constraints on the
1924  for (const auto & ffc : face_constraints)
1925  {
1927  _fe_problem.prepare(elem, tid);
1928  _fe_problem.reinitElem(elem, tid);
1929  ffc->reinit();
1930  ffc->subProblem().prepareShapes(ffc->variable().number(), tid);
1931  ffc->computeJacobian();
1933 
1934  ffc->reinitSide(Moose::Master);
1935  ffc->computeJacobianSide(Moose::Master);
1937 
1938  ffc->reinitSide(Moose::Slave);
1939  ffc->computeJacobianSide(Moose::Slave);
1941  }
1942 
1944  }
1945  }
1946  }
1947 
1948  // go over element-element constraint interface
1949  std::map<unsigned int, std::shared_ptr<ElementPairLocator>> * element_pair_locators = nullptr;
1950 
1951  if (!displaced)
1952  {
1953  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
1954  element_pair_locators = &geom_search_data._element_pair_locators;
1955  }
1956  else
1957  {
1958  GeometricSearchData & displaced_geom_search_data =
1959  _fe_problem.getDisplacedProblem()->geomSearchData();
1960  element_pair_locators = &displaced_geom_search_data._element_pair_locators;
1961  }
1962 
1963  for (const auto & it : *element_pair_locators)
1964  {
1965  ElementPairLocator & elem_pair_loc = *(it.second);
1966 
1967  if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
1968  {
1969  // ElemElemConstraint objects
1970  const auto & _element_constraints =
1971  _constraints.getActiveElemElemConstraints(it.first, displaced);
1972 
1973  // go over pair elements
1974  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
1975  elem_pair_loc.getElemPairs();
1976  for (const auto & pr : elem_pairs)
1977  {
1978  const Elem * elem1 = pr.first;
1979  const Elem * elem2 = pr.second;
1980 
1981  if (elem1->processor_id() != processor_id())
1982  continue;
1983 
1984  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
1985 
1986  // for each element process constraints on the
1987  for (const auto & ec : _element_constraints)
1988  {
1989  _fe_problem.setCurrentSubdomainID(elem1, tid);
1991  _fe_problem.setNeighborSubdomainID(elem2, tid);
1993 
1994  ec->subProblem().prepareShapes(ec->variable().number(), tid);
1995  ec->subProblem().prepareNeighborShapes(ec->variable().number(), tid);
1996 
1997  ec->reinit(info);
1998  ec->computeJacobian();
2001  }
2003  }
2004  }
2005  }
2006 
2007  // go over NodeELemConstraints
2008  std::set<dof_id_type> unique_slave_node_ids;
2009  constraints_applied = false;
2010  for (const auto & slave_id : _mesh.meshSubdomains())
2011  {
2012  for (const auto & master_id : _mesh.meshSubdomains())
2013  {
2014  if (_constraints.hasActiveNodeElemConstraints(slave_id, master_id, displaced))
2015  {
2016  const auto & constraints =
2017  _constraints.getActiveNodeElemConstraints(slave_id, master_id, displaced);
2018 
2019  // get unique set of ids of all nodes on current block
2020  unique_slave_node_ids.clear();
2021  const MeshBase & meshhelper = _mesh.getMesh();
2022  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(slave_id),
2023  meshhelper.active_subdomain_elements_end(slave_id)))
2024  {
2025  for (auto & n : elem->node_ref_range())
2026  unique_slave_node_ids.insert(n.id());
2027  }
2028 
2029  for (auto slave_node_id : unique_slave_node_ids)
2030  {
2031  const Node & slave_node = _mesh.nodeRef(slave_node_id);
2032  // check if slave node is on current processor
2033  if (slave_node.processor_id() == processor_id())
2034  {
2035  // This reinits the variables that exist on the slave node
2036  _fe_problem.reinitNodeFace(&slave_node, slave_id, 0);
2037 
2038  // This will set aside residual and jacobian space for the variables that have dofs
2039  // on the slave node
2042 
2043  for (const auto & nec : constraints)
2044  {
2045  if (nec->shouldApply())
2046  {
2047  constraints_applied = true;
2048 
2049  nec->_jacobian = &jacobian;
2050  nec->subProblem().prepareShapes(nec->variable().number(), 0);
2051  nec->subProblem().prepareNeighborShapes(nec->variable().number(), 0);
2052 
2053  nec->computeJacobian();
2054 
2055  if (nec->overwriteSlaveJacobian())
2056  {
2057  // Add this variable's dof's row to be zeroed
2058  zero_rows.push_back(nec->variable().nodalDofIndex());
2059  }
2060 
2061  std::vector<dof_id_type> slave_dofs(1, nec->variable().nodalDofIndex());
2062 
2063  // Cache the jacobian block for the slave side
2065  slave_dofs,
2066  nec->_connected_dof_indices,
2067  nec->variable().scalingFactor());
2068 
2069  // Cache the jacobian block for the master side
2071  nec->_Kne,
2072  nec->masterVariable().dofIndicesNeighbor(),
2073  nec->_connected_dof_indices,
2074  nec->variable().scalingFactor());
2075 
2078 
2079  // Do the off-diagonals next
2080  const std::vector<MooseVariableFEBase *> coupled_vars = nec->getCoupledMooseVars();
2081  for (const auto & jvar : coupled_vars)
2082  {
2083  // Only compute jacobians for nonlinear variables
2084  if (jvar->kind() != Moose::VAR_NONLINEAR)
2085  continue;
2086 
2087  // Only compute Jacobian entries if this coupling is being used by the
2088  // preconditioner
2089  if (nec->variable().number() == jvar->number() ||
2090  !_fe_problem.areCoupled(nec->variable().number(), jvar->number()))
2091  continue;
2092 
2093  // Need to zero out the matrices first
2095 
2096  nec->subProblem().prepareShapes(nec->variable().number(), 0);
2097  nec->subProblem().prepareNeighborShapes(jvar->number(), 0);
2098 
2099  nec->computeOffDiagJacobian(jvar->number());
2100 
2101  // Cache the jacobian block for the slave side
2103  slave_dofs,
2104  nec->_connected_dof_indices,
2105  nec->variable().scalingFactor());
2106 
2107  // Cache the jacobian block for the master side
2109  nec->variable().dofIndicesNeighbor(),
2110  nec->_connected_dof_indices,
2111  nec->variable().scalingFactor());
2112 
2115  }
2116  }
2117  }
2118  }
2119  }
2120  }
2121  }
2122  }
2123  // See if constraints were applied anywhere
2124  _communicator.max(constraints_applied);
2125 
2126  if (constraints_applied)
2127  {
2128 #ifdef LIBMESH_HAVE_PETSC
2129 // Necessary for speed
2130 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
2131  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
2132 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
2133  // In Petsc 3.0.0, MatSetOption has three args...the third arg
2134  // determines whether the option is set (true) or unset (false)
2135  MatSetOption(
2136  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
2137 #else
2138  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2139  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2140  PETSC_TRUE);
2141 #endif
2142 #endif
2143 
2144  jacobian.close();
2145  jacobian.zero_rows(zero_rows, 0.0);
2146  jacobian.close();
2148  jacobian.close();
2149  }
2150 }
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:438
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:825
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:2569
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:2540
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:162
boundary_id_type BoundaryID
Definition: MooseTypes.h:158
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:2318
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 959 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualInternal().

960 {
961  // Make sure the residual is in a good state
962  residual.close();
963 
964  std::map<std::pair<unsigned int, unsigned int>, PenetrationLocator *> * penetration_locators =
965  NULL;
966 
967  if (!displaced)
968  {
969  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
970  penetration_locators = &geom_search_data._penetration_locators;
971  }
972  else
973  {
974  GeometricSearchData & displaced_geom_search_data =
975  _fe_problem.getDisplacedProblem()->geomSearchData();
976  penetration_locators = &displaced_geom_search_data._penetration_locators;
977  }
978 
979  bool constraints_applied;
980  bool residual_has_inserted_values = false;
982  constraints_applied = false;
983  for (const auto & it : *penetration_locators)
984  {
986  {
987  // Reset the constraint_applied flag before each new constraint, as they need to be assembled
988  // separately
989  constraints_applied = false;
990  }
991  PenetrationLocator & pen_loc = *(it.second);
992 
993  std::vector<dof_id_type> & slave_nodes = pen_loc._nearest_node._slave_nodes;
994 
995  BoundaryID slave_boundary = pen_loc._slave_boundary;
996 
997  if (_constraints.hasActiveNodeFaceConstraints(slave_boundary, displaced))
998  {
999  const auto & constraints =
1000  _constraints.getActiveNodeFaceConstraints(slave_boundary, displaced);
1001 
1002  for (unsigned int i = 0; i < slave_nodes.size(); i++)
1003  {
1004  dof_id_type slave_node_num = slave_nodes[i];
1005  Node & slave_node = _mesh.nodeRef(slave_node_num);
1006 
1007  if (slave_node.processor_id() == processor_id())
1008  {
1009  if (pen_loc._penetration_info[slave_node_num])
1010  {
1011  PenetrationInfo & info = *pen_loc._penetration_info[slave_node_num];
1012 
1013  const Elem * master_elem = info._elem;
1014  unsigned int master_side = info._side_num;
1015 
1016  // *These next steps MUST be done in this order!*
1017 
1018  // This reinits the variables that exist on the slave node
1019  _fe_problem.reinitNodeFace(&slave_node, slave_boundary, 0);
1020 
1021  // This will set aside residual and jacobian space for the variables that have dofs on
1022  // the slave node
1024 
1025  std::vector<Point> points;
1026  points.push_back(info._closest_point);
1027 
1028  // reinit variables on the master element's face at the contact point
1029  _fe_problem.setNeighborSubdomainID(master_elem, 0);
1030  _fe_problem.reinitNeighborPhys(master_elem, master_side, points, 0);
1031 
1032  for (const auto & nfc : constraints)
1033  if (nfc->shouldApply())
1034  {
1035  constraints_applied = true;
1036  nfc->computeResidual();
1037 
1038  if (nfc->overwriteSlaveResidual())
1039  {
1040  _fe_problem.setResidual(residual, 0);
1041  residual_has_inserted_values = true;
1042  }
1043  else
1046  }
1047  }
1048  }
1049  }
1050  }
1052  {
1053  // Make sure that slave contribution to master are assembled, and ghosts have been exchanged,
1054  // as current masters might become slaves on next iteration
1055  // and will need to contribute their former slaves' contributions
1056  // to the future masters.
1057  // See if constraints were applied anywhere
1058  _communicator.max(constraints_applied);
1059 
1060  if (constraints_applied)
1061  {
1062  // If any of the above constraints inserted values in the residual, it needs to be assembled
1063  // before adding the cached residuals below.
1064  _communicator.max(residual_has_inserted_values);
1065  if (residual_has_inserted_values)
1066  {
1067  residual.close();
1068  residual_has_inserted_values = false;
1069  }
1071  residual.close();
1072 
1074  *_residual_ghosted = residual;
1075  }
1076  }
1077  }
1079  {
1080  _communicator.max(constraints_applied);
1081 
1082  if (constraints_applied)
1083  {
1084  // If any of the above constraints inserted values in the residual, it needs to be assembled
1085  // before adding the cached residuals below.
1086  _communicator.max(residual_has_inserted_values);
1087  if (residual_has_inserted_values)
1088  residual.close();
1089 
1091  residual.close();
1092 
1094  *_residual_ghosted = residual;
1095  }
1096  }
1097 
1098  THREAD_ID tid = 0;
1099  // go over mortar interfaces
1100  auto & ifaces = _mesh.getMortarInterfaces();
1101  for (const auto & iface : ifaces)
1102  {
1103  if (_constraints.hasActiveMortarConstraints(iface->_name))
1104  {
1105  const auto & face_constraints = _constraints.getActiveMortarConstraints(iface->_name);
1106 
1107  // go over elements on that interface
1108  const std::vector<Elem *> & elems = iface->_elems;
1109  for (const auto & elem : elems)
1110  {
1111  // for each element process constraints on the
1113  _fe_problem.prepare(elem, tid);
1114  _fe_problem.reinitElem(elem, tid);
1115 
1116  for (const auto & ffc : face_constraints)
1117  {
1118  ffc->reinit();
1119  ffc->computeResidual();
1120  }
1122 
1123  // evaluate residuals that go into master and slave side
1124  for (const auto & ffc : face_constraints)
1125  {
1126  ffc->reinitSide(Moose::Master);
1127  ffc->computeResidualSide(Moose::Master);
1129 
1130  ffc->reinitSide(Moose::Slave);
1131  ffc->computeResidualSide(Moose::Slave);
1133  }
1134  }
1136  }
1137  }
1138 
1139  // go over element-element constraint interface
1140  std::map<unsigned int, std::shared_ptr<ElementPairLocator>> * element_pair_locators = nullptr;
1141 
1142  if (!displaced)
1143  {
1144  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
1145  element_pair_locators = &geom_search_data._element_pair_locators;
1146  }
1147  else
1148  {
1149  GeometricSearchData & displaced_geom_search_data =
1150  _fe_problem.getDisplacedProblem()->geomSearchData();
1151  element_pair_locators = &displaced_geom_search_data._element_pair_locators;
1152  }
1153 
1154  for (const auto & it : *element_pair_locators)
1155  {
1156  ElementPairLocator & elem_pair_loc = *(it.second);
1157 
1158  if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
1159  {
1160  // ElemElemConstraint objects
1161  const auto & _element_constraints =
1162  _constraints.getActiveElemElemConstraints(it.first, displaced);
1163 
1164  // go over pair elements
1165  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
1166  elem_pair_loc.getElemPairs();
1167  for (const auto & pr : elem_pairs)
1168  {
1169  const Elem * elem1 = pr.first;
1170  const Elem * elem2 = pr.second;
1171 
1172  if (elem1->processor_id() != processor_id())
1173  continue;
1174 
1175  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
1176 
1177  // for each element process constraints on the
1178  for (const auto & ec : _element_constraints)
1179  {
1180  _fe_problem.setCurrentSubdomainID(elem1, tid);
1182  _fe_problem.setNeighborSubdomainID(elem2, tid);
1184 
1185  ec->subProblem().prepareShapes(ec->variable().number(), tid);
1186  ec->subProblem().prepareNeighborShapes(ec->variable().number(), tid);
1187 
1188  ec->reinit(info);
1189  ec->computeResidual();
1192  }
1194  }
1195  }
1196  }
1197 
1198  // go over NodeELemConstraints
1199  std::set<dof_id_type> unique_slave_node_ids;
1200 
1201  constraints_applied = false;
1202  residual_has_inserted_values = false;
1203  for (const auto & slave_id : _mesh.meshSubdomains())
1204  {
1205  for (const auto & master_id : _mesh.meshSubdomains())
1206  {
1207  if (_constraints.hasActiveNodeElemConstraints(slave_id, master_id, displaced))
1208  {
1209  const auto & constraints =
1210  _constraints.getActiveNodeElemConstraints(slave_id, master_id, displaced);
1211 
1212  // get unique set of ids of all nodes on current block
1213  unique_slave_node_ids.clear();
1214  const MeshBase & meshhelper = _mesh.getMesh();
1215  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(slave_id),
1216  meshhelper.active_subdomain_elements_end(slave_id)))
1217  {
1218  for (auto & n : elem->node_ref_range())
1219  unique_slave_node_ids.insert(n.id());
1220  }
1221 
1222  for (auto slave_node_id : unique_slave_node_ids)
1223  {
1224  Node & slave_node = _mesh.nodeRef(slave_node_id);
1225  // check if slave node is on current processor
1226  if (slave_node.processor_id() == processor_id())
1227  {
1228  // This reinits the variables that exist on the slave node
1229  _fe_problem.reinitNodeFace(&slave_node, slave_id, 0);
1230 
1231  // This will set aside residual and jacobian space for the variables that have dofs
1232  // on the slave node
1234 
1235  for (const auto & nec : constraints)
1236  {
1237  if (nec->shouldApply())
1238  {
1239  constraints_applied = true;
1240  nec->computeResidual();
1241 
1242  if (nec->overwriteSlaveResidual())
1243  {
1244  _fe_problem.setResidual(residual, 0);
1245  residual_has_inserted_values = true;
1246  }
1247  else
1250  }
1251  }
1253  }
1254  }
1255  }
1256  }
1257  }
1258  _communicator.max(constraints_applied);
1259 
1260  if (constraints_applied)
1261  {
1262  // If any of the above constraints inserted values in the residual, it needs to be assembled
1263  // before adding the cached residuals below.
1264  _communicator.max(residual_has_inserted_values);
1265  if (residual_has_inserted_values)
1266  residual.close();
1267 
1269  residual.close();
1270 
1272  *_residual_ghosted = residual;
1273  }
1274 }
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:438
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:825
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:2569
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:162
boundary_id_type BoundaryID
Definition: MooseTypes.h:158
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:2318
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

◆ containsTimeKernel()

bool NonlinearSystemBase::containsTimeKernel ( )
inherited

Definition at line 2993 of file NonlinearSystemBase.C.

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

2994 {
2995  auto & time_kernels = _kernels.getVectorTagObjectWarehouse(timeVectorTag(), 0);
2996 
2997  return time_kernels.hasActiveObjects();
2998 }
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() [1/2]

bool NonlinearEigenSystem::converged ( )
overridevirtual

Returns the convergence state.

Returns
true if converged, otherwise false

Implements NonlinearSystemBase.

Definition at line 226 of file NonlinearEigenSystem.C.

227 {
228  return _transient_sys.get_n_converged();
229 }
TransientEigenSystem & _transient_sys

◆ converged() [2/2]

bool NonlinearEigenSystem::converged ( )
inlinevirtual

Returns the convergence state.

Returns
true if converged, otherwise false

Implements NonlinearSystemBase.

Definition at line 158 of file NonlinearEigenSystem.h.

158 { return false; }

◆ copyOldSolutions()

void SystemBase::copyOldSolutions ( )
virtualinherited

Shifts the solutions backwards in time.

Definition at line 1013 of file SystemBase.C.

Referenced by EigenExecutionerBase::inversePowerIteration().

1014 {
1015  solutionOlder() = solutionOld();
1017  if (solutionUDotOld())
1018  *solutionUDotOld() = *solutionUDot();
1019  if (solutionUDotDotOld())
1021  if (solutionPreviousNewton())
1023 }
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 996 of file SystemBase.C.

997 {
998  system().update();
1001  if (solutionUDotOld())
1002  *solutionUDotOld() = *solutionUDot();
1003  if (solutionUDotDotOld())
1005  if (solutionPreviousNewton())
1007 }
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 
939  if (hasVariable(vci._dest_name))
940  {
941  if (getVariable(0, vci._dest_name).isNodal())
942  io.copy_nodal_solution(system(), vci._dest_name, vci._source_name, timestep);
943 
944  else
945  io.copy_elemental_solution(system(), vci._dest_name, vci._source_name, timestep);
946  }
947  else if (hasScalarVariable(vci._dest_name))
948  {
949  auto rank = comm().rank();
950  auto size = comm().size();
951 
952  // Read solution on rank 0 only and send data to rank "size - 1" where scalar DOFs are stored
953  std::vector<Real> global_values;
954  if (rank == 0)
955  {
956  // Read the scalar value then set that value in the current solution
957  io.read_global_variable({vci._source_name}, timestep, global_values);
958  if (size > 1)
959  comm().send(size - 1, global_values);
960  }
961  if (rank == size - 1)
962  {
963  if (size > 1)
964  comm().receive(0, global_values);
965  const unsigned int var_num = system().variable_number(vci._dest_name);
966  system().solution->set(var_num, global_values[0]);
967  }
968  }
969  }
970 
971  if (did_copy)
972  solution().close();
973 }
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 bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition: SystemBase.C:652
MPI_Comm comm
virtual NumericVector< Number > & solution()=0
virtual bool hasScalarVariable(const std::string &var_name) const
Definition: SystemBase.C:661

◆ 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:157

◆ 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  _matrix_tag_active_flags.resize(tag + 1);
849 
850  _matrix_tag_active_flags[tag] = false;
851 }
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:128
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:719
SubProblem & _subproblem
Definition: SystemBase.h:694

◆ debuggingResiduals()

void NonlinearSystemBase::debuggingResiduals ( bool  state)
inlineinherited

Definition at line 504 of file NonlinearSystemBase.h.

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

◆ disassociateAllTaggedMatrices()

void SystemBase::disassociateAllTaggedMatrices ( )
virtualinherited

Clear all tagged matrices.

Reimplemented in DisplacedSystem.

Definition at line 887 of file SystemBase.C.

Referenced by DisplacedSystem::disassociateAllTaggedMatrices().

888 {
889  for (auto & matrix : _tagged_matrices)
890  matrix = nullptr;
891 }
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:717

◆ disassociateAllTaggedVectors()

void SystemBase::disassociateAllTaggedVectors ( )
virtualinherited

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

Reimplemented in DisplacedSystem.

Definition at line 774 of file SystemBase.C.

Referenced by DisplacedSystem::disassociateAllTaggedVectors().

775 {
776  for (auto & tagged_vector : _tagged_vectors)
777  tagged_vector = nullptr;
778 }
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:715

◆ disassociateMatrixFromTag()

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

disassociate a matirx from a tag

Reimplemented in DisplacedSystem.

Definition at line 815 of file SystemBase.C.

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

816 {
817  mooseAssert(_subproblem.matrixTagExists(tag),
818  "Cannot disassociate Matrix with matrix_tag : " << tag << "that does not exist");
819 
820  if (_tagged_matrices.size() < tag + 1)
821  _tagged_matrices.resize(tag + 1);
822 
823  if (_tagged_matrices[tag] != &matrix)
824  mooseError("You can not disassociate a matrix from a tag which it was not associated to");
825 
826  _tagged_matrices[tag] = nullptr;
827 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208