www.mooseframework.org
AuxKernel.h
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 #pragma once
11 
12 #include "MooseObject.h"
13 #include "MooseVariableFE.h"
14 #include "SetupInterface.h"
17 #include "FunctionInterface.h"
18 #include "UserObjectInterface.h"
19 #include "TransientInterface.h"
20 #include "PostprocessorInterface.h"
22 #include "RandomInterface.h"
24 #include "BlockRestrictable.h"
25 #include "BoundaryRestrictable.h"
26 #include "Restartable.h"
27 #include "MeshChangedInterface.h"
29 #include "MooseVariableInterface.h"
30 #include "MemberTemplateMacros.h"
31 #include "ElementIDInterface.h"
32 
33 // forward declarations
34 template <typename ComputeValueType>
36 
39 
40 class SubProblem;
41 class AuxiliarySystem;
42 class SystemBase;
43 class MooseMesh;
44 
45 template <>
47 
48 template <>
50 
55 template <typename ComputeValueType>
56 class AuxKernelTempl : public MooseObject,
57  public MooseVariableInterface<ComputeValueType>,
58  public BlockRestrictable,
59  public BoundaryRestrictable,
60  public SetupInterface,
62  public FunctionInterface,
63  public UserObjectInterface,
64  public TransientInterface,
68  public RandomInterface,
69  protected GeometricSearchInterface,
70  public Restartable,
71  public MeshChangedInterface,
73  public ElementIDInterface
74 {
75 public:
77 
79 
83  virtual void compute();
84 
89  bool isNodal() const { return _nodal; }
90 
96 
97  const std::set<std::string> & getDependObjects() const { return _depend_uo; }
98 
99  void coupledCallback(const std::string & var_name, bool is_old) override;
100 
101  virtual const std::set<std::string> & getRequestedItems() override;
102 
103  virtual const std::set<std::string> & getSuppliedItems() override;
104 
108  template <typename T>
109  const MaterialProperty<T> & getMaterialPropertyTempl(const std::string & name);
110  template <typename T>
111  const MaterialProperty<T> & getMaterialPropertyOldTempl(const std::string & name);
112  template <typename T>
113  const MaterialProperty<T> & getMaterialPropertyOlderTempl(const std::string & name);
114 
115  template <typename T>
116  const T & getUserObjectTempl(const std::string & name);
117  template <typename T>
118  const T & getUserObjectByNameTempl(const UserObjectName & name);
119 
120  const UserObject & getUserObjectBase(const std::string & name);
121 
122  virtual const PostprocessorValue & getPostprocessorValue(const std::string & name);
123  virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName & name);
124 
125  virtual const VectorPostprocessorValue &
126  getVectorPostprocessorValue(const std::string & name, const std::string & vector_name) override;
127  virtual const VectorPostprocessorValue &
128  getVectorPostprocessorValueByName(const VectorPostprocessorName &,
129  const std::string & vector_name) override;
130 
132  const std::string & name, const std::string & vector_name, bool needs_broadcast) override;
133  virtual const VectorPostprocessorValue &
134  getVectorPostprocessorValueByName(const VectorPostprocessorName &,
135  const std::string & vector_name,
136  bool needs_broadcast) override;
137 
138  virtual const ScatterVectorPostprocessorValue &
139  getScatterVectorPostprocessorValue(const std::string & name,
140  const std::string & vector_name) override;
141 
142  virtual const ScatterVectorPostprocessorValue &
144  const std::string & vector_name) override;
145 
146 protected:
150  virtual ComputeValueType computeValue() = 0;
151 
152  virtual const VariableValue & coupledDot(const std::string & var_name,
153  unsigned int comp = 0) override;
154 
155  virtual const VariableValue & coupledDotDu(const std::string & var_name,
156  unsigned int comp = 0) override;
157 
159  virtual void precalculateValue() {}
160 
167 
170 
173 
175  bool _nodal;
176 
179 
182 
185 
188 
191 
193  bool _bnd;
197  // unsigned int _dim;
198 
202  const QBase * const & _qrule;
206 
208  const Elem * const & _current_elem;
210  const unsigned int & _current_side;
211 
213  const Real & _current_elem_volume;
215  const Real & _current_side_volume;
216 
218  const Node * const & _current_node;
219 
222 
224  NumericVector<Number> & _solution;
225 
227  unsigned int _qp;
228 
230  std::set<std::string> _depend_vars;
231  std::set<std::string> _supplied_vars;
232 
234  std::set<std::string> _depend_uo;
235 
237  unsigned int _n_local_dofs;
238 
240  DenseVector<Number> _local_re;
242  DenseVector<Number> _local_sol;
244  DenseMatrix<Number> _local_ke;
245 
247 };
248 
249 template <typename ComputeValueType>
250 template <typename T>
251 const MaterialProperty<T> &
253 {
254  if (isNodal())
255  mooseError("Nodal AuxKernel '",
257  "' attempted to reference material property '",
258  name,
259  "'\nConsider using an elemental auxiliary variable for '",
260  _var.name(),
261  "'.");
262 
263  return MaterialPropertyInterface::getMaterialPropertyTempl<T>(name);
264 }
265 
266 template <typename ComputeValueType>
267 template <typename T>
268 const MaterialProperty<T> &
270 {
271  if (isNodal())
272  mooseError("Nodal AuxKernel '",
274  "' attempted to reference material property '",
275  name,
276  "'\nConsider using an elemental auxiliary variable for '",
277  _var.name(),
278  "'.");
279 
280  return MaterialPropertyInterface::getMaterialPropertyOldTempl<T>(name);
281 }
282 
283 template <typename ComputeValueType>
284 template <typename T>
285 const MaterialProperty<T> &
287 {
288  if (isNodal())
289  mooseError("Nodal AuxKernel '",
291  "' attempted to reference material property '",
292  name,
293  "'\nConsider using an elemental auxiliary variable for '",
294  _var.name(),
295  "'.");
296 
297  return MaterialPropertyInterface::getMaterialPropertyOlderTempl<T>(name);
298 }
299 
300 template <typename ComputeValueType>
301 template <typename T>
302 const T &
304 {
305  _depend_uo.insert(_pars.get<UserObjectName>(name));
306  return UserObjectInterface::getUserObjectTempl<T>(name);
307 }
308 
309 template <typename ComputeValueType>
310 template <typename T>
311 const T &
313 {
314  _depend_uo.insert(name);
315  return UserObjectInterface::getUserObjectByNameTempl<T>(name);
316 }
AuxKernelTempl::getVectorPostprocessorValue
virtual const VectorPostprocessorValue & getVectorPostprocessorValue(const std::string &name, const std::string &vector_name) override
DEPRECATED: Use the new version where you need to specify whether or not the vector must be broadcast...
Definition: AuxKernel.C:179
AuxKernelTempl::coupledDotDu
virtual const VariableValue & coupledDotDu(const std::string &var_name, unsigned int comp=0) override
Time derivative of a coupled variable with respect to the coefficients.
Definition: AuxKernel.C:261
AuxKernelTempl::_test
const OutputTools< ComputeValueType >::VariableTestValue & _test
Holds the the test functions.
Definition: AuxKernel.h:187
THREAD_ID
unsigned int THREAD_ID
Definition: MooseTypes.h:196
SetupInterface
Definition: SetupInterface.h:28
AuxKernelTempl::_current_elem_volume
const Real & _current_elem_volume
Volume of the current element.
Definition: AuxKernel.h:213
GeometricSearchInterface
Definition: GeometricSearchInterface.h:23
AuxKernelTempl::getUserObjectBase
const UserObject & getUserObjectBase(const std::string &name)
Definition: AuxKernel.C:155
AuxKernelTempl::_local_ke
DenseMatrix< Number > _local_ke
for holding local mass matrix
Definition: AuxKernel.h:244
GeometricSearchInterface.h
AuxiliarySystem
A system that holds auxiliary variables.
Definition: AuxiliarySystem.h:40
MeshChangedInterface.h
AuxKernelTempl::_aux_sys
AuxiliarySystem & _aux_sys
Definition: AuxKernel.h:166
AuxKernelTempl::_n_local_dofs
unsigned int _n_local_dofs
number of local dofs for elemental variables
Definition: AuxKernel.h:237
ElementIDInterface
Definition: ElementIDInterface.h:21
UserObjectInterface.h
AuxKernelTempl::AuxKernelTempl
AuxKernelTempl(const InputParameters &parameters)
Definition: AuxKernel.C:68
AuxKernelTempl::_tid
THREAD_ID _tid
Thread ID.
Definition: AuxKernel.h:169
AuxKernelTempl::_u_older
const OutputTools< ComputeValueType >::VariableValue & _u_older
Holds the t-2 solution at the current quadrature point.
Definition: AuxKernel.h:184
AuxKernelTempl::_local_sol
DenseVector< Number > _local_sol
for holding local solution
Definition: AuxKernel.h:242
VectorAuxKernel
AuxKernelTempl< RealVectorValue > VectorAuxKernel
Definition: AuxKernel.h:38
AuxKernelTempl::getSuppliedItems
virtual const std::set< std::string > & getSuppliedItems() override
Return a set containing the names of items owned by the object.
Definition: AuxKernel.C:148
VectorPostprocessorInterface.h
AuxKernelTempl::_bnd
bool _bnd
true if the kernel is boundary kernel, false if it is interior kernels
Definition: AuxKernel.h:193
AuxKernelTempl::getUserObjectTempl
const T & getUserObjectTempl(const std::string &name)
Definition: AuxKernel.h:303
FunctionInterface
Interface for objects that need to use functions.
Definition: FunctionInterface.h:38
MooseObject::parameters
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:76
UserObjectInterface
Interface for objects that need to use UserObjects.
Definition: UserObjectInterface.h:28
AuxKernelTempl::_subproblem
SubProblem & _subproblem
Subproblem this kernel is part of.
Definition: AuxKernel.h:162
MaterialPropertyInterface.h
BlockRestrictable.h
SetupInterface.h
AuxKernelTempl
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:35
BoundaryRestrictable
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
Definition: BoundaryRestrictable.h:30
AuxKernelTempl::_coord
const MooseArray< Real > & _coord
Definition: AuxKernel.h:205
AuxKernelTempl::coupledDot
virtual const VariableValue & coupledDot(const std::string &var_name, unsigned int comp=0) override
Time derivative of a coupled variable.
Definition: AuxKernel.C:248
AuxKernelTempl::_qrule
const QBase *const & _qrule
Quadrature rule being used.
Definition: AuxKernel.h:202
AuxKernelTempl::precalculateValue
virtual void precalculateValue()
This callback is used for AuxKernelTempls that need to perform a per-element calculation.
Definition: AuxKernel.h:159
AuxKernelTempl::_sys
SystemBase & _sys
System this kernel is part of.
Definition: AuxKernel.h:164
AuxKernelTempl::getScatterVectorPostprocessorValueByName
virtual const ScatterVectorPostprocessorValue & getScatterVectorPostprocessorValueByName(const std::string &name, const std::string &vector_name) override
Return the scatter value for the post processor.
Definition: AuxKernel.C:227
AuxKernelTempl::_u_old
const OutputTools< ComputeValueType >::VariableValue & _u_old
Holds the previous solution at the current quadrature point.
Definition: AuxKernel.h:181
AuxKernelTempl::getPostprocessorValueByName
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name)
Definition: AuxKernel.C:171
AuxKernelTempl::getMaterialPropertyTempl
const MaterialProperty< T > & getMaterialPropertyTempl(const std::string &name)
Override functions from MaterialPropertyInterface for error checking.
Definition: AuxKernel.h:252
AuxKernelTempl::getMaterialPropertyOlderTempl
const MaterialProperty< T > & getMaterialPropertyOlderTempl(const std::string &name)
Definition: AuxKernel.h:286
mooseError
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition: MooseError.h:210
MooseObject
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:50
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition: InputParameters.h:53
DependencyResolverInterface.h
AuxKernelTempl::_depend_vars
std::set< std::string > _depend_vars
Depend AuxKernelTempls.
Definition: AuxKernel.h:230
AuxKernelTempl::getPostprocessorValue
virtual const PostprocessorValue & getPostprocessorValue(const std::string &name)
Definition: AuxKernel.C:163
PostprocessorValue
Real PostprocessorValue
MOOSE typedefs.
Definition: MooseTypes.h:189
AuxKernelTempl::_current_side
const unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:210
BoundaryRestrictable.h
AuxKernelTempl::_JxW
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
Definition: AuxKernel.h:204
SubProblem
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:62
ScatterVectorPostprocessorValue
Real ScatterVectorPostprocessorValue
Definition: MooseTypes.h:191
AuxKernelTempl::compute
virtual void compute()
Computes the value and stores it in the solution vector.
Definition: AuxKernel.C:274
AuxKernelTempl::_q_point
const MooseArray< Point > & _q_point
Dimension of the problem being solved.
Definition: AuxKernel.h:200
VectorPostprocessorInterface
Definition: VectorPostprocessorInterface.h:20
AuxKernelTempl::_current_boundary_id
const BoundaryID & _current_boundary_id
The current boundary ID.
Definition: AuxKernel.h:221
TransientInterface.h
PostprocessorInterface
Interface class for classes which interact with Postprocessors.
Definition: PostprocessorInterface.h:34
UserObject
Base class for user-specific data.
Definition: UserObject.h:38
ElementIDInterface.h
AuxKernelTempl::_u
const OutputTools< ComputeValueType >::VariableValue & _u
Holds the solution at current quadrature points.
Definition: AuxKernel.h:178
AuxKernelTempl::getMaterialPropertyOldTempl
const MaterialProperty< T > & getMaterialPropertyOldTempl(const std::string &name)
Definition: AuxKernel.h:269
AuxKernelTempl::_mesh
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:195
AuxKernelTempl::_nl_sys
SystemBase & _nl_sys
Definition: AuxKernel.h:165
BoundaryID
boundary_id_type BoundaryID
Definition: AutomaticMortarGeneration.h:47
Restartable
A class for creating restricted objects.
Definition: Restartable.h:29
AuxKernelTempl::_current_elem
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:208
TransientInterface
Interface for objects that needs transient capabilities.
Definition: TransientInterface.h:35
FunctionInterface.h
AuxKernelTempl::getVectorPostprocessorValueByName
virtual const VectorPostprocessorValue & getVectorPostprocessorValueByName(const VectorPostprocessorName &, const std::string &vector_name) override
DEPRECATED: Use the new version where you need to specify whether or not the vector must be broadcast...
Definition: AuxKernel.C:188
CoupleableMooseVariableDependencyIntermediateInterface
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
Definition: CoupleableMooseVariableDependencyIntermediateInterface.h:20
MeshChangedInterface
Interface for notifications that the mesh has changed.
Definition: MeshChangedInterface.h:28
VectorPostprocessorValue
std::vector< Real > VectorPostprocessorValue
Definition: MooseTypes.h:190
MaterialProperty
Concrete definition of a parameter value for a specified type.
Definition: DerivativeMaterialInterface.h:25
AuxKernelTempl::_assembly
Assembly & _assembly
Assembly class.
Definition: AuxKernel.h:190
AuxKernelTempl::getUserObjectByNameTempl
const T & getUserObjectByNameTempl(const UserObjectName &name)
Definition: AuxKernel.h:312
MooseObject.h
AuxKernelTempl::variable
MooseVariableFE< ComputeValueType > & variable()
Get a reference to a variable this kernel is action on.
Definition: AuxKernel.h:95
MooseArray< Point >
MooseVariableFE.h
Assembly
Keeps track of stuff related to assembling.
Definition: Assembly.h:62
AuxKernelTempl::validParams
static InputParameters validParams()
Definition: AuxKernel.C:28
Restartable.h
validParams< AuxKernel >
InputParameters validParams< AuxKernel >()
AuxKernelTempl::_supplied_vars
std::set< std::string > _supplied_vars
Definition: AuxKernel.h:231
AuxKernelTempl::isNodal
bool isNodal() const
Nodal or elemental kernel?
Definition: AuxKernel.h:89
AuxKernelTempl::coupledCallback
void coupledCallback(const std::string &var_name, bool is_old) override
A call-back function provided by the derived object for actions before coupling a variable with funct...
Definition: AuxKernel.C:236
validParams< VectorAuxKernel >
InputParameters validParams< VectorAuxKernel >()
AuxKernel
AuxKernelTempl< Real > AuxKernel
Definition: AuxKernel.h:35
AuxKernelTempl::_nodal
bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition: AuxKernel.h:175
AuxKernelTempl::_current_node
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:218
BlockRestrictable
An interface that restricts an object to subdomains via the 'blocks' input parameter.
Definition: BlockRestrictable.h:61
AuxKernelTempl::computeValue
virtual ComputeValueType computeValue()=0
Compute and return the value of the aux variable.
SystemBase
Base class for a system (of equations)
Definition: SystemBase.h:95
MooseMesh
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
MemberTemplateMacros.h
AuxKernelTempl::_qp
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:227
RandomInterface
Interface for objects that need parallel consistent random numbers without patterns over the course o...
Definition: RandomInterface.h:33
MooseVariableInterface.h
PostprocessorInterface.h
AuxKernelTempl::_var
MooseVariableFE< ComputeValueType > & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: AuxKernel.h:172
VariableValue
OutputTools< Real >::VariableValue VariableValue
Definition: MooseTypes.h:300
CoupleableMooseVariableDependencyIntermediateInterface.h
MooseVariableInterface
Interface for objects that need to get values of MooseVariables.
Definition: MooseVariableInterface.h:24
AuxKernelTempl::_local_re
DenseVector< Number > _local_re
for holding local load
Definition: AuxKernel.h:240
AuxKernelTempl::getDependObjects
const std::set< std::string > & getDependObjects() const
Definition: AuxKernel.h:97
AuxKernelTempl::_depend_uo
std::set< std::string > _depend_uo
Depend UserObjects.
Definition: AuxKernel.h:234
AuxKernelTempl::_solution
NumericVector< Number > & _solution
reference to the solution vector of auxiliary system
Definition: AuxKernel.h:224
DependencyResolverInterface
Interface for sorting dependent vectors of objects.
Definition: DependencyResolverInterface.h:24
MooseVariableFE< ComputeValueType >
MaterialPropertyInterface
An interface for accessing Materials.
Definition: MaterialPropertyInterface.h:38
OutputTools
Definition: MooseTypes.h:264
AuxKernelTempl::getRequestedItems
virtual const std::set< std::string > & getRequestedItems() override
Return a set containing the names of items requested by the object.
Definition: AuxKernel.C:141
AuxKernelTempl::getScatterVectorPostprocessorValue
virtual const ScatterVectorPostprocessorValue & getScatterVectorPostprocessorValue(const std::string &name, const std::string &vector_name) override
Return the scatter value for the post processor.
Definition: AuxKernel.C:218
MooseObject::name
virtual const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:70
AuxKernelTempl::_current_side_volume
const Real & _current_side_volume
Volume of the current side.
Definition: AuxKernel.h:215
RandomInterface.h