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
 
NumericVector< Number > & solutionOld () override
 
const NumericVector< Number > & solutionOld () const override
 
NumericVector< Number > & solutionOlder () override
 
const NumericVector< Number > & solutionOlder () const override
 
virtual TransientNonlinearImplicitSystem & sys ()
 
virtual void init () override
 Initialize the system. More...
 
void turnOffJacobian ()
 Turn off the Jacobian (must be called before equation system initialization) More...
 
virtual void addExtraVectors () override
 Method called during initialSetup to add extra system vector if they are required by the simulation. More...
 
virtual void restoreSolutions () override
 Restore current solutions (call after your solve failed) More...
 
virtual bool computingInitialResidual ()
 Returns true if this system is currently computing the initial residual for a solve. More...
 
virtual void initialSetup ()
 
virtual void timestepSetup ()
 
void setupFieldDecomposition ()
 
bool haveFiniteDifferencedPreconditioner () const
 
bool haveFieldSplitPreconditioner () const
 
void addTimeIntegrator (const std::string &type, const std::string &name, InputParameters parameters) override
 Add a time integrator. More...
 
virtual void addTimeIntegrator (const std::string &, const std::string &, InputParameters)
 
virtual void addTimeIntegrator (std::shared_ptr< TimeIntegrator >)
 
virtual void addTimeIntegrator (std::shared_ptr< TimeIntegrator >)
 
void addDotVectors ()
 Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator. More...
 
virtual void addNodalKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a NodalKernel. More...
 
void addScalarKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a scalar kernel. More...
 
void addBoundaryCondition (const std::string &bc_name, const std::string &name, InputParameters parameters)
 Adds a boundary condition. More...
 
void addConstraint (const std::string &c_name, const std::string &name, InputParameters parameters)
 Adds a Constraint. More...
 
void addDiracKernel (const std::string &kernel_name, const std::string &name, InputParameters parameters)
 Adds a Dirac kernel. More...
 
void addDGKernel (std::string dg_kernel_name, const std::string &name, InputParameters parameters)
 Adds a DG kernel. More...
 
void addInterfaceKernel (std::string interface_kernel_name, const std::string &name, InputParameters parameters)
 Adds an interface kernel. More...
 
void addDamper (const std::string &damper_name, const std::string &name, InputParameters parameters)
 Adds a damper. More...
 
void addSplit (const std::string &split_name, const std::string &name, InputParameters parameters)
 Adds a split. More...
 
std::shared_ptr< SplitgetSplit (const std::string &name)
 Retrieves a split by name. More...
 
void zeroVectorForResidual (const std::string &vector_name)
 
void setInitialSolution ()
 
void setConstraintSlaveValues (NumericVector< Number > &solution, bool displaced)
 Sets the value of constrained variables in the solution vector. More...
 
void constraintResiduals (NumericVector< Number > &residual, bool displaced)
 Add residual contributions from Constraints. More...
 
void computeResidualTag (NumericVector< Number > &residual, TagID tag_id)
 Computes residual for a given tag. More...
 
void computeResidualTags (const std::set< TagID > &tags)
 Form multiple tag-associated residual vectors for all the given tags. More...
 
void computeResidual (NumericVector< Number > &residual, TagID tag_id)
 Form a residual vector for a given tag. More...
 
void findImplicitGeometricCouplingEntries (GeometricSearchData &geom_search_data, std::map< dof_id_type, std::vector< dof_id_type >> &graph)
 Finds the implicit sparsity graph between geometrically related dofs. More...
 
void addImplicitGeometricCouplingEntries (GeometricSearchData &geom_search_data)
 Adds entries to the Jacobian in the correct positions for couplings coming from dofs being coupled that are related geometrically (i.e. More...
 
void constraintJacobians (bool displaced)
 Add jacobian contributions from Constraints. More...
 
void setVariableGlobalDoFs (const std::string &var_name)
 set all the global dof indices for a nonlinear variable More...
 
const std::vector< dof_id_type > & getVariableGlobalDoFs ()
 
void computeJacobianTags (const std::set< TagID > &tags)
 Computes multiple (tag associated) Jacobian matricese. More...
 
void computeJacobian (SparseMatrix< Number > &jacobian, const std::set< TagID > &tags)
 Associate jacobian to systemMatrixTag, and then form a matrix for all the tags. More...
 
void computeJacobian (SparseMatrix< Number > &jacobian)
 Take all tags in the system, and form a matrix for all tags in the system. More...
 
void computeJacobianBlocks (std::vector< JacobianBlock *> &blocks)
 Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditioning matrices. More...
 
void computeJacobianBlocks (std::vector< JacobianBlock *> &blocks, const std::set< TagID > &tags)
 
Real computeDamping (const NumericVector< Number > &solution, const NumericVector< Number > &update)
 Compute damping. More...
 
void computeTimeDerivatives ()
 Computes the time derivative vector. More...
 
void onTimestepBegin ()
 Called at the beginning of the time step. More...
 
virtual void subdomainSetup (SubdomainID subdomain, THREAD_ID tid)
 Called from assembling when we hit a new subdomain. More...
 
virtual void setSolution (const NumericVector< Number > &soln)
 
void updateActive (THREAD_ID tid)
 Update active objects of Warehouses owned by NonlinearSystemBase. More...
 
virtual void setSolutionUDot (const NumericVector< Number > &udot)
 Set transient term used by residual and Jacobian evaluation. More...
 
virtual void setSolutionUDotDot (const NumericVector< Number > &udotdot)
 Set transient term used by residual and Jacobian evaluation. More...
 
NumericVector< Number > * solutionUDot () override
 
const NumericVector< Number > * solutionUDot () const override
 
NumericVector< Number > * solutionUDotDot () override
 
const NumericVector< Number > * solutionUDotDot () const override
 
NumericVector< Number > * solutionUDotOld () override
 
const NumericVector< Number > * solutionUDotOld () const override
 
NumericVector< Number > * solutionUDotDotOld () override
 
const NumericVector< Number > * solutionUDotDotOld () const 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...
 
const NumericVector< Number > *const & currentSolution () const 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...
 
MoosePreconditioner const * getPreconditioner () const
 
void useFiniteDifferencedPreconditioner (bool use=true)
 If called with true this system will use a finite differenced form of the Jacobian as the preconditioner. More...
 
void setDecomposition (const std::vector< std::string > &decomposition)
 If called with a single string, it is used as the name of a the top-level decomposition split. More...
 
void useFieldSplitPreconditioner (bool use=true)
 If called with true this system will use a field split preconditioner matrix. More...
 
void addImplicitGeometricCouplingEntriesToJacobian (bool add=true)
 If called with true this will add entries into the jacobian to link together degrees of freedom that are found to be related through the geometric search system. More...
 
void assembleConstraintsSeparately (bool separately=true)
 Indicates whether to assemble residual and Jacobian after each constraint application. More...
 
void setupDampers ()
 Setup damping stuff (called before we actually start) More...
 
void reinitIncrementAtQpsForDampers (THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
 Compute the incremental change in variables at QPs for dampers. More...
 
void reinitIncrementAtNodeForDampers (THREAD_ID tid, const std::set< MooseVariable *> &damped_vars)
 Compute the incremental change in variables at nodes for dampers. More...
 
unsigned int nNonlinearIterations () const
 Return the number of non-linear iterations. More...
 
unsigned int nLinearIterations () const
 Return the number of linear iterations. More...
 
unsigned int nResidualEvaluations () const
 Return the total number of residual evaluations done so far in this calculation. More...
 
Real finalNonlinearResidual () const
 Return the final nonlinear residual. More...
 
Real nonlinearNorm () const
 Return the last nonlinear norm. More...
 
void printAllVariableNorms (bool state)
 Force the printing of all variable norms after each solve. More...
 
void debuggingResiduals (bool state)
 
void setPredictor (std::shared_ptr< Predictor > predictor)
 
PredictorgetPredictor ()
 
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...
 
NumericVector< Number > & solution () override
 
const NumericVector< Number > & solution () const override
 
virtual System & system () override
 Get the reference to the libMesh system. More...
 
virtual const System & system () const override
 
NumericVector< Number > * solutionPreviousNewton () override
 
const NumericVector< Number > * solutionPreviousNewton () const override
 
virtual void setSolutionUDotOld (const NumericVector< Number > &u_dot_old)
 
virtual void setSolutionUDotDotOld (const NumericVector< Number > &u_dotdot_old)
 
virtual void setPreviousNewtonSolution (const NumericVector< Number > &soln)
 
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 const MooseMeshmesh () const
 
virtual SubProblemsubproblem ()
 
virtual const SubProblemsubproblem () const
 
virtual DofMap & dofMap ()
 Gets writeable reference to the dof map. More...
 
virtual const DofMap & dofMap () const
 Gets const reference to the dof map. More...
 
virtual void initializeObjects ()
 Called only once, just before the solve begins so objects can do some precalculations. More...
 
virtual void update ()
 Update the system (doing libMesh magic) More...
 
virtual void copyOldSolutions ()
 Shifts the solutions backwards in time. More...
 
virtual Number & duDotDu ()
 
virtual const Number & duDotDu () const
 
virtual Number & duDotDotDu ()
 
virtual const Number & duDotDotDu () const
 
virtual void saveOldSolutions ()
 Save the old and older solutions. More...
 
virtual void restoreOldSolutions ()
 Restore the old and older solutions when the saved solutions present. More...
 
bool hasVector (const std::string &tag_name) const
 Check if the named vector exists in the system. More...
 
virtual bool hasVector (TagID tag_id) const
 Check if the tagged vector exists in the system. More...
 
virtual 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 const NumericVector< Number > & getVector (TagID tag) const
 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) const
 Check if the tagged matrix exists in the system. More...
 
virtual SparseMatrix< Number > & getMatrix (TagID tag)
 Get a raw SparseMatrix. More...
 
virtual const SparseMatrix< Number > & getMatrix (TagID tag) const
 Get a raw SparseMatrix. More...
 
virtual void activeAllMatrixTags ()
 Make all exsiting matrices ative. More...
 
virtual void activeMatrixTag (TagID tag)
 Active a matrix for tag. More...
 
virtual bool matrixTagActive (TagID tag) const
 If or not a matrix tag is active. More...
 
virtual void deactiveMatrixTag (TagID tag)
 deactive a matrix for tag More...
 
virtual void deactiveAllMatrixTags ()
 Make matrices inactive. More...
 
void closeTaggedMatrices (const std::set< TagID > &tags)
 Close all matrices associated the tags. More...
 
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 () const
 Gets the maximum number of dofs used by any one variable on any one element. More...
 
size_t getMaxVarNDofsPerNode () const
 Gets the maximum number of dofs used by any one variable on any one node. More...
 
void assignMaxVarNDofsPerElem (const size_t &max_dofs)
 assign the maximum element dofs More...
 
void assignMaxVarNDofsPerNode (const size_t &max_dofs)
 assign the maximum node dofs More...
 
virtual void addVariableToZeroOnResidual (std::string var_name)
 Adds this variable to the list of variables to be zeroed during each residual evaluation. More...
 
virtual void addVariableToZeroOnJacobian (std::string var_name)
 Adds this variable to the list of variables to be zeroed during each Jacobian evaluation. More...
 
virtual void zeroVariables (std::vector< std::string > &vars_to_be_zeroed)
 Zero out the solution for the list of variables passed in. More...
 
virtual void zeroVariablesForResidual ()
 Zero out the solution for the variables that were registered as needing to have their solutions zeroed on out on residual evaluation by a call to addVariableToZeroOnResidual() More...
 
virtual void zeroVariablesForJacobian ()
 Zero out the solution for the variables that were registered as needing to have their solutions zeroed on out on Jacobian evaluation by a call to addVariableToZeroOnResidual() More...
 
virtual Order getMinQuadratureOrder ()
 Get minimal quadrature order needed for integrating variables in this system. More...
 
virtual void prepare (THREAD_ID tid)
 Prepare the system for use. More...
 
virtual void prepareFace (THREAD_ID tid, bool resize_data)
 Prepare the system for use on sides. More...
 
virtual void prepareNeighbor (THREAD_ID tid)
 Prepare the system for use. More...
 
virtual void prepareLowerD (THREAD_ID tid)
 Prepare the system for use for lower dimensional elements. More...
 
virtual void reinitElem (const Elem *elem, THREAD_ID tid)
 Reinit an element assembly info. More...
 
virtual void reinitElemFace (const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
 Reinit assembly info for a side of an element. More...
 
virtual void reinitNeighborFace (const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
 Compute the values of the variables at all the current points. More...
 
virtual void reinitNeighbor (const Elem *elem, THREAD_ID tid)
 Compute the values of the variables at all the current points. More...
 
virtual void reinitLowerD (THREAD_ID tid)
 Compute the values of the variables on the lower dimensional element. More...
 
virtual void reinitNode (const Node *node, THREAD_ID tid)
 Reinit nodal assembly info. More...
 
virtual void reinitNodeFace (const Node *node, BoundaryID bnd_id, THREAD_ID tid)
 Reinit nodal assembly info on a face. More...
 
virtual void reinitNodes (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of nodes. More...
 
virtual void reinitNodesNeighbor (const std::vector< dof_id_type > &nodes, THREAD_ID tid)
 Reinit variables at a set of neighbor nodes. More...
 
virtual void reinitScalars (THREAD_ID tid)
 Reinit scalar varaibles. More...
 
virtual void addVariableToCopy (const std::string &dest_name, const std::string &source_name, const std::string &timestep)
 Add info about variable that will be copied. More...
 
const std::vector< MooseVariableFEBase * > & getVariables (THREAD_ID tid)
 
const std::vector< MooseVariableScalar * > & getScalarVariables (THREAD_ID tid)
 
const std::set< SubdomainID > & getSubdomainsForVar (unsigned int var_number) const
 
virtual void removeVector (const std::string &name)
 Remove a vector from the system with the given name. More...
 
virtual void removeVector (TagID tag_id)
 Remove a solution length vector from the system with the specified TagID. More...
 
virtual NumericVector< Number > & addVector (const std::string &vector_name, const bool project, const ParallelType type)
 Adds a solution length vector to the system. More...
 
NumericVector< Number > & addVector (TagID tag, const bool project, const ParallelType type)
 Adds a solution length vector to the system with the specified TagID. More...
 
virtual void closeTaggedVectors (const std::set< TagID > &tags)
 Close all vectors for given tags. More...
 
virtual void zeroTaggedVectors (const std::set< TagID > &tags)
 Zero all vectors for given tags. More...
 
virtual void removeMatrix (TagID)
 Removes a jacobian sized vector. More...
 
virtual const std::string & name () const
 
virtual void addScalarVariable (const std::string &var_name, Order order, Real scale_factor, const std::set< SubdomainID > *const active_subdomains=NULL)
 Adds a scalar variable. More...
 
const std::vector< VariableName > & getVariableNames () const
 
virtual void computeVariables (const NumericVector< Number > &)
 
void copyVars (ExodusII_IO &io)
 
virtual void copySolutionsBackwards ()
 Copy current solution into old and older. More...
 
TimeIntegratorgetTimeIntegrator ()
 
const TimeIntegratorgetTimeIntegrator () const
 
std::shared_ptr< TimeIntegratorgetSharedTimeIntegrator ()
 
void checkKernelCoverage (const std::set< SubdomainID > &mesh_subdomains) const
 
bool containsTimeKernel ()
 
MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse ()
 Access functions to Warehouses from outside NonlinearSystemBase. More...
 
MooseObjectTagWarehouse< KernelBase > & getADJacobianKernelWarehouse ()
 
MooseObjectTagWarehouse< DGKernelBase > & getDGKernelWarehouse ()
 
MooseObjectTagWarehouse< InterfaceKernel > & getInterfaceKernelWarehouse ()
 
MooseObjectTagWarehouse< DiracKernel > & getDiracKernelWarehouse ()
 
MooseObjectTagWarehouse< IntegratedBCBase > & getIntegratedBCWarehouse ()
 
const MooseObjectWarehouse< ElementDamper > & getElementDamperWarehouse () const
 
const MooseObjectWarehouse< NodalDamper > & getNodalDamperWarehouse () const
 
const ConstraintWarehousegetConstraintWarehouse () const
 
virtual bool hasVariable (const std::string &var_name) const
 Query a system for a variable. More...
 
virtual bool hasScalarVariable (const std::string &var_name) const
 

Public Attributes

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

Protected Member Functions

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

Protected Attributes

std::set< VariableName > _eigen_var_names
 
bool _all_eigen_vars
 
std::set< dof_id_type > _eigen_var_indices
 
bool _active_on_old
 
unsigned int _eigen_kernel_counter
 counter of eigen kernels More...
 
TransientNonlinearImplicitSystem & _transient_sys
 
ComputeResidualFunctor _nl_residual_functor
 
ComputeFDResidualFunctor _fd_residual_functor
 
const NumericVector< Number > * _current_solution
 solution vector from nonlinear solver More...
 
NumericVector< Number > * _residual_ghosted
 ghosted form of the residual More...
 
NumericVector< Number > & _serialized_solution
 Serialized version of the solution vector. More...
 
NumericVector< Number > * _solution_previous_nl
 Solution vector of the previous nonlinear iterate. More...
 
NumericVector< Number > & _residual_copy
 Copy of the residual vector. More...
 
NumericVector< Number > * _u_dot
 solution vector for u^dot More...
 
NumericVector< Number > * _u_dotdot
 solution vector for u^dotdot More...
 
NumericVector< Number > * _u_dot_old
 old solution vector for u^dot More...
 
NumericVector< Number > * _u_dotdot_old
 old solution vector for u^dotdot More...
 
Number _du_dot_du
 \( {du^dot}\over{du} \) More...
 
Number _du_dotdot_du
 \( {du^dotdot}\over{du} \) More...
 
TagID _Re_time_tag
 Tag for time contribution residual. More...
 
std::set< TagID_nl_vector_tags
 Vector tags to temporarily store all tags associated with the current system. More...
 
std::set< TagID_nl_matrix_tags
 Matrix tags to temporarily store all tags associated with the current system. More...
 
NumericVector< Number > * _Re_time
 residual vector for time contributions More...
 
TagID _Re_non_time_tag
 Tag for non-time contribution residual. More...
 
NumericVector< Number > * _Re_non_time
 residual vector for non-time contributions More...
 
TagID _Re_tag
 Used for the residual vector from PETSc. More...
 
TagID _Ke_non_time_tag
 Tag for non-time contribution Jacobian. More...
 
TagID _Ke_system_tag
 Tag for system contribution Jacobian. More...
 
MooseObjectTagWarehouse< DiracKernel_dirac_kernels
 Dirac Kernel storage for each thread. More...
 
MooseObjectWarehouse< ElementDamper_element_dampers
 Element Dampers for each thread. More...
 
MooseObjectWarehouse< NodalDamper_nodal_dampers
 Nodal Dampers for each thread. More...
 
MooseObjectWarehouse< GeneralDamper_general_dampers
 General Dampers. More...
 
MooseObjectTagWarehouse< NodalKernel_nodal_kernels
 NodalKernels for each thread. More...
 
MooseObjectWarehouseBase< Split_splits
 Decomposition splits. More...
 
ConstraintWarehouse _constraints
 Constraints storage object. More...
 
NumericVector< Number > * _increment_vec
 increment vector More...
 
std::shared_ptr< MoosePreconditioner_preconditioner
 Preconditioner. More...
 
Moose::PCSideType _pc_side
 Preconditioning side. More...
 
Moose::MooseKSPNormType _ksp_norm
 KSP norm type. More...
 
bool _use_finite_differenced_preconditioner
 Whether or not to use a finite differenced preconditioner. More...
 
MatFDColoring _fdcoloring
 
bool _have_decomposition
 Whether or not the system can be decomposed into splits. More...
 
std::string _decomposition_split
 Name of the top-level split of the decomposition. More...
 
bool _use_field_split_preconditioner
 Whether or not to use a FieldSplitPreconditioner matrix based on the decomposition. More...
 
bool _add_implicit_geometric_coupling_entries_to_jacobian
 Whether or not to add implicit geometric couplings to the Jacobian for FDP. More...
 
bool _assemble_constraints_separately
 Whether or not to assemble the residual and Jacobian after the application of each constraint. More...
 
bool _need_serialized_solution
 Whether or not a copy of the residual needs to be made. More...
 
bool _need_residual_copy
 Whether or not a copy of the residual needs to be made. More...
 
bool _need_residual_ghosted
 Whether or not a ghosted copy of the residual needs to be made. More...
 
bool _debugging_residuals
 true if debugging residuals More...
 
bool _doing_dg
 true if DG is active (optimization reasons) More...
 
std::vector< std::string > _vecs_to_zero_for_residual
 vectors that will be zeroed before a residual computation More...
 
unsigned int _n_iters
 
unsigned int _n_linear_iters
 
unsigned int _n_residual_evaluations
 Total number of residual evaluations that have been performed. More...
 
Real _final_residual
 
std::shared_ptr< Predictor_predictor
 If predictor is active, this is non-NULL. More...
 
bool _computing_initial_residual
 
bool _print_all_var_norms
 
bool _has_save_in
 If there is any Kernel or IntegratedBC having save_in. More...
 
bool _has_diag_save_in
 If there is any Kernel or IntegratedBC having diag_save_in. More...
 
bool _has_nodalbc_save_in
 If there is a nodal BC having save_in. More...
 
bool _has_nodalbc_diag_save_in
 If there is a nodal BC having diag_save_in. More...
 
std::vector< dof_id_type > _var_all_dof_indices
 
PerfID _compute_residual_tags_timer
 Timers. More...
 
PerfID _compute_residual_internal_timer
 
PerfID _kernels_timer
 
PerfID _scalar_kernels_timer
 
PerfID _nodal_kernels_timer
 
PerfID _nodal_kernel_bcs_timer
 
PerfID _nodal_bcs_timer
 
PerfID _compute_jacobian_tags_timer
 
PerfID _compute_jacobian_blocks_timer
 
PerfID _compute_dampers_timer
 
PerfID _compute_dirac_timer
 
SubProblem_subproblem
 
MooseApp_app
 
Factory_factory
 
MooseMesh_mesh
 
std::string _name
 The name of this system. More...
 
std::vector< VariableWarehouse_vars
 Variable warehouses (one for each thread) More...
 
std::map< unsigned int, std::set< SubdomainID > > _var_map
 Map of variables (variable id -> array of subdomains where it lives) More...
 
std::vector< std::string > _vars_to_be_zeroed_on_residual
 
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
 
std::vector< NumericVector< Number > * > _tagged_vectors
 Tagged vectors (pointer) More...
 
std::vector< SparseMatrix< Number > * > _tagged_matrices
 Tagged matrices (pointer) More...
 
std::vector< bool > _matrix_tag_active_flags
 Active flags for tagged matrices. More...
 
NumericVector< Real > * _saved_old
 
NumericVector< Real > * _saved_older
 
NumericVector< Real > * _saved_dot_old
 
NumericVector< Real > * _saved_dotdot_old
 
Moose::VarKindType _var_kind
 default kind of variables in this system More...
 
std::vector< VarCopyInfo_var_to_copy
 
size_t _max_var_n_dofs_per_elem
 Maximum number of dofs for any one variable on any one element. More...
 
size_t _max_var_n_dofs_per_node
 Maximum number of dofs for any one variable on any one node. More...
 
std::shared_ptr< TimeIntegrator_time_integrator
 Time integrator. More...
 
const InputParameters_pg_params
 Params. More...
 
PerfGraph_perf_graph
 The performance graph to add to. More...
 
std::string _prefix
 A prefix to use for all sections. More...
 
MooseObjectTagWarehouse< KernelBase_kernels
 
MooseObjectTagWarehouse< KernelBase_ad_jacobian_kernels
 
MooseObjectTagWarehouse< ScalarKernel_scalar_kernels
 
MooseObjectTagWarehouse< DGKernelBase_dg_kernels
 
MooseObjectTagWarehouse< InterfaceKernel_interface_kernels
 
MooseObjectTagWarehouse< IntegratedBCBase_integrated_bcs
 
MooseObjectTagWarehouse< NodalBCBase_nodal_bcs
 
MooseObjectWarehouse< PresetNodalBC_preset_nodal_bcs
 
MooseObjectWarehouse< ADPresetNodalBC< RESIDUAL > > _ad_preset_nodal_bcs
 

Detailed Description

Definition at line 19 of file MooseEigenSystem.h.

Member Enumeration Documentation

◆ SYSTEMTAG

System or kernel tags.

Enumerator
ALL 
EIGEN 

Definition at line 43 of file MooseEigenSystem.h.

Constructor & Destructor Documentation

◆ MooseEigenSystem()

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

Definition at line 16 of file MooseEigenSystem.C.

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

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

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

898 {
899  auto num_matrix_tags = _subproblem.numMatrixTags();
900 
901  _matrix_tag_active_flags.resize(num_matrix_tags);
902 
903  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
904  if (hasMatrix(tag))
905  _matrix_tag_active_flags[tag] = true;
906  else
907  _matrix_tag_active_flags[tag] = false;
908 }
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:805
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:760
SubProblem & _subproblem
Definition: SystemBase.h:735
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:157

◆ activeMatrixTag()

void SystemBase::activeMatrixTag ( TagID  tag)
virtualinherited

Active a matrix for tag.

Definition at line 862 of file SystemBase.C.

863 {
864  mooseAssert(_subproblem.matrixTagExists(tag),
865  "Cannot active Matrix with matrix_tag : " << tag << "that does not exist");
866 
867  if (_matrix_tag_active_flags.size() < tag + 1)
868  _matrix_tag_active_flags.resize(tag + 1);
869 
870  _matrix_tag_active_flags[tag] = true;
871 }
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:129
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:760
SubProblem & _subproblem
Definition: SystemBase.h:735

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

433 {
434  // ThreadID
435  THREAD_ID tid = 0;
436 
437  // Create the object
438  std::shared_ptr<BoundaryCondition> bc =
439  _factory.create<BoundaryCondition>(bc_name, name, parameters, tid);
440 
441  // Active BoundaryIDs for the object
442  const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
443  _vars[tid].addBoundaryVar(boundary_ids, &bc->variable());
444 
445  // Cast to the various types of BCs
446  std::shared_ptr<NodalBCBase> nbc = std::dynamic_pointer_cast<NodalBCBase>(bc);
447  std::shared_ptr<IntegratedBCBase> ibc = std::dynamic_pointer_cast<IntegratedBCBase>(bc);
448 
449  // NodalBCBase
450  if (nbc)
451  {
452  _nodal_bcs.addObject(nbc);
453  _vars[tid].addBoundaryVars(boundary_ids, nbc->getCoupledVars());
454 
455  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
456  _has_nodalbc_save_in = true;
457  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
459 
460  // PresetNodalBC
461  std::shared_ptr<PresetNodalBC> pnbc = std::dynamic_pointer_cast<PresetNodalBC>(bc);
462  if (pnbc)
464 
465  std::shared_ptr<ADPresetNodalBC<RESIDUAL>> adpnbc =
467  if (adpnbc)
469  }
470 
471  // IntegratedBCBase
472  else if (ibc)
473  {
474  _integrated_bcs.addObject(ibc, tid);
475  _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
476 
477  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
478  _has_save_in = true;
479  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
480  _has_diag_save_in = true;
481 
482  for (tid = 1; tid < libMesh::n_threads(); tid++)
483  {
484  // Create the object
485  bc = _factory.create<BoundaryCondition>(bc_name, name, parameters, tid);
486 
487  // Active BoundaryIDs for the object
488  const std::set<BoundaryID> & boundary_ids = bc->boundaryIDs();
489  _vars[tid].addBoundaryVar(boundary_ids, &bc->variable());
490 
491  ibc = std::static_pointer_cast<IntegratedBCBase>(bc);
492 
493  _integrated_bcs.addObject(ibc, tid);
494  _vars[tid].addBoundaryVars(boundary_ids, ibc->getCoupledVars());
495  }
496  }
497 
498  else
499  mooseError("Unknown BoundaryCondition type for object named ", bc->name());
500 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
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:738
bool _has_nodalbc_save_in
If there is a nodal BC having save_in.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
Base class for automatic differentiation nodal BCs that (pre)set the solution vector entries...
virtual const std::string & name() const
Definition: SystemBase.C:1088
Base class for nodal BCs that (pre)set the solution vector entries.
Definition: PresetNodalBC.h:22
Base class for deriving any boundary condition that works at nodes.
Definition: NodalBCBase.h:32
Base class for creating new types of boundary conditions.
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:745
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
MooseObjectWarehouse< ADPresetNodalBC< RESIDUAL > > _ad_preset_nodal_bcs
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:161
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 503 of file NonlinearSystemBase.C.

506 {
507  std::shared_ptr<Constraint> constraint = _factory.create<Constraint>(c_name, name, parameters);
508  _constraints.addObject(constraint);
509 
510  if (constraint && constraint->addCouplingEntriesToJacobian())
512 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
void addImplicitGeometricCouplingEntriesToJacobian(bool add=true)
If called with true this will add entries into the jacobian to link together degrees of freedom that ...
Base class for all Constraint types.
Definition: Constraint.h:39
Factory & _factory
Definition: SystemBase.h:738
virtual const std::string & name() const
Definition: SystemBase.C:1088
ConstraintWarehouse _constraints
Constraints storage object.
void addObject(std::shared_ptr< Constraint > object, THREAD_ID tid=0, bool recurse=true) override
Add Constraint object to the warehouse.

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

568 {
569  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
570  {
571  std::shared_ptr<Damper> damper = _factory.create<Damper>(damper_name, name, parameters, tid);
572 
573  // Attempt to cast to the damper types
574  std::shared_ptr<ElementDamper> ed = std::dynamic_pointer_cast<ElementDamper>(damper);
575  std::shared_ptr<NodalDamper> nd = std::dynamic_pointer_cast<NodalDamper>(damper);
576  std::shared_ptr<GeneralDamper> gd = std::dynamic_pointer_cast<GeneralDamper>(damper);
577 
578  if (gd)
579  {
581  break; // not threaded
582  }
583  else if (ed)
584  _element_dampers.addObject(ed, tid);
585  else if (nd)
586  _nodal_dampers.addObject(nd, tid);
587  else
588  mooseError("Invalid damper type");
589  }
590 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Base class for deriving general dampers.
Definition: GeneralDamper.h:26
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
Factory & _factory
Definition: SystemBase.h:738
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
virtual const std::string & name() const
Definition: SystemBase.C:1088
Base class for deriving nodal dampers.
Definition: NodalDamper.h:32
Base class for deriving element dampers.
Definition: ElementDamper.h:33
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
Base class for deriving dampers.
Definition: Damper.h:29
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:161

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

531 {
532  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
533  {
534  auto dg_kernel = _factory.create<DGKernelBase>(dg_kernel_name, name, parameters, tid);
535  _dg_kernels.addObject(dg_kernel, tid);
536  }
537 
538  _doing_dg = true;
539 
540  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
541  _has_save_in = true;
542  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
543  _has_diag_save_in = true;
544 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
Factory & _factory
Definition: SystemBase.h:738
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
Serves as a base class for DGKernel and ADDGKernel.
Definition: DGKernelBase.h:46
virtual const std::string & name() const
Definition: SystemBase.C:1088
bool _doing_dg
true if DG is active (optimization reasons)
bool _has_diag_save_in
If there is any Kernel or IntegratedBC having diag_save_in.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true) override
Adds an object to the storage structure.
unsigned int THREAD_ID
Definition: MooseTypes.h:161

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

518 {
519  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
520  {
521  std::shared_ptr<DiracKernel> kernel =
522  _factory.create<DiracKernel>(kernel_name, name, parameters, tid);
523  _dirac_kernels.addObject(kernel, tid);
524  }
525 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Factory & _factory
Definition: SystemBase.h:738
virtual const std::string & name() const
Definition: SystemBase.C:1088
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:45
MooseObjectTagWarehouse< DiracKernel > _dirac_kernels
Dirac Kernel storage for each thread.
unsigned int THREAD_ID
Definition: MooseTypes.h:161

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

221 {
223  _u_dot = &addVector("u_dot", true, GHOSTED);
225  _u_dot_old = &addVector("u_dot_old", true, GHOSTED);
227  _u_dotdot = &addVector("u_dotdot", true, GHOSTED);
229  _u_dotdot_old = &addVector("u_dotdot_old", true, GHOSTED);
230 }
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:542
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 240 of file NonlinearSystemBase.C.

241 {
243  _solution_previous_nl = &addVector("u_previous_newton", true, GHOSTED);
244 }
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:542
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 1674 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

1675 {
1676  if (!hasMatrix(systemMatrixTag()))
1677  mooseError("Need a system matrix ");
1678 
1679  // At this point, have no idea how to make
1680  // this work with tag system
1681  auto & jacobian = getMatrix(systemMatrixTag());
1682 
1683  std::map<dof_id_type, std::vector<dof_id_type>> graph;
1684 
1685  findImplicitGeometricCouplingEntries(geom_search_data, graph);
1686 
1687  for (const auto & it : graph)
1688  {
1689  dof_id_type dof = it.first;
1690  const std::vector<dof_id_type> & row = it.second;
1691 
1692  for (const auto & coupled_dof : row)
1693  jacobian.add(dof, coupled_dof, 0);
1694  }
1695 }
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:805
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
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:811

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

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

446  {
448  }
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 547 of file NonlinearSystemBase.C.

550 {
551  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
552  {
553  std::shared_ptr<InterfaceKernel> interface_kernel =
554  _factory.create<InterfaceKernel>(interface_kernel_name, name, parameters, tid);
555 
556  const std::set<BoundaryID> & boundary_ids = interface_kernel->boundaryIDs();
557  _vars[tid].addBoundaryVar(boundary_ids, &interface_kernel->variable());
558 
559  _interface_kernels.addObject(interface_kernel, tid);
560  _vars[tid].addBoundaryVars(boundary_ids, interface_kernel->getCoupledVars());
561  }
562 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
MooseObjectTagWarehouse< InterfaceKernel > _interface_kernels
Factory & _factory
Definition: SystemBase.h:738
virtual const std::string & name() const
Definition: SystemBase.C:1088
InterfaceKernel is responsible for interfacing physics across subdomains.
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:745
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:161

◆ addKernel()

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

Adds a kernel.

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

Reimplemented from NonlinearSystemBase.

Definition at line 27 of file MooseEigenSystem.C.

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

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

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

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

404 {
405  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
406  {
407  // Create the kernel object via the factory and add to the warehouse
408  std::shared_ptr<NodalKernel> kernel =
409  _factory.create<NodalKernel>(kernel_name, name, parameters, tid);
410  _nodal_kernels.addObject(kernel, tid);
411  }
412 
413  if (parameters.get<std::vector<AuxVariableName>>("save_in").size() > 0)
414  _has_save_in = true;
415  if (parameters.get<std::vector<AuxVariableName>>("diag_save_in").size() > 0)
416  _has_diag_save_in = true;
417 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Factory & _factory
Definition: SystemBase.h:738
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
virtual const std::string & name() const
Definition: SystemBase.C:1088
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:48
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:161

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

423 {
424  std::shared_ptr<ScalarKernel> kernel =
425  _factory.create<ScalarKernel>(kernel_name, name, parameters);
426  _scalar_kernels.addObject(kernel);
427 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Factory & _factory
Definition: SystemBase.h:738
virtual const std::string & name() const
Definition: SystemBase.C:1088
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 644 of file SystemBase.C.

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

648 {
649  FEType type(order, SCALAR);
650  unsigned int var_num = system().add_variable(var_name, type, active_subdomains);
651  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
652  {
653  // FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in
654  // MooseVariableBase.
655  MooseVariableScalar * var =
656  new MooseVariableScalar(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
657  var->scalingFactor(scale_factor);
658  _vars[tid].add(var_name, var);
659  }
660  if (active_subdomains == nullptr)
661  _var_map[var_num] = std::set<SubdomainID>();
662  else
663  for (const auto subdomain_id : *active_subdomains)
664  _var_map[var_num].insert(subdomain_id);
665 }
virtual Assembly & assembly(THREAD_ID tid)=0
SubProblem & _subproblem
Definition: SystemBase.h:735
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:771
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:747
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:745
MatType type
Class for scalar variables (they are different).
unsigned int THREAD_ID
Definition: MooseTypes.h:161
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 593 of file NonlinearSystemBase.C.

596 {
597  std::shared_ptr<Split> split = _factory.create<Split>(split_name, name, parameters);
599 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
Base class for split-based preconditioners.
Definition: Split.h:29
Factory & _factory
Definition: SystemBase.h:738
MooseObjectWarehouseBase< Split > _splits
Decomposition splits.
std::vector< std::string > split(const std::string &str, const std::string &delimiter)
Python like split function for strings.
Definition: MooseUtils.C:736
virtual const std::string & name() const
Definition: SystemBase.C:1088
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true)
Adds an object to the storage structure.

◆ addTimeIntegrator() [1/4]

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

Add a time integrator.

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

Reimplemented from SystemBase.

Definition at line 367 of file NonlinearSystemBase.C.

370 {
371  parameters.set<SystemBase *>("_sys") = this;
372 
373  std::shared_ptr<TimeIntegrator> ti = _factory.create<TimeIntegrator>(type, name, parameters);
374  _time_integrator = ti;
375 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Factory & _factory
Definition: SystemBase.h:738
Base class for a system (of equations)
Definition: SystemBase.h:92
virtual const std::string & name() const
Definition: SystemBase.C:1088
MatType type
Base class for time integrators.
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:782

◆ addTimeIntegrator() [2/4]

virtual void SystemBase::addTimeIntegrator
inlineinherited

Definition at line 721 of file SystemBase.h.

724  {
725  }

◆ addTimeIntegrator() [3/4]

virtual void SystemBase::addTimeIntegrator
inlineinherited

Definition at line 727 of file SystemBase.h.

727 {}

◆ addTimeIntegrator() [4/4]

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

Reimplemented in DisplacedSystem.

Definition at line 727 of file SystemBase.h.

727 {}

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

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

617 {
618  unsigned int var_num = system().add_variable(var_name, type, active_subdomains);
619  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
620  {
621  // FIXME: we cannot refer fetype in libMesh at this point, so we will just make a copy in
622  // MooseVariableBase.
623  MooseVariableBase * var;
624  if (type == FEType(0, MONOMIAL))
625  var = new MooseVariableConstMonomial(
626  var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
627  else if (type == FEType(FIRST, NEDELEC_ONE) || type.family == LAGRANGE_VEC)
628  var =
629  new VectorMooseVariable(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
630  else
631  var = new MooseVariable(var_num, type, *this, _subproblem.assembly(tid), _var_kind, tid);
632 
633  var->scalingFactor(scale_factor);
634  _vars[tid].add(var_name, var);
635  }
636  if (active_subdomains == nullptr)
637  _var_map[var_num] = std::set<SubdomainID>();
638  else
639  for (const auto subdomain_id : *active_subdomains)
640  _var_map[var_num].insert(subdomain_id);
641 }
virtual Assembly & assembly(THREAD_ID tid)=0
MooseVariableFE< Real > MooseVariable
Definition: Adaptivity.h:29
SubProblem & _subproblem
Definition: SystemBase.h:735
Moose::VarKindType _var_kind
default kind of variables in this system
Definition: SystemBase.h:771
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:747
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:745
MatType type
MooseVariableFE< VectorValue< Real > > VectorMooseVariable
Definition: Adaptivity.h:31
unsigned int THREAD_ID
Definition: MooseTypes.h:161
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 944 of file SystemBase.C.

947 {
948  _var_to_copy.push_back(VarCopyInfo(dest_name, source_name, timestep));
949 }
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:773
Information about variables that will be copied.
Definition: SystemBase.h:74

◆ addVariableToZeroOnJacobian()

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

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

Parameters
var_nameThe name of the variable to be zeroed.

Reimplemented in DisplacedSystem.

Definition at line 184 of file SystemBase.C.

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

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

◆ addVariableToZeroOnResidual()

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

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

Parameters
var_nameThe name of the variable to be zeroed.

Reimplemented in DisplacedSystem.

Definition at line 178 of file SystemBase.C.

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

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

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

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

543 {
544  if (hasVector(vector_name))
545  return getVector(vector_name);
546 
547  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
548  return vec;
549 }
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:701
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:751

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

553 {
554  if (!_subproblem.vectorTagExists(tag))
555  mooseError("Cannot add a tagged vector with vector_tag, ",
556  tag,
557  ", that tag does not exist in System ",
558  name());
559 
560  if (hasVector(tag))
561  return getVector(tag);
562 
563  auto vector_name = _subproblem.vectorTagName(tag);
564 
565  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
566 
567  if (_tagged_vectors.size() < tag + 1)
568  _tagged_vectors.resize(tag + 1);
569 
570  _tagged_vectors[tag] = &vec;
571 
572  return vec;
573 }
virtual TagName vectorTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:106
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:701
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
virtual const std::string & name() const
Definition: SystemBase.C:1088
SubProblem & _subproblem
Definition: SystemBase.h:735
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:112
virtual System & system()=0
Get the reference to the libMesh system.
MatType type
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:756
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:751

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

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

◆ assignMaxVarNDofsPerElem()

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

assign the maximum element dofs

Definition at line 454 of file SystemBase.h.

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

◆ assignMaxVarNDofsPerNode()

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

assign the maximum node dofs

Definition at line 459 of file SystemBase.h.

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

◆ associateMatrixToTag()

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

associate a matirx to a tag

Reimplemented in DisplacedSystem.

Definition at line 835 of file SystemBase.C.

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

836 {
837  mooseAssert(_subproblem.matrixTagExists(tag),
838  "Cannot associate Matrix with matrix_tag : " << tag << "that does not exist");
839 
840  if (_tagged_matrices.size() < tag + 1)
841  _tagged_matrices.resize(tag + 1);
842 
843  _tagged_matrices[tag] = &matrix;
844 }
std::vector< SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
Definition: SystemBase.h:758
virtual bool matrixTagExists(const TagName &tag_name)
Check to see if a particular Tag exists.
Definition: SubProblem.C:129
SubProblem & _subproblem
Definition: SystemBase.h:735

◆ associateVectorToTag()

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

Associate a vector for a given tag.

Reimplemented in DisplacedSystem.

Definition at line 773 of file SystemBase.C.

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

774 {
775  mooseAssert(_subproblem.vectorTagExists(tag),
776  "You can't associate a tag that does not exist " << tag);
777  if (_tagged_vectors.size() < tag + 1)
778  _tagged_vectors.resize(tag + 1);
779 
780  _tagged_vectors[tag] = &vec;
781 }
SubProblem & _subproblem
Definition: SystemBase.h:735
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:112
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:756

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

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

431 {
432  std::set<dof_id_type> & ghosted_elems = _subproblem.ghostedElems();
433 
434  DofMap & dof_map = dofMap();
435 
436  std::vector<dof_id_type> dof_indices;
437 
438  System & sys = system();
439 
440  unsigned int sys_num = sys.number();
441 
442  unsigned int n_vars = sys.n_vars();
443 
444  for (const auto & elem_id : ghosted_elems)
445  {
446  Elem * elem = _mesh.elemPtr(elem_id);
447 
448  if (elem->active())
449  {
450  dof_map.dof_indices(elem, dof_indices);
451 
452  // Only need to ghost it if it's actually not on this processor
453  for (const auto & dof : dof_indices)
454  if (dof < dof_map.first_dof() || dof >= dof_map.end_dof())
455  send_list.push_back(dof);
456 
457  // Now add the DoFs from all of the nodes. This is necessary because of block
458  // restricted variables. A variable might not live _on_ this element but it
459  // might live on nodes connected to this element.
460  for (unsigned int n = 0; n < elem->n_nodes(); n++)
461  {
462  Node * node = elem->node_ptr(n);
463 
464  // Have to get each variable's dofs
465  for (unsigned int v = 0; v < n_vars; v++)
466  {
467  const Variable & var = sys.variable(v);
468  unsigned int var_num = var.number();
469  unsigned int n_comp = var.n_components();
470 
471  // See if this variable has any dofs at this node
472  if (node->n_dofs(sys_num, var_num) > 0)
473  {
474  // Loop over components of the variable
475  for (unsigned int c = 0; c < n_comp; c++)
476  send_list.push_back(node->dof_number(sys_num, var_num, c));
477  }
478  }
479  }
480  }
481  }
482 }
virtual Elem * elemPtr(const dof_id_type i)
Definition: MooseMesh.C:2267
virtual DofMap & dofMap()
Gets writeable reference to the dof map.
Definition: SystemBase.C:932
DofMap & dof_map
SubProblem & _subproblem
Definition: SystemBase.h:735
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
Definition: SubProblem.h:561
virtual System & system()=0
Get the reference to the libMesh system.
MooseMesh & _mesh
Definition: SystemBase.h:740
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 2767 of file NonlinearSystemBase.C.

2770 {
2772  {
2774 
2775  std::map<dof_id_type, std::vector<dof_id_type>> graph;
2776 
2778 
2781  graph);
2782 
2783  const dof_id_type first_dof_on_proc = dofMap().first_dof(processor_id());
2784  const dof_id_type end_dof_on_proc = dofMap().end_dof(processor_id());
2785 
2786  // The total number of dofs on and off processor
2787  const dof_id_type n_dofs_on_proc = dofMap().n_local_dofs();
2788  const dof_id_type n_dofs_not_on_proc = dofMap().n_dofs() - dofMap().n_local_dofs();
2789 
2790  for (const auto & git : graph)
2791  {
2792  dof_id_type dof = git.first;
2793  dof_id_type local_dof = dof - first_dof_on_proc;
2794 
2795  if (dof < first_dof_on_proc || dof >= end_dof_on_proc)
2796  continue;
2797 
2798  const std::vector<dof_id_type> & row = git.second;
2799 
2800  SparsityPattern::Row & sparsity_row = sparsity[local_dof];
2801 
2802  unsigned int original_row_length = sparsity_row.size();
2803 
2804  sparsity_row.insert(sparsity_row.end(), row.begin(), row.end());
2805 
2806  SparsityPattern::sort_row(
2807  sparsity_row.begin(), sparsity_row.begin() + original_row_length, sparsity_row.end());
2808 
2809  // Fix up nonzero arrays
2810  for (const auto & coupled_dof : row)
2811  {
2812  if (coupled_dof < first_dof_on_proc || coupled_dof >= end_dof_on_proc)
2813  {
2814  if (n_oz[local_dof] < n_dofs_not_on_proc)
2815  n_oz[local_dof]++;
2816  }
2817  else
2818  {
2819  if (n_nz[local_dof] < n_dofs_on_proc)
2820  n_nz[local_dof]++;
2821  }
2822  }
2823  }
2824  }
2825 }
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 writeable reference to the dof map.
Definition: SystemBase.C:932
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:710

◆ checkKernelCoverage()

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

System Integrity Checks

Definition at line 2923 of file NonlinearSystemBase.C.

2924 {
2925  // Check kernel coverage of subdomains (blocks) in your mesh
2926  std::set<SubdomainID> input_subdomains;
2927  std::set<std::string> kernel_variables;
2928 
2929  bool global_kernels_exist = _kernels.hasActiveBlockObjects(Moose::ANY_BLOCK_ID);
2930  global_kernels_exist |= _scalar_kernels.hasActiveObjects();
2931  global_kernels_exist |= _nodal_kernels.hasActiveObjects();
2932 
2933  _kernels.subdomainsCovered(input_subdomains, kernel_variables);
2934  _nodal_kernels.subdomainsCovered(input_subdomains, kernel_variables);
2935  _scalar_kernels.subdomainsCovered(input_subdomains, kernel_variables);
2936  _constraints.subdomainsCovered(input_subdomains, kernel_variables);
2937 
2938  if (!global_kernels_exist)
2939  {
2940  std::set<SubdomainID> difference;
2941  std::set_difference(mesh_subdomains.begin(),
2942  mesh_subdomains.end(),
2943  input_subdomains.begin(),
2944  input_subdomains.end(),
2945  std::inserter(difference, difference.end()));
2946 
2947  if (!difference.empty())
2948  {
2949  std::stringstream missing_block_ids;
2950  std::copy(difference.begin(),
2951  difference.end(),
2952  std::ostream_iterator<unsigned int>(missing_block_ids, " "));
2953  mooseError("Each subdomain must contain at least one Kernel.\nThe following block(s) lack an "
2954  "active kernel: " +
2955  missing_block_ids.str());
2956  }
2957  }
2958 
2959  std::set<VariableName> variables(getVariableNames().begin(), getVariableNames().end());
2960 
2961  std::set<VariableName> difference;
2962  std::set_difference(variables.begin(),
2963  variables.end(),
2964  kernel_variables.begin(),
2965  kernel_variables.end(),
2966  std::inserter(difference, difference.end()));
2967 
2968  if (!difference.empty())
2969  {
2970  std::stringstream missing_kernel_vars;
2971  std::copy(difference.begin(),
2972  difference.end(),
2973  std::ostream_iterator<std::string>(missing_kernel_vars, " "));
2974  mooseError("Each variable must be referenced by at least one active Kernel.\nThe following "
2975  "variable(s) lack an active kernel: " +
2976  missing_kernel_vars.str());
2977  }
2978 }
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:207
MooseObjectTagWarehouse< ScalarKernel > _scalar_kernels
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Populates a set of covered subdomains and the associated variable names.
MooseObjectTagWarehouse< KernelBase > _kernels
ConstraintWarehouse _constraints
Constraints storage object.
MooseObjectTagWarehouse< NodalKernel > _nodal_kernels
NodalKernels for each thread.
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:15
bool hasActiveObjects(THREAD_ID tid=0) const
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:710
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 827 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

828 {
829  for (auto tag : tags)
830  if (hasMatrix(tag))
831  getMatrix(tag).close();
832 }
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:805
virtual SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:811

◆ closeTaggedVectors()

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

Close all vectors for given tags.

Definition at line 576 of file SystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTags().

577 {
578  for (auto & tag : tags)
579  {
580  mooseAssert(_subproblem.vectorTagExists(tag), "Tag: " << tag << " does not exsit");
581  getVector(tag).close();
582  }
583 }
SubProblem & _subproblem
Definition: SystemBase.h:735
virtual bool vectorTagExists(TagID tag)
Check to see if a particular Tag exists.
Definition: SubProblem.h:112
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector.
Definition: SystemBase.C:751

◆ 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 }
NumericVector< Number > & solutionOlder() override
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:1020
std::set< dof_id_type > _eigen_var_indices
NumericVector< Number > & solution() override
NumericVector< Number > & solutionOld() override

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

2660 {
2661  // Default to no damping
2662  Real damping = 1.0;
2663  bool has_active_dampers = false;
2664 
2666  {
2667  TIME_SECTION(_compute_dampers_timer);
2668 
2669  has_active_dampers = true;
2672  Threads::parallel_reduce(*_mesh.getActiveLocalElementRange(), cid);
2673  damping = std::min(cid.damping(), damping);
2674  }
2675 
2677  {
2678  TIME_SECTION(_compute_dampers_timer);
2679 
2680  has_active_dampers = true;
2683  Threads::parallel_reduce(*_mesh.getLocalNodeRange(), cndt);
2684  damping = std::min(cndt.damping(), damping);
2685  }
2686 
2688  {
2689  TIME_SECTION(_compute_dampers_timer);
2690 
2691  has_active_dampers = true;
2692  const auto & gdampers = _general_dampers.getActiveObjects();
2693  for (const auto & damper : gdampers)
2694  {
2695  Real gd_damping = damper->computeDamping(solution, update);
2696  try
2697  {
2698  damper->checkMinDamping(gd_damping);
2699  }
2700  catch (MooseException & e)
2701  {
2703  }
2704  damping = std::min(gd_damping, damping);
2705  }
2706  }
2707 
2708  _communicator.min(damping);
2709 
2710  if (has_active_dampers && damping < 1.0)
2711  _console << " Damping factor: " << damping << "\n";
2712 
2713  return damping;
2714 }
ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
Definition: MooseMesh.C:737
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:774
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:1020
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...
NumericVector< Number > & solution() override
Provides a way for users to bail out of the current solve.
MooseMesh & _mesh
Definition: SystemBase.h:740
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
NumericVector< Number > * _increment_vec
increment vector
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
MooseObjectWarehouse< GeneralDamper > _general_dampers
General Dampers.

◆ computeDiracContributions()

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

Definition at line 2717 of file NonlinearSystemBase.C.

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

2718 {
2720 
2721  std::set<const Elem *> dirac_elements;
2722 
2724  {
2725  TIME_SECTION(_compute_dirac_timer);
2726 
2727  // TODO: Need a threading fix... but it's complicated!
2728  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
2729  {
2730  const auto & dkernels = _dirac_kernels.getActiveObjects(tid);
2731  for (const auto & dkernel : dkernels)
2732  {
2733  dkernel->clearPoints();
2734  dkernel->addPoints();
2735  }
2736  }
2737 
2738  ComputeDiracThread cd(_fe_problem, tags, is_jacobian);
2739 
2740  _fe_problem.getDiracElements(dirac_elements);
2741 
2742  DistElemRange range(dirac_elements.begin(), dirac_elements.end(), 1);
2743  // TODO: Make Dirac work thread!
2744  // Threads::parallel_reduce(range, cd);
2745 
2746  cd(range);
2747  }
2748 }
virtual void getDiracElements(std::set< const Elem *> &elems) override
Fills "elems" with the elements that should be looped over for Dirac Kernels.
FEProblemBase & _fe_problem
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
virtual void clearDiracInfo() override
Gets called before Dirac Kernels are asked to add the points they are supposed to be evaluated in...
StoredRange< std::set< const Elem * >::const_iterator, const Elem * > DistElemRange
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectTagWarehouse< DiracKernel > _dirac_kernels
Dirac Kernel storage for each thread.
unsigned int THREAD_ID
Definition: MooseTypes.h:161

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

Referenced by NonlinearSystemBase::computeJacobian().

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

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

2477 {
2478  _nl_matrix_tags.clear();
2479 
2480  auto & tags = _fe_problem.getMatrixTags();
2481 
2482  for (auto & tag : tags)
2483  _nl_matrix_tags.insert(tag.second);
2484 
2485  computeJacobian(jacobian, _nl_matrix_tags);
2486 }
void computeJacobian(SparseMatrix< Number > &jacobian, const std::set< TagID > &tags)
Associate jacobian to systemMatrixTag, and then form a matrix for all the tags.
std::set< TagID > _nl_matrix_tags
Matrix tags to temporarily store all tags associated with the current system.
FEProblemBase & _fe_problem
virtual std::map< TagName, TagID > & getMatrixTags()
Return all matrix tags in the sytem, where a tag is represented by a map from name to ID...
Definition: SubProblem.h:162

◆ computeJacobianBlocks() [1/2]

void NonlinearSystemBase::computeJacobianBlocks ( std::vector< JacobianBlock *> &  blocks)
inherited

Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditioning matrices.

Used by Physics-based preconditioning

Parameters
blocksThe blocks to fill in (JacobianBlock is defined in ComputeJacobianBlocksThread)

Definition at line 2518 of file NonlinearSystemBase.C.

2519 {
2520  _nl_matrix_tags.clear();
2521 
2522  auto & tags = _fe_problem.getMatrixTags();
2523  for (auto & tag : tags)
2524  _nl_matrix_tags.insert(tag.second);
2525 
2527 }
void computeJacobianBlocks(std::vector< JacobianBlock *> &blocks)
Computes several Jacobian blocks simultaneously, summing their contributions into smaller preconditio...
std::set< TagID > _nl_matrix_tags
Matrix tags to temporarily store all tags associated with the current system.
FEProblemBase & _fe_problem
virtual std::map< TagName, TagID > & getMatrixTags()
Return all matrix tags in the sytem, where a tag is represented by a map from name to ID...
Definition: SubProblem.h:162

◆ computeJacobianBlocks() [2/2]

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

Definition at line 2530 of file NonlinearSystemBase.C.

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

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

Referenced by NonlinearSystemBase::computeJacobianTags().

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

◆ computeJacobianTags()

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

Computes multiple (tag associated) Jacobian matricese.

Definition at line 2499 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobian().

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

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

1475 {
1476  _nl_vector_tags.clear();
1477 
1478  auto & tags = _fe_problem.getVectorTags();
1479  for (auto & tag : tags)
1480  _nl_vector_tags.insert(tag.second);
1481 
1483  computeNodalBCs(residual, _nl_vector_tags);
1485 }
virtual std::map< TagName, TagID > & getVectorTags()
Return all vector tags, where a tag is represented by a map from name to ID.
Definition: SubProblem.h:107
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:784
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:773
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 1488 of file NonlinearSystemBase.C.

1489 {
1491 
1492  computeNodalBCs(tags);
1493 
1495 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:784
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:773
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 1498 of file NonlinearSystemBase.C.

1499 {
1500  // We need to close the diag_save_in variables on the aux system before NodalBCBases clear the
1501  // dofs on boundary nodes
1502  if (_has_save_in)
1504 
1505  PARALLEL_TRY
1506  {
1507  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
1508 
1509  if (!bnd_nodes.empty())
1510  {
1511  TIME_SECTION(_nodal_bcs_timer);
1512 
1513  MooseObjectWarehouse<NodalBCBase> * nbc_warehouse;
1514 
1515  // Select nodal kernels
1516  if (tags.size() == _fe_problem.numVectorTags() || !tags.size())
1517  nbc_warehouse = &_nodal_bcs;
1518  else if (tags.size() == 1)
1519  nbc_warehouse = &(_nodal_bcs.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1520  else
1521  nbc_warehouse = &(_nodal_bcs.getVectorTagsObjectWarehouse(tags, 0));
1522 
1523  for (const auto & bnode : bnd_nodes)
1524  {
1525  BoundaryID boundary_id = bnode->_bnd_id;
1526  Node * node = bnode->_node;
1527 
1528  if (node->processor_id() == processor_id())
1529  {
1530  // reinit variables in nodes
1531  _fe_problem.reinitNodeFace(node, boundary_id, 0);
1532  if (nbc_warehouse->hasActiveBoundaryObjects(boundary_id))
1533  {
1534  const auto & bcs = nbc_warehouse->getActiveBoundaryObjects(boundary_id);
1535  for (const auto & nbc : bcs)
1536  if (nbc->shouldApply())
1537  nbc->computeResidual();
1538  }
1539  }
1540  }
1541  }
1542  }
1543  PARALLEL_CATCH;
1544 
1545  if (_Re_time)
1546  _Re_time->close();
1547  _Re_non_time->close();
1548 }
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...
bool _has_save_in
If there is any Kernel or IntegratedBC having save_in.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
FEProblemBase & _fe_problem
boundary_id_type BoundaryID
NumericVector< Number > & solution() override
AuxiliarySystem & getAuxiliarySystem()
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid) override
virtual unsigned int numVectorTags() const
The total number of tags.
Definition: SubProblem.h:122
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
MooseMesh & _mesh
Definition: SystemBase.h:740
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:1258
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > * getBoundaryNodeRange()
Definition: MooseMesh.C:788

◆ computeResidual()

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

Form a residual vector for a given tag.

Definition at line 633 of file NonlinearSystemBase.C.

634 {
635  mooseDeprecated(" Please use computeResidualTag");
636 
637  computeResidualTag(residual, tag_id);
638 }
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:236
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 1294 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTags().

1295 {
1296  TIME_SECTION(_compute_residual_internal_timer);
1297 
1298  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1299  {
1300  _kernels.residualSetup(tid);
1303  if (_doing_dg)
1309  }
1314 
1315  // reinit scalar variables
1316  for (unsigned int tid = 0; tid < libMesh::n_threads(); tid++)
1318 
1319  // residual contributions from the domain
1320  PARALLEL_TRY
1321  {
1322  TIME_SECTION(_kernels_timer);
1323 
1324  ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
1325 
1327 
1328  Threads::parallel_reduce(elem_range, cr);
1329 
1330  unsigned int n_threads = libMesh::n_threads();
1331  for (unsigned int i = 0; i < n_threads;
1332  i++) // Add any cached residuals that might be hanging around
1334  }
1335  PARALLEL_CATCH;
1336 
1337  // residual contributions from the scalar kernels
1338  PARALLEL_TRY
1339  {
1340  // do scalar kernels (not sure how to thread this)
1342  {
1343  TIME_SECTION(_scalar_kernels_timer);
1344 
1345  MooseObjectWarehouse<ScalarKernel> * scalar_kernel_warehouse;
1346  // This code should be refactored once we can do tags for scalar
1347  // kernels
1348  // Should redo this based on Warehouse
1349  if (!tags.size() || tags.size() == _fe_problem.numVectorTags())
1350  scalar_kernel_warehouse = &_scalar_kernels;
1351  else if (tags.size() == 1)
1352  scalar_kernel_warehouse =
1353  &(_scalar_kernels.getVectorTagObjectWarehouse(*(tags.begin()), 0));
1354  else
1355  // scalar_kernels is not threading
1356  scalar_kernel_warehouse = &(_scalar_kernels.getVectorTagsObjectWarehouse(tags, 0));
1357 
1358  bool have_scalar_contributions = false;
1359  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
1360  for (const auto & scalar_kernel : scalars)
1361  {
1362  scalar_kernel->reinit();
1363  const std::vector<dof_id_type> & dof_indices = scalar_kernel->variable().dofIndices();
1364  const DofMap & dof_map = scalar_kernel->variable().dofMap();
1365  const dof_id_type first_dof = dof_map.first_dof();
1366  const dof_id_type end_dof = dof_map.end_dof();
1367  for (dof_id_type dof : dof_indices)
1368  {
1369  if (dof >= first_dof && dof < end_dof)
1370  {
1371  scalar_kernel->computeResidual();
1372  have_scalar_contributions = true;
1373  break;
1374  }
1375  }
1376  }
1377  if (have_scalar_contributions)
1379  }
1380  }
1381  PARALLEL_CATCH;
1382 
1383  // residual contributions from Block NodalKernels
1384  PARALLEL_TRY
1385  {
1387  {
1388  TIME_SECTION(_nodal_kernels_timer);
1389 
1391 
1392  ConstNodeRange & range = *_mesh.getLocalNodeRange();
1393 
1394  if (range.begin() != range.end())
1395  {
1396  _fe_problem.reinitNode(*range.begin(), 0);
1397 
1398  Threads::parallel_reduce(range, cnk);
1399 
1400  unsigned int n_threads = libMesh::n_threads();
1401  for (unsigned int i = 0; i < n_threads;
1402  i++) // Add any cached residuals that might be hanging around
1404  }
1405  }
1406  }
1407  PARALLEL_CATCH;
1408 
1409  // residual contributions from boundary NodalKernels
1410  PARALLEL_TRY
1411  {
1413  {
1414  TIME_SECTION(_nodal_kernel_bcs_timer);
1415 
1417 
1418  ConstBndNodeRange & bnd_node_range = *_mesh.getBoundaryNodeRange();
1419 
1420  Threads::parallel_reduce(bnd_node_range, cnk);
1421 
1422  unsigned int n_threads = libMesh::n_threads();
1423  for (unsigned int i = 0; i < n_threads;
1424  i++) // Add any cached residuals that might be hanging around
1426  }
1427  }
1428  PARALLEL_CATCH;
1429 
1430  if (_need_residual_copy)
1431  {
1432  _Re_non_time->close();
1433  _Re_non_time->localize(_residual_copy);
1434  }
1435 
1437  {
1438  _Re_non_time->close();
1440  _residual_ghosted->close();
1441  }
1442 
1443  PARALLEL_TRY { computeDiracContributions(tags, false); }
1444  PARALLEL_CATCH;
1445 
1447  {
1448  PARALLEL_TRY { enforceNodalConstraintsResidual(*_Re_non_time); }
1449  PARALLEL_CATCH;
1450  _Re_non_time->close();
1451  }
1452 
1453  // Add in Residual contributions from Constraints
1455  {
1456  PARALLEL_TRY
1457  {
1458  // Undisplaced Constraints
1460 
1461  // Displaced Constraints
1464 
1467  }
1468  PARALLEL_CATCH;
1469  _Re_non_time->close();
1470  }
1471 }
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:737
bool hasActiveBlockObjects(THREAD_ID tid=0) const
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
MooseObjectTagWarehouse< DGKernelBase > _dg_kernels
MooseObjectTagWarehouse< InterfaceKernel > _interface_kernels
MooseObjectTagWarehouse< NodalBCBase > _nodal_bcs
MooseObjectWarehouse< T > & getVectorTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object at least has one of the given vector ta...
MooseObjectWarehouse< NodalDamper > _nodal_dampers
Nodal Dampers for each thread.
bool computingNonlinearResid() const
Check whether residual being evaulated is non-linear.
Definition: SubProblem.h:577
ConstNodeRange * getLocalNodeRange()
Definition: MooseMesh.C:774
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
virtual unsigned int numVectorTags() const
The total number of tags.
Definition: SubProblem.h:122
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:740
bool _need_residual_copy
Whether or not a copy of the residual needs to be made.
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< ElementDamper > _element_dampers
Element Dampers for each thread.
NumericVector< Number > * _residual_ghosted
ghosted form of the residual
MooseObjectWarehouse< T > & getVectorTagObjectWarehouse(TagID tag_id, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has the given vector tag...
bool _has_constraints
Whether or not this system has any Constraints.
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
Definition: MooseMesh.h:1258
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:788
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:161

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

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

619 {
620 
621  _nl_vector_tags.clear();
622  _nl_vector_tags.insert(tag_id);
624 
626 
628 
630 }
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition: SystemBase.C:784
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:773
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 641 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualTag().

642 {
643  TIME_SECTION(_compute_residual_tags_timer);
644 
645  bool required_residual = tags.find(residualVectorTag()) == tags.end() ? false : true;
646 
648 
649  // not suppose to do anythin on matrix
651 
653 
654  for (const auto & numeric_vec : _vecs_to_zero_for_residual)
655  if (hasVector(numeric_vec))
656  {
657  NumericVector<Number> & vec = getVector(numeric_vec);
658  vec.close();
659  vec.zero();
660  }
661 
662  try
663  {
664  zeroTaggedVectors(tags);
666  closeTaggedVectors(tags);
667 
668  if (required_residual)
669  {
670  auto & residual = getVector(residualVectorTag());
671  if (_time_integrator)
672  _time_integrator->postResidual(residual);
673  else
674  residual += *_Re_non_time;
675  residual.close();
676  }
677  computeNodalBCs(tags);
678  closeTaggedVectors(tags);
679 
680  // If we are debugging residuals we need one more assignment to have the ghosted copy up to
681  // date
682  if (_need_residual_ghosted && _debugging_residuals && required_residual)
683  {
684  auto & residual = getVector(residualVectorTag());
685 
686  *_residual_ghosted = residual;
687  _residual_ghosted->close();
688  }
689  // Need to close and update the aux system in case residuals were saved to it.
692  if (hasSaveIn())
694  }
695  catch (MooseException & e)
696  {
697  // The buck stops here, we have already handled the exception by
698  // calling stopSolve(), it is now up to PETSc to return a
699  // "diverged" reason during the next solve.
700  }
701 
702  // not supposed to do anything on matrix
704 }
virtual void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition: SystemBase.C:586
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:701
bool _debugging_residuals
true if debugging residuals
NumericVector< Number > * _Re_non_time
residual vector for non-time contributions
bool _has_nodalbc_save_in
If there is a nodal BC having save_in.
Scope guard for starting and stopping Floating Point Exception Trapping.
virtual void update()
Update the system (doing libMesh magic)
Definition: SystemBase.C:1020
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:886
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
NumericVector< Number > & solution() override
virtual void activeAllMatrixTags()
Make all exsiting matrices ative.
Definition: SystemBase.C:897
AuxiliarySystem & getAuxiliarySystem()
virtual void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition: SystemBase.C:576
void computeResidualInternal(const std::set< TagID > &tags)
Compute the residual for a given tag.
MooseApp & _app
Definition: SystemBase.h:737
Provides a way for users to bail out of the current solve.
unsigned int _n_residual_evaluations
Total number of residual evaluations that have been performed.
bool hasSaveIn() const
Weather or not the nonlinear system has save-ins.
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:782
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:751

◆ computeScalarKernelsJacobians()

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

Definition at line 2134 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeJacobianInternal().

2135 {
2136  MooseObjectWarehouse<ScalarKernel> * scalar_kernel_warehouse;
2137 
2138  if (!tags.size() || tags.size() == _fe_problem.numMatrixTags())
2139  scalar_kernel_warehouse = &_scalar_kernels;
2140  else if (tags.size() == 1)
2141  scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagObjectWarehouse(*(tags.begin()), 0));
2142  else
2143  scalar_kernel_warehouse = &(_scalar_kernels.getMatrixTagsObjectWarehouse(tags, 0));
2144 
2145  // Compute the diagonal block for scalar variables
2146  if (scalar_kernel_warehouse->hasActiveObjects())
2147  {
2148  const auto & scalars = scalar_kernel_warehouse->getActiveObjects();
2149 
2150  _fe_problem.reinitScalars(/*tid=*/0);
2151 
2152  bool have_scalar_contributions = false;
2153  for (const auto & kernel : scalars)
2154  {
2155  kernel->reinit();
2156  const std::vector<dof_id_type> & dof_indices = kernel->variable().dofIndices();
2157  const DofMap & dof_map = kernel->variable().dofMap();
2158  const dof_id_type first_dof = dof_map.first_dof();
2159  const dof_id_type end_dof = dof_map.end_dof();
2160  for (dof_id_type dof : dof_indices)
2161  {
2162  if (dof >= first_dof && dof < end_dof)
2163  {
2164  kernel->computeJacobian();
2165  _fe_problem.addJacobianOffDiagScalar(kernel->variable().number());
2166  have_scalar_contributions = true;
2167  break;
2168  }
2169  }
2170  }
2171 
2172  if (have_scalar_contributions)
2174  }
2175 }
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 unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:157
virtual void addJacobianScalar(THREAD_ID tid=0)
virtual void reinitScalars(THREAD_ID tid) override
bool hasActiveObjects(THREAD_ID tid=0) const
MooseObjectWarehouse< T > & getMatrixTagsObjectWarehouse(const std::set< TagID > &tags, THREAD_ID tid)
Retrieve a moose object warehouse in which every moose object has one of the given matrix tags...

◆ computeTimeDerivatives()

void NonlinearSystemBase::computeTimeDerivatives ( )
inherited

Computes the time derivative vector.

Definition at line 820 of file NonlinearSystemBase.C.

821 {
822  if (_time_integrator)
823  {
824  _time_integrator->preStep();
825  _time_integrator->computeTimeDerivatives();
826  }
827 }
std::shared_ptr< TimeIntegrator > _time_integrator
Time integrator.
Definition: SystemBase.h:782

◆ computeVariables()

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

Definition at line 712 of file SystemBase.h.

712 {}

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

Referenced by NonlinearSystemBase::computeJacobianInternal().

1699 {
1700  if (!hasMatrix(systemMatrixTag()))
1701  mooseError("A system matrix is required");
1702 
1703  auto & jacobian = getMatrix(systemMatrixTag());
1704 
1705 #if PETSC_VERSION_LESS_THAN(3, 3, 0)
1706 #else
1708  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
1709  MAT_NEW_NONZERO_ALLOCATION_ERR,
1710  PETSC_FALSE);
1712  MatSetOption(
1713  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE);
1714 #endif
1715 
1716  std::vector<numeric_index_type> zero_rows;
1717  std::map<std::pair<unsigned int, unsigned int>, PenetrationLocator *> * penetration_locators =
1718  NULL;
1719 
1720  if (!displaced)
1721  {
1722  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
1723  penetration_locators = &geom_search_data._penetration_locators;
1724  }
1725  else
1726  {
1727  GeometricSearchData & displaced_geom_search_data =
1728  _fe_problem.getDisplacedProblem()->geomSearchData();
1729  penetration_locators = &displaced_geom_search_data._penetration_locators;
1730  }
1731 
1732  bool constraints_applied;
1734  constraints_applied = false;
1735  for (const auto & it : *penetration_locators)
1736  {
1738  {
1739  // Reset the constraint_applied flag before each new constraint, as they need to be
1740  // assembled separately
1741  constraints_applied = false;
1742  }
1743  PenetrationLocator & pen_loc = *(it.second);
1744 
1745  std::vector<dof_id_type> & slave_nodes = pen_loc._nearest_node._slave_nodes;
1746 
1747  BoundaryID slave_boundary = pen_loc._slave_boundary;
1748 
1749  zero_rows.clear();
1750  if (_constraints.hasActiveNodeFaceConstraints(slave_boundary, displaced))
1751  {
1752  const auto & constraints =
1753  _constraints.getActiveNodeFaceConstraints(slave_boundary, displaced);
1754 
1755  for (const auto & slave_node_num : slave_nodes)
1756  {
1757  Node & slave_node = _mesh.nodeRef(slave_node_num);
1758 
1759  if (slave_node.processor_id() == processor_id())
1760  {
1761  if (pen_loc._penetration_info[slave_node_num])
1762  {
1763  PenetrationInfo & info = *pen_loc._penetration_info[slave_node_num];
1764 
1765  const Elem * master_elem = info._elem;
1766  unsigned int master_side = info._side_num;
1767 
1768  // reinit variables at the node
1769  _fe_problem.reinitNodeFace(&slave_node, slave_boundary, 0);
1770 
1773 
1774  std::vector<Point> points;
1775  points.push_back(info._closest_point);
1776 
1777  // reinit variables on the master element's face at the contact point
1778  _fe_problem.setNeighborSubdomainID(master_elem, 0);
1779  _fe_problem.reinitNeighborPhys(master_elem, master_side, points, 0);
1780  for (const auto & nfc : constraints)
1781  {
1782  nfc->_jacobian = &jacobian;
1783 
1784  if (nfc->shouldApply())
1785  {
1786  constraints_applied = true;
1787 
1788  nfc->subProblem().prepareShapes(nfc->variable().number(), 0);
1789  nfc->subProblem().prepareNeighborShapes(nfc->variable().number(), 0);
1790 
1791  nfc->computeJacobian();
1792 
1793  if (nfc->overwriteSlaveJacobian())
1794  {
1795  // Add this variable's dof's row to be zeroed
1796  zero_rows.push_back(nfc->variable().nodalDofIndex());
1797  }
1798 
1799  std::vector<dof_id_type> slave_dofs(1, nfc->variable().nodalDofIndex());
1800 
1801  // Cache the jacobian block for the slave side
1803  slave_dofs,
1804  nfc->_connected_dof_indices,
1805  nfc->variable().scalingFactor());
1806 
1807  // Cache the jacobian block for the master side
1808  if (nfc->addCouplingEntriesToJacobian())
1810  nfc->_Kne,
1811  nfc->masterVariable().dofIndicesNeighbor(),
1812  nfc->_connected_dof_indices,
1813  nfc->variable().scalingFactor());
1814 
1816  if (nfc->addCouplingEntriesToJacobian())
1818 
1819  // Do the off-diagonals next
1820  const std::vector<MooseVariableFEBase *> coupled_vars = nfc->getCoupledMooseVars();
1821  for (const auto & jvar : coupled_vars)
1822  {
1823  // Only compute jacobians for nonlinear variables
1824  if (jvar->kind() != Moose::VAR_NONLINEAR)
1825  continue;
1826 
1827  // Only compute Jacobian entries if this coupling is being used by the
1828  // preconditioner
1829  if (nfc->variable().number() == jvar->number() ||
1830  !_fe_problem.areCoupled(nfc->variable().number(), jvar->number()))
1831  continue;
1832 
1833  // Need to zero out the matrices first
1835 
1836  nfc->subProblem().prepareShapes(nfc->variable().number(), 0);
1837  nfc->subProblem().prepareNeighborShapes(jvar->number(), 0);
1838 
1839  nfc->computeOffDiagJacobian(jvar->number());
1840 
1841  // Cache the jacobian block for the slave side
1843  slave_dofs,
1844  nfc->_connected_dof_indices,
1845  nfc->variable().scalingFactor());
1846 
1847  // Cache the jacobian block for the master side
1848  if (nfc->addCouplingEntriesToJacobian())
1850  nfc->variable().dofIndicesNeighbor(),
1851  nfc->_connected_dof_indices,
1852  nfc->variable().scalingFactor());
1853 
1855  if (nfc->addCouplingEntriesToJacobian())
1857  }
1858  }
1859  }
1860  }
1861  }
1862  }
1863  }
1865  {
1866  // See if constraints were applied anywhere
1867  _communicator.max(constraints_applied);
1868 
1869  if (constraints_applied)
1870  {
1871 #ifdef LIBMESH_HAVE_PETSC
1872 // Necessary for speed
1873 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
1874  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
1875 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
1876  // In Petsc 3.0.0, MatSetOption has three args...the third arg
1877  // determines whether the option is set (true) or unset (false)
1878  MatSetOption(
1879  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
1880 #else
1881  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
1882  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
1883  PETSC_TRUE);
1884 #endif
1885 #endif
1886 
1887  jacobian.close();
1888  jacobian.zero_rows(zero_rows, 0.0);
1889  jacobian.close();
1891  jacobian.close();
1892  }
1893  }
1894  }
1896  {
1897  // See if constraints were applied anywhere
1898  _communicator.max(constraints_applied);
1899 
1900  if (constraints_applied)
1901  {
1902 #ifdef LIBMESH_HAVE_PETSC
1903 // Necessary for speed
1904 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
1905  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
1906 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
1907  // In Petsc 3.0.0, MatSetOption has three args...the third arg
1908  // determines whether the option is set (true) or unset (false)
1909  MatSetOption(
1910  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
1911 #else
1912  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
1913  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
1914  PETSC_TRUE);
1915 #endif
1916 #endif
1917 
1918  jacobian.close();
1919  jacobian.zero_rows(zero_rows, 0.0);
1920  jacobian.close();
1922  jacobian.close();
1923  }
1924  }
1925 
1926  mortarJacobianConstraints(displaced);
1927 
1928  THREAD_ID tid = 0;
1929  // go over element-element constraint interface
1930  std::map<unsigned int, std::shared_ptr<ElementPairLocator>> * element_pair_locators = nullptr;
1931 
1932  if (!displaced)
1933  {
1934  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
1935  element_pair_locators = &geom_search_data._element_pair_locators;
1936  }
1937  else
1938  {
1939  GeometricSearchData & displaced_geom_search_data =
1940  _fe_problem.getDisplacedProblem()->geomSearchData();
1941  element_pair_locators = &displaced_geom_search_data._element_pair_locators;
1942  }
1943 
1944  for (const auto & it : *element_pair_locators)
1945  {
1946  ElementPairLocator & elem_pair_loc = *(it.second);
1947 
1948  if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
1949  {
1950  // ElemElemConstraint objects
1951  const auto & _element_constraints =
1952  _constraints.getActiveElemElemConstraints(it.first, displaced);
1953 
1954  // go over pair elements
1955  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
1956  elem_pair_loc.getElemPairs();
1957  for (const auto & pr : elem_pairs)
1958  {
1959  const Elem * elem1 = pr.first;
1960  const Elem * elem2 = pr.second;
1961 
1962  if (elem1->processor_id() != processor_id())
1963  continue;
1964 
1965  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
1966 
1967  // for each element process constraints on the
1968  for (const auto & ec : _element_constraints)
1969  {
1970  _fe_problem.setCurrentSubdomainID(elem1, tid);
1972  _fe_problem.setNeighborSubdomainID(elem2, tid);
1974 
1975  ec->subProblem().prepareShapes(ec->variable().number(), tid);
1976  ec->subProblem().prepareNeighborShapes(ec->variable().number(), tid);
1977 
1978  ec->reinit(info);
1979  ec->computeJacobian();
1982  }
1984  }
1985  }
1986  }
1987 
1988  // go over NodeELemConstraints
1989  std::set<dof_id_type> unique_slave_node_ids;
1990  constraints_applied = false;
1991  for (const auto & slave_id : _mesh.meshSubdomains())
1992  {
1993  for (const auto & master_id : _mesh.meshSubdomains())
1994  {
1995  if (_constraints.hasActiveNodeElemConstraints(slave_id, master_id, displaced))
1996  {
1997  const auto & constraints =
1998  _constraints.getActiveNodeElemConstraints(slave_id, master_id, displaced);
1999 
2000  // get unique set of ids of all nodes on current block
2001  unique_slave_node_ids.clear();
2002  const MeshBase & meshhelper = _mesh.getMesh();
2003  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(slave_id),
2004  meshhelper.active_subdomain_elements_end(slave_id)))
2005  {
2006  for (auto & n : elem->node_ref_range())
2007  unique_slave_node_ids.insert(n.id());
2008  }
2009 
2010  for (auto slave_node_id : unique_slave_node_ids)
2011  {
2012  const Node & slave_node = _mesh.nodeRef(slave_node_id);
2013  // check if slave node is on current processor
2014  if (slave_node.processor_id() == processor_id())
2015  {
2016  // This reinits the variables that exist on the slave node
2017  _fe_problem.reinitNodeFace(&slave_node, slave_id, 0);
2018 
2019  // This will set aside residual and jacobian space for the variables that have dofs
2020  // on the slave node
2023 
2024  for (const auto & nec : constraints)
2025  {
2026  if (nec->shouldApply())
2027  {
2028  constraints_applied = true;
2029 
2030  nec->_jacobian = &jacobian;
2031  nec->subProblem().prepareShapes(nec->variable().number(), 0);
2032  nec->subProblem().prepareNeighborShapes(nec->variable().number(), 0);
2033 
2034  nec->computeJacobian();
2035 
2036  if (nec->overwriteSlaveJacobian())
2037  {
2038  // Add this variable's dof's row to be zeroed
2039  zero_rows.push_back(nec->variable().nodalDofIndex());
2040  }
2041 
2042  std::vector<dof_id_type> slave_dofs(1, nec->variable().nodalDofIndex());
2043 
2044  // Cache the jacobian block for the slave side
2046  slave_dofs,
2047  nec->_connected_dof_indices,
2048  nec->variable().scalingFactor());
2049 
2050  // Cache the jacobian block for the master side
2052  nec->_Kne,
2053  nec->masterVariable().dofIndicesNeighbor(),
2054  nec->_connected_dof_indices,
2055  nec->variable().scalingFactor());
2056 
2059 
2060  // Do the off-diagonals next
2061  const std::vector<MooseVariableFEBase *> coupled_vars = nec->getCoupledMooseVars();
2062  for (const auto & jvar : coupled_vars)
2063  {
2064  // Only compute jacobians for nonlinear variables
2065  if (jvar->kind() != Moose::VAR_NONLINEAR)
2066  continue;
2067 
2068  // Only compute Jacobian entries if this coupling is being used by the
2069  // preconditioner
2070  if (nec->variable().number() == jvar->number() ||
2071  !_fe_problem.areCoupled(nec->variable().number(), jvar->number()))
2072  continue;
2073 
2074  // Need to zero out the matrices first
2076 
2077  nec->subProblem().prepareShapes(nec->variable().number(), 0);
2078  nec->subProblem().prepareNeighborShapes(jvar->number(), 0);
2079 
2080  nec->computeOffDiagJacobian(jvar->number());
2081 
2082  // Cache the jacobian block for the slave side
2084  slave_dofs,
2085  nec->_connected_dof_indices,
2086  nec->variable().scalingFactor());
2087 
2088  // Cache the jacobian block for the master side
2090  nec->variable().dofIndicesNeighbor(),
2091  nec->_connected_dof_indices,
2092  nec->variable().scalingFactor());
2093 
2096  }
2097  }
2098  }
2099  }
2100  }
2101  }
2102  }
2103  }
2104  // See if constraints were applied anywhere
2105  _communicator.max(constraints_applied);
2106 
2107  if (constraints_applied)
2108  {
2109 #ifdef LIBMESH_HAVE_PETSC
2110 // Necessary for speed
2111 #if PETSC_VERSION_LESS_THAN(3, 0, 0)
2112  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS);
2113 #elif PETSC_VERSION_LESS_THAN(3, 1, 0)
2114  // In Petsc 3.0.0, MatSetOption has three args...the third arg
2115  // determines whether the option is set (true) or unset (false)
2116  MatSetOption(
2117  static_cast<PetscMatrix<Number> &>(jacobian).mat(), MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
2118 #else
2119  MatSetOption(static_cast<PetscMatrix<Number> &>(jacobian).mat(),
2120  MAT_KEEP_NONZERO_PATTERN, // This is changed in 3.1
2121  PETSC_TRUE);
2122 #endif
2123 #endif
2124 
2125  jacobian.close();
2126  jacobian.zero_rows(zero_rows, 0.0);
2127  jacobian.close();
2129  jacobian.close();
2130  }
2131 }
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.C:805
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:207
Data structure used to hold penetration information.
Assembly & assembly(THREAD_ID tid) override
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
const ElementPairInfo & getElemPairInfo(std::pair< const Elem *, const Elem *> elem_pair) const
std::map< dof_id_type, PenetrationInfo * > & _penetration_info
Data structure of nodes and their associated penetration information.
virtual const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:436
virtual TagID systemMatrixTag() override
Return the Matrix Tag ID for System.
virtual GeometricSearchData & geomSearchData() override
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
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:2567
std::vector< Point > _elem1_constraint_q_point
const ElementPairList & getElemPairs() const
const Elem * _elem
virtual void cacheJacobian(THREAD_ID tid) override
boundary_id_type BoundaryID
void mortarJacobianConstraints(bool displaced)
Do mortar constraint jacobian computation.
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
void cacheJacobianBlock(DenseMatrix< Number > &jac_block, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices, Real scaling_factor, TagID tag=0)
Definition: Assembly.C:3003
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:740
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:811
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:161
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:2316
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 1015 of file NonlinearSystemBase.C.

Referenced by NonlinearSystemBase::computeResidualInternal().

1016 {
1017  // Make sure the residual is in a good state
1018  residual.close();
1019 
1020  std::map<std::pair<unsigned int, unsigned int>, PenetrationLocator *> * penetration_locators =
1021  NULL;
1022 
1023  if (!displaced)
1024  {
1025  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
1026  penetration_locators = &geom_search_data._penetration_locators;
1027  }
1028  else
1029  {
1030  GeometricSearchData & displaced_geom_search_data =
1031  _fe_problem.getDisplacedProblem()->geomSearchData();
1032  penetration_locators = &displaced_geom_search_data._penetration_locators;
1033  }
1034 
1035  bool constraints_applied;
1036  bool residual_has_inserted_values = false;
1038  constraints_applied = false;
1039  for (const auto & it : *penetration_locators)
1040  {
1042  {
1043  // Reset the constraint_applied flag before each new constraint, as they need to be
1044  // assembled separately
1045  constraints_applied = false;
1046  }
1047  PenetrationLocator & pen_loc = *(it.second);
1048 
1049  std::vector<dof_id_type> & slave_nodes = pen_loc._nearest_node._slave_nodes;
1050 
1051  BoundaryID slave_boundary = pen_loc._slave_boundary;
1052 
1053  if (_constraints.hasActiveNodeFaceConstraints(slave_boundary, displaced))
1054  {
1055  const auto & constraints =
1056  _constraints.getActiveNodeFaceConstraints(slave_boundary, displaced);
1057 
1058  for (unsigned int i = 0; i < slave_nodes.size(); i++)
1059  {
1060  dof_id_type slave_node_num = slave_nodes[i];
1061  Node & slave_node = _mesh.nodeRef(slave_node_num);
1062 
1063  if (slave_node.processor_id() == processor_id())
1064  {
1065  if (pen_loc._penetration_info[slave_node_num])
1066  {
1067  PenetrationInfo & info = *pen_loc._penetration_info[slave_node_num];
1068 
1069  const Elem * master_elem = info._elem;
1070  unsigned int master_side = info._side_num;
1071 
1072  // *These next steps MUST be done in this order!*
1073 
1074  // This reinits the variables that exist on the slave node
1075  _fe_problem.reinitNodeFace(&slave_node, slave_boundary, 0);
1076 
1077  // This will set aside residual and jacobian space for the variables that have dofs on
1078  // the slave node
1080 
1081  std::vector<Point> points;
1082  points.push_back(info._closest_point);
1083 
1084  // reinit variables on the master element's face at the contact point
1085  _fe_problem.setNeighborSubdomainID(master_elem, 0);
1086  _fe_problem.reinitNeighborPhys(master_elem, master_side, points, 0);
1087 
1088  for (const auto & nfc : constraints)
1089  if (nfc->shouldApply())
1090  {
1091  constraints_applied = true;
1092  nfc->computeResidual();
1093 
1094  if (nfc->overwriteSlaveResidual())
1095  {
1096  _fe_problem.setResidual(residual, 0);
1097  residual_has_inserted_values = true;
1098  }
1099  else
1102  }
1103  }
1104  }
1105  }
1106  }
1108  {
1109  // Make sure that slave contribution to master are assembled, and ghosts have been
1110  // exchanged, as current masters might become slaves on next iteration and will need to
1111  // contribute their former slaves' contributions to the future masters. See if constraints
1112  // were applied anywhere
1113  _communicator.max(constraints_applied);
1114 
1115  if (constraints_applied)
1116  {
1117  // If any of the above constraints inserted values in the residual, it needs to be
1118  // assembled before adding the cached residuals below.
1119  _communicator.max(residual_has_inserted_values);
1120  if (residual_has_inserted_values)
1121  {
1122  residual.close();
1123  residual_has_inserted_values = false;
1124  }
1126  residual.close();
1127 
1129  *_residual_ghosted = residual;
1130  }
1131  }
1132  }
1134  {
1135  _communicator.max(constraints_applied);
1136 
1137  if (constraints_applied)
1138  {
1139  // If any of the above constraints inserted values in the residual, it needs to be assembled
1140  // before adding the cached residuals below.
1141  _communicator.max(residual_has_inserted_values);
1142  if (residual_has_inserted_values)
1143  residual.close();
1144 
1146  residual.close();
1147 
1149  *_residual_ghosted = residual;
1150  }
1151  }
1152 
1153  mortarResidualConstraints(displaced);
1154 
1155  // go over element-element constraint interface
1156  std::map<unsigned int, std::shared_ptr<ElementPairLocator>> * element_pair_locators = nullptr;
1157 
1158  if (!displaced)
1159  {
1160  GeometricSearchData & geom_search_data = _fe_problem.geomSearchData();
1161  element_pair_locators = &geom_search_data._element_pair_locators;
1162  }
1163  else
1164  {
1165  GeometricSearchData & displaced_geom_search_data =
1166  _fe_problem.getDisplacedProblem()->geomSearchData();
1167  element_pair_locators = &displaced_geom_search_data._element_pair_locators;
1168  }
1169 
1170  THREAD_ID tid = 0;
1171  for (const auto & it : *element_pair_locators)
1172  {
1173  ElementPairLocator & elem_pair_loc = *(it.second);
1174 
1175  if (_constraints.hasActiveElemElemConstraints(it.first, displaced))
1176  {
1177  // ElemElemConstraint objects
1178  const auto & _element_constraints =
1179  _constraints.getActiveElemElemConstraints(it.first, displaced);
1180 
1181  // go over pair elements
1182  const std::list<std::pair<const Elem *, const Elem *>> & elem_pairs =
1183  elem_pair_loc.getElemPairs();
1184  for (const auto & pr : elem_pairs)
1185  {
1186  const Elem * elem1 = pr.first;
1187  const Elem * elem2 = pr.second;
1188 
1189  if (elem1->processor_id() != processor_id())
1190  continue;
1191 
1192  const ElementPairInfo & info = elem_pair_loc.getElemPairInfo(pr);
1193 
1194  // for each element process constraints on the
1195  for (const auto & ec : _element_constraints)
1196  {
1197  _fe_problem.setCurrentSubdomainID(elem1, tid);
1199  _fe_problem.setNeighborSubdomainID(elem2, tid);
1201 
1202  ec->subProblem().prepareShapes(ec->variable().number(), tid);
1203  ec->subProblem().prepareNeighborShapes(ec->variable().number(), tid);
1204 
1205  ec->reinit(info);
1206  ec->computeResidual();
1209  }
1211  }
1212  }
1213  }
1214 
1215  // go over NodeELemConstraints
1216  std::set<dof_id_type> unique_slave_node_ids;
1217 
1218  constraints_applied = false;
1219  residual_has_inserted_values = false;
1220  for (const auto & slave_id : _mesh.meshSubdomains())
1221  {
1222  for (const auto & master_id : _mesh.meshSubdomains())
1223  {
1224  if (_constraints.hasActiveNodeElemConstraints(slave_id, master_id, displaced))
1225  {
1226  const auto & constraints =
1227  _constraints.getActiveNodeElemConstraints(slave_id, master_id, displaced);
1228 
1229  // get unique set of ids of all nodes on current block
1230  unique_slave_node_ids.clear();
1231  const MeshBase & meshhelper = _mesh.getMesh();
1232  for (const auto & elem : as_range(meshhelper.active_subdomain_elements_begin(slave_id),
1233  meshhelper.active_subdomain_elements_end(slave_id)))
1234  {
1235  for (auto & n : elem->node_ref_range())
1236  unique_slave_node_ids.insert(n.id());
1237  }
1238 
1239  for (auto slave_node_id : unique_slave_node_ids)
1240  {
1241  Node & slave_node = _mesh.nodeRef(slave_node_id);
1242  // check if slave node is on current processor
1243  if (slave_node.processor_id() == processor_id())
1244  {
1245  // This reinits the variables that exist on the slave node
1246  _fe_problem.reinitNodeFace(&slave_node, slave_id, 0);
1247 
1248  // This will set aside residual and jacobian space for the variables that have dofs
1249  // on the slave node
1251 
1252  for (const auto & nec : constraints)
1253  {
1254  if (nec->shouldApply())
1255  {
1256  constraints_applied = true;
1257  nec->computeResidual();
1258 
1259  if (nec->overwriteSlaveResidual())
1260  {
1261  _fe_problem.setResidual(residual, 0);
1262  residual_has_inserted_values = true;
1263  }
1264  else
1267  }
1268  }
1270  }
1271  }
1272  }
1273  }
1274  }
1275  _communicator.max(constraints_applied);
1276 
1277  if (constraints_applied)
1278  {
1279  // If any of the above constraints inserted values in the residual, it needs to be assembled
1280  // before adding the cached residuals below.
1281  _communicator.max(residual_has_inserted_values);
1282  if (residual_has_inserted_values)
1283  residual.close();
1284 
1286  residual.close();
1287 
1289  *_residual_ghosted = residual;
1290  }
1291 }
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...
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
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 const Node & nodeRef(const dof_id_type i) const
Definition: MooseMesh.C:436
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.
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:2567
std::vector< Point > _elem1_constraint_q_point
const ElementPairList & getElemPairs() const
const Elem * _elem
boundary_id_type BoundaryID
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:740
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
void mortarResidualConstraints(bool displaced)
Do mortar constraint residual computation.
unsigned int THREAD_ID
Definition: MooseTypes.h:161
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:2316
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 2981 of file NonlinearSystemBase.C.

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

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

◆ converged()

bool NonlinearSystem::converged ( )
overridevirtualinherited

Returns the convergence state.

Returns
true if converged, otherwise false

Implements NonlinearSystemBase.

Definition at line 392 of file NonlinearSystem.C.

393 {
395  return false;
396 
397  return _transient_sys.nonlinear_solver->converged;
398 }
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 1052 of file SystemBase.C.

Referenced by EigenExecutionerBase::inversePowerIteration().

1053 {
1054  solutionOlder() = solutionOld();
1056  if (solutionUDotOld())
1057  *solutionUDotOld() = *solutionUDot();
1058  if (solutionUDotDotOld())
1060  if (solutionPreviousNewton())
1062 }
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
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

◆ copySolutionsBackwards()

void SystemBase::copySolutionsBackwards ( )
virtualinherited

Copy current solution into old and older.

Definition at line 1035 of file SystemBase.C.

1036 {
1037  system().update();
1040  if (solutionUDotOld())
1041  *solutionUDotOld() = *solutionUDot();
1042  if (solutionUDotDotOld())
1044  if (solutionPreviousNewton())
1046 }
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
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

◆ copyVars()

void SystemBase::copyVars ( ExodusII_IO &  io)
inherited

Definition at line 952 of file SystemBase.C.

953 {
954  int n_steps = io.get_num_time_steps();
955 
956  bool did_copy = false;
957  for (const auto & vci : _var_to_copy)
958  {
959  int timestep = -1;
960 
961  if (vci._timestep == "LATEST")
962  // Use the last time step in the file from which to retrieve the solution
963  timestep = n_steps;
964  else
965  {
966  timestep = MooseUtils::convert<int>(vci._timestep);
967  if (timestep > n_steps)
968  mooseError("Invalid value passed as \"initial_from_file_timestep\". Expected \"LATEST\" or "
969  "a valid integer between 1 and ",
970  n_steps,
971  " inclusive, received ",
972  vci._timestep);
973  }
974 
975  did_copy = true;
976 
977  if (hasVariable(vci._dest_name))
978  {
979  if (getVariable(0, vci._dest_name).isNodal())
980  io.copy_nodal_solution(system(), vci._dest_name, vci._source_name, timestep);
981 
982  else
983  io.copy_elemental_solution(system(), vci._dest_name, vci._source_name, timestep);
984  }
985  else if (hasScalarVariable(vci._dest_name))
986  {
987  auto rank = comm().rank();
988  auto size = comm().size();
989 
990  // Read solution on rank 0 only and send data to rank "size - 1" where scalar DOFs are
991  // stored
992  std::vector<Real> global_values;
993  if (rank == 0)
994  {
995  // Read the scalar value then set that value in the current solution
996  io.read_global_variable({vci._source_name}, timestep, global_values);
997  if (size > 1)
998  comm().send(size - 1, global_values);
999  }
1000  if (rank == size - 1)
1001  {
1002  if (size > 1)
1003  comm().receive(0, global_values);
1004  const unsigned int var_num = system().variable_number(vci._dest_name);
1005  system().solution->set(var_num, global_values[0]);
1006  }
1007  }
1008  }
1009 
1010  if (did_copy)
1011  solution().close();
1012 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
MooseVariableFEBase & getVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:105
virtual bool isNodal() const =0
Is this variable nodal.
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:773
int convert< int >(const std::string &str, bool throw_on_failure)
Definition: MooseUtils.C:610
virtual System & system()=0
Get the reference to the libMesh system.
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition: SystemBase.C:668
MPI_Comm comm
virtual NumericVector< Number > & solution()=0
virtual bool hasScalarVariable(const std::string &var_name) const
Definition: SystemBase.C:677

◆ currentSolution()

const NumericVector<Number>* const& NonlinearSystemBase::currentSolution ( ) const
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 392 of file NonlinearSystemBase.h.

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

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

◆ deactiveAllMatrixTags()

void SystemBase::deactiveAllMatrixTags ( )
virtualinherited

Make matrices inactive.

Definition at line 886 of file SystemBase.C.

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

887 {
888  auto num_matrix_tags = _subproblem.numMatrixTags();
889 
890  _matrix_tag_active_flags.resize(num_matrix_tags);
891 
892  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
893  _matrix_tag_active_flags[tag] = false;
894 }
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:760
SubProblem & _subproblem
Definition: SystemBase.h:735
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:157

◆ deactiveMatrixTag()

void SystemBase::deactiveMatrixTag ( TagID  tag)
virtualinherited

deactive a matrix for tag

Definition at line 874 of file SystemBase.C.

875 {
876  mooseAssert(