#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
class CaseWriter(CaseIO):
""" Converting MED file format in memory to a the Case file format (Ensight).
class CaseWriter(CaseIO):
""" Converting MED file format in memory to a the Case file format (Ensight).
assert(isinstance(status,bool))
self.__export_groups=status
pass
assert(isinstance(status,bool))
self.__export_groups=status
pass
def write(self,fileName):
""" Write into the specified fileName series the result """
def write(self,fileName):
""" Write into the specified fileName series the result """
self._real_written_file_name.append(realWrittenCaseFileNameForCurMesh)
pass
return self._real_written_file_name
self._real_written_file_name.append(realWrittenCaseFileNameForCurMesh)
pass
return self._real_written_file_name
assert(isinstance(mdm,MEDFileUMesh))
ms2=[[mdm.getMeshAtLevel(lev) for lev in mdm.getNonEmptyLevels()[:1]]]
if self.__export_groups:
assert(isinstance(mdm,MEDFileUMesh))
ms2=[[mdm.getMeshAtLevel(lev) for lev in mdm.getNonEmptyLevels()[:1]]]
if self.__export_groups:
ms3=[]
for lev in mdm.getGrpNonEmptyLevels(grpnm)[:1]:
m=mdm.getGroup(lev,grpnm) ; m.zipCoords()
ms3=[]
for lev in mdm.getGrpNonEmptyLevels(grpnm)[:1]:
m=mdm.getGroup(lev,grpnm) ; m.zipCoords()
a=np.memmap(f,dtype='byte',mode='w+',offset=0,shape=(sz,)) ; a.flush() # truncate to set the size of the file
mm=mmap.mmap(f.fileno(),offset=0,length=0)
mm.write(self.__str80("C Binary"))
a=np.memmap(f,dtype='byte',mode='w+',offset=0,shape=(sz,)) ; a.flush() # truncate to set the size of the file
mm=mmap.mmap(f.fileno(),offset=0,length=0)
mm.write(self.__str80("C Binary"))
mm.write(self.__str80("Conversion using CaseWriter class"))
mm.write(self.__str80("node id off"))
mm.write(self.__str80("element id off"))
mm.write(self.__str80("Conversion using CaseWriter class"))
mm.write(self.__str80("node id off"))
mm.write(self.__str80("element id off"))
a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(1,))
a[0]=nbelem ; a.flush() ; mm.seek(mm.tell()+4)
if typ!=NORM_POLYHED and typ!=NORM_POLYGON:
a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(1,))
a[0]=nbelem ; a.flush() ; mm.seek(mm.tell()+4)
if typ!=NORM_POLYHED and typ!=NORM_POLYGON:
c=mp.computeNbOfFacesPerCell()
a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(nbelem,))
a[:]=c.toNumPyArray(); a.flush() ; mm.seek(mm.tell()+nbelem*4)
c=mp.computeNbOfFacesPerCell()
a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(nbelem,))
a[:]=c.toNumPyArray(); a.flush() ; mm.seek(mm.tell()+nbelem*4)
a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(len(nbOfNodesPerFace),))
a[:]=nbOfNodesPerFace.toNumPyArray() ; a.flush() ; mm.seek(mm.tell()+len(nbOfNodesPerFace)*4)
ids2=ids.buildComplement(ids.back()+1)
a=np.memmap(f,dtype='int32',mode='w+',offset=mm.tell(),shape=(len(nbOfNodesPerFace),))
a[:]=nbOfNodesPerFace.toNumPyArray() ; a.flush() ; mm.seek(mm.tell()+len(nbOfNodesPerFace)*4)
ids2=ids.buildComplement(ids.back()+1)
def __writeFieldsPart(self,mdfs):
if not mdfs:
return ""
self._ze_top_dict={}
its,areForgottenTS=mdfs.getCommonIterations()
if areForgottenTS:
def __writeFieldsPart(self,mdfs):
if not mdfs:
return ""
self._ze_top_dict={}
its,areForgottenTS=mdfs.getCommonIterations()
if areForgottenTS:
- print "Field \"%s\" will be ignored because number of components (%i) is too big to be %s supported by case files !"%(mdf.getName(),nbCompo,str(self.dictCompo.keys()))
+ print(("Field \"%s\" will be ignored because number of components (%i) is too big to be %s supported by case files !"%(mdf.getName(),nbCompo,str(list(self.dictCompo.keys())))))
- print "WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(self.dictCompo.keys()))
+ print(("WARNING : Field \"%s\" will have its number of components (%i) set to %i, in order to be supported by case files (must be in %s) !"%(mdf.getName(),nbCompo,l[0],str(list(self.dictCompo.keys())))))
pass
a=np.memmap(f,dtype='float32',mode='w+',offset=mm.tell(),shape=(nbCompo,end-bg))
b=arr.toNumPyArray() ; b=b.reshape(nbCompo,end-bg)
pass
a=np.memmap(f,dtype='float32',mode='w+',offset=mm.tell(),shape=(nbCompo,end-bg))
b=arr.toNumPyArray() ; b=b.reshape(nbCompo,end-bg)