30 template <
int dim,
int spacedim>
40 namespace fullydistributed
42 template <
int dim,
int spacedim>
47 const unsigned
int n_partitions) {
50 , currently_processing_create_triangulation_for_internal_usage(
false)
51 , currently_processing_prepare_coarsening_and_refinement_for_internal_usage(
57 template <
int dim,
int spacedim>
65 Assert(construction_data.
comm == this->mpi_communicator,
66 ExcMessage(
"MPI communicators do not match!"));
69 settings = construction_data.
settings;
74 this->set_mesh_smoothing(
76 typename ::Triangulation<dim, spacedim>::MeshSmoothing
>(
80 this->set_mesh_smoothing(
82 typename ::Triangulation<dim, spacedim>::MeshSmoothing
>(
85 this->set_mesh_smoothing(construction_data.
smoothing);
88 this->coarse_cell_id_to_coarse_cell_index_vector.clear();
89 this->coarse_cell_index_to_coarse_cell_id_vector.clear();
95 currently_processing_create_triangulation_for_internal_usage =
true;
97 currently_processing_create_triangulation_for_internal_usage =
false;
100 auto cell = this->
begin();
102 cell->set_level_subdomain_id(
107 this->coarse_cell_id_to_coarse_cell_index_vector.emplace_back(
109 this->coarse_cell_index_to_coarse_cell_id_vector.emplace_back(
115 this->coarse_cell_index_to_coarse_cell_id_vector =
119 std::map<types::coarse_cell_id, unsigned int>
120 coarse_cell_id_to_coarse_cell_index_vector;
121 for (
unsigned int i = 0;
124 coarse_cell_id_to_coarse_cell_index_vector
127 for (
auto i : coarse_cell_id_to_coarse_cell_index_vector)
128 this->coarse_cell_id_to_coarse_cell_index_vector.emplace_back(i);
131 currently_processing_prepare_coarsening_and_refinement_for_internal_usage =
133 currently_processing_create_triangulation_for_internal_usage =
true;
136 currently_processing_prepare_coarsening_and_refinement_for_internal_usage =
138 currently_processing_create_triangulation_for_internal_usage =
false;
141 auto cell_infos = construction_data.
cell_infos;
145 for (
auto &cell_info : cell_infos)
146 std::sort(cell_info.begin(),
150 const CellId a_id(a.id);
151 const CellId b_id(b.id);
153 const auto a_coarse_cell_index =
154 this->coarse_cell_id_to_coarse_cell_index(
155 a_id.get_coarse_cell_id());
156 const auto b_coarse_cell_index =
157 this->coarse_cell_id_to_coarse_cell_index(
158 b_id.get_coarse_cell_id());
165 if (a_coarse_cell_index != b_coarse_cell_index)
166 return a_coarse_cell_index < b_coarse_cell_index;
173 for (
auto cell = this->
begin(); cell != this->
end(); ++cell)
175 if (cell->is_active())
176 cell->set_subdomain_id(
179 cell->set_level_subdomain_id(
187 auto cell_info = cell_infos[
level].begin();
188 for (; cell_info != cell_infos[
level].end(); ++cell_info)
191 while (cell_info->id != cell->id().template to_binary<dim>())
195 if (cell->is_active())
196 cell->set_subdomain_id(cell_info->subdomain_id);
201 cell->set_level_subdomain_id(cell_info->level_subdomain_id);
206 this->update_number_cache();
211 template <
int dim,
int spacedim>
219 currently_processing_create_triangulation_for_internal_usage,
221 "Use the other create_triangulation() function to create triangulations of type parallel::fullydistributed::Triangulation.!"));
230 template <
int dim,
int spacedim>
233 const ::Triangulation<dim, spacedim> &other_tria)
239 const ::Triangulation<dim, spacedim> *other_tria_ptr = &other_tria;
246 std::unique_ptr<::Triangulation<dim, spacedim>> serial_tria;
250 if (
dynamic_cast<const ::parallel::TriangulationBase<dim, spacedim>
251 *
>(&other_tria) ==
nullptr)
254 std_cxx14::make_unique<::Triangulation<dim, spacedim>>();
257 serial_tria->copy_triangulation(other_tria);
260 this->partitioner(*serial_tria,
262 this->mpi_communicator));
265 if (this->is_multilevel_hierarchy_constructed())
269 other_tria_ptr = serial_tria.get();
275 this->mpi_communicator,
284 template <
int dim,
int spacedim>
288 const unsigned int)> &partitioner,
291 this->partitioner = partitioner;
292 this->settings = settings;
297 template <
int dim,
int spacedim>
306 template <
int dim,
int spacedim>
311 currently_processing_prepare_coarsening_and_refinement_for_internal_usage,
312 ExcMessage(
"No coarsening and refinement is supported!"));
314 return ::Triangulation<dim, spacedim>::
315 prepare_coarsening_and_refinement();
320 template <
int dim,
int spacedim>
330 template <
int dim,
int spacedim>
334 const std::size_t mem =
338 coarse_cell_id_to_coarse_cell_index_vector) +
340 coarse_cell_index_to_coarse_cell_id_vector);
346 template <
int dim,
int spacedim>
357 template <
int dim,
int spacedim>
363 coarse_cell_id_to_coarse_cell_index_vector.begin(),
364 coarse_cell_id_to_coarse_cell_index_vector.end(),
366 [](
const std::pair<types::coarse_cell_id, unsigned int> &pair,
368 Assert(coarse_cell_index !=
369 coarse_cell_id_to_coarse_cell_index_vector.cend(),
371 return coarse_cell_index->second;
376 template <
int dim,
int spacedim>
379 const unsigned int coarse_cell_index)
const
382 coarse_cell_index_to_coarse_cell_id_vector.size());
385 coarse_cell_index_to_coarse_cell_id_vector[coarse_cell_index];
387 ExcMessage(
"You are trying to access a dummy cell!"));
399 #include "fully_distributed_tria.inst"