Salome HOME
Copyright update 2022
[tools/medcoupling.git] / src / ParaMEDMEMTest / ParaMEDMEMTest_InterpKernelDEC.cxx
index ba09f7eb41f6e53eeb20c46e9189a840716a4bc3..740557ba7e93a43df6f5443e31a733d695d527b5 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2022  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
 #include "ParaMESH.hxx"
 #include "ParaFIELD.hxx"
 #include "ComponentTopology.hxx"
-#include "ICoCoMEDField.hxx"
 #include "ParaMEDLoader.hxx"
+#include "ICoCoMEDDoubleField.hxx"
 #include "MEDLoader.hxx"
+#include "MEDCouplingUMesh.hxx"
 #include "TestInterpKernelUtils.hxx"
 
  
@@ -105,7 +106,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_1D()
       if(rank==0)
         {
           double coords[4]={0.3,0.7, 0.9,1.0};
-          int conn[4]={0,1,2,3};
+          mcIdType conn[4]={0,1,2,3};
           mesh=MEDCouplingUMesh::New("Source mesh Proc0",1);
           mesh->allocateCells(2);
           mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
@@ -120,7 +121,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_1D()
       if(rank==1)
         {
           double coords[2]={0.7,0.9};
-          int conn[2]={0,1};
+          mcIdType conn[2]={0,1};
           mesh=MEDCouplingUMesh::New("Source mesh Proc1",1);
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
@@ -134,7 +135,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_1D()
       if(rank==2)
         {
           double coords[2]={1.,1.12};
-          int conn[2]={0,1};
+          mcIdType conn[2]={0,1};
           mesh=MEDCouplingUMesh::New("Source mesh Proc2",1);
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
@@ -169,7 +170,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_1D()
       if(rank==3)
         {
           double coords[2]={0.5,0.75};
-          int conn[2]={0,1};
+          mcIdType conn[2]={0,1};
           mesh=MEDCouplingUMesh::New("Target mesh Proc3",1);
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
@@ -184,7 +185,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_1D()
       if(rank==4)
         {
           double coords[2]={0.75,1.2};
-          int conn[2]={0,1};
+          mcIdType conn[2]={0,1};
           mesh=MEDCouplingUMesh::New("Target mesh Proc4",1);
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
@@ -294,7 +295,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2DCurve()
       if(rank==0)
         {
           double coords[8]={0.3,0.3,0.7,0.7, 0.9,0.9,1.0,1.0};
-          int conn[4]={0,1,2,3};
+          mcIdType conn[4]={0,1,2,3};
           mesh=MEDCouplingUMesh::New("Source mesh Proc0",1);
           mesh->allocateCells(2);
           mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
@@ -309,7 +310,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2DCurve()
       if(rank==1)
         {
           double coords[4]={0.7,0.7,0.9,0.9};
-          int conn[2]={0,1};
+          mcIdType conn[2]={0,1};
           mesh=MEDCouplingUMesh::New("Source mesh Proc1",1);
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
@@ -323,7 +324,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2DCurve()
       if(rank==2)
         {
           double coords[4]={1.,1.,1.12,1.12};
-          int conn[2]={0,1};
+          mcIdType conn[2]={0,1};
           mesh=MEDCouplingUMesh::New("Source mesh Proc2",1);
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
@@ -358,7 +359,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2DCurve()
       if(rank==3)
         {
           double coords[4]={0.5,0.5,0.75,0.75};
-          int conn[2]={0,1};
+          mcIdType conn[2]={0,1};
           mesh=MEDCouplingUMesh::New("Target mesh Proc3",1);
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
@@ -373,7 +374,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2DCurve()
       if(rank==4)
         {
           double coords[4]={0.75,0.75,1.2,1.2};
-          int conn[2]={0,1};
+          mcIdType conn[2]={0,1};
           mesh=MEDCouplingUMesh::New("Target mesh Proc4",1);
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
@@ -492,10 +493,10 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *ta
 
   MEDCoupling::InterpKernelDEC dec (*source_group,*target_group);
 
-  MEDCoupling::MEDCouplingUMesh* mesh;
-  MEDCoupling::ParaMESH* paramesh;
-  MEDCoupling::ParaFIELD* parafield;
-  ICoCo::MEDField* icocofield ;
+  MEDCoupling::MEDCouplingUMesh* mesh = nullptr;
+  MEDCoupling::ParaMESH* paramesh = nullptr;
+  MEDCoupling::ParaFIELD* parafield = nullptr;
+  ICoCo::MEDDoubleField* icocofield = nullptr;
   
   string filename_xml1              = "square1_split";
   string filename_xml2              = "square2_split";
@@ -541,7 +542,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *ta
         value[ielem]=1.0;
     
       //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
-      icocofield=new ICoCo::MEDField(parafield->getField());
+      icocofield=new ICoCo::MEDDoubleField(parafield->getField());
       dec.setMethod(srcMeth);
       dec.attachLocalField(icocofield);
     }
@@ -577,7 +578,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *ta
       for(int ielem=0; ielem<nb_local;ielem++)
         value[ielem]=0.0;
       //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
-      icocofield=new ICoCo::MEDField(parafield->getField());
+      icocofield=new ICoCo::MEDDoubleField(parafield->getField());
       dec.setMethod(targetMeth);
       dec.attachLocalField(icocofield);
     }
@@ -700,8 +701,8 @@ void ParaMEDMEMTest::testInterpKernelDEC2_2D_(const char *srcMeth, const char *t
 
   MEDCoupling::InterpKernelDEC dec (*source_group,*target_group);
 
-  MEDCoupling::MEDCouplingUMesh* mesh;
-  MEDCoupling::MEDCouplingFieldDouble* mcfield;
+  MEDCoupling::MEDCouplingUMesh* mesh = nullptr;
+  MEDCoupling::MEDCouplingFieldDouble* mcfield = nullptr;
   
   string filename_xml1              = "square1_split";
   string filename_xml2              = "square2_split";
@@ -859,10 +860,10 @@ void ParaMEDMEMTest::testInterpKernelDEC_3D_(const char *srcMeth, const char *ta
 
   MEDCoupling::InterpKernelDEC dec (*source_group,*target_group);
 
-  MEDCoupling::MEDCouplingUMesh* mesh;
-  MEDCoupling::ParaMESH* paramesh;
-  MEDCoupling::ParaFIELD* parafield;
-  ICoCo::MEDField* icocofield ;
+  MEDCoupling::MEDCouplingUMesh* mesh = nullptr;
+  MEDCoupling::ParaMESH* paramesh = nullptr;
+  MEDCoupling::ParaFIELD* parafield = nullptr;
+  ICoCo::MEDDoubleField* icocofield = nullptr;
   
   char * tmp_dir_c                    = getenv("TMP");
   string tmp_dir;
@@ -914,7 +915,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_3D_(const char *srcMeth, const char *ta
         value[ielem]=1.0;
     
       //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
-      icocofield=new ICoCo::MEDField(parafield->getField());
+      icocofield=new ICoCo::MEDDoubleField(parafield->getField());
       dec.setMethod(srcMeth);
       dec.attachLocalField(icocofield);
     }
@@ -950,7 +951,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_3D_(const char *srcMeth, const char *ta
       for(int ielem=0; ielem<nb_local;ielem++)
         value[ielem]=0.0;
       //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
-      icocofield=new ICoCo::MEDField(parafield->getField());
+      icocofield=new ICoCo::MEDDoubleField(parafield->getField());
       dec.setMethod(targetMeth);
       dec.attachLocalField(icocofield);
     }  
@@ -1091,7 +1092,7 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P0()
   const double targetCoordsAll[3][16]={{0.7,1.45,0.7,1.65,0.9,1.65,0.9,1.45,  1.1,1.4,1.1,1.6,1.3,1.6,1.3,1.4},
                                        {0.7,-0.6,0.7,0.7,0.9,0.7,0.9,-0.6,  1.1,-0.7,1.1,0.6,1.3,0.6,1.3,-0.7},
                                        {0.7,-1.55,0.7,-1.35,0.9,-1.35,0.9,-1.55,  1.1,-1.65,1.1,-1.45,1.3,-1.45,1.3,-1.65}};
-  int conn4All[8]={0,1,2,3,4,5,6,7};
+  mcIdType conn4All[8]={0,1,2,3,4,5,6,7};
   double targetResults[3][2]={{34.,34.},{38.333333333333336,42.666666666666664},{47.,47.}};
   double targetResults2[3][2]={{0.28333333333333344,0.56666666666666687},{1.8564102564102569,2.0128205128205132},{1.0846153846153845,0.36153846153846159}};
   double targetResults3[3][2]={{3.7777777777777781,7.5555555555555562},{24.511111111111113,26.355555555555558},{14.1,4.7}};
@@ -1410,7 +1411,7 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0()
       if(rank==0)
         {
           double coords[6]={-0.3,-0.3, 0.7,0.7, 0.7,-0.3};
-          int conn[3]={0,1,2};
+          mcIdType conn[3]={0,1,2};
           //int globalNode[3]={1,2,0};
           mesh=MEDCouplingUMesh::New("Source mesh Proc0",2);
           mesh->allocateCells(1);
@@ -1425,7 +1426,7 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0()
       if(rank==1)
         {
           double coords[6]={-0.3,-0.3, -0.3,0.7, 0.7,0.7};
-          int conn[3]={0,1,2};
+          mcIdType conn[3]={0,1,2};
           //int globalNode[3]={1,3,2};
           mesh=MEDCouplingUMesh::New("Source mesh Proc1",2);
           mesh->allocateCells(1);
@@ -1462,7 +1463,7 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0()
       if(rank==2)
         {
           double coords[10]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2 };
-          int conn[7]={0,3,4,1, 1,4,2};
+          mcIdType conn[7]={0,3,4,1, 1,4,2};
           //int globalNode[5]={4,3,0,2,1};
           mesh=MEDCouplingUMesh::New("Target mesh Proc2",2);
           mesh->allocateCells(2);
@@ -1475,16 +1476,15 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0()
           mesh->setCoords(myCoords);
           myCoords->decrRef();
           paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
-          DataArrayInt *da=DataArrayInt::New();
-          const int globalNumberingP2[5]={0,1,2,3,4};
-          da->useArray(globalNumberingP2,false,DeallocType::CPP_DEALLOC,5,1);
+          std::vector<mcIdType> globalNumberingP2 = {0,1,2,3,4};
+          MCAuto<DataArrayIdType> da=DataArrayIdType::New(); da->alloc(5,1);
+          std::copy(globalNumberingP2.begin(), globalNumberingP2.end(), da->rwBegin());
           paramesh->setNodeGlobal(da);
-          da->decrRef();
         }
       if(rank==3)
         {
           double coords[6]={0.2,0.2, 0.7,-0.3, 0.7,0.2};
-          int conn[3]={0,2,1};
+          mcIdType conn[3]={0,2,1};
           //int globalNode[3]={1,0,5};
           mesh=MEDCouplingUMesh::New("Target mesh Proc3",2);
           mesh->allocateCells(1);
@@ -1496,16 +1496,15 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0()
           mesh->setCoords(myCoords);
           myCoords->decrRef();
           paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
-          DataArrayInt *da=DataArrayInt::New();
-          const int globalNumberingP3[3]={4,2,5};
-          da->useArray(globalNumberingP3,false,DeallocType::CPP_DEALLOC,3,1);
+          std::vector<mcIdType> globalNumberingP3 = {4,2,5};
+          MCAuto<DataArrayIdType> da=DataArrayIdType::New(); da->alloc(3,1);
+          std::copy(globalNumberingP3.begin(), globalNumberingP3.end(), da->rwBegin());
           paramesh->setNodeGlobal(da);
-          da->decrRef();
         }
       if(rank==4)
         {
           double coords[12]={-0.3,0.2, -0.3,0.7, 0.2,0.7, 0.2,0.2, 0.7,0.7, 0.7,0.2};
-          int conn[8]={0,1,2,3, 3,2,4,5};
+          mcIdType conn[8]={0,1,2,3, 3,2,4,5};
           //int globalNode[6]={2,6,7,1,8,5};
           mesh=MEDCouplingUMesh::New("Target mesh Proc4",2);
           mesh->allocateCells(2);
@@ -1518,11 +1517,10 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0()
           mesh->setCoords(myCoords);
           myCoords->decrRef();
           paramesh=new ParaMESH(mesh,*target_group,targetMeshName);
-          DataArrayInt *da=DataArrayInt::New();
-          const int globalNumberingP4[6]={3,6,7,4,8,5};
-          da->useArray(globalNumberingP4,false,DeallocType::CPP_DEALLOC,6,1);
+          std::vector<mcIdType> globalNumberingP4 = {3,6,7,4,8,5};
+          MCAuto<DataArrayIdType> da=DataArrayIdType::New(); da->alloc(6,1);
+          std::copy(globalNumberingP4.begin(), globalNumberingP4.end(), da->rwBegin());
           paramesh->setNodeGlobal(da);
-          da->decrRef();
         }
       MEDCoupling::ComponentTopology comptopo;
       parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
@@ -1636,7 +1634,7 @@ void ParaMEDMEMTest::testInterpKernelDEC2DM1D_P0P0()
       myCoords->decrRef();
       if(rank==0)
         {
-          int targetConn[7]={0,3,4,1, 1,4,2};
+          mcIdType targetConn[7]={0,3,4,1, 1,4,2};
           mesh->allocateCells(2);
           mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
           mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
@@ -1644,7 +1642,7 @@ void ParaMEDMEMTest::testInterpKernelDEC2DM1D_P0P0()
         }
       else
         { 
-          int targetConn[11]={4,5,2, 6,7,4,3, 7,8,5,4};
+          mcIdType targetConn[11]={4,5,2, 6,7,4,3, 7,8,5,4};
           mesh->allocateCells(3);
           mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
           mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+3);
@@ -1869,7 +1867,7 @@ void ParaMEDMEMTest::testInterpKernelDECPartialProcs()
           std::copy(targetCoords,targetCoords+8,myCoords->getPointer());
           mesh->setCoords(myCoords);
           myCoords->decrRef();
-          int targetConn[4]={0,2,3,1};
+          mcIdType targetConn[4]={0,2,3,1};
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
           mesh->finishInsertingCells();
@@ -1894,7 +1892,7 @@ void ParaMEDMEMTest::testInterpKernelDECPartialProcs()
           std::copy(targetCoords,targetCoords+8,myCoords->getPointer());
           mesh->setCoords(myCoords);
           myCoords->decrRef();
-          int targetConn[6]={0,2,1,2,3,1};
+          mcIdType targetConn[6]={0,2,1,2,3,1};
           mesh->allocateCells(2);
           mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
           mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
@@ -1962,7 +1960,7 @@ void ParaMEDMEMTest::testInterpKernelDEC3DSurfEmptyBBox()
   if(source_group->containsMyRank())
     {
       double coords[15]={1.,0.,0., 2.,0.,0., 2.,2.,0., 0.,2.,0., 0.5,0.5,1.};
-      int conn[7]={0,1,2,3,0,3,4};
+      mcIdType conn[7]={0,1,2,3,0,3,4};
       mesh=MEDCouplingUMesh::New("Source mesh Proc0",2);
       mesh->allocateCells(2);
       mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
@@ -1987,7 +1985,7 @@ void ParaMEDMEMTest::testInterpKernelDEC3DSurfEmptyBBox()
       if(rank==1)
         {
           double coords[12]={0.25,0.25,0.5, 0.,0.25,0.5, 0.,0.,0.5, 0.25,0.,0.5};
-          int conn[4]={0,1,2,3};
+          mcIdType conn[4]={0,1,2,3};
           mesh=MEDCouplingUMesh::New("Target mesh Proc1",2);
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
@@ -2002,7 +2000,7 @@ void ParaMEDMEMTest::testInterpKernelDEC3DSurfEmptyBBox()
       if(rank==2)
         {
           double coords[12]={0.,0.25,0.5, 0.,0.,0.5, -1.,0.,0.5, -1.,0.25,0.5};
-          int conn[4]={0,1,2,3};
+          mcIdType conn[4]={0,1,2,3};
           mesh=MEDCouplingUMesh::New("Target mesh Proc2",2);
           mesh->allocateCells(1);
           mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
@@ -2116,11 +2114,10 @@ void ParaMEDMEMTest::testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA
 
   MEDCoupling::InterpKernelDEC dec (*source_group,*target_group);
   
-  MEDCoupling::MEDCouplingUMesh* mesh;
-  MEDCoupling::ParaMESH* paramesh;
-  MEDCoupling::ParaFIELD* parafield;
-  
-  ICoCo::MEDField* icocofield ;
+  MEDCoupling::MEDCouplingUMesh* mesh = nullptr;
+  MEDCoupling::ParaMESH* paramesh = nullptr;
+  MEDCoupling::ParaFIELD* parafield = nullptr;
+  ICoCo::MEDDoubleField* icocofield = nullptr;
 
   char * tmp_dir_c                    = getenv("TMP");
   string tmp_dir;
@@ -2173,7 +2170,7 @@ void ParaMEDMEMTest::testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA
         value[ielem]=0.0;
     
       //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
-      icocofield=new ICoCo::MEDField(parafield->getField());
+      icocofield=new ICoCo::MEDDoubleField(parafield->getField());
      
       dec.attachLocalField(icocofield);
 
@@ -2213,7 +2210,7 @@ void ParaMEDMEMTest::testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA
       for(int ielem=0; ielem<nb_local;ielem++)
         value[ielem]=0.0;
       //      ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
-      icocofield=new ICoCo::MEDField(parafield->getField());
+      icocofield=new ICoCo::MEDDoubleField(parafield->getField());
       
       dec.attachLocalField(icocofield);
     }