const MEDFileMeshes *ms=_meshes;
if(ms)
ms->write(fileName,mode);
+ int mode2=mode==2?0:mode;
const MEDFileFields *fs=_fields;
if(fs)
- fs->write(fileName,mode);
+ fs->write(fileName,mode2);
}
return ret0;
}
+/*!
+ * This method retrives all groups that partly or fully appear on the level 'meshDimRelToMaxExt'.
+ */
+std::vector<std::string> MEDFileUMesh::getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ret;
+ std::vector<std::string> allGrps=getGroupsNames();
+ for(std::vector<std::string>::const_iterator it=allGrps.begin();it!=allGrps.end();it++)
+ {
+ std::vector<int> levs=getGrpNonEmptyLevelsExt((*it).c_str());
+ if(std::find(levs.begin(),levs.end(),meshDimRelToMaxExt)!=levs.end())
+ ret.push_back(*it);
+ }
+ return ret;
+}
+
int MEDFileUMesh::getMeshDimension() const throw(INTERP_KERNEL::Exception)
{
int lev=0;
void MEDFileMeshes::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
{
checkCoherency();
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++)
+ int i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++,i++)
{
+ int mode2=mode;
+ if(mode==2 && i>0)
+ mode2=0;
(*it)->copyOptionsFrom(*this);
- (*it)->write(fileName,mode);
+ (*it)->write(fileName,mode2);
}
}
std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getCoords() const;
MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getCoords() const;
MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
self.assertEqual((-1,),m.getFamNonEmptyLevels('A4A3____________________________'))
self.assertEqual((0,),m.getFamNonEmptyLevels('MESH____DALT3___DALLE___________'))
self.assertEqual((0,-1,),m.getFamsNonEmptyLevels(['MESH____DALT3___DALLE___________','A4A3____________________________']))
+ self.assertEqual(('A1A2','A2A4','A3A1','A3C5','A4A3','B1C1','B2B4','B3B1','B4C3','C1C4','C2B2','C3C2','C4B3','C5A4'),m.getGroupsOnSpecifiedLev(-1))
+ self.assertEqual(('DALLE','DALQ1','DALQ2','DALT3','MESH'),m.getGroupsOnSpecifiedLev(0))
#
m.write(fileName,2)
pass
mm.write("Pyfile19_bis.med",2)
ff=MEDFileFieldMultiTS.New("Pyfile19.med","VFieldOnNodes")
ff.write("Pyfile19_bis.med",0)
- self.assertEqual([('tyty', 'mm'), ('uiop', 'MW')],MEDLoader.GetComponentsNamesOfField("Pyfile19_bis.med","VFieldOnNodes"))
+ self.assertEqual([('tyty','mm'),('uiop','MW')],MEDLoader.GetComponentsNamesOfField("Pyfile19_bis.med","VFieldOnNodes"))
pass
#gauss points
fs.pushField(ff1) ; fs.pushField(ff21) ; fs.pushField(ff22)
d.setFields(fs)
#
- d.write(fname,0)
+ fname2="Pyfile29_2.med"
+ d.write(fname2,2)
#
- d2=MEDFileData.New(fname)
+ d2=MEDFileData.New(fname2)
self.assertEqual(2,d2.getNumberOfMeshes())
self.assertEqual(3,d2.getNumberOfFields())
self.assertTrue(isinstance(d2.getMeshes().getMeshAtPos(0),MEDFileUMesh))