From: abn Date: Mon, 28 Sep 2020 11:18:16 +0000 (+0200) Subject: Bug fixes: cartesianize() and WriteFieldOnAlreadyWrittenMesh() X-Git-Tag: V9_6_0a1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8fb7387e351a0bb62b42158ff5cff4d700785ddf;p=tools%2Fmedcoupling.git Bug fixes: cartesianize() and WriteFieldOnAlreadyWrittenMesh() + WriteFieldOnAlreadyWrittenMesh() for MCFieldInt and MCFieldFloat + cartesianize() not doing the job when AX_CART set (should only copy) --- diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 1b5a457a8..2dde24e35 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -1880,6 +1880,7 @@ DataArrayDouble *DataArrayDouble::cartesianize(MEDCouplingAxisType atOfThis) con { case AX_CART: ret=deepCopy(); + break; case AX_CYL: if(nbOfComp==3) { diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 687d0bcbf..d6b21ab7c 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -1799,22 +1799,28 @@ void MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, if(!f) throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMesh : input field is null !"); { - const MEDCoupling::MEDCouplingFieldDouble *f1(dynamic_cast(f)); - if(f1) - WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); - return ; + const MEDCoupling::MEDCouplingFieldDouble *f1(dynamic_cast(f)); + if(f1) + { + WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); + return ; + } } { const MEDCoupling::MEDCouplingFieldInt32 *f1(dynamic_cast(f)); if(f1) - WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); - return ; + { + WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); + return ; + } } { const MEDCoupling::MEDCouplingFieldFloat *f1(dynamic_cast(f)); if(f1) - WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); - return ; + { + WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); + return ; + } } throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMesh : input field is not in FLOAT32, FLOAT64, INT32 !"); } diff --git a/src/MEDLoader/Swig/MEDLoaderDataForTest.py b/src/MEDLoader/Swig/MEDLoaderDataForTest.py index e3ac58446..3fd2f7b38 100644 --- a/src/MEDLoader/Swig/MEDLoaderDataForTest.py +++ b/src/MEDLoader/Swig/MEDLoaderDataForTest.py @@ -34,6 +34,7 @@ def WriteInTmpDir(func): return decaratedFunc class MEDLoaderDataForTest: + @classmethod def build1DMesh_1(cls): coords=[ 0.0, 0.3, 0.75, 1.0, 1.4, 1.3 ] conn=[ 0,1, 1,2, 2,3 , 3,4,5] @@ -52,6 +53,7 @@ class MEDLoaderDataForTest: mesh.setCoords(myCoords); return mesh; + @classmethod def build2DCurveMesh_1(cls): coords=[ 0.0,0.0, 0.3,0.3, 0.75,0.75, 1.0,1.0, 1.4,1.4, 1.3,1.3 ] conn=[ 0,1, 1,2, 2,3 , 3,4,5] @@ -69,6 +71,7 @@ class MEDLoaderDataForTest: mesh.setCoords(myCoords); return mesh; + @classmethod def build2DMesh_1(cls): targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, -0.05,0.95, 0.2,1.2, 0.45,0.95] @@ -91,6 +94,7 @@ class MEDLoaderDataForTest: targetMesh.setCoords(myCoords) return targetMesh; + @classmethod def build2DMesh_2(cls): targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, -0.05,0.95, 0.2,1.2, 0.45,0.95] @@ -113,6 +117,7 @@ class MEDLoaderDataForTest: return targetMesh; #this mesh has several cells duplicated ! it is not beautiful but efficient to test file WR. + @classmethod def build2DMesh_3(cls): targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, -0.05,0.95, 0.2,1.2, 0.45,0.95] @@ -142,6 +147,7 @@ class MEDLoaderDataForTest: targetMesh.setCoords(myCoords); return targetMesh; + @classmethod def build3DMesh_1(cls): coords=[0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0., 3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0., @@ -203,7 +209,8 @@ class MEDLoaderDataForTest: myCoords.setInfoOnComponent(2,"t [kW]"); ret.setCoords(myCoords); return ret; - + + @classmethod def build3DSurfMesh_1(cls): targetCoords=[-0.3,-0.3,-0.3, 0.2,-0.3,-0.3, 0.7,-0.3,-0.3, -0.3,0.2,-0.3, 0.2,0.2,-0.3, 0.7,0.2,-0.3, -0.3,0.7,-0.3, 0.2,0.7,-0.3, 0.7,0.7,-0.3 ,-0.05,0.95,-0.3, 0.2,1.2,-0.3, 0.45,0.95,-0.3] @@ -225,7 +232,8 @@ class MEDLoaderDataForTest: myCoords.setInfoOnComponent(2,"ff [km]");#component 1 is not set for test targetMesh.setCoords(myCoords); return targetMesh; - + + @classmethod def build3DMesh_2(cls): m3dsurfBase=MEDLoaderDataForTest.build3DSurfMesh_1(); numbers=[0,1,2,3,5] @@ -240,6 +248,7 @@ class MEDLoaderDataForTest: ret=m3dsurf.buildExtrudedMesh(m1d,0); return ret; + @classmethod def buildMultiLevelMesh_1(cls): coo=[10.,0.,10.,1.25,10.,2.5,10.,3.75,10.,5.,8.75,0.,8.75,1.25,8.75,2.5,8.75,3.75,8.75,5.,7.5,0.,7.5,1.25,7.5,2.5,7.5,3.75,7.5,5.,6.25,0.,6.25,1.25,6.25,2.5,6.25,3.75,6.25,5.,5.,0.,5.,1.25,5.,2.5,5.,3.75,5.,5.,3.75,0.,3.75,1.25,3.75,2.5,3.75,3.75,3.75,5.,2.5,0.,2.5,1.25,2.5,2.5,2.5,3.75,2.5,5.,1.25,0.,1.25,1.25,1.25,2.5,1.25,3.75,1.25,5.,0.,1.25,0.,2.5,0.,3.75,0.,5.,0.,0.,0.,5.,10.,5.,0.,10.,10.,10.,5.,5.,5.,5.,5.,10.,5.,10.,0.625,5.,1.25,5.,1.875,5.,2.5,5.,3.125,5.,3.75,5.,4.375,5.,5.,6.25,5.,7.5,5.,8.75,4.375,10.,3.75,10.,3.125,10.,2.5,10.,1.875,10.,1.25,10.,0.625,10.,0.,8.75,0.,7.5,0.,6.25,4.375,6.25,4.375,7.5,4.375,8.75,3.75,6.25,3.75,7.5,3.75,8.75,3.125,6.25,3.125,7.5,3.125,8.75,2.5,6.25,2.5,7.5,2.5,8.75,1.875,6.25,1.875,7.5,1.875,8.75,1.25,6.25,1.25,7.5,1.25,8.75,0.625,6.25,0.625,7.5,0.625,8.75,5.625,5.,6.25,5.,6.875,5.,7.5,5.,8.125,5.,8.75,5.,9.375,5.,10.,6.25,10.,7.5,10.,8.75,9.375,10.,8.75,10.,8.125,10.,7.5,10.,6.875,10.,6.25,10.,5.625,10.,5.,8.75,5.,7.5,5.,6.25,9.375,6.25,9.375,7.5,9.375,8.75,8.75,6.25,8.75,7.5,8.75,8.75,8.125,6.25,8.125,7.5,8.125,8.75,7.5,6.25,7.5,7.5,7.5,8.75,6.875,6.25,6.875,7.5,6.875,8.75,6.25,6.25,6.25,7.5,6.25,8.75,5.625,6.25,5.625,7.5,5.625,8.75] coo2=DataArrayDouble.New() @@ -325,6 +334,7 @@ class MEDLoaderDataForTest: famIdsPerGrp=[[5],[-11],[1],[-8],[4],[-10],[-12],[2],[-9],[-4],[-5],[-6],[-7],[-4,-5,-6,-7],[6],[-14],[7],[-19],[8],[-17],[9],[-20],[10],[-15],[11],[-18],[12],[-21],[13],[-16],[3],[-13],[-3,-2,-1],[-3],[-2],[-1],[-4,-5,-6,-7,-3,-2,-1],[3]] return m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp + @classmethod def buildMLMeshUnPolyze(cls,tester): """Level 0 (meshDim=3) - 2 TETRA4 + 3 PENTA6 + 2 POLYH # POLYH #0 becomes 1 TETRA4 @@ -343,7 +353,7 @@ class MEDLoaderDataForTest: pass mesh0.finishInsertingCells() mesh0.setCoords(coords) - + meshM1=MEDCouplingUMesh(meshName,2) typeM1=[NORM_TRI3,NORM_TRI3, NORM_QUAD4,NORM_QUAD4,NORM_QUAD4, NORM_POLYGON,NORM_POLYGON,NORM_POLYGON,NORM_POLYGON] connM1=[[0,1,2],[3,4,5], [6,7,8,9],[10,11,12,13],[14,15,16,17], [18,19,20,21,22],[23,24,25,26,27],[28,29,30],[31,32,33,34,35,36,37]] @@ -380,6 +390,7 @@ class MEDLoaderDataForTest: da=DataArrayInt.New(mm.getNumberOfNodes()) ; da.iota(8) ; mm.setRenumFieldArr(1,da) return mm + @classmethod def buildVecFieldOnCells_1(cls): mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); nbOfCells=mesh.getNumberOfCells(); @@ -393,11 +404,43 @@ class MEDLoaderDataForTest: array.setInfoOnComponent(1,"density [g/cm^3]"); array.setInfoOnComponent(2,"temperature [K]"); f1.setArray(array); - tmp=array.getPointer(); f1.setTime(2.,0,1); f1.checkConsistencyLight(); return f1; + @classmethod + def buildIntVecFieldOnCells_1(cls): + mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); + nbOfCells=mesh.getNumberOfCells(); + f1=MEDCouplingFieldInt.New(ON_CELLS,ONE_TIME); + f1.setName("IntVectorFieldOnCells"); + f1.setMesh(mesh); + array=DataArrayInt([0,10,20,1,11,21,2,12,22,3,13,23,4,14,24,5,15,25],nbOfCells ,3) + array.setInfoOnComponent(0,"va1 [MW/m^3]"); + array.setInfoOnComponent(1,"va2 [g/cm^3]"); + array.setInfoOnComponent(2,"val3 [K]"); + f1.setArray(array); + f1.setTime(2.,0,1); + f1.checkConsistencyLight(); + return f1; + + @classmethod + def buildFloatVecFieldOnCells_1(cls): + mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); + nbOfCells=mesh.getNumberOfCells(); + f1=MEDCouplingFieldFloat.New(ON_CELLS,ONE_TIME); + f1.setName("FloatVectorFieldOnCells"); + f1.setMesh(mesh); + array=DataArrayFloat([0.,10.,20.,1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.], nbOfCells, 3); + array.setInfoOnComponent(0,"power [MW/m^3]"); + array.setInfoOnComponent(1,"density [g/cm^3]"); + array.setInfoOnComponent(2,"temperature [K]"); + f1.setArray(array); + f1.setTime(2.,0,1); + f1.checkConsistencyLight(); + return f1; + + @classmethod def buildVecFieldOnNodes_1(cls): mesh=MEDLoaderDataForTest.build3DSurfMesh_1(); nbOfNodes=mesh.getNumberOfNodes(); @@ -416,6 +459,7 @@ class MEDLoaderDataForTest: f1.checkConsistencyLight(); return f1; + @classmethod def buildVecFieldOnGauss_1(cls): _a=0.446948490915965; _b=0.091576213509771; @@ -458,6 +502,7 @@ class MEDLoaderDataForTest: f.checkConsistencyLight(); return f; + @classmethod def buildVecFieldOnGauss_2(cls): _a=0.446948490915965; _b=0.091576213509771; @@ -508,6 +553,7 @@ class MEDLoaderDataForTest: return f; # idem buildVecFieldOnGauss_2 except that different discretizations are sorted inside one type + @classmethod def buildVecFieldOnGauss_2_Simpler(cls): _a=0.446948490915965; _b=0.091576213509771; @@ -557,6 +603,7 @@ class MEDLoaderDataForTest: f.checkConsistencyLight(); return f; + @classmethod def buildVecFieldOnGaussNE_1(cls): m=MEDLoaderDataForTest.build2DMesh_2(); f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME); @@ -573,6 +620,7 @@ class MEDLoaderDataForTest: f.checkConsistencyLight(); return f; + @classmethod def buildACompleteMEDDataStructureWithFieldsOnCells_1(cls): coo=DataArrayDouble([0,0,1,0,2,0,0,1,1,1,2,1,0,2,1,2,2,2],9,2) m0=MEDCouplingUMesh("mesh",2) @@ -669,6 +717,7 @@ class MEDLoaderDataForTest: data=MEDFileData() ; data.setMeshes(ms) ; data.setFields(fs) return data + @classmethod def buildAMEDFileDataWithGroupOnOneFamilyForSauv(self): # Coordinates coords = [0.,0., 0.,1., 1.,1., 1.,0.] @@ -717,25 +766,7 @@ class MEDLoaderDataForTest: mfd.setMeshes(ms) # return mfd - - build1DMesh_1=classmethod(build1DMesh_1) - build2DCurveMesh_1=classmethod(build2DCurveMesh_1) - build2DMesh_1=classmethod(build2DMesh_1) - build2DMesh_2=classmethod(build2DMesh_2) - build2DMesh_3=classmethod(build2DMesh_3) - build3DMesh_1=classmethod(build3DMesh_1) - build3DSurfMesh_1=classmethod(build3DSurfMesh_1) - build3DMesh_2=classmethod(build3DMesh_2) - buildMLMeshUnPolyze=classmethod(buildMLMeshUnPolyze) - buildMultiLevelMesh_1=classmethod(buildMultiLevelMesh_1) - buildVecFieldOnCells_1=classmethod(buildVecFieldOnCells_1) - buildVecFieldOnNodes_1=classmethod(buildVecFieldOnNodes_1) - buildVecFieldOnGauss_1=classmethod(buildVecFieldOnGauss_1) - buildVecFieldOnGauss_2=classmethod(buildVecFieldOnGauss_2) - buildVecFieldOnGauss_2_Simpler=classmethod(buildVecFieldOnGauss_2_Simpler) - buildVecFieldOnGaussNE_1=classmethod(buildVecFieldOnGaussNE_1) - buildACompleteMEDDataStructureWithFieldsOnCells_1=classmethod(buildACompleteMEDDataStructureWithFieldsOnCells_1) - buildAMEDFileDataWithGroupOnOneFamilyForSauv=classmethod(buildAMEDFileDataWithGroupOnOneFamilyForSauv) + pass def TestWriteUMeshesRW1(tester): @@ -858,7 +889,7 @@ def GeneratePyfile18(tester): WriteFieldUsingAlreadyWrittenMesh(fileName,f1); f2=ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7); tester.assertTrue(f2.isEqual(f1,1e-12,1e-12)); - + def GeneratePyfile19(tester): fileName="Pyfile19.med"; fileName2="Pyfile20.med"; diff --git a/src/MEDLoader/Swig/MEDLoaderTest1.py b/src/MEDLoader/Swig/MEDLoaderTest1.py index 04f5c953f..41455fb3c 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest1.py +++ b/src/MEDLoader/Swig/MEDLoaderTest1.py @@ -82,13 +82,20 @@ class MEDLoaderTest1(unittest.TestCase): VAL1=12345.67890314; VAL2=-1111111111111.; f1=MEDLoaderDataForTest.buildVecFieldOnCells_1(); + f1_int=MEDLoaderDataForTest.buildIntVecFieldOnCells_1(); + f1_fl=MEDLoaderDataForTest.buildFloatVecFieldOnCells_1(); MEDLoader.WriteField(fileName,f1,True); f1.setTime(10.,8,9); + f1_int.setTime(10.,8,9); + f1_fl.setTime(10.,8,9); f1.getArray().setIJ(0,0,VAL1); MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); f1.setTime(10.14,18,19); f1.getArray().setIJ(0,0,VAL2); MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1); + # Write int and float fields: + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1_int); + MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1_fl); #retrieving time steps... f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9); f1.setTime(10.,8,9); @@ -103,6 +110,11 @@ class MEDLoaderTest1(unittest.TestCase): self.assertTrue(f1.isEqual(f2,1e-12,1e-12)); #test of throw on invalid (dt,it) self.assertRaises(Exception,MEDLoader.ReadFieldCell,fileName,f1.getMesh().getName(),0,f1.getName(),28,19); + # Reading Int and Float fields: + f2_int=MEDLoader.ReadFieldCell(fileName,f1_int.getMesh().getName(),0,f1_int.getName(),8,9); + self.assertTrue(f1_int.isEqual(f2_int,1e-12,0)); # exact comparison here + f2_fl=MEDLoader.ReadFieldCell(fileName,f1_fl.getMesh().getName(),0,f1_fl.getName(),8,9); + self.assertTrue(f1_fl.isEqual(f2_fl,1e-12,1e-12)); #ON NODES f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1(); fileName2="Pyfile9.med"; diff --git a/src/MEDLoader/Test/MEDLoaderTest.cxx b/src/MEDLoader/Test/MEDLoaderTest.cxx index 39129611f..617cc51db 100644 --- a/src/MEDLoader/Test/MEDLoaderTest.cxx +++ b/src/MEDLoader/Test/MEDLoaderTest.cxx @@ -23,6 +23,8 @@ #include "MEDLoaderBase.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldInt.hxx" +#include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingMemArray.hxx" #include "TestInterpKernelUtils.hxx" // getResourceFile() @@ -118,14 +120,21 @@ void MEDLoaderTest::testFieldRW2() static const double VAL1=12345.67890314; static const double VAL2=-1111111111111.; MEDCouplingFieldDouble *f1=buildVecFieldOnCells_1(); + MEDCouplingFieldInt *f1_int=buildIntVecFieldOnCells_1(); + MEDCouplingFieldFloat *f1_fl=buildFloatVecFieldOnCells_1(); WriteField(fileName,f1,true); f1->setTime(10.,8,9); + f1_int->setTime(10.,8,9); + f1_fl->setTime(10.,8,9); double *tmp=f1->getArray()->getPointer(); tmp[0]=VAL1; WriteFieldUsingAlreadyWrittenMesh(fileName,f1); f1->setTime(10.14,18,19); tmp[0]=VAL2; WriteFieldUsingAlreadyWrittenMesh(fileName,f1); + // Write int and float fields: + WriteFieldUsingAlreadyWrittenMesh(fileName,f1_int); + WriteFieldUsingAlreadyWrittenMesh(fileName,f1_fl); //retrieving time steps... MEDCouplingFieldDouble *f2=dynamic_cast(ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),8,9)); f1->setTime(10.,8,9); @@ -145,6 +154,13 @@ void MEDLoaderTest::testFieldRW2() CPPUNIT_ASSERT_THROW(ReadFieldCell(fileName,f1->getMesh()->getName().c_str(),0,f1->getName().c_str(),28,19),INTERP_KERNEL::Exception); f2->decrRef(); f1->decrRef(); + // Reading Int and Float fields: + MEDCouplingFieldInt *f2_int=dynamic_cast(ReadFieldCell(fileName,f1_int->getMesh()->getName().c_str(),0,f1_int->getName().c_str(),8,9)); + CPPUNIT_ASSERT(f1_int->isEqual(f2_int,1e-12,0)); // exact equality for int values + f2_int->decrRef(); + MEDCouplingFieldFloat *f2_fl=dynamic_cast(ReadFieldCell(fileName,f1_fl->getMesh()->getName().c_str(),0,f1_fl->getName().c_str(),8,9)); + CPPUNIT_ASSERT(f1_fl->isEqual(f2_fl,1e-12,1e-12)); + f2_fl->decrRef(); //ON NODES f1=buildVecFieldOnNodes_1(); const char fileName2[]="file9.med"; @@ -175,7 +191,7 @@ void MEDLoaderTest::testFieldRW2() } /*! - * Multi field in a same file, but this field has several + * Multi field in a same file, but this field has several timesteps */ void MEDLoaderTest::testFieldRW3() { @@ -1385,6 +1401,53 @@ MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnCells_1() return f1; } +MEDCouplingFieldInt *MEDLoaderTest::buildIntVecFieldOnCells_1() +{ + MEDCouplingUMesh *mesh=build3DSurfMesh_1(); + mcIdType nbOfCells=mesh->getNumberOfCells(); + MEDCouplingFieldInt *f1=MEDCouplingFieldInt::New(ON_CELLS,ONE_TIME); + f1->setName("IntVectorFieldOnCells"); + f1->setMesh(mesh); + DataArrayInt *array=DataArrayInt::New(); + array->alloc(nbOfCells,3); + array->setInfoOnComponent(0,"val1 [MW/m^3]"); + array->setInfoOnComponent(1,"va2 [g/cm^3]"); + array->setInfoOnComponent(2,"val3 [K]"); + f1->setArray(array); + array->decrRef(); + mcIdType *tmp=array->getPointer(); + const mcIdType arr1[18]={0,10,20,1,11,21,2,12,22,3,13,23,4,14,24,5,15,25}; + std::copy(arr1,arr1+18,tmp); + f1->setTime(2.,0,1); + f1->checkConsistencyLight(); + mesh->decrRef(); + return f1; +} + +MEDCouplingFieldFloat *MEDLoaderTest::buildFloatVecFieldOnCells_1() +{ + MEDCouplingUMesh *mesh=build3DSurfMesh_1(); + mcIdType nbOfCells=mesh->getNumberOfCells(); + MEDCouplingFieldFloat *f1=MEDCouplingFieldFloat::New(ON_CELLS,ONE_TIME); + f1->setName("FloatVectorFieldOnCells"); + f1->setMesh(mesh); + DataArrayFloat *array=DataArrayFloat::New(); + array->alloc(nbOfCells,3); + array->setInfoOnComponent(0,"power [MW/m^3]"); + array->setInfoOnComponent(1,"density [g/cm^3]"); + array->setInfoOnComponent(2,"temperature [K]"); + f1->setArray(array); + array->decrRef(); + float *tmp=array->getPointer(); + const float arr1[18]={0.,10.,20.,1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.}; + std::copy(arr1,arr1+18,tmp); + f1->setTime(2.,0,1); + f1->checkConsistencyLight(); + mesh->decrRef(); + return f1; +} + + MEDCouplingFieldDouble *MEDLoaderTest::buildVecFieldOnNodes_1() { MEDCouplingUMesh *mesh=build3DSurfMesh_1(); diff --git a/src/MEDLoader/Test/MEDLoaderTest.hxx b/src/MEDLoader/Test/MEDLoaderTest.hxx index 64c87e221..dac756d61 100644 --- a/src/MEDLoader/Test/MEDLoaderTest.hxx +++ b/src/MEDLoader/Test/MEDLoaderTest.hxx @@ -27,6 +27,8 @@ namespace MEDCoupling { class MEDCouplingUMesh; class MEDCouplingFieldDouble; + class MEDCouplingFieldInt; + class MEDCouplingFieldFloat; class MEDLoaderTest : public CppUnit::TestFixture { @@ -96,6 +98,8 @@ namespace MEDCoupling MEDCouplingUMesh *build3DMesh_1(); MEDCouplingUMesh *build3DMesh_2(); MEDCouplingFieldDouble *buildVecFieldOnCells_1(); + MEDCouplingFieldInt *buildIntVecFieldOnCells_1(); + MEDCouplingFieldFloat *buildFloatVecFieldOnCells_1(); MEDCouplingFieldDouble *buildVecFieldOnNodes_1(); MEDCouplingFieldDouble *buildVecFieldOnGauss_1(); MEDCouplingFieldDouble *buildVecFieldOnGaussNE_1();