From f5ef9d3ee60ec09d1a57a9777af9d989748788ee Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 17 Jan 2022 14:39:32 +0300 Subject: [PATCH] bos #26461 [EDF] (2021) MedCoupling: debug tetra/tetra 3d intersector algorithm --- src/INTERP_KERNEL/TransformedTriangle.hxx | 1 + .../TransformedTriangleInline.hxx | 2 +- .../MEDCouplingRemapperTest.py | 38 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/INTERP_KERNEL/TransformedTriangle.hxx b/src/INTERP_KERNEL/TransformedTriangle.hxx index 2d3cb8c82..84b8f3814 100644 --- a/src/INTERP_KERNEL/TransformedTriangle.hxx +++ b/src/INTERP_KERNEL/TransformedTriangle.hxx @@ -21,6 +21,7 @@ #define __TRANSFORMED_TRIANGLE_HXX__ #include "INTERPKERNELDefines.hxx" +#include "VectorUtils.hxx" #include diff --git a/src/INTERP_KERNEL/TransformedTriangleInline.hxx b/src/INTERP_KERNEL/TransformedTriangleInline.hxx index 5f3532781..eb5a66c60 100644 --- a/src/INTERP_KERNEL/TransformedTriangleInline.hxx +++ b/src/INTERP_KERNEL/TransformedTriangleInline.hxx @@ -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 diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py index d88881a24..144118b08 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py @@ -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)): -- 2.39.2