44 const
bool allow_artificial_cells,
50 , allow_artificial_cells(allow_artificial_cells)
52 const auto partition_settings =
53 (partition_zoltan | partition_metis | partition_zorder |
54 partition_custom_signal) &
56 Assert(partition_settings == partition_auto ||
57 partition_settings == partition_metis ||
58 partition_settings == partition_zoltan ||
59 partition_settings == partition_zorder ||
60 partition_settings == partition_custom_signal,
61 ExcMessage(
"Settings must contain exactly one type of the active "
62 "cell partitioning scheme."));
64 if (settings & construct_multigrid_hierarchy)
65 Assert(allow_artificial_cells,
66 ExcMessage(
"construct_multigrid_hierarchy requires "
67 "allow_artificial_cells to be set to true."));
90 const unsigned int max_active_cells =
92 this->get_mpi_communicator());
94 max_active_cells == this->n_active_cells(),
96 "A parallel::shared::Triangulation needs to be refined in the same "
97 "way on all processors, but the participating processors don't "
98 "agree on the number of active cells."));
101 auto partition_settings = (partition_zoltan | partition_metis |
102 partition_zorder | partition_custom_signal) &
104 if (partition_settings == partition_auto)
105# ifdef DEAL_II_TRILINOS_WITH_ZOLTAN
106 partition_settings = partition_zoltan;
107# elif defined DEAL_II_WITH_METIS
108 partition_settings = partition_metis;
110 partition_settings = partition_zorder;
113 if (partition_settings == partition_zoltan)
115# ifndef DEAL_II_TRILINOS_WITH_ZOLTAN
118 "Choosing 'partition_zoltan' requires the library "
119 "to be compiled with support for Zoltan! "
120 "Instead, you might use 'partition_auto' to select "
121 "a partitioning algorithm that is supported "
122 "by your current configuration."));
128 else if (partition_settings == partition_metis)
130# ifndef DEAL_II_WITH_METIS
133 "Choosing 'partition_metis' requires the library "
134 "to be compiled with support for METIS! "
135 "Instead, you might use 'partition_auto' to select "
136 "a partitioning algorithm that is supported "
137 "by your current configuration."));
144 else if (partition_settings == partition_zorder)
148 else if (partition_settings == partition_custom_signal)
159 if ((settings & construct_multigrid_hierarchy) &&
160 !(settings & partition_custom_signal))
163 true_subdomain_ids_of_cells.resize(this->n_active_cells());
167 spacedim>::active_cell_iterator
168 cell = this->begin_active(),
171 if (allow_artificial_cells)
182 spacedim>::active_cell_iterator>
183 active_halo_layer_vector =
186 std::set<typename parallel::shared::Triangulation<dim, spacedim>::
187 active_cell_iterator>
188 active_halo_layer(active_halo_layer_vector.begin(),
189 active_halo_layer_vector.end());
191 for (
unsigned int index = 0; cell != endc; cell++, index++)
194 true_subdomain_ids_of_cells[index] = cell->subdomain_id();
196 if (cell->is_locally_owned() ==
false &&
197 active_halo_layer.find(cell) == active_halo_layer.end())
202 if (settings & construct_multigrid_hierarchy)
204 true_level_subdomain_ids_of_cells.resize(this->n_levels());
210 for (
unsigned int lvl = 0; lvl < this->n_levels(); ++lvl)
212 true_level_subdomain_ids_of_cells[lvl].resize(
217 spacedim>::cell_iterator>
218 level_halo_layer_vector =
220 *
this, predicate, lvl);
221 std::set<
typename parallel::shared::
222 Triangulation<dim, spacedim>::cell_iterator>
223 level_halo_layer(level_halo_layer_vector.begin(),
224 level_halo_layer_vector.end());
227 cell_iterator cell = this->
begin(lvl),
228 endc = this->
end(lvl);
229 for (
unsigned int index = 0; cell != endc; cell++, index++)
233 true_level_subdomain_ids_of_cells[lvl][index] =
234 cell->level_subdomain_id();
243 if (cell->is_active() &&
244 cell->subdomain_id() !=
249 if (cell->has_children())
251 bool keep_cell =
false;
252 for (
unsigned int c = 0; c < cell->n_children(); ++c)
253 if (cell->child(c)->level_subdomain_id() ==
265 if (!cell->is_locally_owned_on_level() &&
266 level_halo_layer.find(cell) != level_halo_layer.
end())
270 cell->set_level_subdomain_id(
279 for (
unsigned int index = 0; cell != endc; cell++, index++)
280 true_subdomain_ids_of_cells[index] = cell->subdomain_id();
287 const unsigned int n_my_cells = std::count_if(
288 this->begin_active(),
291 [](
const auto &i) {
return (i.is_locally_owned()); });
293 const unsigned int total_cells =
295 Assert(total_cells == this->n_active_cells(),
296 ExcMessage(
"Not all cells are assigned to a processor."));
301 if (settings & construct_multigrid_hierarchy)
303 const unsigned int n_my_cells =
304 std::count_if(this->
begin(), this->
end(), [](
const auto &i) {
305 return (i.is_locally_owned_on_level());
309 const unsigned int total_cells =
311 Assert(total_cells == this->n_cells(),
312 ExcMessage(
"Not all cells are assigned to a processor."));
357 spacedim>::communicate_coarsening_and_refinement_flags()
371 using int_type = std::underlying_type_t<
373 static_assert(
sizeof(int_type) ==
sizeof(std::uint8_t),
374 "Internal type mismatch.");
376 std::vector<int_type> refinement_configurations(this->n_active_cells() *
379 for (
const auto &cell : this->active_cell_iterators())
380 if (cell->is_locally_owned())
382 refinement_configurations[cell->active_cell_index() * 2 + 0] =
383 static_cast<int_type
>(cell->refine_flag_set());
384 refinement_configurations[cell->active_cell_index() * 2 + 1] =
385 static_cast<int_type
>(cell->coarsen_flag_set() ? 1 : 0);
389 this->get_mpi_communicator(),
390 refinement_configurations);
392 for (
const auto &cell : this->active_cell_iterators())
394 cell->clear_refine_flag();
395 cell->clear_coarsen_flag();
398 (refinement_configurations[cell->active_cell_index() * 2 + 0] >
402 refinement_configurations[cell->active_cell_index() * 2 +
406 "Refinement/coarsening flags of cells are not consistent in parallel!"));
408 if (refinement_configurations[cell->active_cell_index() * 2 + 0] !=
411 refinement_configurations[cell->active_cell_index() * 2 + 0]));
413 if (refinement_configurations[cell->active_cell_index() * 2 + 1] >
415 cell->set_coarsen_flag();
const ObserverPointer< const ::parallel::shared::Triangulation< dim, spacedim > > shared_tria
TemporarilyRestoreSubdomainIds(const Triangulation< dim, spacedim > &tria)