mirror of
https://github.com/smyalygames/FiniteVolumeGPU.git
synced 2025-11-29 17:28:03 +01:00
Bugfixes
This commit is contained in:
@@ -70,6 +70,10 @@ class HLL2 (Simulator.BaseSimulator):
|
|||||||
self.order = np.int32(order)
|
self.order = np.int32(order)
|
||||||
self.boundary_conditions = boundary_conditions.asCodedInt()
|
self.boundary_conditions = boundary_conditions.asCodedInt()
|
||||||
|
|
||||||
|
#This kernel is dimensionally split, and therefore only second order every other
|
||||||
|
#dimsplit timestep. Therefore, step always runs two substeps
|
||||||
|
self.dt = 2*self.dt
|
||||||
|
|
||||||
#Get kernels
|
#Get kernels
|
||||||
self.kernel = context.get_prepared_kernel("cuda/SWE2D_HLL2.cu", "HLL2Kernel", \
|
self.kernel = context.get_prepared_kernel("cuda/SWE2D_HLL2.cu", "HLL2Kernel", \
|
||||||
"iifffffiiPiPiPiPiPiPi", \
|
"iifffffiiPiPiPiPiPiPi", \
|
||||||
@@ -95,14 +99,15 @@ class HLL2 (Simulator.BaseSimulator):
|
|||||||
|
|
||||||
def step(self, dt):
|
def step(self, dt):
|
||||||
if (self.order == 1):
|
if (self.order == 1):
|
||||||
self.substepDimsplit(dt, substep=(self.nt % 2))
|
self.substepDimsplit(0.5*dt, 0)
|
||||||
|
self.substepDimsplit(0.5*dt, 1)
|
||||||
elif (self.order == 2):
|
elif (self.order == 2):
|
||||||
self.substepDimsplit(dt, substep=0)
|
self.substepDimsplit(0.5*dt, 0)
|
||||||
self.substepDimsplit(dt, substep=1)
|
self.substepDimsplit(0.5*dt, 1)
|
||||||
else:
|
else:
|
||||||
raise(NotImplementedError("Order {:d} is not implemented".format(self.order)))
|
raise(NotImplementedError("Order {:d} is not implemented".format(self.order)))
|
||||||
self.t += dt
|
self.t += dt
|
||||||
self.nt += 1
|
self.nt += 2
|
||||||
|
|
||||||
def substepDimsplit(self, dt, substep):
|
def substepDimsplit(self, dt, substep):
|
||||||
self.kernel.prepared_async_call(self.grid_size, self.block_size, self.stream, \
|
self.kernel.prepared_async_call(self.grid_size, self.block_size, self.stream, \
|
||||||
|
|||||||
@@ -82,10 +82,10 @@ class BoundaryCondition(object):
|
|||||||
Helper function which packs four boundary conditions into one integer
|
Helper function which packs four boundary conditions into one integer
|
||||||
"""
|
"""
|
||||||
bc = 0
|
bc = 0
|
||||||
bc = bc | (self.north & 0x000F) << 24
|
bc = bc | (self.north & 0x0000000F) << 24
|
||||||
bc = bc | (self.south & 0x000F) << 16
|
bc = bc | (self.south & 0x0000000F) << 16
|
||||||
bc = bc | (self.east & 0x000F) << 8
|
bc = bc | (self.east & 0x0000000F) << 8
|
||||||
bc = bc | (self.west & 0x000F)
|
bc = bc | (self.west & 0x0000000F)
|
||||||
|
|
||||||
#for t in types:
|
#for t in types:
|
||||||
# print("{0:s}, {1:d}, {1:032b}, {1:08b}".format(t, types[t]))
|
# print("{0:s}, {1:d}, {1:032b}, {1:08b}".format(t, types[t]))
|
||||||
@@ -233,7 +233,7 @@ def stepOrderToCodedInt(step, order):
|
|||||||
"""
|
"""
|
||||||
Helper function which packs the step and order into a single integer
|
Helper function which packs the step and order into a single integer
|
||||||
"""
|
"""
|
||||||
step_order = (step << 16) ^ (order & 0x00ff)
|
step_order = (step << 16) | (order & 0x0000ffff)
|
||||||
#print("Step: {0:032b}".format(step))
|
#print("Step: {0:032b}".format(step))
|
||||||
#print("Order: {0:032b}".format(order))
|
#print("Order: {0:032b}".format(order))
|
||||||
#print("Mix: {0:032b}".format(step_order))
|
#print("Mix: {0:032b}".format(step_order))
|
||||||
|
|||||||
@@ -114,15 +114,15 @@ enum BoundaryCondition {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline __device__ BoundaryCondition getBCNorth(int bc_) {
|
inline __device__ BoundaryCondition getBCNorth(int bc_) {
|
||||||
return static_cast<BoundaryCondition>(bc_ & 0x000F);
|
return static_cast<BoundaryCondition>(bc_ & 0x0000000F);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline __device__ BoundaryCondition getBCSouth(int bc_) {
|
inline __device__ BoundaryCondition getBCSouth(int bc_) {
|
||||||
return static_cast<BoundaryCondition>((bc_ >> 8) & 0x000F);
|
return static_cast<BoundaryCondition>((bc_ >> 8) & 0x0000000F);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline __device__ BoundaryCondition getBCEast(int bc_) {
|
inline __device__ BoundaryCondition getBCEast(int bc_) {
|
||||||
return static_cast<BoundaryCondition>((bc_ >> 16) & 0x000F);
|
return static_cast<BoundaryCondition>((bc_ >> 16) & 0x0000000F);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline __device__ BoundaryCondition getBCWest(int bc_) {
|
inline __device__ BoundaryCondition getBCWest(int bc_) {
|
||||||
@@ -260,12 +260,26 @@ inline __device__ void writeBlock(float* ptr_, int pitch_,
|
|||||||
float* const row = (float*) ((char*) ptr_ + pitch_*tj);
|
float* const row = (float*) ((char*) ptr_ + pitch_*tj);
|
||||||
|
|
||||||
//Handle runge-kutta timestepping here
|
//Handle runge-kutta timestepping here
|
||||||
|
row[ti] = shmem[ty][tx];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SSPRK2
|
||||||
|
* u^1 = u^n + dt*f(u^n)
|
||||||
|
* u^n+1 = 1/2*u^n + 1/2*(u^1 + dt*f(u^1))
|
||||||
|
*
|
||||||
|
* SSPRK3
|
||||||
|
* u^1 = u^n + dt*f(u^n)
|
||||||
|
* u^2 = 3/4 * u^n + 1/4 * (u^1 + dt*f(u^1))
|
||||||
|
* u^n+1 = 1/3 * u^n + 2/3 * (u^2 + dt*f(u^2))
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
if (rk_order_ == 2 && rk_step_ == 1) {
|
if (rk_order_ == 2 && rk_step_ == 1) {
|
||||||
row[ti] = 0.5f*(row[ti] + shmem[ty][tx]);
|
row[ti] = 0.5f*(row[ti] + shmem[ty][tx]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
row[ti] = shmem[ty][tx];
|
row[ti] = shmem[ty][tx];
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user