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 23 of file SamplerData.h.

Constructor & Destructor Documentation

SamplerData::SamplerData ( const InputParameters &  parameters)

Definition at line 32 of file SamplerData.C.

33  : GeneralVectorPostprocessor(parameters),
34  SamplerInterface(this),
35  _sampler(getSampler("sampler")),
36  _output_col_row_sizes(getParam<bool>("output_column_and_row_sizes"))
37 {
38 }
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:38
Sampler & _sampler
The sampler to extract data.
Definition: SamplerData.h:35

Member Function Documentation

void SamplerData::execute ( )
overridevirtual

Definition at line 48 of file SamplerData.C.

49 {
50  std::vector<DenseMatrix<Real>> data = _sampler.getSamples();
51  auto n = data.size();
52  if (_sample_vectors.empty())
53  {
54  _sample_vectors.resize(n);
55  for (auto i = beginIndex(data); i < n; ++i)
56  {
57  std::string name = "mat_" + std::to_string(i);
58  _sample_vectors[i] = &declareVector(name);
59  }
60  }
61 
62  for (auto i = beginIndex(data); i < n; ++i)
63  {
64  const std::size_t offset = _output_col_row_sizes ? 2 : 0;
65  const std::size_t vec_size = data[i].get_values().size() + offset;
66  _sample_vectors[i]->resize(vec_size);
68  {
69  (*_sample_vectors[i])[0] = data[i].n(); // number of columns
70  (*_sample_vectors[i])[1] = data[i].m(); // number of rows
71  }
72  std::copy(data[i].get_values().begin(),
73  data[i].get_values().end(),
74  _sample_vectors[i]->begin() + offset);
75  }
76 }
std::vector< VectorPostprocessorValue * > _sample_vectors
Storage for declared vectors.
Definition: SamplerData.h:32
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:38
Sampler & _sampler
The sampler to extract data.
Definition: SamplerData.h:35
void SamplerData::initialize ( )
overridevirtual

Definition at line 41 of file SamplerData.C.

42 {
43  for (auto ptr : _sample_vectors)
44  ptr->clear();
45 }
std::vector< VectorPostprocessorValue * > _sample_vectors
Storage for declared vectors.
Definition: SamplerData.h:32

Member Data Documentation

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 38 of file SamplerData.h.

Referenced by execute().

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

Storage for declared vectors.

Definition at line 32 of file SamplerData.h.

Referenced by execute(), and initialize().

Sampler& SamplerData::_sampler
protected

The sampler to extract data.

Definition at line 35 of file SamplerData.h.

Referenced by execute().


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