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 | List of all members
PODSamplerSolutionTransfer Class Reference

Transfer solutions from sub-applications to a container in a Trainer. More...

#include <PODSamplerSolutionTransfer.h>

Inheritance diagram for PODSamplerSolutionTransfer:
[legend]

Public Types

enum  DIRECTION
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 PODSamplerSolutionTransfer (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
 
virtual void initializeFromMultiapp () override
 Methods used when running in batch mode (see SamplerFullSolveMultiApp) More...
 
virtual void executeFromMultiapp () override
 
virtual void finalizeFromMultiapp () override
 
virtual void initializeToMultiapp () override
 Methods for transferring data to sub-applications to the master application. More...
 
virtual void executeToMultiapp () override
 
virtual 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

std::shared_ptr< PODFullSolveMultiApp_pod_multi_app
 The input multiapp casted into a PODFullSolveMultiapp to get access to the specific pod attributes. More...
 
PODReducedBasisTrainer_trainer
 The trainer object to save the solution vector into or to fetch the artificial solution vectors from. 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

template<>
SurrogateModelgetSurrogateModel (const std::string &name) const
 
template<>
SurrogateTrainerBasegetSurrogateTrainer (const std::string &name) const
 
template<>
SurrogateModelgetSurrogateModelByName (const UserObjectName &name) const
 
template<>
SurrogateTrainerBasegetSurrogateTrainerByName (const UserObjectName &name) const
 
template<typename T = SurrogateModel>
T & getSurrogateModel (const std::string &name) const
 Get a SurrogateModel/Trainer with a given name. More...
 
template<typename T = SurrogateTrainerBase>
T & getSurrogateTrainer (const std::string &name) const
 
template<typename T = SurrogateModel>
T & getSurrogateModelByName (const UserObjectName &name) const
 Get a sampler with a given name. More...
 
template<typename T = SurrogateTrainerBase>
T & getSurrogateTrainerByName (const UserObjectName &name) const
 

Detailed Description

Transfer solutions from sub-applications to a container in a Trainer.

This object also transfers artificial solution vectors back to sub-applications.

Definition at line 24 of file PODSamplerSolutionTransfer.h.

Constructor & Destructor Documentation

◆ PODSamplerSolutionTransfer()

PODSamplerSolutionTransfer::PODSamplerSolutionTransfer ( const InputParameters parameters)

Definition at line 29 of file PODSamplerSolutionTransfer.C.

33  ? std::dynamic_pointer_cast<PODFullSolveMultiApp>(getFromMultiApp())
34  : std::dynamic_pointer_cast<PODFullSolveMultiApp>(getToMultiApp())),
35  _trainer(getSurrogateTrainer<PODReducedBasisTrainer>("trainer_name"))
36 {
37  if (!_pod_multi_app)
38  paramError("multi_app", "The Multiapp given is not a PODFullsolveMultiapp!");
39 }
std::shared_ptr< PODFullSolveMultiApp > _pod_multi_app
The input multiapp casted into a PODFullSolveMultiapp to get access to the specific pod attributes...
const std::shared_ptr< MultiApp > getFromMultiApp() const
const std::shared_ptr< MultiApp > getToMultiApp() const
bool hasFromMultiApp() const
void paramError(const std::string &param, Args... args) const
const InputParameters & parameters() const
PODReducedBasisTrainer & _trainer
The trainer object to save the solution vector into or to fetch the artificial solution vectors from...
StochasticToolsTransfer(const InputParameters &parameters)
SurrogateModelInterface(const MooseObject *moose_object)

Member Function Documentation

◆ execute()

void PODSamplerSolutionTransfer::execute ( )
overridevirtual

Implements MultiAppTransfer.

Reimplemented in PODResidualTransfer.

Definition at line 59 of file PODSamplerSolutionTransfer.C.

60 {
61 
62  const std::vector<std::string> & var_names = _trainer.getVarNames();
63 
64  // Selecting the appropriate action based on the drection.
65  switch (_direction)
66  {
67  case FROM_MULTIAPP:
68 
69  // Looping over sub-apps created for different samples
71  ++i)
72  {
73  // Getting reference to the solution vector of the sub-app.
74  FEProblemBase & app_problem = getFromMultiApp()->appProblemBase(i);
75  NonlinearSystemBase & nl = app_problem.getNonlinearSystemBase(/*nl_sys_num=*/0);
76  NumericVector<Number> & solution = nl.solution();
77 
78  // Looping over the variables to extract the corresponding solution values
79  // and copy them into the container of the trainer.
80  for (unsigned int v_index = 0; v_index < var_names.size(); ++v_index)
81  {
82  // Getting the corresponding DoF indices for the variable.
83  nl.setVariableGlobalDoFs(var_names[v_index]);
84  const std::vector<dof_id_type> & var_dofs = nl.getVariableGlobalDoFs();
85 
86  // Initializing a temporary vector for the partial solution.
87  std::shared_ptr<DenseVector<Real>> tmp = std::make_shared<DenseVector<Real>>();
88  solution.localize(tmp->get_values(), var_dofs);
89 
90  // Copying the temporary vector into the trainer.
91  _trainer.addSnapshot(v_index, i, tmp);
92  }
93  }
94  break;
95 
96  case TO_MULTIAPP:
97 
98  // Looping over all the variables in the trainer to copy the corresponding
99  // basis vectors into the solution.
100  unsigned int counter = 0;
101  for (unsigned int var_i = 0; var_i < var_names.size(); ++var_i)
102  {
103  // Looping over the bases of the given variable and plugging them into
104  // a sub-application.
105  unsigned int var_base_num = _trainer.getBaseSize(var_i);
106  for (unsigned int base_i = 0; base_i < var_base_num; ++base_i)
107  {
108  if (getToMultiApp()->hasLocalApp(counter))
109  {
110  // Getting the reference to the solution vector in the subapp.
111  FEProblemBase & app_problem = getToMultiApp()->appProblemBase(counter);
112  NonlinearSystemBase & nl = app_problem.getNonlinearSystemBase(/*nl_sys_num=*/0);
113  NumericVector<Number> & solution = nl.solution();
114 
115  // Zeroing the solution to make sure that only the required part
116  // is non-zero after copy.
117  solution.zero();
118 
119  // Getting the degrees of freedom for the given variable.
120  nl.setVariableGlobalDoFs(var_names[var_i]);
121  const std::vector<dof_id_type> & var_dofs = nl.getVariableGlobalDoFs();
122 
123  // Fetching the basis vector and plugging it into the solution.
124  const DenseVector<Real> & base_vector = _trainer.getBasisVector(var_i, base_i);
125  solution.insert(base_vector, var_dofs);
126  solution.close();
127 
128  // Make sure that the sub-application uses this vector to evaluate the
129  // residual.
130  nl.setSolution(solution);
131  }
132  counter++;
133  }
134  }
135  break;
136  }
137 }
virtual void insert(const Number *v, const std::vector< numeric_index_type > &dof_indices)
Sampler * _sampler_ptr
Pointer to the Sampler object used by the SamplerTransientMultiApp or SamplerFullSolveMultiApp.
const std::shared_ptr< MultiApp > getFromMultiApp() const
NumericVector< Number > & solution()
dof_id_type getLocalRowBegin() const
void setSolution(const NumericVector< Number > &soln)
const std::shared_ptr< MultiApp > getToMultiApp() const
void addSnapshot(unsigned int var_i, unsigned int glob_i, const std::shared_ptr< DenseVector< Real >> &snapshot)
Adding a snapshot for a variable.
virtual void zero()=0
const std::vector< dof_id_type > & getVariableGlobalDoFs()
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
virtual void close()=0
dof_id_type getLocalRowEnd() const
MooseEnum _direction
unsigned int getBaseSize(unsigned int var_i) const
Getting the base size for variable with index v_ind.
PODReducedBasisTrainer & _trainer
The trainer object to save the solution vector into or to fetch the artificial solution vectors from...
void setVariableGlobalDoFs(const std::string &var_name)
const std::vector< std::string > & getVarNames() const
const DenseVector< Real > & getBasisVector(unsigned int var_i, unsigned int base_i) const
Getting a basis vector for a given variable.
uint8_t dof_id_type
virtual void localize(std::vector< Number > &v_local) const =0

◆ executeFromMultiapp()

void PODSamplerSolutionTransfer::executeFromMultiapp ( )
overridevirtual

Reimplemented from StochasticToolsTransfer.

Reimplemented in PODResidualTransfer.

Definition at line 145 of file PODSamplerSolutionTransfer.C.

146 {
147  if (_pod_multi_app->snapshotGeneration())
148  {
149  const std::vector<std::string> & var_names = _trainer.getVarNames();
150 
151  const dof_id_type n = getFromMultiApp()->numGlobalApps();
152 
153  for (MooseIndex(n) i = 0; i < n; i++)
154  {
155  if (getFromMultiApp()->hasLocalApp(i))
156  {
157  // Getting reference to the solution vector of the sub-app.
158  FEProblemBase & app_problem = getFromMultiApp()->appProblemBase(i);
159  NonlinearSystemBase & nl = app_problem.getNonlinearSystemBase(/*nl_sys_num=*/0);
160  NumericVector<Number> & solution = nl.solution();
161 
162  // Looping over the variables to extract the corresponding solution values
163  // and copy them into the container of the trainer.
164  for (unsigned int var_i = 0; var_i < var_names.size(); ++var_i)
165  {
166  // Getting the corresponding DoF indices for the variable.
167  nl.setVariableGlobalDoFs(var_names[var_i]);
168  const std::vector<dof_id_type> & var_dofs = nl.getVariableGlobalDoFs();
169 
170  // Initializing a temporary vector for the partial solution.
171  std::shared_ptr<DenseVector<Real>> tmp = std::make_shared<DenseVector<Real>>();
172  solution.localize(tmp->get_values(), var_dofs);
173 
174  // Copying the temporary vector into the trainer.
175  _trainer.addSnapshot(var_i, _global_index, tmp);
176  }
177  }
178  }
179  }
180 }
dof_id_type _global_index
Index for tracking the row index when using batch mode operation.
std::shared_ptr< PODFullSolveMultiApp > _pod_multi_app
The input multiapp casted into a PODFullSolveMultiapp to get access to the specific pod attributes...
const std::shared_ptr< MultiApp > getFromMultiApp() const
NumericVector< Number > & solution()
void addSnapshot(unsigned int var_i, unsigned int glob_i, const std::shared_ptr< DenseVector< Real >> &snapshot)
Adding a snapshot for a variable.
const std::vector< dof_id_type > & getVariableGlobalDoFs()
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
PODReducedBasisTrainer & _trainer
The trainer object to save the solution vector into or to fetch the artificial solution vectors from...
void setVariableGlobalDoFs(const std::string &var_name)
const std::vector< std::string > & getVarNames() const
uint8_t dof_id_type
virtual void localize(std::vector< Number > &v_local) const =0

◆ executeToMultiapp()

void PODSamplerSolutionTransfer::executeToMultiapp ( )
overridevirtual

Reimplemented from StochasticToolsTransfer.

Definition at line 193 of file PODSamplerSolutionTransfer.C.

194 {
195  if (!_pod_multi_app->snapshotGeneration())
196  {
197  const std::vector<std::string> & var_names = _trainer.getVarNames();
199 
200  // Getting the reference to the solution vector in the subapp.
201  FEProblemBase & app_problem = getToMultiApp()->appProblemBase(processor_id());
202  NonlinearSystemBase & nl = app_problem.getNonlinearSystemBase(/*nl_sys_num=*/0);
203  NumericVector<Number> & solution = nl.solution();
204 
205  // Zeroing the solution to make sure that only the required part
206  // is non-zero after copy.
207  solution.zero();
208 
209  // Getting the degrees of freedom for the given variable.
210  nl.setVariableGlobalDoFs(var_names[var_i]);
211  const std::vector<dof_id_type> & var_dofs = nl.getVariableGlobalDoFs();
212 
213  // Fetching the basis vector and plugging it into the solution.
214  const DenseVector<Real> & base_vector = _trainer.getBasisVector(_global_index);
215  solution.insert(base_vector, var_dofs);
216  solution.close();
217 
218  // Make sure that the sub-application uses this vector to evaluate the
219  // residual.
220  nl.setSolution(solution);
221  }
222 }
dof_id_type _global_index
Index for tracking the row index when using batch mode operation.
virtual void insert(const Number *v, const std::vector< numeric_index_type > &dof_indices)
std::shared_ptr< PODFullSolveMultiApp > _pod_multi_app
The input multiapp casted into a PODFullSolveMultiapp to get access to the specific pod attributes...
NumericVector< Number > & solution()
void setSolution(const NumericVector< Number > &soln)
const std::shared_ptr< MultiApp > getToMultiApp() const
virtual void zero()=0
const std::vector< dof_id_type > & getVariableGlobalDoFs()
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
unsigned int getVariableIndex(unsigned int glob_i) const
Getting appropriate variable index for a global base index.
virtual void close()=0
PODReducedBasisTrainer & _trainer
The trainer object to save the solution vector into or to fetch the artificial solution vectors from...
void setVariableGlobalDoFs(const std::string &var_name)
processor_id_type processor_id() const
const std::vector< std::string > & getVarNames() const
const DenseVector< Real > & getBasisVector(unsigned int var_i, unsigned int base_i) const
Getting a basis vector for a given variable.
uint8_t dof_id_type

◆ finalizeFromMultiapp()

void PODSamplerSolutionTransfer::finalizeFromMultiapp ( )
overridevirtual

Reimplemented from StochasticToolsTransfer.

Reimplemented in PODResidualTransfer.

Definition at line 183 of file PODSamplerSolutionTransfer.C.

184 {
185 }

◆ finalizeToMultiapp()

void PODSamplerSolutionTransfer::finalizeToMultiapp ( )
overridevirtual

Reimplemented from StochasticToolsTransfer.

Definition at line 225 of file PODSamplerSolutionTransfer.C.

226 {
227 }

◆ getSurrogateModel() [1/2]

template<>
SurrogateModel& SurrogateModelInterface::getSurrogateModel ( const std::string &  name) const
inherited

Definition at line 46 of file SurrogateModelInterface.C.

47 {
48  return getSurrogateModelByName<SurrogateModel>(_smi_params.get<UserObjectName>(name));
49 }
const InputParameters & _smi_params
Parameters of the object with this interface.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
const std::string name
Definition: Setup.h:20

◆ getSurrogateModel() [2/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateModel ( const std::string &  name) const
inherited

Get a SurrogateModel/Trainer with a given name.

Parameters
nameThe name of the parameter key of the sampler to retrieve
Returns
The sampler with name associated with the parameter 'name'

Definition at line 81 of file SurrogateModelInterface.h.

Referenced by SurrogateTrainer::initialize().

82 {
83  return getSurrogateModelByName<T>(_smi_params.get<UserObjectName>(name));
84 }
const InputParameters & _smi_params
Parameters of the object with this interface.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
const std::string name
Definition: Setup.h:20

◆ getSurrogateModelByName() [1/2]

template<>
SurrogateModel& SurrogateModelInterface::getSurrogateModelByName ( const UserObjectName &  name) const
inherited

Definition at line 31 of file SurrogateModelInterface.C.

32 {
33  std::vector<SurrogateModel *> models;
35  .query()
36  .condition<AttribName>(name)
37  .condition<AttribSystem>("SurrogateModel")
38  .queryInto(models);
39  if (models.empty())
40  mooseError("Unable to find a SurrogateModel object with the name '" + name + "'");
41  return *(models[0]);
42 }
void mooseError(Args &&... args)
FEProblemBase & _smi_feproblem
Reference to FEProblemBase instance.
TheWarehouse & theWarehouse() const
const std::string name
Definition: Setup.h:20
Query query()

◆ getSurrogateModelByName() [2/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateModelByName ( const UserObjectName &  name) const
inherited

Get a sampler with a given name.

Parameters
nameThe name of the sampler to retrieve
Returns
The sampler with name 'name'

Definition at line 88 of file SurrogateModelInterface.h.

Referenced by CrossValidationScores::CrossValidationScores(), EvaluateSurrogate::EvaluateSurrogate(), and InverseMapping::initialSetup().

89 {
90  std::vector<T *> models;
92  .query()
93  .condition<AttribName>(name)
94  .condition<AttribSystem>("SurrogateModel")
95  .queryInto(models);
96  if (models.empty())
97  mooseError("Unable to find a SurrogateModel object of type " + std::string(typeid(T).name()) +
98  " with the name '" + name + "'");
99  return *(models[0]);
100 }
void mooseError(Args &&... args)
FEProblemBase & _smi_feproblem
Reference to FEProblemBase instance.
TheWarehouse & theWarehouse() const
const std::string name
Definition: Setup.h:20
Query query()

◆ getSurrogateTrainer() [1/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateTrainer ( const std::string &  name) const
inherited

Definition at line 104 of file SurrogateModelInterface.h.

105 {
106  return getSurrogateTrainerByName<T>(_smi_params.get<UserObjectName>(name));
107 }
const InputParameters & _smi_params
Parameters of the object with this interface.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
const std::string name
Definition: Setup.h:20

◆ getSurrogateTrainer() [2/2]

template<>
SurrogateTrainerBase& SurrogateModelInterface::getSurrogateTrainer ( const std::string &  name) const
inherited

Definition at line 60 of file SurrogateModelInterface.C.

61 {
62  return getSurrogateTrainerByName<SurrogateTrainerBase>(_smi_params.get<UserObjectName>(name));
63 }
const InputParameters & _smi_params
Parameters of the object with this interface.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
const std::string name
Definition: Setup.h:20

◆ getSurrogateTrainerByName() [1/2]

template<>
SurrogateTrainerBase& SurrogateModelInterface::getSurrogateTrainerByName ( const UserObjectName &  name) const
inherited

Definition at line 53 of file SurrogateModelInterface.C.

54 {
56 }
T & getUserObject(const std::string &name, unsigned int tid=0) const
FEProblemBase & _smi_feproblem
Reference to FEProblemBase instance.
const std::string name
Definition: Setup.h:20
This is the base trainer class whose main functionality is the API for declaring model data...

◆ getSurrogateTrainerByName() [2/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateTrainerByName ( const UserObjectName &  name) const
inherited

Definition at line 111 of file SurrogateModelInterface.h.

Referenced by SurrogateTrainerOutput::output().

112 {
113  SurrogateTrainerBase * base_ptr =
115  T * obj_ptr = dynamic_cast<T *>(base_ptr);
116  if (!obj_ptr)
117  mooseError("Failed to find a SurrogateTrainer object of type " + std::string(typeid(T).name()) +
118  " with the name '",
119  name,
120  "' for the desired type.");
121  return *obj_ptr;
122 }
T & getUserObject(const std::string &name, unsigned int tid=0) const
void mooseError(Args &&... args)
FEProblemBase & _smi_feproblem
Reference to FEProblemBase instance.
const std::string name
Definition: Setup.h:20
const THREAD_ID _smi_tid
Thread ID.
This is the base trainer class whose main functionality is the API for declaring model data...

◆ initializeFromMultiapp()

void PODSamplerSolutionTransfer::initializeFromMultiapp ( )
overridevirtual

Methods used when running in batch mode (see SamplerFullSolveMultiApp)

Reimplemented from StochasticToolsTransfer.

Reimplemented in PODResidualTransfer.

Definition at line 140 of file PODSamplerSolutionTransfer.C.

141 {
142 }

◆ initializeToMultiapp()

void PODSamplerSolutionTransfer::initializeToMultiapp ( )
overridevirtual

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

Reimplemented from StochasticToolsTransfer.

Definition at line 188 of file PODSamplerSolutionTransfer.C.

189 {
190 }

◆ initialSetup()

void PODSamplerSolutionTransfer::initialSetup ( )
overridevirtual

Reimplemented from MultiAppTransfer.

Definition at line 42 of file PODSamplerSolutionTransfer.C.

43 {
44  const auto multi_app = hasFromMultiApp() ? getFromMultiApp() : getToMultiApp();
45 
46  // Checking if the subapplication has the requested variables
47  const std::vector<std::string> & var_names = _trainer.getVarNames();
48  const dof_id_type n = multi_app->numGlobalApps();
49  for (MooseIndex(n) i = 0; i < n; i++)
50  {
51  if (multi_app->hasLocalApp(i))
52  for (auto var_name : var_names)
53  if (!multi_app->appProblemBase(i).hasVariable(var_name))
54  mooseError("Variable '" + var_name + "' not found on sub-application ", i, "!");
55  }
56 }
const std::shared_ptr< MultiApp > getFromMultiApp() const
const std::shared_ptr< MultiApp > getToMultiApp() const
bool hasFromMultiApp() const
void mooseError(Args &&... args) const
PODReducedBasisTrainer & _trainer
The trainer object to save the solution vector into or to fetch the artificial solution vectors from...
const std::vector< std::string > & getVarNames() const
uint8_t dof_id_type

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

◆ validParams()

InputParameters PODSamplerSolutionTransfer::validParams ( )
static

Definition at line 18 of file PODSamplerSolutionTransfer.C.

Referenced by PODResidualTransfer::validParams().

19 {
21  params.addClassDescription("Transfers solution vectors from the sub-applications to a "
22  "a container in the Trainer object and back.");
23  params.addRequiredParam<UserObjectName>("trainer_name",
24  "Trainer object that contains the solutions"
25  " for different samples.");
26  return params;
27 }
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

◆ _global_index

dof_id_type StochasticToolsTransfer::_global_index = 0
protectedinherited

◆ _pod_multi_app

std::shared_ptr<PODFullSolveMultiApp> PODSamplerSolutionTransfer::_pod_multi_app
protected

The input multiapp casted into a PODFullSolveMultiapp to get access to the specific pod attributes.

Used in batch mode only and checking if the correct MultiApp type has been provided.

Definition at line 50 of file PODSamplerSolutionTransfer.h.

Referenced by executeFromMultiapp(), executeToMultiapp(), and PODSamplerSolutionTransfer().

◆ _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

◆ _trainer

PODReducedBasisTrainer& PODSamplerSolutionTransfer::_trainer
protected

The trainer object to save the solution vector into or to fetch the artificial solution vectors from.

Definition at line 56 of file PODSamplerSolutionTransfer.h.

Referenced by execute(), PODResidualTransfer::execute(), executeFromMultiapp(), executeToMultiapp(), initialSetup(), and PODResidualTransfer::transferResidual().


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