# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2016 CEA/DEN, EDF R&D
+# Copyright (C) 2007-2022 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
# http://www-vis.lbl.gov/NERSC/Software/ensight/doc/OnlineHelp/UM-C11.pdf
import numpy as np
-from MEDLoader import *
+from medcoupling import *
from CaseIO import CaseIO
import sys,re,os
def __traduceMesh(self,name,typ,coords,cells):
""" Convert a CASE mesh into a MEDCouplingUMesh. """
+ name = name.decode("ascii")
nbCoords=len(coords)
coo=np.array(coords,dtype="float64") ; coo=coo.reshape(nbCoords,3)
coo=DataArrayDouble(coo) ; coo=coo.fromNoInterlace()
ct=self.dictMCTyp2[typ]
- m=MEDCouplingUMesh(str(name),MEDCouplingUMesh.GetDimensionOfGeometricType(ct))
+ m=MEDCouplingUMesh(name,MEDCouplingUMesh.GetDimensionOfGeometricType(ct))
m.setCoords(coo)
nbNodesPerCell=MEDCouplingMesh.GetNumberOfNodesOfGeometricType(ct)
cI=DataArrayInt(len(cells)+1) ; cI.iota() ; cI*=nbNodesPerCell+1
#
cells2=cells.reshape(len(cells),nbNodesPerCell)
- if cells2.dtype=='int32':
- c2=DataArrayInt(cells2)
- else:
- c2=DataArrayInt(np.array(cells2,dtype="int32"))
- pass
+ c2=DataArrayInt(np.array(cells2,dtype="int{}".format(MEDCouplingSizeOfIDs())) )
c=DataArrayInt(len(cells),nbNodesPerCell+1) ; c[:,0]=ct ; c[:,1:]=c2-1 ; c.rearrange(1)
m.setConnectivity(c,cI,True)
m.checkConsistency()
typ=fd.read(80).strip() ; pos=fd.tell()
mcmeshes2=[]
while pos!=end and typ!=b"part":
- if typ[0]=='\0': pos+=1; continue
+ if typ[0]==0: pos+=1; continue
mctyp=self.dictMCTyp2[typ]
nbCellsOfType=np.memmap(fd,dtype='int32',mode='r',offset=int(pos),shape=(1,)).tolist()[0]
pos+=4
st="%0"+str(len(stars))+"i"
trueFileName=fileName.replace(stars,st%(it))
fd=open(os.path.join(self._dirName,trueFileName),"r+b") ; fd.seek(0,2) ; end=fd.tell() ; fd.seek(0)
- name=fd.read(80).strip().split(b" ")[0]
+ name=fd.read(80).strip().split(b" ")[0].decode("ascii")
if name!=fieldName:
raise Exception("ConvertField : mismatch")
pos=fd.tell()
end=lines.index("TIME\n")
pass
for i in range(ind + 1,end):
- m=re.match("^([\w]+)[\s]+\per[\s]+([\w]+)[\s]*\:[\s]*[0-9]*[\s]*([\w]+)[\s]+([\S]+)$",lines[i])
+ m=re.match("^([\w]+)[\s]+per[\s]+([\w]+)[\s]*\:[\s]*[0-9]*[\s]*([\w]+)[\s]+([\S]+)$",lines[i])
if m:
if m.groups()[0]=="constant":
continue
spatialDisc=m.groups()[1] ; fieldName=m.groups()[2] ; nbOfCompo=self.dictCompo2[m.groups()[0]] ; fieldFileName=m.groups()[3]
- if fieldFileName.endswith("*"):
+ if "*" in fieldFileName:
fieldsInfo.append((fieldName,spatialDisc,nbOfCompo,fieldFileName))
pass
pass