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 which will ascend in coalesced memory escalting i a range from 0 to nx . // So i * dx will essentially by equivalent to...for (int k = 0; k < nx; k++) if (i*dx >= 0.5 && i*dx <= 1) // replace k here with i for the X dimension because we want to change for the first instance in each dimension same reason as above u[i * nx] = 2; else u[i * nx] = 1; } }