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:
82 case ExtremeType::MIN:
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] =
130 template <
bool is_ad>
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())
152 ev_rep_prop_vals[i] = *_additional_reported_property_values[i];
153 _communicator.broadcast(ev_rep_prop_vals, rank,
true);
155 *_additional_reported_property_values[i] = ev_rep_prop_vals[i];
158 template <
bool is_ad>
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;
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;
183 *_additional_reported_property_values[i] = *(rpt._additional_reported_property_values[i]);
Real & _extreme_value
Extreme value.
virtual void execute() override
Execute method.
static InputParameters validParams()
virtual void threadJoin(const UserObject &uo) override
Must override.
std::vector< const GenericMaterialProperty< Real, is_ad > * > _additional_reported_properties
Pointers to other reported material property objects.
virtual void finalize() override
Finalize.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
registerMooseObject("MooseApp", ElementExtremeMaterialPropertyReporter)
auto max(const L &left, const R &right)
ElementExtremeMaterialPropertyReporterTempl(const InputParameters ¶meters)
Determines the location of the extreme (minimum or maximum) value of a material property, as well as values of a specified set of properties at that location.
void computeQpValue()
Check a given quadrature point for the extreme value, and capture the extreme value as well as the ot...
static InputParameters validParams()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ExtremeType
Type of extreme value to compute.
IntRange< T > make_range(T beg, T end)
auto index_range(const T &sizable)
Base class for user-specific data.
std::vector< Real * > _additional_reported_property_values
Values of other reported material properties.