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

#include <MooseEigenSystem.h>

Inheritance diagram for MooseEigenSystem:
[legend]

Public Types

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

Public Member Functions

 MooseEigenSystem (FEProblemBase &problem, const std::string &name)
 
virtual ~MooseEigenSystem ()
 
virtual void addKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a kernel. More...
 
virtual void markEigenVariable (const VariableName &var_name)
 Mark a variable as a variable of the eigen system. More...
 
void scaleSystemSolution (SYSTEMTAG tag, Real scaling_factor)
 Scale the solution vector. More...
 
void combineSystemSolution (SYSTEMTAG tag, const std::vector< Real > &coefficients)
 Linear combination of the solution vectors. More...
 
void initSystemSolution (SYSTEMTAG tag, Real v)
 Initialize the solution vector with a constant value. More...
 
void initSystemSolutionOld (SYSTEMTAG tag, Real v)
 
void eigenKernelOnOld ()
 Ask eigenkernels to operate on old or current solution vectors. More...
 
void eigenKernelOnCurrent ()
 
void buildSystemDoFIndices (SYSTEMTAG tag=ALL)
 Build DoF indices for a system. More...
 
bool activeOnOld ()
 Return if eigen kernels should be on old solution. More...
 
const std::set< VariableName > & getEigenVariableNames () const
 Get variable names of the eigen system. More...
 
bool containsEigenKernel () const
 Weather or not the system contains eigen kernels. More...
 
virtual SparseMatrix< Number > & addMatrix (TagID tag) override
 Adds a jacobian sized vector. More...
 
virtual void solve () override
 Solve the system (using libMesh magic) More...
 
virtual void stopSolve () override
 Quit the current solve as soon as possible. More...
 
virtual unsigned int getCurrentNonlinearIterationNumber () override
 Returns the current nonlinear iteration number. More...
 
virtual void setupFiniteDifferencedPreconditioner () override
 
virtual bool converged () override
 Returns the convergence state. More...
 
virtual NumericVector< Number > & RHS () override
 
virtual NonlinearSolver< Number > * nonlinearSolver () override
 
virtual NumericVector< Number > & solutionOld () override
 
virtual NumericVector< Number > & solutionOlder () override
 
virtual TransientNonlinearImplicitSystem & sys ()
 
virtual void init () override
 Initialize the system. More...
 
void turnOffJacobian ()
 Turn off the Jacobian (must be called before equation system initialization) More...
 
virtual void addExtraVectors () override
 Method called during initialSetup to add extra system vector if they are required by the simulation. More...
 
virtual void restoreSolutions () override
 Restore current solutions (call after your solve failed) More...
 
virtual bool computingInitialResidual ()
 Returns true if this system is currently computing the initial residual for a solve. More...
 
virtual void initialSetup ()
 
virtual void timestepSetup ()
 
void setupFieldDecomposition ()
 
bool haveFiniteDifferencedPreconditioner () const
 
bool haveFieldSplitPreconditioner () const
 
void addTimeIntegrator (const std::string &type, const std::string &name, InputParameters parameters)
 Add a time integrator. More...
 
void addDotVectors ()
 Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator. More...
 
virtual void addNodalKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a NodalKernel. More...
 
void addScalarKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a scalar kernel. More...
 
void addBoundaryCondition (const std::string &bc_name, const std::string &name, InputParameters parameters)
 Adds a boundary condition. More...
 
void addConstraint (const std::string &c_name, const std::string &name, InputParameters parameters)
 Adds a Constraint. More...
 
void addDiracKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a Dirac kernel. More...
 
void addDGKernel (std::string dg_kernel_name, const std::string &name, InputParameters parameters)
 Adds a DG kernel. More...
 
void addInterfaceKernel (std::string interface_kernel_name, const std::string &name, InputParameters parameters)
 Adds an interface kernel. More...
 
void addDamper (const std::string &damper_name, const std::string &name, InputParameters parameters)
 Adds a damper. More...
 
void addSplit (const std::string &split_name, const std::string &name, InputParameters parameters)
 Adds a split. More...
 
std::shared_ptr< SplitgetSplit (const std::string &name)
 Retrieves a split by name. More...
 
void zeroVectorForResidual (const std::string &vector_name)
 
void setInitialSolution ()
 
void setConstraintSlaveValues (NumericVector< Number > &solution, bool displaced)
 Sets the value of constrained variables in the solution vector. More...
 
void constraintResiduals (NumericVector< Number > &residual, bool displaced)
 Add residual contributions from Constraints. More...
 
void computeResidualTag (NumericVector< Number > &residual, TagID tag_id)
 Computes residual for a given tag. More...
 
void computeResidualTags (const std::set< TagID > &tags)
 Form multiple tag-associated residual vectors for all the given tags. More...
 
void computeResidual (NumericVector< Number > &residual, TagID tag_id)
 Form a residual vector for a given tag. More...
 
void findImplicitGeometricCouplingEntries (GeometricSearchData &geom_search_data, std::map< dof_id_type, std::vector< dof_id_type >> &graph)
 Finds the implicit sparsity graph between geometrically related dofs. More...
 
void addImplicitGeometricCouplingEntries (GeometricSearchData &geom_search_data)
 Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled that are related geometrically (i.e. More...
 
void constraintJacobians (bool displaced)
 Add jacobian contributions from Constraints. More...
 
void setVariableGlobalDoFs (const std::string &var_name)
 set all the global dof indices for a nonlinear variable More...
 
const std::vector< dof_id_type > & getVariableGlobalDoFs ()
 
void computeJacobianTags (const std::set< TagID > &tags)
 Computes multiple (tag associated) Jacobian matricese. More...
 
void computeJacobian (SparseMatrix< Number > &jacobian, const std::set< TagID > &tags)
 Associate jacobian to systemMatrixTag, and then form a matrix for all the tags. More...
 
void computeJacobian (SparseMatrix< Number > &jacobian)
 Take all tags in the system, and form a matrix for all tags in the system. More...
 
void computeJacobianBlocks (std::vector< JacobianBlock *> &blocks)
 Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditioning matrices. More...
 
void computeJacobianBlocks (std::vector< JacobianBlock *> &blocks, const std::set< TagID > &tags)
 
Real computeDamping (const NumericVector< Number > &solution, const NumericVector< Number > &update)
 Compute damping. More...
 
void computeTimeDerivatives ()
 Computes the time derivative vector. More...
 
void onTimestepBegin ()
 Called at the beginning of the time step. More...
 
virtual void subdomainSetup (SubdomainID subdomain, THREAD_ID tid)
 Called from assembling when we hit a new subdomain. More...
 
virtual void setSolution (const NumericVector< Number > &soln)
 
void updateActive (THREAD_ID tid)
 Update active objects of Warehouses owned by NonlinearSystemBase. More...
 
virtual void setSolutionUDot (const NumericVector< Number > &udot)
 Set transient term used by residual and Jacobian evaluation. More...
 
virtual void setSolutionUDotDot (const NumericVector< Number > &udotdot)
 Set transient term used by residual and Jacobian evaluation. More...
 
virtual NumericVector< Number > * solutionUDot () override
 
virtual NumericVector< Number > * solutionUDotDot () override
 
NumericVector< Number > & getResidualTimeVector ()
 Return a numeric vector that is associated with the time tag. More...
 
NumericVector< Number > & getResidualNonTimeVector ()
 Return a numeric vector that is associated with the nontime tag. More...
 
NumericVector< Number > & residualVector (TagID tag)
 Return a residual vector that is associated with the residual tag. More...
 
virtual const NumericVector< Number > *& currentSolution () override
 The solution vector that is currently being operated on. More...
 
virtual void serializeSolution ()
 
virtual NumericVector< Number > & serializedSolution () override
 Returns a reference to a serialized version of the solution vector for this subproblem. More...
 
virtual NumericVector< Number > & residualCopy () override
 
virtual NumericVector< Number > & residualGhosted () override
 
virtual void augmentSparsity (SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz) override
 Will modify the sparsity pattern to add logical geometric connections. More...
 
void setPreconditioner (std::shared_ptr< MoosePreconditioner > pc)
 Sets a preconditioner. More...
 
void useFiniteDifferencedPreconditioner (bool use=true)
 If called with true this system will use a finite differenced form of the Jacobian as the preconditioner. More...
 
void setDecomposition (const std::vector< std::string > &decomposition)
 If called with a single string, it is used as the name of a the top-level decomposition split. More...
 
void useFieldSplitPreconditioner (bool use=true)
 If called with true this system will use a field split preconditioner matrix. More...
 
void addImplicitGeometricCouplingEntriesToJacobian (bool add=true)
 If called with true this will add entries into the jacobian to link together degrees of freedom that are found to be related through the geometric search system. More...
 
void assembleConstraintsSeparately (bool separately=true)
 Indicates whether to assemble residual and Jacobian after each constraint application. More...
 
void setupDampers ()
 Setup damping stuff (called before we actually start) More...
 
void reinitIncrementAtQpsForDampers (THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
 Compute the incremental change in variables at QPs for dampers. More...
 
void reinitIncrementAtNodeForDampers (THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
 Compute the incremental change in variables at nodes for dampers. More...
 
unsigned int nNonlinearIterations () const
 Return the number of non-linear iterations. More...
 
unsigned int nLinearIterations () const
 Return the number of linear iterations. More...
 
unsigned int nResidualEvaluations () const
 Return the total number of residual evaluations done so far in this calculation. More...
 
Real finalNonlinearResidual () const
 Return the final nonlinear residual. More...
 
Real nonlinearNorm () const
 Return the last nonlinear norm. More...
 
void printAllVariableNorms (bool state)
 Force the printing of all variable norms after each solve. More...
 
void debuggingResiduals (bool state)
 
void setPredictor (std::shared_ptr< Predictor > predictor)
 
PredictorgetPredictor ()
 
TimeIntegratorgetTimeIntegrator ()
 
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...
 
virtual void addVariableToZeroOnResidual (std::string var_name)
 Adds this variable to the list of variables to be zeroed during each residual evaluation. More...
 
virtual void addVariableToZeroOnJacobian (std::string var_name)
 Adds this variable to the list of variables to be zeroed during each Jacobian evaluation. More...
 
virtual void zeroVariables (std::vector< std::string > &vars_to_be_zeroed)
 Zero out the solution for the list of variables passed in. More...
 
virtual void zeroVariablesForResidual ()
 Zero out the solution for the variables that were registered as needing to have their solutions zeroed on out on residual evaluation by a call to addVariableToZeroOnResidual() More...
 
virtual void zeroVariablesForJacobian ()
 Zero out the solution for the variables that were registered as needing to have their solutions zeroed on out on Jacobian evaluation by a call to addVariableToZeroOnResidual() More...
 
virtual Order getMinQuadratureOrder ()
 Get minimal quadrature order needed for integrating variables in this system. More...
 
virtual void prepare (THREAD_ID tid)
 Prepare the system for use. More...
 
virtual void prepareFace (THREAD_ID tid, bool resize_data)
 Prepare the system for use on sides. More...
 
virtual void prepareNeighbor (THREAD_ID tid)
 Prepare the system for use. More...
 
virtual void reinitElem (const Elem *elem, THREAD_ID tid)
 Reinit an element assembly info. More...
 
virtual void reinitElemFace (const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
 Reinit assembly info for a side of an element. More...
 
virtual void reinitNeighborFace (const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
 Compute the values of the variables at all the current points. More...
 
virtual void reinitNeighbor (const Elem *elem, THREAD_ID tid)
 Compute the values of the variables at all the current points. More...
 
virtual void reinitNode (const Node *node, THREAD_ID tid)
 Reinit nodal assembly info. More...
 
virtual void reinitNodeFace (const Node *node, BoundaryID bnd_id, THREAD_ID tid)
 Reinit nodal assembly info on a face. More...
 
virtual void reinitNodes (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of nodes. More...
 
virtual void reinitNodesNeighbor (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of neighbor nodes. More...
 
virtual void reinitScalars (THREAD_ID tid)
 Reinit scalar varaibles. More...
 
virtual void addVariableToCopy (const std::string &dest_name, const std::string &source_name, const std::string &timestep)
 Add info about variable that will be copied. More...
 
const std::vector< MooseVariableFEBase * > & getVariables (THREAD_ID tid)
 
const std::vector< MooseVariableScalar * > & getScalarVariables (THREAD_ID tid)
 
const std::set< SubdomainID > & getSubdomainsForVar (unsigned int var_number) const
 
virtual void removeVector (const std::string &name)
 Remove a vector from the system with the given name. More...
 
virtual void removeVector (TagID tag_id)
 Remove a solution length vector from the system with the specified TagID. More...
 
virtual NumericVector< Number > & addVector (const std::string &vector_name, const bool project, const ParallelType type)
 Adds a solution length vector to the system. More...
 
NumericVector< Number > & addVector (TagID tag, const bool project, const ParallelType type)
 Adds a solution length vector to the system with the specified TagID. More...
 
virtual void closeTaggedVectors (const std::set< TagID > &tags)
 Close all vectors for given tags. More...
 
virtual void zeroTaggedVectors (const std::set< TagID > &tags)
 Zero all vectors for given tags. More...
 
virtual void removeMatrix (TagID)
 Removes a jacobian sized vector. More...
 
virtual const std::string & name () const
 
virtual void addScalarVariable (const std::string &var_name, Order order, Real scale_factor, const std::set< SubdomainID > *const active_subdomains=NULL)
 Adds a scalar variable. More...
 
const std::vector< VariableName > & getVariableNames () const
 
virtual void computeVariables (const NumericVector< Number > &)
 
void copyVars (ExodusII_IO &io)
 
virtual void copySolutionsBackwards ()
 Copy current solution into old and older. More...
 
void checkKernelCoverage (const std::set< SubdomainID > &mesh_subdomains) const
 
bool containsTimeKernel ()
 
MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse ()
 Access functions to Warehouses from outside NonlinearSystemBase. More...
 
MooseObjectTagWarehouse< DGKernel > & getDGKernelWarehouse ()
 
MooseObjectTagWarehouse< InterfaceKernel > & getInterfaceKernelWarehouse ()
 
MooseObjectTagWarehouse< DiracKernel > & getDiracKernelWarehouse ()
 
MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse ()
 
const MooseObjectWarehouse< ElementDamper > & getElementDamperWarehouse () const
 
const MooseObjectWarehouse< NodalDamper > & getNodalDamperWarehouse () const
 
const ConstraintWarehousegetConstraintWarehouse () const
 
virtual bool hasVariable (const std::string &var_name) const
 Query a system for a variable. More...
 
virtual bool hasScalarVariable (const std::string &var_name) const
 

Public Attributes

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

Protected Member Functions

void computeResidualInternal (const std::set< TagID > &tags)
 Compute the residual for a given tag. More...
 
void computeNodalBCs (NumericVector< Number > &residual)
 Enforces nodal boundary conditions. More...
 
void computeNodalBCs (NumericVector< Number > &residual, const std::set< TagID > &tags)
 Form a residual for BCs that at least has one of the given tags. More...
 
void computeNodalBCs (const std::set< TagID > &tags)
 Form multiple tag-associated residual vectors for the given tags. More...
 
void computeJacobianInternal (const std::set< TagID > &tags)
 Form multiple matrices for all the tags. More...
 
void computeDiracContributions (const std::set< TagID > &tags, bool is_jacobian)
 
void computeScalarKernelsJacobians (const std::set< TagID > &tags)
 
void enforceNodalConstraintsResidual (NumericVector< Number > &residual)
 Enforce nodal constraints. More...
 
void enforceNodalConstraintsJacobian ()
 
void getNodeDofs (dof_id_type node_id, std::vector< dof_id_type > &dofs)
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level)
 Call to register a named section for timing. More...
 

Protected Attributes

std::set< VariableName > _eigen_var_names
 
bool _all_eigen_vars
 
std::set< dof_id_type > _eigen_var_indices
 
bool _active_on_old
 
unsigned int _eigen_kernel_counter
 counter of eigen kernels More...
 
TransientNonlinearImplicitSystem & _transient_sys
 
ComputeResidualFunctor _nl_residual_functor
 
ComputeFDResidualFunctor _fd_residual_functor
 
const NumericVector< Number > * _current_solution
 solution vector from nonlinear solver More...
 
NumericVector< Number > * _residual_ghosted
 ghosted form of the residual More...
 
NumericVector< Number > & _serialized_solution
 Serialized version of the solution vector. More...
 
NumericVector< Number > * _solution_previous_nl
 Solution vector of the previous nonlinear iterate. More...
 
NumericVector< Number > & _residual_copy
 Copy of the residual vector. More...
 
std::shared_ptr< TimeIntegrator_time_integrator
 Time integrator. 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...
 
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< ScalarKernel_scalar_kernels
 
MooseObjectTagWarehouse< DGKernel_dg_kernels
 
MooseObjectTagWarehouse< InterfaceKernel_interface_kernels
 
MooseObjectTagWarehouse< IntegratedBCBase_integrated_bcs
 
MooseObjectTagWarehouse< NodalBCBase_nodal_bcs
 
MooseObjectWarehouse< PresetNodalBC_preset_nodal_bcs
 

Detailed Description

Definition at line 20 of file MooseEigenSystem.h.

Member Enumeration Documentation

◆ SYSTEMTAG

System or kernel tags.

Enumerator
ALL 
EIGEN 

Definition at line 44 of file MooseEigenSystem.h.

Constructor & Destructor Documentation

◆ MooseEigenSystem()

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

Definition at line 16 of file MooseEigenSystem.C.

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

◆ ~MooseEigenSystem()

MooseEigenSystem::~MooseEigenSystem ( )
virtual

Definition at line 24 of file MooseEigenSystem.C.

24 {}

Member Function Documentation

◆ activeAllMatrixTags()

void SystemBase::activeAllMatrixTags ( )
virtualinherited

Make all exsiting matrices ative.

Definition at line 850 of file SystemBase.C.

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

851 {
852  auto num_matrix_tags = _subproblem.numMatrixTags();
853 
854  _matrix_tag_active_flags.resize(num_matrix_tags);
855 
856  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
857  if (hasMatrix(tag))
858  _matrix_tag_active_flags[tag] = true;
859  else
860  _matrix_tag_active_flags[tag] = false;
861 }
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:766
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:688
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:145

◆ activeMatrixTag()

void SystemBase::activeMatrixTag ( TagID  tag)
virtualinherited

Active a matrix for tag.

Definition at line 815 of file SystemBase.C.

816 {
817  mooseAssert(_subproblem.matrixTagExists(tag),
818  "Cannot active Matrix with matrix_tag : " << tag << "that does not exist");
819 
820  if (_matrix_tag_active_flags.size() < tag + 1)
821  _matrix_tag_active_flags.resize(tag + 1);
822 
823  _matrix_tag_active_flags[tag] = true;
824 }
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:118
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:688
SubProblem & _subproblem
Definition: SystemBase.h:663

◆ activeOnOld()

bool MooseEigenSystem::activeOnOld ( )

Return if eigen kernels should be on old solution.

Definition at line 220 of file MooseEigenSystem.C.

Referenced by EigenKernel::enabled().

221 {
222  return _active_on_old;
223 }

◆ addBoundaryCondition()

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

Adds a boundary condition.

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

Definition at line 366 of file NonlinearSystemBase.C.

369 {
370  // ThreadID
371  THREAD_ID tid = 0;
372 
373  // Create the object
374  std::shared_ptr<BoundaryCondition> bc =
375  _factory.create<BoundaryCondition>(bc_name, name, parameters, tid);
376 
377  // Active BoundaryIDs for the object
378  const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
379  _vars[tid].addBoundaryVar(boundary_ids, &bc->variable());
380 
381  // Cast to the various types of BCs
382  std::shared_ptr<NodalBCBase> nbc = std::dynamic_pointer_cast<NodalBCBase>(bc);
383  std::shared_ptr<IntegratedBCBase> ibc = std::dynamic_pointer_cast<IntegratedBCBase>(bc);
384 
385  // NodalBCBase
386  if (nbc)
387  {
388  _nodal_bcs.addObject(nbc);
389  _vars[tid].addBoundaryVars(boundary_ids, nbc->getCoupledVars());
390 
391  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
392  _has_nodalbc_save_in = true;
393  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
395 
396  // PresetNodalBC
397  std::shared_ptr<PresetNodalBC> pnbc = std::dynamic_pointer_cast<PresetNodalBC>(bc);
398  if (pnbc)
400  }
401 
402  // IntegratedBCBase
403  else if (ibc)
404  {
405  _integrated_bcs.addObject(ibc, tid);
406  _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
407 
408  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
409  _has_save_in = true;
410  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
411  _has_diag_save_in = true;
412 
413  for (tid = 1; tid < libMesh::n_threads(); tid++)
414  {
415  // Create the object
416  bc = _factory.create<BoundaryCondition>(bc_name, name, parameters, tid);
417 
418  // Active BoundaryIDs for the object
419  const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
420  _vars[tid].addBoundaryVar(boundary_ids, &bc->variable());
421 
422  ibc = std::static_pointer_cast<IntegratedBCBase>(bc);
423 
424  _integrated_bcs.addObject(ibc, tid);
425  _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
426  }
427  }
428 
429  else
430  mooseError("Unknown BoundaryCondition type for object named ", bc->name());
431 }
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
virtual const std::string & name() const
Definition: SystemBase.h:638
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:666
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.
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:673
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:112
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 434 of file NonlinearSystemBase.C.

437 {
438  std::shared_ptr<Constraint> constraint = _factory.create<Constraint>(c_name, name, parameters);
439  _constraints.addObject(constraint);
440 
441  if (constraint && constraint->addCouplingEntriesToJacobian())
443 }
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
virtual const std::string & name() const
Definition: SystemBase.h:638
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:666
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 497 of file NonlinearSystemBase.C.

500 {
501  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
502  {
503  std::shared_ptr<Damper> damper = _factory.create<Damper>(damper_name, name, parameters, tid);
504 
505  // Attempt to cast to the damper types
506  std::shared_ptr<ElementDamper> ed = std::dynamic_pointer_cast<ElementDamper>(damper);
507  std::shared_ptr<NodalDamper> nd = std::dynamic_pointer_cast<NodalDamper>(damper);
508  std::shared_ptr<GeneralDamper> gd = std::dynamic_pointer_cast<GeneralDamper>(damper);
509 
510  if (gd)
511  {
513  break; // not threaded
514  }
515  else if (ed)
516  _element_dampers.addObject(ed, tid);
517  else if (nd)
518  _nodal_dampers.addObject(nd, tid);
519  else
520  mooseError("Invalid damper type");
521  }
522 }
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
virtual const std::string & name() const
Definition: SystemBase.h:638
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:666
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)
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:112

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

462 {
463  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
464  {
465  std::shared_ptr<DGKernel> dg_kernel =
466  _factory.create<DGKernel>(dg_kernel_name, name, parameters, tid);
467  _dg_kernels.addObject(dg_kernel, tid);
468  }
469 
470  _doing_dg = true;
471 
472  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
473  _has_save_in = true;
474  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
475  _has_diag_save_in = true;
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
virtual const std::string & name() const
Definition: SystemBase.h:638
MooseObjectTagWarehouse< DGKernel > _dg_kernels
Factory & _factory
Definition: SystemBase.h:666
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
bool _doing_dg
true if DG is active (optimization reasons)
The DGKernel class is responsible for calculating the residuals for various physics on internal sides...
Definition: DGKernel.h:42
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:112

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

449 {
450  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
451  {
452  std::shared_ptr<DiracKernel> kernel =
453  _factory.create<DiracKernel>(kernel_name, name, parameters, tid);
454  _dirac_kernels.addObject(kernel, tid);
455  }
456 }
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
virtual const std::string & name() const
Definition: SystemBase.h:638
Factory & _factory
Definition: SystemBase.h:666
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:112

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

204 {
206  _u_dot = &addVector("u_dot", true, GHOSTED);
208  _u_dot_old = &addVector("u_dot_old", true, GHOSTED);
210  _u_dotdot = &addVector("u_dotdot", true, GHOSTED);
212  _u_dotdot_old = &addVector("u_dotdot_old", true, GHOSTED);
213 }
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:511
virtual bool uDotRequested()
Get boolean flag to check whether solution time derivative needs to be stored.
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
virtual bool uDotDotRequested()
Get boolean flag to check whether solution second time derivative needs to be stored.
FEProblemBase & _fe_problem
virtual bool uDotOldRequested()
Get boolean flag to check whether old solution time derivative needs to be stored.
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
NumericVector< Number > * _u_dot
solution vector for u^dot

◆ addExtraVectors()

void NonlinearSystemBase::addExtraVectors ( )
overridevirtualinherited

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

Reimplemented from SystemBase.

Definition at line 223 of file NonlinearSystemBase.C.

224 {
226  _solution_previous_nl = &addVector("u_previous_newton", true, GHOSTED);
227 }
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:511
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 1637 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

1638 {
1639  if (!hasMatrix(systemMatrixTag()))
1640  mooseError("Need a system matrix ");
1641 
1642  // At this point, have no idea how to make
1643  // this work with tag system
1644  auto & jacobian = getMatrix(systemMatrixTag());
1645 
1646  std::map<dof_id_type, std::vector<dof_id_type>> graph;
1647 
1648  findImplicitGeometricCouplingEntries(geom_search_data, graph);
1649 
1650  for (const auto & it : graph)
1651  {
1652  dof_id_type dof = it.first;
1653  const std::vector<dof_id_type> & row = it.second;
1654 
1655  for (const auto & coupled_dof : row)
1656  jacobian.add(dof, coupled_dof, 0);
1657  }
1658 }
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:766
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:772

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

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

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

482 {
483  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
484  {
485  std::shared_ptr<InterfaceKernel> interface_kernel =
486  _factory.create<InterfaceKernel>(interface_kernel_name, name, parameters, tid);
487 
488  const std::set<BoundaryID> & boundary_ids = interface_kernel->boundaryIDs();
489  _vars[tid].addBoundaryVar(boundary_ids, &interface_kernel->variable());
490 
491  _interface_kernels.addObject(interface_kernel, tid);
492  _vars[tid].addBoundaryVars(boundary_ids, interface_kernel->getCoupledVars());
493  }
494 }
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
virtual const std::string & name() const
Definition: SystemBase.h:638
MooseObjectTagWarehouse< InterfaceKernel > _interface_kernels
Factory & _factory
Definition: SystemBase.h:666
InterfaceKernel is responsible for interfacing physics across subdomains.
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673
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:112

◆ addKernel()

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

Adds a kernel.

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

Reimplemented from NonlinearSystemBase.

Definition at line 27 of file MooseEigenSystem.C.

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

◆ addMatrix()

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

Adds a jacobian sized vector.

Parameters
tag_nameThe name of the tag

Reimplemented from SystemBase.

Definition at line 116 of file NonlinearSystem.C.

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

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

340 {
341  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
342  {
343  // Create the kernel object via the factory and add to the warehouse
344  std::shared_ptr<NodalKernel> kernel =
345  _factory.create<NodalKernel>(kernel_name, name, parameters, tid);
346  _nodal_kernels.addObject(kernel, tid);
347  }
348 
349  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
350  _has_save_in = true;
351  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
352  _has_diag_save_in = true;
353 }
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
virtual const std::string & name() const
Definition: SystemBase.h:638
Factory & _factory
Definition: SystemBase.h:666
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
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:112

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

359 {
360  std::shared_ptr<ScalarKernel> kernel =
361  _factory.create<ScalarKernel>(kernel_name, name, parameters);
362  _scalar_kernels.addObject(kernel);
363 }
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
virtual const std::string & name() const
Definition: SystemBase.h:638
Factory & _factory
Definition: SystemBase.h:666
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 613 of file SystemBase.C.

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

617 {
618  FEType type(order, SCALAR);
619  unsigned int var_num = system().add_variable(var_name, type, active_subdomains);
620  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
621  {
622  // FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in
623  // MooseVariableBase.
624  MooseVariableScalar * var =
625  new MooseVariableScalar(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
626  var->scalingFactor(scale_factor);
627  _vars[tid].add(var_name, var);
628  }
629  if (active_subdomains == nullptr)
630  _var_map[var_num] = std::set<SubdomainID>();
631  else
632  for (const auto subdomain_id : *active_subdomains)
633  _var_map[var_num].insert(subdomain_id);
634 }
virtual Assembly & assembly(THREAD_ID tid)=0
SubProblem & _subproblem
Definition: SystemBase.h:663
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:699
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:675
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673
MatType type
Class for scalar variables (they are different).
unsigned int THREAD_ID
Definition: MooseTypes.h:112
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 525 of file NonlinearSystemBase.C.

528 {
529  std::shared_ptr<Split> split = _factory.create<Split>(split_name, name, parameters);
530  _splits.addObject(split);
531 }
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
virtual const std::string & name() const
Definition: SystemBase.h:638
Base class for split-based preconditioners.
Definition: Split.h:30
Factory & _factory
Definition: SystemBase.h:666
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true)
Adds an object to the storage structure.

◆ addTimeIntegrator()

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

Add a time integrator.

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

Definition at line 307 of file NonlinearSystemBase.C.

310 {
311  parameters.set<SystemBase *>("_sys") = this;
312 
313  std::shared_ptr<TimeIntegrator> ti = _factory.create<TimeIntegrator>(type, name, parameters);
314  _time_integrator = ti;
315 }
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
virtual const std::string & name() const
Definition: SystemBase.h:638
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Factory & _factory
Definition: SystemBase.h:666
Base class for a system (of equations)
Definition: SystemBase.h:91
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
MatType type
Base class for time integrators.

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

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

586 {
587  unsigned int var_num = system().add_variable(var_name, type, active_subdomains);
588  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
589  {
590  // FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in
591  // MooseVariableBase.
592  MooseVariableBase * var;
593  if (type == FEType(0, MONOMIAL))
594  var = new MooseVariableConstMonomial(
595  var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
596  else if (type == FEType(FIRST, NEDELEC_ONE) || type.family == LAGRANGE_VEC)
597  var =
598  new VectorMooseVariable(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
599  else
600  var = new MooseVariable(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
601 
602  var->scalingFactor(scale_factor);
603  _vars[tid].add(var_name, var);
604  }
605  if (active_subdomains == nullptr)
606  _var_map[var_num] = std::set<SubdomainID>();
607  else
608  for (const auto subdomain_id : *active_subdomains)
609  _var_map[var_num].insert(subdomain_id);
610 }
virtual Assembly & assembly(THREAD_ID tid)=0
MooseVariableFE< Real > MooseVariable
Definition: Adaptivity.h:30
SubProblem & _subproblem
Definition: SystemBase.h:663
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:699
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:675
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:673
MatType type
MooseVariableFE< VectorValue< Real > > VectorMooseVariable
Definition: Adaptivity.h:32
unsigned int THREAD_ID
Definition: MooseTypes.h:112
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 891 of file SystemBase.C.

894 {
895  _var_to_copy.push_back(VarCopyInfo(dest_name, source_name, timestep));
896 }
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:701
Information about variables that will be copied.
Definition: SystemBase.h:73

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

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

170 {
171  _vars_to_be_zeroed_on_jacobian.push_back(var_name);
172 }
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
Definition: SystemBase.h:678

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

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

164 {
165  _vars_to_be_zeroed_on_residual.push_back(var_name);
166 }
std::vector< std::string > _vars_to_be_zeroed_on_residual
Definition: SystemBase.h:677

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

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

512 {
513  if (hasVector(vector_name))
514  return getVector(vector_name);
515 
516  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
517  return vec;
518 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:670
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:720

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

522 {
523  if (!_subproblem.vectorTagExists(tag))
524  mooseError("Cannot add a tagged vector with vector_tag, ",
525  tag,
526  ", that tag does not exist in System ",
527  name());
528 
529  if (hasVector(tag))
530  return getVector(tag);
531 
532  auto vector_name = _subproblem.vectorTagName(tag);
533 
534  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
535 
536  if (_tagged_vectors.size() < tag + 1)
537  _tagged_vectors.resize(tag + 1);
538 
539  _tagged_vectors[tag] = &vec;
540 
541  return vec;
542 }
virtual const std::string & name() const
Definition: SystemBase.h:638
virtual TagName vectorTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:95
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:670
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:100
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:684
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:720

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

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

◆ associateMatrixToTag()

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

associate a matirx to a tag

Reimplemented in DisplacedSystem.

Definition at line 788 of file SystemBase.C.

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

789 {
790  mooseAssert(_subproblem.matrixTagExists(tag),
791  "Cannot associate Matrix with matrix_tag : " << tag << "that does not exist");
792 
793  if (_tagged_matrices.size() < tag + 1)
794  _tagged_matrices.resize(tag + 1);
795 
796  _tagged_matrices[tag] = &matrix;
797 }
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:686
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:118
SubProblem & _subproblem
Definition: SystemBase.h:663

◆ associateVectorToTag()

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

Associate a vector for a given tag.

Reimplemented in DisplacedSystem.

Definition at line 734 of file SystemBase.C.

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

735 {
736  mooseAssert(_subproblem.vectorTagExists(tag),
737  "You can't associate a tag that does not exist " << tag);
738  if (_tagged_vectors.size() < tag + 1)
739  _tagged_vectors.resize(tag + 1);
740 
741  _tagged_vectors[tag] = &vec;
742 }
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:100
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:684

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

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

400 {
401  std::set<dof_id_type> & ghosted_elems = _subproblem.ghostedElems();
402 
403  DofMap & dof_map = dofMap();
404 
405  std::vector<dof_id_type> dof_indices;
406 
407  System & sys = system();
408 
409  unsigned int sys_num = sys.number();
410 
411  unsigned int n_vars = sys.n_vars();
412 
413  for (const auto & elem_id : ghosted_elems)
414  {
415  Elem * elem = _mesh.elemPtr(elem_id);
416 
417  if (elem->active())
418  {
419  dof_map.dof_indices(elem, dof_indices);
420 
421  // Only need to ghost it if it's actually not on this processor
422  for (const auto & dof : dof_indices)
423  if (dof < dof_map.first_dof() || dof >= dof_map.end_dof())
424  send_list.push_back(dof);
425 
426  // Now add the DoFs from all of the nodes. This is necessary because of block
427  // restricted variables. A variable might not live _on_ this element but it
428  // might live on nodes connected to this element.
429  for (unsigned int n = 0; n < elem->n_nodes(); n++)
430  {
431  Node * node = elem->node_ptr(n);
432 
433  // Have to get each variable's dofs
434  for (unsigned int v = 0; v < n_vars; v++)
435  {
436  const Variable & var = sys.variable(v);
437  unsigned int var_num = var.number();
438  unsigned int n_comp = var.n_components();
439 
440  // See if this variable has any dofs at this node
441  if (node->n_dofs(sys_num, var_num) > 0)
442  {
443  // Loop over components of the variable
444  for (unsigned int c = 0; c < n_comp; c++)
445  send_list.push_back(node->dof_number(sys_num, var_num, c));
446  }
447  }
448  }
449  }
450  }
451 }
virtual Elem * elemPtr(const dof_id_type i)
Definition: MooseMesh.C:2219
virtual DofMap & dofMap()
Gets the dof map.
Definition: SystemBase.C:885
DofMap & dof_map
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
Definition: SubProblem.h:493
virtual System & system()=0
Get the reference to the libMesh system.
MooseMesh & _mesh
Definition: SystemBase.h:668
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 2763 of file NonlinearSystemBase.C.

2766 {
2768  {
2770 
2771  std::map<dof_id_type, std::vector<dof_id_type>> graph;
2772 
2774 
2777  graph);
2778 
2779  const dof_id_type first_dof_on_proc = dofMap().first_dof(processor_id());
2780  const dof_id_type end_dof_on_proc = dofMap().end_dof(processor_id());
2781 
2782  // The total number of dofs on and off processor
2783  const dof_id_type n_dofs_on_proc = dofMap().n_local_dofs();
2784  const dof_id_type n_dofs_not_on_proc = dofMap().n_dofs() - dofMap().n_local_dofs();
2785 
2786  for (const auto & git : graph)
2787  {
2788  dof_id_type dof = git.first;
2789  dof_id_type local_dof = dof - first_dof_on_proc;
2790 
2791  if (dof < first_dof_on_proc || dof >= end_dof_on_proc)
2792  continue;
2793 
2794  const std::vector<dof_id_type> & row = git.second;
2795 
2796  SparsityPattern::Row & sparsity_row = sparsity[local_dof];
2797 
2798  unsigned int original_row_length = sparsity_row.size();
2799 
2800  sparsity_row.insert(sparsity_row.end(), row.begin(), row.end());
2801 
2802  SparsityPattern::sort_row(
2803  sparsity_row.begin(), sparsity_row.begin() + original_row_length, sparsity_row.end());
2804 
2805  // Fix up nonzero arrays
2806  for (const auto & coupled_dof : row)
2807  {
2808  if (coupled_dof < first_dof_on_proc || coupled_dof >= end_dof_on_proc)
2809  {
2810  if (n_oz[local_dof] < n_dofs_not_on_proc)
2811  n_oz[local_dof]++;
2812  }
2813  else
2814  {
2815  if (n_nz[local_dof] < n_dofs_on_proc)
2816  n_nz[local_dof]++;
2817  }
2818  }
2819  }
2820  }
2821 }
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:885
FEProblemBase & _fe_problem
virtual std::shared_ptr< DisplacedProblem > getDisplacedProblem()
const std::vector< numeric_index_type > & n_nz
virtual void updateGeomSearch(GeometricSearchData::GeometricSearchType type=GeometricSearchData::ALL) override
bool _add_implicit_geometric_coupling_entries_to_jacobian
Whether or not to add implicit geometric couplings to the Jacobian for FDP.
const std::vector< numeric_index_type > & n_oz

◆ buildSystemDoFIndices()

void MooseEigenSystem::buildSystemDoFIndices ( SYSTEMTAG  tag = ALL)

Build DoF indices for a system.

Definition at line 226 of file MooseEigenSystem.C.

Referenced by EigenExecutionerBase::init().

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

◆ checkKernelCoverage()

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

System Integrity Checks

Definition at line 2913 of file NonlinearSystemBase.C.

2914 {
2915  // Check kernel coverage of subdomains (blocks) in your mesh
2916  std::set<SubdomainID> input_subdomains;
2917  std::set<std::string> kernel_variables;
2918 
2919  bool global_kernels_exist = _kernels.hasActiveBlockObjects(Moose::ANY_BLOCK_ID);
2920  global_kernels_exist |= _scalar_kernels.hasActiveObjects();
2921  global_kernels_exist |= _nodal_kernels.hasActiveObjects();
2922 
2923  _kernels.subdomainsCovered(input_subdomains, kernel_variables);
2924  _nodal_kernels.subdomainsCovered(input_subdomains, kernel_variables);
2925  _scalar_kernels.subdomainsCovered(input_subdomains, kernel_variables);
2926  _constraints.subdomainsCovered(input_subdomains, kernel_variables);
2927 
2928  if (!global_kernels_exist)
2929  {
2930  std::set<SubdomainID> difference;
2931  std::set_difference(mesh_subdomains.begin(),
2932  mesh_subdomains.end(),
2933  input_subdomains.begin(),
2934  input_subdomains.end(),
2935  std::inserter(difference, difference.end()));
2936 
2937  if (!difference.empty())
2938  {
2939  std::stringstream missing_block_ids;
2940  std::copy(difference.begin(),
2941  difference.end(),
2942  std::ostream_iterator<unsigned int>(missing_block_ids, " "));
2943  mooseError("Each subdomain must contain at least one Kernel.\nThe following block(s) lack an "
2944  "active kernel: " +
2945  missing_block_ids.str());
2946  }
2947  }
2948 
2949  std::set<VariableName> variables(getVariableNames().begin(), getVariableNames().end());
2950 
2951  std::set<VariableName> difference;
2952  std::set_difference(variables.begin(),
2953  variables.end(),
2954  kernel_variables.begin(),
2955  kernel_variables.end(),
2956  std::inserter(difference, difference.end()));
2957 
2958  if (!difference.empty())
2959  {
2960  std::stringstream missing_kernel_vars;
2961  std::copy(difference.begin(),
2962  difference.end(),
2963  std::ostream_iterator<std::string>(missing_kernel_vars, " "));
2964  mooseError("Each variable must be referenced by at least one active Kernel.\nThe following "
2965  "variable(s) lack an active kernel: " +
2966  missing_kernel_vars.str());
2967  }
2968 }
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.h:328
bool hasActiveObjects(THREAD_ID tid=0) const
Convenience functions for determining if objects exist.
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:651
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 780 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

781 {
782  for (auto tag : tags)
783  if (hasMatrix(tag))
784  getMatrix(tag).close();
785 }
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:766
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:772

◆ closeTaggedVectors()

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

Close all vectors for given tags.

Definition at line 545 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTags().

546 {
547  for (auto & tag : tags)
548  {
549  mooseAssert(_subproblem.vectorTagExists(tag), "Tag: " << tag << " does not exsit");
550  getVector(tag).close();
551  }
552 }
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:100
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:720

◆ combineSystemSolution()

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

Linear combination of the solution vectors.

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

Definition at line 103 of file MooseEigenSystem.C.

Referenced by EigenExecutionerBase::chebyshev().

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

◆ computeDamping()

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

Compute damping.

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

Definition at line 2654 of file NonlinearSystemBase.C.

2656 {
2657  // Default to no damping
2658  Real damping = 1.0;
2659  bool has_active_dampers = false;
2660 
2662  {
2663  TIME_SECTION(_compute_dampers_timer);
2664 
2665  has_active_dampers = true;
2668  Threads::parallel_reduce(*_mesh.getActiveLocalElementRange(), cid);
2669  damping = std::min(cid.damping(), damping);
2670  }
2671 
2673  {
2674  TIME_SECTION(_compute_dampers_timer);
2675 
2676  has_active_dampers = true;
2679  Threads::parallel_reduce(*_mesh.getLocalNodeRange(), cndt);
2680  damping = std::min(cndt.damping(), damping);
2681  }
2682 
2684  {
2685  TIME_SECTION(_compute_dampers_timer);
2686 
2687  has_active_dampers = true;
2688  const auto & gdampers = _general_dampers.getActiveObjects();
2689  for (const auto & damper : gdampers)
2690  {
2691  Real gd_damping = damper->computeDamping(solution, update);
2692  try
2693  {
2694  damper->checkMinDamping(gd_damping);
2695  }
2696  catch (MooseException & e)
2697  {
2699  }
2700  damping = std::min(gd_damping, damping);
2701  }
2702  }
2703 
2704  _communicator.min(damping);
2705 
2706  if (has_active_dampers && damping < 1.0)
2707  _console << " Damping factor: " << damping << "\n";
2708 
2709  return damping;
2710 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:779
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:816
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:939
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:668
bool hasActiveObjects(THREAD_ID tid=0) const
Convenience functions for determining if objects exist.
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 2713 of file NonlinearSystemBase.C.

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

2714 {
2716 
2717  std::set<const Elem *> dirac_elements;
2718 
2720  {
2721  TIME_SECTION(_compute_dirac_timer);
2722 
2723  // TODO: Need a threading fix... but it's complicated!
2724  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
2725  {
2726  const auto & dkernels = _dirac_kernels.getActiveObjects(tid);
2727  for (const auto & dkernel : dkernels)
2728  {
2729  dkernel->clearPoints();
2730  dkernel->addPoints();
2731  }
2732  }
2733 
2734  ComputeDiracThread cd(_fe_problem, tags, is_jacobian);
2735 
2736  _fe_problem.getDiracElements(dirac_elements);
2737 
2738  DistElemRange range(dirac_elements.begin(), dirac_elements.end(), 1);
2739  // TODO: Make Dirac work thread!
2740  // Threads::parallel_reduce(range, cd);
2741 
2742  cd(range);
2743  }
2744 }
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
Convenience functions for determining if objects exist.
MooseObjectTagWarehouse< DiracKernel > _dirac_kernels
Dirac Kernel storage for each thread.
unsigned int THREAD_ID
Definition: MooseTypes.h:112

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

Referenced by NonlinearSystemBase::computeJacobian().

2488 {
2490 
2491  computeJacobianTags(tags);
2492 
2494 }
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:788
virtual void disassociateMatrixFromTag(SparseMatrix< Number > &matrix, TagID tag)
disassociate a matirx from a tag
Definition: SystemBase.C:800

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

2475 {
2476  _nl_matrix_tags.clear();
2477 
2478  auto & tags = _fe_problem.getMatrixTags();
2479 
2480  for (auto & tag : tags)
2481  _nl_matrix_tags.insert(tag.second);
2482 
2483  computeJacobian(jacobian, _nl_matrix_tags);
2484 }
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:150

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

2517 {
2518  _nl_matrix_tags.clear();
2519 
2520  auto & tags = _fe_problem.getMatrixTags();
2521  for (auto & tag : tags)
2522  _nl_matrix_tags.insert(tag.second);
2523 
2525 }
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:150

◆ computeJacobianBlocks() [2/2]

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

Definition at line 2528 of file NonlinearSystemBase.C.

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

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

Referenced by NonlinearSystemBase::computeJacobianTags().

2178 {
2179  // Make matrix ready to use
2181 
2182  for (auto tag : tags)
2183  {
2184  if (!hasMatrix(tag))
2185  continue;
2186 
2187  auto & jacobian = getMatrix(tag);
2188 #ifdef LIBMESH_HAVE_PETSC
2189 // Necessary for speed
2190 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
2191  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
2192 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
2193  // In Petsc 3.0.0, MatSetOption has three args...the third arg
2194  // determines whether the option is set (true) or unset (false)
2195  MatSetOption(
2196  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
2197 #else
2198  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2199  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2200  PETSC_TRUE);
2201 #endif
2202 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
2203 #else
2205  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2206  MAT_NEW_NONZERO_ALLOCATION_ERR,
2207  PETSC_FALSE);
2208 #endif
2209 
2210 #endif
2211  }
2212  // jacobianSetup /////
2213  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
2214  {
2215  _kernels.jacobianSetup(tid);
2218  if (_doing_dg)
2224  }
2229 
2230  // reinit scalar variables
2231  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
2233 
2234  PARALLEL_TRY
2235  {
2236  ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
2237  switch (_fe_problem.coupling())
2238  {
2239  case Moose::COUPLING_DIAG:
2240  {
2242  Threads::parallel_reduce(elem_range, cj);
2243 
2244  unsigned int n_threads = libMesh::n_threads();
2245  for (unsigned int i = 0; i < n_threads;
2246  i++) // Add any Jacobian contributions still hanging around
2248 
2249  // Block restricted Nodal Kernels
2251  {
2253  ConstNodeRange & range = *_mesh.getLocalNodeRange();
2254  Threads::parallel_reduce(range, cnkjt);
2255 
2256  unsigned int n_threads = libMesh::n_threads();
2257  for (unsigned int i = 0; i < n_threads;
2258  i++) // Add any cached jacobians that might be hanging around
2260  }
2261 
2262  // Boundary restricted Nodal Kernels
2264  {
2266  ConstBndNodeRange & bnd_range = *_mesh.getBoundaryNodeRange();
2267 
2268  Threads::parallel_reduce(bnd_range, cnkjt);
2269  unsigned int n_threads = libMesh::n_threads();
2270  for (unsigned int i = 0; i < n_threads;
2271  i++) // Add any cached jacobians that might be hanging around
2273  }
2274  }
2275  break;
2276 
2277  default:
2279  {
2281  Threads::parallel_reduce(elem_range, cj);
2282  unsigned int n_threads = libMesh::n_threads();
2283 
2284  for (unsigned int i = 0; i < n_threads; i++)
2286 
2287  // Block restricted Nodal Kernels
2289  {
2291  ConstNodeRange & range = *_mesh.getLocalNodeRange();
2292  Threads::parallel_reduce(range, cnkjt);
2293 
2294  unsigned int n_threads = libMesh::n_threads();
2295  for (unsigned int i = 0; i < n_threads;
2296  i++) // Add any cached jacobians that might be hanging around
2298  }
2299 
2300  // Boundary restricted Nodal Kernels
2302  {
2304  ConstBndNodeRange & bnd_range = *_mesh.getBoundaryNodeRange();
2305 
2306  Threads::parallel_reduce(bnd_range, cnkjt);
2307 
2308  unsigned int n_threads = libMesh::n_threads();
2309  for (unsigned int i = 0; i < n_threads;
2310  i++) // Add any cached jacobians that might be hanging around
2312  }
2313  }
2314  break;
2315  }
2316 
2317  computeDiracContributions(tags, true);
2318 
2320 
2321  static bool first = true;
2322 
2323  // This adds zeroes into geometric coupling entries to ensure they stay in the matrix
2325  {
2326  first = false;
2328 
2331  }
2332  }
2333  PARALLEL_CATCH;
2334 
2335  closeTaggedMatrices(tags);
2336 
2337  // Have no idea how to have constraints work
2338  // with the tag system
2339  PARALLEL_TRY
2340  {
2341  // Add in Jacobian contributions from Constraints
2343  {
2344  // Nodal Constraints
2346 
2347  // Undisplaced Constraints
2348  constraintJacobians(false);
2349 
2350  // Displaced Constraints
2352  constraintJacobians(true);
2353  }
2354  }
2355  PARALLEL_CATCH;
2357  closeTaggedMatrices(tags);
2358 
2359  // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs on
2360  // boundary nodes
2361  if (_has_diag_save_in)
2363 
2364  PARALLEL_TRY
2365  {
2366  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
2367  // Select nodal kernels
2368  if (tags.size() == _fe_problem.numMatrixTags() || !tags.size())
2369  nbc_warehouse = &_nodal_bcs;
2370  else if (tags.size() == 1)
2371  nbc_warehouse = &(_nodal_bcs.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2372  else
2373  nbc_warehouse = &(_nodal_bcs.getMatrixTagsObjectWarehouse(tags, 0));
2374 
2375  // Cache the information about which BCs are coupled to which
2376  // variables, so we don't have to figure it out for each node.
2377  std::map<std::string, std::set<unsigned int>> bc_involved_vars;
2378  const std::set<BoundaryID> & all_boundary_ids = _mesh.getBoundaryIDs();
2379  for (const auto & bid : all_boundary_ids)
2380  {
2381  // Get reference to all the NodalBCs for this ID. This is only
2382  // safe if there are NodalBCBases there to be gotten...
2383  if (nbc_warehouse->hasActiveBoundaryObjects(bid))
2384  {
2385  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(bid);
2386  for (const auto & bc : bcs)
2387  {
2388  const std::vector<MooseVariableFEBase *> & coupled_moose_vars = bc->getCoupledMooseVars();
2389 
2390  // Create the set of "involved" MOOSE nonlinear vars, which includes all coupled vars and
2391  // the BC's own variable
2392  std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2393  for (const auto & coupled_var : coupled_moose_vars)
2394  if (coupled_var->kind() == Moose::VAR_NONLINEAR)
2395  var_set.insert(coupled_var->number());
2396 
2397  var_set.insert(bc->variable().number());
2398  }
2399  }
2400  }
2401 
2402  // Get variable coupling list. We do all the NodalBCBase stuff on
2403  // thread 0... The couplingEntries() data structure determines
2404  // which variables are "coupled" as far as the preconditioner is
2405  // concerned, not what variables a boundary condition specifically
2406  // depends on.
2407  std::vector<std::pair<MooseVariableFEBase *, MooseVariableFEBase *>> & coupling_entries =
2408  _fe_problem.couplingEntries(/*_tid=*/0);
2409 
2410  // Compute Jacobians for NodalBCBases
2411  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
2412  for (const auto & bnode : bnd_nodes)
2413  {
2414  BoundaryID boundary_id = bnode->_bnd_id;
2415  Node * node = bnode->_node;
2416 
2417  if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id) &&
2418  node->processor_id() == processor_id())
2419  {
2420  _fe_problem.reinitNodeFace(node, boundary_id, 0);
2421 
2422  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
2423  for (const auto & bc : bcs)
2424  {
2425  // Get the set of involved MOOSE vars for this BC
2426  std::set<unsigned int> & var_set = bc_involved_vars[bc->name()];
2427 
2428  // Loop over all the variables whose Jacobian blocks are
2429  // actually being computed, call computeOffDiagJacobian()
2430  // for each one which is actually coupled (otherwise the
2431  // value is zero.)
2432  for (const auto & it : coupling_entries)
2433  {
2434  unsigned int ivar = it.first->number(), jvar = it.second->number();
2435 
2436  // We are only going to call computeOffDiagJacobian() if:
2437  // 1.) the BC's variable is ivar
2438  // 2.) jvar is "involved" with the BC (including jvar==ivar), and
2439  // 3.) the BC should apply.
2440  if ((bc->variable().number() == ivar) && var_set.count(jvar) && bc->shouldApply())
2441  bc->computeOffDiagJacobian(jvar);
2442  }
2443  }
2444  }
2445  } // end loop over boundary nodes
2446 
2447  // Set the cached NodalBCBase values in the Jacobian matrix
2449  }
2450  PARALLEL_CATCH;
2451 
2452  closeTaggedMatrices(tags);
2453 
2454  // We need to close the save_in variables on the aux system before NodalBCBases clear the dofs on
2455  // boundary nodes
2458 
2459  if (hasDiagSaveIn())
2461 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:779
MooseObjectTagWarehouse< DGKernel > _dg_kernels
bool hasActiveBlockObjects(THREAD_ID tid=0) const
virtual Assembly & assembly(THREAD_ID tid) override
MooseObjectTagWarehouse< InterfaceKernel > _interface_kernels
bool _has_nodalbc_diag_save_in
If there is a nodal BC having diag_save_in.
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
virtual bool hasMatrix(TagID tag)
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:766
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:816
std::vector< std::pair< MooseVariableFEBase *, MooseVariableFEBase * > > & couplingEntries(THREAD_ID tid)
virtual GeometricSearchData & geomSearchData() override
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:939
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
Definition: SystemBase.C:780
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:850
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:668
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:772
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:2201
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:2105
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:1243
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.
MooseObjectTagWarehouse< IntegratedBCBase > _integrated_bcs
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:145
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:830
MooseObjectTagWarehouse< DiracKernel > _dirac_kernels
Dirac Kernel storage for each thread.
boundary_id_type BoundaryID
Definition: MooseTypes.h:108
unsigned int THREAD_ID
Definition: MooseTypes.h:112
void setCachedJacobianContributions()
Sets previously-cached Jacobian values via SparseMatrix::set() calls.
Definition: Assembly.C:2167

◆ computeJacobianTags()

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

Computes multiple (tag associated) Jacobian matricese.

Definition at line 2497 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobian().

2498 {
2499  TIME_SECTION(_compute_jacobian_tags_timer);
2500 
2501  FloatingPointExceptionGuard fpe_guard(_app);
2502 
2503  try
2504  {
2506  }
2507  catch (MooseException & e)
2508  {
2509  // The buck stops here, we have already handled the exception by
2510  // calling stopSolve(), it is now up to PETSc to return a
2511  // "diverged" reason during the next solve.
2512  }
2513 }
Scope guard for starting and stopping Floating Point Exception Trapping.
MooseApp & _app
Definition: SystemBase.h:665
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 1437 of file NonlinearSystemBase.C.

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

1438 {
1439  _nl_vector_tags.clear();
1440 
1441  auto & tags = _fe_problem.getVectorTags();
1442  for (auto & tag : tags)
1443  _nl_vector_tags.insert(tag.second);
1444 
1446  computeNodalBCs(residual, _nl_vector_tags);
1448 }
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:95
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:745
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:734
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 1451 of file NonlinearSystemBase.C.

1452 {
1454 
1455  computeNodalBCs(tags);
1456 
1458 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:745
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:734
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 1461 of file NonlinearSystemBase.C.

1462 {
1463  // We need to close the diag_save_in variables on the aux system before NodalBCBases clear the
1464  // dofs on boundary nodes
1465  if (_has_save_in)
1467 
1468  PARALLEL_TRY
1469  {
1470  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
1471 
1472  if (!bnd_nodes.empty())
1473  {
1474  TIME_SECTION(_nodal_bcs_timer);
1475 
1476  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
1477 
1478  // Select nodal kernels
1479  if (tags.size() == _fe_problem.numVectorTags() || !tags.size())
1480  nbc_warehouse = &_nodal_bcs;
1481  else if (tags.size() == 1)
1482  nbc_warehouse = &(_nodal_bcs.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1483  else
1484  nbc_warehouse = &(_nodal_bcs.getVectorTagsObjectWarehouse(tags, 0));
1485 
1486  for (const auto & bnode : bnd_nodes)
1487  {
1488  BoundaryID boundary_id = bnode->_bnd_id;
1489  Node * node = bnode->_node;
1490 
1491  if (node->processor_id() == processor_id())
1492  {
1493  // reinit variables in nodes
1494  _fe_problem.reinitNodeFace(node, boundary_id, 0);
1495  if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id))
1496  {
1497  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
1498  for (const auto & nbc : bcs)
1499  if (nbc->shouldApply())
1500  nbc->computeResidual();
1501  }
1502  }
1503  }
1504  }
1505  }
1506  PARALLEL_CATCH;
1507 
1508  if (_Re_time)
1509  _Re_time->close();
1510  _Re_non_time->close();
1511 }
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:110
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:668
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:1243
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:830
boundary_id_type BoundaryID
Definition: MooseTypes.h:108

◆ computeResidual()

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

Form a residual vector for a given tag.

Definition at line 565 of file NonlinearSystemBase.C.

566 {
567  mooseDeprecated(" Please use computeResidualTag");
568 
569  computeResidualTag(residual, tag_id);
570 }
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 1257 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTags().

1258 {
1259  TIME_SECTION(_compute_residual_internal_timer);
1260 
1261  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1262  {
1263  _kernels.residualSetup(tid);
1266  if (_doing_dg)
1272  }
1277 
1278  // reinit scalar variables
1279  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
1281 
1282  // residual contributions from the domain
1283  PARALLEL_TRY
1284  {
1285  TIME_SECTION(_kernels_timer);
1286 
1287  ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
1288 
1290 
1291  Threads::parallel_reduce(elem_range, cr);
1292 
1293  unsigned int n_threads = libMesh::n_threads();
1294  for (unsigned int i = 0; i < n_threads;
1295  i++) // Add any cached residuals that might be hanging around
1297  }
1298  PARALLEL_CATCH;
1299 
1300  // residual contributions from the scalar kernels
1301  PARALLEL_TRY
1302  {
1303  // do scalar kernels (not sure how to thread this)
1305  {
1306  TIME_SECTION(_scalar_kernels_timer);
1307 
1308  MooseObjectWarehouse<ScalarKernel> * scalar_kernel_warehouse;
1309  // This code should be refactored once we can do tags for scalar
1310  // kernels
1311  // Should redo this based on Warehouse
1312  if (!tags.size() || tags.size() == _fe_problem.numVectorTags())
1313  scalar_kernel_warehouse = &_scalar_kernels;
1314  else if (tags.size() == 1)
1315  scalar_kernel_warehouse =
1316  &(_scalar_kernels.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1317  else
1318  // scalar_kernels is not threading
1319  scalar_kernel_warehouse = &(_scalar_kernels.getVectorTagsObjectWarehouse(tags, 0));
1320 
1321  bool have_scalar_contributions = false;
1322  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
1323  for (const auto & scalar_kernel : scalars)
1324  {
1325  scalar_kernel->reinit();
1326  const std::vector<dof_id_type> & dof_indices = scalar_kernel->variable().dofIndices();
1327  const DofMap & dof_map = scalar_kernel->variable().dofMap();
1328  const dof_id_type first_dof = dof_map.first_dof();
1329  const dof_id_type end_dof = dof_map.end_dof();
1330  for (dof_id_type dof : dof_indices)
1331  {
1332  if (dof >= first_dof && dof < end_dof)
1333  {
1334  scalar_kernel->computeResidual();
1335  have_scalar_contributions = true;
1336  break;
1337  }
1338  }
1339  }
1340  if (have_scalar_contributions)
1342  }
1343  }
1344  PARALLEL_CATCH;
1345 
1346  // residual contributions from Block NodalKernels
1347  PARALLEL_TRY
1348  {
1350  {
1351  TIME_SECTION(_nodal_kernels_timer);
1352 
1354 
1355  ConstNodeRange & range = *_mesh.getLocalNodeRange();
1356 
1357  if (range.begin() != range.end())
1358  {
1359  _fe_problem.reinitNode(*range.begin(), 0);
1360 
1361  Threads::parallel_reduce(range, cnk);
1362 
1363  unsigned int n_threads = libMesh::n_threads();
1364  for (unsigned int i = 0; i < n_threads;
1365  i++) // Add any cached residuals that might be hanging around
1367  }
1368  }
1369  }
1370  PARALLEL_CATCH;
1371 
1372  // residual contributions from boundary NodalKernels
1373  PARALLEL_TRY
1374  {
1376  {
1377  TIME_SECTION(_nodal_kernel_bcs_timer);
1378 
1380 
1381  ConstBndNodeRange & bnd_node_range = *_mesh.getBoundaryNodeRange();
1382 
1383  Threads::parallel_reduce(bnd_node_range, cnk);
1384 
1385  unsigned int n_threads = libMesh::n_threads();
1386  for (unsigned int i = 0; i < n_threads;
1387  i++) // Add any cached residuals that might be hanging around
1389  }
1390  }
1391  PARALLEL_CATCH;
1392 
1393  if (_need_residual_copy)
1394  {
1395  _Re_non_time->close();
1396  _Re_non_time->localize(_residual_copy);
1397  }
1398 
1400  {
1401  _Re_non_time->close();
1403  _residual_ghosted->close();
1404  }
1405 
1406  PARALLEL_TRY { computeDiracContributions(tags, false); }
1407  PARALLEL_CATCH;
1408 
1410  {
1411  PARALLEL_TRY { enforceNodalConstraintsResidual(*_Re_non_time); }
1412  PARALLEL_CATCH;
1413  _Re_non_time->close();
1414  }
1415 
1416  // Add in Residual contributions from Constraints
1418  {
1419  PARALLEL_TRY
1420  {
1421  // Undisplaced Constraints
1423 
1424  // Displaced Constraints
1427 
1430  }
1431  PARALLEL_CATCH;
1432  _Re_non_time->close();
1433  }
1434 }
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:779
MooseObjectTagWarehouse< DGKernel > _dg_kernels
bool hasActiveBlockObjects(THREAD_ID tid=0) const
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
MooseObjectTagWarehouse< InterfaceKernel > _interface_kernels
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< T > & getVectorTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object at least has one of the given vector ta...
bool & computingNonlinearResid()
Check whether residual being evaulated is non-linear.
Definition: SubProblem.h:504
virtual unsigned int numVectorTags()
The total number of tags.
Definition: SubProblem.h:110
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
ConstNodeRange * getLocalNodeRange()
Definition: MooseMesh.C:816
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:668
bool _need_residual_copy
Whether or not a copy of the residual needs to be made.
bool hasActiveObjects(THREAD_ID tid=0) const
Convenience functions for determining if objects exist.
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:1243
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:830
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:112

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

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

551 {
552 
553  _nl_vector_tags.clear();
554  _nl_vector_tags.insert(tag_id);
556 
558 
560 
562 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:745
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:734
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 573 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTag().

574 {
575  TIME_SECTION(_compute_residual_tags_timer);
576 
577  bool required_residual = tags.find(residualVectorTag()) == tags.end() ? false : true;
578 
580 
581  // not suppose to do anythin on matrix
583 
585 
586  for (const auto & numeric_vec : _vecs_to_zero_for_residual)
587  if (hasVector(numeric_vec))
588  {
589  NumericVector<Number> & vec = getVector(numeric_vec);
590  vec.close();
591  vec.zero();
592  }
593 
594  try
595  {
596  zeroTaggedVectors(tags);
598  closeTaggedVectors(tags);
599 
600  if (required_residual)
601  {
602  auto & residual = getVector(residualVectorTag());
603  if (_time_integrator)
604  _time_integrator->postResidual(residual);
605  else
606  residual += *_Re_non_time;
607  residual.close();
608  }
609  computeNodalBCs(tags);
610  closeTaggedVectors(tags);
611 
612  // If we are debugging residuals we need one more assignment to have the ghosted copy up to date
613  if (_need_residual_ghosted && _debugging_residuals && required_residual)
614  {
615  auto & residual = getVector(residualVectorTag());
616 
617  *_residual_ghosted = residual;
618  _residual_ghosted->close();
619  }
620  // Need to close and update the aux system in case residuals were saved to it.
623  if (hasSaveIn())
625  }
626  catch (MooseException & e)
627  {
628  // The buck stops here, we have already handled the exception by
629  // calling stopSolve(), it is now up to PETSc to return a
630  // "diverged" reason during the next solve.
631  }
632 
633  // not supposed to do anything on matrix
635 }
virtual void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition: SystemBase.C:555
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:670
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.
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Scope guard for starting and stopping Floating Point Exception Trapping.
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:939
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:839
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:850
AuxiliarySystem & getAuxiliarySystem()
virtual void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition: SystemBase.C:545
void computeResidualInternal(const std::set< TagID > &tags)
Compute the residual for a given tag.
virtual NumericVector< Number > & solution() override
MooseApp & _app
Definition: SystemBase.h:665
Provides a way for users to bail out of the current solve.
unsigned int _n_residual_evaluations
Total number of residual evaluations that have been performed.
bool hasSaveIn() const
Weather or not the nonlinear system has save-ins.
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
void computeNodalBCs(NumericVector< Number > &residual)
Enforces nodal boundary conditions.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:720

◆ computeScalarKernelsJacobians()

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

Definition at line 2133 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

2134 {
2135  MooseObjectWarehouse<ScalarKernel> * scalar_kernel_warehouse;
2136 
2137  if (!tags.size() || tags.size() == _fe_problem.numMatrixTags())
2138  scalar_kernel_warehouse = &_scalar_kernels;
2139  else if (tags.size() == 1)
2140  scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2141  else
2142  scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagsObjectWarehouse(tags, 0));
2143 
2144  // Compute the diagonal block for scalar variables
2145  if (scalar_kernel_warehouse->hasActiveObjects())
2146  {
2147  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
2148 
2149  _fe_problem.reinitScalars(/*tid=*/0);
2150 
2151  bool have_scalar_contributions = false;
2152  for (const auto & kernel : scalars)
2153  {
2154  kernel->reinit();
2155  const std::vector<dof_id_type> & dof_indices = kernel->variable().dofIndices();
2156  const DofMap & dof_map = kernel->variable().dofMap();
2157  const dof_id_type first_dof = dof_map.first_dof();
2158  const dof_id_type end_dof = dof_map.end_dof();
2159  for (dof_id_type dof : dof_indices)
2160  {
2161  if (dof >= first_dof && dof < end_dof)
2162  {
2163  kernel->computeJacobian();
2164  _fe_problem.addJacobianOffDiagScalar(kernel->variable().number());
2165  have_scalar_contributions = true;
2166  break;
2167  }
2168  }
2169  }
2170 
2171  if (have_scalar_contributions)
2173  }
2174 }
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
Convenience functions for determining if objects exist.
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:145

◆ computeTimeDerivatives()

void NonlinearSystemBase::computeTimeDerivatives ( )
inherited

Computes the time derivative vector.

Definition at line 744 of file NonlinearSystemBase.C.

745 {
746  if (_time_integrator)
747  {
748  _time_integrator->preStep();
749  _time_integrator->computeTimeDerivatives();
750  }
751 }
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.

◆ computeVariables()

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

Definition at line 653 of file SystemBase.h.

653 {};

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

Referenced by NonlinearSystemBase::computeJacobianInternal().

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

Referenced by NonlinearSystemBase::computeResidualInternal().

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

◆ containsEigenKernel()

bool MooseEigenSystem::containsEigenKernel ( ) const

Weather or not the system contains eigen kernels.

Definition at line 252 of file MooseEigenSystem.C.

Referenced by EigenExecutionerBase::checkIntegrity().

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

◆ containsTimeKernel()

bool NonlinearSystemBase::containsTimeKernel ( )
inherited

Definition at line 2971 of file NonlinearSystemBase.C.

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

2972 {
2973  auto & time_kernels = _kernels.getVectorTagObjectWarehouse(timeVectorTag(), 0);
2974 
2975  return time_kernels.hasActiveObjects();
2976 }
MooseObjectTagWarehouse< KernelBase > _kernels
virtual TagID timeVectorTag() override
Ideally, we should not need this API.
bool hasActiveObjects(THREAD_ID tid=0) const
Convenience functions for determining if objects exist.
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...

◆ converged()

bool NonlinearSystem::converged ( )
overridevirtualinherited

Returns the convergence state.

Returns
true if converged, otherwise false

Implements NonlinearSystemBase.

Definition at line 384 of file NonlinearSystem.C.

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

◆ copyOldSolutions()

void SystemBase::copyOldSolutions ( )
virtualinherited

Shifts the solutions backwards in time.

Definition at line 971 of file SystemBase.C.

Referenced by EigenExecutionerBase::inversePowerIteration().

972 {
975  if (solutionUDotOld())
977  if (solutionUDotDotOld())
981 }
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 954 of file SystemBase.C.

955 {
956  system().update();
959  if (solutionUDotOld())
961  if (solutionUDotDotOld())
965 }
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 899 of file SystemBase.C.

900 {
901  int n_steps = io.get_num_time_steps();
902 
903  bool did_copy = false;
904  for (const auto & vci : _var_to_copy)
905  {
906  int timestep = -1;
907 
908  if (vci._timestep == "LATEST")
909  // Use the last time step in the file from which to retrieve the solution
910  timestep = n_steps;
911  else
912  {
913  timestep = MooseUtils::convert<int>(vci._timestep);
914  if (timestep > n_steps)
915  mooseError("Invalid value passed as \"initial_from_file_timestep\". Expected \"LATEST\" or "
916  "a valid integer between 1 and ",
917  n_steps,
918  " inclusive, received ",
919  vci._timestep);
920  }
921 
922  did_copy = true;
923  if (getVariable(0, vci._dest_name).isNodal())
924  io.copy_nodal_solution(system(), vci._dest_name, vci._source_name, timestep);
925  else
926  io.copy_elemental_solution(system(), vci._dest_name, vci._source_name, timestep);
927  }
928 
929  if (did_copy)
930  solution().close();
931 }
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:101
virtual bool isNodal() const =0
Is this variable nodal.
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:701
int convert< int >(const std::string &str, bool throw_on_failure)
Definition: MooseUtils.C:655
virtual System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > & solution()=0

◆ currentSolution()

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

The solution vector that is currently being operated on.

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

Implements SystemBase.

Definition at line 381 of file NonlinearSystemBase.h.

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

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

◆ deactiveAllMatrixTags()

void SystemBase::deactiveAllMatrixTags ( )
virtualinherited

Make matrices inactive.

Definition at line 839 of file SystemBase.C.

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

840 {
841  auto num_matrix_tags = _subproblem.numMatrixTags();
842 
843  _matrix_tag_active_flags.resize(num_matrix_tags);
844 
845  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
846  _matrix_tag_active_flags[tag] = false;
847 }
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:688
SubProblem & _subproblem
Definition: SystemBase.h:663
virtual unsigned int numMatrixTags()
The total number of tags.
Definition: SubProblem.h:145

◆ deactiveMatrixTag()

void SystemBase::deactiveMatrixTag ( TagID  tag)
virtualinherited

deactive a matrix for tag

Definition at line 827 of file SystemBase.C.

828 {
829  mooseAssert(_subproblem.matrixTagExists(tag),
830  "Cannot deactivate Matrix with matrix_tag : " << tag << "that does not exist");
831 
832  if (_matrix_tag_active_flags.size() < tag + 1)
833  _matrix_tag_active_flags.resize(tag + 1);
834 
835  _matrix_tag_active_flags[tag] = false;
836 }
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:118
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:688
SubProblem & _subproblem
Definition: SystemBase.h:663

◆ debuggingResiduals()

void NonlinearSystemBase::debuggingResiduals ( bool  state)
inlineinherited

Definition at line 502 of file NonlinearSystemBase.h.

502 { _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 872 of file SystemBase.C.

Referenced by DisplacedSystem::disassociateAllTaggedMatrices().

873 {
874  for (auto & matrix : _tagged_matrices)
875  matrix = nullptr;
876 }
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:686

◆ disassociateAllTaggedVectors()

void SystemBase::disassociateAllTaggedVectors ( )
virtualinherited

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

Reimplemented in DisplacedSystem.

Definition at line 759 of file SystemBase.C.

Referenced by DisplacedSystem::disassociateAllTaggedVectors().

760 {
761  for (auto & tagged_vector : _tagged_vectors)
762  tagged_vector = nullptr;
763 }
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:684

◆ disassociateMatrixFromTag()

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

disassociate a matirx from a tag

Reimplemented in DisplacedSystem.

Definition at line 800 of file SystemBase.C.

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

801 {
802  mooseAssert(_subproblem.matrixTagExists(tag),
803  "Cannot disassociate Matrix with matrix_tag : " << tag << "that does not exist");
804 
805  if (_tagged_matrices.size() < tag + 1)
806  _tagged_matrices.resize(tag + 1);
807 
808  if (_tagged_matrices[tag] != &matrix)
809  mooseError("You can not disassociate a matrix from a tag which it was not associated to");
810 
811  _tagged_matrices[tag] = nullptr;
812 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:686
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:118