forked from python-hydro/pyro2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbc_demo.py
More file actions
70 lines (47 loc) · 1.64 KB
/
Copy pathbc_demo.py
File metadata and controls
70 lines (47 loc) · 1.64 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
64
65
66
67
68
69
70
# test the boundary fill routine
import numpy as np
import pyro.mesh.boundary as bnd
import pyro.mesh.patch as patch
def doit():
myg = patch.Grid2d(4, 4, ng=2, xmax=1.0, ymax=1.0)
mydata = patch.CellCenterData2d(myg, dtype=np.int32)
bco = bnd.BC(xlb="outflow", xrb="outflow",
ylb="outflow", yrb="outflow")
mydata.register_var("outflow", bco)
bcp = bnd.BC(xlb="periodic", xrb="periodic",
ylb="periodic", yrb="periodic")
mydata.register_var("periodic", bcp)
bcre = bnd.BC(xlb="reflect-even", xrb="reflect-even",
ylb="reflect-even", yrb="reflect-even")
mydata.register_var("reflect-even", bcre)
bcro = bnd.BC(xlb="reflect-odd", xrb="reflect-odd",
ylb="reflect-odd", yrb="reflect-odd")
mydata.register_var("reflect-odd", bcro)
mydata.create()
a = mydata.get_var("outflow")
for i in range(myg.ilo, myg.ihi+1):
for j in range(myg.jlo, myg.jhi+1):
a[i, j] = (i-myg.ilo) + 10*(j-myg.jlo) + 1
b = mydata.get_var("periodic")
c = mydata.get_var("reflect-even")
d = mydata.get_var("reflect-odd")
b[:, :] = a[:, :]
c[:, :] = a[:, :]
d[:, :] = a[:, :]
mydata.fill_BC("outflow")
mydata.fill_BC("periodic")
mydata.fill_BC("reflect-even")
mydata.fill_BC("reflect-odd")
print("outflow")
mydata.pretty_print("outflow")
print(" ")
print("periodic")
mydata.pretty_print("periodic")
print(" ")
print("reflect-even")
mydata.pretty_print("reflect-even")
print(" ")
print("reflect-odd")
mydata.pretty_print("reflect-odd")
if __name__ == "__main__":
doit()