16#include "libmesh/mesh_base.h"
24 MooseEnum reduction(
"integral average min max");
27 "Functors to apply the reduction on");
30 "Mesh division object which dictates the elements to perform the reduction with");
31 params.
addClassDescription(
"Perform reductions on functors based on a per-mesh-division basis");
38 _reduction(getParam<
MooseEnum>(
"reduction")),
39 _nfunctors(getParam<
std::vector<MooseFunctorName>>(
"functors").size()),
40 _mesh_division(_fe_problem.getMeshDivision(getParam<MeshDivisionName>(
"mesh_division"), _tid))
43 const auto & functor_names = getParam<std::vector<MooseFunctorName>>(
"functors");
44 for (
const auto & functor_name : functor_names)
45 _functors.push_back(&getFunctor<Real>(functor_name));
50 for (
const auto & functor_name : functor_names)
64 std::fill(reduction->begin(), reduction->end(), 0);
66 std::fill(reduction->begin(), reduction->end(), std::numeric_limits<Real>::max());
68 std::fill(reduction->begin(), reduction->end(), std::numeric_limits<Real>::min());
70 mooseAssert(
false,
"Unknown reduction type");
84 mooseWarning(
"Spatial value sampled outside of the mesh_division specified in element: " +
91 for (
const auto qp : make_range(
_qrule->n_points()))
94 const auto functor_value = (*
_functors[i])(elem_qp, state_arg);
128 if (!MooseUtils::absoluteFuzzyEqual(
_volumes[i], 0))
164 mooseError(
"The spatialValue user object interface was not conceived for objects that compute "
165 "multiple values for a given spatial point. Please specify only one functor");
168 mooseError(
"Spatial value sampled outside of the mesh_division specified at", p);
registerMooseObject("MooseApp", MeshDivisionFunctorReductionVectorPostprocessor)
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
const QBase *const & _qrule
const Elem *const & _current_elem
The current element pointer (available during execute())
const MooseArray< Real > & _coord
const MooseArray< Real > & _JxW
const MooseArray< Point > & _q_point
This MeshDivisionFunctorReductionVectorPostprocessor serves to integrate functors based on the index ...
const MeshDivision & _mesh_division
Mesh division providing the division.
std::vector< VectorPostprocessorValue * > _functor_reductions
Vectors holding functor reductions (integrals, averages, extrema..) over each mesh division.
MeshDivisionFunctorReductionVectorPostprocessor(const InputParameters ¶meters)
const MooseEnum _reduction
Reduction operation to be performed.
virtual void finalize() override
Finalize.
std::vector< const Moose::Functor< Real > * > _functors
Functors that are evaluated to create the reduction.
const unsigned int _nfunctors
Number of functors to be integrated.
virtual void threadJoin(const UserObject &uo) override
Must override.
static InputParameters validParams()
virtual Real spatialValue(const Point &p) const override
Optional interface function for "evaluating" a UserObject at a spatial position.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
std::vector< Real > _volumes
Vectors holding the mesh division volumes.
virtual void execute() override
Execute method.
virtual bool hasBlocks(SubdomainID sub) const override
Returns whether the functor is defined on this block.
unsigned int getNumDivisions() const
Return the number of divisions.
virtual unsigned int divisionIndex(const Point &pt) const =0
Return the index of the division to which the point belongs.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Base class for creating a user object with the SpatialUserObject and Moose::Functor APIs.
static InputParameters validParams()
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
void gatherMin(T &value)
Gather the parallel min of the variable passed in.
void gatherMax(T &value)
Gather the parallel max of the variable passed in.
Base class for user-specific data.
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
unsigned int INVALID_DIVISION_INDEX
Invalid subdomain id to return when outside the mesh division.
std::string stringify(const T &t)
conversion to string
Argument for requesting functor evaluation at a quadrature point location in an element.