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 "ElementIDInterface.h"
31 #include "UserObject.h"
32 #include "NonADFunctorInterface.h"
33 
34 // forward declarations
35 template <typename ComputeValueType>
37 
41 
42 class SubProblem;
43 class AuxiliarySystem;
44 class SystemBase;
45 class MooseMesh;
46 
51 template <typename ComputeValueType>
52 class AuxKernelTempl : public MooseObject,
53  public MooseVariableInterface<ComputeValueType>,
54  public BlockRestrictable,
55  public BoundaryRestrictable,
56  public SetupInterface,
58  public FunctionInterface,
59  public UserObjectInterface,
60  public TransientInterface,
64  public RandomInterface,
66  public Restartable,
67  public MeshChangedInterface,
69  public ElementIDInterface,
70  protected NonADFunctorInterface
71 {
72 public:
74 
76 
80  virtual void compute();
81 
86  bool isNodal() const { return _nodal; }
87 
91  bool isMortar();
92 
98 
99  const std::set<UserObjectName> & getDependObjects() const { return _depend_uo; }
100 
101  void coupledCallback(const std::string & var_name, bool is_old) const override;
102 
103  virtual const std::set<std::string> & getRequestedItems() override;
104 
105  virtual const std::set<std::string> & getSuppliedItems() override;
106 
110  template <typename T>
111  const MaterialProperty<T> & getMaterialProperty(const std::string & name);
112  template <typename T, bool is_ad>
114  template <typename T>
115  const MaterialProperty<T> & getMaterialPropertyOld(const std::string & name);
116  template <typename T>
117  const MaterialProperty<T> & getMaterialPropertyOlder(const std::string & name);
118 
122  void insert();
123 
124 protected:
128  virtual ComputeValueType computeValue() = 0;
129 
130  virtual const VariableValue & coupledDot(const std::string & var_name,
131  unsigned int comp = 0) const override;
132 
133  virtual const VariableValue & coupledDotDu(const std::string & var_name,
134  unsigned int comp = 0) const override;
135 
137  virtual void precalculateValue() {}
138 
144  const typename OutputTools<ComputeValueType>::VariableValue & uOld() const;
145 
151  const typename OutputTools<ComputeValueType>::VariableValue & uOlder() const;
152 
162 
169 
172 
175 
177  bool _nodal;
178 
181 
184 
186  bool _bnd;
190  // unsigned int _dim;
191 
194 
198  const QBase * const & _qrule;
202 
204  const Elem * const & _current_elem;
206  const unsigned int & _current_side;
207 
212 
214  const Node * const & _current_node;
215 
218 
221 
223  const Elem * const & _current_lower_d_elem;
224 
228 
230  unsigned int _qp;
231 
233  unsigned int _n_local_dofs;
234 
236 
238  DenseVector<OutputData> _local_re;
240  DenseVector<OutputData> _local_sol;
243 
245 
246 private:
247  void addPostprocessorDependencyHelper(const PostprocessorName & name) const override final;
248  void addUserObjectDependencyHelper(const UserObject & uo) const override final;
249  void
250  addVectorPostprocessorDependencyHelper(const VectorPostprocessorName & name) const override final;
251 
259  void setDofValueHelper(const ComputeValueType & dof_value);
260 
262  mutable std::set<std::string> _depend_vars;
263  std::set<std::string> _supplied_vars;
264 
266  mutable std::set<UserObjectName> _depend_uo;
267 };
268 
269 template <typename ComputeValueType>
270 template <typename T>
271 const MaterialProperty<T> &
273 {
274  if (isNodal())
275  mooseError("Nodal AuxKernel '",
277  "' attempted to reference material property '",
278  name,
279  "'\nConsider using an elemental auxiliary variable for '",
280  _var.name(),
281  "'.");
282 
283  return MaterialPropertyInterface::getMaterialProperty<T>(name);
284 }
285 
286 template <typename ComputeValueType>
287 template <typename T, bool is_ad>
290 {
291  if (isNodal())
292  mooseError("Nodal AuxKernel '",
294  "' attempted to reference material property '",
295  name,
296  "'\nConsider using an elemental auxiliary variable for '",
297  _var.name(),
298  "'.");
299 
300  return MaterialPropertyInterface::getGenericMaterialProperty<T, is_ad>(name);
301 }
302 
303 template <typename ComputeValueType>
304 template <typename T>
305 const MaterialProperty<T> &
307 {
308  if (isNodal())
309  mooseError("Nodal AuxKernel '",
311  "' attempted to reference material property '",
312  name,
313  "'\nConsider using an elemental auxiliary variable for '",
314  _var.name(),
315  "'.");
316 
317  return MaterialPropertyInterface::getMaterialPropertyOld<T>(name);
318 }
319 
320 template <typename ComputeValueType>
321 template <typename T>
322 const MaterialProperty<T> &
324 {
325  if (isNodal())
326  mooseError("Nodal AuxKernel '",
328  "' attempted to reference material property '",
329  name,
330  "'\nConsider using an elemental auxiliary variable for '",
331  _var.name(),
332  "'.");
333 
334  return MaterialPropertyInterface::getMaterialPropertyOlder<T>(name);
335 }
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
std::string name(const ElemQuality q)
Interface for objects that need parallel consistent random numbers without patterns over the course o...
const OutputTools< ComputeValueType >::VariableValue & _u
Holds the solution at current quadrature points.
Definition: AuxKernel.h:180
AuxKernelTempl< RealVectorValue > VectorAuxKernel
Definition: AuxKernel.h:39
A class for creating restricted objects.
Definition: Restartable.h:28
bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition: AuxKernel.h:177
THREAD_ID _tid
Thread ID.
Definition: AuxKernel.h:171
const MooseArray< Real > & _coord
Definition: AuxKernel.h:201
Keeps track of stuff related to assembling.
Definition: Assembly.h:93
const unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:206
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:188
MooseVariableField< ComputeValueType > & variable()
Get a reference to a variable this kernel is action on.
Definition: AuxKernel.h:97
const OutputTools< ComputeValueType >::VariableValue & uOlder() const
Retrieves the older value of the variable that this AuxKernel operates on.
Definition: AuxKernel.C:471
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:284
OutputType type
Definition: MooseTypes.h:256
SystemBase & _sys
System this kernel is part of.
Definition: AuxKernel.h:166
const Real & _current_side_volume
Volume of the current side.
Definition: AuxKernel.h:211
void addPostprocessorDependencyHelper(const PostprocessorName &name) const override final
Helper for deriving classes to override to add dependencies when a Postprocessor is requested...
Definition: AuxKernel.C:216
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:214
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
const BoundaryID & _current_boundary_id
The current boundary ID.
Definition: AuxKernel.h:217
Base class for a system (of equations)
Definition: SystemBase.h:84
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:56
DenseVector< OutputData > _local_sol
for holding local solution
Definition: AuxKernel.h:240
AuxKernelTempl< Real > AuxKernel
Definition: AuxKernel.h:36
bool _bnd
true if the kernel is boundary kernel, false if it is interior kernels
Definition: AuxKernel.h:186
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
Definition: AuxKernel.h:200
virtual void compute()
Computes the value and stores it in the solution vector.
Definition: AuxKernel.C:296
Interface for objects that needs transient capabilities.
virtual ComputeValueType computeValue()=0
Compute and return the value of the aux variable.
Interface for notifications that the mesh has changed.
virtual const std::set< std::string > & getRequestedItems() override
Return a set containing the names of items requested by the object.
Definition: AuxKernel.C:193
DenseVector< OutputData > _local_re
for holding local load
Definition: AuxKernel.h:238
virtual void precalculateValue()
This callback is used for AuxKernelTempls that need to perform a per-element calculation.
Definition: AuxKernel.h:137
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:33
SystemBase & _nl_sys
Definition: AuxKernel.h:167
boundary_id_type BoundaryID
typename GenericMaterialPropertyStruct< T, is_ad >::type GenericMaterialProperty
bool isMortar()
Definition: AuxKernel.C:484
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
AuxKernelTempl(const InputParameters &parameters)
Definition: AuxKernel.C:82
const std::set< UserObjectName > & getDependObjects() const
Definition: AuxKernel.h:99
const Real & _current_elem_volume
Volume of the current element.
Definition: AuxKernel.h:209
Assembly & _assembly
Assembly class.
Definition: AuxKernel.h:183
Interface for objects that need to use UserObjects.
virtual const VariableValue & coupledDot(const std::string &var_name, unsigned int comp=0) const override
Time derivative of a coupled variable.
Definition: AuxKernel.C:243
virtual const std::set< std::string > & getSuppliedItems() override
Return a set containing the names of items owned by the object.
Definition: AuxKernel.C:200
const Elem *const & _current_lower_d_elem
The current lower dimensional element.
Definition: AuxKernel.h:223
AuxiliarySystem & _aux_sys
Definition: AuxKernel.h:168
OutputTools< Real >::VariableValue VariableValue
Definition: MooseTypes.h:302
NumericVector< Number > & _solution
reference to the solution vector of auxiliary system
Definition: AuxKernel.h:220
const MaterialProperty< T > & getMaterialPropertyOld(const std::string &name)
Definition: AuxKernel.h:306
const OutputTools< ComputeValueType >::VariableValue & uOld() const
Retrieves the old value of the variable that this AuxKernel operates on.
Definition: AuxKernel.C:458
void insert()
Insert the just computed values into the auxiliary solution vector.
Definition: AuxKernel.C:286
MooseVariableField< ComputeValueType > & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: AuxKernel.h:174
void addVectorPostprocessorDependencyHelper(const VectorPostprocessorName &name) const override final
Helper for deriving classes to override to add dependencies when a VectorPostprocessor is requested...
Definition: AuxKernel.C:224
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
const QBase *const & _qrule
Quadrature rule being used.
Definition: AuxKernel.h:198
An interface for accessing Materials.
const MaterialProperty< T > & getMaterialPropertyOlder(const std::string &name)
Definition: AuxKernel.h:323
Moose::DOFType< ComputeValueType >::type OutputData
Definition: AuxKernel.h:235
std::set< UserObjectName > _depend_uo
Depend UserObjects.
Definition: AuxKernel.h:266
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
Interface for objects that need to get values of MooseVariables.
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
const MaterialProperty< T > & getMaterialProperty(const std::string &name)
Override functions from MaterialPropertyInterface for error checking.
Definition: AuxKernel.h:272
Interface for sorting dependent vectors of objects.
SubProblem & _subproblem
Subproblem this kernel is part of.
Definition: AuxKernel.h:164
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:204
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:230
const InputParameters & parameters() const
Get the parameters of the object.
DenseMatrix< Number > _local_ke
for holding local mass matrix
Definition: AuxKernel.h:242
void addUserObjectDependencyHelper(const UserObject &uo) const override final
Helper for deriving classes to override to add dependencies when a UserObject is requested.
Definition: AuxKernel.C:207
const OutputTools< ComputeValueType >::VariableTestValue & _test
Dimension of the problem being solved.
Definition: AuxKernel.h:193
static InputParameters validParams()
Definition: AuxKernel.C:27
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:36
const bool & _check_boundary_restricted
Whether or not to check for repeated element sides on the sideset to which the auxkernel is restricte...
Definition: AuxKernel.h:161
virtual const VariableValue & coupledDotDu(const std::string &var_name, unsigned int comp=0) const override
Time derivative of a coupled variable with respect to the coefficients.
Definition: AuxKernel.C:256
void setDofValueHelper(const ComputeValueType &dof_value)
Currently only used when the auxiliary variable is a finite volume variable, this helps call through ...
std::set< std::string > _depend_vars
Depend AuxKernelTempls.
Definition: AuxKernel.h:262
const MooseArray< Point > & _q_point
Active quadrature points.
Definition: AuxKernel.h:196
void coupledCallback(const std::string &var_name, bool is_old) const override
A call-back function provided by the derived object for actions before coupling a variable with funct...
Definition: AuxKernel.C:232
std::set< std::string > _supplied_vars
Definition: AuxKernel.h:263
AuxKernelTempl< RealEigenVector > ArrayAuxKernel
Definition: AuxKernel.h:40
Interface for objects that need to use functions.
A system that holds auxiliary variables.
Base class for user-specific data.
Definition: UserObject.h:39
bool isNodal() const
Nodal or elemental kernel?
Definition: AuxKernel.h:86
unsigned int _n_local_dofs
number of local dofs for elemental variables
Definition: AuxKernel.h:233
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:198
const bool _coincident_lower_d_calc
Whether we are computing for a lower dimensional variable using boundary restriction, e.g.
Definition: AuxKernel.h:227
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty(const std::string &name)
Definition: AuxKernel.h:289