https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SamplerBase.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12// MOOSE includes
13#include "MooseTypes.h"
14
15// Forward Declarations
16class InputParameters;
18class TransientBase;
19
20namespace libMesh
21{
22class Point;
23
24namespace Parallel
25{
26class Communicator;
27}
28}
29
30template <typename T>
32
38{
39public:
41
47 SamplerBase(const InputParameters & parameters,
50 virtual ~SamplerBase() = default;
51
52protected:
60 void setupVariables(const std::vector<std::string> & variable_names);
61
69 const std::string & var_param_name = "variable") const;
70
77 virtual void addSample(const Point & p, const Real & id, const std::vector<Real> & values);
78
84 virtual void initialize();
85
91 virtual void finalize();
92
101 virtual void threadJoin(const SamplerBase & y);
102
105
108
111
114
116 std::vector<std::string> _variable_names;
117
119 unsigned int _sort_by_index;
120
127
130
131 std::vector<VectorPostprocessorValue *> _values;
132
133private:
135 const std::string _sort_by;
137 std::size_t _curr_num_samples = 0;
139 std::set<std::size_t, std::greater<std::size_t>> _curr_indices;
141 std::size_t _curr_total_samples = 0;
142};
std::vector< Real > VectorPostprocessorValue
Definition MooseTypes.h:231
std::array< Real, 2 > values
Definition MortarUtils.C:52
InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
This class provides an interface for common operations on field variables of both FE and FV types wit...
Base class for VectorPostprocessors that need to do "sampling" of values in the domain.
Definition SamplerBase.h:38
const InputParameters & _sampler_params
The child params.
std::vector< std::string > _variable_names
The variable names.
unsigned int _sort_by_index
The index for what to sort by: x=0, y=1, z=2, then sampled variables in ordered specified in the para...
std::vector< VectorPostprocessorValue * > _values
const std::string _sort_by
What to sort by.
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.
Definition SamplerBase.C:91
VectorPostprocessorValue & _x
x coordinate of the points
VectorPostprocessorValue & _y
y coordinate of the points
const TransientBase *const _sampler_transient
Transient executioner used to determine if the last solve converged.
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.
Definition SamplerBase.C:69
virtual void initialize()
Initialize the datastructures.
virtual void threadJoin(const SamplerBase &y)
Join the values.
VectorPostprocessor * _vpp
The child VectorPostprocessor.
VectorPostprocessorValue & _id
The node ID of each point.
VectorPostprocessorValue & _z
x coordinate of the points
virtual void finalize()
Finalize the values.
std::size_t _curr_num_samples
The number of samples added in the last execution.
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.
std::size_t _curr_total_samples
The full size of the vector since the last execution.
const libMesh::Parallel::Communicator & _comm
The communicator of the child.
std::set< std::size_t, std::greater< std::size_t > > _curr_indices
The indices of the samples in the last execution.
virtual ~SamplerBase()=default
static InputParameters validParams()
Definition SamplerBase.C:24
Base class for transient executioners that use a FixedPointSolve solve object for multiapp-main app i...
Base class for Postprocessors that produce a vector of values.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...