www.mooseframework.org
MultiAppDTKInterpolationTransfer.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "libmesh/libmesh_config.h"
16 
17 #ifdef LIBMESH_TRILINOS_HAVE_DTK
18 
19 // MOOSE includes
21 #include "MooseTypes.h"
22 #include "FEProblem.h"
23 #include "MultiApp.h"
24 #include "MooseMesh.h"
25 
26 template <>
29 {
31  params.addRequiredParam<AuxVariableName>(
32  "variable", "The auxiliary variable to store the transferred values in.");
33  params.addRequiredParam<VariableName>("source_variable", "The variable to transfer from.");
34  return params;
35 }
36 
38  const InputParameters & parameters)
39  : MultiAppTransfer(parameters),
40  _from_var_name(getParam<VariableName>("source_variable")),
41  _to_var_name(getParam<AuxVariableName>("variable"))
42 {
43 }
44 
45 void
47 {
48  // Every processor has to be involved with every transfer because the "master" domain is on all
49  // processors
50  // However, each processor might or might not have the particular multiapp on it. When that
51  // happens
52  // we need to pass NULL in for the variable and the MPI_Comm for that piece of the transfer
53  for (unsigned int i = 0; i < _multi_app->numGlobalApps(); i++)
54  {
55  switch (_direction)
56  {
57  case TO_MULTIAPP:
58  {
59  System * from_sys = find_sys(_multi_app->problemBase().es(), _from_var_name);
60  System * to_sys = NULL;
61 
62  if (_multi_app->hasLocalApp(i))
63  to_sys = find_sys(_multi_app->appProblemBase(i).es(), _to_var_name);
64 
65  _helper.transferWithOffset(
66  0,
67  i,
68  &from_sys->variable(from_sys->variable_number(_from_var_name)),
69  to_sys ? &to_sys->variable(to_sys->variable_number(_to_var_name)) : NULL,
71  _multi_app->position(i),
72  const_cast<libMesh::Parallel::communicator *>(&_communicator.get()),
73  to_sys ? &_multi_app->comm() : NULL);
74  break;
75  }
76 
77  case FROM_MULTIAPP:
78  {
79  System * from_sys = NULL;
80  System * to_sys = find_sys(_multi_app->problemBase().es(), _to_var_name);
81 
82  if (_multi_app->hasLocalApp(i))
83  from_sys = find_sys(_multi_app->appProblemBase(i).es(), _from_var_name);
84 
85  _helper.transferWithOffset(
86  i,
87  0,
88  from_sys ? &from_sys->variable(from_sys->variable_number(_from_var_name)) : NULL,
89  &to_sys->variable(to_sys->variable_number(_to_var_name)),
90  _multi_app->position(i),
92  from_sys ? &_multi_app->comm() : NULL,
93  const_cast<libMesh::Parallel::communicator *>(&_communicator.get()));
94  break;
95  }
96 
97  _multi_app->problemBase().es().update();
98 
99  if (_multi_app->hasLocalApp(i))
100  _multi_app->appProblemBase(i).es().update();
101  }
102  }
103 }
104 
105 #endif // LIBMESH_TRILINOS_HAVE_DTK
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MultiAppDTKInterpolationTransfer(const InputParameters &parameters)
std::shared_ptr< MultiApp > _multi_app
The MultiApp this Transfer is transferring data to or from.
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...
MooseEnum _direction
Whether we&#39;re transferring to or from the MultiApp.
InputParameters validParams< MultiAppTransfer >()
Base class for all MultiAppTransfer objects.
InputParameters validParams< MultiAppDTKInterpolationTransfer >()
static System * find_sys(EquationSystems &es, const std::string &var_name)
Small helper function for finding the system containing the variable.
Definition: Transfer.C:70
virtual void execute() override
Execute the transfer.