https://mooseframework.inl.gov
Function.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 "FunctionBase.h"
13 #include "MooseFunctor.h"
14 #include "ChainedReal.h"
15 
16 // libMesh
17 #include "libmesh/vector_value.h"
18 
19 // libMesh forward declarations
20 namespace libMesh
21 {
22 class Point;
23 }
24 
29 class Function : public Moose::FunctionBase, public Moose::FunctorBase<Real>
30 {
31 public:
37 
39 
43  virtual ~Function();
44 
52  virtual Real value(Real t, const Point & p) const;
53 
62  virtual ADReal value(const ADReal & t, const ADPoint & p) const;
63 
65  ChainedReal value(const ChainedReal & t) const;
66  template <typename U>
67  auto value(const U & t) const;
68  template <typename U>
69  auto value(const U & t, const U & x, const U & y = 0, const U & z = 0) const;
71 
79  virtual RealVectorValue vectorValue(Real t, const Point & p) const;
80 
88  virtual RealVectorValue curl(Real t, const Point & p) const;
89 
97  virtual Real div(Real t, const Point & p) const;
98 
107  virtual RealGradient gradient(Real t, const Point & p) const;
108 
115  virtual Real timeDerivative(Real t, const Point & p) const;
116 
118  template <typename U>
119  auto timeDerivative(const U & t) const;
120  template <typename U>
121  auto timeDerivative(const U & t, const U & x, const U & y = 0, const U & z = 0) const;
123 
125  virtual Real integral() const;
126 
128  virtual Real average() const;
129 
137  virtual Real timeIntegral(Real t1, Real t2, const Point & p) const;
138 
139  void timestepSetup() override;
140  // We will only allow initialSetup() and timestepSetup() to be overriden
141  void residualSetup() override final;
142  void jacobianSetup() override final;
143  void customSetup(const ExecFlagType & exec_type) override final;
144 
145  bool hasBlocks(SubdomainID) const override { return true; }
146 
147  bool supportsFaceArg() const override final { return true; }
148  bool supportsElemSideQpArg() const override final { return true; }
149 
150 private:
153  using typename Moose::FunctorBase<Real>::DotType;
154 
161 
162  template <typename R>
163  ValueType evaluateHelper(const R & r, const Moose::StateArg & state) const;
164 
165  ValueType evaluate(const ElemArg & elem, const Moose::StateArg & state) const override final;
166  ValueType evaluate(const FaceArg & face, const Moose::StateArg & state) const override final;
167  ValueType evaluate(const ElemQpArg & qp, const Moose::StateArg & state) const override final;
168  ValueType evaluate(const ElemSideQpArg & elem_side_qp,
169  const Moose::StateArg & state) const override final;
170  ValueType evaluate(const ElemPointArg & elem_point,
171  const Moose::StateArg & state) const override final;
172  ValueType evaluate(const NodeArg & node, const Moose::StateArg & state) const override final;
173 
174  template <typename R>
175  GradientType evaluateGradientHelper(const R & r, const Moose::StateArg & state) const;
176 
178  const Moose::StateArg & state) const override final;
180  const Moose::StateArg & state) const override final;
182  const Moose::StateArg & state) const override final;
183  GradientType evaluateGradient(const ElemSideQpArg & elem_side_qp,
184  const Moose::StateArg & state) const override final;
185  GradientType evaluateGradient(const ElemPointArg & elem_point,
186  const Moose::StateArg & state) const override final;
188  const Moose::StateArg & state) const override final;
189 
190  template <typename R>
191  DotType evaluateDotHelper(const R & r, const Moose::StateArg & state) const;
192  DotType evaluateDot(const ElemArg & elem, const Moose::StateArg & state) const override final;
193  DotType evaluateDot(const FaceArg & face, const Moose::StateArg & state) const override final;
194  DotType evaluateDot(const ElemQpArg & qp, const Moose::StateArg & state) const override final;
195  DotType evaluateDot(const ElemSideQpArg & elem_side_qp,
196  const Moose::StateArg & state) const override final;
197  DotType evaluateDot(const ElemPointArg & elem_point,
198  const Moose::StateArg & state) const override final;
199  DotType evaluateDot(const NodeArg & node, const Moose::StateArg & state) const override final;
200 };
201 
202 template <typename U>
203 auto
204 Function::value(const U & t) const
205 {
207  return value(t, p);
208 }
209 
210 template <typename U>
211 auto
212 Function::value(const U & t, const U & x, const U & y, const U & z) const
213 {
215  return value(t, p);
216 }
217 
218 template <typename U>
219 auto
220 Function::timeDerivative(const U & t) const
221 {
223  return timeDerivative(t, p);
224 }
225 
226 template <typename U>
227 auto
228 Function::timeDerivative(const U & t, const U & x, const U & y, const U & z) const
229 {
231  return timeDerivative(t, p);
232 }
Base class for function objects.
Definition: Function.h:29
Base class template for functor objects.
Definition: MooseFunctor.h:137
virtual Real timeIntegral(Real t1, Real t2, const Point &p) const
Computes the time integral at a spatial point between two time values.
Definition: Function.C:76
virtual Real div(Real t, const Point &p) const
Override this to evaluate the divergence of the vector function at a point (t,x,y,z), by default this returns zero, you must override it.
Definition: Function.C:96
DotType evaluateDotHelper(const R &r, const Moose::StateArg &state) const
Definition: Function.C:222
virtual RealVectorValue curl(Real t, const Point &p) const
Override this to evaluate the curl of the vector function at a point (t,x,y,z), by default this retur...
Definition: Function.C:89
virtual Real timeDerivative(Real t, const Point &p) const
Get the time derivative of the function.
Definition: Function.C:69
DualNumber< Real, Real > ChainedReal
Definition: ChainedReal.h:30
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
A structure that is used to evaluate Moose functors at an arbitrary physical point contained within a...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void residualSetup() override final
Definition: Function.C:270
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:42
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
Definition: Function.h:148
typename FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type GradientType
This rigmarole makes it so that a user can create functors that return containers (std::vector...
Definition: MooseFunctor.h:149
typename std::conditional< is_ad, typename ADType< T >::type, T >::type GenericType
Definition: MooseTypes.h:689
Function(const InputParameters &parameters)
Definition: Function.C:22
virtual Real average() const
Returns the average of the function over its domain.
Definition: Function.C:110
A structure defining a "face" evaluation calling argument for Moose functors.
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
Definition: Function.h:147
A structure that is used to evaluate Moose functors logically at an element/cell center.
Argument for requesting functor evaluation at a quadrature point location in an element.
void jacobianSetup() override final
Definition: Function.C:276
void customSetup(const ExecFlagType &exec_type) override final
Definition: Function.C:282
void timestepSetup() override
Definition: Function.C:264
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
GradientType evaluateGradientHelper(const R &r, const Moose::StateArg &state) const
Definition: Function.C:179
ValueType evaluate(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor with a given element.
Definition: Function.C:124
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
virtual RealGradient gradient(Real t, const Point &p) const
Function objects can optionally provide a gradient at a point.
Definition: Function.C:62
DotType evaluateDot(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor time derivative with a given element.
Definition: Function.C:228
virtual RealVectorValue vectorValue(Real t, const Point &p) const
Override this to evaluate the vector function at a point (t,x,y,z), by default this returns a zero ve...
Definition: Function.C:82
virtual Real integral() const
Returns the integral of the function over its domain.
Definition: Function.C:103
State argument for evaluating functors.
virtual ~Function()
Function destructor.
Definition: Function.C:27
bool hasBlocks(SubdomainID) const override
Returns whether the functor is defined on this block.
Definition: Function.h:145
virtual Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:30
GradientType evaluateGradient(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor gradient with a given element.
Definition: Function.C:185
static InputParameters validParams()
Class constructor.
Definition: Function.C:16
Argument for requesting functor evaluation at quadrature point locations on an element side...
ValueType evaluateHelper(const R &r, const Moose::StateArg &state) const
Definition: Function.C:118