21 #include "libmesh/point.h" 33 params.
set<
bool>(
"_auto_broadcast") =
false;
41 : _sampler_params(parameters),
45 _x(vpp->declareVector(
"x")),
46 _y(vpp->declareVector(
"y")),
47 _z(vpp->declareVector(
"z")),
48 _id(vpp->declareVector(
"id"))
56 _values.reserve(variable_names.size());
58 for (
const auto & variable_name : variable_names)
71 mooseAssert(values.size() ==
_variable_names.size(),
"Mismatch of variable names to vector size");
72 for (MooseIndex(values) i = 0; i < values.size(); ++i)
73 _values[i]->emplace_back(values[i]);
94 const std::string & var_param_name)
const 98 "Scalar variable '" + var_ptr->
name() +
"' cannot be sampled.");
99 mooseAssert(dynamic_cast<const MooseObject *>(
_vpp),
"Should have succeeded");
101 dynamic_cast<const MooseObject *>(
_vpp)->paramError(
105 "' is a vector variable. Sampling those is not currently supported in the " 106 "framework. It may be supported using a dedicated object in your application. Use " 107 "'VectorVariableComponentAux' auxkernel to copy those values into a regular field " 110 dynamic_cast<const MooseObject *>(
_vpp)->paramError(
114 "' is an array variable. Sampling those is not currently supported in the " 115 "framework. It may be supported using a dedicated object in your application. Use " 116 "'ArrayVariableComponent' auxkernel to copy those values into a regular field variable");
127 constexpr
auto NUM_ID_VECTORS = 4;
129 std::vector<VectorPostprocessorValue *> vec_ptrs;
130 vec_ptrs.reserve(
_values.size() + NUM_ID_VECTORS);
137 for (
auto vec_ptr : vec_ptrs)
141 std::vector<std::size_t> sorted_indices;
153 auto vector_length = sorted_indices.size();
157 for (
const auto vec_ptr : vec_ptrs)
158 if (vec_ptr->size() != vector_length)
163 for (
auto & vec_ptr : vec_ptrs)
165 for (MooseIndex(sorted_indices) j = 0; j < sorted_indices.size(); ++j)
166 tmp_vector[j] = (*vec_ptr)[sorted_indices[j]];
169 vec_ptr->swap(tmp_vector);
176 _x.insert(
_x.end(), y.
_x.begin(), y.
_x.end());
177 _y.insert(
_y.end(), y.
_y.begin(), y.
_y.end());
178 _z.insert(
_z.end(), y.
_z.begin(), y.
_z.end());
Base class for VectorPostprocessors that need to do "sampling" of values in the domain.
virtual void initialize()
Initialize the datastructures.
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
const libMesh::FEType & feType() const
Get the type of finite element object.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
void indirectSort(RandomAccessIterator beg, RandomAccessIterator end, std::vector< size_t > &b)
const std::string & name() const override
Get the variable name.
processor_id_type rank() const
std::vector< std::string > _variable_names
The variable names.
This class provides an interface for common operations on field variables of both FE and FV types wit...
VectorPostprocessorValue & _y
y coordinate of the points
const unsigned int _sort_by
What to sort by.
virtual bool isVector() const =0
std::vector< VectorPostprocessorValue * > _values
void setupVariables(const std::vector< std::string > &variable_names)
You MUST call this in the constructor of the child class and pass down the name of the variables...
bool containsCompleteHistory() const
Return whether or not this VectorPostprocessor contains complete history.
VectorPostprocessor * _vpp
The child VectorPostprocessor.
virtual void threadJoin(const SamplerBase &y)
Join the values.
virtual bool isArray() const
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
VectorPostprocessorValue & _x
x coordinate of the points
static InputParameters validParams()
SamplerBase(const InputParameters ¶meters, VectorPostprocessor *vpp, const libMesh::Parallel::Communicator &comm)
virtual void finalize()
Finalize the values.
std::vector< Real > VectorPostprocessorValue
VectorPostprocessorValue & _id
The node ID of each point.
virtual void addSample(const Point &p, const Real &id, const std::vector< Real > &values)
Call this with the value of every variable at each point you want to sample at.
VectorPostprocessorValue & _z
x coordinate of the points
const libMesh::Parallel::Communicator & _comm
The communicator of the child.
Base class for Postprocessors that produce a vector of values.
void checkForStandardFieldVariableType(const MooseVariableFieldBase *const var_ptr, const std::string &var_param_name="variable") const
Checks whether the passed variable pointer corresponds to a regular single-valued field variable...