]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
bos #26461 [EDF] (2021) MedCoupling: debug tetra/tetra 3d intersector algorithm
authoreap <eap@opencascade.com>
Mon, 17 Jan 2022 11:39:32 +0000 (14:39 +0300)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 20 Jan 2022 14:52:59 +0000 (15:52 +0100)
src/INTERP_KERNEL/TransformedTriangle.hxx
src/INTERP_KERNEL/TransformedTriangleInline.hxx
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py

index 2d3cb8c825dcd5b7a7998da36d5d0d17f53aa9d3..84b8f3814dcfaf7d1cedcf8f0da2cdb7a5fba8c9 100644 (file)
@@ -21,6 +21,7 @@
 #define __TRANSFORMED_TRIANGLE_HXX__
 
 #include "INTERPKERNELDefines.hxx"
+#include "VectorUtils.hxx"
 
 #include <vector>
 
index 5f35327818af093d7793bb634d548046ab52d5f1..eb5a66c604bae42789cb3c4977d956d93c59babe 100644 (file)
@@ -188,7 +188,7 @@ inline bool TransformedTriangle::testEdgeIntersectsTriangle(const TetraEdge edge
 
   //? should equality with zero use epsilon?
   LOG(5, "testEdgeIntersectsTriangle : t1 = " << t1 << " t2 = " << t2 );
-  return (t1*t2 <= 0.0) && (t1 - t2 != 0.0);
+  return (t1*t2 <= 0.0) && !epsilonEqual(t1 - t2, 0.0); // tuleap26461
 }
 
 inline bool TransformedTriangle::testFacetSurroundsSegment(const TriSegment seg, const TetraFacet facet) const
index d88881a243a0ad5b8bca05f4bc2e408ca462cd76..144118b08bee8109b398a76074d527ebe3bf60d2 100644 (file)
@@ -1548,6 +1548,44 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         fldTgt = remap.transferField(fldSrc, -1.0)
         self.assertTrue(fldTgt.getArray().isUniform(50.0, 1e-12))
 
+    def testGrandyBug1(self):
+        """
+        Non regression test relative to test tuleap26461
+        """
+        rem = MEDCouplingRemapper()
+        src_final = MEDCouplingUMesh("src_final",3)
+        src_final.setCoords( DataArrayDouble([0.74763179385813627,2.0528797000000716,0.42830000000000013,0.77426950622837643,2.0528797000000001,0.40000000000000036,0.77426950622837643,2.0528797000000001,0.42830000000000013,0.77426950622830537,2.0262419876297604,0.42830000000000013],4,3) )
+        src_final.allocateCells()
+        src_final.insertNextCell(NORM_TETRA4,[0,3,2,1])
+        trg_final = MEDCouplingUMesh("trg_final",3)
+        trg_final.setCoords( DataArrayDouble([0.81034725000000007,1.9988565499999984,0.40000000000000002,0.75632410000000005,2.0528796999999983,0.40000000000000002,0.75632410000000005,1.9988565499999984,0.41800000000000004,0.81034725000000007,2.0528796999999983,0.41800000000000004],4,3) )
+        trg_final.allocateCells()
+        trg_final.insertNextCell(NORM_TETRA4,[0,2,1,3])
+
+        ref_values = [# ref values coming from geom2medcoupling.py
+            (0.0,   1.671615506097834e-08),
+            (1e-12, 1.671615506712106e-08),
+            (1e-11, 1.671615512239666e-08),
+            (1e-10, 1.6716155675164925e-08),
+            (1e-9,  1.671616120285316e-08),
+            (1e-8,  1.6716216479802182e-08),
+            (1e-7,  1.671676925650806e-08),
+            (1e-6,  1.672014459316238e-08),
+            (1e-5,  1.6805275475457618e-08),
+            (1e-4,  1.7608769838220544e-08),
+            (1e-3,  2.5791583779126835e-08)
+        ]
+
+        for ty,ref_value in ref_values:
+            trg_final2 = trg_final.deepCopy()
+            trg_final2.translate([0,ty,0])
+            rem.setPrecision(1e-12)
+            rem.prepare(src_final,trg_final2,"P0P0")
+            mat_mc = rem.getCrudeMatrix()
+            csr_new = MEDCouplingRemapper.ToCSRMatrix(mat_mc,src_final.getNumberOfCells())
+            delta = abs(csr_new[0,0]-ref_value)/ref_value
+            self.assertTrue(delta < 1e-3)
+
     def checkMatrix(self,mat1,mat2,nbCols,eps):
         self.assertEqual(len(mat1),len(mat2))
         for i in range(len(mat1)):