-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGrid.pyx
64 lines (49 loc) · 2.15 KB
/
Grid.pyx
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
#!python
#cython: boundscheck=False
#cython: wraparound=False
#cython: initializedcheck=False
#cython: cdivision=True
cimport numpy as np
import numpy as np
import time
cdef class Grid:
'''
A class for storing information about the LES grid.
'''
# i = 0,1,2
# Gr.dims.n[i] = namelist['grid']['ni'] (e.g. n[0] = 'nx') --> global number of pts per direction
# Gr.dims.nl[i] = Gr.dims.n[i] // mpi_dims[i] --> local number of pts (per processor)
# Gr.dims.ng[i] = Gr.dims.n[i] + 2*gw --> global number of pts incl. ghost pts
# Gr.dims.nlg[i] = Gr.dims.nl[i] + 2*gw --> local number of pts incl ghost pts
# Gr.dims.npd = n[0] * n[1] * n[2] ( = nx * ny * nz) --> global number of pts in 3D grid
# Gr.dims.npl = nl[0] * nl[1] * nl[2] --> local number of pts in 3D grid
# Gr.dims.npg = nlg[0] * nlg[1] * nlg[2] ( = nxg * nyg * nzg ) --> local number of pts in 3D grid incl. ghost pts
def __init__(self,namelist):
# dimensions = #velocity direction
self.dims = namelist['grid']['dims']
# grid spacing
self.dz = namelist['grid']['dz']
# inverse grid spacing
self.dzi = 1.0/self.dz
# dimensions of the physical domain
self.lz = np.double(self.dz * self.nz)
#Get the grid dimensions and ghost points
self.gw = namelist['grid']['gw']
self.nz = namelist['grid']['nz']
self.nzg = self.nz + 2 * self.gw
self.compute_coordinates()
return
def compute_coordinates(self):
'''
Compute the dimensional (with units) of meters coordiantes. x_half, y_half and z_half are
the grid cell center and x,y,z are at the grid cell edges.
:return:
'''
self.z_half = np.empty((self.nz+2*self.gw),dtype=np.double,order='c')
self.z = np.empty((self.nz+2*self.gw),dtype=np.double,order='c')
count = 0
for i in xrange(-self.gw,self.nz+self.gw,1):
self.z[count] = (i + 1) * self.dz
self.z_half[count] = (i+0.5)*self.dz
count += 1
return