Skip to content

Commit 95ed0ee

Browse files
committed
Added pyvnt implementation of cavity case and modified writer function according to needs
1 parent 965e6de commit 95ed0ee

File tree

15 files changed

+590
-15
lines changed

15 files changed

+590
-15
lines changed

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"files.associations": {
3-
"dictionaryFile.C": "cpp"
3+
"dictionaryFile.C": "cpp",
4+
"*Dict": "OpenFOAM",
5+
"*Properties": "OpenFOAM",
6+
"fvSchemes": "OpenFOAM",
7+
"fvSolution": "OpenFOAM",
8+
"**/constant/g": "OpenFOAM",
9+
"**/0/*": "OpenFOAM"
410
},
511
"python.testing.pytestArgs": [
612
"tests"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from pyvnt import *
2+
3+
p = Node_C("P")
4+
5+
dim = Dim_Set_P("dimensions", [0, 2, -2, 0, 0, 0, 0])
6+
7+
p.add_data(dim)
8+
9+
internalField = Key_C("internalField",
10+
Enm_P("type", {"uniform", "nonuniform"}, "uniform"),
11+
Flt_P("value", 0)
12+
)
13+
14+
p.add_data(internalField)
15+
16+
bf = Node_C("boundaryField", p)
17+
18+
mWall = Node_C("mWall", bf, [],
19+
Key_C("type",
20+
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "zeroGradient")
21+
)
22+
)
23+
24+
fWalls = Node_C("fWalls", bf, [],
25+
Key_C("type",
26+
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "zeroGradient")
27+
)
28+
)
29+
30+
fnb = Node_C("fnb", bf, [],
31+
Key_C("type",
32+
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "empty")
33+
)
34+
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from pyvnt import *
2+
3+
u = Node_C("U")
4+
5+
dim = Key_C("dimensions",
6+
Dim_Set_P("dim_set", [0, 1, -1, 0, 0, 0, 0])
7+
)
8+
9+
u.add_data(dim)
10+
11+
internalField = Key_C("internalField",
12+
Enm_P("type", {"uniform", "nonuniform"}, "uniform"),
13+
Vector_P("value", 0, 0, 0)
14+
)
15+
16+
u.add_data(internalField)
17+
18+
bf = Node_C("boundaryField", u)
19+
20+
mWall = Node_C("mWall", bf, [],
21+
Key_C("type",
22+
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "fixedValue")
23+
),
24+
Key_C("value",
25+
Enm_P("type", {"uniform", "nonuniform"}, "uniform"),
26+
Vector_P("value", 1, 0, 0)
27+
)
28+
)
29+
30+
fWalls = Node_C("fWalls", bf, [],
31+
Key_C("type",
32+
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "noSlip")
33+
)
34+
)
35+
36+
fnb = Node_C("fnb", bf, [],
37+
Key_C("type",
38+
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "empty")
39+
)
40+
)
41+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from pyvnt import *
2+
3+
transportProperties = Node_C("transportProperties")
4+
5+
nu = Key_C("nu",
6+
Dim_Set_P("nu_dim", [0, 2, -1, 0, 0, 0, 0]),
7+
Flt_P("nu_val", 0.01)
8+
)
9+
10+
transportProperties.add_data(nu)
11+
12+
writeTo(transportProperties, "Demo_case_files/")
Lines changed: 113 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
from pyvnt import *
22

33
blockMeshDict = Node_C("blockMeshDict")
4-
cM = Key_C("convertToMeters", "1.0")
4+
cM = Key_C("convertToMeters", Flt_P("convertToMeters", 0.1))
55

66
blockMeshDict.add_data(cM)
77

8-
vertices = List_CP("vertices")
9-
108
v = [
119
[0, 0, 0],
1210
[1, 0, 0],
@@ -18,12 +16,122 @@
1816
[0, 1, 0.1]
1917
]
2018

19+
v_elem = []
20+
2121
for i in range(len(v)):
22-
vertices.append_elem(List_CP(name=f'v_{i+1}', elems=[[Flt_P('x', i[0]), Flt_P('y', i[1]), Flt_P('z', i[2])]]))
22+
v_elem.append([List_CP(f"v{i}", elems=[[Flt_P('x', v[i][0]), Flt_P('y', v[i][1]), Flt_P('z', v[i][2])]])])
23+
24+
vertices = List_CP("vertices", elems=v_elem)
2325

2426
verts = Key_C("vertices", vertices)
2527

2628
blockMeshDict.add_data(verts)
2729

28-
blocks = List_CP("blocks")
30+
e1 = [
31+
Enm_P("type", {"hex"}, "hex"),
32+
List_CP("faces", elems=[[
33+
Int_P("v0", 0),
34+
Int_P("v1", 1),
35+
Int_P("v2", 2),
36+
Int_P("v3", 3),
37+
Int_P("v4", 4),
38+
Int_P("v5", 5),
39+
Int_P("v6", 6),
40+
Int_P("v7", 7)
41+
]]),
42+
List_CP("res", elems=[[
43+
Int_P("nx", 20),
44+
Int_P("ny", 20),
45+
Int_P("nz", 1)
46+
]]),
47+
Enm_P("grading", {"simpleGrading"}, "simpleGrading"),
48+
List_CP("simpleGrading", elems=[[
49+
Int_P("x", 1),
50+
Int_P("y", 1),
51+
Int_P("z", 1)
52+
]])
53+
]
54+
55+
blocks = List_CP("blocks", elems=[e1])
56+
57+
blks = Key_C("blocks", blocks)
58+
59+
blockMeshDict.add_data(blks)
60+
61+
edges = List_CP("edges", elems=[[]])
62+
63+
edgs = Key_C("edges", edges)
64+
65+
blockMeshDict.add_data(edgs)
66+
67+
typ = Key_C("type", Enm_P("type", {"wall", "empty"}, "wall"))
68+
69+
faces_1 = List_CP("faces", elems=[
70+
[List_CP("f0", elems=[[
71+
Int_P("v0", 3),
72+
Int_P("v1", 7),
73+
Int_P("v2", 6),
74+
Int_P("v3", 2)
75+
]])]
76+
])
77+
78+
fcs1 = Key_C("faces", faces_1)
79+
80+
mWall = Node_C("movingWall", None, [], typ, fcs1)
81+
82+
fcs2 = Key_C("faces", List_CP("faces", elems=[
83+
[List_CP("f0", elems=[
84+
[
85+
Int_P("v0", 0),
86+
Int_P("v1", 4),
87+
Int_P("v2", 7),
88+
Int_P("v3", 3)
89+
]])], [List_CP("f1", elems=[
90+
[
91+
Int_P("v0", 2),
92+
Int_P("v1", 6),
93+
Int_P("v2", 5),
94+
Int_P("v3", 1)
95+
]])], [List_CP("f2", elems=[
96+
[
97+
Int_P("v0", 1),
98+
Int_P("v1", 5),
99+
Int_P("v2", 4),
100+
Int_P("v3", 0)
101+
]])],
102+
103+
]))
104+
105+
fwall = Node_C("fixedWalls", None, [], typ, fcs2)
106+
107+
fcs3 = Key_C("faces", List_CP("faces", elems=[
108+
[List_CP("f0", elems=[[
109+
Int_P("v0", 0),
110+
Int_P("v1", 3),
111+
Int_P("v2", 2),
112+
Int_P("v3", 1)
113+
]])],
114+
[List_CP("f1", elems=[[
115+
Int_P("v0", 4),
116+
Int_P("v1", 5),
117+
Int_P("v2", 6),
118+
Int_P("v3", 7)
119+
]])]
120+
121+
]))
122+
123+
typ2 = Key_C("type", Enm_P("type", {"wall", "empty"}, "empty"))
124+
125+
fnb = Node_C("frontAndBack", None, [], typ2 , fcs3)
126+
127+
bnd = List_CP("boundary", values=[mWall, fwall, fnb], isNode=True)
128+
129+
blockMeshDict.add_child(bnd)
130+
131+
mergePatchPairs = List_CP("mergePatchPairs", elems=[[]])
132+
133+
mpp = Key_C("mergePatchPairs", mergePatchPairs)
134+
135+
blockMeshDict.add_data(mpp)
29136

137+
writeTo(blockMeshDict, "Demo_case_files/")
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from pyvnt import *
2+
3+
controlDict = Node_C("controlDict")
4+
5+
app = Key_C("application", Enm_P("application", {"icoFoam", "simpleFoam", "pimpleFoam"}, "icoFoam"))
6+
7+
controlDict.add_data(app)
8+
9+
startFrom = Key_C("startFrom", Enm_P("startFrom", {"startTime", "latestTime"}, "startTime"))
10+
11+
controlDict.add_data(startFrom)
12+
13+
startTime = Key_C("startTime", Flt_P("startTime", 0))
14+
15+
controlDict.add_data(startTime)
16+
17+
stopAt = Key_C("stopAt", Enm_P("stopAt", {"endTime", "startTime"}, "endTime"))
18+
19+
controlDict.add_data(stopAt)
20+
21+
endTime = Key_C("endTime", Flt_P("endTime", 0.5))
22+
23+
controlDict.add_data(endTime)
24+
25+
deltaT = Key_C("deltaT", Flt_P("deltaT", 0.005))
26+
27+
controlDict.add_data(deltaT)
28+
29+
writeControl = Key_C("writeControl", Enm_P("writeControl", {"timeStep", "runTime", "adjustableRunTime"}, "timeStep"))
30+
31+
controlDict.add_data(writeControl)
32+
33+
writeInterval = Key_C("writeInterval", Int_P("writeInterval", 20))
34+
35+
controlDict.add_data(writeInterval)
36+
37+
purgeWrite = Key_C("purgeWrite", Flt_P("purgeWrite", 0))
38+
39+
controlDict.add_data(purgeWrite)
40+
41+
writeFormat = Key_C("writeFormat", Enm_P("writeFormat", {"ascii", "binary"}, "ascii"))
42+
43+
controlDict.add_data(writeFormat)
44+
45+
writePrecision = Key_C("writePrecision", Int_P("writePrecision", 6))
46+
47+
controlDict.add_data(writePrecision)
48+
49+
writeCompression = Key_C("writeCompression", Enm_P("writeCompression", {"off", "on"}, "off"))
50+
51+
controlDict.add_data(writeCompression)
52+
53+
timeFormat = Key_C("timeFormat", Enm_P("timeFormat", {"general", "scientific"}, "general"))
54+
55+
controlDict.add_data(timeFormat)
56+
57+
timePrecision = Key_C("timePrecision", Int_P("timePrecision", 6))
58+
59+
controlDict.add_data(timePrecision)
60+
61+
runTimeModifiable = Key_C("runTimeModifiable", Enm_P("runTimeModifiable", {"true", "false"}, "true"))
62+
63+
controlDict.add_data(runTimeModifiable)
64+
65+
writeTo(controlDict, "Demo_case_files/")
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from pyvnt import *
2+
3+
fvSchemes = Node_C("fvSchemes")
4+
5+
ddtSchemes = Node_C(
6+
"ddtSchemes", fvSchemes, [],
7+
Key_C(
8+
"default",
9+
Enm_P("default", {"Euler", "CrankNicolson"}, "Euler")
10+
)
11+
)
12+
13+
gradSchemes = Node_C(
14+
"gradSchemes", fvSchemes, [],
15+
Key_C(
16+
"default",
17+
Enm_P("def1", {"Gauss", "CrankNicolson", "none"}, "Gauss"),
18+
Enm_P("def2", {"linear", "limitedlinear", "limitedCubic"}, "linear")
19+
),
20+
Key_C(
21+
"grad(p)",
22+
Enm_P("gradp1", {"Gauss", "CrankNicolson", "none"}, "Gauss"),
23+
Enm_P("gradp2", {"linear", "limitedlinear", "limitedCubic"}, "linear")
24+
)
25+
)
26+
27+
divSchemes = Node_C(
28+
"divSchemes", fvSchemes, [],
29+
Key_C(
30+
"default",
31+
Enm_P("def1", {"Gauss", "CrankNicolson", "none"}, "none"),
32+
),
33+
Key_C(
34+
"div(phi,U)",
35+
Enm_P("divphi1", {"Gauss", "CrankNicolson", "none"}, "Gauss"),
36+
Enm_P("divphi2", {"linear", "limitedLinear", "limitedCubic"}, "linear")
37+
)
38+
)
39+
40+
laplacianSchemes = Node_C(
41+
"laplacianSchemes", fvSchemes, [],
42+
Key_C(
43+
"default",
44+
Enm_P("def1", {"Gauss", "CrankNicolson", "none"}, "Gauss"),
45+
Enm_P("def2", {"linear", "limitedLinear", "limitedCubic"}, "linear"),
46+
Enm_P("def3", {"hexagonal", "orthogonal", "skew", "symmetric"}, "orthogonal")
47+
)
48+
)
49+
50+
interpolationSchemes = Node_C(
51+
"interpolationSchemes", fvSchemes, [],
52+
Key_C(
53+
"default",
54+
Enm_P("def1", {"linear", "linearUpwind", "linearLimited", "linearV", "linearVUpwind", "linearVLimited"}, "linear")
55+
)
56+
)
57+
58+
snGradSchemes = Node_C(
59+
"snGradSchemes", fvSchemes, [],
60+
Key_C(
61+
"default",
62+
Enm_P("def1", {"hexagonal", "orthogonal", "skew", "symmetric"}, "orthogonal")
63+
)
64+
)
65+
66+
writeTo(fvSchemes, "Demo_case_files/")

0 commit comments

Comments
 (0)