https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SideIntegralFunctorPostprocessor.C
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
11
12#include "metaphysicl/raw_type.h"
13
16
17template <bool is_ad>
20{
22 params.addRequiredParam<MooseFunctorName>(
23 "functor", "The name of the functor that this postprocessor integrates");
24 params.addParam<MooseFunctorName>("prefactor", 1, "Factor multiplying the integrand");
25 params.addParam<bool>("restrict_to_functors_domain",
26 false,
27 "If the functor (and the prefactor) is only defined only along part of "
28 "the sideset, allows to skip the parts where it is not defined. Please "
29 "keep in mind that if the sideset is defined with the wrong normal, this "
30 "may allow to skip the entire integral.");
31 MooseEnum functor_args("qp face", "face");
32 params.addParam<MooseEnum>(
33 "functor_argument", functor_args, "Location to evaluate the functors at");
35 "Computes a surface integral of the specified functor, using the "
36 "single-sided face argument, which usually means that the functor will be"
37 " evaluated from a single side of the surface, not interpolated between "
38 "both sides.");
39 return params;
41
42template <bool is_ad>
44 const InputParameters & parameters)
45 : SideIntegralPostprocessor(parameters),
46 _functor(getFunctor<GenericReal<is_ad>>("functor")),
47 _prefactor(getFunctor<GenericReal<is_ad>>("prefactor")),
48 _partial_integral(getParam<bool>("restrict_to_functors_domain"))
49{
50 _qp_integration = (getParam<MooseEnum>("functor_argument") == "qp");
51
52 checkFunctorSupportsSideIntegration<GenericReal<is_ad>>("functor", _qp_integration);
53 checkFunctorSupportsSideIntegration<GenericReal<is_ad>>("prefactor", _qp_integration);
54}
55
56template <bool is_ad>
57Real
59{
60 mooseAssert(fi, "We should have a FaceInfo");
61 const auto face = makeCDFace(*fi);
62 return computeLocalContribution(face);
63}
64
65template <bool is_ad>
66template <typename T>
67Real
69{
70 // It's possible the functor is not defined on that side of the boundary
71 // We wont allow that case, unless explicitly requested by the user,
72 // as this means the sideset is reversed, but we will allow the case where
73 // both sides are defined
74 const bool has_elem = checkFunctorDefinedOnSideBlock();
75
76 if (has_elem)
77 return MetaPhysicL::raw_value(_prefactor(functor_arg, determineState()) *
78 _functor(functor_arg, determineState()));
79 else
80 {
81 if (!_partial_integral)
82 errorFunctorNotDefinedOnSideBlock();
83 return 0;
84 }
85}
86
87template <bool is_ad>
88Real
90{
91 Moose::ElemSideQpArg elem_side_qp = {_current_elem, _current_side, _qp, _qrule, _q_point[_qp]};
92 return computeLocalContribution(elem_side_qp);
93}
94
95template <bool is_ad>
96bool
98{
99 if (_functor.hasBlocks(_current_elem->subdomain_id()) &&
100 _prefactor.hasBlocks(_current_elem->subdomain_id()))
101 return true;
102 else
103 {
104#ifndef NDEBUG
105 const auto neighbor_ptr = _current_elem->neighbor_ptr(_current_side);
106 if (neighbor_ptr)
107 {
108 mooseAssert(_functor.hasBlocks(_current_elem->subdomain_id()) ||
109 _functor.hasBlocks(neighbor_ptr->subdomain_id()),
110 "Functor should be defined on at least one side of the boundary");
111 mooseAssert(_prefactor.hasBlocks(_current_elem->subdomain_id()) ||
112 _prefactor.hasBlocks(neighbor_ptr->subdomain_id()),
113 "Prefactor should be defined on at least one side of the boundary");
114 }
115#endif
116 return false;
117 }
118}
119
120template <bool is_ad>
121void
123{
124 paramError("boundary",
125 "Functor " + _functor.functorName() + " (or prefactor " + _prefactor.functorName() +
126 ") is not defined on block " + std::to_string(_current_elem->subdomain_id()) +
127 ". Is the functor defined along the whole sideset? "
128 "Are the sidesets in 'boundary' all oriented correctly?");
129}
130
131template <bool is_ad>
132bool
134 const bool fi_elem_side) const
135{
136 return _current_elem == (fi_elem_side ? &fi.elem() : fi.neighborPtr());
137}
138
Moose::GenericType< Real, is_ad > GenericReal
Definition MooseTypes.h:698
registerMooseObject("MooseApp", SideIntegralFunctorPostprocessor)
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
const Elem & elem() const
Definition FaceInfo.h:85
const Elem * neighborPtr() const
Definition FaceInfo.h:88
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
void errorFunctorNotDefinedOnSideBlock() const
Error with a helpful message if the functor is not defined on the primary block by the sideset.
bool checkFunctorDefinedOnSideBlock() const
Check if the functor and the prefactor are defined on the primary block by the sideset.
SideIntegralFunctorPostprocessorTempl(const InputParameters &parameters)
bool hasFaceSide(const FaceInfo &fi, const bool fi_elem_side) const override
virtual Real computeFaceInfoIntegral(const FaceInfo *fi) override
Compute contribution from an element face, either on a boundary or between two active elements.
Real computeLocalContribution(const T &functor_arg) const
This postprocessor computes a surface integral of the specified variable on a sideset on the boundary...
static InputParameters validParams()
auto raw_value(const Eigen::Map< T > &in)
Argument for requesting functor evaluation at quadrature point locations on an element side.