11 #include "libmesh/parallel.h" 12 #include "libmesh/parallel_algebra.h" 13 #include "libmesh/vector_value.h" 25 "functor",
"Functor of which the extremas are going to form the list of positions");
27 MooseEnum(
"max=0 min=1 max_abs=2",
"max"),
28 "Type of extreme value to return. 'max' " 29 "returns the location(s) of the maximum value(s). 'min' returns " 30 "the location(s) of the minimum value(s). 'max_abs' returns the " 31 "locations of the maximum(a) of the absolute value.");
32 params.
addParam<
unsigned int>(
"num_extrema", 1,
"Number of extrema to look for");
39 params.
set<
bool>(
"auto_sort") =
false;
42 params.
set<
bool>(
"auto_broadcast") =
false;
56 _functor(getFunctor<
Real>(
"functor")),
57 _n_extrema(getParam<unsigned
int>(
"num_extrema")),
63 const auto & functor_name = getParam<MooseFunctorName>(
"functor");
68 "Postprocessors and constants do not have extrema, they are constant over the domain.");
70 if (getParam<ExecFlagEnum>(
"execute_on").contains(
EXEC_NONE))
72 "NONE execution flag not supported. Most functors (functions, variables, spatial " 73 "user objects for example) are not initialized at construction.");
83 std::list<Real> extrema;
84 std::list<Point> extrema_locs;
94 for (
const auto & elem :
100 auto extremum = extrema.begin();
101 auto extremum_loc = extrema_locs.begin();
106 bool extrema_found =
false;
114 if (
value > *extremum)
115 extrema_found =
true;
120 if (
value < *extremum)
121 extrema_found =
true;
128 extrema.insert(extremum,
value);
129 extrema_locs.insert(extremum_loc, elem->true_centroid());
131 extrema_locs.pop_back();
136 std::advance(extremum, 1);
137 std::advance(extremum_loc, 1);
142 auto current_candidate = extrema.begin();
143 auto current_candidate_loc = extrema_locs.begin();
148 auto copy = *current_candidate;
157 extreme_point = *current_candidate_loc;
159 std::advance(current_candidate, 1);
160 std::advance(current_candidate_loc, 1);
170 "Positions extrema should be the same across all MPI processes.");
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
virtual MooseMesh & mesh()=0
bool parsesToReal(const std::string &input)
Check if the input string can be parsed into a Real.
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
A MultiMooseEnum object to hold "execute_on" flags.
static InputParameters validParams()
std::vector< Real > & _positions_values
Values of the functor at the extrema.
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 ...
This context is specific for vector types of reporters, mainly for declaring a vector of the type fro...
void minloc(T &r, unsigned int &min_id) const
void clearPositions()
Clear all positions vectors.
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
const ExecFlagType EXEC_NONE
Positions objects are under the hood Reporters.
void initialize() override
In charge of computing / loading the positions.
ExtremeType
Type of extreme value we are going to compute.
const Parallel::Communicator & comm() const
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.
const Moose::Functor< Real > & _functor
Functor providing the value.
auto max(const L &left, const R &right)
bool _initialized
Whether the positions object has been initialized. This must be set by derived objects.
static InputParameters validParams()
SubProblem & _subproblem
Reference to the Subproblem for this user object.
void libmesh_ignore(const Args &...)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
const ExecFlagType EXEC_TIMESTEP_BEGIN
const unsigned int _n_extrema
Number of extrema to keep track of.
std::vector< Point > & _positions
For now, only the 1D vector will be shared across all ranks.
bool hasPostprocessorValueByName(const PostprocessorName &name) const
Whether or not a Postprocessor value exists by a given name.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
A structure that is used to evaluate Moose functors logically at an element/cell center.
void maxloc(T &r, unsigned int &max_id) const
FunctorExtremaPositions(const InputParameters ¶meters)
const ExecFlagType EXEC_LINEAR
static InputParameters validParams()
registerMooseObject("MooseApp", FunctorExtremaPositions)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
An interface that restricts an object to subdomains via the 'blocks' input parameter.
IntRange< T > make_range(T beg, T end)
static InputParameters validParams()
const ReporterMode REPORTER_MODE_REPLICATED
Positions from the extrema of a functor.
processor_id_type processor_id() const
enum FunctorExtremaPositions::ExtremeType _type
void ErrorVector unsigned int