15 #include "libmesh/quadrature.h" 25 params.
addClassDescription(
"Records all scalar material properties of a material object on " 26 "elements at the indicated execution points.");
28 "Material for which all properties will be recorded.");
29 params.
addParam<std::vector<dof_id_type>>(
31 "Subset of element IDs to print data for. If omitted, all elements will be printed.");
37 _elem_ids(declareVector(
"elem_id")),
38 _qp_ids(declareVector(
"qp_id")),
39 _x_coords(declareVector(
"x")),
40 _y_coords(declareVector(
"y")),
41 _z_coords(declareVector(
"z"))
44 auto & prop_names = mat.getSuppliedItems();
45 if (mat.isBoundaryMaterial())
46 mooseError(
name(),
": boundary materials (i.e. ", mat.name(),
") cannot be used");
51 const auto & ids = getParam<std::vector<dof_id_type>>(
"elem_ids");
52 _elem_filter = std::set<dof_id_type>(ids.begin(), ids.end());
55 for (
const auto &
id : ids)
61 bool found_elem = (el !=
nullptr);
67 if (!found_elem || (el && !mat.hasBlocks(el->subdomain_id())))
68 mooseError(
name(),
": material ", mat.name(),
" is not defined on element ", id);
72 for (
auto & prop : prop_names)
74 if (hasMaterialProperty<Real>(prop))
75 _prop_refs.push_back(&getMaterialProperty<Real>(prop));
76 else if (hasMaterialProperty<unsigned int>(prop))
77 _prop_refs.push_back(&getMaterialProperty<unsigned int>(prop));
78 else if (hasMaterialProperty<int>(prop))
79 _prop_refs.push_back(&getMaterialProperty<int>(prop));
83 " is of unsupported type and skipped by MaterialVectorPostprocessor");
114 unsigned int nqp =
_qrule->n_points();
115 for (
unsigned int qp = 0; qp < nqp; qp++)
124 for (
unsigned int i = 0; i <
_prop_names.size(); i++)
128 std::vector<Real> vals;
129 if (hasMaterialProperty<Real>(prop_name))
132 for (
unsigned int qp = 0; qp < nqp; qp++)
133 prop->push_back((*vals)[qp]);
135 else if (hasMaterialProperty<unsigned int>(prop_name))
138 for (
unsigned int qp = 0; qp < nqp; qp++)
139 prop->push_back((*vals)[qp]);
141 else if (hasMaterialProperty<int>(prop_name))
144 for (
unsigned int qp = 0; qp < nqp; qp++)
145 prop->push_back((*vals)[qp]);
169 _qp_ids.insert(
_qp_ids.end(), vpp._qp_ids.begin(), vpp._qp_ids.end());
174 for (
unsigned int i = 0; i <
_prop_vecs.size(); i++)
177 auto & othervec = *vpp._prop_vecs[i];
178 vec.insert(vec.end(), othervec.begin(), othervec.end());
186 std::vector<size_t> ind;
188 std::iota(ind.begin(), ind.end(), 0);
189 std::sort(ind.begin(),
191 [&](
size_t a,
size_t b) ->
bool std::optional< std::set< dof_id_type > > _elem_filter
Element ids to record material properties for.
const MooseArray< Point > & _q_point
static InputParameters validParams()
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
VectorPostprocessorValue & _y_coords
const Parallel::Communicator & comm() const
std::vector< VectorPostprocessorValue * > _prop_vecs
Columns for each (scalar) property of the material.
VectorPostprocessorValue & _qp_ids
Column of quadrature point indices.
virtual void finalize() override
Finalize.
void applyIndices(T &container, const std::vector< size_t > &indices)
Uses indices created by the indirectSort function to sort the given container (which must support ran...
virtual const std::string & name() const
Get the name of the class.
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
virtual void threadJoin(const UserObject &y) override
Must override.
VectorPostprocessorValue & _x_coords
Columns of quadrature point coordinates.
VectorPostprocessorValue & _z_coords
bool containsCompleteHistory() const
Return whether or not this VectorPostprocessor contains complete history.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
void sortVecs()
Sorts all data in the VectorPostProcessorValue objects so that output from this postprocessor is orde...
virtual void execute() override
Execute method.
std::vector< const PropertyValue * > _prop_refs
Reference to each material property - used to retrieve the actual property values at every execution ...
registerMooseObject("MooseApp", MaterialVectorPostprocessor)
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
std::vector< std::string > _prop_names
Names for every property in the material - used for determining if properties are scalar or not...
MaterialBase & getMaterialByName(const std::string &name, bool no_warn=false)
const QBase *const & _qrule
const Elem *const & _current_elem
The current element pointer (available during execute())
void max(const T &r, T &o, Request &req) const
VectorPostprocessorValue & _elem_ids
Column of element id info.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const InputParameters & parameters() const
Get the parameters of the object.
static InputParameters validParams()
This postprocessor records all scalar material properties of the specified material object on specifi...
Base class for user-specific data.
MaterialVectorPostprocessor(const InputParameters ¶meters)