www.mooseframework.org
KernelBase.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "KernelBase.h"
11 #include "Assembly.h"
12 #include "MooseVariableFE.h"
13 #include "Problem.h"
14 #include "SubProblem.h"
15 #include "SystemBase.h"
16 #include "NonlinearSystem.h"
17 
18 #include "libmesh/threads.h"
19 
20 template <>
23 {
27  params += validParams<RandomInterface>();
31 
32  params.addRequiredParam<NonlinearVariableName>(
33  "variable", "The name of the variable that this Kernel operates on");
34  params.addParam<std::vector<AuxVariableName>>(
35  "save_in",
36  "The name of auxiliary variables to save this Kernel's residual contributions to. "
37  " Everything about that variable must match everything about this variable (the "
38  "type, what blocks it's on, etc.)");
39  params.addParam<std::vector<AuxVariableName>>(
40  "diag_save_in",
41  "The name of auxiliary variables to save this Kernel's diagonal Jacobian "
42  "contributions to. Everything about that variable must match everything "
43  "about this variable (the type, what blocks it's on, etc.)");
44 
45  params.addParam<bool>("use_displaced_mesh",
46  false,
47  "Whether or not this object should use the "
48  "displaced mesh for computation. Note that in "
49  "the case this is true but no displacements "
50  "are provided in the Mesh block the "
51  "undisplaced mesh will still be used.");
52  params.addParamNamesToGroup(" diag_save_in save_in use_displaced_mesh", "Advanced");
53  params.addCoupledVar("displacements", "The displacements");
54 
55  params.declareControllable("enable");
56  return params;
57 }
58 
60  : MooseObject(parameters),
61  BlockRestrictable(this),
62  SetupInterface(this),
64  FunctionInterface(this),
65  UserObjectInterface(this),
66  TransientInterface(this),
70  RandomInterface(parameters,
71  *parameters.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base"),
72  parameters.get<THREAD_ID>("_tid"),
73  false),
75  Restartable(this, "Kernels"),
76  MeshChangedInterface(parameters),
77  TaggingInterface(this),
78  _subproblem(*getCheckedPointerParam<SubProblem *>("_subproblem")),
79  _fe_problem(*parameters.get<FEProblemBase *>("_fe_problem_base")),
80  _sys(*getCheckedPointerParam<SystemBase *>("_sys")),
81  _tid(parameters.get<THREAD_ID>("_tid")),
82  _assembly(_subproblem.assembly(_tid)),
83  _mesh(_subproblem.mesh()),
84  _current_elem(_assembly.elem()),
85  _current_elem_volume(_assembly.elemVolume()),
86  _q_point(_assembly.qPoints()),
87  _qrule(_assembly.qRule()),
88  _JxW(_assembly.JxW()),
89  _coord(_assembly.coordTransformation()),
90  _has_save_in(false),
91  _save_in_strings(parameters.get<std::vector<AuxVariableName>>("save_in")),
92  _has_diag_save_in(false),
93  _diag_save_in_strings(parameters.get<std::vector<AuxVariableName>>("diag_save_in"))
94 {
95  auto num_disp = coupledComponents("displacements");
96  for (decltype(num_disp) i = 0; i < num_disp; ++i)
97  _displacements.push_back(coupled("displacements", i));
98 }
99 
InputParameters validParams< MaterialPropertyInterface >()
Interface for objects that need parallel consistent random numbers without patterns over the course o...
A class for creating restricted objects.
Definition: Restartable.h:29
unsigned int coupledComponents(const std::string &var_name)
Number of coupled components.
Definition: Coupleable.C:166
InputParameters validParams< BlockRestrictable >()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual ~KernelBase()
Definition: KernelBase.C:100
Base class for a system (of equations)
Definition: SystemBase.h:92
KernelBase(const InputParameters &parameters)
Definition: KernelBase.C:59
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
Interface for objects that needs transient capabilities.
Interface for notifications that the mesh has changed.
InputParameters validParams< RandomInterface >()
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
InputParameters validParams< MeshChangedInterface >()
Interface for objects that need to use UserObjects.
std::vector< unsigned int > _displacements
Definition: KernelBase.h:180
InputParameters validParams< MooseObject >()
Definition: MooseObject.C:25
InputParameters validParams< KernelBase >()
Definition: KernelBase.C:22
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:59
An interface for accessing Materials.
const std::set< BoundaryID > EMPTY_BOUNDARY_IDS
Definition: MooseTypes.h:452
InputParameters validParams< TaggingInterface >()
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
Definition: Moose.h:112
Interface for objects that need to use functions.
InputParameters validParams< TransientInterface >()
virtual unsigned int coupled(const std::string &var_name, unsigned int comp=0)
Returns the index for a coupled variable by name.
Definition: Coupleable.C:253
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:161