]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Remapper deals with 3D to 3DSurf in P1P1 using PointLocator intersection type.
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 27 Dec 2016 10:56:49 +0000 (11:56 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 27 Dec 2016 10:56:49 +0000 (11:56 +0100)
src/INTERP_KERNEL/Interpolation2D3D.txx
src/INTERP_KERNEL/Interpolation3D.txx
src/INTERP_KERNEL/Interpolation3D1D.txx
src/MEDCoupling/MEDCouplingRemapper.cxx
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py

index dc63a286c1d73025b828a3d094080e1733a48d1a..cfd759ea7f843a5ef5867ced3af514b1e994e728 100644 (file)
@@ -107,7 +107,7 @@ namespace INTERP_KERNEL
           }
       }
     else
-      throw Exception("Invalid method choosed must be in \"P0P0\".");
+      throw Exception("Invalid method chosen must be in \"P0P0\".");
     // create empty maps for all source elements
     matrix.resize(intersector->getNumberOfRowsOfResMatrix());
 
index c78f2a059b5f2e412b20579b15032134c4d145e6..5df84a9742636c4d6de2a1b93f4f5fd490b7b9cc 100644 (file)
@@ -163,7 +163,7 @@ namespace INTERP_KERNEL
           }
       }
     else
-      throw Exception("Invalid method choosed must be in \"P0P0\", \"P0P1\", \"P1P0\" or \"P1P1\".");
+      throw Exception("Invalid method chosen must be in \"P0P0\", \"P0P1\", \"P1P0\" or \"P1P1\".");
     // create empty maps for all source elements
     result.resize(intersector->getNumberOfRowsOfResMatrix());
 
index b9ebc86fac21f656b8bd87312252b8169c5728a5..d77b59b919186a87571ab00aceee5414bf08dd44 100644 (file)
@@ -77,7 +77,7 @@ namespace INTERP_KERNEL
       {  intersector=new PointLocator3DIntersectorP1P1<MyMeshType,MatrixType>(targetMesh, srcMesh, getPrecision());
       }
     else
-      throw Exception("Invalid method choosed must be in \"P0P0\", \"P0P1\", \"P1P0\" or \"P1P1\".");
+      throw Exception("Invalid method chosen must be in \"P0P0\", \"P0P1\", \"P1P0\" or \"P1P1\".");
     // create empty maps for all source elements
     result.resize(intersector->getNumberOfRowsOfResMatrix());
 
index 36d1a0b9659e58f6494f2c387246a0b7e97e2956..56e5b268e41906eb3e027e18b2f6bdea50a75ecf 100644 (file)
@@ -537,23 +537,33 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU()
     }
   else if(srcMeshDim==3 && trgMeshDim==2 && srcSpaceDim==3)
     {
-      MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
-      MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
-      INTERP_KERNEL::Interpolation2D3D interpolation(*this);
-      std::vector<std::map<int,double> > matrixTmp;
-      std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
-      nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
-      ReverseMatrix(matrixTmp,nbCols,_matrix);
-      nbCols=matrixTmp.size();
-      INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
-      if(!duplicateFaces.empty())
+      if(getIntersectionType()==INTERP_KERNEL::PointLocator)
         {
-          std::ostringstream oss; oss << "An unexpected situation happend ! For the following 2D Cells are part of edges shared by 3D cells :\n";
-          for(std::map<int,std::set<int> >::const_iterator it=duplicateFaces.begin();it!=duplicateFaces.end();it++)
+          MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
+          MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
+          INTERP_KERNEL::Interpolation3D interpolation(*this);
+          nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+        }
+      else
+        {
+          MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
+          MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
+          INTERP_KERNEL::Interpolation2D3D interpolation(*this);
+          std::vector<std::map<int,double> > matrixTmp;
+          std::string revMethod(BuildMethodFrom(trgMeth,srcMeth));
+          nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,revMethod);
+          ReverseMatrix(matrixTmp,nbCols,_matrix);
+          nbCols=matrixTmp.size();
+          INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
+          if(!duplicateFaces.empty())
             {
-              oss << "2D Cell #" << (*it).first << " is part of common face of following 3D cells ids : ";
-              std::copy((*it).second.begin(),(*it).second.end(),std::ostream_iterator<int>(oss," "));
-              oss << std::endl;
+              std::ostringstream oss; oss << "An unexpected situation happend ! For the following 2D Cells are part of edges shared by 3D cells :\n";
+              for(std::map<int,std::set<int> >::const_iterator it=duplicateFaces.begin();it!=duplicateFaces.end();it++)
+                {
+                  oss << "2D Cell #" << (*it).first << " is part of common face of following 3D cells ids : ";
+                  std::copy((*it).second.begin(),(*it).second.end(),std::ostream_iterator<int>(oss," "));
+                  oss << std::endl;
+                }
             }
         }
     }
index 5f6b3660125283859c5853bc5b56818d9f6fa3ef..716217461f457b2d1eeddd4cc7af8c5e34d24f8a 100644 (file)
@@ -1049,6 +1049,39 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         self.assertEqual(rem.getCrudeMatrix(), [{}, {}])
         pass
 
+    def testPointLocator3DTo2D(self):
+        """Target mesh has spaceDim==3 and meshDim==2. Source has spaceDim==3 and meshDim==3. Here we are on pointlocator alg.
+        The test evaluates on each nodes of target mesh the bary coor into source mesh."""
+        src=MEDCouplingCMesh()
+        arr=DataArrayDouble([0,1,2])
+        src.setCoords(arr,arr,arr)
+        src=src.buildUnstructured()
+        src.simplexize(PLANAR_FACE_5)
+        fsrc=MEDCouplingFieldDouble(ON_NODES) ; fsrc.setMesh(src)
+        fsrc.setArray(DataArrayDouble([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]))
+        #
+        trg=MEDCouplingCMesh()
+        arr=DataArrayDouble([0,1])
+        trg.setCoords(arr,arr)
+        trg=trg.buildUnstructured()
+        trg.changeSpaceDimension(3,0.)
+        trg.translate([0.5,0.5,0.5])
+        #
+        arrTrg=fsrc.getValueOnMulti(trg.getCoords())
+        ftrg=MEDCouplingFieldDouble(ON_NODES)
+        ftrg.setMesh(trg)
+        ftrg.setArray(arrTrg)
+        ftrg.checkConsistencyLight()
+        ftrg.setNature(IntensiveMaximum)
+        #
+        fsrc.setNature(IntensiveMaximum)
+        remap=MEDCouplingRemapper()
+        remap.setIntersectionType(PointLocator)
+        self.assertEqual(remap.prepare(src,trg,"P1P1"),1)
+        ftrg2=remap.transferField(fsrc,1e300)
+        self.assertTrue(ftrg.isEqual(ftrg2,1e-12,1e-12))
+        pass
+
     def testExtrudedOnDiffZLev1(self):
         """Non regression bug : This test is base on P0P0 ExtrudedExtruded. This test checks that if the input meshes are not based on a same plane // OXY the interpolation works"""
         arrX=DataArrayDouble([0,1]) ; arrY=DataArrayDouble([0,1]) ; arrZ=DataArrayDouble([0,1,2])