https://mooseframework.inl.gov
MultiAppUserObjectTransfer.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "MooseAppCoordTransform.h"
12 
13 #include <limits>
14 
15 // MOOSE includes
16 #include "DisplacedProblem.h"
17 #include "FEProblem.h"
18 #include "MooseMesh.h"
19 #include "MooseTypes.h"
20 #include "MooseVariableFE.h"
21 #include "MultiApp.h"
22 #include "UserObject.h"
23 
24 // libMesh
25 #include "libmesh/meshfree_interpolation.h"
26 #include "libmesh/system.h"
27 #include "libmesh/mesh_function.h"
28 #include "libmesh/mesh_tools.h"
29 
30 registerMooseObjectDeprecated("MooseApp", MultiAppUserObjectTransfer, "12/31/2024 24:00");
31 
34 {
36  // MultiAppUserObjectTransfer does not need source variable since it query values from user
37  // objects
38  params.set<std::vector<VariableName>>("source_variable") = std::vector<VariableName>{};
39  params.suppressParameter<std::vector<VariableName>>("source_variable");
40  params.addRequiredParam<UserObjectName>(
41  "user_object",
42  "The UserObject you want to transfer values from. Note: This might be a "
43  "UserObject from your MultiApp's input file!");
44  params.addParam<bool>("all_parent_nodes_contained_in_sub_app",
45  false,
46  "Set to true if every parent app node is mapped to a distinct point on one "
47  "of the subApps during a transfer from sub App to Parent App. If parent app"
48  " node cannot be found within bounding boxes of any of the subApps, an "
49  " error is generated.");
50  params.addDeprecatedParam<bool>(
51  "all_master_nodes_contained_in_sub_app",
52  "Set to true if every parent app node is mapped to a distinct point on one "
53  "of the subApps during a transfer from sub App to Parent App. If parent app"
54  " node cannot be found within bounding boxes of any of the subApps, an "
55  " error is generated.",
56  "all_master_nodes_contained_in_sub_app is deprecated. Use "
57  "all_parent_nodes_contained_in_sub_app");
58  params.addParam<bool>(
59  "skip_bounding_box_check",
60  false,
61  "Skip the check if the to_elem is within the bounding box of the from_app.");
62  params.addParam<std::vector<SubdomainName>>(
63  "block", "The block we are transferring to (if not specified, whole domain is used).");
64  params.addParam<std::vector<BoundaryName>>(
65  "boundary",
66  "The boundary we are transferring to (if not specified, whole domain is used unless 'block' "
67  "parameter is used).");
68 
69  params.addClassDescription(
70  "Samples a variable's value in the Parent app domain at the point where the MultiApp is and "
71  "copies that value into a post-processor in the MultiApp");
72 
73  params.addParam<bool>("nearest_sub_app",
74  false,
75  "When True, a from_multiapp transfer will work by finding the nearest "
76  "(using the `location`) sub-app and query that for the value to transfer");
78 
79  return params;
80 }
81 
83  : MultiAppConservativeTransfer(parameters),
84  _user_object_name(getParam<UserObjectName>("user_object")),
85  _all_parent_nodes_contained_in_sub_app(
86  isParamValid("all_master_nodes_contained_in_sub_app")
87  ? getParam<bool>("all_master_nodes_contained_in_sub_app")
88  : getParam<bool>("all_parent_nodes_contained_in_sub_app")),
89  _skip_bbox_check(getParam<bool>("skip_bounding_box_check")),
90  _nearest_sub_app(getParam<bool>("nearest_sub_app"))
91 {
92  mooseDeprecated("MultiAppUserObjectTransfer is deprecated. Use "
93  "MultiAppGeneralFieldUserObjectTransfer instead and adapt the parameters");
94 
95  // This transfer does not work with DistributedMesh
96  _fe_problem.mesh().errorIfDistributedMesh("MultiAppUserObjectTransfer");
97 
98  if (_to_var_names.size() != 1)
99  paramError("variable", " Support single to-variable only ");
100 
101  if (_from_var_names.size() > 0)
102  paramError("source_variable",
103  " You should not provide any source variables since the transfer takes values from "
104  "user objects ");
105 
106  if (isParamValid("block") && isParamValid("boundary"))
107  mooseError(name(), ": Transfer can be either block- or boundary-restricted. Not both.");
108 
109  if (isParamValid("to_multi_app") && isParamValid("from_multi_app") &&
111  paramError("to_multi_app",
112  "Sibling multiapp transfer has not been implemented for this transfer.");
113 }
114 
115 void
117 {
118  TIME_SECTION(
119  "MultiAppUserObjectTransfer::execute()", 5, "Performing transfer with a user object");
120 
121  getAppInfo();
122 
123  // Execute the user object if it was specified to execute on TRANSFER
124  switch (_current_direction)
125  {
126  case TO_MULTIAPP:
127  {
131  break;
132  }
133  case FROM_MULTIAPP:
135  }
136 
137  switch (_current_direction)
138  {
139  case TO_MULTIAPP:
140  {
141  for (unsigned int i = 0; i < getToMultiApp()->numGlobalApps(); i++)
142  {
143  if (getToMultiApp()->hasLocalApp(i))
144  {
146 
147  // Loop over the parent app nodes and set the value of the variable
148  System * to_sys = find_sys(getToMultiApp()->appProblemBase(i).es(), _to_var_name);
149 
150  unsigned int sys_num = to_sys->number();
151  unsigned int var_num = to_sys->variable_number(_to_var_name);
152 
153  NumericVector<Real> & solution = getToMultiApp()->appTransferVector(i, _to_var_name);
154 
155  MooseMesh * mesh = NULL;
156 
157  if (_displaced_target_mesh && getToMultiApp()->appProblemBase(i).getDisplacedProblem())
158  mesh = &getToMultiApp()->appProblemBase(i).getDisplacedProblem()->mesh();
159  else
160  mesh = &getToMultiApp()->appProblemBase(i).mesh();
161 
162  _blk_ids.clear();
163  _bnd_ids.clear();
164  if (isParamValid("block"))
165  {
166  const std::vector<SubdomainName> & blocks =
167  getParam<std::vector<SubdomainName>>("block");
168  for (const auto & b : blocks)
170  paramError("block", "The block '", b, "' was not found in the mesh");
171 
172  std::vector<SubdomainID> ids = mesh->getSubdomainIDs(blocks);
173  _blk_ids.insert(ids.begin(), ids.end());
174  }
175  else if (isParamValid("boundary"))
176  {
177  const std::vector<BoundaryName> & boundary_names =
178  getParam<std::vector<BoundaryName>>("boundary");
179  for (const auto & b : boundary_names)
181  paramError("boundary", "The boundary '", b, "' was not found in the mesh");
182 
183  std::vector<BoundaryID> ids = mesh->getBoundaryIDs(boundary_names, true);
184  _bnd_ids.insert(ids.begin(), ids.end());
185  }
186 
187  auto & fe_type = to_sys->variable_type(var_num);
188  bool is_constant = fe_type.order == CONSTANT;
189  bool is_nodal = fe_type.family == LAGRANGE;
190 
191  if (fe_type.order > FIRST && !is_nodal)
192  mooseError("We don't currently support second order or higher elemental variable ");
193 
194  const UserObject & user_object =
195  getToMultiApp()->problemBase().getUserObjectBase(_user_object_name);
196  mooseAssert(_from_transforms.size() == 1, "This should have size 1");
197  const auto & from_transform = *_from_transforms[0];
198  const auto & to_transform = *_to_transforms[i];
199 
200  if (is_nodal)
201  {
202  for (auto & node : mesh->getMesh().local_node_ptr_range())
203  {
204  if (blockRestricted() && !hasBlocks(mesh, node))
205  continue;
206 
207  if (boundaryRestricted() && !isBoundaryNode(mesh, node))
208  continue;
209 
210  if (node->n_dofs(sys_num, var_num) > 0) // If this variable has dofs at this node
211  {
212  // The zero only works for LAGRANGE!
213  dof_id_type dof = node->dof_number(sys_num, var_num, 0);
214 
215  swapper.forceSwap();
216  Real from_value =
217  user_object.spatialValue(from_transform.mapBack(to_transform(*node)));
218  swapper.forceSwap();
219 
220  solution.set(dof, from_value);
221  }
222  }
223  }
224  else // Elemental
225  {
226  std::vector<Point> points;
227  for (auto & elem : as_range(mesh->getMesh().local_elements_begin(),
228  mesh->getMesh().local_elements_end()))
229  {
230  if (blockRestricted() && !hasBlocks(elem))
231  continue;
232 
233  if (boundaryRestricted() && !isBoundaryElem(mesh, elem))
234  continue;
235 
236  // Skip this element if the variable has no dofs at it.
237  if (elem->n_dofs(sys_num, var_num) < 1)
238  continue;
239 
240  points.clear();
241  // grap sample points
242  // for constant shape function, we take the element centroid
243  if (is_constant)
244  points.push_back(elem->vertex_average());
245  // for higher order method, we take all nodes of element
246  // this works for the first order L2 Lagrange.
247  else
248  for (auto & node : elem->node_ref_range())
249  points.push_back(node);
250 
251  auto n_points = points.size();
252  unsigned int n_comp = elem->n_comp(sys_num, var_num);
253  // We assume each point corresponds to one component of elemental variable
254  if (n_points != n_comp)
255  mooseError(" Number of points ",
256  n_points,
257  " does not equal to number of variable components ",
258  n_comp);
259 
260  unsigned int offset = 0;
261  for (auto & point : points) // If this variable has dofs at this elem
262  {
263  dof_id_type dof = elem->dof_number(sys_num, var_num, offset++);
264 
265  swapper.forceSwap();
266  Real from_value =
267  user_object.spatialValue(from_transform.mapBack(to_transform(point)));
268  swapper.forceSwap();
269 
270  solution.set(dof, from_value);
271  }
272  }
273  }
274 
275  solution.close();
276  to_sys->update();
277  }
278  }
279 
280  break;
281  }
282  case FROM_MULTIAPP:
283  {
284  FEProblemBase & to_problem = getFromMultiApp()->problemBase();
285  mooseAssert(_to_transforms.size() == 1, "This should only be size one");
286  const auto & to_transform = *_to_transforms[0];
287  MooseVariableFEBase & to_var = to_problem.getVariable(
289  SystemBase & to_system_base = to_var.sys();
290 
291  System & to_sys = to_system_base.system();
292 
293  unsigned int to_sys_num = to_sys.number();
294 
295  // Only works with a serialized mesh to transfer to!
296  mooseAssert(to_sys.get_mesh().is_serial(),
297  "MultiAppUserObjectTransfer only works with ReplicatedMesh!");
298 
299  unsigned int to_var_num = to_sys.variable_number(to_var.name());
300 
301  // EquationSystems & to_es = to_sys.get_equation_systems();
302 
303  // Create a serialized version of the solution vector
304  NumericVector<Number> * to_solution = to_sys.solution.get();
305 
306  MooseMesh * to_mesh = NULL;
307 
308  if (_displaced_target_mesh && to_problem.getDisplacedProblem())
309  to_mesh = &to_problem.getDisplacedProblem()->mesh();
310  else
311  to_mesh = &to_problem.mesh();
312 
313  _blk_ids.clear();
314  _bnd_ids.clear();
315  if (isParamValid("block"))
316  {
317  const std::vector<SubdomainName> & blocks = getParam<std::vector<SubdomainName>>("block");
318  for (const auto & b : blocks)
319  if (!MooseMeshUtils::hasSubdomainName(*to_mesh, b))
320  paramError("block", "The block '", b, "' was not found in the mesh");
321 
322  std::vector<SubdomainID> ids = to_mesh->getSubdomainIDs(blocks);
323  _blk_ids.insert(ids.begin(), ids.end());
324  }
325  else if (isParamValid("boundary"))
326  {
327  const std::vector<BoundaryName> & boundary_names =
328  getParam<std::vector<BoundaryName>>("boundary");
329  for (const auto & b : boundary_names)
330  if (!MooseMeshUtils::hasBoundaryName(*to_mesh, b))
331  paramError("boundary", "The boundary '", b, "' was not found in the mesh");
332 
333  std::vector<BoundaryID> ids = to_mesh->getBoundaryIDs(boundary_names, true);
334  _bnd_ids.insert(ids.begin(), ids.end());
335  }
336 
337  auto & fe_type = to_sys.variable_type(to_var_num);
338  bool is_constant = fe_type.order == CONSTANT;
339  bool is_nodal = fe_type.family == LAGRANGE;
340 
341  if (fe_type.order > FIRST && !is_nodal)
342  mooseError("We don't currently support second order or higher elemental variable ");
343 
345  {
346  // check to see if parent app nodes or elements lies within any of the sub application
347  // bounding boxes
348  if (is_nodal)
349  {
350  for (auto & node : to_mesh->getMesh().node_ptr_range())
351  {
352  if (blockRestricted() && !hasBlocks(to_mesh, node))
353  continue;
354 
355  if (boundaryRestricted() && !isBoundaryNode(to_mesh, node))
356  continue;
357 
358  if (node->n_dofs(to_sys_num, to_var_num) > 0)
359  {
360  const auto transformed_node = to_transform(*node);
361 
362  unsigned int node_found_in_sub_app = 0;
363  for (unsigned int i = 0; i < getFromMultiApp()->numGlobalApps(); i++)
364  {
365  if (!getFromMultiApp()->hasLocalApp(i))
366  continue;
367 
368  BoundingBox app_box = getFromMultiApp()->getBoundingBox(
370 
371  if (app_box.contains_point(transformed_node))
372  ++node_found_in_sub_app;
373  }
374 
375  if (node_found_in_sub_app == 0)
376  mooseError("MultiAppUserObjectTransfer: Parent app node ",
377  transformed_node,
378  " not found within the bounding box of any of the sub applications.");
379  else if (node_found_in_sub_app > 1)
380  mooseError("MultiAppUserObjectTransfer: Parent app node ",
381  transformed_node,
382  " found within the bounding box of two or more sub applications.");
383  }
384  }
385  }
386  else // elemental
387  {
388  std::vector<Point> points;
389  for (auto & elem :
390  as_range(to_mesh->getMesh().elements_begin(), to_mesh->getMesh().elements_end()))
391  {
392  if (blockRestricted() && !hasBlocks(elem))
393  continue;
394 
395  if (boundaryRestricted() && !isBoundaryElem(to_mesh, elem))
396  continue;
397 
398  // Skip this element if the variable has no dofs at it.
399  if (elem->n_dofs(to_sys_num, to_var_num) < 1)
400  continue;
401 
402  points.clear();
403  // grap sample points
404  // for constant shape function, we take the element centroid
405  if (is_constant)
406  points.push_back(to_transform(elem->vertex_average()));
407  // for higher order method, we take all nodes of element
408  // this works for the first order L2 Lagrange.
409  else
410  for (auto & node : elem->node_ref_range())
411  points.push_back(to_transform(node));
412 
413  auto n_points = points.size();
414  unsigned int n_comp = elem->n_comp(to_sys_num, to_var_num);
415  // We assume each point corresponds to one component of elemental variable
416  if (n_points != n_comp)
417  mooseError(" Number of points ",
418  n_points,
419  " does not equal to number of variable components ",
420  n_comp);
421 
422  for (auto & point : points)
423  {
424  unsigned int elem_found_in_sub_app = 0;
425 
426  for (unsigned int i = 0; i < getFromMultiApp()->numGlobalApps(); i++)
427  {
428  if (!getFromMultiApp()->hasLocalApp(i))
429  continue;
430 
431  BoundingBox app_box = getFromMultiApp()->getBoundingBox(
433 
434  if (app_box.contains_point(point))
435  ++elem_found_in_sub_app;
436  }
437 
438  if (elem_found_in_sub_app == 0)
439  mooseError("MultiAppUserObjectTransfer: Parent app element with ",
440  n_points > 1 ? "node" : "centroid",
441  " at ",
442  point,
443  " not found within the bounding box of any of the sub applications.");
444 
445  else if (elem_found_in_sub_app > 1)
446  mooseError("MultiAppUserObjectTransfer: Parent app element with ",
447  n_points > 1 ? "node" : "centroid",
448  " at ",
449  point,
450  " found within the bounding box of two or more sub applications.");
451  }
452  }
453  }
454  }
455 
456  if (is_nodal)
457  {
458  for (auto & node : to_mesh->getMesh().node_ptr_range())
459  {
460  if (blockRestricted() && !hasBlocks(to_mesh, node))
461  continue;
462 
463  if (boundaryRestricted() && !isBoundaryNode(to_mesh, node))
464  continue;
465 
466  if (node->n_dofs(to_sys_num, to_var_num) > 0) // If this variable has dofs at this node
467  {
468  const auto transformed_node = to_transform(*node);
469  const auto sub_app = findSubAppToTransferFrom(transformed_node);
470 
471  // Check to see if a sub-app was found
472  if (sub_app == static_cast<unsigned int>(-1))
473  continue;
474 
475  const auto & from_transform = *_from_transforms[sub_app];
476  const auto & user_object = _multi_app->appUserObjectBase(sub_app, _user_object_name);
477 
478  dof_id_type dof = node->dof_number(to_sys_num, to_var_num, 0);
479 
480  Real from_value = 0;
481  {
483  from_value = user_object.spatialValue(from_transform.mapBack(transformed_node));
484  }
485 
486  if (from_value == std::numeric_limits<Real>::infinity())
487  mooseError("MultiAppUserObjectTransfer: Point corresponding to parent app node at (",
488  transformed_node,
489  ") not found in the sub application.");
490  to_solution->set(dof, from_value);
491  }
492  }
493  }
494  else // Elemental
495  {
496  std::vector<Point> points;
497  for (auto & elem :
498  as_range(to_mesh->getMesh().elements_begin(), to_mesh->getMesh().elements_end()))
499  {
500  if (blockRestricted() && !hasBlocks(elem))
501  continue;
502 
503  if (boundaryRestricted() && !isBoundaryElem(to_mesh, elem))
504  continue;
505 
506  // Skip this element if the variable has no dofs at it.
507  if (elem->n_dofs(to_sys_num, to_var_num) < 1)
508  continue;
509 
510  points.clear();
511  // grap sample points
512  // for constant shape function, we take the element centroid
513  if (is_constant)
514  points.push_back(to_transform(elem->vertex_average()));
515  // for higher order method, we take all nodes of element
516  // this works for the first order L2 Lagrange.
517  else
518  for (auto & node : elem->node_ref_range())
519  points.push_back(to_transform(node));
520 
521  auto n_points = points.size();
522  unsigned int n_comp = elem->n_comp(to_sys_num, to_var_num);
523  // We assume each point corresponds to one component of elemental variable
524  if (n_points != n_comp)
525  mooseError(" Number of points ",
526  n_points,
527  " does not equal to number of variable components ",
528  n_comp);
529 
530  unsigned int offset = 0;
531  for (auto & point : points) // If this variable has dofs at this elem
532  {
533  const auto sub_app = findSubAppToTransferFrom(point);
534 
535  // Check to see if a sub-app was found
536  if (sub_app == static_cast<unsigned int>(-1))
537  continue;
538 
539  const auto & from_transform = *_from_transforms[sub_app];
540  const auto & user_object =
541  getFromMultiApp()->appUserObjectBase(sub_app, _user_object_name);
542 
543  dof_id_type dof = elem->dof_number(to_sys_num, to_var_num, offset++);
544 
545  Real from_value = 0;
546  {
548  from_value = user_object.spatialValue(from_transform.mapBack(point));
549  }
550 
551  if (from_value == std::numeric_limits<Real>::infinity())
552  mooseError("MultiAppUserObjectTransfer: Point corresponding to element's centroid (",
553  point,
554  ") not found in sub application.");
555 
556  to_solution->set(dof, from_value);
557  }
558  }
559  }
560 
561  to_solution->close();
562  to_sys.update();
563 
564  break;
565  }
566  }
567 
568  postExecute();
569 }
570 
571 bool
573 {
574  return !_blk_ids.empty();
575 }
576 
577 bool
579 {
580  return !_bnd_ids.empty();
581 }
582 
583 bool
585 {
586  return _blk_ids.find(elem->subdomain_id()) != _blk_ids.end();
587 }
588 
589 bool
590 MultiAppUserObjectTransfer::hasBlocks(const MooseMesh * mesh, const Node * node) const
591 {
592  const auto & node_blk_ids = mesh->getNodeBlockIds(*node);
593  std::set<SubdomainID> u;
594  std::set_intersection(_blk_ids.begin(),
595  _blk_ids.end(),
596  node_blk_ids.begin(),
597  node_blk_ids.end(),
598  std::inserter(u, u.begin()));
599  return !u.empty();
600 }
601 
602 bool
603 MultiAppUserObjectTransfer::isBoundaryNode(const MooseMesh * mesh, const Node * node) const
604 {
605  for (auto & bid : _bnd_ids)
606  if (mesh->isBoundaryNode(node->id(), bid))
607  return true;
608  return false;
609 }
610 
611 bool
612 MultiAppUserObjectTransfer::isBoundaryElem(const MooseMesh * mesh, const Elem * elem) const
613 {
614  for (auto & bid : _bnd_ids)
615  if (mesh->isBoundaryElem(elem->id(), bid))
616  return true;
617  return false;
618 }
619 
620 unsigned int
622 {
623  // Just find the nearest app to this point
624  if (_nearest_sub_app)
625  {
626  unsigned int closest_app = 0;
627  Real closest_distance = std::numeric_limits<Real>::max();
628 
629  mooseAssert(_multi_app->numGlobalApps() > 0, "No Multiapps To Transfer From");
630 
631  for (unsigned int i = 0; i < _multi_app->numGlobalApps(); i++)
632  {
633  // Obtain the possibly transformed app position by querying the transform with the origin
634  const auto app_position = _multi_app->runningInPosition()
635  ? (*_from_transforms[i])(_multi_app->position(i))
636  : (*_from_transforms[i])(Point(0));
637 
638  auto distance = (p - app_position).norm();
639 
640  if (distance < closest_distance)
641  {
642  closest_app = i;
643  closest_distance = distance;
644  }
645  }
646 
647  // We can only get the value if we have this app
648  // otherwise - another processor will set it
649  if (_multi_app->hasLocalApp(closest_app))
650  return closest_app;
651  else
652  return -1;
653  }
654 
655  // Find the app that contains this point...
656 
657  // This loop counts _down_ so that it can preserve legacy behavior of the
658  // last sub-app "winning" to be able to set the value at this point
659  for (int i = _multi_app->numGlobalApps() - 1; i >= 0; i--)
660  {
661  if (!_multi_app->hasLocalApp(i))
662  continue;
663 
664  BoundingBox app_box =
665  _multi_app->getBoundingBox(i, _displaced_source_mesh, _from_transforms[i].get());
666 
667  if (_skip_bbox_check || app_box.contains_point(p))
668  return static_cast<unsigned int>(i);
669  }
670 
671  return -1;
672 }
LAGRANGE
std::vector< std::unique_ptr< MultiAppCoordTransform > > _to_transforms
const ExecFlagType EXEC_TRANSFER
Definition: Moose.C:55
bool hasBlocks(const Elem *elem) const
Check that element &#39;elem&#39; is part of the domain this transfer is restricted to.
bool isBoundaryElem(const MooseMesh *mesh, const Elem *elem) const
Check that the element belongs to boundary this transfer is restricted to.
static InputParameters validParams()
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
const std::shared_ptr< MultiApp > getFromMultiApp() const
Get the MultiApp to transfer data from.
bool hasBoundaryName(const MeshBase &input_mesh, const BoundaryName &name)
Whether a particular boundary name exists in the mesh.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:435
const bool _all_parent_nodes_contained_in_sub_app
Boolean variable to generate error if every parent app node cannot be mapped to a subApp during from_...
MooseEnum _current_direction
Definition: Transfer.h:106
char ** blocks
virtual void get(const std::vector< numeric_index_type > &index, Number *values) const
bool isBoundaryNode(const MooseMesh *mesh, const Node *node) const
Check that the node belongs to boundary this transfer is restricted to.
static void addUserObjectExecutionCheckParam(InputParameters &params)
Add the execution order check parameter (to skip the warning if needed)
FIRST
virtual void execute() override
Execute the transfer.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
const std::vector< VariableName > _from_var_names
Name of variables transferring from.
MeshBase & mesh
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Parallel::Communicator & comm() const
void checkParentAppUserObjectExecuteOn(const std::string &object_name) const
Checks the execute_on flags for user object transfers with user objects on the source app which is al...
virtual void postExecute()
Add some extra work if necessary after execute().
FEProblemBase & _fe_problem
Definition: Transfer.h:97
const bool _skip_bbox_check
whether to check the bounding box check or not
const std::shared_ptr< MultiApp > getToMultiApp() const
Get the MultiApp to transfer data to.
This class provides an interface for common operations on field variables of both FE and FV types wit...
Base class for a system (of equations)
Definition: SystemBase.h:84
std::shared_ptr< MultiApp > _multi_app
Deprecated class attribute for compatibility with the apps.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Real distance(const Point &p)
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_names) const
Get the associated subdomainIDs for the subdomain names that are passed in.
Definition: MooseMesh.C:1737
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
auto max(const L &left, const R &right)
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
bool _displaced_target_mesh
True if displaced mesh is used for the target mesh, otherwise false.
void errorIfDistributedMesh(std::string name) const
Generate a unified error message if the underlying libMesh mesh is a DistributedMesh.
Definition: MooseMesh.C:3617
CONSTANT
unsigned int number() const
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:99
void forceSwap()
Forcibly swap the currently swapped-out communicator back in to libmesh.
Definition: Moose.h:283
void errorIfObjectExecutesOnTransferInSourceApp(const std::string &object_name) const
Error if executing this MooseObject on EXEC_TRANSFER in a source multiapp (from_multiapp, e.g.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3448
void mooseDeprecated(Args &&... args) const
Definition: MooseBase.h:310
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
std::set< SubdomainID > _blk_ids
Set of block ids this transfer is restricted to.
const std::vector< AuxVariableName > _to_var_names
Name of variables transferring to.
static libMesh::System * find_sys(libMesh::EquationSystems &es, const std::string &var_name)
Small helper function for finding the system containing the variable.
Definition: Transfer.C:91
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
Transfers variables on possibly different meshes while conserving a user defined property (Postproces...
auto norm(const T &a) -> decltype(std::abs(a))
virtual void close()=0
bool hasSubdomainName(const MeshBase &input_mesh, const SubdomainName &name)
Whether a particular subdomain name exists in the mesh.
Loops over a target mesh and uses either node or element centroid location (based on the target varia...
const bool & _nearest_sub_app
Whether to utilize the nearest sub-app to transfer from.
virtual Real spatialValue(const Point &) const
Optional interface function for "evaluating" a UserObject at a spatial position.
Definition: UserObject.h:95
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual std::shared_ptr< const DisplacedProblem > getDisplacedProblem() const
unsigned int findSubAppToTransferFrom(const Point &p)
Gets the UserObject to transfer from when transferring from_multiapp.
std::vector< std::unique_ptr< MultiAppCoordTransform > > _from_transforms
virtual MooseMesh & mesh() override
bool _displaced_source_mesh
True if displaced mesh is used for the source mesh, otherwise false.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
virtual void set(const numeric_index_type i, const Number value)=0
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:195
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side. ...
virtual void computeUserObjectByName(const ExecFlagType &type, const Moose::AuxGroup &group, const std::string &name)
Compute an user object with the given name.
MultiAppUserObjectTransfer(const InputParameters &parameters)
virtual void getAppInfo()
This method will fill information into the convenience member variables (_to_problems, _from_meshes, etc.)
SystemBase & sys()
Get the system this variable is part of.
Base class for user-specific data.
Definition: UserObject.h:40
registerMooseObjectDeprecated("MooseApp", MultiAppUserObjectTransfer, "12/31/2024 24:00")
uint8_t dof_id_type