www.mooseframework.org
MultiAppDTKInterpolationTransfer.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
10 #include "libmesh/libmesh_config.h"
11 
12 #ifdef LIBMESH_TRILINOS_HAVE_DTK
13 
14 // MOOSE includes
16 #include "MooseTypes.h"
17 #include "FEProblem.h"
18 #include "MultiApp.h"
19 #include "MooseMesh.h"
20 
22 
23 template <>
26 {
28  params.addRequiredParam<AuxVariableName>(
29  "variable", "The auxiliary variable to store the transferred values in.");
30  params.addRequiredParam<VariableName>("source_variable", "The variable to transfer from.");
31  return params;
32 }
33 
35  const InputParameters & parameters)
36  : MultiAppTransfer(parameters),
37  _from_var_name(getParam<VariableName>("source_variable")),
38  _to_var_name(getParam<AuxVariableName>("variable"))
39 {
40 }
41 
42 void
44 {
45  // Every processor has to be involved with every transfer because the "master" domain is on all
46  // processors
47  // However, each processor might or might not have the particular multiapp on it. When that
48  // happens
49  // we need to pass NULL in for the variable and the MPI_Comm for that piece of the transfer
50  for (unsigned int i = 0; i < _multi_app->numGlobalApps(); i++)
51  {
52  switch (_direction)
53  {
54  case TO_MULTIAPP:
55  {
56  System * from_sys = find_sys(_multi_app->problemBase().es(), _from_var_name);
57  System * to_sys = NULL;
58 
59  if (_multi_app->hasLocalApp(i))
60  to_sys = find_sys(_multi_app->appProblemBase(i).es(), _to_var_name);
61 
62  _helper.transferWithOffset(
63  0,
64  i,
65  &from_sys->variable(from_sys->variable_number(_from_var_name)),
66  to_sys ? &to_sys->variable(to_sys->variable_number(_to_var_name)) : NULL,
68  _multi_app->position(i),
69  const_cast<libMesh::Parallel::communicator *>(&_communicator.get()),
70  to_sys ? &_multi_app->comm() : NULL);
71  break;
72  }
73 
74  case FROM_MULTIAPP:
75  {
76  System * from_sys = NULL;
77  System * to_sys = find_sys(_multi_app->problemBase().es(), _to_var_name);
78 
79  if (_multi_app->hasLocalApp(i))
80  from_sys = find_sys(_multi_app->appProblemBase(i).es(), _from_var_name);
81 
82  _helper.transferWithOffset(
83  i,
84  0,
85  from_sys ? &from_sys->variable(from_sys->variable_number(_from_var_name)) : NULL,
86  &to_sys->variable(to_sys->variable_number(_to_var_name)),
87  _multi_app->position(i),
89  from_sys ? &_multi_app->comm() : NULL,
90  const_cast<libMesh::Parallel::communicator *>(&_communicator.get()));
91  break;
92  }
93 
94  _multi_app->problemBase().es().update();
95 
96  if (_multi_app->hasLocalApp(i))
97  _multi_app->appProblemBase(i).es().update();
98  }
99  }
100 }
101 
102 #endif // LIBMESH_TRILINOS_HAVE_DTK
Transfers from spatially varying Interpolations in a MultiApp to the "master" system.
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...
registerMooseObject("MooseApp", MultiAppDTKInterpolationTransfer)
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:65
const MooseEnum _direction
Whether we&#39;re transferring to or from the MultiApp.
virtual void execute() override
Execute the transfer.