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

Sampler * _sampler
 Sampler object that is retrieved from the SamplerTransientMultiApp or SamplerFullSolveMultiApp. 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 32 of file SamplerPostprocessorTransfer.C.

33  : MultiAppVectorPostprocessorTransfer(parameters)
34 {
35  // Determine the Sampler
36  std::shared_ptr<SamplerTransientMultiApp> ptr_transient =
37  std::dynamic_pointer_cast<SamplerTransientMultiApp>(_multi_app);
38  std::shared_ptr<SamplerFullSolveMultiApp> ptr_fullsolve =
39  std::dynamic_pointer_cast<SamplerFullSolveMultiApp>(_multi_app);
40 
41  if (!ptr_transient && !ptr_fullsolve)
42  mooseError("The 'multi_app' parameter must provide either a 'SamplerTransientMultiApp' or "
43  "'SamplerFullSolveMultiApp' object.");
44 
45  if (ptr_transient)
46  _sampler = &(ptr_transient->getSampler());
47  else
48  _sampler = &(ptr_fullsolve->getSampler());
49 }
Sampler * _sampler
Sampler object that is retrieved from the SamplerTransientMultiApp or SamplerFullSolveMultiApp.

Member Function Documentation

◆ executeFromMultiapp()

void SamplerPostprocessorTransfer::executeFromMultiapp ( )
overrideprotectedvirtual

Definition at line 64 of file SamplerPostprocessorTransfer.C.

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

◆ initialSetup()

void SamplerPostprocessorTransfer::initialSetup ( )
overridevirtual

Definition at line 52 of file SamplerPostprocessorTransfer.C.

53 {
54  auto & uo = _fe_problem.getUserObject<UserObject>(_master_vpp_name);
55  _results = dynamic_cast<StochasticResults *>(&uo);
56 
57  if (!_results)
58  mooseError("The 'results' object must be a 'StochasticResults' object.");
59 
61 }
void init(Sampler &_sampler)
Initialize storage based on the Sampler returned by the SamplerTransientMultiApp or SamplerFullSolveM...
StochasticResults * _results
Storage for StochasticResults object that data will be transferred to/from.
Sampler * _sampler
Sampler object that is retrieved from the SamplerTransientMultiApp or SamplerFullSolveMultiApp.
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 42 of file SamplerPostprocessorTransfer.h.

Referenced by executeFromMultiapp(), and initialSetup().

◆ _sampler

Sampler* SamplerPostprocessorTransfer::_sampler
protected

Sampler object that is retrieved from the SamplerTransientMultiApp or SamplerFullSolveMultiApp.

Definition at line 39 of file SamplerPostprocessorTransfer.h.

Referenced by executeFromMultiapp(), initialSetup(), and SamplerPostprocessorTransfer().


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