]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added flat to control overwriting of non flat manifold ids.
authorLuca Heltai <luca.heltai@sissa.it>
Thu, 21 Mar 2019 23:27:14 +0000 (00:27 +0100)
committerLuca Heltai <luca.heltai@sissa.it>
Sat, 23 Mar 2019 22:24:17 +0000 (23:24 +0100)
include/deal.II/grid/grid_tools.h
source/grid/grid_tools.cc
source/grid/grid_tools.inst.in

index 5a341b9e9f2a517433eb6d6544783cc6aee83b49..13a53614955ee43d5e9c43b9685ebfec6714e2c7 100644 (file)
@@ -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 <int dim, int spacedim>
@@ -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);
   /*@}*/
 
   /**
index 219159c1facd5f3a64e6255f913b2f2e6597e8dc..1b5939f12c659b8815322443c702837ac5d41dcc 100644 (file)
@@ -3762,7 +3762,8 @@ namespace GridTools
   assign_co_dimensional_manifold_indicators(
     Triangulation<dim, spacedim> &            tria,
     const std::function<types::manifold_id(
-      const std::set<types::manifold_id> &)> &disambiguation_function)
+      const std::set<types::manifold_id> &)> &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<dim>::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);
index 4d04f4141da7a93861cdc3c85970800d902f9426..0c64e7ff346a510a4bb8ddf7ea82ae489bee15b4 100644 (file)
@@ -379,7 +379,8 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
       assign_co_dimensional_manifold_indicators(
         Triangulation<deal_II_dimension, deal_II_space_dimension> &,
         const std::function<
-          types::manifold_id(const std::set<types::manifold_id> &)> &);
+          types::manifold_id(const std::set<types::manifold_id> &)> &,
+        bool);
 
       template void
       regularize_corner_cells(

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.