https://mooseframework.inl.gov
Loading...
Searching...
No Matches
VectorCompositeFunctor.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#include "libmesh/vector_value.h"
14
15namespace Moose
16{
20template <typename T>
21class VectorCompositeFunctor : public FunctorBase<VectorValue<T>>
22{
23public:
24 template <typename U>
26
30
34 VectorCompositeFunctor(const MooseFunctorName & name,
35 const FunctorBase<T> & x_comp,
36 const FunctorBase<T> & y_comp,
37 const FunctorBase<T> & z_comp);
38
42 VectorCompositeFunctor(const MooseFunctorName & name,
43 const FunctorBase<T> & x_comp,
44 const FunctorBase<T> & y_comp);
45
49 VectorCompositeFunctor(const MooseFunctorName & name, const FunctorBase<T> & x_comp);
50
51 virtual bool hasBlocks(SubdomainID sub_id) const override
52 {
53 const bool ret = _x_comp.hasBlocks(sub_id);
54 if (_has_y)
55 mooseAssert(ret == _y_comp.hasBlocks(sub_id), "x and y block restriction don't agree");
56 if (_has_z)
57 mooseAssert(ret == _z_comp.hasBlocks(sub_id), "x and z block restriction don't agree");
58 return ret;
59 }
60
61 bool supportsFaceArg() const override;
62 bool supportsElemSideQpArg() const override;
63
64private:
65 ValueType evaluate(const ElemArg & elem_arg, const StateArg & state) const override;
66 ValueType evaluate(const FaceArg & face, const StateArg & state) const override;
67 ValueType evaluate(const ElemQpArg & elem_qp, const StateArg & state) const override;
68 ValueType evaluate(const ElemSideQpArg & elem_side_qp, const StateArg & state) const override;
69 ValueType evaluate(const ElemPointArg & elem_point_arg, const StateArg & state) const override;
70 ValueType evaluate(const NodeArg & node_arg, const StateArg & state) const override;
71 ValueType evaluate(const PointArg & point_arg, const StateArg & state) const override;
72
73 using FunctorBase<VectorValue<T>>::evaluateGradient;
74 GradientType evaluateGradient(const ElemArg & elem_arg, const StateArg & state) const override;
75
76 using FunctorBase<VectorValue<T>>::evaluateDot;
77 DotType evaluateDot(const FaceArg & face_arg, const StateArg & state) const override;
78 DotType evaluateDot(const ElemArg & elem_arg, const StateArg & state) const override;
79
82 std::unique_ptr<ConstantFunctor<T>> _y_constant;
83
86 std::unique_ptr<ConstantFunctor<T>> _z_constant;
87
94
96 const bool _has_y;
97
99 const bool _has_z;
100};
101
102template <typename T>
104 const FunctorBase<T> & x_comp,
105 const FunctorBase<T> & y_comp,
106 const FunctorBase<T> & z_comp)
107 : FunctorBase<VectorValue<T>>(name),
108 _x_comp(x_comp),
109 _y_comp(y_comp),
110 _z_comp(z_comp),
111 _has_y(true),
112 _has_z(true)
113{
114}
115
116template <typename T>
118 const FunctorBase<T> & x_comp,
119 const FunctorBase<T> & y_comp)
120 : FunctorBase<VectorValue<T>>(name),
121 _z_constant(std::make_unique<ConstantFunctor>(T(0))),
122 _x_comp(x_comp),
123 _y_comp(y_comp),
124 _z_comp(*_z_constant),
125 _has_y(true),
126 _has_z(false)
127{
128}
129
130template <typename T>
132 const FunctorBase<T> & x_comp)
133 : FunctorBase<VectorValue<T>>(name),
134 _y_constant(std::make_unique<ConstantFunctor>(T(0))),
135 _z_constant(std::make_unique<ConstantFunctor>(T(0))),
136 _x_comp(x_comp),
137 _y_comp(*_y_constant),
138 _z_comp(*_z_constant),
139 _has_y(false),
140 _has_z(false)
141{
142}
143
144template <typename T>
145bool
147{
148 if (!_x_comp.supportsFaceArg())
149 return false;
150 if (_has_y && !_y_comp.supportsFaceArg())
151 return false;
152 if (_has_z && !_z_comp.supportsFaceArg())
153 return false;
154 return true;
155}
156
157template <typename T>
158bool
160{
161 if (!_x_comp.supportsElemSideQpArg())
162 return false;
163 if (_has_y && !_y_comp.supportsElemSideQpArg())
164 return false;
165 if (_has_z && !_z_comp.supportsElemSideQpArg())
166 return false;
167 return true;
168}
169
170template <typename T>
172VectorCompositeFunctor<T>::evaluate(const ElemArg & elem_arg, const StateArg & state) const
173{
174 return {_x_comp(elem_arg, state), _y_comp(elem_arg, state), _z_comp(elem_arg, state)};
175}
176
177template <typename T>
179VectorCompositeFunctor<T>::evaluate(const FaceArg & face, const StateArg & state) const
180{
181 return {_x_comp(face, state), _y_comp(face, state), _z_comp(face, state)};
182}
183
184template <typename T>
186VectorCompositeFunctor<T>::evaluate(const ElemQpArg & elem_qp, const StateArg & state) const
187{
188 return {_x_comp(elem_qp, state), _y_comp(elem_qp, state), _z_comp(elem_qp, state)};
189}
190
191template <typename T>
194 const StateArg & state) const
195{
196 return {_x_comp(elem_side_qp, state), _y_comp(elem_side_qp, state), _z_comp(elem_side_qp, state)};
197}
198
199template <typename T>
202 const StateArg & state) const
203{
204 return {_x_comp(elem_point_arg, state),
205 _y_comp(elem_point_arg, state),
206 _z_comp(elem_point_arg, state)};
207}
208
209template <typename T>
211VectorCompositeFunctor<T>::evaluate(const NodeArg & node_arg, const StateArg & state) const
212{
213 return {_x_comp(node_arg, state), _y_comp(node_arg, state), _z_comp(node_arg, state)};
214}
215
216template <typename T>
218VectorCompositeFunctor<T>::evaluate(const PointArg & point_arg, const StateArg & state) const
219{
220 return {_x_comp(point_arg, state), _y_comp(point_arg, state), _z_comp(point_arg, state)};
221}
222
223template <typename T>
226{
227 return {_x_comp.gradient(elem_arg, state),
228 _y_comp.gradient(elem_arg, state),
229 _z_comp.gradient(elem_arg, state)};
230}
231
232template <typename T>
234VectorCompositeFunctor<T>::evaluateDot(const FaceArg & face_arg, const StateArg & state) const
235{
236 return {_x_comp.dot(face_arg, state), _y_comp.dot(face_arg, state), _z_comp.dot(face_arg, state)};
237}
238
239template <typename T>
241VectorCompositeFunctor<T>::evaluateDot(const ElemArg & elem_arg, const StateArg & state) const
242{
243 return {_x_comp.dot(elem_arg, state), _y_comp.dot(elem_arg, state), _z_comp.dot(elem_arg, state)};
244}
245}
subdomain_id_type SubdomainID
Class template for creating constant functors.
Base class template for functor objects.
typename FunctorReturnType< VectorValue< T >, FunctorEvaluationKind::Gradient >::type GradientType
This rigmarole makes it so that a user can create functors that return containers (std::vector,...
A functor that returns a vector composed of its component functor evaluations.
const FunctorBase< T > & _y_comp
The y-component functor.
const FunctorBase< T > & _x_comp
The x-component functor.
std::unique_ptr< ConstantFunctor< T > > _z_constant
Possible holder of constant-0 z-component functor.
VectorCompositeFunctor(const MooseFunctorName &name, const FunctorBase< T > &x_comp, const FunctorBase< T > &y_comp, const FunctorBase< T > &z_comp)
From xyz component constructor.
bool supportsElemSideQpArg() const override
Whether this functor supports evaluation with ElemSideQpArg.
ValueType evaluate(const ElemArg &elem_arg, const StateArg &state) const override
Evaluate the functor with a given element.
std::unique_ptr< ConstantFunctor< T > > _y_constant
Possible holder of constant-0 y-component functor.
GradientType evaluateGradient(const ElemArg &elem_arg, const StateArg &state) const override
Evaluate the functor gradient with a given element.
virtual bool hasBlocks(SubdomainID sub_id) const override
Returns whether the functor is defined on this block.
const bool _has_y
Whether the user supplied a y-functor.
const FunctorBase< T > & _z_comp
The z-component functor.
DotType evaluateDot(const FaceArg &face_arg, const StateArg &state) const override
const bool _has_z
Whether the user supplied a z-functor.
bool supportsFaceArg() const override
Whether this functor supports evaluation with FaceArg.
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.
A structure that is used to evaluate Moose functors at an arbitrary physical point,...
State argument for evaluating functors.