Salome HOME
MEDCoupling API renaming - stage #2
[tools/medcoupling.git] / src / INTERP_KERNELTest / MeshTestToolkit.txx
index 28ce7bde9511e07b6af5200b85121fd385ed2dd0..d263cc8a00d748045f2c8e004758f4c88fe54dbb 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015  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
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -38,7 +38,7 @@
 #include <algorithm>
 
 
-// levels : 
+// levels :
 // 1 - titles and volume results
 // 2 - symmetry / diagonal results and intersection matrix output
 // 3 - empty
@@ -49,7 +49,7 @@
 #include <cppunit/extensions/HelperMacros.h>
 
 //#define VOL_PREC 1.0e-6
-using namespace ParaMEDMEM;
+using namespace MEDCoupling;
 using namespace INTERP_KERNEL;
 
 namespace INTERP_TEST
@@ -104,9 +104,9 @@ namespace INTERP_TEST
    * @param tab    pointer to double[no. elements of mesh] array in which to store the volumes
    */
   template <int SPACEDIM, int MESHDIM>
-  void MeshTestToolkit<SPACEDIM,MESHDIM>::getVolumes(ParaMEDMEM::MEDCouplingUMesh& mesh, double *tab) const
+  void MeshTestToolkit<SPACEDIM,MESHDIM>::getVolumes(MEDCoupling::MEDCouplingUMesh& mesh, double *tab) const
   {
-    MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> vol=mesh.getMeasureField(true);
+    MCAuto<MEDCouplingFieldDouble> vol=mesh.getMeasureField(true);
     std::copy(vol->getArray()->begin(),vol->getArray()->end(),tab);
   }
 
@@ -138,7 +138,7 @@ namespace INTERP_TEST
   }
 
   /**
-   * Verifies if for a given intersection matrix the sum of each row is equal to the volumes 
+   * Verifies if for a given intersection matrix the sum of each row is equal to the volumes
    * of the corresponding source elements and the sum of each column is equal to the volumes
    * of the corresponding target elements. This will be true as long as the meshes correspond
    * to the same geometry. The equalities are in the "epsilon-sense", making sure the relative
@@ -150,7 +150,7 @@ namespace INTERP_TEST
    * @return true if the condition is verified, false if not.
    */
   template <int SPACEDIM, int MESHDIM>
-  bool MeshTestToolkit<SPACEDIM,MESHDIM>::testVolumes(const IntersectionMatrix& m,  ParaMEDMEM::MEDCouplingUMesh& sMesh,  ParaMEDMEM::MEDCouplingUMesh& tMesh) const
+  bool MeshTestToolkit<SPACEDIM,MESHDIM>::testVolumes(const IntersectionMatrix& m,  MEDCoupling::MEDCouplingUMesh& sMesh,  MEDCoupling::MEDCouplingUMesh& tMesh) const
   {
     bool ok = true;
 
@@ -160,7 +160,7 @@ namespace INTERP_TEST
 
     for(int i = 0; i < sMesh.getNumberOfCells(); ++i)
       {
-        const double sum_row = sumRow(m, i+1);
+        const double sum_row = sumRow(m, i);
         if(!epsilonEqualRelative(sum_row, fabs(sVol[i]), _precision))
           {
             LOG(1, "Source volume inconsistent : vol of cell " << i << " = " << sVol[i] << " but the row sum is " << sum_row );
@@ -206,11 +206,11 @@ namespace INTERP_TEST
         for(std::map<int, double>::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2)
           {
             int j = iter2->first;
-            if(m2.at(j-1).count(i+1) == 0)
+            if(m2.at(j).count(i) == 0)
               {
                 if(!epsilonEqual(iter2->second, 0.0, _precision))
                   {
-                    LOG(2, "V1( " << i << ", " << j << ") exists, but V2( " << j - 1 << ", " << i + 1 << ") " << " does not " );
+                    LOG(2, "V1( " << i << ", " << j << ") exists, but V2( " << j << ", " << i << ") " << " does not " );
                     LOG(2, "(" << i << ", " << j << ") fails");
                     compatitable = false;
                   }
@@ -251,11 +251,11 @@ namespace INTERP_TEST
             const double v1 = fabs(iter2->second);
             //if(m2[j - 1].count(i+1) > 0)
             //  {
-            std::map<int, double> theMap =  m2.at(j-1);
-            const double v2 = fabs(theMap[i + 1]); 
+            std::map<int, double> theMap =  m2.at(j);
+            const double v2 = fabs(theMap[i]);
             if(v1 != v2)
               {
-                LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 );
+                LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j << ", " << i << ") = " << v2 << " | diff = " << v1 - v2 );
                 if(!epsilonEqualRelative(v1, v2, _precision))
                   {
                     LOG(2, "(" << i << ", " << j << ") fails");
@@ -267,7 +267,7 @@ namespace INTERP_TEST
       }
     if(!isSymmetric)
       {
-        LOG(1, "*** matrices are not symmetric"); 
+        LOG(1, "*** matrices are not symmetric");
       }
     return isSymmetric;
   }
@@ -283,7 +283,7 @@ namespace INTERP_TEST
   bool MeshTestToolkit<SPACEDIM,MESHDIM>::testDiagonal(const IntersectionMatrix& m) const
   {
     LOG(1, "Checking if matrix is diagonal" );
-    int i = 1;
+    int i = 0;
     bool isDiagonal = true;
     for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter)
       {
@@ -293,7 +293,7 @@ namespace INTERP_TEST
             const double vol = iter2->second;
             if(vol != 0.0 && (i != j))
               {
-                LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" );
+                LOG(2, "V( " << i << ", " << j << ") = " << vol << " which is not zero" );
                 if(!epsilonEqual(vol, 0.0, _precision))
                   {
                     LOG(2, "(" << i << ", " << j << ") fails");
@@ -335,9 +335,9 @@ namespace INTERP_TEST
    * Calculates the intersection matrix for two meshes.
    * If the source and target meshes are the same, a CppUnit assertion raised if testVolumes() returns false.
    *
-   * @param  mesh1path   the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/
+   * @param  mesh1path   the path to the file containing the source mesh, relative to {$MEDCOUPLING_ROOT_DIR}/share/resources/med/
    * @param  mesh1       the name of the source mesh
-   * @param  mesh2path   the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/
+   * @param  mesh2path   the path to the file containing the target mesh, relative to {$MEDCOUPLING_ROOT_DIR}/share/resources/med/
    * @param  mesh2       the name of the target mesh
    * @param  m           intersection matrix in which to store the result of the intersection
    */
@@ -347,12 +347,12 @@ namespace INTERP_TEST
     LOG(1, std::endl << "=== -> intersecting src = " << mesh1path << ", target = " << mesh2path );
 
     LOG(5, "Loading " << mesh1 << " from " << mesh1path);
-    MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> sMeshML=MEDFileUMesh::New(INTERP_TEST::getResourceFile(mesh1path).c_str(),mesh1);
-    MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> sMesh=sMeshML->getMeshAtLevel(0);
+    MCAuto<MEDFileUMesh> sMeshML=MEDFileUMesh::New(INTERP_TEST::getResourceFile(mesh1path).c_str(),mesh1);
+    MCAuto<MEDCouplingUMesh> sMesh=sMeshML->getMeshAtLevel(0);
 
     LOG(5, "Loading " << mesh2 << " from " << mesh2path);
-    MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> tMeshML=MEDFileUMesh::New(INTERP_TEST::getResourceFile(mesh2path).c_str(),mesh2);
-    MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tMesh=tMeshML->getMeshAtLevel(0);
+    MCAuto<MEDFileUMesh> tMeshML=MEDFileUMesh::New(INTERP_TEST::getResourceFile(mesh2path).c_str(),mesh2);
+    MCAuto<MEDCouplingUMesh> tMesh=tMeshML->getMeshAtLevel(0);
 
     MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM> sMesh_wrapper(sMesh);
     MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM> tMesh_wrapper(tMesh);
@@ -397,9 +397,9 @@ namespace INTERP_TEST
    * it will be confirmed that the intersection matrix is diagonal, otherwise the intersection matrices will be
    * calculated once which each mesh as source mesh, and it will be verified that the they are each others' transpose.
    *
-   * @param  mesh1path   the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/
+   * @param  mesh1path   the path to the file containing the source mesh, relative to {$MEDCOUPLING_ROOT_DIR}/share/resources/med/
    * @param  mesh1       the name of the source mesh
-   * @param  mesh2path   the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/
+   * @param  mesh2path   the path to the file containing the target mesh, relative to {$MEDCOUPLING_ROOT_DIR}/share/resources/med/
    * @param  mesh2       the name of the target mesh
    * @param  correctVol  the total volume of the intersection of the two meshes
    * @param  prec        maximum relative error to be tolerated in volume comparisions
@@ -420,7 +420,7 @@ namespace INTERP_TEST
     IntersectionMatrix matrix1;
     calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1);
 
-#if LOG_LEVEL >= 2 
+#if LOG_LEVEL >= 2
     dumpIntersectionMatrix(matrix1);
 #endif
 
@@ -441,7 +441,7 @@ namespace INTERP_TEST
     else
       {
         IntersectionMatrix matrix2;
-        calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2);    
+        calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2);
 
 #if LOG_LEVEL >= 2
         dumpIntersectionMatrix(matrix2);
@@ -460,7 +460,7 @@ namespace INTERP_TEST
 
   /**
    * Utility method used to facilitate the call to intersect meshes.
-   * It calls intersectMeshes, using "mesh1.med" as file name for the mesh with name "mesh1" and 
+   * It calls intersectMeshes, using "mesh1.med" as file name for the mesh with name "mesh1" and
    * "mesh2.med" as file name for the mesh with name "mesh2". The rest of the arguments are passed
    * along as they are.
    *