Skip to content

Commit

Permalink
Move p:d:T::has_hanging_nodes() to DistributedTriangulationBase
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrum committed Mar 6, 2022
1 parent baf78cb commit bab3b0f
Show file tree
Hide file tree
Showing 33 changed files with 826 additions and 63 deletions.
8 changes: 0 additions & 8 deletions include/deal.II/distributed/fully_distributed_tria.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,6 @@ namespace parallel
virtual bool
prepare_coarsening_and_refinement() override;

/**
* Return true if the triangulation has hanging nodes.
*
* @note Not implemented yet.
*/
virtual bool
has_hanging_nodes() const override;

/**
* Return the local memory consumption in bytes.
*/
Expand Down
19 changes: 0 additions & 19 deletions include/deal.II/distributed/tria.h
Original file line number Diff line number Diff line change
Expand Up @@ -567,25 +567,6 @@ namespace parallel
void
repartition();


/**
* Return true if the triangulation has hanging nodes.
*
* In the context of parallel distributed triangulations, every
* processor stores only that part of the triangulation it locally owns.
* However, it also stores the entire coarse mesh, and to guarantee the
* 2:1 relationship between cells, this may mean that there are hanging
* nodes between cells that are not locally owned or ghost cells (i.e.,
* between ghost cells and artificial cells, or between artificial and
* artificial cells; see
* @ref GlossArtificialCell "the glossary").
* One is not typically interested in this case, so the function returns
* whether there are hanging nodes between any two cells of the "global"
* mesh, i.e., the union of locally owned cells on all processors.
*/
virtual bool
has_hanging_nodes() const override;

/**
* Return the local memory consumption in bytes.
*/
Expand Down
18 changes: 18 additions & 0 deletions include/deal.II/distributed/tria_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,24 @@ namespace parallel
using CellStatus =
typename dealii::Triangulation<dim, spacedim>::CellStatus;

/**
* Return true if the triangulation has hanging nodes.
*
* In the context of parallel distributed triangulations, every
* processor stores only that part of the triangulation it owns locally.
* However, it also stores coarser levels, and to guarantee the
* 2:1 relationship between cells, this may mean that there are hanging
* nodes between cells that are not locally owned or ghost cells (i.e.,
* between ghost cells and artificial cells, or between artificial and
* artificial cells; see
* @ref GlossArtificialCell "the glossary").
* One is not typically interested in this case, so the function returns
* whether there are hanging nodes between any two cells of the "global"
* mesh, i.e., the union of locally owned cells on all processors.
*/
virtual bool
has_hanging_nodes() const override;

/**
* Save the triangulation into the given file. This file needs to be
* reachable from all nodes in the computation on a shared network file
Expand Down
10 changes: 0 additions & 10 deletions source/distributed/fully_distributed_tria.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,6 @@ namespace parallel



template <int dim, int spacedim>
bool
Triangulation<dim, spacedim>::has_hanging_nodes() const
{
Assert(false, ExcNotImplemented());
return false;
}



template <int dim, int spacedim>
std::size_t
Triangulation<dim, spacedim>::memory_consumption() const
Expand Down
26 changes: 0 additions & 26 deletions source/distributed/tria.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1961,32 +1961,6 @@ namespace parallel
}


template <int dim, int spacedim>
bool
Triangulation<dim, spacedim>::has_hanging_nodes() const
{
if (this->n_global_levels() <= 1)
return false; // can not have hanging nodes without refined cells

// if there are any active cells with level less than n_global_levels()-1,
// then there is obviously also one with level n_global_levels()-1, and
// consequently there must be a hanging node somewhere.
//
// The problem is that we cannot just ask for the first active cell, but
// instead need to filter over locally owned cells.
const bool have_coarser_cell =
std::any_of(this->begin_active(this->n_global_levels() - 2),
this->end_active(this->n_global_levels() - 2),
[](const CellAccessor<dim, spacedim> &cell) {
return cell.is_locally_owned();
});

// return true if at least one process has a coarser cell
return 0 < Utilities::MPI::max(have_coarser_cell ? 1 : 0,
this->mpi_communicator);
}



template <int dim, int spacedim>
void
Expand Down
34 changes: 34 additions & 0 deletions source/distributed/tria_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ namespace parallel
}



template <int dim, int spacedim>
types::subdomain_id
TriangulationBase<dim, spacedim>::locally_owned_subdomain() const
Expand Down Expand Up @@ -638,6 +639,8 @@ namespace parallel
return number_cache.active_cell_index_partitioner;
}



template <int dim, int spacedim>
const std::weak_ptr<const Utilities::MPI::Partitioner>
TriangulationBase<dim, spacedim>::global_level_cell_index_partitioner(
Expand Down Expand Up @@ -724,6 +727,34 @@ namespace parallel
}



template <int dim, int spacedim>
bool
DistributedTriangulationBase<dim, spacedim>::has_hanging_nodes() const
{
if (this->n_global_levels() <= 1)
return false; // can not have hanging nodes without refined cells

// if there are any active cells with level less than n_global_levels()-1,
// then there is obviously also one with level n_global_levels()-1, and
// consequently there must be a hanging node somewhere.
//
// The problem is that we cannot just ask for the first active cell, but
// instead need to filter over locally owned cells.
const bool have_coarser_cell =
std::any_of(this->begin_active(this->n_global_levels() - 2),
this->end_active(this->n_global_levels() - 2),
[](const CellAccessor<dim, spacedim> &cell) {
return cell.is_locally_owned();
});

// return true if at least one process has a coarser cell
return Utilities::MPI::max(have_coarser_cell ? 1 : 0,
this->mpi_communicator) != 0;
}



template <int dim, int spacedim>
void
DistributedTriangulationBase<dim, spacedim>::load_attached_data(
Expand Down Expand Up @@ -759,6 +790,8 @@ namespace parallel
}
}



template <int dim, int spacedim>
unsigned int
DistributedTriangulationBase<dim, spacedim>::register_data_attach(
Expand Down Expand Up @@ -788,6 +821,7 @@ namespace parallel
}



template <int dim, int spacedim>
void
DistributedTriangulationBase<dim, spacedim>::notify_ready_to_unpack(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
DEAL:0:2d::n_levels: 7
DEAL:0:2d::n_cells: 5461
DEAL:0:2d::n_active_cells: 4096
DEAL:0:2d::has_hanging_nodes: false
DEAL:0:2d::
DEAL:0:2d::n_dofs: 16641
DEAL:0:2d::n_locally_owned_dofs: 16641
DEAL:0:2d::has_hanging_nodes: false
DEAL:0:2d::
DEAL:0:3d::n_levels: 5
DEAL:0:3d::n_cells: 4681
DEAL:0:3d::n_active_cells: 4096
DEAL:0:3d::has_hanging_nodes: false
DEAL:0:3d::
DEAL:0:3d::n_dofs: 35937
DEAL:0:3d::n_locally_owned_dofs: 35937
DEAL:0:3d::has_hanging_nodes: false
DEAL:0:3d::
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,98 @@
DEAL:0:2d::n_levels: 7
DEAL:0:2d::n_cells: 1373
DEAL:0:2d::n_active_cells: 1030
DEAL:0:2d::has_hanging_nodes: false
DEAL:0:2d::
DEAL:0:2d::n_dofs: 16641
DEAL:0:2d::n_locally_owned_dofs: 3409
DEAL:0:2d::has_hanging_nodes: false
DEAL:0:2d::
DEAL:0:3d::n_levels: 5
DEAL:0:3d::n_cells: 1793
DEAL:0:3d::n_active_cells: 1569
DEAL:0:3d::has_hanging_nodes: false
DEAL:0:3d::
DEAL:0:3d::n_dofs: 35937
DEAL:0:3d::n_locally_owned_dofs: 7809
DEAL:0:3d::has_hanging_nodes: false
DEAL:0:3d::

DEAL:1:2d::n_levels: 7
DEAL:1:2d::n_cells: 1557
DEAL:1:2d::n_active_cells: 1168
DEAL:1:2d::has_hanging_nodes: false
DEAL:1:2d::
DEAL:1:2d::n_dofs: 16641
DEAL:1:2d::n_locally_owned_dofs: 3344
DEAL:1:2d::has_hanging_nodes: false
DEAL:1:2d::
DEAL:1:3d::n_levels: 5
DEAL:1:3d::n_cells: 2265
DEAL:1:3d::n_active_cells: 1982
DEAL:1:3d::has_hanging_nodes: false
DEAL:1:3d::
DEAL:1:3d::n_dofs: 35937
DEAL:1:3d::n_locally_owned_dofs: 7312
DEAL:1:3d::has_hanging_nodes: false
DEAL:1:3d::


DEAL:2:2d::n_levels: 7
DEAL:2:2d::n_cells: 1717
DEAL:2:2d::n_active_cells: 1288
DEAL:2:2d::has_hanging_nodes: false
DEAL:2:2d::
DEAL:2:2d::n_dofs: 16641
DEAL:2:2d::n_locally_owned_dofs: 3296
DEAL:2:2d::has_hanging_nodes: false
DEAL:2:2d::
DEAL:2:3d::n_levels: 5
DEAL:2:3d::n_cells: 2297
DEAL:2:3d::n_active_cells: 2010
DEAL:2:3d::has_hanging_nodes: false
DEAL:2:3d::
DEAL:2:3d::n_dofs: 35937
DEAL:2:3d::n_locally_owned_dofs: 7152
DEAL:2:3d::has_hanging_nodes: false
DEAL:2:3d::


DEAL:3:2d::n_levels: 7
DEAL:3:2d::n_cells: 1557
DEAL:3:2d::n_active_cells: 1168
DEAL:3:2d::has_hanging_nodes: false
DEAL:3:2d::
DEAL:3:2d::n_dofs: 16641
DEAL:3:2d::n_locally_owned_dofs: 3312
DEAL:3:2d::has_hanging_nodes: false
DEAL:3:2d::
DEAL:3:3d::n_levels: 5
DEAL:3:3d::n_cells: 2265
DEAL:3:3d::n_active_cells: 1982
DEAL:3:3d::has_hanging_nodes: false
DEAL:3:3d::
DEAL:3:3d::n_dofs: 35937
DEAL:3:3d::n_locally_owned_dofs: 7008
DEAL:3:3d::has_hanging_nodes: false
DEAL:3:3d::


DEAL:4:2d::n_levels: 7
DEAL:4:2d::n_cells: 1373
DEAL:4:2d::n_active_cells: 1030
DEAL:4:2d::has_hanging_nodes: false
DEAL:4:2d::
DEAL:4:2d::n_dofs: 16641
DEAL:4:2d::n_locally_owned_dofs: 3280
DEAL:4:2d::has_hanging_nodes: false
DEAL:4:2d::
DEAL:4:3d::n_levels: 5
DEAL:4:3d::n_cells: 1793
DEAL:4:3d::n_active_cells: 1569
DEAL:4:3d::has_hanging_nodes: false
DEAL:4:3d::
DEAL:4:3d::n_dofs: 35937
DEAL:4:3d::n_locally_owned_dofs: 6656
DEAL:4:3d::has_hanging_nodes: false
DEAL:4:3d::

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
DEAL:0:2d::n_levels: 4
DEAL:0:2d::n_cells: 2125
DEAL:0:2d::n_active_cells: 1600
DEAL:0:2d::has_hanging_nodes: false
DEAL:0:2d::n_cells on level=0: 25
DEAL:0:2d::n_cells on level=1: 100
DEAL:0:2d::n_cells on level=2: 400
Expand All @@ -13,6 +14,7 @@ DEAL:0:2d::n_active_cells on level=3: 1600
DEAL:0:2d::
DEAL:0:2d::n_dofs: 6561
DEAL:0:2d::n_locally_owned_dofs: 6561
DEAL:0:2d::has_hanging_nodes: false
DEAL:0:2d::n_dofs on level=0: 121
DEAL:0:2d::n_dofs on level=1: 441
DEAL:0:2d::n_dofs on level=2: 1681
Expand All @@ -25,6 +27,7 @@ DEAL:0:2d::
DEAL:0:3d::n_levels: 4
DEAL:0:3d::n_cells: 37440
DEAL:0:3d::n_active_cells: 32768
DEAL:0:3d::has_hanging_nodes: false
DEAL:0:3d::n_cells on level=0: 64
DEAL:0:3d::n_cells on level=1: 512
DEAL:0:3d::n_cells on level=2: 4096
Expand All @@ -36,6 +39,7 @@ DEAL:0:3d::n_active_cells on level=3: 32768
DEAL:0:3d::
DEAL:0:3d::n_dofs: 274625
DEAL:0:3d::n_locally_owned_dofs: 274625
DEAL:0:3d::has_hanging_nodes: false
DEAL:0:3d::n_dofs on level=0: 729
DEAL:0:3d::n_dofs on level=1: 4913
DEAL:0:3d::n_dofs on level=2: 35937
Expand Down

0 comments on commit bab3b0f

Please sign in to comment.