https://mooseframework.inl.gov
ResidualObject.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "MooseObject.h"
13 #include "SetupInterface.h"
14 #include "FunctionInterface.h"
15 #include "UserObjectInterface.h"
16 #include "TransientInterface.h"
17 #include "PostprocessorInterface.h"
19 #include "RandomInterface.h"
20 #include "Restartable.h"
21 #include "MeshChangedInterface.h"
22 #include "TaggingInterface.h"
23 
24 class FEProblemBase;
25 class MooseMesh;
26 class SubProblem;
27 class Assembly;
28 class MooseVariableBase;
30 class InputParameters;
31 class SystemBase;
32 
36 class ResidualObject : public MooseObject,
37  public SetupInterface,
38  public FunctionInterface,
39  public UserObjectInterface,
40  public TransientInterface,
43  public RandomInterface,
44  public Restartable,
45  public MeshChangedInterface,
46  public TaggingInterface
47 {
48 public:
50 
56  ResidualObject(const InputParameters & parameters, bool nodal = false);
57 
58 #ifdef MOOSE_KOKKOS_ENABLED
59 
62  ResidualObject(const ResidualObject & object, const Moose::Kokkos::FunctorCopy & key);
63 #endif
64 
66  virtual void computeResidual() = 0;
67 
69  virtual void computeJacobian() = 0;
70 
72  virtual void computeResidualAndJacobian();
73 
82  virtual void computeOffDiagJacobian(unsigned int /*jvar*/) {}
83 
88  virtual void computeOffDiagJacobianScalar(unsigned int /*jvar*/) {}
89 
94  virtual void computeNonlocalJacobian() {}
95 
99  virtual void computeNonlocalOffDiagJacobian(unsigned int /* jvar */) {}
100 
104  virtual const MooseVariableBase & variable() const = 0;
105 
109  const SubProblem & subProblem() const { return _subproblem; }
110 
115  virtual void prepareShapes(unsigned int var_num);
116 
121  virtual std::set<std::string> additionalROVariables() { return {}; }
122 
123 protected:
124  virtual void precalculateResidual() {}
125  virtual void precalculateJacobian() {}
126  virtual void precalculateOffDiagJacobian(unsigned int /* jvar */) {}
127 
131  const MooseVariableFieldBase & getVariable(unsigned int jvar_num) const
132  {
133  return _sys.getVariable(_tid, jvar_num);
134  }
135 
136 protected:
139 
142 
145 
148 
151 
154 };
MooseMesh & _mesh
Reference to this Kernel&#39;s mesh object.
Interface for objects that need parallel consistent random numbers without patterns over the course o...
virtual void computeResidualAndJacobian()
Compute this object&#39;s contribution to the residual and Jacobian simultaneously.
A class for creating restricted objects.
Definition: Restartable.h:28
Keeps track of stuff related to assembling.
Definition: Assembly.h:109
virtual void precalculateOffDiagJacobian(unsigned int)
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
virtual void computeOffDiagJacobian(unsigned int)
Computes this object&#39;s contribution to off-diagonal blocks of the system Jacobian matrix...
virtual void precalculateResidual()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void prepareShapes(unsigned int var_num)
Prepare shape functions.
virtual void computeNonlocalJacobian()
Compute this object&#39;s contribution to the diagonal Jacobian entries corresponding to nonlocal dofs of...
This class provides an interface for common operations on field variables of both FE and FV types wit...
Base class for a system (of equations)
Definition: SystemBase.h:84
THREAD_ID _tid
The thread ID for this kernel.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const MooseVariableFieldBase & getVariable(unsigned int jvar_num) const
Retrieve the variable object from our system associated with jvar_num.
SystemBase & _sys
Reference to the EquationSystem object.
Interface for objects that needs transient capabilities.
Interface for notifications that the mesh has changed.
virtual std::set< std::string > additionalROVariables()
virtual void precalculateJacobian()
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:27
virtual void computeResidual()=0
Compute this object&#39;s contribution to the residual.
SubProblem & _subproblem
Reference to this kernel&#39;s SubProblem.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:92
FEProblemBase & _fe_problem
Reference to this kernel&#39;s FEProblemBase.
ResidualObject(const InputParameters &parameters, bool nodal=false)
Class constructor.
virtual void computeJacobian()=0
Compute this object&#39;s contribution to the diagonal Jacobian entries.
static InputParameters validParams()
Interface for objects that need to use UserObjects.
virtual void computeNonlocalOffDiagJacobian(unsigned int)
Computes Jacobian entries corresponding to nonlocal dofs of the jvar.
Assembly & _assembly
Reference to this Kernel&#39;s assembly object.
This is the common base class for objects that give residual contributions.
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
const SubProblem & subProblem() const
Returns a reference to the SubProblem for which this Kernel is active.
virtual void computeOffDiagJacobianScalar(unsigned int)
Computes jacobian block with respect to a scalar variable.
virtual const MooseVariableBase & variable() const =0
Returns the variable that this object operates on.
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:90
Interface for objects that need to use functions.
Interface class for classes which interact with Postprocessors.
Base variable class.
unsigned int THREAD_ID
Definition: MooseTypes.h:209