https://mooseframework.inl.gov
KernelBase.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 "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 
22 {
23  auto params = ResidualObject::validParams();
26  params.registerSystemAttributeName("Kernel");
27 
28  params.addParam<std::vector<AuxVariableName>>(
29  "save_in",
30  {},
31  "The name of auxiliary variables to save this Kernel's residual contributions to. "
32  " Everything about that variable must match everything about this variable (the "
33  "type, what blocks it's on, etc.)");
34  params.addParam<std::vector<AuxVariableName>>(
35  "diag_save_in",
36  {},
37  "The name of auxiliary variables to save this Kernel's diagonal Jacobian "
38  "contributions to. Everything about that variable must match everything "
39  "about this variable (the type, what blocks it's on, etc.)");
40 
41  params.addParam<bool>("use_displaced_mesh",
42  false,
43  "Whether or not this object should use the "
44  "displaced mesh for computation. Note that in "
45  "the case this is true but no displacements "
46  "are provided in the Mesh block the "
47  "undisplaced mesh will still be used.");
48 
49  params.addParamNamesToGroup("diag_save_in save_in use_displaced_mesh", "Advanced");
50  params.addCoupledVar("displacements", "The displacements");
51 
52  // Kernels always couple within their element
53  params.addRelationshipManager("ElementSideNeighborLayers",
55  [](const InputParameters &, InputParameters & rm_params)
56  { rm_params.set<unsigned short>("layers") = 0; });
57  return params;
58 }
59 
61  : ResidualObject(parameters),
62  BlockRestrictable(this),
66  ElementIDInterface(this),
67  _current_elem(_assembly.elem()),
68  _current_elem_volume(_assembly.elemVolume()),
69  _q_point(_assembly.qPoints()),
70  _qrule(_assembly.qRule()),
71  _JxW(_assembly.JxW()),
72  _coord(_assembly.coordTransformation()),
73  _has_save_in(false),
74  _save_in_strings(parameters.get<std::vector<AuxVariableName>>("save_in")),
75  _has_diag_save_in(false),
76  _diag_save_in_strings(parameters.get<std::vector<AuxVariableName>>("diag_save_in")),
77  _use_displaced_mesh(getParam<bool>("use_displaced_mesh"))
78 {
79  auto num_disp = coupledComponents("displacements");
80  for (decltype(num_disp) i = 0; i < num_disp; ++i)
81  _displacements.push_back(coupled("displacements", i));
82 }
virtual unsigned int coupled(const std::string &var_name, unsigned int comp=0) const
Returns the index for a coupled variable by name.
Definition: Coupleable.C:442
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
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
KernelBase(const InputParameters &parameters)
Definition: KernelBase.C:60
static InputParameters validParams()
static InputParameters validParams()
std::vector< unsigned int > _displacements
Definition: KernelBase.h:73
unsigned int coupledComponents(const std::string &var_name) const
Number of coupled components.
Definition: Coupleable.C:158
This is the common base class for objects that give residual contributions.
An interface for accessing Materials.
const std::set< BoundaryID > EMPTY_BOUNDARY_IDS
Definition: MooseTypes.h:684
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.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
static InputParameters validParams()
Definition: KernelBase.C:21