From 902e8bc2aa46b8f62dbd6f9192681b5bb21d60d2 Mon Sep 17 00:00:00 2001 From: Amaury Johnan <amjohnen@gmail.com> Date: Tue, 3 May 2016 13:15:18 +0000 Subject: [PATCH] add getValidity() function to MElement class. Return an int. Just check if this int is positive to know if the element is valid. When orientation is not a problem, checking if the int is true is sufficient. -1 means the element is possibly invalid or just has an incorrect numbering of the nodes. --- Geo/MElement.cpp | 27 ++++++++++++++++++++------- Geo/MElement.h | 6 ++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp index dd28bb8c79..df692d1e28 100644 --- a/Geo/MElement.cpp +++ b/Geo/MElement.cpp @@ -249,15 +249,12 @@ double MElement::specialQuality() #if defined(HAVE_MESH) double minJ, maxJ; jacobianBasedQuality::minMaxJacobianDeterminant(this, minJ, maxJ); - if (minJ < 0 && maxJ >= 0) { // accept -inf as a answer - return minJ/maxJ; - } - if (minJ < 0 && maxJ < 0) { - return -std::numeric_limits<double>::infinity(); - } + if (minJ == 0.) return 0; + if (minJ < 0 && maxJ >= 0) return minJ/maxJ; // accept -inf as an answer + if (minJ < 0 && maxJ < 0) return -std::numeric_limits<double>::infinity(); return jacobianBasedQuality::minAnisotropyMeasure(this); #else - return 0.; + return 0; #endif } @@ -527,6 +524,22 @@ bool MElement::setVolumePositive() return true; } +int MElement::getValidity() +{ +#if defined(HAVE_MESH) + double jmin, jmax; + jacobianBasedQuality::minMaxJacobianDeterminant(this, jmin, jmax); + if (jmin > .0 && jmax > .0) return 1; // valid + if (jmax >= .0) return 0; // invalid + // Here, jmin < 0 and jmax < 0. The element validity is quite indeterminate. + // It can be valid but with a wrong numbering of the nodes, + // or it can be invalid, i.e. with nodes that are incorrectly located. + return -1; +#else + return 0; +#endif +} + std::string MElement::getInfoString() { char tmp[256]; diff --git a/Geo/MElement.h b/Geo/MElement.h index 21ef1d7afe..ae1b55eb44 100644 --- a/Geo/MElement.h +++ b/Geo/MElement.h @@ -255,6 +255,12 @@ class MElement // volume (return false if element has zero volume) virtual bool setVolumePositive(); + // compute the extrema of the Jacobian determinant + // return 1 if the element is valid, + // 0 if the element is invalid, + // -1 if the element is reversed + int getValidity(); + // return an information string for the element virtual std::string getInfoString(); -- GitLab