]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Document the choice of 16 neighbors. 17875/head
authorDavid Wells <drwells@email.unc.edu>
Tue, 19 Nov 2024 17:41:42 +0000 (12:41 -0500)
committerDavid Wells <drwells@email.unc.edu>
Tue, 19 Nov 2024 22:18:43 +0000 (17:18 -0500)
source/grid/grid_tools_topology.cc

index 97b88c422ec962a3aed50c210fbfdafa46c828a0..926cd924ecbbf9dab143144c436d06a39dd0ec3c 100644 (file)
@@ -1855,7 +1855,40 @@ namespace GridTools
     const Triangulation<dim, spacedim> &triangulation,
     DynamicSparsityPattern             &cell_connectivity)
   {
-    // Assume at most 16 neighbors per cell (a structured hex mesh has 8)
+    // The choice of 16 or fewer neighbors here is based on empirical
+    // measurements.
+    //
+    // Vertices in a structured hexahedral mesh have 8 adjacent cells. In a
+    // structured tetrahedral mesh, about 98% of vertices have 16 neighbors or
+    // fewer. Similarly, in an unstructured tetrahedral mesh, if we count the
+    // number of neighbors each vertex has we obtain the following distribution:
+    //
+    // 3, 1
+    // 4, 728
+    // 5, 4084
+    // 6, 7614
+    // 7, 17329
+    // 8, 31145
+    // 9, 46698
+    // 10, 64193
+    // 11, 68269
+    // 12, 63574
+    // 13, 57016
+    // 14, 50476
+    // 15, 41886
+    // 16, 31820
+    // 17, 21269
+    // 18, 12217
+    // 19, 6072
+    // 20, 2527
+    // 21, 825
+    // 22, 262
+    // 23, 61
+    // 24, 12
+    // 26, 1
+    //
+    // so about 86% of vertices have 16 neighbors or fewer. Hence, we picked 16
+    // neighbors here to cover most cases without allocation.
     std::vector<boost::container::small_vector<unsigned int, 16>>
       vertex_to_cell(triangulation.n_vertices());
     for (const auto &cell : triangulation.active_cell_iterators())

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.