Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
SecondTimeDerivativeAux.C
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 
11 
13 
16 {
18  params.addClassDescription("Returns the second order time derivative of the specified variable "
19  "as an auxiliary variable.");
20 
21  params.addRequiredCoupledVar("v", "Variable to take the second time derivative of");
22  params.addParam<MooseFunctorName>(
23  "factor", 1, "Factor to multiply the second time derivative by");
24 
25  return params;
26 }
27 
29  : AuxKernel(parameters),
30  _v(coupledDotDot("v")),
31  _factor(getFunctor<Real>("factor")),
32  _use_qp_arg(dynamic_cast<MooseVariableFE<Real> *>(&_var))
33 {
34  const auto v_name = coupledName("v");
35  if (_subproblem.hasVariable(v_name))
36  {
37  const auto * functor_var = &_subproblem.getVariable(_tid, v_name);
38  if (dynamic_cast<const MooseVariableFE<Real> *>(&_var) &&
39  !dynamic_cast<const MooseVariableFE<Real> *>(functor_var))
40  mooseWarning("'variable' argument is a finite element variable but 'v' is not.");
41  if (!dynamic_cast<const MooseVariableFE<Real> *>(&_var) &&
42  dynamic_cast<const MooseVariableFE<Real> *>(functor_var))
43  mooseWarning("'v' argument is a finite element variable but 'variable' is not.");
44  }
45  if (isNodal())
46  paramError("variable", "This AuxKernel only supports Elemental fields");
47 }
48 
49 Real
51 {
52  if (_use_qp_arg)
53  {
54  const Moose::ElemQpArg qp_arg = {_current_elem, _qp, _qrule, _q_point[_qp]};
55  return _factor(qp_arg, determineState()) * _v[_qp];
56  }
57  else
58  {
59  const auto elem_arg = makeElemArg(_current_elem);
60  return _factor(elem_arg, determineState()) * _v[_qp];
61  }
62 }
virtual Real computeValue() override
Compute and return the value of the aux variable.
Second time derivative of a variable.
THREAD_ID _tid
Thread ID.
Definition: AuxKernel.h:171
Class for stuff related to variables.
Definition: Adaptivity.h:31
VariableName coupledName(const std::string &var_name, unsigned int comp=0) const
Names of the variable in the Coupleable interface.
Definition: Coupleable.C:2484
const Moose::Functor< Real > & _factor
Factor to multiply the second time derivative with.
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
Helper method to create an elemental argument for a functor that includes whether to perform skewness...
registerMooseObject("MooseApp", SecondTimeDerivativeAux)
const VariableValue & _v
Variable we&#39;re computing the second time derivative of.
const bool _use_qp_arg
Whether to use a quadrature-based functor argument, appropriate for finite element evaluations...
Argument for requesting functor evaluation at a quadrature point location in an element.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
SecondTimeDerivativeAux(const InputParameters &parameters)
virtual bool hasVariable(const std::string &var_name) const =0
Whether or not this problem has the variable.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
MooseVariableField< Real > & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: AuxKernel.h:174
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
Quadrature rule being used.
Definition: AuxKernel.h:198
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
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
static InputParameters validParams()
Definition: AuxKernel.C:27
const MooseArray< Point > & _q_point
Active quadrature points.
Definition: AuxKernel.h:196
static InputParameters validParams()
bool isNodal() const
Nodal or elemental kernel?
Definition: AuxKernel.h:86