21 #include "libmesh/point.h" 33 params.
set<
bool>(
"_auto_broadcast") =
false;
41 : _sampler_params(parameters),
45 parameters.getCheckedPointerParam<
FEProblemBase *>(
"_fe_problem_base")
49 _x(vpp->declareVector(
"x")),
50 _y(vpp->declareVector(
"y")),
51 _z(vpp->declareVector(
"z")),
52 _id(vpp->declareVector(
"id"))
60 _values.reserve(variable_names.size());
62 for (
const auto & variable_name : variable_names)
75 mooseAssert(values.size() ==
_variable_names.size(),
"Mismatch of variable names to vector size");
76 for (MooseIndex(values) i = 0; i < values.size(); ++i)
77 _values[i]->emplace_back(values[i]);
93 std::vector<VectorPostprocessorValue *> vec_ptrs = {{&
_x, &
_y, &
_z, &
_id}};
96 for (
auto vec_ptr : vec_ptrs)
102 "Number of samples is not what is expected.");
107 mooseAssert(ind < vec_ptr->size(),
"Trying to remove a sample that doesn't exist.");
108 vec_ptr->erase(vec_ptr->begin() + ind);
130 const std::string & var_param_name)
const 134 "Scalar variable '" + var_ptr->
name() +
"' cannot be sampled.");
135 mooseAssert(dynamic_cast<const MooseObject *>(
_vpp),
"Should have succeeded");
137 dynamic_cast<const MooseObject *>(
_vpp)->paramError(
141 "' is a vector variable. Sampling those is not currently supported in the " 142 "framework. It may be supported using a dedicated object in your application. Use " 143 "'VectorVariableComponentAux' auxkernel to copy those values into a regular field " 146 dynamic_cast<const MooseObject *>(
_vpp)->paramError(
150 "' is an array variable. Sampling those is not currently supported in the " 151 "framework. It may be supported using a dedicated object in your application. Use " 152 "'ArrayVariableComponent' auxkernel to copy those values into a regular field variable");
163 constexpr
auto NUM_ID_VECTORS = 4;
165 std::vector<VectorPostprocessorValue *> vec_ptrs;
166 vec_ptrs.reserve(
_values.size() + NUM_ID_VECTORS);
173 for (
auto vec_ptr : vec_ptrs)
177 std::vector<std::size_t> sorted_indices;
189 auto vector_length = sorted_indices.size();
193 for (
const auto vec_ptr : vec_ptrs)
194 if (vec_ptr->size() != vector_length)
199 for (
auto & vec_ptr : vec_ptrs)
201 for (MooseIndex(sorted_indices) j = 0; j < sorted_indices.size(); ++j)
202 tmp_vector[j] = (*vec_ptr)[sorted_indices[j]];
205 vec_ptr->swap(tmp_vector);
224 _x.insert(
_x.end(), y.
_x.begin(), y.
_x.end());
225 _y.insert(
_y.end(), y.
_y.begin(), y.
_y.end());
226 _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...
const TransientBase *const _sampler_transient
Transient executioner used to determine if the last solve converged.
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)
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...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
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
const std::string & name() const
Get the name of the class.
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
std::set< std::size_t, std::greater< std::size_t > > _curr_indices
The indices of the samples in the last execution.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
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.
std::size_t _curr_total_samples
The full size of the vector since the last execution.
VectorPostprocessorValue & _z
x coordinate of the points
const libMesh::Parallel::Communicator & _comm
The communicator of the child.
virtual bool lastSolveConverged() const override
Whether or not the last solve converged.
std::size_t _curr_num_samples
The number of samples added in the last execution.
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...