https://mooseframework.inl.gov
ResidualObject.C
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 #include "ResidualObject.h"
11 #include "SubProblem.h"
12 #include "InputParameters.h"
13 
16 {
17  auto params = MooseObject::validParams();
19  params += RandomInterface::validParams();
22 
23  params.addRequiredParam<NonlinearVariableName>(
24  "variable", "The name of the variable that this residual object operates on");
25 
26  params.declareControllable("enable");
27  params.set<bool>("_residual_object") = true;
28  return params;
29 }
30 
33  SetupInterface(this),
34  FunctionInterface(this),
35  UserObjectInterface(this),
36  TransientInterface(this),
38  // VPPs used by ScalarKernels must be broadcast because we don't know where the
39  // ScalarKernel will end up being evaluated
40  // Note: residual objects should have a valid _moose_base.
42  parameters.get<std::string>("_moose_base") == "ScalarKernel"),
44  *parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base"),
45  parameters.get<THREAD_ID>("_tid"),
46  is_nodal),
47  Restartable(this, parameters.get<std::string>("_moose_base") + "s"),
49  TaggingInterface(this),
50  _subproblem(*getCheckedPointerParam<SubProblem *>("_subproblem")),
51  _fe_problem(*parameters.get<FEProblemBase *>("_fe_problem_base")),
52  _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
53  _tid(parameters.get<THREAD_ID>("_tid")),
54  _assembly(_subproblem.assembly(_tid, _sys.number())),
55  _mesh(_subproblem.mesh())
56 {
57 }
58 
59 void
60 ResidualObject::prepareShapes(const unsigned int var_num)
61 {
62  _subproblem.prepareShapes(var_num, _tid);
63 }
64 
65 void
67 {
68  mooseError(
69  "This object has not yet implemented 'computeResidualAndJacobian'. If you would like that "
70  "feature for this object, please contact a MOOSE developer.");
71 }
virtual void prepareShapes(unsigned int var, const THREAD_ID tid)=0
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
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
MeshBase & mesh
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.
static InputParameters validParams()
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.
Interface for objects that needs transient capabilities.
static InputParameters validParams()
Interface for notifications that the mesh has changed.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
SubProblem & _subproblem
Reference to this kernel&#39;s SubProblem.
static InputParameters validParams()
ResidualObject(const InputParameters &parameters, bool nodal=false)
Class constructor.
static InputParameters validParams()
Interface for objects that need to use UserObjects.
T getCheckedPointerParam(const std::string &name, const std::string &error_string="") const
Verifies that the requested parameter exists and is not NULL and returns it to the caller...
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const InputParameters & parameters() const
Get the parameters of the object.
static InputParameters validParams()
Definition: MooseObject.C:25
static InputParameters validParams()
Interface for objects that need to use functions.
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:209
FEProblemBase & _fe_problem
Definition: Executioner.h:148