14#include "libmesh/mesh_base.h"
15#include "libmesh/elem.h"
24 "Divide the mesh along based on uniformly binned values of a functor.");
25 params.
addRequiredParam<Real>(
"min_value",
"Minimum value of the functor for the binning");
26 params.
addRequiredParam<Real>(
"max_value",
"Maximum value of the functor for the binning");
28 "num_bins",
"num_bins>0",
"Number of uniform bins in functor values");
30 "functor",
"Functor to evaluate to assign points/elements to the bins");
31 params.
addParam<
bool>(
"assign_out_of_bounds_to_extreme_bins",
33 "Whether to map functor values outside of the [min,max] range to the "
34 "lowest and highest bins, or to use the invalid division index");
42 _min(getParam<Real>(
"min_value")),
43 _max(getParam<Real>(
"max_value")),
44 _nbins(getParam<unsigned
int>(
"num_bins")),
45 _functor(getFunctor<Real>(
"functor")),
46 _oob_is_edge_bins(getParam<bool>(
"assign_out_of_bounds_to_extreme_bins"))
48 if (MooseUtils::absoluteFuzzyLessEqual(
_max,
_min))
49 paramError(
"max_value",
"Maximum value should be above minimum value.");
73 else if (value >
_max)
80 else if (value >
_max)
84 for (
const auto i_bin : make_range(
_nbins + 1))
87 if (MooseUtils::absoluteFuzzyEqual(value, border_value))
90 if (value < border_value)
91 return (i_bin > 0) ? i_bin - 1 : 0;
111 std::set<const Elem *> candidates;
112 (*pl)(pt, candidates);
115 const Elem * elem =
nullptr;
117 for (
const auto elem_ptr : candidates)
118 if (elem_ptr->id() < min_elem_id)
121 min_elem_id = elem_ptr->id();
124 mooseError(
"Division index queried for a point outside the local mesh");
registerMooseObject("MooseApp", FunctorBinnedValuesDivision)
void ErrorVector unsigned int
Divides the mesh based on the binned values of a functor.
static InputParameters validParams()
unsigned int getBinIndex(Real value, const Point &pt) const
Get the bin for that functor value.
const Real _max
Max functor bin value.
const Real _min
Min functor bin value.
const bool _oob_is_edge_bins
Whether to map functor values outside [min, max] onto the edge bins.
virtual void initialize() override
Set up any data members that would be necessary to obtain the division indices.
const Moose::Functor< Real > & _functor
Functor to use to subdivide the mesh.
const unsigned int _nbins
Number of value bins.
FunctorBinnedValuesDivision(const InputParameters ¶meters)
virtual unsigned int divisionIndex(const Point &pt) const override
Return the index of the division to which the point belongs.
Base class for MeshDivision objects.
static InputParameters validParams()
Class constructor.
void setNumDivisions(const unsigned int ndivs)
Set the number of divisions.
const MooseMesh & _mesh
Mesh that is being divided.
bool _mesh_fully_indexed
Whether the mesh is fully covered / indexed, all elements and points have a valid index.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
void mooseWarning(Args &&... args) const
unsigned int INVALID_DIVISION_INDEX
Invalid subdomain id to return when outside the mesh division.
std::string stringify(const T &t)
conversion to string
const unsigned int invalid_uint
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...
State argument for evaluating functors.