15 #include "libmesh/mesh_base.h" 23 params.
addParam<std::vector<MaterialPropertyName>>(
24 "mat_prop",
"The names of material properties that this VectorPostprocessor operates on");
26 "id_name",
"List of extra element ID names by which to separate integral(s).");
27 params.
addParam<
bool>(
"average",
false,
"Whether or not to compute volume average");
28 params.
addParam<std::string>(
"spatial_value_name",
29 "To specify which variable or material property is to be used when " 30 "using as a spatial user object functor");
39 _average(getParam<bool>(
"average")),
40 _nvar(isParamValid(
"variable") ? coupledComponents(
"variable") : 0),
41 _nprop(isParamValid(
"mat_prop") ? getParam<
std::vector<MaterialPropertyName>>(
"mat_prop").size()
43 _prop_names(isParamValid(
"mat_prop") ? getParam<
std::vector<MaterialPropertyName>>(
"mat_prop")
44 :
std::vector<MaterialPropertyName>()),
45 _extra_id(getParam<
std::vector<ExtraElementIDName>>(
"id_name")),
46 _n_extra_id(_extra_id.size()),
47 _spatial_evaluation_index(
std::numeric_limits<unsigned
int>::
max())
50 mooseError(
"Neither 'variable' nor 'mat_prop' was specified.");
60 auto & p =
declareVector(
"Level-" + std::to_string(i) +
"-" + id_type);
62 std::map<dof_id_type, dof_id_type> extra_ids;
63 for (
const auto & elem :
_mesh.
getMesh().active_local_element_ptr_range())
68 if (extra_ids.find(vpp_id) == extra_ids.end())
73 p.resize(extra_ids.size());
74 for (
auto it : extra_ids)
75 p[it.first] = it.second;
79 std::vector<std::string> vector_names;
82 for (
unsigned int i = 0; i <
_nvar; ++i)
95 _props.push_back(&getMaterialPropertyByName<Real>(
name));
96 vector_names.push_back(
name);
104 const auto &
name = getParam<std::string>(
"spatial_value_name");
107 if (
name == vector_names[i])
114 "not a variable name or material property name of this vector postprocessor");
122 std::fill(integral->begin(), integral->end(), 0);
135 for (
unsigned int ivar = 0; ivar <
_nvar; ++ivar, ++i)
137 for (
unsigned int qp = 0; qp <
_qrule->n_points(); qp++)
140 for (
unsigned int iprop = 0; iprop <
_nprop; ++iprop, ++i)
141 for (
unsigned int qp = 0; qp <
_qrule->n_points(); qp++)
160 for (
unsigned int i = 0; i < integral->size(); ++i)
170 for (
unsigned int i = 0; i <
_integrals.size(); ++i)
171 for (
size_t j = 0; j < (*
_integrals[i]).size(); ++j)
172 (*
_integrals[i])[j] += (*sibling._integrals[i])[j];
175 for (
unsigned int i = 0; i <
_volumes.size(); ++i)
183 mooseAssert(state.state == 0,
"We do not currently support evaluating at old states");
191 mooseAssert(state.state == 0,
"We do not currently support evaluating at old states");
200 "Must set when ExtraIDIntegralVectorPostprocessor is used as a functor");
206 "Failed evaluating spatial value of element ",
209 elem->subdomain_id(),
210 ". This is likely due to the object using this " 211 "ExtraIDIntegralVectorPostprocessor as a functor operates on a subdomain outside of " 212 "this ExtraIDIntegralVectorPostprocessor");
214 mooseError(
"Failed evaluating spatial value of element ",
216 ". We should not hit this error. Please contact code developers for help");
std::unordered_map< dof_id_type, dof_id_type > getExtraIDUniqueCombinationMap(const MeshBase &mesh, const std::set< SubdomainID > &block_ids, std::vector< ExtraElementIDName > extra_ids)
Crate a new set of element-wise IDs by finding unique combinations of existing extra ID values...
const MooseArray< Real > & _coord
const Parallel::Communicator & comm() const
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
Extract pointer to a coupled variable.
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.
virtual const std::string & name() const
Get the name of the class.
auto max(const L &left, const R &right)
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
virtual const VariableValue & coupledValue(const std::string &var_name, unsigned int comp=0) const
Returns value of a coupled variable.
Base class VectorPostprocessors operating on elemental variables.
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
virtual bool hasBlocks(SubdomainID sub) const override
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 ...
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
virtual unsigned int getElementIDIndexByName(const std::string &id_name) const
Return the accessing integer for an extra element integer with its name.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
const Elem *const & _current_elem
The current element pointer (available during execute())
const MooseArray< Real > & _JxW
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
Base class for creating a user object with the SpatialUserObject and Moose::Functor APIs...
State argument for evaluating functors.
static InputParameters validParams()
void ErrorVector unsigned int
auto index_range(const T &sizable)
Base class for user-specific data.
void set_union(T &data, const unsigned int root_id) const