16 #include <deal.II/base/memory_consumption.h> 17 #include <deal.II/base/smartpointer.h> 18 #include <deal.II/grid/tria.h> 19 #include <deal.II/dofs/dof_handler.h> 20 #include <deal.II/fe/fe.h> 21 #include <deal.II/grid/tria_accessor.h> 22 #include <deal.II/dofs/dof_accessor.h> 23 #include <deal.II/grid/tria_iterator.h> 24 #include <deal.II/grid/intergrid_map.h> 25 #include <deal.II/distributed/tria.h> 26 #include <deal.II/distributed/shared_tria.h> 29 DEAL_II_NAMESPACE_OPEN
32 template <
class MeshType>
35 source_grid(nullptr, typeid(*this).name()),
36 destination_grid(nullptr, typeid(*this).name())
42 template <
class MeshType>
44 const MeshType &destination_grid)
50 this->source_grid = &source_grid;
51 this->destination_grid = &destination_grid;
55 const unsigned int n_levels = source_grid.get_triangulation().n_levels();
56 mapping.resize (n_levels);
57 for (
unsigned int level=0; level<n_levels; ++level)
66 unsigned int n_cells = 0;
68 endc = source_grid.end(level);
69 for (; cell!=endc; ++cell)
70 if (static_cast<unsigned int>(cell->index()) > n_cells)
71 n_cells = cell->index();
76 mapping[level].resize (n_cells+1, destination_grid.end());
86 dst_cell = destination_grid.begin(0),
87 endc = source_grid.end(0);
88 for (; src_cell!=endc; ++src_cell, ++dst_cell)
89 set_mapping (src_cell, dst_cell);
93 Assert (dst_cell == destination_grid.end(0),
94 ExcIncompatibleGrids ());
99 template <
class MeshType>
105 mapping[src_cell->level()][src_cell->index()] = dst_cell;
109 if (src_cell->has_children() && dst_cell->has_children())
111 Assert(src_cell->n_children()==
114 Assert(dst_cell->n_children()==
117 Assert(src_cell->refinement_case()==dst_cell->refinement_case(),
119 for (
unsigned int c=0; c<GeometryInfo<MeshType::dimension>::max_children_per_cell; ++c)
120 set_mapping (src_cell->child(c),
123 else if (src_cell->has_children() &&
124 !dst_cell->has_children())
129 for (
unsigned int c=0; c<src_cell->n_children(); ++c)
130 set_entries_to_cell (src_cell->child(c),
139 template <
class MeshType>
145 mapping[src_cell->level()][src_cell->index()] = dst_cell;
149 if (src_cell->has_children())
150 for (
unsigned int c=0; c<src_cell->n_children(); ++c)
151 set_entries_to_cell (src_cell->child(c),
156 template <
class MeshType>
161 ExcInvalidKey (source_cell));
162 Assert (source_cell->level() <=
static_cast<int>(mapping.size()),
163 ExcInvalidKey (source_cell));
164 Assert (source_cell->index() <=
static_cast<int>(mapping[source_cell->level()].size()),
165 ExcInvalidKey (source_cell));
167 return mapping[source_cell->level()][source_cell->index()];
172 template <
class MeshType>
176 source_grid =
nullptr;
177 destination_grid =
nullptr;
182 template <
class MeshType>
191 template <
class MeshType>
195 return *destination_grid;
200 template <
class MeshType>
212 #include "intergrid_map.inst" 214 DEAL_II_NAMESPACE_CLOSE
MeshType::cell_iterator cell_iterator
cell_iterator operator[](const cell_iterator &source_cell) const
const MeshType & get_destination_grid() const
void set_entries_to_cell(const cell_iterator &src_cell, const cell_iterator &dst_cell)
const MeshType & get_source_grid() const
std::size_t memory_consumption() const
#define Assert(cond, exc)
void make_mapping(const MeshType &source_grid, const MeshType &destination_grid)
static ::ExceptionBase & ExcNotImplemented()
Iterator points to a valid object.
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
void set_mapping(const cell_iterator &src_cell, const cell_iterator &dst_cell)