www.mooseframework.org
MultiAppDTKUserObjectEvaluator.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 "UserObject.h"
22 #include "Executioner.h"
23 #include "FEProblem.h"
24 #include "MultiApp.h"
25 #include "MooseTypes.h"
26 #include "MooseMesh.h"
27 
28 #include "libmesh/mesh_tools.h"
29 
31  const std::string & user_object_name)
32  : _multi_app(multi_app), _user_object_name(user_object_name)
33 {
34 }
35 
37 
38 DataTransferKit::FieldContainer<double>
39 MultiAppDTKUserObjectEvaluator::evaluate(const Teuchos::ArrayRCP<GlobalOrdinal> & bids,
40  const Teuchos::ArrayRCP<double> & coords)
41 {
42  Teuchos::RCP<const Teuchos::Comm<int>> comm = Teuchos::rcp(new Teuchos::MpiComm<int>(
43  Teuchos::rcp(new Teuchos::OpaqueWrapper<MPI_Comm>(_multi_app.comm()))));
44 
45  int num_values = bids.size();
46 
47  Teuchos::ArrayRCP<double> evaluated_data(num_values);
48 
49  unsigned int dim = 3; // TODO: REPLACE ME!!!!!!!!!
50 
51  for (GlobalOrdinal i = 0; i < static_cast<GlobalOrdinal>(num_values); i++)
52  {
53  // See if this app is on this processor
54  if (std::binary_search(_box_ids.begin(), _box_ids.end(), bids[i]))
55  {
56  GlobalOrdinal app = bids[i];
57 
58  Point p;
59  for (unsigned int j = 0; j < dim; j++)
60  p(j) = coords[(j * num_values) + i];
61 
62  evaluated_data[i] = _multi_app.appUserObjectBase(app, _user_object_name)
63  .spatialValue(p - _multi_app.position(app));
64  }
65  else
66  evaluated_data[i] = 0.0;
67  }
68 
69  return DataTransferKit::FieldContainer<double>(evaluated_data, 1);
70 }
71 
72 Teuchos::RCP<DataTransferKit::GeometryManager<DataTransferKit::Box, long unsigned int>>
74  const Teuchos::RCP<const Teuchos::Comm<int>> & comm)
75 {
76  _boxes.resize(_multi_app.numLocalApps());
78 
79  comm->barrier();
80 
81  for (unsigned int app = 0; app < _multi_app.numLocalApps(); app++)
82  {
83  unsigned int global_app = _multi_app.firstLocalApp() + app;
84 
85  BoundingBox bbox = _multi_app.getBoundingBox(global_app);
86 
87  _boxes[app] = DataTransferKit::Box(
88  bbox.min()(0), bbox.min()(1), bbox.min()(2), bbox.max()(0), bbox.max()(1), bbox.max()(2));
89 
90  _box_ids[app] = global_app;
91  }
92 
93  return Teuchos::rcp(new DataTransferKit::GeometryManager<DataTransferKit::Box, GlobalOrdinal>(
94  _boxes, _box_ids, comm, 3));
95 }
96 
97 #endif // LIBMESH_TRILINOS_HAVE_DTK
Point position(unsigned int app)
The physical position of a global App number.
Definition: MultiApp.h:222
Teuchos::ArrayRCP< DataTransferKit::Box > _boxes
MultiAppDTKUserObjectEvaluator(MultiApp &multi_app, const std::string &user_object_name)
Teuchos::RCP< DataTransferKit::GeometryManager< DataTransferKit::Box, GlobalOrdinal > > createSourceGeometry(const Teuchos::RCP< const Teuchos::Comm< int >> &comm)
Teuchos::ArrayRCP< GlobalOrdinal > _box_ids
unsigned int numLocalApps()
Definition: MultiApp.h:192
std::string _user_object_name
The name of the UserObject we&#39;re going to be evaluating.
DataTransferKit::FieldContainer< double > evaluate(const Teuchos::ArrayRCP< GlobalOrdinal > &bids, const Teuchos::ArrayRCP< double > &coords)
unsigned int firstLocalApp()
Definition: MultiApp.h:197
virtual BoundingBox getBoundingBox(unsigned int app)
Get the BoundingBox for the mesh associated with app The bounding box will be shifted to be in the co...
Definition: MultiApp.C:359
MPI_Comm & comm()
Get the MPI communicator this MultiApp is operating on.
Definition: MultiApp.h:256
MPI_Comm comm
MultiApp & _multi_app
The MultiAppUserObject object this object will be evaluating.
A MultiApp represents one or more MOOSE applications that are running simultaneously.
Definition: MultiApp.h:59
const UserObject & appUserObjectBase(unsigned int app, const std::string &name)
Get a UserObject base for a specific global app.
Definition: MultiApp.C:431
virtual Real spatialValue(const Point &) const
Optional interface function for "evaluating" a UserObject at a spatial position.
Definition: UserObject.h:99