bugfix: fixed size of the readable portion of chunk['data'] (now it works also when no ghost cells are present)

This commit is contained in:
Tiago Pestana 2020-09-16 20:06:11 +02:00
parent c75092dfc7
commit a0643f951b
1 changed files with 34 additions and 30 deletions

View File

@ -291,19 +291,19 @@ class ibmppp:
# Also determine file which contains the desired field as well as the
# dataset ID
if key[0]=='u':
filebase = self.__dir_base+'uvwp.'
filebase = self.__dir_base+'/uvwp.'
dset = 1
elif key[0]=='v':
filebase = self.__dir_base+'uvwp.'
filebase = self.__dir_base+'/uvwp.'
dset = 2
elif key[0]=='w':
filebase = self.__dir_base+'uvwp.'
filebase = self.__dir_base+'/uvwp.'
dset = 3
elif key[0]=='p':
filebase = self.__dir_base+'uvwp.'
filebase = self.__dir_base+'/uvwp.'
dset = 4
elif key[0]=='s':
filebase = self.__dir_base+'scal.'
filebase = self.__dir_base+'/scal.'
dset = int(key[1])
if dset!=1:
self.fields[key] = None
@ -348,10 +348,14 @@ class ibmppp:
if kb1!=chunk['kbeg'] or ke1!=chunk['kbeg']+chunk['nzl']-1:
raise ValueError('Loaded chunk does not correspond to processor grid (kbeg={}, nzl={} vs kbeg={},nzl={}'.format(kb1,ke1-kb1+1,chunk['kbeg'],chunk['nzl']))
ngh1 = chunk['ighost']
ibeg = [i + ngh1 for i in [0,0,0]]
iend = [i-ngh1 for i in chunk['data'].shape]
# No need to care about ghost cells here, we communicate them later
self.field[key][ib1-ib+self.__nghx:ie1-ib+self.__nghx+1,
jb1-jb+self.__nghy:je1-jb+self.__nghy+1,
kb1-kb+self.__nghz:ke1-kb+self.__nghz+1] = chunk['data'][ngh1:-ngh1,ngh1:-ngh1,ngh1:-ngh1]
kb1-kb+self.__nghz:ke1-kb+self.__nghz+1] = chunk['data'][ibeg[0]:iend[0],\
ibeg[1]:iend[1],\
ibeg[2]:iend[2]]
# Exchange ghost cells and set boundary conditions
self.exchangeGhostCells(key)
self.imposeBoundaryConditions(key)