Skip to content

Commit

Permalink
Move exchange_refinement_flags out of p4est ifdef.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcfehling committed Apr 12, 2024
1 parent b4f74bd commit ce6c421
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 57 deletions.
10 changes: 6 additions & 4 deletions include/deal.II/distributed/tria.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@

DEAL_II_NAMESPACE_OPEN

#ifdef DEAL_II_WITH_P4EST

// Forward declarations
# ifndef DOXYGEN
#ifndef DOXYGEN

namespace FETools
{
Expand Down Expand Up @@ -94,7 +92,11 @@ namespace internal
} // namespace distributed
} // namespace parallel
} // namespace internal
# endif
#endif



#ifdef DEAL_II_WITH_P4EST

namespace parallel
{
Expand Down
106 changes: 53 additions & 53 deletions source/distributed/tria.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,59 @@
DEAL_II_NAMESPACE_OPEN


namespace internal
{
namespace parallel
{
namespace distributed
{
namespace TriangulationImplementation
{
/**
* Communicate refinement flags on ghost cells from the owner of the
* cell.
*
* This is necessary to get consistent refinement, as mesh smoothing
* would undo some of the requested coarsening/refinement.
*/
template <int dim, int spacedim>
void
exchange_refinement_flags(
dealii::parallel::distributed::Triangulation<dim, spacedim> &tria)
{
auto pack =
[](const typename Triangulation<dim, spacedim>::active_cell_iterator
&cell) -> std::uint8_t {
if (cell->refine_flag_set())
return 1;
if (cell->coarsen_flag_set())
return 2;
return 0;
};

auto unpack =
[](const typename Triangulation<dim, spacedim>::active_cell_iterator
&cell,
const std::uint8_t &flag) -> void {
cell->clear_coarsen_flag();
cell->clear_refine_flag();
if (flag == 1)
cell->set_refine_flag();
else if (flag == 2)
cell->set_coarsen_flag();
};

GridTools::exchange_cell_data_to_ghosts<std::uint8_t>(tria,
pack,
unpack);
}
} // namespace TriangulationImplementation
} // namespace distributed
} // namespace parallel
} // namespace internal



#ifdef DEAL_II_WITH_P4EST

namespace
Expand Down Expand Up @@ -1685,59 +1738,6 @@ namespace



namespace internal
{
namespace parallel
{
namespace distributed
{
namespace TriangulationImplementation
{
/**
* Communicate refinement flags on ghost cells from the owner of the
* cell.
*
* This is necessary to get consistent refinement, as mesh smoothing
* would undo some of the requested coarsening/refinement.
*/
template <int dim, int spacedim>
void
exchange_refinement_flags(
dealii::parallel::distributed::Triangulation<dim, spacedim> &tria)
{
auto pack =
[](const typename Triangulation<dim, spacedim>::active_cell_iterator
&cell) -> std::uint8_t {
if (cell->refine_flag_set())
return 1;
if (cell->coarsen_flag_set())
return 2;
return 0;
};

auto unpack =
[](const typename Triangulation<dim, spacedim>::active_cell_iterator
&cell,
const std::uint8_t &flag) -> void {
cell->clear_coarsen_flag();
cell->clear_refine_flag();
if (flag == 1)
cell->set_refine_flag();
else if (flag == 2)
cell->set_coarsen_flag();
};

GridTools::exchange_cell_data_to_ghosts<std::uint8_t>(tria,
pack,
unpack);
}
} // namespace TriangulationImplementation
} // namespace distributed
} // namespace parallel
} // namespace internal



namespace parallel
{
namespace distributed
Expand Down

0 comments on commit ce6c421

Please sign in to comment.