Salome HOME
ParaMEDMEM: DisjointDEC
[tools/medcoupling.git] / src / ParaMEDMEM / InterpolationMatrix.cxx
index 1ea54be9f965b7dcf5ab6aa78f687fc12cca6500..177a08dbbf8d1903531646e3db37be429fa26a6d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -29,7 +29,7 @@
 #include "Interpolation2D.txx"
 #include "Interpolation3DSurf.hxx"
 #include "Interpolation3D.txx"
-#include "Interpolation3D2D.txx"
+#include "Interpolation2D3D.txx"
 #include "Interpolation2D1D.txx"
 #include "MEDCouplingUMesh.hxx"
 #include "MEDCouplingNormalizedUnstructuredMesh.txx"
 
 #include <algorithm>
 
-// class InterpolationMatrix
-// This class enables the storage of an interpolation matrix Wij mapping 
-// source field Sj to target field Ti via Ti=Vi^(-1).Wij.Sj.
-// The matrix is built and stored on the processors belonging to the source
-// group. 
-
 using namespace std;
 
-namespace ParaMEDMEM
+namespace MEDCoupling
 {
 
-  //   ====================================================================
-  //   Creates an empty matrix structure linking two distributed supports.
-  //   The method must be called by all processors belonging to source
-  //   and target groups.
-  //   param source_support local support
-  //   param source_group processor group containing the local processors
-  //   param target_group processor group containing the distant processors
-  //   param method interpolation method
-  //   ====================================================================
-
-  InterpolationMatrix::InterpolationMatrix(const ParaMEDMEM::ParaFIELD *source_field, 
+  /**!
+     Creates an empty matrix structure linking two distributed supports.
+     The method must be called by all processors belonging to source
+     and target groups.
+     \param source_support local support
+     \param source_group processor group containing the local processors
+     \param target_group processor group containing the distant processors
+     \param method interpolation method
+  */
+  InterpolationMatrix::InterpolationMatrix(const MEDCoupling::ParaFIELD *source_field, 
                                            const ProcessorGroup& source_group,
                                            const ProcessorGroup& target_group,
                                            const DECOptions& dec_options,
@@ -84,22 +77,21 @@ namespace ParaMEDMEM
   }
 
 
-  //   ======================================================================
-  //   \brief Adds the contribution of a distant subdomain to the*
-  //   interpolation matrix.
-  //   The method adds contribution to the interpolation matrix.
-  //   For each row of the matrix, elements are addded as
-  //   a (column, coeff) pair in the _coeffs array. This column number refers
-  //   to an element on the target side via the _col_offsets array.
-  //   It is made of a series of (iproc, ielem) pairs. 
-  //   The number of elements per row is stored in the row_offsets array.
-
-  //   param distant_support local representation of the distant subdomain
-  //   param iproc_distant id of the distant subdomain (in the distant group)
-  //   param distant_elems mapping between the local representation of
-  //   the subdomain and the actual elem ids on the distant subdomain
-  //   ======================================================================
-
+  /*!
+     \brief Adds the contribution of a distant subdomain to the*
+     interpolation matrix.
+     The method adds contribution to the interpolation matrix.
+     For each row of the matrix, elements are addded as
+     a (column, coeff) pair in the _coeffs array. This column number refers
+     to an element on the target side via the _col_offsets array.
+     It is made of a series of (iproc, ielem) pairs.
+     The number of elements per row is stored in the row_offsets array.
+
+     param distant_support local representation of the distant subdomain
+     param iproc_distant id of the distant subdomain (in the distant group)
+     param distant_elems mapping between the local representation of
+     the subdomain and the actual elem ids on the distant subdomain
+   */
   void InterpolationMatrix::addContribution ( MEDCouplingPointSet& distant_support,
                                               int iproc_distant,
                                               const int* distant_elems,
@@ -165,7 +157,7 @@ namespace ParaMEDMEM
       {
         MEDCouplingNormalizedUnstructuredMesh<3,3> target_wrapper(distant_supportC);
         MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(source_supportC);
-        INTERP_KERNEL::Interpolation3D2D interpolator (*this);
+        INTERP_KERNEL::Interpolation2D3D interpolator (*this);
         interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);
         target_wrapper.releaseTempArrays();
         source_wrapper.releaseTempArrays();
@@ -181,6 +173,17 @@ namespace ParaMEDMEM
         target_wrapper.releaseTempArrays();
         source_wrapper.releaseTempArrays();
       }
+    else if ( distant_support.getMeshDimension() == 3
+              && _source_support->getMeshDimension() == 1
+              && distant_support.getSpaceDimension() == 3 && _source_support->getSpaceDimension() == 3)
+      {
+        MEDCouplingNormalizedUnstructuredMesh<3,3> target_wrapper(distant_supportC);
+        MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(source_supportC);
+        INTERP_KERNEL::Interpolation3D interpolator (*this);
+        interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod);
+        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");
@@ -344,10 +347,10 @@ namespace ParaMEDMEM
     NatureOfField nature=elementLocator.getLocalNature();
     switch(nature)
       {
-      case ConservativeVolumic:
+      case IntensiveMaximum:
         computeConservVolDenoW(elementLocator);
         break;
-      case Integral:
+      case ExtensiveMaximum:
         {
           if(!elementLocator.isM1DCorr())
             computeIntegralDenoW(elementLocator);
@@ -355,10 +358,10 @@ namespace ParaMEDMEM
             computeGlobConstraintDenoW(elementLocator);
           break;
         }
-      case IntegralGlobConstraint:
+      case ExtensiveConservation:
         computeGlobConstraintDenoW(elementLocator);
         break;
-      case RevIntegral:
+      case IntensiveConservation:
         {
           if(!elementLocator.isM1DCorr())
             computeRevIntegralDenoW(elementLocator);
@@ -377,10 +380,10 @@ namespace ParaMEDMEM
     NatureOfField nature=elementLocator.getLocalNature();
     switch(nature)
       {
-      case ConservativeVolumic:
+      case IntensiveMaximum:
         computeConservVolDenoL(elementLocator);
         break;
-      case Integral:
+      case ExtensiveMaximum:
         {
           if(!elementLocator.isM1DCorr())
             computeIntegralDenoL(elementLocator);
@@ -388,11 +391,11 @@ namespace ParaMEDMEM
             computeConservVolDenoL(elementLocator);
           break;
         }
-      case IntegralGlobConstraint:
-        //this is not a bug doing like ConservativeVolumic
+      case ExtensiveConservation:
+        //this is not a bug doing like IntensiveMaximum
         computeConservVolDenoL(elementLocator);
         break;
-      case RevIntegral:
+      case IntensiveConservation:
         {
           if(!elementLocator.isM1DCorr())
             computeRevIntegralDenoL(elementLocator);
@@ -829,14 +832,13 @@ namespace ParaMEDMEM
       }
   }
 
-  // ==================================================================
-  // The call to this method updates the arrays on the target side
-  //   so that they know which amount of data from which processor they 
-  //   should expect. 
-  //   That call makes actual interpolations via multiply method 
-  //   available.
-  // ==================================================================
 
+ /**!  The call to this method updates the arrays on the target side
+     so that they know which amount of data from which processor they
+     should expect.
+     That call makes actual interpolations via multiply method
+     available.
+     */
   void InterpolationMatrix::prepare()
   {
     int nbelems = _source_field->getField()->getNumberOfTuples();
@@ -848,18 +850,18 @@ namespace ParaMEDMEM
   }
 
 
-  //   =======================================================================
-  //   brief performs t=Ws, where t is the target field, s is the source field
 
-  //   The call to this method must be called both on the working side 
-  //   and on the idle side. On the working side, the vector  T=VT^(-1).(W.S)
-  //   is computed and sent. On the idle side, no computation is done, but the 
-  //   result from the working side is received and the field is updated.
+  /*!
+     \brief performs t=Ws, where t is the target field, s is the source field
 
-  //   param field source field on processors involved on the source side,
-  //   target field on processors on the target side
-  //   =======================================================================
+     The call to this method must be called both on the working side
+     and on the idle side. On the working side, the vector  T=VT^(-1).(W.S)
+     is computed and sent. On the idle side, no computation is done, but the
+     result from the working side is received and the field is updated.
 
+     \param field source field on processors involved on the source side,
+     target field on processors on the target side
+   */
   void InterpolationMatrix::multiply(MEDCouplingFieldDouble& field) const
   {
     int nbcomp = field.getArray()->getNumberOfComponents();
@@ -906,20 +908,19 @@ namespace ParaMEDMEM
   }
   
 
-  // =========================================================================
-  // brief performs s=WTt, where t is the target field, s is the source field,
-  // WT is the transpose matrix from W
-
-  //   The call to this method must be called both on the working side 
-  //   and on the idle side. On the working side, the target vector T is
-  //   received and the vector  S=VS^(-1).(WT.T) is computed to update
-  //   the field. 
-  //   On the idle side, no computation is done, but the field is sent.
+  /**!
+   \brief performs s=WTt, where t is the target field, s is the source field,
+   WT is the transpose matrix from W
 
-  //   param field source field on processors involved on the source side,
-  //   target field on processors on the target side
-  // =========================================================================
+     The call to this method must be called both on the working side
+     and on the idle side. On the working side, the target vector T is
+     received and the vector  S=VS^(-1).(WT.T) is computed to update
+     the field.
+     On the idle side, no computation is done, but the field is sent.
 
+     param field source field on processors involved on the source side,
+     target field on processors on the target side
+     */
   void InterpolationMatrix::transposeMultiply(MEDCouplingFieldDouble& field) const
   {
     int nbcomp = field.getArray()->getNumberOfComponents();