https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ADWrapperFunctor.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 "MooseFunctor.h"
13
14namespace Moose
15{
19template <typename T>
21{
22public:
25 using typename Moose::FunctorBase<T>::DotType;
26
27 ADWrapperFunctor(const FunctorBase<typename MetaPhysicL::RawType<T>::value_type> & non_ad_functor)
28 : FunctorBase<T>(non_ad_functor.functorName() + "_ad_ified", {EXEC_ALWAYS}),
29 _non_ad_functor(non_ad_functor)
30 {
31 }
32
33 virtual bool isExtrapolatedBoundaryFace(const FaceInfo & fi,
34 const Elem * const elem,
35 const Moose::StateArg & state) const override
36 {
37 return _non_ad_functor.isExtrapolatedBoundaryFace(fi, elem, state);
38 }
39 virtual bool isConstant() const override { return _non_ad_functor.isConstant(); }
40 virtual bool hasBlocks(const SubdomainID id) const override
41 {
42 return _non_ad_functor.hasBlocks(id);
43 }
44 virtual bool hasFaceSide(const FaceInfo & fi, const bool fi_elem_side) const override
45 {
46 return _non_ad_functor.hasFaceSide(fi, fi_elem_side);
47 }
48
49 bool supportsFaceArg() const override final { return _non_ad_functor.supportsFaceArg(); }
50 bool supportsElemSideQpArg() const override final
51 {
53 }
54
55protected:
57
60 ValueType evaluate(const ElemArg & elem, const StateArg & state) const override
61 {
62 return _non_ad_functor(elem, state);
63 }
64 ValueType evaluate(const FaceArg & face, const StateArg & state) const override
65 {
66 return _non_ad_functor(face, state);
67 }
68 ValueType evaluate(const ElemQpArg & qp, const StateArg & state) const override
69 {
70 return _non_ad_functor(qp, state);
71 }
72 ValueType evaluate(const ElemSideQpArg & qp, const StateArg & state) const override
73 {
74 return _non_ad_functor(qp, state);
75 }
76 ValueType evaluate(const ElemPointArg & elem_point, const StateArg & state) const override
77 {
78 return _non_ad_functor(elem_point, state);
79 }
80 ValueType evaluate(const NodeArg & node, const StateArg & state) const override
81 {
82 return _non_ad_functor(node, state);
83 }
84
85 GradientType evaluateGradient(const ElemArg & elem, const StateArg & state) const override
86 {
87 return _non_ad_functor.gradient(elem, state);
88 }
89 GradientType evaluateGradient(const FaceArg & face, const StateArg & state) const override
90 {
91 return _non_ad_functor.gradient(face, state);
92 }
93 GradientType evaluateGradient(const ElemQpArg & qp, const StateArg & state) const override
94 {
95 return _non_ad_functor.gradient(qp, state);
96 }
97 GradientType evaluateGradient(const ElemSideQpArg & qp, const StateArg & state) const override
98 {
99 return _non_ad_functor.gradient(qp, state);
100 }
102 const StateArg & state) const override
103 {
104 return _non_ad_functor.gradient(elem_point, state);
105 }
106 GradientType evaluateGradient(const NodeArg & node, const StateArg & state) const override
107 {
108 return _non_ad_functor.gradient(node, state);
109 }
110
111 DotType evaluateDot(const ElemArg & elem, const StateArg & state) const override
112 {
113 return _non_ad_functor.dot(elem, state);
114 }
115 DotType evaluateDot(const FaceArg & face, const StateArg & state) const override
116 {
117 return _non_ad_functor.dot(face, state);
118 }
119 DotType evaluateDot(const ElemQpArg & qp, const StateArg & state) const override
120 {
121 return _non_ad_functor.dot(qp, state);
122 }
123 DotType evaluateDot(const ElemSideQpArg & qp, const StateArg & state) const override
124 {
125 return _non_ad_functor.dot(qp, state);
126 }
127 DotType evaluateDot(const ElemPointArg & elem_point, const StateArg & state) const override
128 {
129 return _non_ad_functor.dot(elem_point, state);
130 }
131 DotType evaluateDot(const NodeArg & node, const StateArg & state) const override
132 {
133 return _non_ad_functor.dot(node, state);
134 }
135
136 GradientType evaluateGradDot(const ElemArg & elem, const StateArg & state) const override
137 {
138 return _non_ad_functor.gradDot(elem, state);
139 }
140 GradientType evaluateGradDot(const FaceArg & face, const StateArg & state) const override
141 {
142 return _non_ad_functor.gradDot(face, state);
143 }
144 GradientType evaluateGradDot(const ElemQpArg & qp, const StateArg & state) const override
145 {
146 return _non_ad_functor.gradDot(qp, state);
147 }
148 GradientType evaluateGradDot(const ElemSideQpArg & qp, const StateArg & state) const override
149 {
150 return _non_ad_functor.gradDot(qp, state);
151 }
153 const StateArg & state) const override
154 {
155 return _non_ad_functor.gradDot(elem_point, state);
156 }
157 GradientType evaluateGradDot(const NodeArg & node, const StateArg & state) const override
158 {
159 return _non_ad_functor.gradDot(node, state);
160 }
162
163private:
166};
167}
const ExecFlagType EXEC_ALWAYS
Definition Moose.C:53
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
Wraps non-AD functors such that they can be used in objects that have requested the functor as AD.
GradientType evaluateGradDot(const FaceArg &face, const StateArg &state) const override
ADWrapperFunctor(const FunctorBase< typename MetaPhysicL::RawType< T >::value_type > &non_ad_functor)
virtual bool hasFaceSide(const FaceInfo &fi, const bool fi_elem_side) const override
virtual bool isExtrapolatedBoundaryFace(const FaceInfo &fi, const Elem *const elem, const Moose::StateArg &state) const override
Returns whether this (sided) face is an extrapolated boundary face for this functor.
DotType evaluateDot(const FaceArg &face, const StateArg &state) const override
bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
DotType evaluateDot(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor time derivative with a given element and point.
GradientType evaluateGradDot(const ElemQpArg &qp, const StateArg &state) const override
GradientType evaluateGradDot(const NodeArg &node, const StateArg &state) const override
GradientType evaluateGradDot(const ElemArg &elem, const StateArg &state) const override
Evaluate the functor gradient-dot with a given element.
ValueType evaluate(const ElemArg &elem, const StateArg &state) const override
Forward calls to wrapped object.
ValueType evaluate(const NodeArg &node, const StateArg &state) const override
ValueType evaluate(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor with a given element and point.
GradientType evaluateGradient(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor gradient with a given element and point.
virtual bool isConstant() const override
Returns true if this functor is a constant.
ValueType evaluate(const FaceArg &face, const StateArg &state) const override
GradientType evaluateGradDot(const ElemPointArg &elem_point, const StateArg &state) const override
Evaluate the functor gradient-dot with a given element and point.
DotType evaluateDot(const ElemArg &elem, const StateArg &state) const override
Evaluate the functor time derivative with a given element.
DotType evaluateDot(const ElemSideQpArg &qp, const StateArg &state) const override
const FunctorBase< typename MetaPhysicL::RawType< T >::value_type > & _non_ad_functor
Our wrapped AD object.
GradientType evaluateGradient(const ElemArg &elem, const StateArg &state) const override
Evaluate the functor gradient with a given element.
GradientType evaluateGradient(const FaceArg &face, const StateArg &state) const override
GradientType evaluateGradient(const NodeArg &node, const StateArg &state) const override
GradientType evaluateGradient(const ElemQpArg &qp, const StateArg &state) const override
virtual bool hasBlocks(const SubdomainID id) const override
Returns whether the functor is defined on this block.
DotType evaluateDot(const ElemQpArg &qp, const StateArg &state) const override
ValueType evaluate(const ElemQpArg &qp, const StateArg &state) const override
ValueType evaluate(const ElemSideQpArg &qp, const StateArg &state) const override
GradientType evaluateGradDot(const ElemSideQpArg &qp, const StateArg &state) const override
DotType evaluateDot(const NodeArg &node, const StateArg &state) const override
GradientType evaluateGradient(const ElemSideQpArg &qp, const StateArg &state) const override
bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
Base class template for functor objects.
DotType dot(const ElemArg &elem, const StateArg &state) const
Same as their evaluateDot overloads with the same arguments but allows for caching implementation.
virtual bool isExtrapolatedBoundaryFace(const FaceInfo &, const Elem *, const StateArg &) const
Returns whether this (sided) face is an extrapolated boundary face for this functor.
typename FunctorReturnType< T, FunctorEvaluationKind::Gradient >::type GradientType
This rigmarole makes it so that a user can create functors that return containers (std::vector,...
virtual bool supportsFaceArg() const =0
Whether this functor supports evaluation with FaceArg.
const MooseFunctorName & functorName() const
Return the functor name.
virtual bool hasBlocks(SubdomainID) const
Returns whether the functor is defined on this block.
virtual bool supportsElemSideQpArg() const =0
Whether this functor supports evaluation with ElemSideQpArg.
GradientType gradient(const ElemArg &elem, const StateArg &state) const
Same as their evaluateGradient overloads with the same arguments but allows for caching implementatio...
GradientType gradDot(const ElemArg &elem, const StateArg &state) const
Same as their evaluateGradDot overloads with the same arguments but allows for caching implementation...
virtual bool hasFaceSide(const FaceInfo &fi, const bool fi_elem_side) const override
virtual bool isConstant() const
Returns true if this functor is a constant.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
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.