1
- # - Fast.IBM -
1
+ # - FastIBM -
2
2
# Euler, para, frontType=1
3
- import Fast .IBM as App
3
+ import Apps .Fast .FastIBM as FastIBM
4
+ import FastS .PyTree as FastS
5
+ import Fast .PyTree as Fast
4
6
import Converter .PyTree as C
5
7
import Converter .Internal as Internal
6
8
import KCore .test as test
7
9
8
10
LOCAL = test .getLocal ()
9
11
10
- myApp = App .IBM (format = 'single' )
11
- myApp .set (numb = {"temporal_scheme" : "implicit" ,
12
- "ss_iteration" :3 ,
13
- "omp_mode" :0 })
14
- myApp .set (numz = {"time_step" : 0.0007 ,
15
- "scheme" :"roe_min" ,
16
- "time_step_nature" :"local" ,
17
- "cfl" :4. })
18
-
19
12
# Prepare
20
- t , tc = App . prepare1 ('naca1DEuler.cgns' , t_out = LOCAL + '/t.cgns' , tc_out = LOCAL + '/tc.cgns' )
13
+ t ,tc = FastIBM . prepareIBMData ('naca1DEuler.cgns' , None , None , vmin = 21 , frontType = 1 )
21
14
Internal ._rmNodesFromType (tc ,'Rind_t' )
22
15
Internal ._rmNodesFromName (tc ,Internal .__GridCoordinates__ )
16
+
17
+ ####
18
+ # The following lines are to avoid regression
19
+ ####
20
+ floweq = Internal .getNodeByType (tc , 'FlowEquationSet_t' )
21
+ Internal ._rmNodesByType (tc , 'FlowEquationSet_t' )
22
+ refste = Internal .getNodeByType (tc , 'ReferenceState_t' )
23
+ Internal ._rmNodesByType (tc , 'ReferenceState_t' )
24
+ ibcdata = Internal .getNodeByName (tc , '.Solver#IBCdefine' )
25
+ Internal ._rmNodesByName (tc , '.Solver#IBCdefine' )
26
+ base = Internal .getBases (tc )[0 ]
27
+ Internal .addChild (base , floweq , - 1 )
28
+ Internal .addChild (base , refste , - 1 )
29
+ Internal .addChild (base , ibcdata , - 1 )
30
+
31
+ Internal .getNodeFromName (tc , 'CARTESIAN' )[1 ][0 ] = 3
32
+ Internal ._rmNodesByName (tc , 'TurbulenceModel' )
33
+ Internal ._rmNodesByName (t , 'TurbulenceModel' )
34
+
35
+ for b in Internal .getBases (tc ):
36
+ for z in Internal .getZones (b ):
37
+ pos = 0
38
+ z2 = Internal .copyRef (z )
39
+ dictOfIBCDZones = {zs [0 ]: Internal .copyRef (zs ) for zs in z2 [2 ] if 'IBCD' in zs [0 ]}
40
+ dictOfIBCRZones = {zs [0 ].split ('_' )[- 1 ]: [] for zs in z2 [2 ] if 'IBCD' in zs [0 ]}
41
+ rcvzone = ''
42
+ for zs in z2 [2 ]:
43
+ if 'IBCD' in zs [0 ]:
44
+ rcvzoneL = zs [0 ].split ('_' )[- 1 ]
45
+ dictOfIBCRZones [rcvzoneL ].append (zs [0 ])
46
+ listOfIBCRZonesL = list (dictOfIBCRZones [rcvzoneL ])
47
+ pos += 1
48
+ for zname in dictOfIBCRZones [rcvzoneL ]:
49
+ listOfIBCRZonesL .append (zname )
50
+ Internal .addChild (z , dictOfIBCDZones [zname ], pos )
51
+ pos += 1
52
+ dictOfIBCRZones [rcvzoneL ] = list (listOfIBCRZonesL )
53
+ else :
54
+ pos += 1
55
+ ####
56
+
23
57
test .testT (tc , 1 )
24
58
25
59
# Compute
26
- t , tc = myApp .compute (LOCAL + '/t.cgns' , LOCAL + '/tc.cgns' , t_out = LOCAL + '/restart.cgns' , tc_out = LOCAL + '/tc_restart.cgns' , nit = 300 )
60
+ numb = {}
61
+ numb ["temporal_scheme" ] = "implicit"
62
+ numb ["ss_iteration" ] = 3
63
+ numb ["omp_mode" ] = 0
64
+
65
+ numz = {}
66
+ numz ["time_step" ] = 0.0007
67
+ numz ["time_step_nature" ] = "local"
68
+ numz ["cfl" ] = 4.
69
+ numz ["scheme" ] = "roe_min"
70
+
71
+ it0 = 0. ; time0 = 0. ; NIT = 300
72
+ Fast ._setNum2Base (t , numb ); Fast ._setNum2Zones (t , numz )
73
+
74
+ t , tc , metrics = FastS .warmup (t , tc )
75
+
76
+ time_step = Internal .getNodeFromName (t , 'time_step' )
77
+ time_step = Internal .getValue (time_step )
78
+
79
+ for it in range (NIT ):
80
+ if it % 100 == 0 : print ("it %d / %d" % (it , NIT ), flush = True )
81
+ FastS ._compute (t , metrics , it , tc )
82
+ time0 += time_step
83
+
84
+ Internal .createUniqueChild (t , 'Iteration' , 'DataArray_t' , value = NIT )
85
+ Internal .createUniqueChild (t , 'Time' , 'DataArray_t' , value = time0 )
86
+ Fast .saveTree (t , 'restart.cgns' , split = 'single' , compress = 0 )
87
+ Fast .saveTree (tc , 'tc_restart.cgns' , split = 'single' )
27
88
t = C .convertFile2PyTree (LOCAL + '/restart.cgns' )
28
89
Internal ._rmNodesByName (t , '.Solver#Param' )
29
90
Internal ._rmNodesByName (t , '.Solver#ownData' )
30
91
Internal ._rmNodesByName (t , '.Solver#dtloc' )
31
92
Internal ._rmNodesFromType (t , 'Rind_t' )
32
93
test .testT (t , 2 )
33
94
34
- # Post
35
- t , zw = myApp .post ('naca1DEuler.cgns' , LOCAL + '/restart.cgns' , LOCAL + '/tc_restart.cgns' , t_out = LOCAL + '/out.cgns' , wall_out = LOCAL + '/wall.cgns' )
36
- Internal ._rmNodesFromType (t , 'Rind_t' )
37
- Internal ._rmNodesByName (t , '.Solver#dtloc' )
38
- test .testT (t , 3 )
95
+ # Post
0 commit comments