--- /dev/null
+New: The new function Triangulation::n_global_coarse_cells() allows to
+query the global number of coarse cells. This function is particularly useful
+for parallel::fullydistributed::Triangulation, since in this case the coarse
+cells might differ on each process.
+<br>
+(Peter Munch, 2021/06/26)
virtual void
update_cell_relations() override;
+ virtual void
+ update_number_cache() override;
+
/**
* store the Settings.
*/
communicate_locally_moved_vertices(
const std::vector<bool> &vertex_locally_moved);
+ virtual types::coarse_cell_id
+ n_global_coarse_cells() const override;
+
protected:
/**
* MPI communicator to be used for the triangulation. We create a unique
* Number of locally owned active cells of this MPI rank.
*/
unsigned int n_locally_owned_active_cells;
+
/**
* The total number of active cells (sum of @p
* n_locally_owned_active_cells).
*/
types::global_cell_index n_global_active_cells;
+
+ /**
+ * Number of global coarse cells.
+ */
+ types::coarse_cell_id number_of_global_coarse_cells;
+
/**
* The global number of levels computed as the maximum number of levels
* taken over all MPI ranks, so <tt>n_levels()<=n_global_levels =
* max(n_levels() on proc i)</tt>.
*/
unsigned int n_global_levels;
+
/**
* A set containing the subdomain_id (MPI rank) of the owners of the
* ghost cells on this processor.
*/
std::set<types::subdomain_id> ghost_owners;
+
/**
* A set containing the MPI ranks of the owners of the level ghost cells
* on this processor (for all levels).
unsigned int
n_active_cells(const unsigned int level) const;
+ /**
+ * Return the total number of coarse cells. If the coarse mesh is replicated
+ * on each process, this simply returns <tt>n_cells(0)</tt>.
+ */
+ virtual types::coarse_cell_id
+ n_global_coarse_cells() const;
+
/**
* Return the total number of used faces, active or not. In 2D, the result
* equals n_lines(), in 3D it equals n_quads(), while in 1D it equals
, mg_level_fine(mg_level_fine)
, communicator(
mesh_fine.get_communicator() /*TODO: fix for different comms*/)
- , cell_id_translator(n_coarse_cells(mesh_fine),
- n_global_levels(mesh_fine))
+ , cell_id_translator(
+ mesh_fine.get_triangulation().n_global_coarse_cells(),
+ mesh_fine.get_triangulation().n_global_levels())
{
- AssertDimension(n_coarse_cells(mesh_fine), n_coarse_cells(mesh_coarse));
- AssertIndexRange(n_global_levels(mesh_coarse),
- n_global_levels(mesh_fine) + 1);
+ AssertDimension(mesh_fine.get_triangulation().n_global_coarse_cells(),
+ mesh_coarse.get_triangulation().n_global_coarse_cells());
+ AssertIndexRange(mesh_coarse.get_triangulation().n_global_levels(),
+ mesh_fine.get_triangulation().n_global_levels() + 1);
}
void
std::map<unsigned int,
std::pair<unsigned int, std::vector<types::global_dof_index>>>
map;
-
- static unsigned int
- n_coarse_cells(const DoFHandler<dim> &mesh)
- {
- types::coarse_cell_id n_coarse_cells = 0;
-
- for (const auto &cell : mesh.get_triangulation().active_cell_iterators())
- if (!cell->is_artificial())
- n_coarse_cells =
- std::max(n_coarse_cells, cell->id().get_coarse_cell_id());
-
- return Utilities::MPI::max(n_coarse_cells, mesh.get_communicator()) + 1;
- }
-
- static unsigned int
- n_global_levels(const DoFHandler<dim> &mesh)
- {
- return mesh.get_triangulation().n_global_levels();
- }
};
template <int dim>
}
+
+ template <int dim, int spacedim>
+ void
+ Triangulation<dim, spacedim>::update_number_cache()
+ {
+ dealii::parallel::TriangulationBase<dim, spacedim>::update_number_cache();
+
+ // additionally update the number of global coarse cells
+ types::coarse_cell_id number_of_global_coarse_cells = 0;
+
+ for (const auto &cell : this->active_cell_iterators())
+ if (!cell->is_artificial())
+ number_of_global_coarse_cells =
+ std::max(number_of_global_coarse_cells,
+ cell->id().get_coarse_cell_id());
+
+ number_of_global_coarse_cells =
+ Utilities::MPI::max(number_of_global_coarse_cells,
+ this->mpi_communicator) +
+ 1;
+
+ this->number_cache.number_of_global_coarse_cells =
+ number_of_global_coarse_cells;
+ }
+
+
} // namespace fullydistributed
} // namespace parallel
{
namespace
{
- template <typename MeshType>
- unsigned int
- compute_n_coarse_cells(const MeshType &mesh)
- {
- types::coarse_cell_id n_coarse_cells = 0;
-
- for (const auto &cell :
- mesh.get_triangulation().cell_iterators_on_level(0))
- n_coarse_cells =
- std::max(n_coarse_cells, cell->id().get_coarse_cell_id());
-
- return Utilities::MPI::max(n_coarse_cells, mesh.get_communicator()) + 1;
- }
-
-
-
- template <typename MeshType>
- unsigned int
- compute_n_global_levels(const MeshType &mesh)
- {
- return mesh.get_triangulation().n_global_levels();
- }
-
-
-
template <int dim, int spacedim>
void
add_indices_recursevly_for_first_child_policy(
template <int dim, int spacedim>
FirstChildPolicy<dim, spacedim>::FirstChildPolicy(
const Triangulation<dim, spacedim> &tria_fine)
- : n_coarse_cells(compute_n_coarse_cells(tria_fine))
- , n_global_levels(compute_n_global_levels(tria_fine))
+ : n_coarse_cells(tria_fine.n_global_coarse_cells())
+ , n_global_levels(tria_fine.n_global_levels())
{
Assert(
tria_fine.all_reference_cells_are_hyper_cube(),
template <int dim, int spacedim>
TriangulationBase<dim, spacedim>::NumberCache::NumberCache()
: n_locally_owned_active_cells(0)
+ , number_of_global_coarse_cells(0)
, n_global_levels(0)
{}
ExcInternalError());
}
+ this->number_cache.number_of_global_coarse_cells = this->n_cells(0);
+
// reset global cell ids
this->reset_global_cell_indices();
}
+ template <int dim, int spacedim>
+ types::coarse_cell_id
+ TriangulationBase<dim, spacedim>::n_global_coarse_cells() const
+ {
+ return number_cache.number_of_global_coarse_cells;
+ }
+
+
+
template <int dim, int spacedim>
DistributedTriangulationBase<dim, spacedim>::DistributedTriangulationBase(
const MPI_Comm &mpi_communicator,
return n_active_cells();
}
-
+template <int dim, int spacedim>
+types::coarse_cell_id
+Triangulation<dim, spacedim>::n_global_coarse_cells() const
+{
+ return n_cells(0);
+}
template <int dim, int spacedim>
unsigned int