https://mooseframework.inl.gov
Loading...
Searching...
No Matches
AuxKernel.h
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#pragma once
11
12#include "AuxKernelBase.h"
14
15// forward declarations
16template <typename ComputeValueType>
17class AuxKernelTempl;
18
22
26template <typename ComputeValueType>
27class AuxKernelTempl : public AuxKernelBase, public MooseVariableInterface<ComputeValueType>
28{
29public:
31
33
37 virtual void compute() override;
38
43 bool isNodal() const { return _nodal; }
44
48 bool isMortar();
49
55
59 template <typename T>
60 const MaterialProperty<T> & getMaterialProperty(const std::string & name);
61 template <typename T, bool is_ad>
63 template <typename T>
64 const MaterialProperty<T> & getMaterialPropertyOld(const std::string & name);
65 template <typename T>
67
71 void insert();
72
77
79 virtual std::set<MooseVariableFieldBase *>
80 checkVariables(const libMesh::Node & node,
81 const std::set<MooseVariableFieldBase *> & vars_to_check) override;
82
83protected:
87 virtual ComputeValueType computeValue() = 0;
88
89 virtual const VariableValue & coupledDot(const std::string & var_name,
90 unsigned int comp = 0) const override;
91
92 virtual const VariableValue & coupledDotDu(const std::string & var_name,
93 unsigned int comp = 0) const override;
94
96 virtual void precalculateValue() {}
97
103 const typename OutputTools<ComputeValueType>::VariableValue & uOld() const;
104
111
114
116 const bool _nodal;
117
120
123
127 const QBase * const & _qrule;
131
133 const Elem * const & _current_elem;
135 const unsigned int & _current_side;
136
141
143 const Node * const & _current_node;
144
147
149 NumericVector<Number> & _solution;
150
152 const Elem * const & _current_lower_d_elem;
153
155 unsigned int _qp;
156
158 unsigned int _n_shapes;
159
161
163 DenseVector<OutputData> _local_re;
165 DenseVector<OutputData> _local_sol;
167 DenseMatrix<Number> _local_ke;
168
171 std::optional<bool> _coincident_lower_d_calc;
172
173 using MooseVariableInterface<ComputeValueType>::mooseVariableBase;
174
175private:
183 void setDofValueHelper(const ComputeValueType & dof_value);
184};
185
186template <typename ComputeValueType>
187template <typename T>
190{
191 if (isNodal())
192 mooseError("Nodal AuxKernel '",
194 "' attempted to reference material property '",
195 name,
196 "'\nConsider using an elemental auxiliary variable for '",
197 _var.name(),
198 "'.");
199
200 return MaterialPropertyInterface::getMaterialProperty<T>(name);
201}
202
203template <typename ComputeValueType>
204template <typename T, bool is_ad>
207{
208 if (isNodal())
209 mooseError("Nodal AuxKernel '",
211 "' attempted to reference material property '",
212 name,
213 "'\nConsider using an elemental auxiliary variable for '",
214 _var.name(),
215 "'.");
216
217 return MaterialPropertyInterface::getGenericMaterialProperty<T, is_ad>(name);
218}
219
220template <typename ComputeValueType>
221template <typename T>
224{
225 if (isNodal())
226 mooseError("Nodal AuxKernel '",
228 "' attempted to reference material property '",
229 name,
230 "'\nConsider using an elemental auxiliary variable for '",
231 _var.name(),
232 "'.");
233
234 return MaterialPropertyInterface::getMaterialPropertyOld<T>(name);
235}
236
237template <typename ComputeValueType>
238template <typename T>
241{
242 if (isNodal())
243 mooseError("Nodal AuxKernel '",
245 "' attempted to reference material property '",
246 name,
247 "'\nConsider using an elemental auxiliary variable for '",
248 _var.name(),
249 "'.");
250
251 return MaterialPropertyInterface::getMaterialPropertyOlder<T>(name);
252}
253
254// Declare all the specializations, as the template specialization declaration below must know
255template <>
256void AuxKernelTempl<Real>::setDofValueHelper(const Real & value);
257template <>
258void AuxKernelTempl<RealVectorValue>::setDofValueHelper(const RealVectorValue &);
259template <>
261
262// Prevent implicit instantiation in other translation units where these classes are used
263extern template class AuxKernelTempl<Real>;
264extern template class AuxKernelTempl<RealVectorValue>;
265extern template class AuxKernelTempl<RealEigenVector>;
boundary_id_type BoundaryID
AuxKernelTempl< Real > AuxKernel
Definition AuxKernel.h:19
AuxKernelTempl< RealVectorValue > VectorAuxKernel
Definition AuxKernel.h:20
AuxKernelTempl< RealEigenVector > ArrayAuxKernel
Definition AuxKernel.h:21
typename GenericMaterialPropertyStruct< T, is_ad >::type GenericMaterialProperty
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
OutputTools< Real >::VariableValue VariableValue
Definition MooseTypes.h:348
Base class for auxiliary kernels.
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition AuxKernel.h:28
virtual void precalculateValue()
This callback is used for AuxKernelTempls that need to perform a per-element calculation.
Definition AuxKernel.h:96
std::optional< bool > _coincident_lower_d_calc
Whether we are computing for a lower dimensional variable using boundary restriction,...
Definition AuxKernel.h:171
void insert()
Insert the just computed values into the auxiliary solution vector.
Definition AuxKernel.C:131
bool isNodal() const
Nodal or elemental kernel?
Definition AuxKernel.h:43
const OutputTools< ComputeValueType >::VariableTestValue & _test
Holds the the test functions.
Definition AuxKernel.h:122
virtual ComputeValueType computeValue()=0
Compute and return the value of the aux variable.
DenseMatrix< Number > _local_ke
for holding local mass matrix
Definition AuxKernel.h:167
const OutputTools< ComputeValueType >::VariableValue & uOld() const
Retrieves the old value of the variable that this AuxKernel operates on.
Definition AuxKernel.C:297
const Elem *const & _current_lower_d_elem
The current lower dimensional element.
Definition AuxKernel.h:152
const MooseArray< Point > & _q_point
Active quadrature points.
Definition AuxKernel.h:125
virtual void compute() override
Computes the value and stores it in the solution vector.
Definition AuxKernel.C:143
DenseVector< OutputData > _local_sol
for holding local solution
Definition AuxKernel.h:165
void determineWhetherCoincidentLowerDCalc()
Determines whether we're a coincident lower-d calculation.
Definition AuxKernel.C:330
const MaterialProperty< T > & getMaterialPropertyOlder(const std::string &name)
Definition AuxKernel.h:240
const Real & _current_elem_volume
Volume of the current element.
Definition AuxKernel.h:138
const Real & _current_side_volume
Volume of the current side.
Definition AuxKernel.h:140
DenseVector< OutputData > _local_re
for holding local load
Definition AuxKernel.h:163
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition AuxKernel.h:133
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:101
const MaterialProperty< T > & getMaterialProperty(const std::string &name)
Override functions from MaterialPropertyInterface for error checking.
Definition AuxKernel.h:189
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition AuxKernel.h:143
const OutputTools< ComputeValueType >::VariableValue & _u
Holds the solution at current quadrature points.
Definition AuxKernel.h:119
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty(const std::string &name)
Definition AuxKernel.h:206
const bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition AuxKernel.h:116
virtual const VariableValue & coupledDot(const std::string &var_name, unsigned int comp=0) const override
Time derivative of a coupled variable.
Definition AuxKernel.C:88
const MooseArray< Real > & _coord
Definition AuxKernel.h:130
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
Definition AuxKernel.h:129
const unsigned int & _current_side
current side of the current element
Definition AuxKernel.h:135
unsigned int _n_shapes
number of shape functions for the finite element type and current DofObject
Definition AuxKernel.h:158
unsigned int _qp
Quadrature point index.
Definition AuxKernel.h:155
MooseVariableField< ComputeValueType > & _var
This is a regular kernel so we cast to a regular MooseVariable, hides base _var.
Definition AuxKernel.h:113
bool isMortar()
Definition AuxKernel.C:323
const QBase *const & _qrule
Quadrature rule being used.
Definition AuxKernel.h:127
MooseVariableField< ComputeValueType > & variable()
Get a reference to a variable this kernel is action on.
Definition AuxKernel.h:54
void setDofValueHelper(const ComputeValueType &dof_value)
Currently only used when the auxiliary variable is a finite volume variable, this helps call through ...
const OutputTools< ComputeValueType >::VariableValue & uOlder() const
Retrieves the older value of the variable that this AuxKernel operates on.
Definition AuxKernel.C:310
const MaterialProperty< T > & getMaterialPropertyOld(const std::string &name)
Definition AuxKernel.h:223
Moose::DOFType< ComputeValueType >::type OutputData
Definition AuxKernel.h:160
virtual std::set< MooseVariableFieldBase * > checkVariables(const libMesh::Node &node, const std::set< MooseVariableFieldBase * > &vars_to_check) override
Check whether all of the supplied variables have degree of freedom indices on the supplied node.
Definition AuxKernel.C:357
const BoundaryID & _current_boundary_id
The current boundary ID.
Definition AuxKernel.h:146
static InputParameters validParams()
Definition AuxKernel.C:27
NumericVector< Number > & _solution
reference to the solution vector of auxiliary system
Definition AuxKernel.h:149
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
forward declarations
Definition MooseArray.h:18
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
virtual std::set< MooseVariableFieldBase * > checkVariables(const libMesh::Node &node, const std::set< MooseVariableFieldBase * > &vars_to_check)
Check whether all of the supplied variables have degree of freedom indices on the supplied node.
Class for stuff related to variables.
Interface for objects that need to get values of MooseVariables.
MooseVariableBase * mooseVariableBase() const
Get the variable that this object is using.
OutputType type
Definition MooseTypes.h:302