From: Anthony Geay Date: Thu, 2 Jan 2020 06:47:35 +0000 (+0100) Subject: OK X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cdc44305e63e41372b1aa112bc6e7549fd9b43f5;p=tools%2Fmedcoupling.git OK --- diff --git a/src/INTERP_KERNEL/CurveIntersector.txx b/src/INTERP_KERNEL/CurveIntersector.txx index 8d3dab651..c7860b292 100644 --- a/src/INTERP_KERNEL/CurveIntersector.txx +++ b/src/INTERP_KERNEL/CurveIntersector.txx @@ -448,6 +448,23 @@ namespace INTERP_KERNEL return ( x0 < x1 ) ? ( x1 - x0 ) : 0.; } + template + class DummyMyMeshType1D + { + public: + static const int MY_SPACEDIM=1; + static const int MY_MESHDIM=8; + typedef mcIdType MyConnType; + static const INTERP_KERNEL::NumberingPolicy My_numPol=MyMeshType::My_numPol; + // begin + // useless, but for windows compilation ... + const double *getCoordinatesPtr() const { return nullptr; } + const MyConnType *getConnectivityPtr() const { return nullptr; } + const MyConnType *getConnectivityIndexPtr() const { return nullptr; } + INTERP_KERNEL::NormalizedCellType getTypeOfElement(MyConnType) const { return (INTERP_KERNEL::NormalizedCellType)0; } + // end + }; + /*! * This method determines if a target point ( \a coordsT ) is in source seg2 contained in \a coordsS. To do so _precision attribute is used. * If target point is in, \a xs0, \a xs1 and \a xt are set to 1D referential for a further barycentric computation. @@ -459,7 +476,9 @@ namespace INTERP_KERNEL if(!projectionThis(coordsT,coordsS,xs0,xs1,xt)) return false; constexpr ConnType TAB[2]={0,1}; - return PointLocatorAlgos::isElementContainsPoint(coordsT,NORM_SEG2,coordsS,TAB,2,this->_precision); + const double coordsS_1D[2]={xs0,xs1}; + const double *coordsT_1D(&xt); + return PointLocatorAlgos>::isElementContainsPoint(coordsT_1D,NORM_SEG2,coordsS_1D,TAB,2,this->_precision); } /*! diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py index b9e2ff012..189887c21 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py @@ -924,7 +924,6 @@ class MEDCouplingBasicsTest(unittest.TestCase): rem.setIntersectionType(PointLocator) self.assertEqual(rem.prepare(mS.buildUnstructured(),mT.buildUnstructured(),"P1P1"),1) m=rem.getCrudeCSRMatrix() - print(rem.getCrudeMatrix()) rowSum=m.sum(axis=1) m=diags(array(1/rowSum.transpose()),[0])*m # expected matrix @@ -973,7 +972,6 @@ class MEDCouplingBasicsTest(unittest.TestCase): rem.setIntersectionType(PointLocator) self.assertEqual(rem.prepare(mS,mT,"P1P1"),1) m=rem.getCrudeCSRMatrix() - print(rem.getCrudeMatrix()) rowSum=m.sum(axis=1) m=diags(array(1/rowSum.transpose()),[0])*m diff=abs(m-mExp0) @@ -1303,7 +1301,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): ref=float(m.getMeasureField(True).getArray()) self.assertTrue(abs(res-ref)/ref<1e-12) pass - + def test3D0DPointLocator(self): """ For pointlocator fans, Remapper support following intersection @@ -1429,12 +1427,23 @@ class MEDCouplingBasicsTest(unittest.TestCase): src.insertNextCell(NORM_SEG2,[0,2]) src.insertNextCell(NORM_SEG2,[2,3]) src.insertNextCell(NORM_SEG2,[3,1]) - trg = MEDCouplingUMesh.Build0DMeshFromCoords( DataArrayDouble([0.4,2.3-1e-13,4.,7.]) ) + for eps in [0,1e-13,-1e-13]: + trg = MEDCouplingUMesh.Build0DMeshFromCoords( DataArrayDouble([0.4,2.3+eps,4.,7.]) ) + rem=MEDCouplingRemapper() + rem.setIntersectionType(PointLocator) + rem.prepare(src,trg,"P1P1") + rem.nullifiedTinyCoeffInCrudeMatrixAbs(1e-12) + self.checkMatrix(rem.getCrudeMatrix(),[{}, {2: 2.0}, {2: 0.4516129032258065, 3: 0.5483870967741935}, {1: 0.7272727272727273, 3: 0.27272727272727265}],src.getNumberOfNodes(),1e-12) + # P1P1 - 5 - descending order of coords in source mesh + src = MEDCouplingUMesh("src",1) + src.allocateCells() + src.setCoords( DataArrayDouble([3.,1.]) ) + src.insertNextCell(NORM_SEG2,[0,1]) + trg = MEDCouplingUMesh.Build0DMeshFromCoords( DataArrayDouble([2.3]) ) rem=MEDCouplingRemapper() rem.setIntersectionType(PointLocator) rem.prepare(src,trg,"P1P1") - rem.nullifiedTinyCoeffInCrudeMatrixAbs(1e-12) - self.checkMatrix(rem.getCrudeMatrix(),[{}, {2: 2.0}, {2: 0.4516129032258065, 3: 0.5483870967741935}, {1: 0.7272727272727273, 3: 0.27272727272727265}],src.getNumberOfNodes(),1e-12) + self.checkMatrix(rem.getCrudeMatrix(),[{0:0.65,1:0.35}],src.getNumberOfNodes(),1e-12) pass def checkMatrix(self,mat1,mat2,nbCols,eps):