From: Anthony Geay Date: Tue, 19 Jan 2016 10:42:45 +0000 (+0100) Subject: MEDFile 3.2.0 porting to support CYL and SPHER. X-Git-Tag: V8_0_0b1~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f2494a83efd03107a558640c7ece7773cb06dfea;p=tools%2Fmedcoupling.git MEDFile 3.2.0 porting to support CYL and SPHER. --- diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 66cad4ba0..c5c9f58d0 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -6181,7 +6181,7 @@ void MEDFileCMesh::loadLL(med_idt fid, const std::string& mName, int dt, int it, } MEDFileCMeshL2 loaderl2; loaderl2.loadAll(fid,mid,mName,dt,it); - setAxType(loaderl2.getAxType()); + setAxType(axType); MEDCouplingCMesh *mesh=loaderl2.getMesh(); mesh->incrRef(); _cmesh=mesh; @@ -6260,8 +6260,7 @@ void MEDFileCMesh::writeLL(med_idt fid) const MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo } - // MED_CARTESIAN and not MEDFileMeshL2::TraduceAxisTypeRev(getAxType()) ! Yes it is not a bug. The discrimination is done in MEDmeshGridTypeWr. - MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,spaceDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MED_CARTESIAN,comp,unit)); + MEDFILESAFECALLERWR0(MEDmeshCr,(fid,maa,spaceDim,spaceDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MEDFileMeshL2::TraduceAxisTypeRev(getAxType()),comp,unit)); if(_univ_wr_status) MEDFILESAFECALLERWR0(MEDmeshUniversalNameWr,(fid,maa)); MEDFILESAFECALLERWR0(MEDmeshGridTypeWr,(fid,maa,MEDFileMeshL2::TraduceAxisTypeRevStruct(getAxType()))); diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index 25ad1fd53..ff1afac61 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -75,8 +75,7 @@ int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, Para int naxis(MEDmeshnAxis(fid,i+1)); INTERP_KERNEL::AutoPtr axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); INTERP_KERNEL::AutoPtr axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE); - MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit)); - + MEDFILESAFECALLERRD0(MEDmeshInfo,(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit)); dtunit1=MEDLoaderBase::buildStringFromFortran(dtunit,sizeof(dtunit)); std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa)); ms.push_back(cur); @@ -433,8 +432,10 @@ med_grid_type MEDFileMeshL2::TraduceAxisTypeRevStruct(ParaMEDMEM::MEDCouplingAxi return MED_CARTESIAN_GRID; case AX_CYL: return MED_POLAR_GRID; + case AX_SPHER: + return MED_POLAR_GRID; default: - throw INTERP_KERNEL::Exception("MEDFileMeshL2::TraduceAxisTypeRevStruct : only Cartesian and Cylindrical supported by MED file !"); + throw INTERP_KERNEL::Exception("MEDFileMeshL2::TraduceAxisTypeRevStruct : unrecognized axis type !"); } } diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 852f8ca69..58932a087 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -5134,8 +5134,11 @@ class MEDLoaderTest4(unittest.TestCase): # ms=MEDFileMeshes() ; ms.pushMesh(mm) fields=MEDFileFields() ; fields.pushField(fmts) - #ms.write(fname,2) ; fields.write(fname,0) - # WARNING for the moment we do not reread fname ! It is not a hidden bug it is just to wait EF control. Coming soon. + ms.write(fname,2) ; fields.write(fname,0) + # + del mm,fmts,fields,ms + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) ms.cartesianizeMe() # fields.removeFieldsWithoutAnyTimeStep() @@ -5180,7 +5183,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(v.isEqual(DataArrayDouble([0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.0,2.1,2.2,2.3]),1e-14)) pass pass - + def test38(self): """ Introduction of non cartesian meshes management. Here spherical.""" fname="ForMEDReader38.med" @@ -5200,8 +5203,11 @@ class MEDLoaderTest4(unittest.TestCase): # ms=MEDFileMeshes() ; ms.pushMesh(mm) fields=MEDFileFields() ; fields.pushField(fmts) - #ms.write(fname,2) ; fields.write(fname,0) - # WARNING for the moment we do not reread fname ! It is not a hidden bug it is just to wait EF control. Coming soon. + ms.write(fname,2) ; fields.write(fname,0) + # + del mm,fmts,fields,ms + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) ms.cartesianizeMe() # fields.removeFieldsWithoutAnyTimeStep() @@ -5268,6 +5274,10 @@ class MEDLoaderTest4(unittest.TestCase): fields=MEDFileFields() ; fields.pushField(fmts) ms.write(fname,2) ; fields.write(fname,0) # + del mm,fmts,fields,ms + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + # ms=MEDFileMeshes(fname) ; ms.cartesianizeMe() fields=MEDFileFields(fname,False) fields.removeFieldsWithoutAnyTimeStep()