www.mooseframework.org
Public Member Functions | Protected Types | Protected Attributes | List of all members
libMesh::DTKInterpolationHelper Class Reference

Helper object that uses DTK to interpolate between two libMesh based systems. More...

#include <DTKInterpolationHelper.h>

Public Member Functions

 DTKInterpolationHelper ()
 
virtual ~DTKInterpolationHelper ()
 
void transferWithOffset (unsigned int from, unsigned int to, const Variable *from_var, const Variable *to_var, const Point &from_offset, const Point &to_offset, MPI_Comm *from_mpi_comm, MPI_Comm *to_mpi_comm)
 Do an interpolation with possibly offsetting each of the domains (moving them). More...
 

Protected Types

typedef DataTransferKit::SharedDomainMap< DTKInterpolationAdapter::MeshContainerType, DTKInterpolationAdapter::MeshContainerTypeshared_domain_map_type
 

Protected Attributes

std::map< EquationSystems *, DTKInterpolationAdapter * > adapters
 The DTKAdapter associated with each EquationSystems. More...
 
std::map< std::pair< unsigned int, unsigned int >, shared_domain_map_type * > dtk_maps
 The dtk shared domain maps for pairs of EquationSystems (from, to) More...
 

Detailed Description

Helper object that uses DTK to interpolate between two libMesh based systems.

Definition at line 34 of file DTKInterpolationHelper.h.

Member Typedef Documentation

◆ shared_domain_map_type

Definition at line 70 of file DTKInterpolationHelper.h.

Constructor & Destructor Documentation

◆ DTKInterpolationHelper()

libMesh::DTKInterpolationHelper::DTKInterpolationHelper ( )

Definition at line 44 of file DTKInterpolationHelper.C.

44 {}

◆ ~DTKInterpolationHelper()

libMesh::DTKInterpolationHelper::~DTKInterpolationHelper ( )
virtual

Definition at line 46 of file DTKInterpolationHelper.C.

47 {
48  for (std::map<EquationSystems *, DTKInterpolationAdapter *>::iterator it = adapters.begin();
49  it != adapters.end();
50  ++it)
51  delete it->second;
52 
53  for (std::map<std::pair<unsigned int, unsigned int>, shared_domain_map_type *>::iterator it =
54  dtk_maps.begin();
55  it != dtk_maps.end();
56  ++it)
57  delete it->second;
58 }
DataTransferKit::SharedDomainMap< DTKInterpolationAdapter::MeshContainerType, DTKInterpolationAdapter::MeshContainerType > shared_domain_map_type
std::map< EquationSystems *, DTKInterpolationAdapter * > adapters
The DTKAdapter associated with each EquationSystems.
std::map< std::pair< unsigned int, unsigned int >, shared_domain_map_type * > dtk_maps
The dtk shared domain maps for pairs of EquationSystems (from, to)

Member Function Documentation

◆ transferWithOffset()

void libMesh::DTKInterpolationHelper::transferWithOffset ( unsigned int  from,
unsigned int  to,
const Variable *  from_var,
const Variable *  to_var,
const Point &  from_offset,
const Point &  to_offset,
MPI_Comm *  from_mpi_comm,
MPI_Comm *  to_mpi_comm 
)

Do an interpolation with possibly offsetting each of the domains (moving them).

Parameters
fromA unique identifier for the source system.
toA unique identifier for the target system.
from_varThe source variable. Pass NULL if this processor doesn't own any of the source domain.
to_varThe destination variable Pass NULL if this processor doesn't own any of the destination domain.
from_offsetHow much to move the source domain. This value will get added to each nodal position.
to_offsetHow much to move the destination domain. This value will get added to each nodal position.
from_mpi_commThe MPI communicator the source domain lives on. If NULL then this particular processor doesn't contain the source domain.
to_mpi_commThe MPI communicator the destination domain lives on. If NULL then this particular processor doesn't contain the destination domain.

Definition at line 61 of file DTKInterpolationHelper.C.

69 {
70  Teuchos::RCP<const Teuchos::MpiComm<int>> from_comm;
71  Teuchos::RCP<const Teuchos::MpiComm<int>> to_comm;
72 
73  if (from_mpi_comm)
74  from_comm = Teuchos::rcp(new Teuchos::MpiComm<int>(
75  Teuchos::rcp(new Teuchos::OpaqueWrapper<MPI_Comm>(*from_mpi_comm))));
76 
77  if (to_mpi_comm)
78  to_comm = Teuchos::rcp(new Teuchos::MpiComm<int>(
79  Teuchos::rcp(new Teuchos::OpaqueWrapper<MPI_Comm>(*to_mpi_comm))));
80 
81  // Create a union comm for the shared domain transfer
82  Teuchos::RCP<const Teuchos::Comm<int>> comm_union;
83 
84  DataTransferKit::CommTools::unite(from_comm, to_comm, comm_union);
85 
86  EquationSystems * from_es = NULL;
87  EquationSystems * to_es = NULL;
88 
89  if (from_mpi_comm)
90  from_es = &from_var->system()->get_equation_systems();
91 
92  if (to_mpi_comm)
93  to_es = &to_var->system()->get_equation_systems();
94 
95  unsigned int dim = 3;
96 
97  if (from_es && to_es &&
98  (from_es->get_mesh().mesh_dimension() < to_es->get_mesh().mesh_dimension()))
99  mooseError(
100  "Receiving system dimension should be less than or equal to the sending system dimension!");
101 
102  if (from_es && to_es)
103  dim = std::max(from_es->get_mesh().mesh_dimension(), to_es->get_mesh().mesh_dimension());
104  else if (from_es)
105  dim = from_es->get_mesh().mesh_dimension();
106  else
107  dim = to_es->get_mesh().mesh_dimension();
108 
109  // Possibly make an Adapter for from_es
110  if (from_mpi_comm && adapters.find(from_es) == adapters.end())
111  adapters[from_es] = new DTKInterpolationAdapter(from_comm, *from_es, from_offset, dim);
112 
113  // Possibly make an Adapter for to_es
114  if (to_mpi_comm && adapters.find(to_es) == adapters.end())
115  adapters[to_es] = new DTKInterpolationAdapter(to_comm, *to_es, to_offset, dim);
116 
117  DTKInterpolationAdapter * from_adapter = NULL;
118  DTKInterpolationAdapter * to_adapter = NULL;
119 
120  if (from_mpi_comm)
121  from_adapter = adapters[from_es];
122 
123  if (to_mpi_comm)
124  to_adapter = adapters[to_es];
125 
126  std::pair<int, int> from_to(from, to);
127 
128  // If we haven't created a map for this pair of EquationSystems yet, do it now
129  if (dtk_maps.find(from_to) == dtk_maps.end())
130  {
131  shared_domain_map_type * map = NULL;
132 
133  if (from_mpi_comm)
134  map = new shared_domain_map_type(comm_union, from_es->get_mesh().mesh_dimension(), true);
135  else if (to_mpi_comm)
136  map = new shared_domain_map_type(comm_union, to_es->get_mesh().mesh_dimension(), true);
137 
138  dtk_maps[from_to] = map;
139 
140  // The tolerance here is for the "contains_point()" implementation in DTK. Set a larger value
141  // for a looser tolerance...
142  if (from_mpi_comm && to_mpi_comm)
143  {
144  if (to_var->type() == FEType())
145  map->setup(from_adapter->get_mesh_manager(),
146  to_adapter->get_target_coords(),
148  else
149  map->setup(from_adapter->get_mesh_manager(),
150  to_adapter->get_elem_target_coords(),
152  }
153  else if (from_mpi_comm)
154  map->setup(
155  from_adapter->get_mesh_manager(),
156  Teuchos::RCP<DataTransferKit::FieldManager<DTKInterpolationAdapter::MeshContainerType>>(),
158  else if (to_mpi_comm)
159  {
160  if (to_var->type() == FEType())
161  map->setup(Teuchos::RCP<
162  DataTransferKit::MeshManager<DTKInterpolationAdapter::MeshContainerType>>(),
163  to_adapter->get_target_coords(),
165  else
166  map->setup(Teuchos::RCP<
167  DataTransferKit::MeshManager<DTKInterpolationAdapter::MeshContainerType>>(),
168  to_adapter->get_elem_target_coords(),
170  }
171  }
172 
174 
175  if (from_mpi_comm)
176  from_evaluator = from_adapter->get_variable_evaluator(from_var->name());
177 
178  Teuchos::RCP<DataTransferKit::FieldManager<DTKInterpolationAdapter::FieldContainerType>>
179  to_values;
180 
181  if (to_mpi_comm)
182  to_values = to_adapter->get_values_to_fill(to_var->name());
183 
184  dtk_maps[from_to]->apply(from_evaluator, to_values);
185 
186  if (to_mpi_comm)
187  to_adapter->update_variable_values(to_var->name(), dtk_maps[from_to]->getMissedTargetPoints());
188 }
int eps(unsigned int i, unsigned int j)
2D version
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...
RCP_Evaluator get_variable_evaluator(std::string var_name)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
Teuchos::RCP< EvaluatorType > RCP_Evaluator
Teuchos::RCP< DataTransferKit::MeshManager< MeshContainerType > > get_mesh_manager()
DataTransferKit::SharedDomainMap< DTKInterpolationAdapter::MeshContainerType, DTKInterpolationAdapter::MeshContainerType > shared_domain_map_type
std::map< EquationSystems *, DTKInterpolationAdapter * > adapters
The DTKAdapter associated with each EquationSystems.
Teuchos::RCP< DataTransferKit::FieldManager< MeshContainerType > > get_elem_target_coords()
Used to get the centroids for the receiving elements.
Teuchos::RCP< DataTransferKit::FieldManager< FieldContainerType > > get_values_to_fill(std::string var_name)
Teuchos::RCP< DataTransferKit::FieldManager< MeshContainerType > > get_target_coords()
std::map< std::pair< unsigned int, unsigned int >, shared_domain_map_type * > dtk_maps
The dtk shared domain maps for pairs of EquationSystems (from, to)

Member Data Documentation

◆ adapters

std::map<EquationSystems *, DTKInterpolationAdapter *> libMesh::DTKInterpolationHelper::adapters
protected

The DTKAdapter associated with each EquationSystems.

Definition at line 73 of file DTKInterpolationHelper.h.

Referenced by transferWithOffset(), and ~DTKInterpolationHelper().

◆ dtk_maps

std::map<std::pair<unsigned int, unsigned int>, shared_domain_map_type *> libMesh::DTKInterpolationHelper::dtk_maps
protected

The dtk shared domain maps for pairs of EquationSystems (from, to)

Definition at line 76 of file DTKInterpolationHelper.h.

Referenced by transferWithOffset(), and ~DTKInterpolationHelper().


The documentation for this class was generated from the following files: