www.mooseframework.org
MultiAppDTKUserObjectTransfer.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 
21 #include "MultiApp.h"
22 
23 // Moose Includes
24 #include "MooseTypes.h"
25 #include "FEProblem.h"
26 #include "MooseVariable.h"
27 
28 template <>
31 {
33  params.addRequiredParam<AuxVariableName>(
34  "variable", "The auxiliary variable to store the transferred values in.");
35  params.addRequiredParam<UserObjectName>(
36  "user_object",
37  "The UserObject you want to transfer values from. Note: This might be a "
38  "UserObject from your MultiApp's input file!");
39  return params;
40 }
41 
43  : MultiAppTransfer(parameters),
44  MooseVariableInterface(this, true),
45  _user_object_name(getParam<UserObjectName>("user_object")),
46  _setup(false)
47 {
48 }
49 
50 void
52 {
53  if (!_setup)
54  {
55  _setup = true;
56 
57  _comm_default = Teuchos::rcp(new Teuchos::MpiComm<int>(
58  Teuchos::rcp(new Teuchos::OpaqueWrapper<MPI_Comm>(_communicator.get()))));
59 
62 
64 
66 
67  _to_adapter =
68  new DTKInterpolationAdapter(_comm_default, _multi_app->problemBase().es(), Point(), 3);
69 
71  new DataTransferKit::VolumeSourceMap<DataTransferKit::Box,
73  DataTransferKit::MeshContainer<GlobalOrdinal>>(
74  _comm_default, 3, true);
75 
76  _console << "--Setting Up Transfer--" << std::endl;
77  if (_variable->isNodal())
78  _src_to_tgt_map->setup(_multi_app_geom, _to_adapter->get_target_coords());
79  else
80  _src_to_tgt_map->setup(_multi_app_geom, _to_adapter->get_elem_target_coords());
81 
82  _console << "--Transfer Setup Complete--" << std::endl;
83 
85  }
86 
87  _console << "--Mapping Values--" << std::endl;
89  _console << "--Finished Mapping--" << std::endl;
90 
91  _to_adapter->update_variable_values(_variable->name(), _src_to_tgt_map->getMissedTargetPoints());
92  _multi_app->problemBase().es().update();
93 }
94 
95 #endif // LIBMESH_TRILINOS_HAVE_DTK
void update_variable_values(std::string var_name, Teuchos::ArrayView< GlobalOrdinal > missed_points)
After computing values for a variable in this EquationSystems we need to take those values and put th...
Evaluates the specified UserObject and returns the result in a DTK FieldContainer.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
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...
const std::string & name() const
Get the variable name.
virtual bool isNodal() const override
Is this variable nodal.
Teuchos::RCP< const Teuchos::MpiComm< int > > _comm_default
MultiAppDTKUserObjectTransfer(const InputParameters &parameters)
virtual void execute() override
Execute the transfer.
Teuchos::RCP< DataTransferKit::FieldManager< DTKAdapter::FieldContainerType > > _to_values
DataTransferKit::VolumeSourceMap< DataTransferKit::Box, GlobalOrdinal, DataTransferKit::MeshContainer< GlobalOrdinal > > * _src_to_tgt_map
InputParameters validParams< MultiAppDTKUserObjectTransfer >()
Teuchos::RCP< MultiAppDTKUserObjectEvaluator > _multi_app_user_object_evaluator
Teuchos::RCP< DataTransferKit::FieldManager< MeshContainerType > > get_elem_target_coords()
Used to get the centroids for the receiving elements.
InputParameters validParams< MultiAppTransfer >()
Teuchos::RCP< DataTransferKit::GeometryManager< DataTransferKit::Box, GlobalOrdinal > > _multi_app_geom
Base class for all MultiAppTransfer objects.
Interface for objects that need to get values of MooseVariables.
Teuchos::RCP< DataTransferKit::FieldEvaluator< GlobalOrdinal, DataTransferKit::FieldContainer< double > > > _field_evaluator
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
MooseVariable * _variable
The variable this object is acting on.
Teuchos::RCP< DataTransferKit::FieldManager< FieldContainerType > > get_values_to_fill(std::string var_name)
Teuchos::RCP< DataTransferKit::FieldManager< MeshContainerType > > get_target_coords()