The Sampler class is used to sample selected Pipeline properties during simulations.
More...
#include <sampler.hpp>
|
| Sampler (const std::filesystem::path &path, const arma::uword interval=60, const bool append=false, const arma::uvec indicesToSample={}) |
| Construct given output directory and (optional) print interval. More...
|
|
void | addPropertyToPrint (PropertyGetter samplingFunction) |
| Add property to save to file. This automatically determines the label and filename of the property. More...
|
|
void | addPropertyToPrint (PropertyGetter samplingFunction, const std::string &label) |
| Add property to print with explicit label. More...
|
|
bool | sample (const Pipeline &pipeline, const bool forceSample=false) |
| Sample current state. This is usually only called by Simulator, but can also be called to force a sample. More...
|
|
const std::filesystem::path & | outputDir () const |
| Get (const ref) output directory.
|
|
Sampler & | setIndicesToSample (const arma::uvec &indices) |
|
The Sampler class is used to sample selected Pipeline properties during simulations.
Adding new properties to sample is done via Sampler::addPropertyToPrint.
Control of which properties to sample is implemented via pointers to member functions/getters of Pipeline, which are stored in m_samplers, together with a label.
◆ Sampler()
Sampler::Sampler |
( |
const std::filesystem::path & |
path, |
|
|
const arma::uword |
interval = 60 , |
|
|
const bool |
append = false , |
|
|
const arma::uvec |
indicesToSample = {} |
|
) |
| |
Construct given output directory and (optional) print interval.
- Parameters
-
path | Where to store results |
interval | How often to sample (max) [s] |
append | If we should append to (true) or overwrite existing output files (false) |
◆ addPropertyToPrint() [1/2]
Add property to save to file. This automatically determines the label and filename of the property.
- Parameters
-
samplingFunction | Pointer to Pipeline property getter |
◆ addPropertyToPrint() [2/2]
void Sampler::addPropertyToPrint |
( |
PropertyGetter |
samplingFunction, |
|
|
const std::string & |
label |
|
) |
| |
Add property to print with explicit label.
- Parameters
-
samplingFunction | Pointer to Pipeline property getter |
label | Property label (filename will be <label>.csv) |
◆ getSampleLabel()
static std::string Sampler::getSampleLabel |
( |
PropertyGetter |
samplingFunction | ) |
|
|
static |
Automatically determines property label from Pipeline getter function pointer.
◆ makeOutputDir()
static std::filesystem::path Sampler::makeOutputDir |
( |
const std::filesystem::path & |
path | ) |
|
|
static |
Make output directory from string. Does some checks to see if directory exists, and creates it if it doesn't exists. Throws error if directory is a file, or if directory can't be created.
◆ sample()
bool Sampler::sample |
( |
const Pipeline & |
pipeline, |
|
|
const bool |
forceSample = false |
|
) |
| |
Sample current state. This is usually only called by Simulator, but can also be called to force a sample.
- Parameters
-
pipeline | Pipeline instance to sample |
forceSample | [bool] |
- Returns
- true if a sample was recorded, else false
◆ setIndicesToSample()
Sampler& Sampler::setIndicesToSample |
( |
const arma::uvec & |
indices | ) |
|
Set which indices to sample. Empty vector means that we sample all points.
◆ m_indicesToSample
arma::uvec Sampler::m_indicesToSample {} |
|
private |
Which grid points to sample. Empty vector means that we sample all points.
◆ m_outputFiles
std::vector<std::ofstream> Sampler::m_outputFiles |
|
private |
Output file streams, one for each property. Should be in the same order as m_samplers.
◆ m_samplers
The documentation for this class was generated from the following file:
- D:/Code/transient-pipeline-flow-gh-pages/src/sampler.hpp