Changes

Jump to: navigation, search

BetaT

19 bytes added, 20:20, 1 April 2017
New Kernel
'''
__global__ void Initalize(float* u, float* un, int nx, int nt, float dx)  { int i = blockIdx.x * blockDim.x + threadIdx.x; int j = blockIdx.y * blockDim.y + threadIdx.y; if (i < nx && j < nx) { // replace k with i. because i represents the x dimension in coalesced memory escalting i from 0 to nx if (i*dx >= 0.5 && i*dx <= 1) // replace k here with i for the X dimension because we want to change the first instance in each dimension u[i * nx] = 2; else u[i * nx] = 1; } }
The old code was:
for (int k = 0; k <= nx - 1; k++) if (k*dx >= 0.5 && k*dx <= 1) { u[k * nx] = 2; } else { u[k * nx] = 1;
if (k*dx >= 0.5 && k*dx <= 1) { u[k * nx] = 2; } else { u[k * nx] = 1; }'''
212
edits

Navigation menu