#include <deal.II/base/memory_consumption.h>
+#include <deal.II/distributed/shared_tria.h>
#include <deal.II/distributed/tria.h>
#include <deal.II/dofs/dof_accessor.h>
clear();
+ // We need to access dof indices on the entire domain. For
+ // shared::Triangulations, ownership of cells might change. If they allow the
+ // use of artificial cells, we need to restore the true cell owners
+ // temporarily. We save the current set of subdomain ids, set subdomain ids to
+ // the "true" owner of each cell, and later restore these flags.
+ std::vector<types::subdomain_id> saved_subdomain_ids;
+ const parallel::shared::Triangulation<dim, DoFHandlerType::space_dimension>
+ *shared_tria =
+ (dynamic_cast<const parallel::shared::
+ Triangulation<dim, DoFHandlerType::space_dimension> *>(
+ &dof_handler->get_triangulation()));
+ if (shared_tria != nullptr && shared_tria->with_artificial_cells())
+ {
+ saved_subdomain_ids.resize(shared_tria->n_active_cells());
+
+ const std::vector<types::subdomain_id> &true_subdomain_ids =
+ shared_tria->get_true_subdomain_ids_of_cells();
+
+ for (const auto &cell : shared_tria->active_cell_iterators())
+ {
+ const unsigned int index = cell->active_cell_index();
+ saved_subdomain_ids[index] = cell->subdomain_id();
+ cell->set_subdomain_id(true_subdomain_ids[index]);
+ }
+ }
+
const unsigned int n_active_cells =
dof_handler->get_triangulation().n_active_cells();
n_dofs_old = dof_handler->n_dofs();
Pointerstruct(&indices_on_cell[i], cell->active_fe_index());
}
prepared_for = pure_refinement;
+
+ // Undo the subdomain modification.
+ if (shared_tria != nullptr && shared_tria->with_artificial_cells())
+ for (const auto &cell : shared_tria->active_cell_iterators())
+ cell->set_subdomain_id(saved_subdomain_ids[cell->active_cell_index()]);
}
ExcMessage("Vectors cannot be used as input and output"
" at the same time!"));
+ // We need to access dof indices on the entire domain. For
+ // shared::Triangulations, ownership of cells might change. If they allow the
+ // use of artificial cells, we need to restore the true cell owners
+ // temporarily. We save the current set of subdomain ids, set subdomain ids to
+ // the "true" owner of each cell, and later restore these flags.
+ std::vector<types::subdomain_id> saved_subdomain_ids;
+ const parallel::shared::Triangulation<dim, DoFHandlerType::space_dimension>
+ *shared_tria =
+ (dynamic_cast<const parallel::shared::
+ Triangulation<dim, DoFHandlerType::space_dimension> *>(
+ &dof_handler->get_triangulation()));
+ if (shared_tria != nullptr && shared_tria->with_artificial_cells())
+ {
+ saved_subdomain_ids.resize(shared_tria->n_active_cells());
+
+ const std::vector<types::subdomain_id> &true_subdomain_ids =
+ shared_tria->get_true_subdomain_ids_of_cells();
+
+ for (const auto &cell : shared_tria->active_cell_iterators())
+ {
+ const unsigned int index = cell->active_cell_index();
+ saved_subdomain_ids[index] = cell->subdomain_id();
+ cell->set_subdomain_id(true_subdomain_ids[index]);
+ }
+ }
+
Vector<typename VectorType::value_type> local_values(0);
typename std::map<std::pair<unsigned int, unsigned int>,
this_fe_index);
}
}
+
+ // Undo the subdomain modification.
+ if (shared_tria != nullptr && shared_tria->with_artificial_cells())
+ for (const auto &cell : shared_tria->active_cell_iterators())
+ cell->set_subdomain_id(saved_subdomain_ids[cell->active_cell_index()]);
}
}
#endif
+ // We need to access dof indices on the entire domain. For
+ // shared::Triangulations, ownership of cells might change. If they allow the
+ // use of artificial cells, we need to restore the true cell owners
+ // temporarily. We save the current set of subdomain ids, set subdomain ids to
+ // the "true" owner of each cell, and later restore these flags.
+ std::vector<types::subdomain_id> saved_subdomain_ids;
+ const parallel::shared::Triangulation<dim, DoFHandlerType::space_dimension>
+ *shared_tria =
+ (dynamic_cast<const parallel::shared::
+ Triangulation<dim, DoFHandlerType::space_dimension> *>(
+ &dof_handler->get_triangulation()));
+ if (shared_tria != nullptr && shared_tria->with_artificial_cells())
+ {
+ saved_subdomain_ids.resize(shared_tria->n_active_cells());
+
+ const std::vector<types::subdomain_id> &true_subdomain_ids =
+ shared_tria->get_true_subdomain_ids_of_cells();
+
+ for (const auto &cell : shared_tria->active_cell_iterators())
+ {
+ const unsigned int index = cell->active_cell_index();
+ saved_subdomain_ids[index] = cell->subdomain_id();
+ cell->set_subdomain_id(true_subdomain_ids[index]);
+ }
+ }
+
// first count the number
// of cells that will be coarsened
// and that'll stay or be refined
Assert(n_cf == n_coarsen_fathers, ExcInternalError());
prepared_for = coarsening_and_refinement;
+
+ // Undo the subdomain modification.
+ if (shared_tria != nullptr && shared_tria->with_artificial_cells())
+ for (const auto &cell : shared_tria->active_cell_iterators())
+ cell->set_subdomain_id(saved_subdomain_ids[cell->active_cell_index()]);
}
" at the same time!"));
#endif
+ // We need to access dof indices on the entire domain. For
+ // shared::Triangulations, ownership of cells might change. If they allow the
+ // use of artificial cells, we need to restore the true cell owners
+ // temporarily. We save the current set of subdomain ids, set subdomain ids to
+ // the "true" owner of each cell, and later restore these flags.
+ std::vector<types::subdomain_id> saved_subdomain_ids;
+ const parallel::shared::Triangulation<dim, DoFHandlerType::space_dimension>
+ *shared_tria =
+ (dynamic_cast<const parallel::shared::
+ Triangulation<dim, DoFHandlerType::space_dimension> *>(
+ &dof_handler->get_triangulation()));
+ if (shared_tria != nullptr && shared_tria->with_artificial_cells())
+ {
+ saved_subdomain_ids.resize(shared_tria->n_active_cells());
+
+ const std::vector<types::subdomain_id> &true_subdomain_ids =
+ shared_tria->get_true_subdomain_ids_of_cells();
+
+ for (const auto &cell : shared_tria->active_cell_iterators())
+ {
+ const unsigned int index = cell->active_cell_index();
+ saved_subdomain_ids[index] = cell->subdomain_id();
+ cell->set_subdomain_id(true_subdomain_ids[index]);
+ }
+ }
+
Vector<typename VectorType::value_type> local_values;
std::vector<types::global_dof_index> dofs;
Assert(false, ExcInternalError());
}
}
+
+ // Undo the subdomain modification.
+ if (shared_tria != nullptr && shared_tria->with_artificial_cells())
+ for (const auto &cell : shared_tria->active_cell_iterators())
+ cell->set_subdomain_id(saved_subdomain_ids[cell->active_cell_index()]);
}