]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added optional mapping to minimal/maximal grid diameter.
authorLuca Heltai <luca.heltai@sissa.it>
Mon, 23 Apr 2018 15:01:54 +0000 (17:01 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Mon, 23 Apr 2018 15:01:54 +0000 (17:01 +0200)
include/deal.II/grid/grid_tools.h
source/grid/grid_tools.cc
source/grid/grid_tools.inst.in

index 7c57c3d4a526c71fb0bac2d12ef5e4a20c69ee45..1ce036b808b706e28d44bfad9ab0c2d463a64f84 100644 (file)
@@ -158,14 +158,16 @@ namespace GridTools
    */
   template <int dim, int spacedim>
   double
-  minimal_cell_diameter (const Triangulation<dim, spacedim> &triangulation);
+  minimal_cell_diameter (const Triangulation<dim, spacedim> &triangulation,
+                         const Mapping<dim,spacedim> &mapping = (StaticMappingQ1<dim,spacedim>::mapping));
 
   /**
    * Return the diameter of the largest active cell of a triangulation.
    */
   template <int dim, int spacedim>
   double
-  maximal_cell_diameter (const Triangulation<dim, spacedim> &triangulation);
+  maximal_cell_diameter (const Triangulation<dim, spacedim> &triangulation,
+                         const Mapping<dim,spacedim> &mapping = (StaticMappingQ1<dim,spacedim>::mapping));
 
   /**
    * Given a list of vertices (typically obtained using
index 0d6b768e272bee56080e6a3d54bf10d2c3737b35..ed6e97e30ac1698ccea5755f69691f05c542b26a 100644 (file)
@@ -2770,15 +2770,43 @@ next_cell:
 
 
 
+  namespace
+  {
+    template <int dim, int spacedim>
+    double diameter(const typename Triangulation<dim, spacedim>::cell_iterator &cell,
+                    const Mapping<dim,spacedim> &mapping)
+    {
+      auto vertices = mapping.get_vertices(cell);
+      switch (dim)
+        {
+        case 1:
+          return (vertices[1]-vertices[0]).norm();
+        case 2:
+          return std::max((vertices[3]-vertices[0]).norm(),
+                          (vertices[2]-vertices[1]).norm());
+        case 3:
+          return std::max( std::max((vertices[7]-vertices[0]).norm(),
+                                    (vertices[6]-vertices[1]).norm()),
+                           std::max((vertices[2]-vertices[5]).norm(),
+                                    (vertices[3]-vertices[4]).norm()) );
+        default:
+          Assert (false, ExcNotImplemented());
+          return -1e10;
+        }
+    }
+  }
+
+
   template <int dim, int spacedim>
   double
-  minimal_cell_diameter (const Triangulation<dim, spacedim> &triangulation)
+  minimal_cell_diameter (const Triangulation<dim, spacedim> &triangulation,
+                         const Mapping<dim,spacedim> &mapping)
   {
     double min_diameter = std::numeric_limits<double>::max();
     for (const auto &cell: triangulation.active_cell_iterators())
       if (!cell->is_artificial())
         min_diameter = std::min (min_diameter,
-                                 cell->diameter());
+                                 diameter<dim,spacedim>(cell, mapping));
 
     double global_min_diameter = 0;
 
@@ -2797,13 +2825,14 @@ next_cell:
 
   template <int dim, int spacedim>
   double
-  maximal_cell_diameter (const Triangulation<dim, spacedim> &triangulation)
+  maximal_cell_diameter (const Triangulation<dim, spacedim> &triangulation,
+                         const Mapping<dim, spacedim> &mapping)
   {
     double max_diameter = 0.;
     for (const auto &cell: triangulation.active_cell_iterators())
       if (!cell->is_artificial())
         max_diameter = std::max (max_diameter,
-                                 cell->diameter());
+                                 diameter(cell, mapping));
 
     double global_max_diameter = 0;
 
index b84264dcb99b43e9c2e943736f576dfa58615446..3a33c28abc6d56f9322d5516d40bd9d1f1289eb9 100644 (file)
@@ -245,11 +245,13 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension :  SPACE_DIMENSIONS
 
     template
     double
-    minimal_cell_diameter (const Triangulation<deal_II_dimension, deal_II_space_dimension> &triangulation);
+    minimal_cell_diameter (const Triangulation<deal_II_dimension, deal_II_space_dimension> &triangulation,
+                           const Mapping<deal_II_dimension, deal_II_space_dimension> &);
 
     template
     double
-    maximal_cell_diameter (const Triangulation<deal_II_dimension, deal_II_space_dimension> &triangulation);
+    maximal_cell_diameter (const Triangulation<deal_II_dimension, deal_II_space_dimension> &triangulation,
+                           const Mapping<deal_II_dimension, deal_II_space_dimension> &);
 
     template
     std::map<unsigned int,Point<deal_II_space_dimension> >

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.