def depth(sol, t, x, y, xi, yi): ybed = np.zeros(len(xi)) if np.mod(t, 1) == 0: timename = str(int(t)) + '/' else: timename = str(t) + '/' alpha = fluidfoam.readscalar(sol, timename, 'alpha_a') alphai = mlab.griddata(x, y, alpha, xi, yi, interp='linear') for j in range(len(xi) - 1): tab = np.where(alphai[:, j+1] > 0.5) ybed[j] = yi[np.max(tab)] return ybed
ybed = np.zeros(len(xi)) arr_size = int((tfinal - t0) / dt + 0.01) yscour = np.zeros(arr_size) time = np.zeros(arr_size) i = -1 j = 10 t = t0 while t < tfinal: t = t + dt i = i + 1 if np.mod(t, 1) == 0: timename = str(int(t)) + '/' else: timename = str(t) + '/' a = fluidfoam.readscalar(case, timename, 'alpha_a') ai = mlab.griddata(x, y, a, xi, yi, interp='linear') for j in range(ngridx): ybed[j] = yi[np.max((np.where(ai[:, j] > 0.5)))] yscour[i] = np.min(ybed[:]) time[i] = t return yscour, time # Case information case = '../RAS/2DPipelineScour/' # Number of division for linear interpolation ngridx = 500 ngridy = 180 # Interpolation grid dimensions