https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
20namespace libMesh
21{
22class Point;
23}
24
30{
31public:
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
150private:
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
202template <typename U>
203auto
204Function::value(const U & t) const
205{
207 return value(t, p);
208}
209
210template <typename U>
211auto
212Function::value(const U & t, const U & x, const U & y, const U & z) const
213{
215 return value(t, p);
216}
217
218template <typename U>
219auto
220Function::timeDerivative(const U & t) const
221{
223 return timeDerivative(t, p);
224}
225
226template <typename U>
227auto
228Function::timeDerivative(const U & t, const U & x, const U & y, const U & z) const
229{
231 return timeDerivative(t, p);
232}
DualNumber< Real, DNDerivativeType, true > ADReal
DualNumber< Real, Real > ChainedReal
Definition ChainedReal.h:30
Base class for function objects.
Definition Function.h:30
virtual Real integral() const
Returns the integral of the function over its domain.
Definition Function.C:103
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
static InputParameters validParams()
Class constructor.
Definition Function.C:16
virtual RealGradient gradient(Real t, const Point &p) const
Function objects can optionally provide a gradient at a point.
Definition Function.C:62
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
void residualSetup() override final
Gets called just before the residual is computed and before this object is asked to do its job.
Definition Function.C:270
void customSetup(const ExecFlagType &exec_type) override final
Gets called in FEProblemBase::execute() for execute flags other than initial, timestep_begin,...
Definition Function.C:282
virtual ~Function()
Function destructor.
Definition Function.C:27
DotType evaluateDotHelper(const R &r, const Moose::StateArg &state) const
Definition Function.C:222
ValueType evaluateHelper(const R &r, const Moose::StateArg &state) const
Definition Function.C:118
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 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
ValueType evaluate(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor with a given element.
Definition Function.C:124
virtual Real timeDerivative(Real t, const Point &p) const
Get the time derivative of the function.
Definition Function.C:69
GradientType evaluateGradient(const ElemArg &elem, const Moose::StateArg &state) const override final
Evaluate the functor gradient with a given element.
Definition Function.C:185
GradientType evaluateGradientHelper(const R &r, const Moose::StateArg &state) const
Definition Function.C:179
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
Definition Function.h:147
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,...
Definition Function.C:96
void timestepSetup() override
Gets called at the beginning of the timestep before this object is asked to do its job.
Definition Function.C:264
virtual Real average() const
Returns the average of the function over its domain.
Definition Function.C:110
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
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
Definition Function.h:148
bool hasBlocks(SubdomainID) const override
Returns whether the functor is defined on this block.
Definition Function.h:145
void jacobianSetup() override final
Gets called just before the Jacobian is computed and before this object is asked to do its job.
Definition Function.C:276
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
Class for containing MooseEnum item information.
Base class template for functor objects.
typename FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type GradientType
This rigmarole makes it so that a user can create functors that return containers (std::vector,...
typename std::conditional< is_ad, typename ADType< T >::type, T >::type GenericType
Definition MooseTypes.h:694
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
A structure that is used to evaluate Moose functors logically at an element/cell center.
A structure that is used to evaluate Moose functors at an arbitrary physical point contained within a...
Argument for requesting functor evaluation at a quadrature point location in an element.
Argument for requesting functor evaluation at quadrature point locations on an element side.
A structure defining a "face" evaluation calling argument for Moose functors.
State argument for evaluating functors.