46 const
bool allow_artificial_cells,
52 , allow_artificial_cells(allow_artificial_cells)
54 const auto partition_settings =
55 (partition_zoltan | partition_metis | partition_zorder |
56 partition_custom_signal) &
58 (void)partition_settings;
59 Assert(partition_settings == partition_auto ||
60 partition_settings == partition_metis ||
61 partition_settings == partition_zoltan ||
62 partition_settings == partition_zorder ||
63 partition_settings == partition_custom_signal,
64 ExcMessage(
"Settings must contain exactly one type of the active "
65 "cell partitioning scheme."));
67 if (settings & construct_multigrid_hierarchy)
68 Assert(allow_artificial_cells,
69 ExcMessage(
"construct_multigrid_hierarchy requires "
70 "allow_artificial_cells to be set to true."));
92 const unsigned int max_active_cells =
95 max_active_cells == this->n_active_cells(),
97 "A parallel::shared::Triangulation needs to be refined in the same "
98 "way on all processors, but the participating processors don't "
99 "agree on the number of active cells."));
102 auto partition_settings = (partition_zoltan | partition_metis |
103 partition_zorder | partition_custom_signal) &
105 if (partition_settings == partition_auto)
106# ifdef DEAL_II_TRILINOS_WITH_ZOLTAN
107 partition_settings = partition_zoltan;
108# elif defined DEAL_II_WITH_METIS
109 partition_settings = partition_metis;
111 partition_settings = partition_zorder;
114 if (partition_settings == partition_zoltan)
116# ifndef DEAL_II_TRILINOS_WITH_ZOLTAN
119 "Choosing 'partition_zoltan' requires the library "
120 "to be compiled with support for Zoltan! "
121 "Instead, you might use 'partition_auto' to select "
122 "a partitioning algorithm that is supported "
123 "by your current configuration."));
129 else if (partition_settings == partition_metis)
131# ifndef DEAL_II_WITH_METIS
134 "Choosing 'partition_metis' requires the library "
135 "to be compiled with support for METIS! "
136 "Instead, you might use 'partition_auto' to select "
137 "a partitioning algorithm that is supported "
138 "by your current configuration."));
145 else if (partition_settings == partition_zorder)
149 else if (partition_settings == partition_custom_signal)
160 if ((settings & construct_multigrid_hierarchy) &&
161 !(settings & partition_custom_signal))
164 true_subdomain_ids_of_cells.resize(this->n_active_cells());
168 spacedim>::active_cell_iterator
169 cell = this->begin_active(),
172 if (allow_artificial_cells)
183 spacedim>::active_cell_iterator>
184 active_halo_layer_vector =
187 std::set<typename parallel::shared::Triangulation<dim, spacedim>::
188 active_cell_iterator>
189 active_halo_layer(active_halo_layer_vector.begin(),
190 active_halo_layer_vector.end());
192 for (
unsigned int index = 0; cell != endc; cell++, index++)
195 true_subdomain_ids_of_cells[index] = cell->subdomain_id();
197 if (cell->is_locally_owned() ==
false &&
198 active_halo_layer.find(cell) == active_halo_layer.end())
203 if (settings & construct_multigrid_hierarchy)
205 true_level_subdomain_ids_of_cells.resize(this->n_levels());
211 for (
unsigned int lvl = 0; lvl < this->n_levels(); ++lvl)
213 true_level_subdomain_ids_of_cells[lvl].resize(
218 spacedim>::cell_iterator>
219 level_halo_layer_vector =
221 *
this, predicate, lvl);
222 std::set<
typename parallel::shared::
223 Triangulation<dim, spacedim>::cell_iterator>
224 level_halo_layer(level_halo_layer_vector.begin(),
225 level_halo_layer_vector.end());
228 cell_iterator cell = this->begin(lvl),
229 endc = this->end(lvl);
230 for (
unsigned int index = 0; cell != endc; cell++, index++)
234 true_level_subdomain_ids_of_cells[lvl][index] =
235 cell->level_subdomain_id();
244 if (cell->is_active() &&
245 cell->subdomain_id() !=
250 if (cell->has_children())
252 bool keep_cell =
false;
253 for (
unsigned int c = 0;
254 c < GeometryInfo<dim>::max_children_per_cell;
256 if (cell->child(c)->level_subdomain_id() ==
268 if (!cell->is_locally_owned_on_level() &&
269 level_halo_layer.find(cell) != level_halo_layer.
end())
273 cell->set_level_subdomain_id(
282 for (
unsigned int index = 0; cell != endc; cell++,
index++)
283 true_subdomain_ids_of_cells[
index] = cell->subdomain_id();
289 const unsigned int n_my_cells = std::count_if(
290 this->begin_active(),
293 [](
const auto &i) {
return (i.is_locally_owned()); });
295 const unsigned int total_cells =
297 Assert(total_cells == this->n_active_cells(),
298 ExcMessage(
"Not all cells are assigned to a processor."));
303 if (settings & construct_multigrid_hierarchy)
305 const unsigned int n_my_cells =
306 std::count_if(this->begin(), this->end(), [](
const auto &i) {
307 return (i.is_locally_owned_on_level());
311 const unsigned int total_cells =
313 Assert(total_cells == this->n_cells(),
314 ExcMessage(
"Not all cells are assigned to a processor."));
321 template <
int dim,
int spacedim>
325 return allow_artificial_cells;
330 template <
int dim,
int spacedim>
332 const std::vector<types::subdomain_id>
335 return true_subdomain_ids_of_cells;
340 template <
int dim,
int spacedim>
342 const std::vector<types::subdomain_id>
344 const unsigned int level)
const
346 Assert(
level < true_level_subdomain_ids_of_cells.size(),
348 Assert(true_level_subdomain_ids_of_cells[
level].size() ==
349 this->n_cells(
level),
351 return true_level_subdomain_ids_of_cells[
level];
356 template <
int dim,
int spacedim>
372 using int_type = std::underlying_type_t<
374 static_assert(
sizeof(int_type) ==
sizeof(std::uint8_t),
375 "Internal type mismatch.");
377 std::vector<int_type> refinement_configurations(this->n_active_cells() *
380 for (
const auto &cell : this->active_cell_iterators())
381 if (cell->is_locally_owned())
383 refinement_configurations[cell->active_cell_index() * 2 + 0] =
384 static_cast<int_type
>(cell->refine_flag_set());
385 refinement_configurations[cell->active_cell_index() * 2 + 1] =
386 static_cast<int_type
>(cell->coarsen_flag_set() ? 1 : 0);
390 this->get_communicator(),
391 refinement_configurations);
393 for (
const auto &cell : this->active_cell_iterators())
395 cell->clear_refine_flag();
396 cell->clear_coarsen_flag();
399 (refinement_configurations[cell->active_cell_index() * 2 + 0] >
403 refinement_configurations[cell->active_cell_index() * 2 +
407 "Refinement/coarsening flags of cells are not consistent in parallel!"));
409 if (refinement_configurations[cell->active_cell_index() * 2 + 0] !=
412 refinement_configurations[cell->active_cell_index() * 2 + 0]));
414 if (refinement_configurations[cell->active_cell_index() * 2 + 1] >
416 cell->set_coarsen_flag();
422 this->update_number_cache();
427 template <
int dim,
int spacedim>
440 const typename ::Triangulation<dim, spacedim>::DistortedCellList
448 this->update_number_cache();
453 template <
int dim,
int spacedim>
459 (void)construction_data;
466 template <
int dim,
int spacedim>
473 const ::parallel::DistributedTriangulationBase<dim, spacedim>
474 *
>(&other_tria) ==
nullptr),
476 "Cannot use this function on parallel::distributed::Triangulation."));
481 this->update_number_cache();
492 template <
int dim,
int spacedim>
502 template <
int dim,
int spacedim>
512 template <
int dim,
int spacedim>
514 const std::vector<unsigned int>
518 return true_subdomain_ids_of_cells;
523 template <
int dim,
int spacedim>
525 const std::vector<unsigned int>
527 const unsigned int)
const
530 return true_level_subdomain_ids_of_cells;
546 template <
int dim,
int spacedim>
558 const std::vector<types::subdomain_id> &true_subdomain_ids =
562 for (
const auto &cell :
shared_tria->active_cell_iterators())
564 const unsigned int index = cell->active_cell_index();
566 cell->set_subdomain_id(true_subdomain_ids[
index]);
573 template <
int dim,
int spacedim>
577 if (shared_tria && shared_tria->with_artificial_cells())
580 for (
const auto &cell : shared_tria->active_cell_iterators())
582 const unsigned int index = cell->active_cell_index();
583 cell->set_subdomain_id(saved_subdomain_ids[
index]);
593#include "shared_tria.inst"
std::vector< unsigned int > saved_subdomain_ids
const SmartPointer< const ::parallel::shared::Triangulation< dim, spacedim > > shared_tria
TemporarilyRestoreSubdomainIds(const Triangulation< dim, spacedim > &tria)