From: ageay Date: Fri, 30 Sep 2011 09:30:15 +0000 (+0000) Subject: Introduction of 2D/1D and 3D/2D interpolation into ParaMEDMEM. X-Git-Tag: V6_main_FINAL~941 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=047e51798ed5cffa50f07c5ff7f7de2f5db40648;p=tools%2Fmedcoupling.git Introduction of 2D/1D and 3D/2D interpolation into ParaMEDMEM. --- diff --git a/src/ParaMEDMEM/InterpolationMatrix.cxx b/src/ParaMEDMEM/InterpolationMatrix.cxx index 2b45c71f3..038425c54 100644 --- a/src/ParaMEDMEM/InterpolationMatrix.cxx +++ b/src/ParaMEDMEM/InterpolationMatrix.cxx @@ -29,6 +29,8 @@ #include "Interpolation2D.txx" #include "Interpolation3DSurf.hxx" #include "Interpolation3D.txx" +#include "Interpolation3D2D.txx" +#include "Interpolation2D1D.txx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingNormalizedUnstructuredMesh.txx" #include "InterpolationOptions.hxx" @@ -158,6 +160,28 @@ namespace ParaMEDMEM else throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of distant mesh to -1D sourceMesh"); } + else if ( distant_support.getMeshDimension() == 2 + && _source_support->getMeshDimension() == 3 + && distant_support.getSpaceDimension() == 3 && _source_support->getSpaceDimension() == 3) + { + MEDCouplingNormalizedUnstructuredMesh<3,3> target_wrapper(distant_supportC); + MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(source_supportC); + INTERP_KERNEL::Interpolation3D2D interpolator (*this); + colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); + target_wrapper.releaseTempArrays(); + source_wrapper.releaseTempArrays(); + } + else if ( distant_support.getMeshDimension() == 1 + && _source_support->getMeshDimension() == 2 + && distant_support.getSpaceDimension() == 2 && _source_support->getSpaceDimension() == 2) + { + MEDCouplingNormalizedUnstructuredMesh<2,2> target_wrapper(distant_supportC); + MEDCouplingNormalizedUnstructuredMesh<2,2> source_wrapper(source_supportC); + INTERP_KERNEL::Interpolation2D1D interpolator (*this); + colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); + target_wrapper.releaseTempArrays(); + source_wrapper.releaseTempArrays(); + } else if (distant_support.getMeshDimension() != _source_support->getMeshDimension()) { throw INTERP_KERNEL::Exception("local and distant meshes do not have the same space and mesh dimensions"); diff --git a/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx b/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx index d232ca821..75b075c2d 100644 --- a/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx +++ b/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx @@ -28,6 +28,8 @@ #include "Interpolation2D.txx" #include "Interpolation3DSurf.hxx" #include "Interpolation3D.txx" +#include "Interpolation3D2D.txx" +#include "Interpolation2D1D.txx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingNormalizedUnstructuredMesh.txx" #include "InterpolationOptions.hxx" @@ -132,6 +134,56 @@ namespace ParaMEDMEM else throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of distant mesh to -1D sourceMesh"); } + else if ( src->getMeshDimension() == 2 && trg->getMeshDimension() == 3 + && trg->getSpaceDimension() == 3 && src->getSpaceDimension() == 3 ) + { + MEDCouplingNormalizedUnstructuredMesh<3,3> target_wrapper(trgC); + MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(srcC); + + INTERP_KERNEL::Interpolation3D2D interpolator (*this); + colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str()); + target_wrapper.releaseTempArrays(); + source_wrapper.releaseTempArrays(); + } + else if ( src->getMeshDimension() == 3 && trg->getMeshDimension() == 2 + && trg->getSpaceDimension() == 3 && src->getSpaceDimension() == 3 ) + { + MEDCouplingNormalizedUnstructuredMesh<3,3> target_wrapper(trgC); + MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(srcC); + + INTERP_KERNEL::Interpolation3D2D interpolator (*this); + vector > surfacesTranspose; + colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str());//not a bug target in source. + TransposeMatrix(surfacesTranspose,colSize,surfaces); + colSize=surfacesTranspose.size(); + target_wrapper.releaseTempArrays(); + source_wrapper.releaseTempArrays(); + } + else if ( src->getMeshDimension() == 1 && trg->getMeshDimension() == 2 + && trg->getSpaceDimension() == 2 && src->getSpaceDimension() == 2 ) + { + MEDCouplingNormalizedUnstructuredMesh<2,2> target_wrapper(trgC); + MEDCouplingNormalizedUnstructuredMesh<2,2> source_wrapper(srcC); + + INTERP_KERNEL::Interpolation2D1D interpolator (*this); + colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str()); + target_wrapper.releaseTempArrays(); + source_wrapper.releaseTempArrays(); + } + else if ( src->getMeshDimension() == 2 && trg->getMeshDimension() == 1 + && trg->getSpaceDimension() == 2 && src->getSpaceDimension() == 2 ) + { + MEDCouplingNormalizedUnstructuredMesh<2,2> target_wrapper(trgC); + MEDCouplingNormalizedUnstructuredMesh<2,2> source_wrapper(srcC); + + INTERP_KERNEL::Interpolation2D1D interpolator (*this); + vector > surfacesTranspose; + colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfacesTranspose,interpMethod.c_str());//not a bug target in source. + TransposeMatrix(surfacesTranspose,colSize,surfaces); + colSize=surfacesTranspose.size(); + target_wrapper.releaseTempArrays(); + source_wrapper.releaseTempArrays(); + } else if (trg->getMeshDimension() != _source_support->getMeshDimension()) { throw INTERP_KERNEL::Exception("local and distant meshes do not have the same space and mesh dimensions"); @@ -250,4 +302,13 @@ namespace ParaMEDMEM { return method=="P0"; } + + void OverlapInterpolationMatrix::TransposeMatrix(const std::vector >& matIn, int nbColsMatIn, std::vector >& matOut) + { + matOut.resize(nbColsMatIn); + int id=0; + for(std::vector >::const_iterator iter1=matIn.begin();iter1!=matIn.end();iter1++,id++) + for(std::map::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++) + matOut[(*iter2).first][id]=(*iter2).second; + } } diff --git a/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx b/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx index c3a464907..52b9cc1a0 100644 --- a/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx +++ b/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx @@ -104,6 +104,7 @@ namespace ParaMEDMEM void fillDistributedMatrix(const std::vector< std::map >& res, const DataArrayInt *srcIds, int srcProc, const DataArrayInt *trgIds, int trgProc); + static void TransposeMatrix(const std::vector >& matIn, int nbColsMatIn, std::vector >& matOut); private: ParaMEDMEM::ParaFIELD *_source_field; ParaMEDMEM::ParaFIELD *_target_field;