]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
OK agy/interp1D0D
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 2 Jan 2020 06:47:35 +0000 (07:47 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 2 Jan 2020 06:47:35 +0000 (07:47 +0100)
src/INTERP_KERNEL/CurveIntersector.txx
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py

index 8d3dab651f73836127bfdfb56434ac912d353696..c7860b292ec30c425d5b09c7dda5928575f9c0ac 100644 (file)
@@ -448,6 +448,23 @@ namespace INTERP_KERNEL
     return ( x0 < x1 ) ? ( x1 - x0 ) : 0.;
   }
 
+  template<class MyMeshType>
+  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<MyMeshType>::isElementContainsPoint(coordsT,NORM_SEG2,coordsS,TAB,2,this->_precision);
+    const double coordsS_1D[2]={xs0,xs1};
+    const double *coordsT_1D(&xt);
+    return PointLocatorAlgos<DummyMyMeshType1D<MyMeshType>>::isElementContainsPoint(coordsT_1D,NORM_SEG2,coordsS_1D,TAB,2,this->_precision);
   }
   
   /*!
index b9e2ff01258a3556bbf9e473156ab20e8de9d1ad..189887c21344d1ceab67439b7d0f6171b5234711 100644 (file)
@@ -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):