]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added asserts to Manifold::get_normals_at_vertices 2558/head
authorLuca Heltai <luca.heltai@sissa.it>
Wed, 27 Apr 2016 07:20:38 +0000 (09:20 +0200)
committerLuca Heltai <luca.heltai@sissa.it>
Wed, 27 Apr 2016 07:20:44 +0000 (09:20 +0200)
source/grid/manifold.cc

index 07ff568521122682292e8bf3919e7dc4d9eed6b3..912b7516f8bb06c8e9be13fec5a112be2a1139f8 100644 (file)
@@ -185,8 +185,13 @@ get_normals_at_vertices (const Triangulation<2, 2>::face_iterator &face,
   n[0] = cross_product_2d(get_tangent_vector(face->vertex(0), face->vertex(1)));
   n[1] = -cross_product_2d(get_tangent_vector(face->vertex(1), face->vertex(0)));
 
-  n[0] /= n[0].norm();
-  n[1] /= n[1].norm();
+  for (unsigned int i=0; i<2; ++i)
+    {
+      Assert(n[i].norm() != 0, ExcInternalError("Something went wrong. The "
+                                                "computed normals have "
+                                                "zero length."));
+      n[i] /= n[i].norm();
+    }
 }
 
 
@@ -213,7 +218,12 @@ get_normals_at_vertices (const Triangulation<3, 3>::face_iterator &face,
           get_tangent_vector(face->vertex(3), face->vertex(1)));
 
   for (unsigned int i=0; i<4; ++i)
-    n[i] /=n[i].norm();
+    {
+      Assert(n[i].norm() != 0, ExcInternalError("Something went wrong. The "
+                                                "computed normals have "
+                                                "zero length."));
+      n[i] /=n[i].norm();
+    }
 }
 
 

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.