]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add extra checks based on the cell measure.
authorDavid Wells <wellsd2@rpi.edu>
Sat, 7 May 2016 12:07:27 +0000 (08:07 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Sun, 8 May 2016 13:29:42 +0000 (09:29 -0400)
doc/news/changes.h
source/grid/tria.cc

index 241540efc420bcf22978f8998e5a980c4429831f..7718a459df0cd56573e0aaa3f7042dde36ce322a 100644 (file)
@@ -120,6 +120,14 @@ inconvenience this causes.
 <h3>General</h3>
 
 <ol>
+ <li> Improved: The method Triangulation::create_triangulation will now throw an
+ exception if any cells have negative measure. This check is not run if the
+ triangulation keeps track of distorted cells or if the codimension is not zero.
+ This check was previously only run in 3D.
+ <br>
+ (David Wells, 2016/05/07)
+ </li>
+
  <li> New: Add a collection of classes to manage user's quadrature point data:
  CellDataStorage, TransferableQuadraturePointData and
  parallel::distributed::ContinuousQuadratureDataTransfer.
index 31c8f22f8745c45ae14b6d442162ede964aa5ade..8f6cc849fdaeb62d732f161ad02028be9aa14836 100644 (file)
@@ -1637,6 +1637,23 @@ namespace internal
         triangulation.vertices = v;
         triangulation.vertices_used = std::vector<bool> (v.size(), true);
 
+        // Check that all cells have positive volume. This check is not run in
+        // the codimension one or two cases since cell_measure is not
+        // implemented for those.
+#ifndef _MSC_VER
+        //TODO: The following code does not compile with MSVC. Find a way around it
+        if (dim == spacedim)
+          {
+            for (unsigned int cell_no = 0; cell_no<cells.size(); ++cell_no)
+              {
+                const double cell_measure = GridTools::cell_measure<1, spacedim>
+                  (triangulation.vertices, cells[cell_no].vertices);
+                AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no));
+              }
+          }
+#endif
+
+
         // store the indices of the lines
         // which are adjacent to a given
         // vertex
@@ -1815,6 +1832,22 @@ namespace internal
         triangulation.vertices = v;
         triangulation.vertices_used = std::vector<bool> (v.size(), true);
 
+        // Check that all cells have positive volume. This check is not run in
+        // the codimension one or two cases since cell_measure is not
+        // implemented for those.
+#ifndef _MSC_VER
+        //TODO: The following code does not compile with MSVC. Find a way around it
+        if (dim == spacedim)
+          {
+            for (unsigned int cell_no = 0; cell_no<cells.size(); ++cell_no)
+              {
+                const double cell_measure = GridTools::cell_measure<2, spacedim>
+                  (triangulation.vertices, cells[cell_no].vertices);
+                AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no));
+              }
+          }
+#endif
+
         // make up a list of the needed
         // lines each line is a pair of
         // vertices. The list is kept
@@ -2186,9 +2219,11 @@ namespace internal
 #ifndef _MSC_VER
         //TODO: The following code does not compile with MSVC. Find a way around it
         for (unsigned int cell_no = 0; cell_no<cells.size(); ++cell_no)
-          AssertThrow(dealii::GridTools::cell_measure(triangulation.vertices,
-                                                      cells[cell_no].vertices) >= 0,
-                      ExcGridHasInvalidCell(cell_no));
+          {
+            const double cell_measure = GridTools::cell_measure<3, spacedim>
+              (triangulation.vertices, cells[cell_no].vertices);
+            AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no));
+          }
 #endif
 
         ///////////////////////////////////////

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.