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 =
94 this->get_mpi_communicator());
96 max_active_cells == this->n_active_cells(),
98 "A parallel::shared::Triangulation needs to be refined in the same "
99 "way on all processors, but the participating processors don't "
100 "agree on the number of active cells."));
103 auto partition_settings = (partition_zoltan | partition_metis |
104 partition_zorder | partition_custom_signal) &
106 if (partition_settings == partition_auto)
107# ifdef DEAL_II_TRILINOS_WITH_ZOLTAN
108 partition_settings = partition_zoltan;
109# elif defined DEAL_II_WITH_METIS
110 partition_settings = partition_metis;
112 partition_settings = partition_zorder;
115 if (partition_settings == partition_zoltan)
117# ifndef DEAL_II_TRILINOS_WITH_ZOLTAN
120 "Choosing 'partition_zoltan' requires the library "
121 "to be compiled with support for Zoltan! "
122 "Instead, you might use 'partition_auto' to select "
123 "a partitioning algorithm that is supported "
124 "by your current configuration."));
130 else if (partition_settings == partition_metis)
132# ifndef DEAL_II_WITH_METIS
135 "Choosing 'partition_metis' requires the library "
136 "to be compiled with support for METIS! "
137 "Instead, you might use 'partition_auto' to select "
138 "a partitioning algorithm that is supported "
139 "by your current configuration."));
146 else if (partition_settings == partition_zorder)
150 else if (partition_settings == partition_custom_signal)
161 if ((settings & construct_multigrid_hierarchy) &&
162 !(settings & partition_custom_signal))
165 true_subdomain_ids_of_cells.resize(this->n_active_cells());
169 spacedim>::active_cell_iterator
170 cell = this->begin_active(),
173 if (allow_artificial_cells)
184 spacedim>::active_cell_iterator>
185 active_halo_layer_vector =
188 std::set<typename parallel::shared::Triangulation<dim, spacedim>::
189 active_cell_iterator>
190 active_halo_layer(active_halo_layer_vector.begin(),
191 active_halo_layer_vector.end());
193 for (
unsigned int index = 0; cell != endc; cell++, index++)
196 true_subdomain_ids_of_cells[index] = cell->subdomain_id();
198 if (cell->is_locally_owned() ==
false &&
199 active_halo_layer.find(cell) == active_halo_layer.end())
204 if (settings & construct_multigrid_hierarchy)
206 true_level_subdomain_ids_of_cells.resize(this->n_levels());
212 for (
unsigned int lvl = 0; lvl < this->n_levels(); ++lvl)
214 true_level_subdomain_ids_of_cells[lvl].resize(
219 spacedim>::cell_iterator>
220 level_halo_layer_vector =
222 *
this, predicate, lvl);
223 std::set<
typename parallel::shared::
224 Triangulation<dim, spacedim>::cell_iterator>
225 level_halo_layer(level_halo_layer_vector.begin(),
226 level_halo_layer_vector.end());
229 cell_iterator cell = this->begin(lvl),
230 endc = this->end(lvl);
231 for (
unsigned int index = 0; cell != endc; cell++, index++)
235 true_level_subdomain_ids_of_cells[lvl][index] =
236 cell->level_subdomain_id();
245 if (cell->is_active() &&
246 cell->subdomain_id() !=
251 if (cell->has_children())
253 bool keep_cell =
false;
254 for (
unsigned int c = 0;
255 c < GeometryInfo<dim>::max_children_per_cell;
257 if (cell->child(c)->level_subdomain_id() ==
269 if (!cell->is_locally_owned_on_level() &&
270 level_halo_layer.find(cell) != level_halo_layer.
end())
274 cell->set_level_subdomain_id(
283 for (
unsigned int index = 0; cell != endc; cell++, index++)
284 true_subdomain_ids_of_cells[index] = cell->subdomain_id();
290 const unsigned int n_my_cells = std::count_if(
291 this->begin_active(),
294 [](
const auto &i) {
return (i.is_locally_owned()); });
296 const unsigned int total_cells =
298 Assert(total_cells == this->n_active_cells(),
299 ExcMessage(
"Not all cells are assigned to a processor."));
304 if (settings & construct_multigrid_hierarchy)
306 const unsigned int n_my_cells =
307 std::count_if(this->begin(), this->end(), [](
const auto &i) {
308 return (i.is_locally_owned_on_level());
312 const unsigned int total_cells =
314 Assert(total_cells == this->n_cells(),
315 ExcMessage(
"Not all cells are assigned to a processor."));
373 using int_type = std::underlying_type_t<
375 static_assert(
sizeof(int_type) ==
sizeof(std::uint8_t),
376 "Internal type mismatch.");
378 std::vector<int_type> refinement_configurations(this->n_active_cells() *
381 for (
const auto &cell : this->active_cell_iterators())
382 if (cell->is_locally_owned())
384 refinement_configurations[cell->active_cell_index() * 2 + 0] =
385 static_cast<int_type
>(cell->refine_flag_set());
386 refinement_configurations[cell->active_cell_index() * 2 + 1] =
387 static_cast<int_type
>(cell->coarsen_flag_set() ? 1 : 0);
391 this->get_mpi_communicator(),
392 refinement_configurations);
394 for (
const auto &cell : this->active_cell_iterators())
396 cell->clear_refine_flag();
397 cell->clear_coarsen_flag();
400 (refinement_configurations[cell->active_cell_index() * 2 + 0] >
404 refinement_configurations[cell->active_cell_index() * 2 +
408 "Refinement/coarsening flags of cells are not consistent in parallel!"));
410 if (refinement_configurations[cell->active_cell_index() * 2 + 0] !=
413 refinement_configurations[cell->active_cell_index() * 2 + 0]));
415 if (refinement_configurations[cell->active_cell_index() * 2 + 1] >
417 cell->set_coarsen_flag();
423 this->update_number_cache();
const ObserverPointer< const ::parallel::shared::Triangulation< dim, spacedim > > shared_tria
TemporarilyRestoreSubdomainIds(const Triangulation< dim, spacedim > &tria)