-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtest.py
118 lines (93 loc) · 2.6 KB
/
test.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from LBM_python import *
import time
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
print ('%r (%r, %r) %2.2f sec' % (method.__name__, args, kw, te-ts))
return result
return timed
class Foo(object):
@timeit
def foo(self, a=2, b=3):
pass
numpy.set_printoptions(3)
nx = 400
ny = 50
center_x = 3
center_y = 3
radius = 2
omega = 1
#define geometry
topPlate = Indicator.cuboid(0,ny,nx,ny) #x1,y1,x2,y2
circle = Indicator.circle(center_x,center_y,radius)
rightPlate = Indicator.cuboid(nx,0,nx,ny)
leftPlate = Indicator.cuboid(0,0,0,ny)
cGeometry = CuboidGeometry2D(0,0,nx,ny)
cGeometry.setPeriodicity()
superG = SuperGeometry(cGeometry)
superG.rename(0,5,topPlate)
superG.rename(0,1,circle)
superG.rename(0,2)
superG.rename(2,3,rightPlate)
superG.rename(2,4,leftPlate)
#print(superG.materialMap)
superG.print()
print('================================================')
#lattice
rho = 1
u = [0,0]
sLattice = SuperLattice2D(superG)
sLattice.defineRhoU(superG,1,rho,u)
sLattice.defineRhoU(superG,4,rho,u)
sLattice.defineRhoU(superG,5,rho,u)
sLattice.defineRhoU(superG,3,rho,u)
sLattice.defineRhoU(superG,2,rho,u)
#print(sLattice.getRhoMap())
#print(sLattice.getRhoMap().sum())
#print(sLattice.getUxMap())
#print(sLattice.getUyMap())
#print(sLattice.getSpeedMap())
bulk1 = BGKdynamics(omega)
bounceb = BBwall()
bbv = BBvelocity(omega)
bbp = BBpressure(omega)
sLattice.defineDynamics(superG,1,bulk1)# SuperGeometry, materialNum, dynamics
sLattice.defineDynamics(superG,2,bulk1)
sLattice.defineDynamics(superG,3,bbv)
sLattice.defineDynamics(superG,4,bbp)
sLattice.defineDynamics(superG,5,bounceb)
#print(sLattice.dynamics)
#print(sLattice.omega)
#print(sLattice.dynamics)
#print(sLattice.getUxMap())
#print(sLattice.getUyMap())
#print(sLattice.getAverageRho())
#print(sLattice.getRhoMap())
maxVelocity = numpy.array([-0.1,0])
poV = Poiseuille2D(superG,3,maxVelocity,0.5) #SuperGeometry,materialNum,maxVelocity,distance2Wall
#print(superG.materialMap)
@timeit
def f1():
pass
#print(sLattice.getAverageRho())
@timeit
def collide(iter):
for i in numpy.arange(iter):
sLattice.collide()
################################################################################################
@timeit
def stream(iter):
for i in numpy.arange(iter):
sLattice.stream()
@timeit
def define(iter):
for i in numpy.arange(iter):
sLattice.defineU_BC(superG,3,poV.getVelocityField())
sLattice.defineRho_BC(superG,4,1)
f1()
collide(100)
stream(100)
define(100)
Foo().foo()