Go to the documentation of this file.
19 #include "libmesh/parallel_algebra.h"
20 #include "libmesh/mesh_tools.h"
28 params.
addRequiredParam<MultiAppName>(
"multi_app",
"The name of the MultiApp to use.");
35 params.
setDocString(
"execute_on", exec_enum.getDocString());
38 "check_multiapp_execute_on",
40 "When false the check between the multiapp and transfer execute on flags is not preformed.");
41 params.
addParam<
bool>(
"displaced_source_mesh",
43 "Whether or not to use the displaced mesh for the source mesh.");
44 params.
addParam<
bool>(
"displaced_target_mesh",
46 "Whether or not to use the displaced mesh for the target mesh.");
52 _multi_app(_fe_problem.getMultiApp(getParam<MultiAppName>(
"multi_app"))),
53 _displaced_source_mesh(getParam<bool>(
"displaced_source_mesh")),
54 _displaced_target_mesh(getParam<bool>(
"displaced_target_mesh"))
56 if (getParam<bool>(
"check_multiapp_execute_on"))
60 paramError(
"direction",
"At least one direction is required");
76 mooseDoOnce(
mooseWarning(
"MultiAppTransfer execute_on flags do not match associated Multiapp "
83 for (
unsigned int i = 0; i <
_multi_app->numGlobalApps(); i++)
85 mooseError(
"Cannot find variable ", var_name,
" for ",
name(),
" Transfer");
88 const std::vector<ExecFlagType> &
91 mooseDeprecated(
"The execFlags() methos is being removed because MOOSE has been updated to use a "
92 "ExecFlagEnum for execute flags. The current flags should be retrieved from "
93 "the \"exeucte_on\" parameters of your object or by using the \"_execute_enum\" "
94 "reference to the parameter or the getExecuteOnEnum() method.");
121 for (
unsigned int i_app = 0; i_app <
_multi_app->numGlobalApps(); i_app++)
134 for (
unsigned int i_app = 0; i_app <
_multi_app->numGlobalApps(); i_app++)
165 std::vector<BoundingBox>
168 std::vector<std::pair<Point, Point>> bb_points(
_from_meshes.size());
173 BoundingBox bbox = MeshTools::create_local_bounding_box(*
_from_meshes[i]);
181 bb_points[i] =
static_cast<std::pair<Point, Point>
>(bbox);
185 _communicator.allgather(bb_points);
188 std::vector<BoundingBox> bboxes(bb_points.size());
189 for (
unsigned int i = 0; i < bb_points.size(); i++)
190 bboxes[i] = static_cast<BoundingBox>(bb_points[i]);
195 std::vector<BoundingBox>
198 std::vector<std::pair<Point, Point>> bb_points(
_from_meshes.size());
199 const Real min_r = std::numeric_limits<Real>::lowest();
200 const Real max_r = std::numeric_limits<Real>::max();
205 Point min(max_r, max_r, max_r);
206 Point max(min_r, min_r, min_r);
207 bool at_least_one =
false;
211 for (
const auto & bnode : bnd_nodes)
213 if (bnode->_bnd_id == boundary_id && bnode->_node->processor_id() == processor_id())
215 const auto & node = *bnode->_node;
216 for (
unsigned int i = 0; i < LIBMESH_DIM; ++i)
218 min = std::min(min(i), node(i));
219 max = std::max(max(i), node(i));
225 BoundingBox bbox(min, max);
237 bb_points[i] =
static_cast<std::pair<Point, Point>
>(bbox);
241 _communicator.allgather(bb_points);
244 std::vector<BoundingBox> bboxes(bb_points.size());
245 for (
unsigned int i = 0; i < bb_points.size(); i++)
246 bboxes[i] = static_cast<BoundingBox>(bb_points[i]);
251 std::vector<unsigned int>
254 std::vector<unsigned int> froms_per_proc;
258 froms_per_proc.resize(n_processors(), 1);
261 froms_per_proc.resize(n_processors());
262 _communicator.allgather(
_multi_app->numLocalApps(), froms_per_proc);
265 return froms_per_proc;
268 NumericVector<Real> &
278 const VariableName & var_name,
279 const std::string & param_name)
const
283 if (param_name.empty())
284 mooseError(
"The variable '", var_name,
"' does not exist.");
286 paramError(param_name,
"The variable '", var_name,
"' does not exist.");
void variableIntegrityCheck(const AuxVariableName &var_name) const
Utility to verify that the variable in the destination system exists.
std::vector< Point > _from_positions
MultiAppTransfer(const InputParameters ¶meters)
std::shared_ptr< MultiApp > _multi_app
The MultiApp this Transfer is transferring data to or from.
void mooseError(Args &&... args) const
StoredRange< MooseMesh::const_bnd_node_iterator, const BndNode * > ConstBndNodeRange
Some useful StoredRange typedefs.
std::vector< MooseMesh * > _to_meshes
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
std::vector< FEProblemBase * > _to_problems
unsigned int get(unsigned int i) const
Indexing operator Operator to retrieve an item from the MultiMooseEnum.
bool _displaced_source_mesh
True if displaced mesh is used for the source mesh, otherwise false.
void checkMultiAppExecuteOn()
Helper method for checking the 'check_multiapp_execute_on' flag.
std::vector< BoundingBox > getFromBoundingBoxes()
Return the bounding boxes of all the "from" domains, including all the domains not local to this proc...
MooseEnum _current_direction
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
std::vector< unsigned int > getFromsPerProc()
Return the number of "from" domains that each processor owns.
Base class for all Transfer objects.
const ExecFlagEnum & getExecuteOnEnum() const
Return the execute on MultiMooseEnum for this object.
virtual bool hasVariable(const std::string &var_name) const override
Whether or not this problem has the variable.
std::vector< Point > _to_positions
unsigned int size() const
Return the number of active items in the MultiMooseEnum.
bool _displaced_target_mesh
True if displaced mesh is used for the target mesh, otherwise false.
boundary_id_type BoundaryID
void checkVariable(const FEProblemBase &fe_problem, const VariableName &var_name, const std::string ¶m_name="") const
Helper for checking a problem for a variable.
defineLegacyParams(MultiAppTransfer)
const std::vector< ExecFlagType > _exec_flags
(DEPRECATED) execution flag (when is the object executed/evaluated) TODO: ExecFlagType
Base class for all MultiAppTransfer objects.
std::vector< unsigned int > _local2global_map
static InputParameters validParams()
void getAppInfo()
This method will fill information into the convenience member variables (_to_problems,...
static InputParameters validParams()
std::vector< EquationSystems * > _to_es
NumericVector< Real > & getTransferVector(unsigned int i_local, std::string var_name)
If we are transferring to a multiapp, return the appropriate solution vector.
std::vector< FEProblemBase * > _from_problems
const MultiMooseEnum _directions
The directions this Transfer is to be executed on.
virtual const std::vector< ExecFlagType > & execFlags() const
Return the execution flags, handling "same_as_multiapp".
std::vector< MooseMesh * > _from_meshes
std::vector< EquationSystems * > _from_es
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
A MultiMooseEnum object to hold "execute_on" flags.
void mooseDeprecated(Args &&... args) const
const ExecFlagType EXEC_SAME_AS_MULTIAPP
void mooseWarning(Args &&... args) const
virtual const std::string & name() const
Get the name of the object.