Skip to content

Commit 91c7aa3

Browse files
authored
Merge pull request #84 from BconstantMMK/dev
Fast/FastS: update test-cases that use old IBM functions from Apps.Fa…
2 parents e6fa532 + a3c4a0d commit 91c7aa3

15 files changed

+747
-232
lines changed

Fast/Fast/Fast/FastIBM.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from Generator.IBM import buildOctree, generateIBMMesh, createRefinementBodies
1+
from Generator.IBM import buildOctree, generateIBMMesh, createRefinementBodies, extrudeCartesianZDir
22

3-
from Connector.IBM import prepareIBMData, dist2wallIBM, blankingIBM, buildFrontIBM, setInterpDataIBM, initializeIBM
3+
from Connector.IBM import prepareIBMData, prepareIBMDataExtrude, dist2wallIBM, blankingIBM, buildFrontIBM, setInterpDataIBM, initializeIBM
44

55
from Geom.IBM import setSnear, _setSnear, setDfar, _setDfar, setIBCType, _setIBCType, _setFluidInside, _setFluidOutside, snearFactor, _snearFactor, setIBCType, changeIBCType, _changeIBCType, initOutflow, _initOutflow, initInj, _initInj, setFluidInside, setFluidOutside, flatPlate, bumpInChannel, naca0012
66

Fast/Fast/test/FastIBM.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

Fast/Fast/test/FastIBMO.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

Fast/Fast/test/FastIBMWireMeshModel_m1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## test case - Wire Mesh Model
22
import Connector.IBM as X_IBM
3-
import Fast.IBM as App
3+
import Distributor2.PyTree as D2
44
import Converter.PyTree as C
55
import Converter.Mpi as Cmpi
66
import Converter.Internal as Internal
@@ -50,7 +50,7 @@
5050
X_IBM.prepareIBMData(tb , tFile , tcFile , tbox=tboffset,
5151
snears=snears , dfars=dfars , vmin=vmin,
5252
check=False , frontType=1 , cartesian=False)
53-
App._distribute(tFile, tcFile, NP=Cmpi.size)
53+
D2._distributeSkeletonTree([tcFile, tFile], Cmpi.size)
5454
t = Fast.loadTree(tFile, split='single')
5555
tc,graph= Fast.loadFile(tcFile, split='single', graph=True)
5656

Fast/Fast/test/FastIBM_t1.py

Lines changed: 74 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,89 @@
1-
# - Fast.IBM -
1+
# - FastIBM -
22
# Euler, seq, frontType=1
3-
import Fast.IBM as App
3+
import Fast.FastIBM as FastIBM
4+
import FastS.PyTree as FastS
5+
import Fast.PyTree as Fast
46
import Converter.PyTree as C
57
import Converter.Internal as Internal
68
import KCore.test as test
79

810
LOCAL = test.getLocal()
911

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-
1912
# Prepare
20-
myApp.input_var.NP = 1
21-
t, tc = myApp.prepare('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)
2214
Internal._rmNodesFromName(tc, Internal.__GridCoordinates__)
15+
16+
####
17+
# The following lines are to avoid regression
18+
####
19+
floweq = Internal.getNodeByType(tc, 'FlowEquationSet_t')
20+
Internal._rmNodesByType(tc, 'FlowEquationSet_t')
21+
refste = Internal.getNodeByType(tc, 'ReferenceState_t')
22+
Internal._rmNodesByType(tc, 'ReferenceState_t')
23+
ibcdata = Internal.getNodeByName(tc, '.Solver#IBCdefine')
24+
Internal._rmNodesByName(tc, '.Solver#IBCdefine')
25+
base = Internal.getBases(tc)[0]
26+
Internal.addChild(base, floweq, -1)
27+
Internal.addChild(base, refste, -1)
28+
Internal.addChild(base, ibcdata, -1)
29+
30+
Internal.getNodeFromName(tc, 'CARTESIAN')[1][0] = 3
31+
Internal._rmNodesByName(tc, 'TurbulenceModel')
32+
Internal._rmNodesByName(t, 'TurbulenceModel')
33+
34+
for b in Internal.getBases(tc):
35+
for z in Internal.getZones(b):
36+
pos = 0
37+
z2 = Internal.copyRef(z)
38+
dictOfIBCDZones = {zs[0]: Internal.copyRef(zs) for zs in z2[2] if 'IBCD' in zs[0]}
39+
dictOfIBCRZones = {zs[0].split('_')[-1]: [] for zs in z2[2] if 'IBCD' in zs[0]}
40+
rcvzone = ''
41+
for zs in z2[2]:
42+
if 'IBCD' in zs[0]:
43+
rcvzoneL = zs[0].split('_')[-1]
44+
dictOfIBCRZones[rcvzoneL].append(zs[0])
45+
listOfIBCRZonesL = list(dictOfIBCRZones[rcvzoneL])
46+
pos += 1
47+
for zname in dictOfIBCRZones[rcvzoneL]:
48+
listOfIBCRZonesL.append(zname)
49+
Internal.addChild(z, dictOfIBCDZones[zname], pos)
50+
pos +=1
51+
dictOfIBCRZones[rcvzoneL] = list(listOfIBCRZonesL)
52+
else:
53+
pos += 1
54+
####
55+
2356
test.testT(tc, 1)
2457

2558
# 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)
59+
numb = {}
60+
numb["temporal_scheme"] = "implicit"
61+
numb["ss_iteration"] = 3
62+
numb["omp_mode"] = 0
63+
64+
numz = {}
65+
numz["time_step"] = 0.0007
66+
numz["time_step_nature"] = "local"
67+
numz["cfl"] = 4.
68+
numz["scheme"] = "roe_min"
69+
70+
it0 = 0.; time0 = 0.; NIT = 300
71+
Fast._setNum2Base(t, numb); Fast._setNum2Zones(t, numz)
72+
73+
t, tc, metrics = FastS.warmup(t, tc)
74+
75+
time_step = Internal.getNodeFromName(t, 'time_step')
76+
time_step = Internal.getValue(time_step)
77+
78+
for it in range(NIT):
79+
if it%100 == 0: print("it %d / %d"%(it, NIT), flush=True)
80+
FastS._compute(t, metrics, it, tc)
81+
time0 += time_step
82+
83+
Internal.createUniqueChild(t, 'Iteration', 'DataArray_t', value=NIT)
84+
Internal.createUniqueChild(t, 'Time', 'DataArray_t', value=time0)
85+
Fast.saveTree(t, 'restart.cgns', split='single', compress=0)
86+
Fast.saveTree(tc, 'tc_restart.cgns', split='single')
2787
t = C.convertFile2PyTree(LOCAL+'/restart.cgns')
2888
Internal._rmNodesFromName(t, '.Solver#Param')
2989
Internal._rmNodesFromName(t, '.Solver#ownData')
@@ -32,8 +92,3 @@
3292
test.testT(t, 2)
3393

3494
# 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._rmNodesFromName(t, '.Solver#dtloc')
37-
Internal._rmNodesFromName(zw, '.Solver#dtloc')
38-
test.testT(t, 3)
39-
test.testT(zw, 4)

Fast/Fast/test/FastIBM_t2.py

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,95 @@
1-
# - Fast.IBM -
1+
# - FastIBM -
22
# 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
46
import Converter.PyTree as C
57
import Converter.Internal as Internal
68
import KCore.test as test
79

810
LOCAL = test.getLocal()
911

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-
1912
# 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)
2114
Internal._rmNodesFromType(tc,'Rind_t')
2215
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+
2357
test.testT(tc, 1)
2458

2559
# 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')
2788
t = C.convertFile2PyTree(LOCAL+'/restart.cgns')
2889
Internal._rmNodesByName(t, '.Solver#Param')
2990
Internal._rmNodesByName(t, '.Solver#ownData')
3091
Internal._rmNodesByName(t, '.Solver#dtloc')
3192
Internal._rmNodesFromType(t, 'Rind_t')
3293
test.testT(t, 2)
3394

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

Comments
 (0)