From f929fa1787ec7669107b348f6e4626f5b0071693 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Thu, 9 May 2013 07:28:33 +0000
Subject: [PATCH] check for zero volume elements

---
 Geo/GModel.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp
index a660b7b5d3..e32ee9f325 100644
--- a/Geo/GModel.cpp
+++ b/Geo/GModel.cpp
@@ -1462,8 +1462,11 @@ void GModel::checkMeshCoherence(double tolerance)
     for(unsigned int i = 0; i < entities.size(); i++)
       for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++){
         MElement *e = entities[i]->getMeshElement(j);
-        if(e->getVolumeSign() < 0)
-          Msg::Warning("Element %d has egative volume", e->getNum());
+        double vol = e->getVolume();
+        if(vol < 0)
+          Msg::Warning("Element %d has negative volume", e->getNum());
+        else if(vol < 1e-12)
+          Msg::Warning("Element %d has zero volume", e->getNum());
         SPoint3 p = e->barycenter();
         vertices.push_back(new MVertex(p.x(), p.y(), p.z()));
       }
-- 
GitLab