Base class for VectorPostprocessors that need to do "sampling" of values in the domain. More...
#include <SamplerBase.h>
Public Member Functions | |
SamplerBase (const InputParameters ¶meters, VectorPostprocessor *vpp, const libMesh::Parallel::Communicator &comm) | |
virtual | ~SamplerBase ()=default |
Static Public Member Functions | |
static InputParameters | validParams () |
Protected Member Functions | |
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. More... | |
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. More... | |
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. More... | |
virtual void | initialize () |
Initialize the datastructures. More... | |
virtual void | finalize () |
Finalize the values. More... | |
virtual void | threadJoin (const SamplerBase &y) |
Join the values. More... | |
Protected Attributes | |
const InputParameters & | _sampler_params |
The child params. More... | |
VectorPostprocessor * | _vpp |
The child VectorPostprocessor. More... | |
const libMesh::Parallel::Communicator & | _comm |
The communicator of the child. More... | |
const TransientBase *const | _sampler_transient |
Transient executioner used to determine if the last solve converged. More... | |
std::vector< std::string > | _variable_names |
The variable names. More... | |
const unsigned int | _sort_by |
What to sort by. More... | |
VectorPostprocessorValue & | _x |
x coordinate of the points More... | |
VectorPostprocessorValue & | _y |
y coordinate of the points More... | |
VectorPostprocessorValue & | _z |
x coordinate of the points More... | |
VectorPostprocessorValue & | _id |
The node ID of each point. More... | |
std::vector< VectorPostprocessorValue * > | _values |
Private Attributes | |
std::size_t | _curr_num_samples = 0 |
The number of samples added in the last execution. More... | |
std::set< std::size_t, std::greater< std::size_t > > | _curr_indices |
The indices of the samples in the last execution. More... | |
std::size_t | _curr_total_samples = 0 |
The full size of the vector since the last execution. More... | |
Base class for VectorPostprocessors that need to do "sampling" of values in the domain.
Definition at line 37 of file SamplerBase.h.
SamplerBase::SamplerBase | ( | const InputParameters & | parameters, |
VectorPostprocessor * | vpp, | ||
const libMesh::Parallel::Communicator & | comm | ||
) |
parameters | The parameters for the object |
vpp | A pointer to the child object |
comm | The communicator of the child |
Definition at line 41 of file SamplerBase.C.
|
virtualdefault |
|
protectedvirtual |
Call this with the value of every variable at each point you want to sample at.
p | The point where you took the sample |
id | This can either be an actual ID or a distance or anything else you want |
values | The value of each variable |
Definition at line 70 of file SamplerBase.C.
Referenced by SideValueSampler::execute(), LineFunctionSampler::execute(), ElementValueSampler::execute(), NodalValueSampler::execute(), and PointSamplerBase::finalize().
|
protected |
Checks whether the passed variable pointer corresponds to a regular single-valued field variable.
var_param_name | name of the variable parameter in which the variables were passed |
var_ptr | pointer to the field variable |
Definition at line 132 of file SamplerBase.C.
Referenced by ElementValueSampler::ElementValueSampler(), NodalValueSampler::NodalValueSampler(), PointVariableSamplerBase::PointVariableSamplerBase(), and SideValueSampler::SideValueSampler().
|
protectedvirtual |
Finalize the values.
YOU MUST CALL THIS DURING finalize() in the child class!
We have several vectors that all need to be processed in the same way. Rather than enumerate them all, let's just create a vector of pointers and work on them that way.
We now have one sorted vector. The remaining vectors need to be sorted according to that vector. We'll need a temporary vector to hold values as we map them according to the sorted indices. After that, we'll swap the vector contents with the sorted vector to get the values back into the original vector.
Reimplemented in LineMaterialSamplerBase< T >, LineMaterialSamplerBase< Real >, PointSamplerBase, ElementValueSampler, NodalValueSampler, LineFunctionSampler, and SideValueSampler.
Definition at line 159 of file SamplerBase.C.
Referenced by SideValueSampler::finalize(), LineFunctionSampler::finalize(), NodalValueSampler::finalize(), ElementValueSampler::finalize(), PointSamplerBase::finalize(), and LineMaterialSamplerBase< Real >::finalize().
|
protectedvirtual |
Initialize the datastructures.
YOU MUST CALL THIS DURING initialize() in the child class!
Reimplemented in LineMaterialSamplerBase< T >, LineMaterialSamplerBase< Real >, PointSamplerBase, PointVariableSamplerBase, PositionsFunctorValueSampler, ElementValueSampler, NodalValueSampler, LineFunctionSampler, and SideValueSampler.
Definition at line 86 of file SamplerBase.C.
Referenced by SideValueSampler::initialize(), LineFunctionSampler::initialize(), NodalValueSampler::initialize(), ElementValueSampler::initialize(), PointSamplerBase::initialize(), and LineMaterialSamplerBase< Real >::initialize().
|
protected |
You MUST call this in the constructor of the child class and pass down the name of the variables.
variable_names | The names of the variables. Note: The order of the variables sets the order of the values for addSample() |
Definition at line 60 of file SamplerBase.C.
Referenced by ElementValueSampler::ElementValueSampler(), LineFunctionSampler::LineFunctionSampler(), LineMaterialSamplerBase< Real >::LineMaterialSamplerBase(), NodalValueSampler::NodalValueSampler(), PointVariableSamplerBase::PointVariableSamplerBase(), PositionsFunctorValueSampler::PositionsFunctorValueSampler(), and SideValueSampler::SideValueSampler().
|
protectedvirtual |
Join the values.
YOU MUST CALL THIS DURING threadJoin() in the child class!
y | You must cast the UserObject to your child class type first then you can pass it in here. |
Definition at line 225 of file SamplerBase.C.
Referenced by SideValueSampler::threadJoin(), ElementValueSampler::threadJoin(), and NodalValueSampler::threadJoin().
|
static |
Definition at line 27 of file SamplerBase.C.
Referenced by SideValueSampler::validParams(), LineFunctionSampler::validParams(), NodalValueSampler::validParams(), ElementValueSampler::validParams(), PointVariableSamplerBase::validParams(), PointSamplerBase::validParams(), and LineMaterialSamplerBase< Real >::validParams().
|
protected |
The communicator of the child.
Definition at line 110 of file SamplerBase.h.
Referenced by PointSamplerBase::finalize(), finalize(), and initialize().
|
private |
The indices of the samples in the last execution.
Definition at line 137 of file SamplerBase.h.
Referenced by finalize(), and initialize().
|
private |
The number of samples added in the last execution.
Definition at line 135 of file SamplerBase.h.
Referenced by addSample(), finalize(), initialize(), and threadJoin().
|
private |
The full size of the vector since the last execution.
Definition at line 139 of file SamplerBase.h.
Referenced by finalize(), and initialize().
|
protected |
The node ID of each point.
Definition at line 129 of file SamplerBase.h.
Referenced by addSample(), finalize(), LineValueSampler::getValue(), initialize(), and threadJoin().
|
protected |
The child params.
Definition at line 104 of file SamplerBase.h.
|
protected |
Transient executioner used to determine if the last solve converged.
Definition at line 113 of file SamplerBase.h.
Referenced by initialize().
|
protected |
What to sort by.
Definition at line 119 of file SamplerBase.h.
Referenced by finalize(), and LineValueSampler::getValue().
|
protected |
Definition at line 131 of file SamplerBase.h.
Referenced by addSample(), finalize(), LineValueSampler::getValue(), initialize(), setupVariables(), and threadJoin().
|
protected |
The variable names.
Definition at line 116 of file SamplerBase.h.
Referenced by addSample(), setupVariables(), and threadJoin().
|
protected |
The child VectorPostprocessor.
Definition at line 107 of file SamplerBase.h.
Referenced by checkForStandardFieldVariableType(), finalize(), initialize(), and setupVariables().
|
protected |
x coordinate of the points
Definition at line 122 of file SamplerBase.h.
Referenced by addSample(), finalize(), initialize(), and threadJoin().
|
protected |
y coordinate of the points
Definition at line 124 of file SamplerBase.h.
Referenced by addSample(), finalize(), initialize(), and threadJoin().
|
protected |
x coordinate of the points
Definition at line 126 of file SamplerBase.h.
Referenced by addSample(), finalize(), initialize(), and threadJoin().