# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2015 CEA/DEN, EDF R&D
+# Copyright (C) 2007-2016 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
""" Converting MED file format in memory to a the Case file format (Ensight).
A new file with the same base name and the .case extension is created with its depencies (.geo ...).
"""
-
+
header="""FORMAT
type: ensight gold
GEOMETRY
time values:
%(TimeValues)s
"""
-
+
@classmethod
def New(cls):
""" Static constructor. """
assert(isinstance(status,bool))
self.__export_groups=status
pass
-
+
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
-
+
def __writeMeshesPart(self,mdm,meshfn):
try:
os.remove(meshfn)
assert(isinstance(mdm,MEDFileUMesh))
ms2=[[mdm.getMeshAtLevel(lev) for lev in mdm.getNonEmptyLevels()[:1]]]
if self.__export_groups:
- for grpnm in mdm.getGroupsNames():
+ for grpnm in mdm.getGroupsNames():
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"))
- mm.write(self.__str80("Exported from MEDCoupling/MEDLoader SALOME version %s"%(MEDCouplingVersionStr())))
+ mm.write(self.__str80("Exported from MEDCoupling/MEDLoader version %s"%(MEDCouplingVersionStr())))
mm.write(self.__str80("Conversion using CaseWriter class"))
mm.write(self.__str80("node id off"))
mm.write(self.__str80("element id off"))
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.getNodalConnectivity()[:] ; c.pushBackSilent(-1) ; c[mp.getNodalConnectivityIndex()[:-1]]=-1 ; ids=c.getIdsEqual(-1) ; nbOfNodesPerFace=ids.deltaShiftIndex()-1
+ c=mp.getNodalConnectivity()[:] ; c.pushBackSilent(-1) ; c[mp.getNodalConnectivityIndex()[:-1]]=-1 ; ids=c.findIdsEqual(-1) ; nbOfNodesPerFace=ids.deltaShiftIndex()-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)
pass
pass
pass
-
+
def __writeFieldsPart(self,mdfs):
if not mdfs:
return ""
headerPart+=htp
pass
return headerPart
-
+
@classmethod
def __str80(cls,st):
if len(st)>79:
raise Exception("String \"%s\" is too long (>79) !"%(st))
return st.ljust(79)+"\n"
-
+
def __computeSizeOfGeoFile(self,listOfMeshes,nn):
sz=0
for m in listOfMeshes: