-// 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"
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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";
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);
}
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);
}
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";
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;
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);
}
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);
}
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}};
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);
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);
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);
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);
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);
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);
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);
}
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);
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();
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);
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);
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);
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);
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;
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);
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);
}