-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmesh.py
More file actions
31 lines (26 loc) · 994 Bytes
/
mesh.py
File metadata and controls
31 lines (26 loc) · 994 Bytes
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
import numpy as np
# ---------------------
# building mesh arrays
# ---------------------
class Mesh():
def __init__(self, directory=""):
if len(directory) > 1:
if directory[-1] != '/':
directory += '/'
# -----
# Grid
# -----
with open(directory+'radial_grid', 'r') as f:
self.ndomains = int(f.readline())
self.nzd = np.zeros(self.ndomains, dtype=int)
for i in range(self.ndomains):
values = f.readline().split()
self.nzd[i] = int(values[1])
self.r = self.read_scalar(f, self.nr + 1)
with open(directory+'lat_grid', 'r') as f:
self.theta = self.read_scalar(f, self.nth)
with open(directory+'2D_grid', 'r') as f:
f.readline()
self.x = self.read_array(f, self.nr+1, self.nth)
f.readline()
self.y = self.read_array(f, self.nr+1, self.nth)