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");
39 _reduction(getParam<
MooseEnum>(
"reduction")),
40 _nfunctors(getParam<
std::vector<MooseFunctorName>>(
"functors").size()),
41 _mesh_division(_fe_problem.getMeshDivision(getParam<MeshDivisionName>(
"mesh_division"), _tid))
44 const auto & functor_names = getParam<std::vector<MooseFunctorName>>(
"functors");
45 for (
const auto & functor_name : functor_names)
46 _functors.push_back(&getFunctor<Real>(functor_name));
51 for (
const auto & functor_name : functor_names)
65 std::fill(reduction->begin(), reduction->end(), 0);
71 mooseAssert(
false,
"Unknown reduction type");
85 mooseWarning(
"Spatial value sampled outside of the mesh_division specified in element: " +
95 const auto functor_value = (*
_functors[i])(elem_qp, state_arg);
107 if (i == 0 &&
_reduction == ReductionEnum::AVERAGE)
156 if (i_f == 0 &&
_reduction == ReductionEnum::AVERAGE)
165 mooseError(
"The spatialValue user object interface was not conceived for objects that compute " 166 "multiple values for a given spatial point. Please specify only one functor");
169 mooseError(
"Spatial value sampled outside of the mesh_division specified at", p);
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
virtual void finalize() override
Finalize.
virtual void execute() override
Execute method.
virtual unsigned int divisionIndex(const Point &pt) const =0
Return the index of the division to which the point belongs.
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
const MooseArray< Point > & _q_point
const MooseArray< Real > & _coord
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
void gatherMax(T &value)
Gather the parallel max of the variable passed in.
static InputParameters validParams()
std::vector< const Moose::Functor< Real > * > _functors
Functors that are evaluated to create the reduction.
void gatherMin(T &value)
Gather the parallel min of the variable passed in.
registerMooseObject("MooseApp", MeshDivisionFunctorReductionVectorPostprocessor)
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
auto max(const L &left, const R &right)
const MeshDivision & _mesh_division
Mesh division providing the division.
This MeshDivisionFunctorReductionVectorPostprocessor serves to integrate functors based on the index ...
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
std::vector< Real > _volumes
Vectors holding the mesh division volumes.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual bool hasBlocks(SubdomainID sub) const override
Returns whether the functor is defined on this block.
Argument for requesting functor evaluation at a quadrature point location in an element.
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
std::string stringify(const T &t)
conversion to string
const MooseEnum _reduction
Reduction operation to be performed.
unsigned int INVALID_DIVISION_INDEX
Invalid subdomain id to return when outside the mesh division.
unsigned int getNumDivisions() const
Return the number of divisions.
virtual void threadJoin(const UserObject &uo) override
Must override.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
const Elem *const & _current_elem
The current element pointer (available during execute())
const MooseArray< Real > & _JxW
const unsigned int _nfunctors
Number of functors to be integrated.
IntRange< T > make_range(T beg, T end)
virtual Real spatialValue(const Point &p) const override
Optional interface function for "evaluating" a UserObject at a spatial position.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
Base class for creating a user object with the SpatialUserObject and Moose::Functor APIs...
static InputParameters validParams()
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
auto min(const L &left, const R &right)
MeshDivisionFunctorReductionVectorPostprocessor(const InputParameters ¶meters)
std::vector< VectorPostprocessorValue * > _functor_reductions
Vectors holding functor reductions (integrals, averages, extrema..) over each mesh division...
auto index_range(const T &sizable)
Base class for user-specific data.