]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Deal with 2D/0D pointlocator into Remapper
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 31 Dec 2019 09:28:23 +0000 (10:28 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 31 Dec 2019 09:28:23 +0000 (10:28 +0100)
src/MEDCoupling/MEDCouplingRemapper.cxx
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py

index b5297715200a02d56b72da7addc7b0b54de95345..884132a50e75cc8657794124104d50fc2ebfeebd 100755 (executable)
@@ -527,6 +527,15 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU()
             }
         }
     }
+  else if(srcMeshDim==2 && trgMeshDim==0 && srcSpaceDim==2)
+    {
+      if(getIntersectionType()!=INTERP_KERNEL::PointLocator)
+        throw INTERP_KERNEL::Exception("Invalid interpolation requested between 2D and 0D ! Select PointLocator as intersection type !");
+      MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(src_mesh);
+      MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(target_mesh);
+      INTERP_KERNEL::Interpolation2D interpolation(*this);
+      nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+    }
   else if(srcMeshDim==1 && trgMeshDim==2 && srcSpaceDim==2)
     {
       if(getIntersectionType()==INTERP_KERNEL::PointLocator)
index 63bf0ee7fd5d76ca99a54d00354a5ae3ad076ade..773e0a1478eaa45f6700e49eea9a6b4ca50e61c5 100644 (file)
@@ -1302,7 +1302,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertTrue(abs(res-ref)/ref<1e-12)
         pass
 
-    def test3D0DP1P1(self):
+    def test3D0DPointLocator(self):
         """
         For pointlocator fans, Remapper support following intersection
         IntersectionType == PointLocator
@@ -1319,7 +1319,6 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         rem.setIntersectionType(PointLocator)
         rem.prepare(src,trg,"P1P1")
         self.checkMatrix(rem.getCrudeMatrix(),[{0:0.23,1:0.4,2:0.3,3:0.07}],src.getNumberOfNodes(),1e-12)
-        self.checkMatrix(rem.getCrudeMatrix(),[{0:0.23,1:0.4,2:0.3,3:0.07}],src.getNumberOfNodes(),1e-12)
         # P1P0
         rem=MEDCouplingRemapper()
         rem.setIntersectionType(PointLocator)
@@ -1336,6 +1335,40 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         rem.prepare(src,trg,"P0P0")
         self.checkMatrix(rem.getCrudeMatrix(),[{0:1.0}],src.getNumberOfCells(),1e-12)
         pass
+    
+    def test2D0DPointLocator(self):
+        """
+        For pointlocator fans, Remapper support following intersection
+        IntersectionType == PointLocator
+        - source == 2D
+        - target == 0D
+        """
+        src = MEDCouplingUMesh("src",2)
+        src.allocateCells()
+        src.setCoords( DataArrayDouble([(0,0),(1,0),(0,1)]) )
+        src.insertNextCell(NORM_TRI3,[0,1,2])
+        trg = MEDCouplingUMesh.Build0DMeshFromCoords( DataArrayDouble([(0.4,0.3)]) )
+        # P1P1
+        rem=MEDCouplingRemapper()
+        rem.setIntersectionType(PointLocator)
+        rem.prepare(src,trg,"P1P1")
+        self.checkMatrix(rem.getCrudeMatrix(),[{0:0.3,1:0.4,2:0.3}],src.getNumberOfNodes(),1e-12)
+        # P1P0
+        rem=MEDCouplingRemapper()
+        rem.setIntersectionType(PointLocator)
+        rem.prepare(src,trg,"P1P0")
+        self.checkMatrix(rem.getCrudeMatrix(),[{0:0.3,1:0.4,2:0.3}],src.getNumberOfNodes(),1e-12)
+        # P0P1
+        rem=MEDCouplingRemapper()
+        rem.setIntersectionType(PointLocator)
+        rem.prepare(src,trg,"P0P1")
+        self.checkMatrix(rem.getCrudeMatrix(),[{0:1.0}],src.getNumberOfNodes(),1e-12)
+        # P0P0
+        rem=MEDCouplingRemapper()
+        rem.setIntersectionType(PointLocator)
+        rem.prepare(src,trg,"P0P0")
+        self.checkMatrix(rem.getCrudeMatrix(),[{0:1.0}],src.getNumberOfNodes(),1e-12)
+        pass
 
     def checkMatrix(self,mat1,mat2,nbCols,eps):
         self.assertEqual(len(mat1),len(mat2))