www.mooseframework.org
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | List of all members
MultiAppFXTransfer Class Reference

Transfers mutable coefficient arrays between supported object types. More...

#include <MultiAppFXTransfer.h>

Inheritance diagram for MultiAppFXTransfer:
[legend]

Public Types

enum  DIRECTION
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 MultiAppFXTransfer (const InputParameters &parameters)
 
virtual void execute () override
 
virtual void initialSetup () override
 
void variableIntegrityCheck (const AuxVariableName &var_name) 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
 
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 & 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 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 &name, const std::string *param=nullptr) 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
 

Static Public Member Functions

static InputParameters validParams ()
 
static void addSkipCoordCollapsingParam (InputParameters &params)
 
static System * find_sys (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 Number OutOfMeshValue
 

Protected Member Functions

virtual GetProblemObject scanProblemBaseForObject (FEProblemBase &base, const std::string &object_name, const std::string &app_name)
 Searches an FEProblemBase for a MutableCoefficientsInterface-based object and returns a function pointer to the matched function type. More...
 
std::vector< unsigned intgetFromsPerProc ()
 
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
 
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< 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< BoundingBox > getFromBoundingBoxes ()
 
std::vector< BoundingBox > getFromBoundingBoxes (BoundaryID boundary_id)
 
std::vector< BoundingBox > getFromBoundingBoxes ()
 
std::vector< BoundingBox > getFromBoundingBoxes (BoundaryID boundary_id)
 

Static Protected Member Functions

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

Protected Attributes

const std::string _this_app_object_name
 Name of the MutableCoefficientsInterface-derived object in the creating app. More...
 
const std::string _multi_app_object_name
 Name of the MutableCoefficientsInterface-derived object in the MultiApp. More...
 
GetProblemObject getMultiAppObject
 Function pointer for grabbing the MultiApp object. More...
 
GetProblemObject getSubAppObject
 Function pointer for grabbing the SubApp object. More...
 
std::shared_ptr< MultiApp_multi_app
 
std::vector< FEProblemBase *> _to_problems
 
std::vector< FEProblemBase *> _from_problems
 
std::vector< EquationSystems *> _to_es
 
std::vector< 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 Types

typedef MutableCoefficientsInterface &(MultiAppFXTransfer::* GetProblemObject) (FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
 Function pointer typedef for functions used to find, convert, and return the appropriate MutableCoefficientsInterface object from an FEProblemBase. More...
 

Private Member Functions

MutableCoefficientsInterfacegetMutableCoefficientsFunction (FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
 Gets a MutableCoefficientsInterface-based Function, intented for use via function pointer. More...
 
MutableCoefficientsInterfacegetMutableCoefficientsUserOject (FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
 Gets a MutableCoefficientsInterface-based UserObject, intended for use via function pointer. More...
 

Detailed Description

Transfers mutable coefficient arrays between supported object types.

Definition at line 19 of file MultiAppFXTransfer.h.

Member Typedef Documentation

◆ GetProblemObject

typedef MutableCoefficientsInterface&(MultiAppFXTransfer::* MultiAppFXTransfer::GetProblemObject) (FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
private

Function pointer typedef for functions used to find, convert, and return the appropriate MutableCoefficientsInterface object from an FEProblemBase.

Definition at line 56 of file MultiAppFXTransfer.h.

Constructor & Destructor Documentation

◆ MultiAppFXTransfer()

MultiAppFXTransfer::MultiAppFXTransfer ( const InputParameters parameters)

Definition at line 39 of file MultiAppFXTransfer.C.

41  _this_app_object_name(getParam<std::string>("this_app_object_name")),
42  _multi_app_object_name(getParam<std::string>("multi_app_object_name")),
43  getMultiAppObject(NULL),
44  getSubAppObject(NULL)
45 {
46  if (_directions.size() != 1)
47  paramError("direction", "This transfer is only unidirectional");
48  if (hasToMultiApp() && hasFromMultiApp())
49  mooseError("This transfer does not currently support between_multiapp transfer");
50 }
MultiAppTransfer(const InputParameters &parameters)
const std::string _this_app_object_name
Name of the MutableCoefficientsInterface-derived object in the creating app.
unsigned int size() const
const std::string _multi_app_object_name
Name of the MutableCoefficientsInterface-derived object in the MultiApp.
bool hasFromMultiApp() const
GetProblemObject getSubAppObject
Function pointer for grabbing the SubApp object.
void paramError(const std::string &param, Args... args) const
MultiMooseEnum _directions
bool hasToMultiApp() const
void mooseError(Args &&... args) const
const InputParameters & parameters() const
GetProblemObject getMultiAppObject
Function pointer for grabbing the MultiApp object.

Member Function Documentation

◆ execute()

void MultiAppFXTransfer::execute ( )
overridevirtual

Implements MultiAppTransfer.

Definition at line 160 of file MultiAppFXTransfer.C.

161 {
162  _console << "Beginning MultiAppFXTransfer: " << name() << std::endl;
163 
164  switch (_current_direction)
165  {
166  // LocalApp -> MultiApp
167  case TO_MULTIAPP:
168  {
169  // Get a reference to the object in the LocalApp
170  const MutableCoefficientsInterface & from_object =
171  (this->*getMultiAppObject)(getToMultiApp()->problemBase(), _this_app_object_name, 0);
172 
173  for (unsigned int i = 0; i < getToMultiApp()->numGlobalApps(); ++i)
174  {
175  if (getToMultiApp()->hasLocalApp(i))
176  for (THREAD_ID t = 0; t < libMesh::n_threads(); ++t)
177  {
178  // Get a reference to the object in each MultiApp
179  MutableCoefficientsInterface & to_object = (this->*getSubAppObject)(
180  getToMultiApp()->appProblemBase(i), _multi_app_object_name, t);
181 
182  if (to_object.isCompatibleWith(from_object))
183  to_object.importCoefficients(from_object);
184  else
185  mooseError("'",
187  "' is not compatible with '",
189  "'");
190  }
191  }
192  break;
193  }
194 
195  // MultiApp -> LocalApp
196  case FROM_MULTIAPP:
197  {
198  /*
199  * For now we will assume that the transfers are 1:1 and the coefficients are synchronized
200  * among all instances, thus we only need to grab the set of coefficients from the first
201  * SubApp.
202  */
203  if (getFromMultiApp()->hasLocalApp(0))
204  {
205  // Get a reference to the first thread object in the first MultiApp
206  const MutableCoefficientsInterface & from_object = (this->*getSubAppObject)(
207  getFromMultiApp()->appProblemBase(0), _multi_app_object_name, 0);
208 
209  for (THREAD_ID t = 0; t < libMesh::n_threads(); ++t)
210  {
211  // Get a reference to the object in each LocalApp instance
212  MutableCoefficientsInterface & to_object = (this->*getMultiAppObject)(
213  getFromMultiApp()->problemBase(), _this_app_object_name, t);
214 
215  if (to_object.isCompatibleWith(from_object))
216  to_object.importCoefficients(from_object);
217  else
218  mooseError("'",
220  "' is not compatible with '",
222  "'");
223  }
224  }
225  break;
226  }
227  }
228 
229  _console << "Finished MultiAppFXTransfer: " << name() << std::endl;
230 }
unsigned int n_threads()
const std::shared_ptr< MultiApp > getFromMultiApp() const
MooseEnum _current_direction
const std::string _this_app_object_name
Name of the MutableCoefficientsInterface-derived object in the creating app.
const std::shared_ptr< MultiApp > getToMultiApp() const
const std::string _multi_app_object_name
Name of the MutableCoefficientsInterface-derived object in the MultiApp.
virtual const std::string & name() const
GetProblemObject getSubAppObject
Function pointer for grabbing the SubApp object.
bool isCompatibleWith(const MutableCoefficientsInterface &other) const
Checks to see if another instance is compatible.
void mooseError(Args &&... args) const
This class is designed to provide a uniform interface for any class that uses an array of coefficient...
const ConsoleStream _console
void importCoefficients(const MutableCoefficientsInterface &other)
Import the coefficients from another instance.
GetProblemObject getMultiAppObject
Function pointer for grabbing the MultiApp object.
unsigned int THREAD_ID

◆ getMutableCoefficientsFunction()

MutableCoefficientsInterface & MultiAppFXTransfer::getMutableCoefficientsFunction ( FEProblemBase base,
const std::string &  object_name,
THREAD_ID  thread 
)
private

Gets a MutableCoefficientsInterface-based Function, intented for use via function pointer.

Definition at line 142 of file MultiAppFXTransfer.C.

Referenced by scanProblemBaseForObject().

145 {
146  return dynamic_cast<MutableCoefficientsInterface &>(base.getFunction(object_name, thread));
147 }
virtual Function & getFunction(const std::string &name, const THREAD_ID tid=0)
This class is designed to provide a uniform interface for any class that uses an array of coefficient...

◆ getMutableCoefficientsUserOject()

MutableCoefficientsInterface & MultiAppFXTransfer::getMutableCoefficientsUserOject ( FEProblemBase base,
const std::string &  object_name,
THREAD_ID  thread 
)
private

Gets a MutableCoefficientsInterface-based UserObject, intended for use via function pointer.

Definition at line 150 of file MultiAppFXTransfer.C.

Referenced by scanProblemBaseForObject().

153 {
154  // Get the non-const qualified UserObject, otherwise we would use getUserObject()
155  auto & user_object = base.getUserObject<UserObject>(object_name, thread);
156  return dynamic_cast<MutableCoefficientsInterface &>(user_object);
157 }
T & getUserObject(const std::string &name, unsigned int tid=0) const
This class is designed to provide a uniform interface for any class that uses an array of coefficient...

◆ initialSetup()

void MultiAppFXTransfer::initialSetup ( )
overridevirtual

Reimplemented from MultiAppTransfer.

Definition at line 53 of file MultiAppFXTransfer.C.

54 {
55  const auto multi_app = hasFromMultiApp() ? getFromMultiApp() : getToMultiApp();
56 
57  // Search for the _this_app_object_name in the LocalApp
59  scanProblemBaseForObject(multi_app->problemBase(), _this_app_object_name, "MultiApp");
60  if (getMultiAppObject == NULL)
61  mooseError(
62  "Transfer '", name(), "': Cannot find object '", _this_app_object_name, "' in MultiApp");
63 
64  // Search for the _multi_app_object_name in each of the MultiApps
65  for (std::size_t i = 0; i < multi_app->numGlobalApps(); ++i)
66  if (multi_app->hasLocalApp(i))
67  {
68  if (i == 0) // First time through, assign without checking against previous values
70  multi_app->appProblemBase(i), _multi_app_object_name, multi_app->name());
71  else if (getSubAppObject != scanProblemBaseForObject(multi_app->appProblemBase(i),
73  multi_app->name()))
74  mooseError("The name '",
76  "' is assigned to two different object types. Please modify your input file and "
77  "try again.");
78  }
79  if (getSubAppObject == NULL)
80  mooseError(
81  "Transfer '", name(), "': Cannot find object '", _multi_app_object_name, "' in SubApp");
82 }
const std::shared_ptr< MultiApp > getFromMultiApp() const
const std::string _this_app_object_name
Name of the MutableCoefficientsInterface-derived object in the creating app.
const std::shared_ptr< MultiApp > getToMultiApp() const
const std::string _multi_app_object_name
Name of the MutableCoefficientsInterface-derived object in the MultiApp.
bool hasFromMultiApp() const
virtual const std::string & name() const
GetProblemObject getSubAppObject
Function pointer for grabbing the SubApp object.
virtual GetProblemObject scanProblemBaseForObject(FEProblemBase &base, const std::string &object_name, const std::string &app_name)
Searches an FEProblemBase for a MutableCoefficientsInterface-based object and returns a function poin...
void mooseError(Args &&... args) const
GetProblemObject getMultiAppObject
Function pointer for grabbing the MultiApp object.

◆ scanProblemBaseForObject()

MultiAppFXTransfer::GetProblemObject MultiAppFXTransfer::scanProblemBaseForObject ( FEProblemBase base,
const std::string &  object_name,
const std::string &  app_name 
)
protectedvirtual

Searches an FEProblemBase for a MutableCoefficientsInterface-based object and returns a function pointer to the matched function type.

Definition at line 85 of file MultiAppFXTransfer.C.

Referenced by initialSetup().

88 {
89  /*
90  * For now we are only considering Functions and UserObjects, as they are the only types currently
91  * implemented with MutableCoefficientsInterface. Others may be added later.
92  *
93  * Functions:
94  * FunctionSeries
95  *
96  * UserObjects:
97  * FXBoundaryUserObject (via FXBaseUserObject)
98  * FXVolumeUserObject (via FXBaseUserObject)
99  */
100  MutableCoefficientsInterface * interface;
101 
102  // Check to see if the object with object_name is a Function
103  if (base.hasFunction(object_name))
104  {
105  Function & function = base.getFunction(object_name);
106  interface = dynamic_cast<MutableCoefficientsInterface *>(&function);
107 
108  // Check to see if the function is a subclass of MutableCoefficientsInterface
109  if (interface)
111  else
112  mooseError("Function '",
113  object_name,
114  "' in '",
115  app_name,
116  "' does not inherit from MutableCoefficientsInterface.",
117  " Please change the function type and try again.");
118  }
119  // Check to see if the object with object_name is a UserObject
120  else if (base.hasUserObject(object_name))
121  {
122  // Get the non-const qualified UserObject, otherwise we would use getUserObject()
123  auto & user_object = base.getUserObject<UserObject>(object_name);
124  interface = dynamic_cast<MutableCoefficientsInterface *>(&user_object);
125 
126  // Check to see if the userObject is a subclass of MutableCoefficientsInterface
127  if (interface)
129  else
130  mooseError("UserObject '",
131  object_name,
132  "' in '",
133  app_name,
134  "' does not inherit from MutableCoefficientsInterface.",
135  " Please change the function type and try again.");
136  }
137 
138  return NULL;
139 }
T & getUserObject(const std::string &name, unsigned int tid=0) const
MutableCoefficientsInterface & getMutableCoefficientsUserOject(FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
Gets a MutableCoefficientsInterface-based UserObject, intended for use via function pointer...
bool hasUserObject(const std::string &name) const
MutableCoefficientsInterface & getMutableCoefficientsFunction(FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
Gets a MutableCoefficientsInterface-based Function, intented for use via function pointer...
virtual Function & getFunction(const std::string &name, const THREAD_ID tid=0)
void mooseError(Args &&... args) const
This class is designed to provide a uniform interface for any class that uses an array of coefficient...
virtual bool hasFunction(const std::string &name, const THREAD_ID tid=0)

◆ validParams()

InputParameters MultiAppFXTransfer::validParams ( )
static

Definition at line 20 of file MultiAppFXTransfer.C.

21 {
23 
24  params.addClassDescription("Transfers coefficient arrays between objects that are derived from "
25  "MutableCoefficientsInterface; currently includes the following "
26  "types: FunctionSeries, FXBoundaryUserObject, and FXVolumeUserObject");
27 
28  params.addRequiredParam<std::string>(
29  "this_app_object_name",
30  "Name of the MutableCoefficientsInterface-derived object in this app (LocalApp).");
31 
32  params.addRequiredParam<std::string>(
33  "multi_app_object_name",
34  "Name of the MutableCoefficientsInterface-derived object in the MultiApp.");
35 
36  return params;
37 }
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _multi_app_object_name

const std::string MultiAppFXTransfer::_multi_app_object_name
protected

Name of the MutableCoefficientsInterface-derived object in the MultiApp.

Definition at line 35 of file MultiAppFXTransfer.h.

Referenced by execute(), and initialSetup().

◆ _this_app_object_name

const std::string MultiAppFXTransfer::_this_app_object_name
protected

Name of the MutableCoefficientsInterface-derived object in the creating app.

Definition at line 32 of file MultiAppFXTransfer.h.

Referenced by execute(), and initialSetup().

◆ getMultiAppObject

GetProblemObject MultiAppFXTransfer::getMultiAppObject
protected

Function pointer for grabbing the MultiApp object.

Definition at line 69 of file MultiAppFXTransfer.h.

Referenced by execute(), and initialSetup().

◆ getSubAppObject

GetProblemObject MultiAppFXTransfer::getSubAppObject
protected

Function pointer for grabbing the SubApp object.

Definition at line 72 of file MultiAppFXTransfer.h.

Referenced by execute(), and initialSetup().


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