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 
59  virtual void computeResidual() = 0;
60 
62  virtual void computeJacobian() = 0;
63 
65  virtual void computeResidualAndJacobian();
66 
75  virtual void computeOffDiagJacobian(unsigned int /*jvar*/) {}
76 
81  virtual void computeOffDiagJacobianScalar(unsigned int /*jvar*/) {}
82 
87  virtual void computeNonlocalJacobian() {}
88 
92  virtual void computeNonlocalOffDiagJacobian(unsigned int /* jvar */) {}
93 
97  virtual const MooseVariableBase & variable() const = 0;
98 
102  const SubProblem & subProblem() const { return _subproblem; }
103 
108  virtual void prepareShapes(unsigned int var_num);
109 
114  virtual std::set<std::string> additionalROVariables() { return {}; }
115 
116 protected:
117  virtual void precalculateResidual() {}
118  virtual void precalculateJacobian() {}
119  virtual void precalculateOffDiagJacobian(unsigned int /* jvar */) {}
120 
124  const MooseVariableFieldBase & getVariable(unsigned int jvar_num) const
125  {
126  return _sys.getVariable(_tid, jvar_num);
127  }
128 
129 protected:
132 
135 
138 
141 
144 
147 };
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:101
virtual void precalculateOffDiagJacobian(unsigned int)
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:28
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:88
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.
const InputParameters & parameters() const
Get the parameters of the object.
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:89
Interface for objects that need to use functions.
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:209