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 
31 // forward declarations
32 template <typename ComputeValueType>
34 
37 
38 class SubProblem;
39 class AuxiliarySystem;
40 class SystemBase;
41 class MooseMesh;
42 
43 template <>
45 
46 template <>
48 
53 template <typename ComputeValueType>
54 class AuxKernelTempl : public MooseObject,
55  public MooseVariableInterface<ComputeValueType>,
56  public BlockRestrictable,
57  public BoundaryRestrictable,
58  public SetupInterface,
60  public FunctionInterface,
61  public UserObjectInterface,
62  public TransientInterface,
66  public RandomInterface,
67  protected GeometricSearchInterface,
68  public Restartable,
69  public MeshChangedInterface,
71 {
72 public:
74 
78  virtual void compute();
79 
84  bool isNodal() { return _nodal; }
85 
91 
92  const std::set<std::string> & getDependObjects() const { return _depend_uo; }
93 
94  void coupledCallback(const std::string & var_name, bool is_old) override;
95 
96  virtual const std::set<std::string> & getRequestedItems() override;
97 
98  virtual const std::set<std::string> & getSuppliedItems() override;
99 
103  template <typename T>
104  const MaterialProperty<T> & getMaterialProperty(const std::string & name);
105  template <typename T>
106  const MaterialProperty<T> & getMaterialPropertyOld(const std::string & name);
107  template <typename T>
108  const MaterialProperty<T> & getMaterialPropertyOlder(const std::string & name);
109 
110  template <typename T>
111  const T & getUserObject(const std::string & name);
112  template <typename T>
113  const T & getUserObjectByName(const UserObjectName & name);
114 
115  const UserObject & getUserObjectBase(const std::string & name);
116 
117  virtual const PostprocessorValue & getPostprocessorValue(const std::string & name);
118  virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName & name);
119 
120  virtual const VectorPostprocessorValue &
121  getVectorPostprocessorValue(const std::string & name, const std::string & vector_name) override;
122  virtual const VectorPostprocessorValue &
123  getVectorPostprocessorValueByName(const VectorPostprocessorName &,
124  const std::string & vector_name) override;
125 
127  const std::string & name, const std::string & vector_name, bool needs_broadcast) override;
128  virtual const VectorPostprocessorValue &
129  getVectorPostprocessorValueByName(const VectorPostprocessorName &,
130  const std::string & vector_name,
131  bool needs_broadcast) override;
132 
133  virtual const ScatterVectorPostprocessorValue &
134  getScatterVectorPostprocessorValue(const std::string & name,
135  const std::string & vector_name) override;
136 
137  virtual const ScatterVectorPostprocessorValue &
139  const std::string & vector_name) override;
140 
141 protected:
145  virtual ComputeValueType computeValue() = 0;
146 
147  virtual const VariableValue & coupledDot(const std::string & var_name,
148  unsigned int comp = 0) override;
149 
150  virtual const VariableValue & coupledDotDu(const std::string & var_name,
151  unsigned int comp = 0) override;
152 
154  virtual void precalculateValue() {}
155 
162 
165 
168 
170  bool _nodal;
171 
174 
177 
180 
183 
186 
188  bool _bnd;
192  // unsigned int _dim;
193 
197  const QBase * const & _qrule;
201 
203  const Elem * const & _current_elem;
205  const unsigned int & _current_side;
206 
208  const Real & _current_elem_volume;
210  const Real & _current_side_volume;
211 
213  const Node * const & _current_node;
214 
216  NumericVector<Number> & _solution;
217 
219  unsigned int _qp;
220 
222  std::set<std::string> _depend_vars;
223  std::set<std::string> _supplied_vars;
224 
226  std::set<std::string> _depend_uo;
227 
229  unsigned int _n_local_dofs;
230 
232  DenseVector<Number> _local_re;
234  DenseVector<Number> _local_sol;
236  DenseMatrix<Number> _local_ke;
237 
239 };
240 
241 template <typename ComputeValueType>
242 template <typename T>
243 const MaterialProperty<T> &
245 {
246  if (isNodal())
247  mooseError("Nodal AuxKernel '",
249  "' attempted to reference material property '",
250  name,
251  "'\nConsider using an elemental auxiliary variable for '",
252  _var.name(),
253  "'.");
254 
255  return MaterialPropertyInterface::getMaterialProperty<T>(name);
256 }
257 
258 template <typename ComputeValueType>
259 template <typename T>
260 const MaterialProperty<T> &
262 {
263  if (isNodal())
264  mooseError("Nodal AuxKernel '",
266  "' attempted to reference material property '",
267  name,
268  "'\nConsider using an elemental auxiliary variable for '",
269  _var.name(),
270  "'.");
271 
272  return MaterialPropertyInterface::getMaterialPropertyOld<T>(name);
273 }
274 
275 template <typename ComputeValueType>
276 template <typename T>
277 const MaterialProperty<T> &
279 {
280  if (isNodal())
281  mooseError("Nodal AuxKernel '",
283  "' attempted to reference material property '",
284  name,
285  "'\nConsider using an elemental auxiliary variable for '",
286  _var.name(),
287  "'.");
288 
289  return MaterialPropertyInterface::getMaterialPropertyOlder<T>(name);
290 }
291 
292 template <typename ComputeValueType>
293 template <typename T>
294 const T &
296 {
297  _depend_uo.insert(_pars.get<UserObjectName>(name));
298  return UserObjectInterface::getUserObject<T>(name);
299 }
300 
301 template <typename ComputeValueType>
302 template <typename T>
303 const T &
305 {
306  _depend_uo.insert(name);
307  return UserObjectInterface::getUserObjectByName<T>(name);
308 }
309 
Interface for objects that need parallel consistent random numbers without patterns over the course o...
MooseVariableFE< ComputeValueType > & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: AuxKernel.h:167
const OutputTools< ComputeValueType >::VariableValue & _u
Holds the solution at current quadrature points.
Definition: AuxKernel.h:173
const T & getUserObjectByName(const UserObjectName &name)
Definition: AuxKernel.h:304
AuxKernelTempl< RealVectorValue > VectorAuxKernel
Definition: AuxKernel.h:36
A class for creating restricted objects.
Definition: Restartable.h:29
DenseVector< Number > _local_re
for holding local load
Definition: AuxKernel.h:232
const T & getUserObject(const std::string &name)
Definition: AuxKernel.h:295
bool _nodal
Flag indicating if the AuxKernel is nodal.
Definition: AuxKernel.h:170
THREAD_ID _tid
Thread ID.
Definition: AuxKernel.h:164
const OutputTools< ComputeValueType >::VariableValue & _u_older
Holds the t-2 solution at the current quadrature point.
Definition: AuxKernel.h:179
const MooseArray< Real > & _coord
Definition: AuxKernel.h:200
Keeps track of stuff related to assembling.
Definition: Assembly.h:62
const unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:205
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:190
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
SystemBase & _sys
System this kernel is part of.
Definition: AuxKernel.h:159
const Real & _current_side_volume
Volume of the current side.
Definition: AuxKernel.h:210
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:213
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 OutputTools< ComputeValueType >::VariableValue & _u_old
Holds the previous solution at the current quadrature point.
Definition: AuxKernel.h:176
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:181
Base class for a system (of equations)
Definition: SystemBase.h:92
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:263
AuxKernelTempl< Real > AuxKernel
Definition: AuxKernel.h:33
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:220
virtual const PostprocessorValue & getPostprocessorValue(const std::string &name)
Definition: AuxKernel.C:165
virtual const VariableValue & coupledDot(const std::string &var_name, unsigned int comp=0) override
Time derivative of a coupled variable.
Definition: AuxKernel.C:250
bool _bnd
true if the kernel is boundary kernel, false if it is interior kernels
Definition: AuxKernel.h:188
void coupledCallback(const std::string &var_name, bool is_old) override
Definition: AuxKernel.C:238
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
Definition: AuxKernel.h:199
virtual void compute()
Computes the value and stores it in the solution vector.
Definition: AuxKernel.C:276
Interface for objects that needs transient capabilities.
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name)
Definition: AuxKernel.C:173
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:143
virtual void precalculateValue()
This callback is used for AuxKernelTempls that need to perform a per-element calculation.
Definition: AuxKernel.h:154
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:65
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:229
SystemBase & _nl_sys
Definition: AuxKernel.h:160
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:25
Real PostprocessorValue
MOOSE typedefs.
Definition: MooseTypes.h:154
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
AuxKernelTempl(const InputParameters &parameters)
Definition: AuxKernel.C:71
bool isNodal()
Nodal or elemental kernel?
Definition: AuxKernel.h:84
const Real & _current_elem_volume
Volume of the current element.
Definition: AuxKernel.h:208
Assembly & _assembly
Assembly class.
Definition: AuxKernel.h:185
Interface for objects that need to use UserObjects.
DenseVector< Number > _local_sol
for holding local solution
Definition: AuxKernel.h:234
virtual const std::set< std::string > & getSuppliedItems() override
Return a set containing the names of items owned by the object.
Definition: AuxKernel.C:150
InputParameters validParams< VectorAuxKernel >()
Definition: AuxKernel.C:63
AuxiliarySystem & _aux_sys
Definition: AuxKernel.h:161
OutputTools< Real >::VariableValue VariableValue
Definition: MooseTypes.h:197
std::vector< Real > VectorPostprocessorValue
Definition: MooseTypes.h:155
Real ScatterVectorPostprocessorValue
Definition: MooseTypes.h:156
NumericVector< Number > & _solution
reference to the solution vector of auxiliary system
Definition: AuxKernel.h:216
const MaterialProperty< T > & getMaterialPropertyOld(const std::string &name)
Definition: AuxKernel.h:261
MooseVariableFE< ComputeValueType > & variable()
Get a reference to a variable this kernel is action on.
Definition: AuxKernel.h:90
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:59
const QBase *const & _qrule
Quadrature rule being used.
Definition: AuxKernel.h:197
An interface for accessing Materials.
const std::set< std::string > & getDependObjects() const
Definition: AuxKernel.h:92
const UserObject & getUserObjectBase(const std::string &name)
Definition: AuxKernel.C:157
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:190
const MaterialProperty< T > & getMaterialPropertyOlder(const std::string &name)
Definition: AuxKernel.h:278
Concrete definition of a parameter value for a specified type.
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:244
Interface for sorting dependent vectors of objects.
SubProblem & _subproblem
Subproblem this kernel is part of.
Definition: AuxKernel.h:157
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:59
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:203
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:219
DenseMatrix< Number > _local_ke
for holding local mass matrix
Definition: AuxKernel.h:236
const OutputTools< ComputeValueType >::VariableTestValue & _test
Holds the the test functions.
Definition: AuxKernel.h:182
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:33
std::set< std::string > _depend_vars
Depend AuxKernelTempls.
Definition: AuxKernel.h:222
const MooseArray< Point > & _q_point
Dimension of the problem being solved.
Definition: AuxKernel.h:195
std::set< std::string > _depend_uo
Depend UserObjects.
Definition: AuxKernel.h:226
std::set< std::string > _supplied_vars
Definition: AuxKernel.h:223
Interface for objects that need to use functions.
A system that holds auxiliary variables.
Base class for user-specific data.
Definition: UserObject.h:37
unsigned int _n_local_dofs
number of local dofs for elemental variables
Definition: AuxKernel.h:229
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:161