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 24 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 59 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  if (_directions.size() != 1)
48  paramError("direction", "This transfer is only unidirectional");
49 }

Member Function Documentation

◆ execute()

void MultiAppFXTransfer::execute ( )
overridevirtual

Definition at line 157 of file MultiAppFXTransfer.C.

158 {
159  _console << "Beginning MultiAppFXTransfer: " << name() << std::endl;
160 
161  switch (_current_direction)
162  {
163  // LocalApp -> MultiApp
164  case TO_MULTIAPP:
165  {
166  // Get a reference to the object in the LocalApp
167  const MutableCoefficientsInterface & from_object =
168  (this->*getMultiAppObject)(_multi_app->problemBase(), _this_app_object_name, 0);
169 
170  for (unsigned int i = 0; i < _multi_app->numGlobalApps(); ++i)
171  {
172  if (_multi_app->hasLocalApp(i))
173  for (THREAD_ID t = 0; t < libMesh::n_threads(); ++t)
174  {
175  // Get a reference to the object in each MultiApp
176  MutableCoefficientsInterface & to_object =
177  (this->*getSubAppObject)(_multi_app->appProblemBase(i), _multi_app_object_name, t);
178 
179  if (to_object.isCompatibleWith(from_object))
180  to_object.importCoefficients(from_object);
181  else
182  mooseError("'",
184  "' is not compatible with '",
186  "'");
187  }
188  }
189  break;
190  }
191 
192  // MultiApp -> LocalApp
193  case FROM_MULTIAPP:
194  {
195  /*
196  * For now we will assume that the transfers are 1:1 and the coefficients are synchronized
197  * among all instances, thus we only need to grab the set of coefficients from the first
198  * SubApp.
199  */
200  if (_multi_app->hasLocalApp(0))
201  {
202  // Get a reference to the first thread object in the first MultiApp
203  const MutableCoefficientsInterface & from_object =
204  (this->*getSubAppObject)(_multi_app->appProblemBase(0), _multi_app_object_name, 0);
205 
206  for (THREAD_ID t = 0; t < libMesh::n_threads(); ++t)
207  {
208  // Get a reference to the object in each LocalApp instance
209  MutableCoefficientsInterface & to_object =
210  (this->*getMultiAppObject)(_multi_app->problemBase(), _this_app_object_name, t);
211 
212  if (to_object.isCompatibleWith(from_object))
213  to_object.importCoefficients(from_object);
214  else
215  mooseError("'",
217  "' is not compatible with '",
219  "'");
220  }
221  }
222  break;
223  }
224  }
225 
226  _console << "Finished MultiAppFXTransfer: " << name() << std::endl;
227 }

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

142 {
143  return dynamic_cast<MutableCoefficientsInterface &>(base.getFunction(object_name, thread));
144 }

Referenced by scanProblemBaseForObject().

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

150 {
151  // Get the non-const qualified UserObject, otherwise we would use getUserObject()
152  auto & user_object = base.getUserObjectTempl<UserObject>(object_name, thread);
153  return dynamic_cast<MutableCoefficientsInterface &>(user_object);
154 }

Referenced by scanProblemBaseForObject().

◆ initialSetup()

void MultiAppFXTransfer::initialSetup ( )
overridevirtual

Definition at line 52 of file MultiAppFXTransfer.C.

53 {
54  // Search for the _this_app_object_name in the LocalApp
56  scanProblemBaseForObject(_multi_app->problemBase(), _this_app_object_name, "MultiApp");
57  if (getMultiAppObject == NULL)
58  mooseError(
59  "Transfer '", name(), "': Cannot find object '", _this_app_object_name, "' in MultiApp");
60 
61  // Search for the _multi_app_object_name in each of the MultiApps
62  for (std::size_t i = 0; i < _multi_app->numGlobalApps(); ++i)
63  if (_multi_app->hasLocalApp(i))
64  {
65  if (i == 0) // First time through, assign without checking against previous values
67  _multi_app->appProblemBase(i), _multi_app_object_name, _multi_app->name());
68  else if (getSubAppObject != scanProblemBaseForObject(_multi_app->appProblemBase(i),
70  _multi_app->name()))
71  mooseError("The name '",
73  "' is assigned to two different object types. Please modify your input file and "
74  "try again.");
75  }
76  if (getSubAppObject == NULL)
77  mooseError(
78  "Transfer '", name(), "': Cannot find object '", _multi_app_object_name, "' in SubApp");
79 }

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

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

Referenced by initialSetup().

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 38 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 35 of file MultiAppFXTransfer.h.

Referenced by execute(), and initialSetup().

◆ getMultiAppObject

GetProblemObject MultiAppFXTransfer::getMultiAppObject
protected

Function pointer for grabbing the MultiApp object.

Definition at line 72 of file MultiAppFXTransfer.h.

Referenced by execute(), and initialSetup().

◆ getSubAppObject

GetProblemObject MultiAppFXTransfer::getSubAppObject
protected

Function pointer for grabbing the SubApp object.

Definition at line 75 of file MultiAppFXTransfer.h.

Referenced by execute(), and initialSetup().


The documentation for this class was generated from the following files:
MultiAppFXTransfer::getMutableCoefficientsUserOject
MutableCoefficientsInterface & getMutableCoefficientsUserOject(FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
Gets a MutableCoefficientsInterface-based UserObject, intended for use via function pointer.
Definition: MultiAppFXTransfer.C:147
MutableCoefficientsInterface::importCoefficients
void importCoefficients(const MutableCoefficientsInterface &other)
Import the coefficients from another instance.
Definition: MutableCoefficientsInterface.C:117
MultiAppFXTransfer::getSubAppObject
GetProblemObject getSubAppObject
Function pointer for grabbing the SubApp object.
Definition: MultiAppFXTransfer.h:75
MultiAppFXTransfer::_multi_app_object_name
const std::string _multi_app_object_name
Name of the MutableCoefficientsInterface-derived object in the MultiApp.
Definition: MultiAppFXTransfer.h:38
MultiAppFXTransfer::scanProblemBaseForObject
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...
Definition: MultiAppFXTransfer.C:82
name
const std::string name
Definition: Setup.h:21
MultiAppFXTransfer::getMutableCoefficientsFunction
MutableCoefficientsInterface & getMutableCoefficientsFunction(FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
Gets a MutableCoefficientsInterface-based Function, intented for use via function pointer.
Definition: MultiAppFXTransfer.C:139
MutableCoefficientsInterface
This class is designed to provide a uniform interface for any class that uses an array of coefficient...
Definition: MutableCoefficientsInterface.h:30
MutableCoefficientsInterface::isCompatibleWith
bool isCompatibleWith(const MutableCoefficientsInterface &other) const
Checks to see if another instance is compatible.
Definition: MutableCoefficientsInterface.C:86
MultiAppFXTransfer::getMultiAppObject
GetProblemObject getMultiAppObject
Function pointer for grabbing the MultiApp object.
Definition: MultiAppFXTransfer.h:72
MultiAppFXTransfer::_this_app_object_name
const std::string _this_app_object_name
Name of the MutableCoefficientsInterface-derived object in the creating app.
Definition: MultiAppFXTransfer.h:35