]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Remapper: PointLocator method does not make sense for srcMeshDim=2, trgtMeshDim=3...
authorabn <adrien.bruneton@cea.fr>
Mon, 18 Feb 2019 10:29:55 +0000 (11:29 +0100)
committerabn <adrien.bruneton@cea.fr>
Thu, 21 Feb 2019 11:24:58 +0000 (12:24 +0100)
src/INTERP_KERNEL/Interpolation2D3D.txx
src/MEDCoupling/MEDCouplingRemapper.cxx
src/MEDCoupling_Swig/MEDCouplingRemapperTest.py

index c9c7dad82feeb3c322c6ee3e7bca92ab262de835..a9b7252435d9e8e2088d9bc7781f840c007ccce2 100644 (file)
@@ -99,11 +99,8 @@ namespace INTERP_KERNEL
                                                                                    intersectFaces,
                                                                                    getSplittingPolicy());
             break;
-          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.");
+            throw INTERP_KERNEL::Exception("Invalid 2D to 3D intersection type for P0P0 interp specified : must be Triangulation.");
           }
       }
     else
index bec0b62e73885f4446a114b35d71e6dbacc74f0d..5b4d4cc9ac74ea383360e428293c4218a69bdd02 100644 (file)
@@ -552,19 +552,24 @@ int MEDCouplingRemapper::prepareInterpKernelOnlyUU()
     }
   else if(srcMeshDim==2 && trgMeshDim==3 && srcSpaceDim==3)
     {
-      MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(src_mesh);
-      MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(target_mesh);
-      INTERP_KERNEL::Interpolation2D3D interpolation(*this);
-      nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
-      INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces=interpolation.retrieveDuplicateFaces();
-      if(!duplicateFaces.empty())
+      if(getIntersectionType()==INTERP_KERNEL::PointLocator)
+        throw INTERP_KERNEL::Exception("Using point locator to transfer a mesh of dim 2 to a mesh of dim 3 does not make sense: 3D centers of mass can not be localized in a mesh having mesh-dim=2, space-dim=3!!");
+      else
         {
-          std::ostringstream oss; oss << "An unexpected situation happened ! 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::Interpolation2D3D interpolation(*this);
+          nbCols=interpolation.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,_matrix,method);
+          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 happened ! 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 a2efa36abff62c7117a61cdbfbd60af5a46984a4..e6aedde615fbfcc1cbbc554f4e30aeff62ebd260 100644 (file)
@@ -998,8 +998,10 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         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}])
+        ##
+        # 2D to 3D with point locator does not make sense:
+        ##
+        self.assertRaises(InterpKernelException, rem2.prepare,mt,ms,"P0P0")
         pass
 
     def test2D1Dand1D2DPointLocator1(self):
@@ -1192,7 +1194,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         rem.setIntersectionType(PointLocator)
         self.assertEqual(rem.prepare(src,trg,"P1P1"),1)
         mat=rem.getCrudeCSRMatrix()
-        row=array([2,2, 3,3, 0,0, 1,1]) # here ref to target point 3 
+        row=array([2,2, 3,3, 0,0, 1,1]) # here ref to target point 3
         col=array([1,2, 1,2, 1,2, 1,2])
         data=array([0.1,0.9, 0.3,0.7, 0.5,0.5, 0.8,0.2])
         mExp2=csr_matrix((data,(row,col)),shape=(4,3))
@@ -1299,7 +1301,7 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         ref=float(m.getMeasureField(True).getArray())
         self.assertTrue(abs(res-ref)/ref<1e-12)
         pass
-        
+
     def checkMatrix(self,mat1,mat2,nbCols,eps):
         self.assertEqual(len(mat1),len(mat2))
         for i in range(len(mat1)):