12#include "metaphysicl/raw_type.h"
13#include "libmesh/parallel.h"
14#include "libmesh/parallel_algebra.h"
29 "Material property for which to find the extreme. "
30 "The value of this property is always reported.");
34 "Type of extreme value to report: 'max' "
35 "reports the maximum value and 'min' reports "
36 "the minimum value.");
38 params.
addParam<std::vector<MaterialPropertyName>>(
39 "additional_reported_properties",
41 "Additional material properties reported at the location of the extreme value");
43 "Determines the location of the minimum or maximum value of a material property over a "
44 "volume, and provides its coordinates and optionally other requested data at that location.");
53 _mat_prop(getGenericMaterialProperty<Real, is_ad>(
"material_property")),
55 _extreme_value(declareValueByName<Real>(
"extreme_value")),
56 _coordinates(declareValueByName<Point>(
"coordinates")),
59 const auto & mat_prop_names =
60 getParam<std::vector<MaterialPropertyName>>(
"additional_reported_properties");
65 for (
const auto & mpn : mat_prop_names)
78 case ExtremeType::MAX:
79 _extreme_value = -std::numeric_limits<Real>::max();
82 case ExtremeType::MIN:
83 _extreme_value = std::numeric_limits<Real>::max();
86 _coordinates = Point(0., 0., 0.);
87 for (
const auto i : index_range(_additional_reported_properties))
88 *_additional_reported_property_values[i] = 0.0;
95 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
106 case ExtremeType::MAX:
107 if (raw_mat_val > _extreme_value)
109 _extreme_value = raw_mat_val;
110 _coordinates = _q_point[_qp];
111 for (
const auto i : index_range(_additional_reported_properties))
112 *_additional_reported_property_values[i] =
117 case ExtremeType::MIN:
118 if (raw_mat_val < _extreme_value)
120 _extreme_value = raw_mat_val;
121 _coordinates = _q_point[_qp];
122 for (
const auto i : index_range(_additional_reported_properties))
123 *_additional_reported_property_values[i] =
134 unsigned int rank = 0;
138 case ExtremeType::MAX:
139 _communicator.maxloc(_extreme_value, rank);
141 case ExtremeType::MIN:
142 _communicator.minloc(_extreme_value, rank);
146 const auto prop_size = _additional_reported_property_values.size();
147 std::vector<Real> ev_rep_prop_vals(prop_size, 0.);
149 _communicator.broadcast(_coordinates, rank);
150 if (rank == processor_id())
151 for (
const auto i : make_range(prop_size))
152 ev_rep_prop_vals[i] = *_additional_reported_property_values[i];
153 _communicator.broadcast(ev_rep_prop_vals, rank,
true);
154 for (
const auto i : make_range(prop_size))
155 *_additional_reported_property_values[i] = ev_rep_prop_vals[i];
163 const auto prop_size = _additional_reported_property_values.size();
167 case ExtremeType::MAX:
168 if (rpt._extreme_value > _extreme_value)
171 _coordinates = rpt._coordinates;
172 for (
const auto i : make_range(prop_size))
173 *_additional_reported_property_values[i] = *(rpt._additional_reported_property_values[i]);
177 case ExtremeType::MIN:
178 if (rpt._extreme_value < _extreme_value)
180 _extreme_value = rpt._extreme_value;
181 _coordinates = rpt._coordinates;
182 for (
const auto i : make_range(prop_size))
183 *_additional_reported_property_values[i] = *(rpt._additional_reported_property_values[i]);
registerMooseObject("MooseApp", ElementExtremeMaterialPropertyReporter)
Determines the location of the extreme (minimum or maximum) value of a material property,...
static InputParameters validParams()
std::vector< Real * > _additional_reported_property_values
Values of other reported material properties.
virtual void finalize() override
Finalize.
void computeQpValue()
Check a given quadrature point for the extreme value, and capture the extreme value as well as the ot...
std::vector< const GenericMaterialProperty< Real, is_ad > * > _additional_reported_properties
Pointers to other reported material property objects.
ElementExtremeMaterialPropertyReporterTempl(const InputParameters ¶meters)
ExtremeType
Type of extreme value to compute.
Real & _extreme_value
Extreme value.
virtual void threadJoin(const UserObject &uo) override
Must override.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
virtual void execute() override
Execute method.
static InputParameters validParams()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Base class for user-specific data.