mirror of
https://github.com/smyalygames/FiniteVolumeGPU.git
synced 2026-01-14 15:48:43 +01:00
Refactoring CudaArray and ArakawaA grid
This commit is contained in:
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
#Import packages we need
|
||||
from GPUSimulators import Simulator
|
||||
from GPUSimulators import Simulator, Common
|
||||
|
||||
|
||||
|
||||
@@ -60,9 +60,7 @@ class FORCE (Simulator.BaseSimulator):
|
||||
|
||||
# Call super constructor
|
||||
super().__init__(context, \
|
||||
h0, hu0, hv0, \
|
||||
nx, ny, \
|
||||
1, 1, \
|
||||
dx, dy, dt, \
|
||||
g, \
|
||||
block_width, block_height);
|
||||
@@ -73,6 +71,16 @@ class FORCE (Simulator.BaseSimulator):
|
||||
BLOCK_WIDTH=self.local_size[0], \
|
||||
BLOCK_HEIGHT=self.local_size[1])
|
||||
|
||||
#Create data by uploading to device
|
||||
self.u0 = Common.ArakawaA2D(self.stream, \
|
||||
nx, ny, \
|
||||
1, 1, \
|
||||
[h0, hu0, hv0])
|
||||
self.u1 = Common.ArakawaA2D(self.stream, \
|
||||
nx, ny, \
|
||||
1, 1, \
|
||||
[None, None, None])
|
||||
|
||||
def __str__(self):
|
||||
return "First order centered"
|
||||
|
||||
@@ -84,13 +92,14 @@ class FORCE (Simulator.BaseSimulator):
|
||||
self.nx, self.ny, \
|
||||
self.dx, self.dy, dt, \
|
||||
self.g, \
|
||||
self.data.h0.data.gpudata, self.data.h0.data.strides[0], \
|
||||
self.data.hu0.data.gpudata, self.data.hu0.data.strides[0], \
|
||||
self.data.hv0.data.gpudata, self.data.hv0.data.strides[0], \
|
||||
self.data.h1.data.gpudata, self.data.h1.data.strides[0], \
|
||||
self.data.hu1.data.gpudata, self.data.hu1.data.strides[0], \
|
||||
self.data.hv1.data.gpudata, self.data.hv1.data.strides[0])
|
||||
self.data.swap()
|
||||
self.u0[0].data.gpudata, self.u0[0].data.strides[0], \
|
||||
self.u0[1].data.gpudata, self.u0[1].data.strides[0], \
|
||||
self.u0[2].data.gpudata, self.u0[2].data.strides[0], \
|
||||
self.u1[0].data.gpudata, self.u1[0].data.strides[0], \
|
||||
self.u1[1].data.gpudata, self.u1[1].data.strides[0], \
|
||||
self.u1[2].data.gpudata, self.u1[2].data.strides[0])
|
||||
self.u0, self.u1 = self.u1, self.u0
|
||||
self.t += dt
|
||||
|
||||
|
||||
def download(self):
|
||||
return self.u0.download(self.stream)
|
||||
Reference in New Issue
Block a user