www.mooseframework.org
Public Member Functions | Protected 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 initialSetup () override
 

Protected Member Functions

virtual void executeFromMultiapp () override
 

Protected Attributes

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...
 

Detailed Description

Transfer Postprocessor from sub-applications to the master application.

Definition at line 29 of file SamplerPostprocessorTransfer.h.

Constructor & Destructor Documentation

◆ SamplerPostprocessorTransfer()

SamplerPostprocessorTransfer::SamplerPostprocessorTransfer ( const InputParameters &  parameters)

Definition at line 31 of file SamplerPostprocessorTransfer.C.

32  : MultiAppVectorPostprocessorTransfer(parameters),
33  _sampler_multi_app(std::dynamic_pointer_cast<SamplerMultiApp>(_multi_app).get()),
35 {
36  if (!_sampler_multi_app)
37  mooseError("The 'multi_app' must be a 'SamplerMultiApp.'");
38 }
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.

Member Function Documentation

◆ executeFromMultiapp()

void SamplerPostprocessorTransfer::executeFromMultiapp ( )
overrideprotectedvirtual

Definition at line 53 of file SamplerPostprocessorTransfer.C.

54 {
55  // Number of PP is equal to the number of MultiApps
56  const unsigned int n = _multi_app->numGlobalApps();
57 
58  // Collect the PP values for this processor
59  std::vector<PostprocessorValue> values;
60  values.reserve(_multi_app->numLocalApps());
61  for (unsigned int i = 0; i < n; i++)
62  {
63  if (_multi_app->hasLocalApp(i))
64  {
65  FEProblemBase & app_problem = _multi_app->appProblemBase(i);
66 
67  // use reserve and push_back b/c access to FEProblemBase is based on global id
68  values.push_back(app_problem.getPostprocessorValue(_sub_pp_name));
69  }
70  }
71 
72  // Gather the PP values from all ranks
73  _communicator.allgather<PostprocessorValue>(values);
74 
75  // Update VPP
76  for (unsigned int i = 0; i < n; i++)
77  {
78  Sampler::Location loc = _sampler.getLocation(i);
79  VectorPostprocessorValue & vpp = _results->getVectorPostprocessorValueByGroup(loc.sample());
80  vpp[loc.row()] = values[i];
81  }
82 }
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.

◆ initialSetup()

void SamplerPostprocessorTransfer::initialSetup ( )
overridevirtual

Definition at line 41 of file SamplerPostprocessorTransfer.C.

42 {
43  auto & uo = _fe_problem.getUserObject<UserObject>(_master_vpp_name);
44  _results = dynamic_cast<StochasticResults *>(&uo);
45 
46  if (!_results)
47  mooseError("The 'results' object must be a 'StochasticResults' object.");
48 
50 }
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.
A tool for output Sampler data.

Member Data Documentation

◆ _results

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 executeFromMultiapp(), and initialSetup().

◆ _sampler

Sampler& SamplerPostprocessorTransfer::_sampler
protected

Sampler object that is retrieved from the SamplerMultiApp.

Definition at line 42 of file SamplerPostprocessorTransfer.h.

Referenced by executeFromMultiapp(), and initialSetup().

◆ _sampler_multi_app

SamplerMultiApp* SamplerPostprocessorTransfer::_sampler_multi_app
protected

SamplerMultiApp that this transfer is working with.

Definition at line 39 of file SamplerPostprocessorTransfer.h.

Referenced by SamplerPostprocessorTransfer().


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