From: ageay Date: Wed, 3 Mar 2010 09:13:18 +0000 (+0000) Subject: 1D->2D in remapper. X-Git-Tag: V5_1_main_FINAL~172 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4d5adeb5b7c80b618e18d0a983bd03fb2404f0aa;p=tools%2Fmedcoupling.git 1D->2D in remapper. --- diff --git a/src/MEDCoupling/MEDCouplingRemapper.cxx b/src/MEDCoupling/MEDCouplingRemapper.cxx index 8aefe6e14..5beef8bfc 100644 --- a/src/MEDCoupling/MEDCouplingRemapper.cxx +++ b/src/MEDCoupling/MEDCouplingRemapper.cxx @@ -215,6 +215,18 @@ int MEDCouplingRemapper::prepareUU(const char *method) 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) + throw INTERP_KERNEL::Exception("Invalid interpolation requested between 1D and 2D ! 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); + std::vector > matrixTmp; + nbCols=interpolation.interpolateMeshes(target_mesh_wrapper,source_mesh_wrapper,matrixTmp,method); + reverseMatrix(matrixTmp,nbCols,_matrix); + nbCols=matrixTmp.size(); + } else if(trgMeshDim==-1) { if(srcMeshDim==2 && srcSpaceDim==2) diff --git a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx b/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx index 67cf46cfc..02b8db7f4 100644 --- a/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx +++ b/src/MEDCoupling/Test/MEDCouplingRemapperTest.cxx @@ -407,6 +407,30 @@ void MEDCouplingRemapperTest::testMultiDimCombi() srcField->decrRef(); sourceMesh->decrRef(); targetMesh->decrRef(); + // ------------- 1D -> 2D + sourceMesh=build1DTargetMesh_2(); + targetMesh=build2DTargetMesh_1(); + remapper.setIntersectionType(INTERP_KERNEL::PointLocator); + CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(sourceMesh,targetMesh,"P0P0")); + srcField=MEDCouplingFieldDouble::New(ON_CELLS); + srcField->setNature(ConservativeVolumic); + srcField->setMesh(sourceMesh); + array=DataArrayDouble::New(); + array->alloc(sourceMesh->getNumberOfCells(),1); + srcField->setArray(array); + ptr=array->getPointer(); + for(int i=0;igetNumberOfCells();i++) + ptr[i]=(double)(i+7); + array->decrRef(); + trgField=remapper.transferField(srcField,4.57); + const double valuesExpected9[5]={10.,8.,7.,4.57,10.}; + values=trgField->getArray()->getConstPointer(); + for(int i0=0;i0<5;i0++) + CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected9[i0],values[i0],1e-12); + trgField->decrRef(); + srcField->decrRef(); + sourceMesh->decrRef(); + targetMesh->decrRef(); // ------------- 2D -> -1D sourceMesh=build2DTargetMesh_1(); targetMesh=MEDCouplingUMesh::New("an example of -1 D mesh",-1);