]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Introduction of 2D/1D and 3D/2D interpolation into ParaMEDMEM.
authorageay <ageay>
Fri, 30 Sep 2011 09:30:15 +0000 (09:30 +0000)
committerageay <ageay>
Fri, 30 Sep 2011 09:30:15 +0000 (09:30 +0000)
src/ParaMEDMEM/InterpolationMatrix.cxx
src/ParaMEDMEM/OverlapInterpolationMatrix.cxx
src/ParaMEDMEM/OverlapInterpolationMatrix.hxx

index 2b45c71f374512dcb7449fb4e4b3d754f9a5aef8..038425c54cfaae4a56d10b3046bd719a258d6ab6 100644 (file)
@@ -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");
index d232ca8214f0b13fde789d7217d94ae5fa4b5094..75b075c2d76786c5b6533b4cadd8bc72247f5e37 100644 (file)
@@ -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<map<int,double> > 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<map<int,double> > 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<std::map<int,double> >& matIn, int nbColsMatIn, std::vector<std::map<int,double> >& matOut)
+  {
+    matOut.resize(nbColsMatIn);
+    int id=0;
+    for(std::vector<std::map<int,double> >::const_iterator iter1=matIn.begin();iter1!=matIn.end();iter1++,id++)
+      for(std::map<int,double>::const_iterator iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++)
+        matOut[(*iter2).first][id]=(*iter2).second;
+  }
 }
index c3a464907e7483fe1428c4486d58fdfa4363cc75..52b9cc1a0ffe9e5cf71abeff37a2e7494b23d977 100644 (file)
@@ -104,6 +104,7 @@ namespace ParaMEDMEM
     void fillDistributedMatrix(const std::vector< std::map<int,double> >& res,
                                const DataArrayInt *srcIds, int srcProc,
                                const DataArrayInt *trgIds, int trgProc);
+    static void TransposeMatrix(const std::vector<std::map<int,double> >& matIn, int nbColsMatIn, std::vector<std::map<int,double> >& matOut);
   private:
     ParaMEDMEM::ParaFIELD *_source_field;
     ParaMEDMEM::ParaFIELD *_target_field;