diff --git a/python/ibmppp/ibmppp.py b/python/ibmppp/ibmppp.py index d33fe06..6f3e426 100644 --- a/python/ibmppp/ibmppp.py +++ b/python/ibmppp/ibmppp.py @@ -417,11 +417,6 @@ class ibmppp: ioflag = 'a' else: ioflag = 'w' - # get information about origin and grid spacing - delta = [self.__dx[key], self.__dx[key], self.__dx[key]] - origin = [self.grid[key][0][ib-1]-nghx*dx, \ - self.grid[key][1][jb-1]-nghy*dx, \ - self.grid[key][2][kb-1]-nghz*dx] # Open the file and write data, then close it because we are done fid = h5py.File(file_chunk,ioflag) if not append: @@ -432,8 +427,6 @@ class ibmppp: fid.create_dataset('nxproc',data=self.__nxp) fid.create_dataset('nyproc',data=self.__nyp) fid.create_dataset('nzproc',data=self.__nzp) - fid.create_dataset('origin',data=origin) - fid.create_dataset('delta',data=delta) gid = fid.create_group('/'+key) gid.create_dataset('ib',data=self.__localChunkBounds[key][0]) gid.create_dataset('ie',data=self.__localChunkBounds[key][1]) @@ -455,16 +448,18 @@ class ibmppp: did.attrs['F_CONTIGUOUS'] = 1 did.attrs['DIM'] = (self.__localChunkSize[key][0]+2*nghx,self.__localChunkSize[key][1]+2*nghy,self.__localChunkSize[key][2]+2*nghz) fid.close() - # Create an XDMF file for the field + # Create an XDMF file for the field --> if append write only attribute if xdmf and self.__rank==0: # Construct XDMF filename - file_xdmf = filename+'_'+key+'.xdmf' - # Open file and write header - fid = open(file_xdmf,'w') - fid.write('\n') - fid.write('\n') - fid.write(' \n') - fid.write(' \n'.format(key)) + # file_xdmf = filename+'_'+key+'.xdmf' + file_xdmf = filename+'.xdmf' + # Open file and write header; or skip if appending + if not append: + fid = open(file_xdmf,'w') + fid.write('\n') + fid.write('\n') + fid.write(' \n') + fid.write(' \n'.format(key)) #fid.write(' \n') - fid.write(' \n') - fid.write(' \n') + if append: + #find where the Geometry ends... and add new attribute + fid = open(file_xdmf,'r') + lines = fid.readlines() + fid.close() + lnb=0 + for i in lines: + logical = "" in i + if logical: + newAttrb = ' \n'.format(key,nzl,nyl,nxl) + newAttrb += ' \n'.format(nzl,nyl,nxl) + newAttrb += ' {}:/{}/data \n'.format(subfile,key) + newAttrb += ' \n' + break + lnb+=1 + fid = open(file_xdmf,'w') + fid.writelines(lines[0:lnb+1]) + fid.write(newAttrb) + fid.writelines(lines[lnb+1:]) + fid.close() + else: + # Write XDMF for this processor + fid.write(' \n'.format(iprank,iproc,jproc,kproc)) + fid.write(' \n'.format(nzl,nyl,nxl)) + fid.write(' \n') + fid.write(' {:12f} {:12f} {:12f}\n'.format(z0,y0,x0)) + fid.write(' {:12f} {:12f} {:12f}\n'.format(dx,dx,dx)) + fid.write(' \n') + fid.write(' \n'.format(key,nzl,nyl,nxl)) + fid.write(' \n'.format(nzl,nyl,nxl)) + fid.write(' {}:/{}/data \n'.format(subfile,key)) + fid.write(' \n') + fid.write(' \n') + # Write footer and close file + fid.write(' \n') + fid.write(' \n') + fid.write(' \n') fid.close() def saveFieldOriginal(self,filename,key,append=False,xdmf=False):