www.mooseframework.org
Public Member Functions | 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 Member Functions

 MultiAppFXTransfer (const InputParameters &parameters)
 
virtual void execute () override
 
virtual void initialSetup () override
 

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

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

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 25 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 60 of file MultiAppFXTransfer.h.

Constructor & Destructor Documentation

◆ MultiAppFXTransfer()

MultiAppFXTransfer::MultiAppFXTransfer ( const InputParameters &  parameters)

Definition at line 40 of file MultiAppFXTransfer.C.

41  : MultiAppTransfer(parameters),
42  _this_app_object_name(getParam<std::string>("this_app_object_name")),
43  _multi_app_object_name(getParam<std::string>("multi_app_object_name")),
44  getMultiAppObject(NULL),
45  getSubAppObject(NULL)
46 {
47 }
const std::string _this_app_object_name
Name of the MutableCoefficientsInterface-derived object in the creating app.
const std::string _multi_app_object_name
Name of the MutableCoefficientsInterface-derived object in the MultiApp.
GetProblemObject getSubAppObject
Function pointer for grabbing the SubApp object.
GetProblemObject getMultiAppObject
Function pointer for grabbing the MultiApp object.

Member Function Documentation

◆ execute()

void MultiAppFXTransfer::execute ( )
overridevirtual

Definition at line 155 of file MultiAppFXTransfer.C.

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

◆ 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 137 of file MultiAppFXTransfer.C.

Referenced by scanProblemBaseForObject().

140 {
141  return dynamic_cast<MutableCoefficientsInterface &>(base.getFunction(object_name, thread));
142 }
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 145 of file MultiAppFXTransfer.C.

Referenced by scanProblemBaseForObject().

148 {
149  // Get the non-const qualified UserObject, otherwise we would use getUserObject()
150  auto & user_object = base.getUserObject<UserObject>(object_name, thread);
151  return dynamic_cast<MutableCoefficientsInterface &>(user_object);
152 }
This class is designed to provide a uniform interface for any class that uses an array of coefficient...

◆ initialSetup()

void MultiAppFXTransfer::initialSetup ( )
overridevirtual

Definition at line 50 of file MultiAppFXTransfer.C.

51 {
52  // Search for the _this_app_object_name in the LocalApp
54  scanProblemBaseForObject(_multi_app->problemBase(), _this_app_object_name, "MultiApp");
55  if (getMultiAppObject == NULL)
56  mooseError(
57  "Transfer '", name(), "': Cannot find object '", _this_app_object_name, "' in MultiApp");
58 
59  // Search for the _multi_app_object_name in each of the MultiApps
60  for (std::size_t i = 0; i < _multi_app->numGlobalApps(); ++i)
61  if (_multi_app->hasLocalApp(i))
62  {
63  if (i == 0) // First time through, assign without checking against previous values
65  _multi_app->appProblemBase(i), _multi_app_object_name, _multi_app->name());
66  else if (getSubAppObject != scanProblemBaseForObject(_multi_app->appProblemBase(i),
68  _multi_app->name()))
69  mooseError("The name '",
71  "' is assigned to two different object types. Please modify your input file and "
72  "try again.");
73  }
74  if (getSubAppObject == NULL)
75  mooseError(
76  "Transfer '", name(), "': Cannot find object '", _multi_app_object_name, "' in SubApp");
77 }
const std::string _this_app_object_name
Name of the MutableCoefficientsInterface-derived object in the creating app.
const std::string _multi_app_object_name
Name of the MutableCoefficientsInterface-derived object in the MultiApp.
GetProblemObject getSubAppObject
Function pointer for grabbing the SubApp object.
const std::string name
Definition: Setup.h:22
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...
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 80 of file MultiAppFXTransfer.C.

Referenced by initialSetup().

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

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 39 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 36 of file MultiAppFXTransfer.h.

Referenced by execute(), and initialSetup().

◆ getMultiAppObject

GetProblemObject MultiAppFXTransfer::getMultiAppObject
protected

Function pointer for grabbing the MultiApp object.

Definition at line 73 of file MultiAppFXTransfer.h.

Referenced by execute(), and initialSetup().

◆ getSubAppObject

GetProblemObject MultiAppFXTransfer::getSubAppObject
protected

Function pointer for grabbing the SubApp object.

Definition at line 76 of file MultiAppFXTransfer.h.

Referenced by execute(), and initialSetup().


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