www.mooseframework.org
AuxKernel.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef AUXKERNEL_H
16 #define AUXKERNEL_H
17 
18 #include "MooseObject.h"
19 #include "MooseVariable.h" // for name() in mooseError calls
20 #include "SetupInterface.h"
23 #include "FunctionInterface.h"
24 #include "UserObjectInterface.h"
25 #include "TransientInterface.h"
26 #include "PostprocessorInterface.h"
28 #include "RandomInterface.h"
30 #include "BlockRestrictable.h"
31 #include "BoundaryRestrictable.h"
32 #include "Restartable.h"
33 #include "ZeroInterface.h"
34 #include "MeshChangedInterface.h"
36 
37 // forward declarations
38 class SubProblem;
39 class AuxKernel;
40 class AuxiliarySystem;
41 class SystemBase;
42 class MooseMesh;
43 
44 template <>
46 
51 class AuxKernel : public MooseObject,
52  public BlockRestrictable,
53  public BoundaryRestrictable,
54  public SetupInterface,
56  public FunctionInterface,
57  public UserObjectInterface,
58  public TransientInterface,
62  public RandomInterface,
63  protected GeometricSearchInterface,
64  public Restartable,
65  public ZeroInterface,
66  public MeshChangedInterface,
68 {
69 public:
71 
72  virtual ~AuxKernel();
73 
77  virtual void compute();
78 
83  MooseVariable & variable() { return _var; }
84 
89  bool isNodal() { return _nodal; }
90 
91  const std::set<std::string> & getDependObjects() const { return _depend_uo; }
92 
93  void coupledCallback(const std::string & var_name, bool is_old) override;
94 
95  virtual const std::set<std::string> & getRequestedItems() override;
96 
97  virtual const std::set<std::string> & getSuppliedItems() override;
98 
102  template <typename T>
103  const MaterialProperty<T> & getMaterialProperty(const std::string & name);
104  template <typename T>
105  const MaterialProperty<T> & getMaterialPropertyOld(const std::string & name);
106  template <typename T>
107  const MaterialProperty<T> & getMaterialPropertyOlder(const std::string & name);
108 
109  template <typename T>
110  const T & getUserObject(const std::string & name);
111  template <typename T>
112  const T & getUserObjectByName(const UserObjectName & name);
113 
114  const UserObject & getUserObjectBase(const std::string & name);
115 
116  virtual const PostprocessorValue & getPostprocessorValue(const std::string & name);
117  virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName & name);
118 
119  virtual const VectorPostprocessorValue &
120  getVectorPostprocessorValue(const std::string & name, const std::string & vector_name) override;
121  virtual const VectorPostprocessorValue &
122  getVectorPostprocessorValueByName(const VectorPostprocessorName &,
123  const std::string & vector_name) override;
124 
125 protected:
126  virtual const VariableValue & coupledDot(const std::string & var_name,
127  unsigned int comp = 0) override;
128 
129  virtual const VariableValue & coupledDotDu(const std::string & var_name,
130  unsigned int comp = 0) override;
131 
132  virtual Real computeValue() = 0;
133 
135  virtual void precalculateValue() {}
136 
150  bool _nodal;
152  bool _bnd;
156  // unsigned int _dim;
157 
161  QBase *& _qrule;
165 
167  const VariableValue & _u;
174 
176  const Elem *& _current_elem;
178  unsigned int & _current_side;
179 
181  const Real & _current_elem_volume;
183  const Real & _current_side_volume;
184 
186  const Node *& _current_node;
187 
189  NumericVector<Number> & _solution;
190 
192  unsigned int _qp;
193 
195  std::set<std::string> _depend_vars;
196  std::set<std::string> _supplied_vars;
197 
199  std::set<std::string> _depend_uo;
200 
202  unsigned int _n_local_dofs;
203 
205  DenseVector<Number> _local_re;
207  DenseVector<Number> _local_sol;
209  DenseMatrix<Number> _local_ke;
210 };
211 
212 template <typename T>
213 const MaterialProperty<T> &
215 {
216  if (isNodal())
217  mooseError("Nodal AuxKernel '",
218  AuxKernel::name(),
219  "' attempted to reference material property '",
220  name,
221  "'\nConsider using an elemental auxiliary variable for '",
222  _var.name(),
223  "'.");
224 
225  return MaterialPropertyInterface::getMaterialProperty<T>(name);
226 }
227 
228 template <typename T>
229 const MaterialProperty<T> &
231 {
232  if (isNodal())
233  mooseError("Nodal AuxKernel '",
234  AuxKernel::name(),
235  "' attempted to reference material property '",
236  name,
237  "'\nConsider using an elemental auxiliary variable for '",
238  _var.name(),
239  "'.");
240 
241  return MaterialPropertyInterface::getMaterialPropertyOld<T>(name);
242 }
243 
244 template <typename T>
245 const MaterialProperty<T> &
247 {
248  if (isNodal())
249  mooseError("Nodal AuxKernel '",
250  AuxKernel::name(),
251  "' attempted to reference material property '",
252  name,
253  "'\nConsider using an elemental auxiliary variable for '",
254  _var.name(),
255  "'.");
256 
257  return MaterialPropertyInterface::getMaterialPropertyOlder<T>(name);
258 }
259 
260 template <typename T>
261 const T &
262 AuxKernel::getUserObject(const std::string & name)
263 {
264  _depend_uo.insert(_pars.get<UserObjectName>(name));
265  return UserObjectInterface::getUserObject<T>(name);
266 }
267 
268 template <typename T>
269 const T &
270 AuxKernel::getUserObjectByName(const UserObjectName & name)
271 {
272  _depend_uo.insert(name);
273  return UserObjectInterface::getUserObjectByName<T>(name);
274 }
275 
276 #endif // AUXKERNEL_H
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:47
AuxiliarySystem & _aux_sys
Definition: AuxKernel.h:142
Interface for objects that need parallel consistent random numbers without patterns over the course o...
virtual Real computeValue()=0
const VariableValue & _u_older
Holds the t-2 solution at the current quadrature point.
Definition: AuxKernel.h:171
SystemBase & _sys
System this kernel is part of.
Definition: AuxKernel.h:140
A class for creating restricted objects.
Definition: Restartable.h:31
DenseMatrix< Number > _local_ke
for holding local mass matrix
Definition: AuxKernel.h:209
Assembly & _assembly
Assembly class.
Definition: AuxKernel.h:146
Keeps track of stuff related to assembling.
Definition: Assembly.h:63
const MooseArray< Real > & _coord
Definition: AuxKernel.h:164
Class for stuff related to variables.
Definition: MooseVariable.h:43
const T & getUserObjectByName(const UserObjectName &name)
Definition: AuxKernel.h:270
DenseVector< Number > _local_re
for holding local load
Definition: AuxKernel.h:205
virtual void precalculateValue()
This callback is used for AuxKernels that need to perform a per-element calculation.
Definition: AuxKernel.h:135
const MaterialProperty< T > & getMaterialPropertyOlder(const std::string &name)
Definition: AuxKernel.h:246
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:266
const MooseArray< Point > & _q_point
Dimension of the problem being solved.
Definition: AuxKernel.h:159
const Elem *& _current_elem
Current element (valid only for elemental kernels)
Definition: AuxKernel.h:176
unsigned int & _current_side
current side of the current element
Definition: AuxKernel.h:178
QBase *& _qrule
Quadrature rule being used.
Definition: AuxKernel.h:161
unsigned int _n_local_dofs
number of local dofs for elemental variables
Definition: AuxKernel.h:202
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...
NumericVector< Number > & _solution
reference to the solution vector of auxiliary system
Definition: AuxKernel.h:189
const UserObject & getUserObjectBase(const std::string &name)
Definition: AuxKernel.C:151
virtual const PostprocessorValue & getPostprocessorValue(const std::string &name)
Definition: AuxKernel.C:158
virtual const VectorPostprocessorValue & getVectorPostprocessorValueByName(const VectorPostprocessorName &, const std::string &vector_name) override
Retrieve the value of the VectorPostprocessor.
Definition: AuxKernel.C:179
void coupledCallback(const std::string &var_name, bool is_old) override
Definition: AuxKernel.C:187
MooseVariable & variable()
Get a reference to a variable this kernel is action on.
Definition: AuxKernel.h:83
Base class for a system (of equations)
Definition: SystemBase.h:91
const Real & _current_elem_volume
Volume of the current element.
Definition: AuxKernel.h:181
MooseMesh & _mesh
Mesh this kernel is active on.
Definition: AuxKernel.h:154
const std::string & name() const
Get the variable name.
SystemBase & _nl_sys
Definition: AuxKernel.h:141
DenseVector< Number > _local_sol
for holding local solution
Definition: AuxKernel.h:207
virtual const std::set< std::string > & getRequestedItems() override
Return a set containing the names of items requested by the object.
Definition: AuxKernel.C:139
bool _bnd
true if the kernel is boundary kernel, false if it is interior kernels
Definition: AuxKernel.h:152
Interface for objects that needs transient capabilities.
Interface for notifications that the mesh has changed.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:36
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:30
Real PostprocessorValue
MOOSE typedefs.
Definition: MooseTypes.h:73
const Node *& _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:186
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name)
Definition: AuxKernel.C:165
virtual const std::set< std::string > & getSuppliedItems() override
Return a set containing the names of items owned by the object.
Definition: AuxKernel.C:145
bool isNodal()
Nodal or elemental kernel?
Definition: AuxKernel.h:89
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:192
Interface for objects that need to use UserObjects.
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:51
SubProblem & _subproblem
Subproblem this kernel is part of.
Definition: AuxKernel.h:138
const MaterialProperty< T > & getMaterialPropertyOld(const std::string &name)
Definition: AuxKernel.h:230
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
Definition: MooseObject.h:111
const Real & _current_side_volume
Volume of the current side.
Definition: AuxKernel.h:183
const VariableValue & _u
Holds the solution at current quadrature points.
Definition: AuxKernel.h:167
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
Definition: AuxKernel.h:163
THREAD_ID _tid
Thread ID.
Definition: AuxKernel.h:144
bool _nodal
true if the kernel is nodal, false if it is elemental
Definition: AuxKernel.h:150
const VariableTestValue & _test
holds the the test functions
Definition: AuxKernel.h:173
const std::set< std::string > & getDependObjects() const
Definition: AuxKernel.h:91
std::vector< Real > VectorPostprocessorValue
Definition: MooseTypes.h:74
virtual ~AuxKernel()
Definition: AuxKernel.C:136
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:53
Interface to bring zero values inside objects.
Definition: ZeroInterface.h:35
An interface for accessing Materials.
Concrete definition of a parameter value for a specified type.
Intermediate base class that ties together all the interfaces for getting MooseVariables with the Moo...
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:53
const MaterialProperty< T > & getMaterialProperty(const std::string &name)
Override functions from MaterialPropertyInterface for error checking.
Definition: AuxKernel.h:214
Interface for sorting dependent vectors of objects.
virtual const VectorPostprocessorValue & getVectorPostprocessorValue(const std::string &name, const std::string &vector_name) override
Retrieve the value of a VectorPostprocessor.
Definition: AuxKernel.C:172
std::set< std::string > _depend_vars
Depend AuxKernels.
Definition: AuxKernel.h:195
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
AuxKernel(const InputParameters &parameters)
Definition: AuxKernel.C:63
const T & getUserObject(const std::string &name)
Definition: AuxKernel.h:262
virtual const VariableValue & coupledDot(const std::string &var_name, unsigned int comp=0) override
Time derivative of a coupled variable.
Definition: AuxKernel.C:254
MooseVariable & _var
Variable this kernel is acting on.
Definition: AuxKernel.h:148
Interface for objects that need to use functions.
std::set< std::string > _depend_uo
Depend UserObjects.
Definition: AuxKernel.h:199
A system that holds auxiliary variables.
virtual void compute()
Computes the value and stores it in the solution vector.
Definition: AuxKernel.C:198
std::set< std::string > _supplied_vars
Definition: AuxKernel.h:196
Base class for user-specific data.
Definition: UserObject.h:42
Interface class for classes which interact with Postprocessors.
unsigned int THREAD_ID
Definition: MooseTypes.h:79
const VariableValue & _u_old
Holds the previous solution at the current quadrature point.
Definition: AuxKernel.h:169