From 38a988cb43f186a003bd70a6d609ce132dfdc929 Mon Sep 17 00:00:00 2001 From: Eric Dalissier <Eric.Dalissier@imag.fr> Date: Wed, 20 Feb 2013 14:52:16 +0000 Subject: [PATCH] resolution of ogrid problem --- HySoP/hysop/fields/discrete.py | 22 +- HySoP/hysop/problem/problem.py | 22 +- HySoP/hysop/tools/cpu_data_transfer.py | 282 +++++++++++-------------- 3 files changed, 141 insertions(+), 185 deletions(-) diff --git a/HySoP/hysop/fields/discrete.py b/HySoP/hysop/fields/discrete.py index bbb099587..ae77240bc 100644 --- a/HySoP/hysop/fields/discrete.py +++ b/HySoP/hysop/fields/discrete.py @@ -93,14 +93,14 @@ class ScalarField(object): print "...", v_formula = np.vectorize(formula) if self.dimension == 3: - self.data = v_formula(self.topology.mesh.coords[0], - self.topology.mesh.coords[1], - self.topology.mesh.coords[2]) + self.data = v_formula(self.topology.mesh.coords[0][0:self.resolution[0],0:self.resolution[1],0:self.resolution[2]], + self.topology.mesh.coords[1][0:self.resolution[0],0:self.resolution[1],0:self.resolution[2]], + self.topology.mesh.coords[2][0:self.resolution[0],0:self.resolution[1],0:self.resolution[2]]) elif self.dimension == 2: - self.data = v_formula(self.topology.mesh.coords[0], - self.topology.mesh.coords[1]) + self.data = v_formula(self.topology.mesh.coords[0][0:self.resolution[0],0:self.resolution[1]], + self.topology.mesh.coords[1][0:self.resolution[0],0:self.resolution[1]]) else: - self.data = v_formula(self.topology.mesh.coords[0]) + self.data = v_formula(self.topology.mesh.coords[0][0:self.resolution[0]]) self.contains_data = True else: print "No formula", @@ -215,15 +215,15 @@ class VectorField(object): print "...", v_formula = np.vectorize(formula) if self.dimension == 3: - self.data[0], self.data[1], self.data[2] = v_formula(self.topology.mesh.coords[0], - self.topology.mesh.coords[1], - self.topology.mesh.coords[2]) + self.data[0], self.data[1], self.data[2] = v_formula(self.topology.mesh.coords[0][0:self.resolution[0],0:self.resolution[1],0:self.resolution[2]], + self.topology.mesh.coords[1][0:self.resolution[0],0:self.resolution[1],0:self.resolution[2]], + self.topology.mesh.coords[2][0:self.resolution[0],0:self.resolution[1],0:self.resolution[2]]) self.data[0] = np.array(self.data[0], dtype=PARMES_REAL , order=ORDER) self.data[1] = np.array(self.data[1], dtype=PARMES_REAL , order=ORDER) self.data[2] = np.array(self.data[2], dtype=PARMES_REAL , order=ORDER) elif self.dimension == 2: - self.data[0], self.data[1] = v_formula(self.topology.mesh.coords[0], - self.topology.mesh.coords[1]) + self.data[0], self.data[1] = v_formula(self.topology.mesh.coords[0][0:self.resolution[0],0:self.resolution[1]], + self.topology.mesh.coords[1][0:self.resolution[0],0:self.resolution[1]]) self.contains_data = True else: print "No formula", diff --git a/HySoP/hysop/problem/problem.py b/HySoP/hysop/problem/problem.py index fccd36859..c78606626 100644 --- a/HySoP/hysop/problem/problem.py +++ b/HySoP/hysop/problem/problem.py @@ -93,22 +93,24 @@ class Problem(): self.initSolver() self.io.step() while not self.timer.end: - print "==== Iteration : {0:3d} t={1:6.3f} ====".format(self.timer.ite + 1, self.timer.t + self.timer.dt) + if ( self.topology.rank == 0 ) : + print "==== Iteration : {0:3d} t={1:6.3f} ====".format(self.timer.ite + 1, self.timer.t + self.timer.dt) for op in self.operators: op.apply(self.timer.t, self.timer.dt) self.timer.step() self.io.step() print "\n\n End solving\n" print "=== Timings ===" - print "IO total", self.io.compute_time - self.timings_info[0] += "\"IO\" " - self.timings_info[1] += str(self.io.compute_time) + " " - for op in self.operators: - op.printComputeTime() - self.timings_info[0] += op.timings_info[0] - self.timings_info[1] += op.timings_info[1] - print "\n" - print "===\n" + if ( self.topology.rank == 0 ) : + print "IO total", self.io.compute_time + self.timings_info[0] += "\"IO\" " + self.timings_info[1] += str(self.io.compute_time) + " " + for op in self.operators: + op.printComputeTime() + self.timings_info[0] += op.timings_info[0] + self.timings_info[1] += op.timings_info[1] + print "\n" + print "===\n" def addVariable(self, cVariable): """ diff --git a/HySoP/hysop/tools/cpu_data_transfer.py b/HySoP/hysop/tools/cpu_data_transfer.py index 9ae1f1e0d..323d5e0f8 100644 --- a/HySoP/hysop/tools/cpu_data_transfer.py +++ b/HySoP/hysop/tools/cpu_data_transfer.py @@ -20,7 +20,7 @@ class Synchronize(object): @param topology : Local topology """ self.topo = topology - self.total_time = 0. + self.total_time = 1 ## problem le topology.mesh.resolution peut etre different du shape du field rentre self.size= topology.mesh.resolution @@ -44,6 +44,7 @@ class Synchronize(object): # [self.north,4],[self.south,5]]) self.compute_time = time.time() self.comm = MPI.COMM_WORLD + self.count = None for f in listFields: # self.size= f.data[0].shape @@ -88,50 +89,50 @@ class Synchronize(object): # if(self.topo.tabSort[i,1] == 'up'): if(self.topo.tabSort[i,1] == 0): if( self.topo.rank < self.topo.tabSort[i,0]) : - print 'UP',self.topo.rank,'Send to',self.topo.tabSort[i,0] +# print 'UP',self.topo.rank,'Send to',self.topo.tabSort[i,0] self.UPsend(self.topo.tabSort[i,0], f) else : - print 'UP', self.topo.rank,'Recv from',self.topo.tabSort[i,0] +# print 'UP', self.topo.rank,'Recv from',self.topo.tabSort[i,0] self.UPrecv(self.topo.tabSort[i,0], f) # if(self.topo.tabSort[i,1] == 'down'): if(self.topo.tabSort[i,1] == 1): if( self.topo.rank < self.topo.tabSort[i,0]) : - print 'DOWN',self.topo.rank,'Send to',self.topo.tabSort[i,0] +# print 'DOWN',self.topo.rank,'Send to',self.topo.tabSort[i,0] self.DOWNsend(self.topo.tabSort[i,0], f) else : - print 'DOWN', self.topo.rank,'Recv from',self.topo.tabSort[i,0] +# print 'DOWN', self.topo.rank,'Recv from',self.topo.tabSort[i,0] self.DOWNrecv(self.topo.tabSort[i,0], f) # if(self.topo.tabSort[i,1] == 'east'): if(self.topo.tabSort[i,1] == 2): if( self.topo.rank < self.topo.tabSort[i,0]) : - print 'EST',self.topo.rank,'Send to',self.topo.tabSort[i,0] +# print 'EST',self.topo.rank,'Send to',self.topo.tabSort[i,0] self.EASTsend(self.topo.tabSort[i,0], f) else : - print 'EST', self.topo.rank,'Recv from',self.topo.tabSort[i,0] +# print 'EST', self.topo.rank,'Recv from',self.topo.tabSort[i,0] self.EASTrecv(self.topo.tabSort[i,0], f) # if(self.topo.tabSort[i,1] == 'west'): if(self.topo.tabSort[i,1] == 3): if( self.topo.rank < self.topo.tabSort[i,0]) : - print 'WEST',self.topo.rank,'Send to',self.topo.tabSort[i,0] +# print 'WEST',self.topo.rank,'Send to',self.topo.tabSort[i,0] self.WESTsend(self.topo.tabSort[i,0], f) else : - print 'WEST', self.topo.rank,'Recv from',self.topo.tabSort[i,0] +# print 'WEST', self.topo.rank,'Recv from',self.topo.tabSort[i,0] self.WESTrecv(self.topo.tabSort[i,0], f) # if(self.topo.tabSort[i,1] == 'north'): if(self.topo.tabSort[i,1] == 4): if( self.topo.rank < self.topo.tabSort[i,0]) : - print 'NORTH',self.topo.rank,'Send to',self.topo.tabSort[i,0] +# print 'NORTH',self.topo.rank,'Send to',self.topo.tabSort[i,0] self.NORTHsend(self.topo.tabSort[i,0], f) else : - print 'NORTH', self.topo.rank,'Recv from',self.topo.tabSort[i,0] +# print 'NORTH', self.topo.rank,'Recv from',self.topo.tabSort[i,0] self.NORTHrecv(self.topo.tabSort[i,0], f) # if(self.topo.tabSort[i,1] == 'south'): if(self.topo.tabSort[i,1] == 5): if( self.topo.rank < self.topo.tabSort[i,0]) : - print 'SOUTH',self.topo.rank,'Send to',self.topo.tabSort[i,0] +# print 'SOUTH',self.topo.rank,'Send to',self.topo.tabSort[i,0] self.SOUTHsend(self.topo.tabSort[i,0], f) else : - print 'SOUTH', self.topo.rank,'Recv from',self.topo.tabSort[i,0] +# print 'SOUTH', self.topo.rank,'Recv from',self.topo.tabSort[i,0] self.SOUTHrecv(self.topo.tabSort[i,0], f) self.compute_time = time.time() - self.compute_time self.total_time += self.compute_time @@ -140,197 +141,150 @@ class Synchronize(object): def UPsend(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - self.topo.mesh.resolution[0]-2*self.topo.ghosts[0]:self.topo.mesh.resolution[0]-self.topo.ghosts[0],:,:].shape) - startsSend = np.asarray([self.topo.mesh.resolution[0]-2*self.topo.ghosts[0],0,0]) - UPtypeSend = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - UPtypeSend.Commit() - self.comm.Send([listFields[i], UPtypeSend ], dest=proc, tag=77) - startsRecv = [self.topo.mesh.resolution[0]-self.topo.ghosts[0],0,0] - UPtypeRecv = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - UPtypeRecv.Commit() - data = listFields[i] - self.comm.Recv([data, UPtypeRecv] , source=proc, tag=77) + data = np.zeros((ghosts[0],resolution[1], resolution[2]) , dtype=PARMES_REAL , order=ORDER) + data = np.array(np.copy(listFields[i][ \ + self.topo.mesh.resolution[0]-2*self.topo.ghosts[0]:self.topo.mesh.resolution[0]-self.topo.ghosts[0],:,:]), order=ORDER) + self.comm.Ssend(data, dest=proc, tag=11) + self.comm.Recv(data , source=proc, tag=11) listFields[i][ self.topo.mesh.resolution[0]-self.topo.ghosts[0]:self.topo.mesh.resolution[0],:,:]\ - = data[self.topo.mesh.resolution[0]-self.topo.ghosts[0]:self.topo.mesh.resolution[0],:,:] + = data def DOWNsend(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - self.topo.ghosts[0]:2*self.topo.ghosts[0],:,:].shape) - startsSend = np.asarray([self.topo.ghosts[0],0,0]) - DOWNtypeSend = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - DOWNtypeSend.Commit() - self.comm.Send([ listFields[i], DOWNtypeSend ], dest=proc, tag=77) - startsRecv = [0,0,0] - DOWNtypeRecv = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - DOWNtypeRecv.Commit() - data = listFields[i] - self.comm.Recv([data, DOWNtypeRecv], source=proc, tag=77) - listFields[i][0:self.topo.ghosts[0],:,:] = data[0:self.topo.ghosts[0],:,:] + data = np.zeros((ghosts[0],resolution[1], resolution[2]) , dtype=PARMES_REAL , order=ORDER) + data = np.array(np.copy(listFields[i][ \ + ghosts[0]:2*ghosts[0],:,:]), order=ORDER) + self.comm.Ssend(data, dest=proc, tag=22) + self.comm.Recv(data , source=proc, tag=22) + listFields[i][0:ghosts[0],:,:] = data + def EASTsend(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - :,self.topo.mesh.resolution[1]-2*self.topo.ghosts[1]:self.topo.mesh.resolution[1]-self.topo.ghosts[1],:].shape) - startsSend = np.asarray([0,self.topo.mesh.resolution[1]-2*self.topo.ghosts[1],0]) - EASTtypeSend = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - EASTtypeSend.Commit() - self.comm.Send([ listFields[i], EASTtypeSend ], dest=proc, tag=33) - startsRecv = [0,self.topo.mesh.resolution[1]-self.topo.ghosts[1],0] - EASTtypeRecv = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - EASTtypeRecv.Commit() - data = listFields[i] - self.comm.Recv([data, EASTtypeRecv] , source=proc, tag=33) - listFields[i][ - :,self.topo.mesh.resolution[1]-self.topo.ghosts[1]:self.topo.mesh.resolution[1] ,:]\ - = data[:,self.topo.mesh.resolution[1]-self.topo.ghosts[1]:self.topo.mesh.resolution[1],:] + data = np.zeros((resolution[0], ghosts[1], resolution[2]) , dtype=PARMES_REAL , order=ORDER) + data = np.array(np.copy(listFields[i][ \ + :,resolution[1]-2*ghosts[1]:resolution[1]-ghosts[1],:]), order=ORDER) + + self.comm.Ssend(data, dest=proc, tag=33) + self.comm.Recv(data , source=proc, tag=33) + listFields[i][:,resolution[1]-ghosts[1]:resolution[1],:]= data + def WESTsend(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - :,self.topo.ghosts[1]:2*self.topo.ghosts[1],:].shape) - startsSend = np.asarray([0,self.topo.ghosts[1],0]) - WESTtypeSend = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - WESTtypeSend.Commit() - self.comm.Send([ listFields[i], WESTtypeSend ], dest=proc, tag=33) - startsRecv = [0,0,0] - WESTtypeRecv = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - WESTtypeRecv.Commit() - data = listFields[i] - self.comm.Recv([data, WESTtypeRecv], source=proc, tag=33) - listFields[i][:,0:self.topo.ghosts[1],:] = data[:,0:self.topo.ghosts[1],:] + data = np.zeros((resolution[0], ghosts[1], resolution[2]) , dtype=PARMES_REAL , order=ORDER) + data = np.array(np.copy(listFields[i][ \ + :,ghosts[1]:ghosts[1]*2,:]), order=ORDER) + self.comm.Ssend(data, dest=proc, tag=44) + self.comm.Recv(data , source=proc, tag=44) + listFields[i][:,0:ghosts[1],:]= data + def NORTHsend(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - :,:,self.topo.mesh.resolution[2]-2*self.topo.ghosts[2]:self.topo.mesh.resolution[2]-self.topo.ghosts[2]].shape) - startsSend = np.asarray([0,0,self.topo.mesh.resolution[2]-2*self.topo.ghosts[2]]) - NORTHtypeSend = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - NORTHtypeSend.Commit() - self.comm.Send([listFields[i], NORTHtypeSend ], dest=proc, tag=55) - startsRecv = [0,0,self.topo.mesh.resolution[2]-self.topo.ghosts[2]] - NORTHtypeRecv = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - NORTHtypeRecv.Commit() - data = listFields[i] - self.comm.Recv([data, NORTHtypeRecv] , source=proc, tag=55) - listFields[i][ - :,:,self.topo.mesh.resolution[2]-self.topo.ghosts[2]:self.topo.mesh.resolution[2]]\ - = data[:,:,self.topo.mesh.resolution[2]-self.topo.ghosts[2]:self.topo.mesh.resolution[2]] + data = np.zeros((resolution[0], resolution[1], ghosts[2]) , dtype=PARMES_REAL , order=ORDER) + data = np.array(np.copy(listFields[i][ \ + :,:,resolution[2]-2*ghosts[2]:resolution[2]-ghosts[2]]), order=ORDER) + self.comm.Ssend(data, dest=proc, tag=55) + self.comm.Recv(data , source=proc, tag=55) + listFields[i][:,:,resolution[2]-ghosts[2]:resolution[2]]= data + def SOUTHsend(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - :,:,self.topo.ghosts[2]:2*self.topo.ghosts[2]].shape) - startsSend = np.asarray([0,0,self.topo.ghosts[2]]) - SOUTHtypeSend = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - SOUTHtypeSend.Commit() - self.comm.Send([ listFields[i], SOUTHtypeSend ], dest=proc, tag=55) - startsRecv = [0,0,0] - SOUTHtypeRecv = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - SOUTHtypeRecv.Commit() - data = listFields[i] - self.comm.Recv([data, SOUTHtypeRecv], source=proc, tag=55) - listFields[i][:,:,0:self.topo.ghosts[2]] = data[:,:,0:self.topo.ghosts[2]] + data = np.zeros((resolution[0], resolution[1], ghosts[2]) , dtype=PARMES_REAL , order=ORDER) + data = np.array(np.copy(listFields[i][ \ + :,:,ghosts[2]:2*ghosts[2]]), order=ORDER) + self.comm.Ssend(data, dest=proc, tag=66) + self.comm.Recv(data , source=proc, tag=66) + listFields[i][:,:,0:ghosts[2]]= data def UPrecv(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - self.topo.mesh.resolution[0]-self.topo.ghosts[0]:self.topo.mesh.resolution[0],:,:].shape) - startsRecv = np.asarray([self.topo.mesh.resolution[0]-self.topo.ghosts[0],0,0]) - UPtypeRecv = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - UPtypeRecv.Commit() - data = listFields[i] - self.comm.Recv([data, UPtypeRecv], source=proc, tag=77) - listFields[i][self.topo.mesh.resolution[0]-self.topo.ghosts[0]:self.topo.mesh.resolution[0],:,:] = data[ \ - self.topo.mesh.resolution[0]-self.topo.ghosts[0]:self.topo.mesh.resolution[0],:,:] - startsSend = [self.topo.mesh.resolution[0]-2*self.topo.ghosts[0],0,0] - UPtypeSend = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - UPtypeSend.Commit() - self.comm.Send([listFields[i], UPtypeSend], dest=proc, tag=77) + data = np.zeros((ghosts[0],resolution[1], resolution[2]) , dtype=PARMES_REAL , order=ORDER) + self.comm.Recv(data, source = proc, tag =22) + listFields[i][resolution[0]-ghosts[0]:resolution[0],:,:] = data + data = np.array(np.copy(listFields[i][ \ + resolution[0]-2*ghosts[0]:resolution[0]-ghosts[0],:,:]), order=ORDER) + self.comm.Ssend(data, dest = proc, tag =22) def DOWNrecv(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - 0:self.topo.ghosts[0],:,:].shape) - startsRecv = np.asarray([0,0,0]) - DOWNtypeRecv= MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - DOWNtypeRecv.Commit() - data=listFields[i] - self.comm.Recv([data, DOWNtypeRecv], source = proc, tag =77) - listFields[i][0:self.topo.ghosts[0],:,:] = data[0:self.topo.ghosts[0],:,:] - startsSend = [self.topo.ghosts[0],0,0] - DOWNtypeSend= MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - DOWNtypeSend.Commit() - self.comm.Send([listFields[i], DOWNtypeSend], dest = proc, tag =77) + data = np.zeros((ghosts[0],resolution[1], resolution[2]) , dtype=PARMES_REAL , order=ORDER) + self.comm.Recv(data, source = proc, tag =11) + listFields[i][0:self.topo.ghosts[0],:,:] = data + data = np.array(np.copy(listFields[i][ \ + ghosts[0]:ghosts[0]*2,:,:]), order=ORDER) + self.comm.Ssend(data, dest = proc, tag =11) def EASTrecv(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - :,self.topo.mesh.resolution[1]-self.topo.ghosts[1]:self.topo.mesh.resolution[1],:].shape) - startsRecv = np.asarray([0,self.topo.mesh.resolution[1]-self.topo.ghosts[1],0]) - EASTtypeRecv = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - EASTtypeRecv.Commit() - data = listFields[i] - self.comm.Recv([data, EASTtypeRecv], source=proc, tag=33) - listFields[i][:,self.topo.mesh.resolution[1]-self.topo.ghosts[1]:self.topo.mesh.resolution[1],:] = data[ \ - :,self.topo.mesh.resolution[1]-self.topo.ghosts[1]:self.topo.mesh.resolution[1],:] - startsSend = [0,self.topo.mesh.resolution[1]-2*self.topo.ghosts[1],0] - EASTtypeSend = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - EASTtypeSend.Commit() - self.comm.Send([listFields[i], EASTtypeSend], dest=proc, tag=33) + data = np.zeros((resolution[0], ghosts[1], resolution[2]) , dtype=PARMES_REAL , order=ORDER) + self.comm.Recv(data , source=proc, tag=44) + listFields[i][:,resolution[1]-ghosts[1]:resolution[1],:]= data + data = np.array(np.copy(listFields[i][ \ + :,resolution[1]-2*ghosts[1]:resolution[1]-ghosts[1],:]), order=ORDER) + self.comm.Ssend(data, dest=proc, tag=44) + def WESTrecv(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - :,0:self.topo.ghosts[1],:].shape) - startsRecv = np.asarray([0,0,0]) - WESTtypeRecv= MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - WESTtypeRecv.Commit() - data=listFields[i] - self.comm.Recv([data, WESTtypeRecv], source = proc, tag =33) - listFields[i][:,0:self.topo.ghosts[1],:] = data[:,0:self.topo.ghosts[1],:] - startsSend = [0,self.topo.ghosts[1],0] - WESTtypeSend= MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - WESTtypeSend.Commit() - self.comm.Send([listFields[i], WESTtypeSend], dest = proc, tag =33) + data = np.zeros((resolution[0], ghosts[1], resolution[2]) , dtype=PARMES_REAL , order=ORDER) + self.comm.Recv(data , source=proc, tag=33) + listFields[i][:,0:ghosts[1],:]= data + data = np.array(np.copy(listFields[i][ \ + :,ghosts[1]:2*ghosts[1],:]), order=ORDER) + self.comm.Ssend(data, dest=proc, tag=33) + def NORTHrecv(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - :,:,self.topo.mesh.resolution[2]-self.topo.ghosts[2]:self.topo.mesh.resolution[2]].shape) - startsRecv = np.asarray([0,0,self.topo.mesh.resolution[2]-self.topo.ghosts[2]]) - NORTHtypeRecv = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - NORTHtypeRecv.Commit() - data = listFields[i] - self.comm.Recv([data, NORTHtypeRecv], source=proc, tag=55) - listFields[i][:,:,self.topo.mesh.resolution[2]-self.topo.ghosts[2]:self.topo.mesh.resolution[2]] = data[ \ - :,:,self.topo.mesh.resolution[2]-self.topo.ghosts[2]:self.topo.mesh.resolution[2]] - startsSend = [0,0,self.topo.mesh.resolution[2]-2*self.topo.ghosts[2]] - NORTHtypeSend = MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - NORTHtypeSend.Commit() - self.comm.Send([listFields[i], NORTHtypeSend], dest=proc, tag=55) + data = np.zeros((resolution[0], resolution[1], ghosts[2]) , dtype=PARMES_REAL , order=ORDER) + self.comm.Recv(data , source=proc, tag=66) + listFields[i][:,:,resolution[2]-ghosts[2]:resolution[2]]= data + data = np.array(np.copy(listFields[i][ \ + :,:,resolution[2]-2*ghosts[2]:resolution[2]-ghosts[2]]), order=ORDER) + self.comm.Ssend(data, dest=proc, tag=66) + def SOUTHrecv(self, proc, listFields): + ghosts= self.topo.ghosts + resolution = self.topo.mesh.resolution for i in xrange(self.topo.dim) : - subsizes = np.asarray(listFields[i][ \ - :,:,0:self.topo.ghosts[2]].shape) - startsRecv = np.asarray([0,0,0]) - SOUTHtypeRecv= MPI.DOUBLE.Create_subarray(self.size, subsizes, startsRecv, order=MPI.ORDER_F) - SOUTHtypeRecv.Commit() - data=listFields[i] - self.comm.Recv([data, SOUTHtypeRecv], source = proc, tag =55) - listFields[i][:,:,0:self.topo.ghosts[2]] = data[:,:,0:self.topo.ghosts[2]] - startsSend = [0,0,self.topo.ghosts[2]] - SOUTHtypeSend= MPI.DOUBLE.Create_subarray(self.size, subsizes, startsSend, order=MPI.ORDER_F) - SOUTHtypeSend.Commit() - self.comm.Send([listFields[i], SOUTHtypeSend], dest = proc, tag =55) + data = np.zeros((resolution[0], resolution[1], ghosts[2]) , dtype=PARMES_REAL , order=ORDER) + self.comm.Recv(data , source=proc, tag=55) + listFields[i][:,:,0:ghosts[2]]= data + data = np.array(np.copy(listFields[i][ \ + :,:,ghosts[2]:2*ghosts[2]]), order=ORDER) + self.comm.Ssend(data, dest=proc, tag=55) def printComputeTime(self): -- GitLab