-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStaggered_Grid_Generation.py~
More file actions
63 lines (51 loc) · 2 KB
/
Staggered_Grid_Generation.py~
File metadata and controls
63 lines (51 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def Generate_Grid(Lx, Ly, Nx, Ny, x_s, y_s):
"""Generates a 2D staggered Grid
Params:
-------
Lx, Ly float, length of grid in x and y
Nx, Ny float, number of points in x and y not includeing ghost cells
xs, ys float, starting points in x and y
Returns:
-------
dx, dy float, step size in x and y
x, y 1D array of float, x and y points
xp, yp 1D array of float, pressure point grid in x and y
p_exact 2D array of float, array for exact pressure
xu, yu 1D array of float, u velocity grid in x and y
u_exact 2D array of float, array for exact u
ut 2D array of float, array for time varying u
xv, yv 1D array of float, v velocity grid in x and y
v_exact 2D array of float, array for exact v
vt 2D array of float, array for time varying v
"""
import numpy
dx = Lx/(Nx)
dy = Ly/(Ny)
#test3
x = numpy.zeros((Nx+2,1), dtype=float)
y = numpy.zeros((Ny+2,1), dtype=float)
# Pressure Points
xp = numpy.zeros(Nx, dtype=float)
yp = numpy.zeros(Ny, dtype=float)
p_exact = numpy.zeros((Ny,Nx), dtype=float)
# u velocity points
xu = numpy.zeros(Nx+3, dtype=float)
yu = numpy.zeros(Ny+2, dtype=float)
u_exact = numpy.zeros((Ny+2,Nx+3), dtype=float)
#ut = numpy.zeros_like((Ny+2,Nx+3,nt), dtype=float)
# v velocity points
xv = numpy.zeros(Nx+2, dtype=float)
yv = numpy.zeros(Ny+3, dtype=float)
v_exact = numpy.zeros((Ny+3,Nx+2), dtype=float)
#vt = numpy.zeros_like((Ny+3,Nx+2,nt), dtype=float)
#Pressure
#for i in range(0,Nx+2):
xp = numpy.linspace(dx/2.0,Lx-dx/2.0,Nx)
yp = numpy.linspace(dy/2.0,Ly-dy/2.0,Ny)
#u Velocity
xu = numpy.linspace(-dx,Lx+dx,Nx+3)
yu = numpy.linspace(-dy/2.0,Ly+dy/2.0,Ny+2)
#v Velocity
xv = numpy.linspace(-dx/2.0,Lx+dx/2.0,Nx+2)
yv = numpy.linspace(-dy,Ly+dy,Ny+3)
return x, y, xp, yp, p_exact, xu, yu, u_exact, xv, yv, v_exact, dx, dy