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

UserObject for testing Sampler object threaded and parallel behavior, it should be used for anything else. More...

#include <TestSampler.h>

Inheritance diagram for TestSampler:
[legend]

Public Member Functions

 TestSampler (const InputParameters &parameters)
 

Protected Member Functions

virtual void execute () final
 
virtual void initialize () final
 
virtual void finalize () final
 
virtual void threadJoin (const UserObject &uo) final
 

Protected Attributes

Sampler & _sampler
 
const MooseEnum & _test_type
 

Detailed Description

UserObject for testing Sampler object threaded and parallel behavior, it should be used for anything else.

Definition at line 25 of file TestSampler.h.

Constructor & Destructor Documentation

TestSampler::TestSampler ( const InputParameters &  parameters)

Definition at line 22 of file TestSampler.C.

23  : ElementUserObject(parameters),
24  SamplerInterface(this),
25  _sampler(getSampler("sampler")),
26  _test_type(getParam<MooseEnum>("test_type"))
27 {
28 }
const MooseEnum & _test_type
Definition: TestSampler.h:36
Sampler & _sampler
Definition: TestSampler.h:35

Member Function Documentation

virtual void TestSampler::execute ( )
inlinefinalprotectedvirtual

Definition at line 31 of file TestSampler.h.

31 {}
void TestSampler::finalize ( )
finalprotectedvirtual

Definition at line 31 of file TestSampler.C.

Referenced by initialize().

32 {
33  if (_communicator.size() > 1 && _test_type == "mpi")
34  {
35  std::size_t vec_size;
36  std::vector<Real> samples;
37  if (_communicator.rank() == 0)
38  {
39  samples = _sampler.getSamples()[0].get_values();
40  vec_size = samples.size();
41  }
42 
43  _communicator.broadcast(vec_size);
44  samples.resize(vec_size);
45  _communicator.broadcast(samples);
46 
47  if (_sampler.getSamples()[0].get_values() != samples)
48  mooseError("The sample generation is not working correctly with MPI.");
49  }
50 }
const MooseEnum & _test_type
Definition: TestSampler.h:36
Sampler & _sampler
Definition: TestSampler.h:35
virtual void TestSampler::initialize ( )
inlinefinalprotectedvirtual

Definition at line 32 of file TestSampler.h.

32 {}
void TestSampler::threadJoin ( const UserObject &  uo)
finalprotectedvirtual

Definition at line 53 of file TestSampler.C.

Referenced by initialize().

54 {
55  if (_test_type == "thread")
56  {
57  const TestSampler & other = static_cast<const TestSampler &>(uo);
58  if (_sampler.getSamples() != other._sampler.getSamples())
59  mooseError("The sample generation is not working correctly with threads.");
60  }
61 }
const MooseEnum & _test_type
Definition: TestSampler.h:36
UserObject for testing Sampler object threaded and parallel behavior, it should be used for anything ...
Definition: TestSampler.h:25
Sampler & _sampler
Definition: TestSampler.h:35

Member Data Documentation

Sampler& TestSampler::_sampler
protected

Definition at line 35 of file TestSampler.h.

Referenced by finalize(), and threadJoin().

const MooseEnum& TestSampler::_test_type
protected

Definition at line 36 of file TestSampler.h.

Referenced by finalize(), and threadJoin().


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