def copyCommonData(self): SLFn = SELAFIN('') # Meta data SLFn.TITLE = self.slf.TITLE SLFn.file = self.slf.file SLFn.IPARAM = self.slf.IPARAM # Time SLFn.DATETIME = self.slf.DATETIME SLFn.tags = self.slf.tags # Variables SLFn.NBV1 = self.slf.NBV1 SLFn.VARNAMES = self.slf.VARNAMES SLFn.VARUNITS = self.slf.VARUNITS SLFn.NBV2 = self.slf.NBV2 SLFn.CLDNAMES = self.slf.CLDNAMES SLFn.CLDUNITS = self.slf.CLDUNITS SLFn.NVAR = self.slf.NVAR SLFn.VARINDEX = range(self.slf.NVAR) # Unchanged numbers SLFn.NPLAN = self.slf.NPLAN SLFn.NDP2 = self.slf.NDP2 SLFn.NDP3 = self.slf.NDP3 return SLFn
def copyCommonData(self): SLFn = SELAFIN("") # Meta data SLFn.TITLE = self.slf.TITLE SLFn.file = self.slf.file SLFn.IPARAM = self.slf.IPARAM # Time SLFn.DATETIME = self.slf.DATETIME SLFn.tags = self.slf.tags # Variables SLFn.NBV1 = self.slf.NBV1 SLFn.VARNAMES = self.slf.VARNAMES SLFn.VARUNITS = self.slf.VARUNITS SLFn.NBV2 = self.slf.NBV2 SLFn.CLDNAMES = self.slf.CLDNAMES SLFn.CLDUNITS = self.slf.CLDUNITS SLFn.NVAR = self.slf.NVAR SLFn.VARINDEX = range(self.slf.NVAR) # Unchanged numbers SLFn.NPLAN = self.slf.NPLAN SLFn.NDP2 = self.slf.NDP2 SLFn.NDP3 = self.slf.NDP3 return SLFn
support3d = zip(support2d, len(xys) * [range(slf.NPLAN)]) # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # ~~~~ writes BND header ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bndFile = options.args[3] bnd = SELAFIN('') bnd.fole = {} bnd.fole.update({'hook': open(bndFile, 'wb')}) bnd.fole.update({'name': bndFile}) bnd.fole.update({'endian': ">"}) # big endian bnd.fole.update({'float': ('f', 4)}) # single precision # Meta data and variable names bnd.TITLE = '' bnd.NBV1 = 5 # /!\ ELEVATION has to be the first variable # (for possible vertical re-interpolation within TELEMAC) bnd.VARNAMES = ['ELEVATION Z ', \ 'VELOCITY U ','VELOCITY V ', \ 'SALINITY ','TEMPERATURE ' ] bnd.VARUNITS = ['M ', \ 'M/S ','M/S ', \ ' ',' ' ] bnd.NVAR = bnd.NBV1 bnd.VARINDEX = range(bnd.NVAR) # Sizes and mesh connectivity bnd.NPLAN = slf.NPLAN bnd.NDP2 = 2 bnd.NDP3 = 4
support3d = zip(support2d,len(xys)*[range(slf.NPLAN)]) # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # ~~~~ writes INI header ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ iniFile = options.args[2] ini = SELAFIN('') ini.fole = {} ini.fole.update({ 'hook': open(iniFile,'wb') }) ini.fole.update({ 'name': iniFile}) ini.fole.update({ 'endian': ">" }) # big endian ini.fole.update({ 'float': ('f',4) }) # single precision # Meta data and variable names ini.TITLE = '' ini.NBV1 = 5 # /!\ ELEVATION has to be the first variable # (for possible vertical re-interpolation within TELEMAC) ini.VARNAMES = ['ELEVATION Z ', \ 'VELOCITY U ','VELOCITY V ', \ 'SALINITY ','TEMPERATURE ' ] ini.VARUNITS = ['M ', \ 'M/S ','M/S ', \ ' ',' ' ] ini.NVAR = ini.NBV1 ini.VARINDEX = range(ini.NVAR) # Sizes and mesh connectivity ini.NPLAN = slf.NPLAN ini.NDP2 = 3 ini.NDP3 = 6
support3d = zip(support2d, len(xys) * [range(slf.NPLAN)]) # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< # ~~~~ writes ATM header ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ atmFile = options.args[2] atm = SELAFIN('') atm.fole = {} atm.fole.update({'hook': open(atmFile, 'wb')}) atm.fole.update({'name': atmFile}) atm.fole.update({'endian': ">"}) # big endian atm.fole.update({'float': ('f', 4)}) # single precision # Meta data and variable names atm.TITLE = '' atm.NBV1 = 4 atm.VARNAMES = ['SURFACE PRESSURE', \ 'WIND VELOCITY U ','WIND VELOCITY V ', \ 'AIR TEMPERATURE '] atm.VARUNITS = ['UI ', \ 'M/S ','M/S ', \ 'DEGREES '] atm.NVAR = atm.NBV1 atm.VARINDEX = range(atm.NVAR) # Sizes and mesh connectivity atm.NPLAN = slf.NPLAN # it should be 2D but why the heack not ... atm.NDP2 = slf.NDP2 atm.NDP3 = slf.NDP3 atm.NPOIN2 = geo.NPOIN2 atm.NPOIN3 = geo.NPOIN2 * atm.NPLAN
#fout = open("junk.out","w") #for i in range(len(b)): # fout.write(str(b[i]) + '\n') # now we can delete the temp file os.remove(temp_nodes_file) os.remove(temp_elements_file) os.remove(temp_boundaries_file) # now to write the SELAFIN mesh file slf2d = SELAFIN('') #print ' +> Set SELAFIN variables' slf2d.TITLE = 'Converted from gmsh' slf2d.NBV1 = 1 slf2d.NVAR = 1 slf2d.VARINDEX = range(slf2d.NVAR) slf2d.VARNAMES.append('BOTTOM ') slf2d.VARUNITS.append('M ') #print ' +> Set SELAFIN sizes' slf2d.NPLAN = 1 slf2d.NDP2 = 3 slf2d.NDP3 = 3 slf2d.NPOIN2 = n slf2d.NPOIN3 = n slf2d.NELEM2 = e slf2d.NELEM3 = e slf2d.IPARAM = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]