]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Quick solve of bug with interpolation 3DSurf<->3D using PointLocator.
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 8 Jan 2016 13:03:27 +0000 (14:03 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 8 Jan 2016 13:03:27 +0000 (14:03 +0100)
src/INTERP_KERNEL/Interpolation3D2D.txx
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py

index 674317e1af0327042fc94f17fe5744b07cd8e907..29d9ec2ae25884908b8900b558ec891cafc2228f 100644 (file)
@@ -54,8 +54,8 @@ namespace INTERP_KERNEL
    * the indexing is more natural : the intersection volume of the target element i with source element j is found at matrix[i-1][j].
    * 
 
-   * @param srcMesh     3-dimensional source mesh
-   * @param targetMesh  3-dimesional target mesh, containing only tetraedra
+   * @param srcMesh     3DSurf source mesh (meshDim=2,spaceDim=3)
+   * @param targetMesh  3D target mesh, containing only tetraedra
    * @param matrix      matrix in which the result is stored
    *
    */
@@ -99,8 +99,8 @@ namespace INTERP_KERNEL
                                                                                    intersectFaces,
                                                                                    getSplittingPolicy());
             break;
-          case PointLocator:
-            intersector=new PointLocator3DIntersectorP0P0<MyMeshType,MyMatrixType>(targetMesh,srcMesh,getPrecision());
+          case PointLocator:// switch target and source
+            intersector=new PointLocator3DIntersectorP0P0<MyMeshType,MyMatrixType>(srcMesh,targetMesh,getPrecision());
             break;
           default:
             throw INTERP_KERNEL::Exception("Invalid 3D to 2D intersection type for P0P0 interp specified : must be Triangulation or PointLocator.");
index e342f8c982551982a9718c4b66b4031e9f77f1c9..c5d99f89fcf53b8c58a42a4d043e557aa5941e82 100644 (file)
@@ -854,6 +854,30 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertAlmostEqual(diff.sum(),0.,14)
         pass
     
+    def test3D2Dand2D3DPointLocator1(self):
+        """ Non regression test solving SIGSEGV when using 3D<->3Dsurf pointlocator."""
+        arrX=DataArrayDouble([0,1,2])
+        arrY=DataArrayDouble([0,1])
+        arrZ=DataArrayDouble([0,1])
+        ms=MEDCouplingCMesh() ; ms.setCoords(arrX,arrY,arrZ)
+        ms=ms.buildUnstructured() ; ms.setName("source")
+        #
+        mt=MEDCouplingUMesh("target",2) ; mt.allocateCells()
+        mt.insertNextCell(NORM_TRI3,[0,4,6])
+        mt.insertNextCell(NORM_TRI3,[1,5,7])
+        mt.setCoords(ms.getCoords()[:])
+        mt.zipCoords()
+        #
+        rem=MEDCouplingRemapper()
+        rem.setIntersectionType(PointLocator)
+        rem.prepare(ms,mt,"P0P0")
+        self.assertEqual(rem.getCrudeMatrix(),[{0: 1.0}, {1: 1.0}])
+        rem2=MEDCouplingRemapper()
+        rem2.setIntersectionType(PointLocator)
+        rem2.prepare(mt,ms,"P0P0") # reverse mt<->ms
+        self.assertEqual(rem2.getCrudeMatrix(),[{0: 1.0}, {1: 1.0}])
+        pass
+    
     def build2DSourceMesh_1(self):
         sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]
         sourceConn=[0,3,1,0,2,3]