https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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 | Static Private Member Functions | Private Attributes | 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, 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
 
bool isKokkosObject () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (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
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) 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
 

Static Public Member Functions

static InputParameters validParams ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 
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
 
 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const libMesh::Number OutOfMeshValue
 
static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 

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.
 
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 checkParentAppUserObjectExecuteOn (const std::string &object_name) const
 
void errorIfObjectExecutesOnTransferInSourceApp (const std::string &object_name) const
 
Point getPointInTargetAppFrame (const Point &p, unsigned int local_i_to, const std::string &phase) const
 
Point getPointInSourceAppFrame (const Point &p, unsigned int local_i_from, 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
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
TdeclareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< TdeclareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const TgetRestartableData (const std::string &data_name) const
 
TdeclareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
TdeclareRecoverableData (const std::string &data_name, Args &&... args)
 
TdeclareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
TdeclareRestartableDataWithObjectNameWithContext (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 addUserObjectExecutionCheckParam (InputParameters &params)
 
static void addBBoxFactorParam (InputParameters &params)
 
static void transformBoundingBox (libMesh::BoundingBox &box, const MultiAppCoordTransform &transform)
 

Protected Attributes

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 getMultiAppObject
 Function pointer for grabbing the MultiApp object.
 
GetProblemObject getSubAppObject
 Function pointer for grabbing the SubApp object.
 
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
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
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.
 

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.
 
MutableCoefficientsInterfacegetMutableCoefficientsUserOject (FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
 Gets a MutableCoefficientsInterface-based UserObject, intended for use via function pointer.
 
virtual bool usesMooseAppCoordTransform () const
 
Point mapBackWithoutCollapsing (MultiAppCoordTransform &transform, const Point &p, const std::string &phase) const
 
void getFromMultiAppInfo ()
 
void getToMultiAppInfo ()
 
RestartableDataValueregisterRestartableDataOnApp (std::unique_ptr< RestartableDataValue > data, THREAD_ID tid) const
 
void registerRestartableNameWithFilterOnApp (const std::string &name, Moose::RESTARTABLE_FILTER filter)
 
RestartableData< T > & declareRestartableDataHelper (const std::string &data_name, void *context, Args &&... args) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

std::shared_ptr< MultiApp_from_multi_app
 
std::shared_ptr< MultiApp_to_multi_app
 
std::unique_ptr< MooseAppCoordTransform_from_moose_app_transform
 
std::unique_ptr< MooseAppCoordTransform_to_moose_app_transform
 
const ParallelParamObject_parent
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 
ExecFlagEnum _empty_execute_enum
 
const RestartableDataMapName _metaname
 
std::string _restartable_name
 

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

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 THREAD_ID
const ConsoleStream _console
const std::string & name() const
const std::shared_ptr< MultiApp > getToMultiApp() const
const std::shared_ptr< MultiApp > getFromMultiApp() const
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.
bool isCompatibleWith(const MutableCoefficientsInterface &other) const
Checks to see if another instance is compatible.
MooseEnum _current_direction
unsigned int n_threads()

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

145{
146 return dynamic_cast<MutableCoefficientsInterface &>(base.getFunction(object_name, thread));
147}
virtual Function & getFunction(const std::string &name, const THREAD_ID tid=0)

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

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

Referenced by scanProblemBaseForObject().

◆ initialSetup()

void MultiAppFXTransfer::initialSetup ( )
overridevirtual

Reimplemented from Transfer.

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)
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)
81 "Transfer '", name(), "': Cannot find object '", _multi_app_object_name, "' in SubApp");
82}
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...

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

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 */
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}
bool hasUserObject(const std::string &name) const
virtual bool hasFunction(const std::string &name, const THREAD_ID tid=0)
MutableCoefficientsInterface & getMutableCoefficientsFunction(FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
Gets a MutableCoefficientsInterface-based Function, intented for use via function pointer.
MutableCoefficientsInterface & getMutableCoefficientsUserOject(FEProblemBase &base, const std::string &object_name, THREAD_ID thread)
Gets a MutableCoefficientsInterface-based UserObject, intended for use via function pointer.

Referenced by initialSetup().

◆ 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)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()

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: