www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
SamplerData Class Reference

A tool for output Sampler data. More...

#include <SamplerData.h>

Inheritance diagram for SamplerData:
[legend]

Public Member Functions

 SamplerData (const InputParameters &parameters)
 
virtual void initialize () override
 
virtual void execute () override
 

Protected Attributes

std::vector< VectorPostprocessorValue * > _sample_vectors
 Storage for declared vectors. More...
 
Sampler & _sampler
 The sampler to extract data. More...
 
const bool & _output_col_row_sizes
 Whether to output the number of rows and columns in the first two rows of output. More...
 

Detailed Description

A tool for output Sampler data.

Definition at line 25 of file SamplerData.h.

Constructor & Destructor Documentation

◆ SamplerData()

SamplerData::SamplerData ( const InputParameters &  parameters)

Definition at line 36 of file SamplerData.C.

37  : GeneralVectorPostprocessor(parameters),
38  SamplerInterface(this),
39  _sampler(getSampler("sampler")),
40  _output_col_row_sizes(getParam<bool>("output_column_and_row_sizes"))
41 {
42 }
const bool & _output_col_row_sizes
Whether to output the number of rows and columns in the first two rows of output. ...
Definition: SamplerData.h:40
Sampler & _sampler
The sampler to extract data.
Definition: SamplerData.h:37

Member Function Documentation

◆ execute()

void SamplerData::execute ( )
overridevirtual

Definition at line 52 of file SamplerData.C.

53 {
54  std::vector<DenseMatrix<Real>> data = _sampler.getSamples();
55  auto n = data.size();
56  if (_sample_vectors.empty())
57  {
58  _sample_vectors.resize(n);
59  for (auto i = beginIndex(data); i < n; ++i)
60  {
61  std::string name = "mat_" + std::to_string(i);
62  _sample_vectors[i] = &declareVector(name);
63  }
64  }
65 
66  for (auto i = beginIndex(data); i < n; ++i)
67  {
68  const std::size_t offset = _output_col_row_sizes ? 2 : 0;
69  const std::size_t vec_size = data[i].get_values().size() + offset;
70  _sample_vectors[i]->resize(vec_size);
72  {
73  (*_sample_vectors[i])[0] = data[i].n(); // number of columns
74  (*_sample_vectors[i])[1] = data[i].m(); // number of rows
75  }
76  std::copy(data[i].get_values().begin(),
77  data[i].get_values().end(),
78  _sample_vectors[i]->begin() + offset);
79  }
80 }
std::vector< VectorPostprocessorValue * > _sample_vectors
Storage for declared vectors.
Definition: SamplerData.h:34
const std::string name
Definition: Setup.h:22
const bool & _output_col_row_sizes
Whether to output the number of rows and columns in the first two rows of output. ...
Definition: SamplerData.h:40
Sampler & _sampler
The sampler to extract data.
Definition: SamplerData.h:37

◆ initialize()

void SamplerData::initialize ( )
overridevirtual

Definition at line 45 of file SamplerData.C.

46 {
47  for (auto ptr : _sample_vectors)
48  ptr->clear();
49 }
std::vector< VectorPostprocessorValue * > _sample_vectors
Storage for declared vectors.
Definition: SamplerData.h:34

Member Data Documentation

◆ _output_col_row_sizes

const bool& SamplerData::_output_col_row_sizes
protected

Whether to output the number of rows and columns in the first two rows of output.

Definition at line 40 of file SamplerData.h.

Referenced by execute().

◆ _sample_vectors

std::vector<VectorPostprocessorValue *> SamplerData::_sample_vectors
protected

Storage for declared vectors.

Definition at line 34 of file SamplerData.h.

Referenced by execute(), and initialize().

◆ _sampler

Sampler& SamplerData::_sampler
protected

The sampler to extract data.

Definition at line 37 of file SamplerData.h.

Referenced by execute().


The documentation for this class was generated from the following files: