https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
SerializedSolutionTransfer Class Reference

This class is responsible for serializing solutions coming from subapps on specific processors. More...

#include <SerializedSolutionTransfer.h>

Inheritance diagram for SerializedSolutionTransfer:
[legend]

Public Types

enum  DIRECTION
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 SerializedSolutionTransfer (const InputParameters &parameters)
 
virtual void initialSetup () override
 
virtual void execute () override
 
void setGlobalMultiAppIndex (dof_id_type index)
 Method for setting the app index when running in batch mode. More...
 
void setGlobalRowIndex (dof_id_type row)
 Method for keeping track of the global row index when running in batch mode. More...
 
void setCurrentRow (const std::vector< Real > &row)
 Method for keeping track of the row data when running in batch mode. More...
 
void variableIntegrityCheck (const AuxVariableName &var_name, bool is_from_multiapp) const
 
const std::shared_ptr< MultiAppgetMultiApp () const
 
const std::shared_ptr< MultiAppgetFromMultiApp () const
 
const std::shared_ptr< MultiAppgetToMultiApp () const
 
std::string getFromName () const
 
std::string getToName () const
 
bool hasFromMultiApp () const
 
bool hasToMultiApp () const
 
virtual void getAppInfo ()
 
const MultiMooseEnumdirections ()
 
void setCurrentDirection (const int direction)
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void residualSetup ()
 
virtual void subdomainSetup ()
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnumgetExecuteOnEnum () const
 
PerfGraphperfGraph ()
 
MooseEnum direction ()
 
MooseEnum direction ()
 
MooseEnum currentDirection ()
 
MooseEnum currentDirection ()
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
void initializeFromMultiapp () override
 Methods used when running in batch mode (see SamplerFullSolveMultiApp) More...
 
void executeFromMultiapp () override
 
void finalizeFromMultiapp () override
 
void initializeToMultiapp () override
 Methods for transferring data to sub-applications to the master application. More...
 
void executeToMultiapp () override
 
void finalizeToMultiapp () override
 

Static Public Member Functions

static InputParameters validParams ()
 
static void addSkipCoordCollapsingParam (InputParameters &params)
 
static libMesh::Systemfind_sys (libMesh::EquationSystems &es, const std::string &var_name)
 
static std::string possibleDirections ()
 

Public Attributes

 TO_MULTIAPP
 
 FROM_MULTIAPP
 
 BETWEEN_MULTIAPP
 
const ConsoleStream _console
 

Static Public Attributes

static const libMesh::Number OutOfMeshValue
 

Protected Member Functions

std::vector< unsigned intgetFromsPerProc ()
 
libMesh::NumericVector< Real > & getTransferVector (unsigned int i_local, std::string var_name)
 
unsigned int getGlobalSourceAppIndex (unsigned int i_from) const
 
unsigned int getGlobalTargetAppIndex (unsigned int i_to) const
 
unsigned int getLocalSourceAppIndex (unsigned int i_from) const
 
virtual void checkSiblingsTransferSupported () const
 
void errorIfObjectExecutesOnTransferInSourceApp (const std::string &object_name) const
 
Point getPointInTargetAppFrame (const Point &p, unsigned int local_i_to, const std::string &phase) const
 
void checkMultiAppExecuteOn ()
 
void checkVariable (const FEProblemBase &fe_problem, const VariableName &var_name, const std::string &param_name="") const
 
void extendBoundingBoxes (const Real factor, std::vector< libMesh::BoundingBox > &bboxes) const
 
T & declareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const T & getRestartableData (const std::string &data_name) const
 
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 
std::vector< libMesh::BoundingBoxgetFromBoundingBoxes ()
 
std::vector< libMesh::BoundingBoxgetFromBoundingBoxes (BoundaryID boundary_id)
 
std::vector< libMesh::BoundingBoxgetFromBoundingBoxes ()
 
std::vector< libMesh::BoundingBoxgetFromBoundingBoxes (BoundaryID boundary_id)
 

Static Protected Member Functions

static void addBBoxFactorParam (InputParameters &params)
 
static void transformBoundingBox (libMesh::BoundingBox &box, const MultiAppCoordTransform &transform)
 

Protected Attributes

ParallelSolutionStorage_parallel_storage
 The storage on the main application where the serialized solutions should be transferred. More...
 
std::vector< VariableName > _variable_names
 The names of the variables which should be extracted from the solution vector. More...
 
std::vector< SolutionContainer * > _solution_container
 Link to the storage spaces on the subapplications (will only hold one in batch mode) More...
 
dof_id_type _app_index = 0
 Index for the sub-app that the batch-mode multiapp is working on. More...
 
dof_id_type _global_index = 0
 Index for tracking the row index when using batch mode operation. More...
 
std::vector< Real_row_data
 The current row of data (comes from multiapp) More...
 
Sampler_sampler_ptr
 Pointer to the Sampler object used by the SamplerTransientMultiApp or SamplerFullSolveMultiApp. More...
 
std::shared_ptr< MultiApp_multi_app
 
std::vector< FEProblemBase *> _to_problems
 
std::vector< FEProblemBase *> _from_problems
 
std::vector< libMesh::EquationSystems *> _to_es
 
std::vector< libMesh::EquationSystems *> _from_es
 
std::vector< MooseMesh *> _to_meshes
 
std::vector< MooseMesh *> _from_meshes
 
std::vector< Point > _to_positions
 
std::vector< Point > _from_positions
 
std::vector< std::unique_ptr< MultiAppCoordTransform > > _to_transforms
 
std::vector< std::unique_ptr< MultiAppCoordTransform > > _from_transforms
 
const bool _skip_coordinate_collapsing
 
bool _displaced_source_mesh
 
bool _displaced_target_mesh
 
Real _bbox_factor
 
std::vector< unsigned int_to_local2global_map
 
std::vector< unsigned int_from_local2global_map
 
SubProblem_subproblem
 
FEProblemBase_fe_problem
 
SystemBase_sys
 
THREAD_ID _tid
 
MultiMooseEnum _directions
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
const ExecFlagEnum_execute_enum
 
const ExecFlagType_current_execute_flag
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
MooseEnum _direction
 
MooseEnum _current_direction
 
const Parallel::Communicator & _communicator
 

Private Member Functions

void transferToSubAppRoot (FEProblemBase &app_problem, SolutionContainer &solution_container, const dof_id_type global_i)
 Serialize on the root processor of the subapplication and transfer the result to the main application. More...
 
void transferInParallel (FEProblemBase &app_problem, SolutionContainer &solution_container, const dof_id_type global_i)
 Serialize on methodically determined rank of the subapp and transfer to the main application. More...
 
void initializeInNormalMode ()
 Initializes the solution container if the multiapp is run in normal mode. More...
 
void initializeInBatchMode ()
 This routine queries the solution container addresses from the subapps. More...
 
SystemBasegetSystem (FEProblemBase &app_problem, const VariableName &vname)
 Return the system which contains the given variable. More...
 

Private Attributes

const bool _serialize_on_root
 User-selected switch that determines if we want to serialize on the root of the subapp only or distribute the solutions between all the ranks of the subapp. More...
 

Detailed Description

This class is responsible for serializing solutions coming from subapps on specific processors.

It is designed to serve as an interface between SolutionContainer and ParallelSolutionStorage objects.

Definition at line 26 of file SerializedSolutionTransfer.h.

Constructor & Destructor Documentation

◆ SerializedSolutionTransfer()

SerializedSolutionTransfer::SerializedSolutionTransfer ( const InputParameters parameters)

Definition at line 37 of file SerializedSolutionTransfer.C.

39  _variable_names(getParam<std::vector<VariableName>>("variables")),
40  _serialize_on_root(getParam<bool>("serialize_on_root"))
41 {
42  if (hasToMultiApp())
43  paramError("to_multi_app", "To and between multiapp directions are not implemented");
44 }
const bool _serialize_on_root
User-selected switch that determines if we want to serialize on the root of the subapp only or distri...
const T & getParam(const std::string &name) const
void paramError(const std::string &param, Args... args) const
bool hasToMultiApp() const
const InputParameters & parameters() const
StochasticToolsTransfer(const InputParameters &parameters)
std::vector< VariableName > _variable_names
The names of the variables which should be extracted from the solution vector.

Member Function Documentation

◆ execute()

void SerializedSolutionTransfer::execute ( )
overridevirtual

Implements MultiAppTransfer.

Definition at line 84 of file SerializedSolutionTransfer.C.

85 {
87 
88  const auto n = getFromMultiApp()->numGlobalApps();
89 
90  for (MooseIndex(n) i = 0; i < n; i++)
91  {
92  if (getFromMultiApp()->hasLocalApp(i))
93  {
94  FEProblemBase & app_problem = getFromMultiApp()->appProblemBase(i);
95 
96  // Converting the local indexing to global sample indices
97  const unsigned int local_i = i - _sampler_ptr->getLocalRowBegin();
98 
99  // Here we have to branch out based on if only the root processors
100  // need to participate in the transfer or if we would like to distribute the
101  // data among every processor of the subapplication
102  if (_serialize_on_root)
103  transferToSubAppRoot(app_problem, *_solution_container[local_i], i);
104  else
105  transferInParallel(app_problem, *_solution_container[local_i], i);
106  }
107  }
108 }
Sampler * _sampler_ptr
Pointer to the Sampler object used by the SamplerTransientMultiApp or SamplerFullSolveMultiApp.
const std::shared_ptr< MultiApp > getFromMultiApp() const
void initializeInNormalMode()
Initializes the solution container if the multiapp is run in normal mode.
dof_id_type getLocalRowBegin() const
const bool _serialize_on_root
User-selected switch that determines if we want to serialize on the root of the subapp only or distri...
void transferInParallel(FEProblemBase &app_problem, SolutionContainer &solution_container, const dof_id_type global_i)
Serialize on methodically determined rank of the subapp and transfer to the main application.
void transferToSubAppRoot(FEProblemBase &app_problem, SolutionContainer &solution_container, const dof_id_type global_i)
Serialize on the root processor of the subapplication and transfer the result to the main application...
std::vector< SolutionContainer * > _solution_container
Link to the storage spaces on the subapplications (will only hold one in batch mode) ...

◆ executeFromMultiapp()

void SerializedSolutionTransfer::executeFromMultiapp ( )
overridevirtual

Reimplemented from StochasticToolsTransfer.

Definition at line 111 of file SerializedSolutionTransfer.C.

112 {
114 
115  if (getFromMultiApp()->hasLocalApp(_app_index))
116  {
117  FEProblemBase & app_problem = getFromMultiApp()->appProblemBase(_app_index);
118 
119  // Here we have to branch out based on if only the root processors
120  // need to participate in the transfer or if we would like to distribute the
121  // data among every processor of the subapplication
122  if (_serialize_on_root)
124  else
126  }
127 }
dof_id_type _global_index
Index for tracking the row index when using batch mode operation.
const std::shared_ptr< MultiApp > getFromMultiApp() const
void initializeInBatchMode()
This routine queries the solution container addresses from the subapps.
const bool _serialize_on_root
User-selected switch that determines if we want to serialize on the root of the subapp only or distri...
void transferInParallel(FEProblemBase &app_problem, SolutionContainer &solution_container, const dof_id_type global_i)
Serialize on methodically determined rank of the subapp and transfer to the main application.
dof_id_type _app_index
Index for the sub-app that the batch-mode multiapp is working on.
void transferToSubAppRoot(FEProblemBase &app_problem, SolutionContainer &solution_container, const dof_id_type global_i)
Serialize on the root processor of the subapplication and transfer the result to the main application...
std::vector< SolutionContainer * > _solution_container
Link to the storage spaces on the subapplications (will only hold one in batch mode) ...

◆ executeToMultiapp()

void SerializedSolutionTransfer::executeToMultiapp ( )
inlineoverridevirtual

Reimplemented from StochasticToolsTransfer.

Definition at line 45 of file SerializedSolutionTransfer.h.

45 {}

◆ finalizeFromMultiapp()

void SerializedSolutionTransfer::finalizeFromMultiapp ( )
inlineoverridevirtual

Reimplemented from StochasticToolsTransfer.

Definition at line 42 of file SerializedSolutionTransfer.h.

42 {}

◆ finalizeToMultiapp()

void SerializedSolutionTransfer::finalizeToMultiapp ( )
inlineoverridevirtual

Reimplemented from StochasticToolsTransfer.

Definition at line 46 of file SerializedSolutionTransfer.h.

46 {}

◆ getSystem()

SystemBase & SerializedSolutionTransfer::getSystem ( FEProblemBase app_problem,
const VariableName &  vname 
)
private

Return the system which contains the given variable.

It can either be a flavor of a nonlinear system or the auxiliary system.

Parameters
vnameThe name of the variable whose system is queried

Definition at line 211 of file SerializedSolutionTransfer.C.

Referenced by transferInParallel(), and transferToSubAppRoot().

212 {
213  auto & variable = app_problem.getVariable(_tid, vname);
214  return variable.sys();
215 }
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
SystemBase & sys()

◆ initializeFromMultiapp()

void SerializedSolutionTransfer::initializeFromMultiapp ( )
inlineoverridevirtual

Methods used when running in batch mode (see SamplerFullSolveMultiApp)

Reimplemented from StochasticToolsTransfer.

Definition at line 40 of file SerializedSolutionTransfer.h.

40 {}

◆ initializeInBatchMode()

void SerializedSolutionTransfer::initializeInBatchMode ( )
private

This routine queries the solution container addresses from the subapps.

We need to redo this every time initialSetup() (batch-reset) is called on the subapp because the address of SolutionContainer changes. Considering that the transfer doesn't know the multiapp setting, we use the same approach for batch-restore as well, which might be a little wasteful if the execution of the subapps is very fast (usually not the case).

Definition at line 71 of file SerializedSolutionTransfer.C.

Referenced by executeFromMultiapp().

72 {
73  // First we fetch the solution containers from the subapps. This function is used
74  // in batch mode only so we will have one solution container on each rank
75  _solution_container.clear();
76 
77  FEProblemBase & app_problem = getFromMultiApp()->appProblemBase(_app_index);
78 
79  _solution_container.push_back(
80  &app_problem.getUserObject<SolutionContainer>(getParam<std::string>("solution_container")));
81 }
T & getUserObject(const std::string &name, unsigned int tid=0) const
const std::shared_ptr< MultiApp > getFromMultiApp() const
dof_id_type _app_index
Index for the sub-app that the batch-mode multiapp is working on.
This class is responsible for collecting solution vectors in one place.
std::vector< SolutionContainer * > _solution_container
Link to the storage spaces on the subapplications (will only hold one in batch mode) ...

◆ initializeInNormalMode()

void SerializedSolutionTransfer::initializeInNormalMode ( )
private

Initializes the solution container if the multiapp is run in normal mode.

We need this because in normal mode we don't have a function for initialization besides initialSetup(), which is execute every time regardless of the multiapp settings.

Definition at line 55 of file SerializedSolutionTransfer.C.

Referenced by execute().

56 {
57  _solution_container.clear();
58  const auto n = getFromMultiApp()->numGlobalApps();
59  const auto & serialized_solution_reporter = getParam<std::string>("solution_container");
60 
61  for (MooseIndex(n) i = 0; i < n; i++)
62  if (getFromMultiApp()->hasLocalApp(i))
63  {
64  FEProblemBase & app_problem = getFromMultiApp()->appProblemBase(i);
65  _solution_container.push_back(
66  &app_problem.getUserObject<SolutionContainer>(serialized_solution_reporter));
67  }
68 }
T & getUserObject(const std::string &name, unsigned int tid=0) const
const std::shared_ptr< MultiApp > getFromMultiApp() const
This class is responsible for collecting solution vectors in one place.
std::vector< SolutionContainer * > _solution_container
Link to the storage spaces on the subapplications (will only hold one in batch mode) ...

◆ initializeToMultiapp()

void SerializedSolutionTransfer::initializeToMultiapp ( )
inlineoverridevirtual

Methods for transferring data to sub-applications to the master application.

Reimplemented from StochasticToolsTransfer.

Definition at line 44 of file SerializedSolutionTransfer.h.

44 {}

◆ initialSetup()

void SerializedSolutionTransfer::initialSetup ( )
overridevirtual

Reimplemented from MultiAppTransfer.

Definition at line 47 of file SerializedSolutionTransfer.C.

48 {
49  // Check if we have the storage space to receive the serialized solution fields
51  getParam<std::string>("parallel_storage"));
52 }
T & getUserObject(const std::string &name, unsigned int tid=0) const
FEProblemBase & _fe_problem
ParallelSolutionStorage * _parallel_storage
The storage on the main application where the serialized solutions should be transferred.
A Reporter which stores serialized solution fields for given variables in a distributed fashion...

◆ setCurrentRow()

void StochasticToolsTransfer::setCurrentRow ( const std::vector< Real > &  row)
inlineinherited

Method for keeping track of the row data when running in batch mode.

See StochasticTools<FullSolve/Transient>MultiApp

Definition at line 65 of file StochasticToolsTransfer.h.

65 { _row_data = row; }
std::vector< Real > _row_data
The current row of data (comes from multiapp)

◆ setGlobalMultiAppIndex()

void StochasticToolsTransfer::setGlobalMultiAppIndex ( dof_id_type  index)
inlineinherited

Method for setting the app index when running in batch mode.

See StochasticTools<FullSolve/Transient>MultiApp

Definition at line 51 of file StochasticToolsTransfer.h.

51 { _app_index = index; }
dof_id_type _app_index
Index for the sub-app that the batch-mode multiapp is working on.

◆ setGlobalRowIndex()

void StochasticToolsTransfer::setGlobalRowIndex ( dof_id_type  row)
inlineinherited

Method for keeping track of the global row index when running in batch mode.

See StochasticTools<FullSolve/Transient>MultiApp

Definition at line 58 of file StochasticToolsTransfer.h.

58 { _global_index = row; }
dof_id_type _global_index
Index for tracking the row index when using batch mode operation.

◆ transferInParallel()

void SerializedSolutionTransfer::transferInParallel ( FEProblemBase app_problem,
SolutionContainer solution_container,
const dof_id_type  global_i 
)
private

Serialize on methodically determined rank of the subapp and transfer to the main application.

Example: Let's say we have 5 samples and 3 processors on a sub-application. In this case, we will serialize the first two on rank 1, the second two on rank 2 and the last one on rank 3.

Definition at line 130 of file SerializedSolutionTransfer.C.

Referenced by execute(), and executeFromMultiapp().

133 {
134  unsigned int local_app_index = global_i - _sampler_ptr->getLocalRowBegin();
135 
136  // Looping over the variables to extract the corresponding solution values
137  // and copy them into the container.
138  for (unsigned int var_i = 0; var_i < _variable_names.size(); ++var_i)
139  {
140  SystemBase & system = getSystem(app_problem, _variable_names[var_i]);
141 
142  // We need to go through this communicator because the multiapp's
143  // communicator is not necessarily the communicator of the underlying MooseObject.
144  const auto & comm = system.comm();
146  comm.sum(num_entries);
147 
148  // We shall distribute the samples on the given application between its processors.
149  // Only using a linear partitioning here for the sake of simplicity.
150  dof_id_type new_local_entries_begin;
151  dof_id_type new_local_entries_end;
152  dof_id_type num_new_local_entries;
153 
155  comm.size(),
156  comm.rank(),
157  num_new_local_entries,
158  new_local_entries_begin,
159  new_local_entries_end);
160 
161  // Getting the corresponding DoF indices for the variable.
162  system.setVariableGlobalDoFs(_variable_names[var_i]);
163 
164  for (const auto & snapshot : solution_container.getSnapshots())
165  {
166  DenseVector<Real> serialized_solution;
167 
168  // Localize the solution and add it to the local container on the rank
169  // which is supposed to own it
170  snapshot.localize(
171  serialized_solution.get_values(),
172  (local_app_index >= new_local_entries_begin && local_app_index < new_local_entries_end)
173  ? system.getVariableGlobalDoFs()
174  : std::vector<dof_id_type>());
175 
176  if (local_app_index >= new_local_entries_begin && local_app_index < new_local_entries_end)
177  _parallel_storage->addEntry(_variable_names[var_i], global_i, serialized_solution);
178  }
179  }
180 }
Sampler * _sampler_ptr
Pointer to the Sampler object used by the SamplerTransientMultiApp or SamplerFullSolveMultiApp.
const Snapshots & getSnapshots() const
Return the whole snapshot container.
void addEntry(const VariableName &vname, unsigned int global_i, const DenseVector< Real > &solution)
Add a new solution entry to the container.
processor_id_type rank() const
dof_id_type getLocalRowBegin() const
const Parallel::Communicator & comm() const
void linearPartitionItems(dof_id_type num_items, dof_id_type num_chunks, dof_id_type chunk_id, dof_id_type &num_local_items, dof_id_type &local_items_begin, dof_id_type &local_items_end)
dof_id_type getNumberOfLocalRows() const
processor_id_type size() const
const std::vector< dof_id_type > & getVariableGlobalDoFs()
SystemBase & getSystem(FEProblemBase &app_problem, const VariableName &vname)
Return the system which contains the given variable.
ParallelSolutionStorage * _parallel_storage
The storage on the main application where the serialized solutions should be transferred.
void setVariableGlobalDoFs(const std::string &var_name)
std::vector< VariableName > _variable_names
The names of the variables which should be extracted from the solution vector.
uint8_t dof_id_type

◆ transferToSubAppRoot()

void SerializedSolutionTransfer::transferToSubAppRoot ( FEProblemBase app_problem,
SolutionContainer solution_container,
const dof_id_type  global_i 
)
private

Serialize on the root processor of the subapplication and transfer the result to the main application.

Definition at line 183 of file SerializedSolutionTransfer.C.

Referenced by execute(), and executeFromMultiapp().

186 {
187  // Looping over the variables to extract the corresponding solution values
188  for (unsigned int var_i = 0; var_i < _variable_names.size(); ++var_i)
189  {
190  SystemBase & system = getSystem(app_problem, _variable_names[var_i]);
191 
192  // Getting the corresponding DoF indices for the variable.
193  system.setVariableGlobalDoFs(_variable_names[var_i]);
194 
195  for (const auto & snapshot : solution_container.getSnapshots())
196  {
197  DenseVector<Real> serialized_solution;
198 
199  // In this case we always serialize on the root processor of the application.
200  snapshot.localize(serialized_solution.get_values(),
201  getFromMultiApp()->isRootProcessor() ? system.getVariableGlobalDoFs()
202  : std::vector<dof_id_type>());
203 
204  if (getFromMultiApp()->isRootProcessor())
205  _parallel_storage->addEntry(_variable_names[var_i], global_i, serialized_solution);
206  }
207  }
208 }
const std::shared_ptr< MultiApp > getFromMultiApp() const
const Snapshots & getSnapshots() const
Return the whole snapshot container.
void addEntry(const VariableName &vname, unsigned int global_i, const DenseVector< Real > &solution)
Add a new solution entry to the container.
const std::vector< dof_id_type > & getVariableGlobalDoFs()
SystemBase & getSystem(FEProblemBase &app_problem, const VariableName &vname)
Return the system which contains the given variable.
ParallelSolutionStorage * _parallel_storage
The storage on the main application where the serialized solutions should be transferred.
void setVariableGlobalDoFs(const std::string &var_name)
std::vector< VariableName > _variable_names
The names of the variables which should be extracted from the solution vector.

◆ validParams()

InputParameters SerializedSolutionTransfer::validParams ( )
static

Definition at line 18 of file SerializedSolutionTransfer.C.

19 {
21  params.addClassDescription(
22  "Serializes and transfers solution vectors for given variables from sub-applications.");
23  params.addRequiredParam<std::string>("parallel_storage",
24  "The name of the parallel storage reporter.");
25  params.addRequiredParam<std::string>("solution_container",
26  "The name of the solution container on the subapp.");
27  params.addRequiredParam<std::vector<VariableName>>(
28  "variables",
29  "The names of the variables which should be serialized and transferred to this application.");
30  params.addParam<bool>("serialize_on_root",
31  false,
32  "If we want to gather the solution fields only on the root processors of "
33  "the subapps before transfering to the main app.");
34  return params;
35 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _app_index

dof_id_type StochasticToolsTransfer::_app_index = 0
protectedinherited

Index for the sub-app that the batch-mode multiapp is working on.

Definition at line 69 of file StochasticToolsTransfer.h.

Referenced by executeFromMultiapp(), SamplerParameterTransfer::executeToMultiapp(), initializeInBatchMode(), and StochasticToolsTransfer::setGlobalMultiAppIndex().

◆ _global_index

dof_id_type StochasticToolsTransfer::_global_index = 0
protectedinherited

◆ _parallel_storage

ParallelSolutionStorage* SerializedSolutionTransfer::_parallel_storage
protected

The storage on the main application where the serialized solutions should be transferred.

Definition at line 52 of file SerializedSolutionTransfer.h.

Referenced by initialSetup(), transferInParallel(), and transferToSubAppRoot().

◆ _row_data

std::vector<Real> StochasticToolsTransfer::_row_data
protectedinherited

The current row of data (comes from multiapp)

Definition at line 73 of file StochasticToolsTransfer.h.

Referenced by SamplerParameterTransfer::executeToMultiapp(), and StochasticToolsTransfer::setCurrentRow().

◆ _sampler_ptr

Sampler* StochasticToolsTransfer::_sampler_ptr
protectedinherited

◆ _serialize_on_root

const bool SerializedSolutionTransfer::_serialize_on_root
private

User-selected switch that determines if we want to serialize on the root of the subapp only or distribute the solutions between all the ranks of the subapp.

Definition at line 97 of file SerializedSolutionTransfer.h.

Referenced by execute(), and executeFromMultiapp().

◆ _solution_container

std::vector<SolutionContainer *> SerializedSolutionTransfer::_solution_container
protected

Link to the storage spaces on the subapplications (will only hold one in batch mode)

Definition at line 58 of file SerializedSolutionTransfer.h.

Referenced by execute(), executeFromMultiapp(), initializeInBatchMode(), and initializeInNormalMode().

◆ _variable_names

std::vector<VariableName> SerializedSolutionTransfer::_variable_names
protected

The names of the variables which should be extracted from the solution vector.

Definition at line 55 of file SerializedSolutionTransfer.h.

Referenced by transferInParallel(), and transferToSubAppRoot().


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