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

Transfer Postprocessor from sub-applications to the master application. More...

#include <SamplerPostprocessorTransfer.h>

Inheritance diagram for SamplerPostprocessorTransfer:
[legend]

Public Member Functions

 SamplerPostprocessorTransfer (const InputParameters &parameters)
 
virtual void execute () override
 
virtual void initialSetup () override
 

Protected Attributes

const VectorPostprocessorName & _results_name
 Name of VPP that will store the data. More...
 
SamplerMultiApp_sampler_multi_app
 SamplerMultiApp that this transfer is working with. More...
 
Sampler & _sampler
 Sampler object that is retrieved from the SamplerMultiApp. More...
 
StochasticResults_results
 Storage for StochasticResults object that data will be transferred to/from. More...
 
const std::string & _sub_pp_name
 Name of Postprocessor transferring from. More...
 

Detailed Description

Transfer Postprocessor from sub-applications to the master application.

Definition at line 27 of file SamplerPostprocessorTransfer.h.

Constructor & Destructor Documentation

SamplerPostprocessorTransfer::SamplerPostprocessorTransfer ( const InputParameters &  parameters)

Definition at line 30 of file SamplerPostprocessorTransfer.C.

31  : MultiAppTransfer(parameters),
32  _results_name(getParam<VectorPostprocessorName>("results")),
33  _sampler_multi_app(std::dynamic_pointer_cast<SamplerMultiApp>(_multi_app).get()),
35  _sub_pp_name(getParam<std::string>("postprocessor"))
36 {
37  if (!_sampler_multi_app)
38  mooseError("The 'multi_app' must be a 'SamplerMultiApp.'");
39 }
Sampler & getSampler() const
Return the Sampler object for this MultiApp.
Sampler & _sampler
Sampler object that is retrieved from the SamplerMultiApp.
SamplerMultiApp * _sampler_multi_app
SamplerMultiApp that this transfer is working with.
const VectorPostprocessorName & _results_name
Name of VPP that will store the data.
const std::string & _sub_pp_name
Name of Postprocessor transferring from.

Member Function Documentation

void SamplerPostprocessorTransfer::execute ( )
overridevirtual

Definition at line 55 of file SamplerPostprocessorTransfer.C.

56 {
57  // Number of PP is equal to the number of MultiApps
58  const unsigned int n = _multi_app->numGlobalApps();
59 
60  // Collect the PP values for this processor
61  std::vector<PostprocessorValue> values;
62  values.reserve(_multi_app->numLocalApps());
63  for (unsigned int i = 0; i < n; i++)
64  {
65  if (_multi_app->hasLocalApp(i))
66  {
67  FEProblemBase & app_problem = _multi_app->appProblemBase(i);
68 
69  // use reserve and push_back b/c access to FEProblemBase is based on global id
70  values.push_back(app_problem.getPostprocessorValue(_sub_pp_name));
71  }
72  }
73 
74  // Gather the PP values from all ranks
75  _communicator.allgather<PostprocessorValue>(values);
76 
77  // Update VPP
78  for (unsigned int i = 0; i < n; i++)
79  {
80  Sampler::Location loc = _sampler.getLocation(i);
81  VectorPostprocessorValue & vpp = _results->getVectorPostprocessorValueByGroup(loc.sample());
82  vpp[loc.row()] = values[i];
83  }
84 }
StochasticResults * _results
Storage for StochasticResults object that data will be transferred to/from.
VectorPostprocessorValue & getVectorPostprocessorValueByGroup(unsigned int group)
Return the VectorPostprocessorValue for a given Sampler group index.
Sampler & _sampler
Sampler object that is retrieved from the SamplerMultiApp.
const std::string & _sub_pp_name
Name of Postprocessor transferring from.
void SamplerPostprocessorTransfer::initialSetup ( )
overridevirtual

Definition at line 42 of file SamplerPostprocessorTransfer.C.

43 {
44  const ExecuteMooseObjectWarehouse<UserObject> & user_objects = _fe_problem.getUserObjects();
45  UserObject * uo = user_objects.getActiveObject(_results_name).get();
46  _results = dynamic_cast<StochasticResults *>(uo);
47 
48  if (!_results)
49  mooseError("The 'results' object must be a 'StochasticResults' object.");
50 
52 }
void init(Sampler &_sampler)
Initialize storage based on the Sampler returned by the SamplerMultiApp.
StochasticResults * _results
Storage for StochasticResults object that data will be transferred to/from.
Sampler & _sampler
Sampler object that is retrieved from the SamplerMultiApp.
const VectorPostprocessorName & _results_name
Name of VPP that will store the data.
A tool for output Sampler data.

Member Data Documentation

StochasticResults* SamplerPostprocessorTransfer::_results
protected

Storage for StochasticResults object that data will be transferred to/from.

Definition at line 45 of file SamplerPostprocessorTransfer.h.

Referenced by execute(), and initialSetup().

const VectorPostprocessorName& SamplerPostprocessorTransfer::_results_name
protected

Name of VPP that will store the data.

Definition at line 36 of file SamplerPostprocessorTransfer.h.

Referenced by initialSetup().

Sampler& SamplerPostprocessorTransfer::_sampler
protected

Sampler object that is retrieved from the SamplerMultiApp.

Definition at line 42 of file SamplerPostprocessorTransfer.h.

Referenced by execute(), and initialSetup().

SamplerMultiApp* SamplerPostprocessorTransfer::_sampler_multi_app
protected

SamplerMultiApp that this transfer is working with.

Definition at line 39 of file SamplerPostprocessorTransfer.h.

Referenced by SamplerPostprocessorTransfer().

const std::string& SamplerPostprocessorTransfer::_sub_pp_name
protected

Name of Postprocessor transferring from.

Definition at line 48 of file SamplerPostprocessorTransfer.h.

Referenced by execute().


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