https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SpatialUserObjectFunctor.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 "InputParameters.h"
14#include "BlockRestrictable.h"
15
19template <typename UserObjectType>
20class SpatialUserObjectFunctor : public UserObjectType, public Moose::FunctorBase<Real>
21{
22public:
24
26 virtual bool hasBlocks(SubdomainID sub) const override;
27
28protected:
35
36 virtual Real evaluate(const ElemArg & elem, const Moose::StateArg & state) const override;
37 virtual Real evaluate(const FaceArg & face, const Moose::StateArg & state) const override final;
38 virtual Real evaluate(const ElemQpArg & qp, const Moose::StateArg & state) const override;
39 virtual Real evaluate(const ElemSideQpArg & elem_side_qp,
40 const Moose::StateArg & state) const override final;
41 virtual Real evaluate(const ElemPointArg & elem_point,
42 const Moose::StateArg & state) const override final;
43 virtual Real evaluate(const NodeArg & node, const Moose::StateArg & state) const override final;
44
45 virtual bool supportsFaceArg() const override final { return true; }
46 virtual bool supportsElemSideQpArg() const override final { return true; }
47
48private:
49 /*
50 * Helper template implementing functor evaluations
51 */
52 template <typename SpatialArg>
53 Real evaluateTemplate(const SpatialArg & position, const Moose::StateArg & state) const;
54};
55
56template <typename UserObjectType>
59{
60 auto params = UserObjectType::validParams();
61 // Spatial UOs are used in the transfers
62 ExecFlagEnum & exec_enum = params.template set<ExecFlagEnum>("execute_on", true);
64 return params;
65}
66
67template <typename UserObjectType>
69 : UserObjectType(params), Moose::FunctorBase<Real>(this->name())
70{
71}
72
73template <typename UserObjectType>
74template <typename SpatialArg>
75Real
77 const SpatialArg & position, const Moose::StateArg & libmesh_dbg_var(state)) const
78{
79 mooseAssert(state.state == 0, "We do not currently support evaluating at old states");
80 return this->spatialValue(position.getPoint());
81}
82
83template <typename UserObjectType>
84Real
86 const Moose::StateArg & state) const
87{
88 return evaluateTemplate(elem, state);
89}
90
91template <typename UserObjectType>
92Real
94 const Moose::StateArg & state) const
95{
96 return evaluateTemplate(face, state);
97}
98
99template <typename UserObjectType>
100Real
102 const Moose::StateArg & state) const
103{
104 return evaluateTemplate(qp, state);
105}
106
107template <typename UserObjectType>
108Real
110 const Moose::StateArg & state) const
111{
112 return evaluateTemplate(elem_side_qp, state);
113}
114
115template <typename UserObjectType>
116Real
118 const Moose::StateArg & state) const
119{
120 return evaluateTemplate(elem_point, state);
121}
122
123template <typename UserObjectType>
124Real
126 const Moose::StateArg & state) const
127{
128 return evaluateTemplate(node, state);
129}
130
131template <typename UserObjectType>
132bool
134{
135 if constexpr (std::is_base_of<BlockRestrictable, UserObjectType>::value)
136 return UserObjectType::hasBlocks(sub_id);
137 else
139}
const ExecFlagType EXEC_TRANSFER
Definition Moose.C:57
A MultiMooseEnum object to hold "execute_on" flags.
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Base class template for functor objects.
virtual bool hasBlocks(SubdomainID) const
Returns whether the functor is defined on this block.
Base class for creating a user object with the SpatialUserObject and Moose::Functor APIs.
virtual Real evaluate(const ElemQpArg &qp, const Moose::StateArg &state) const override
virtual bool hasBlocks(SubdomainID sub) const override
Returns whether the functor is defined on this block.
SpatialUserObjectFunctor(const InputParameters &params)
static InputParameters validParams()
virtual Real evaluate(const ElemArg &elem, const Moose::StateArg &state) const override
Evaluate the functor with a given element.
virtual Real evaluate(const FaceArg &face, const Moose::StateArg &state) const override final
virtual bool supportsElemSideQpArg() const override final
Whether this functor supports evaluation with ElemSideQpArg.
virtual Real evaluate(const NodeArg &node, const Moose::StateArg &state) const override final
virtual bool supportsFaceArg() const override final
Whether this functor supports evaluation with FaceArg.
virtual Real evaluate(const ElemPointArg &elem_point, const Moose::StateArg &state) const override final
Evaluate the functor with a given element and point.
virtual Real evaluate(const ElemSideQpArg &elem_side_qp, const Moose::StateArg &state) const override final
Real evaluateTemplate(const SpatialArg &position, const Moose::StateArg &state) const
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.