Changes

Jump to: navigation, search

BetaT

16 bytes added, 17:50, 29 March 2017
Parallelize
The next problem encountered is like a vector we cannot transfer a 2D array to a *cudaMalloc* or *cudaMemCPy* function call. So the 2D array needs to be converted into a single array. And that brings another problem regarding the original algorithm which is shown below.
 
'''
 
for (int i=0; i <= nx-1; i++)
{
'''
'''for (int k = 0; k <= nx - 1; k++) if (k*dx >= 0.5 && k*dx <= 1) { { u[k * nt + 0] = 2; } else { u[k * nt + 0] = 1; } 
for (int it = 1; it <= nx - 1; it++) { for (int k = 0; k <= nx - 1; k++) { un[k * nx + it - 1] = u[k * nx + it - 1]; } for (int m = 1; m <= nx - 1; m++) { u[0 * nx + it] = un[1 * nx + it - 1]; u[m * nx + it] = un[m * nx + it - 1] - c*dt / dx*(un[m * nx + it - 1] - un[(m - 1) * nx + it - 1]); }''' }'''
212
edits

Navigation menu