From: Anthony Geay Date: Tue, 27 Dec 2016 10:56:49 +0000 (+0100) Subject: Remapper deals with 3D to 3DSurf in P1P1 using PointLocator intersection type. X-Git-Tag: V8_3_0a2~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=878f4223c8eb3ea03fb54e9a2605ae3df05251fd;p=tools%2Fmedcoupling.git Remapper deals with 3D to 3DSurf in P1P1 using PointLocator intersection type. --- diff --git a/src/INTERP_KERNEL/Interpolation2D3D.txx b/src/INTERP_KERNEL/Interpolation2D3D.txx index dc63a286c..cfd759ea7 100644 --- a/src/INTERP_KERNEL/Interpolation2D3D.txx +++ b/src/INTERP_KERNEL/Interpolation2D3D.txx @@ -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()); diff --git a/src/INTERP_KERNEL/Interpolation3D.txx b/src/INTERP_KERNEL/Interpolation3D.txx index c78f2a059..5df84a974 100644 --- a/src/INTERP_KERNEL/Interpolation3D.txx +++ b/src/INTERP_KERNEL/Interpolation3D.txx @@ -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()); diff --git a/src/INTERP_KERNEL/Interpolation3D1D.txx b/src/INTERP_KERNEL/Interpolation3D1D.txx index b9ebc86fa..d77b59b91 100644 --- a/src/INTERP_KERNEL/Interpolation3D1D.txx +++ b/src/INTERP_KERNEL/Interpolation3D1D.txx @@ -77,7 +77,7 @@ namespace INTERP_KERNEL { intersector=new PointLocator3DIntersectorP1P1(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()); diff --git a/src/MEDCoupling/MEDCouplingRemapper.cxx b/src/MEDCoupling/MEDCouplingRemapper.cxx index 36d1a0b96..56e5b268e 100644 --- a/src/MEDCoupling/MEDCouplingRemapper.cxx +++ b/src/MEDCoupling/MEDCouplingRemapper.cxx @@ -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 > 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 >::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 > 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(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 >::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(oss," ")); + oss << std::endl; + } } } } diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py index 5f6b36601..716217461 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingRemapperTest.py @@ -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])