From 6f189b7be7b30559c8840d4a4c652f4dd2dbaf17 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Fri, 22 Mar 2019 00:27:14 +0100 Subject: [PATCH] Added flat to control overwriting of non flat manifold ids. --- include/deal.II/grid/grid_tools.h | 17 +++++++++++++---- source/grid/grid_tools.cc | 15 ++++++++++----- source/grid/grid_tools.inst.in | 3 ++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index 5a341b9e9f..13a5361495 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -2636,8 +2636,9 @@ namespace GridTools * Propagate manifold indicators associated to the cells of the Triangulation * @p tria to their co-dimension one and two objects. * - * This function sets the @p manifold_id of shared faces and edges to the value - * returnd by the @p disambiguation_function method, called with the set of + * This function sets the @p manifold_id of faces and edges (both on the + * interior and on the boundary) to the value returnd by the + * @p disambiguation_function method, called with the set of * manifold indicators of the cells that share the same face or edge. * * By default, the @p disambiguation_function returns @@ -2648,6 +2649,13 @@ namespace GridTools * dimension one (i.e., when all adjacent cells and faces have the same * manifold indicator). * + * The parameter @p overwrite_only_flat_manifold_ids allows you to specify + * what to do when a face or an edge already has a manifold indicator + * different from numbers::flat_manifold_id. If the flag is @p true, the edge + * or face will maintain its original manifold indicator. + * If it is @p false, then also the manifold indicator of these faces and edges + * is set according to the return value of the @p disambiguation_function. + * * @author Luca Heltai, 2019. */ template @@ -2660,8 +2668,9 @@ namespace GridTools if (manifold_ids.size() == 1) return *manifold_ids.begin(); else - return numbers::invalid_manifold_id; - }); + return numbers::flat_manifold_id; + }, + bool overwrite_only_flat_manifold_ids = true); /*@}*/ /** diff --git a/source/grid/grid_tools.cc b/source/grid/grid_tools.cc index 219159c1fa..1b5939f12c 100644 --- a/source/grid/grid_tools.cc +++ b/source/grid/grid_tools.cc @@ -3762,7 +3762,8 @@ namespace GridTools assign_co_dimensional_manifold_indicators( Triangulation & tria, const std::function &)> &disambiguation_function) + const std::set &)> &disambiguation_function, + bool overwrite_only_flat_manifold_ids) { // Easy case first: if (dim == 1) @@ -3812,16 +3813,20 @@ namespace GridTools { const auto id = cell->line(l)->user_index(); Assert(id != 0, ExcInternalError()); - cell->line(l)->set_manifold_id( - disambiguation_function(manifold_ids[id])); + if (cell->line(l)->manifold_id() == numbers::flat_manifold_id || + overwrite_only_flat_manifold_ids == false) + cell->line(l)->set_manifold_id( + disambiguation_function(manifold_ids[id])); } if (dim > 2) for (unsigned int l = 0; l < GeometryInfo::quads_per_cell; ++l) { const auto id = cell->quad(l)->user_index(); Assert(id != 0, ExcInternalError()); - cell->quad(l)->set_manifold_id( - disambiguation_function(manifold_ids[id])); + if (cell->quad(l)->manifold_id() == numbers::flat_manifold_id || + overwrite_only_flat_manifold_ids == false) + cell->quad(l)->set_manifold_id( + disambiguation_function(manifold_ids[id])); } } tria.load_user_indices(backup); diff --git a/source/grid/grid_tools.inst.in b/source/grid/grid_tools.inst.in index 4d04f4141d..0c64e7ff34 100644 --- a/source/grid/grid_tools.inst.in +++ b/source/grid/grid_tools.inst.in @@ -379,7 +379,8 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) assign_co_dimensional_manifold_indicators( Triangulation &, const std::function< - types::manifold_id(const std::set &)> &); + types::manifold_id(const std::set &)> &, + bool); template void regularize_corner_cells( -- 2.39.5