Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pyvnt implementation of cavity case and modified writer function according to needs #11

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"files.associations": {
"dictionaryFile.C": "cpp"
"dictionaryFile.C": "cpp",
"*Dict": "OpenFOAM",
"*Properties": "OpenFOAM",
"fvSchemes": "OpenFOAM",
"fvSolution": "OpenFOAM",
"**/constant/g": "OpenFOAM",
"**/0/*": "OpenFOAM"
},
"python.testing.pytestArgs": [
"tests"
Expand Down
34 changes: 34 additions & 0 deletions Demo_case_files/cavity_pyvnt/0_fields/p.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from pyvnt import *

p = Node_C("P")

dim = Dim_Set_P("dimensions", [0, 2, -2, 0, 0, 0, 0])

p.add_data(dim)

internalField = Key_C("internalField",
Enm_P("type", {"uniform", "nonuniform"}, "uniform"),
Flt_P("value", 0)
)

p.add_data(internalField)

bf = Node_C("boundaryField", p)

mWall = Node_C("mWall", bf, [],
Key_C("type",
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "zeroGradient")
)
)

fWalls = Node_C("fWalls", bf, [],
Key_C("type",
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "zeroGradient")
)
)

fnb = Node_C("fnb", bf, [],
Key_C("type",
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "empty")
)
)
41 changes: 41 additions & 0 deletions Demo_case_files/cavity_pyvnt/0_fields/u.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from pyvnt import *

u = Node_C("U")

dim = Key_C("dimensions",
Dim_Set_P("dim_set", [0, 1, -1, 0, 0, 0, 0])
)

u.add_data(dim)

internalField = Key_C("internalField",
Enm_P("type", {"uniform", "nonuniform"}, "uniform"),
Vector_P("value", 0, 0, 0)
)

u.add_data(internalField)

bf = Node_C("boundaryField", u)

mWall = Node_C("mWall", bf, [],
Key_C("type",
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "fixedValue")
),
Key_C("value",
Enm_P("type", {"uniform", "nonuniform"}, "uniform"),
Vector_P("value", 1, 0, 0)
)
)

fWalls = Node_C("fWalls", bf, [],
Key_C("type",
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "noSlip")
)
)

fnb = Node_C("fnb", bf, [],
Key_C("type",
Enm_P("type", {"fixedValue", "zeroGradient", "noSlip", "empty"}, "empty")
)
)

12 changes: 12 additions & 0 deletions Demo_case_files/cavity_pyvnt/constant/transportProperties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pyvnt import *

transportProperties = Node_C("transportProperties")

nu = Key_C("nu",
Dim_Set_P("nu_dim", [0, 2, -1, 0, 0, 0, 0]),
Flt_P("nu_val", 0.01)
)

transportProperties.add_data(nu)

writeTo(transportProperties, "Demo_case_files/")
118 changes: 113 additions & 5 deletions Demo_case_files/cavity_pyvnt/system/blockMeshDict.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from pyvnt import *

blockMeshDict = Node_C("blockMeshDict")
cM = Key_C("convertToMeters", "1.0")
cM = Key_C("convertToMeters", Flt_P("convertToMeters", 0.1))

blockMeshDict.add_data(cM)

vertices = List_CP("vertices")

v = [
[0, 0, 0],
[1, 0, 0],
Expand All @@ -18,12 +16,122 @@
[0, 1, 0.1]
]

v_elem = []

for i in range(len(v)):
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])]]))
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])]])])

vertices = List_CP("vertices", elems=v_elem)

verts = Key_C("vertices", vertices)

blockMeshDict.add_data(verts)

blocks = List_CP("blocks")
e1 = [
Enm_P("type", {"hex"}, "hex"),
List_CP("faces", elems=[[
Int_P("v0", 0),
Int_P("v1", 1),
Int_P("v2", 2),
Int_P("v3", 3),
Int_P("v4", 4),
Int_P("v5", 5),
Int_P("v6", 6),
Int_P("v7", 7)
]]),
List_CP("res", elems=[[
Int_P("nx", 20),
Int_P("ny", 20),
Int_P("nz", 1)
]]),
Enm_P("grading", {"simpleGrading"}, "simpleGrading"),
List_CP("simpleGrading", elems=[[
Int_P("x", 1),
Int_P("y", 1),
Int_P("z", 1)
]])
]

blocks = List_CP("blocks", elems=[e1])

blks = Key_C("blocks", blocks)

blockMeshDict.add_data(blks)

edges = List_CP("edges", elems=[[]])

edgs = Key_C("edges", edges)

blockMeshDict.add_data(edgs)

typ = Key_C("type", Enm_P("type", {"wall", "empty"}, "wall"))

faces_1 = List_CP("faces", elems=[
[List_CP("f0", elems=[[
Int_P("v0", 3),
Int_P("v1", 7),
Int_P("v2", 6),
Int_P("v3", 2)
]])]
])

fcs1 = Key_C("faces", faces_1)

mWall = Node_C("movingWall", None, [], typ, fcs1)

fcs2 = Key_C("faces", List_CP("faces", elems=[
[List_CP("f0", elems=[
[
Int_P("v0", 0),
Int_P("v1", 4),
Int_P("v2", 7),
Int_P("v3", 3)
]])], [List_CP("f1", elems=[
[
Int_P("v0", 2),
Int_P("v1", 6),
Int_P("v2", 5),
Int_P("v3", 1)
]])], [List_CP("f2", elems=[
[
Int_P("v0", 1),
Int_P("v1", 5),
Int_P("v2", 4),
Int_P("v3", 0)
]])],

]))

fwall = Node_C("fixedWalls", None, [], typ, fcs2)

fcs3 = Key_C("faces", List_CP("faces", elems=[
[List_CP("f0", elems=[[
Int_P("v0", 0),
Int_P("v1", 3),
Int_P("v2", 2),
Int_P("v3", 1)
]])],
[List_CP("f1", elems=[[
Int_P("v0", 4),
Int_P("v1", 5),
Int_P("v2", 6),
Int_P("v3", 7)
]])]

]))

typ2 = Key_C("type", Enm_P("type", {"wall", "empty"}, "empty"))

fnb = Node_C("frontAndBack", None, [], typ2 , fcs3)

bnd = List_CP("boundary", values=[mWall, fwall, fnb], isNode=True)

blockMeshDict.add_child(bnd)

mergePatchPairs = List_CP("mergePatchPairs", elems=[[]])

mpp = Key_C("mergePatchPairs", mergePatchPairs)

blockMeshDict.add_data(mpp)

writeTo(blockMeshDict, "Demo_case_files/")
65 changes: 65 additions & 0 deletions Demo_case_files/cavity_pyvnt/system/controlDict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
from pyvnt import *

controlDict = Node_C("controlDict")

app = Key_C("application", Enm_P("application", {"icoFoam", "simpleFoam", "pimpleFoam"}, "icoFoam"))

controlDict.add_data(app)

startFrom = Key_C("startFrom", Enm_P("startFrom", {"startTime", "latestTime"}, "startTime"))

controlDict.add_data(startFrom)

startTime = Key_C("startTime", Flt_P("startTime", 0))

controlDict.add_data(startTime)

stopAt = Key_C("stopAt", Enm_P("stopAt", {"endTime", "startTime"}, "endTime"))

controlDict.add_data(stopAt)

endTime = Key_C("endTime", Flt_P("endTime", 0.5))

controlDict.add_data(endTime)

deltaT = Key_C("deltaT", Flt_P("deltaT", 0.005))

controlDict.add_data(deltaT)

writeControl = Key_C("writeControl", Enm_P("writeControl", {"timeStep", "runTime", "adjustableRunTime"}, "timeStep"))

controlDict.add_data(writeControl)

writeInterval = Key_C("writeInterval", Int_P("writeInterval", 20))

controlDict.add_data(writeInterval)

purgeWrite = Key_C("purgeWrite", Flt_P("purgeWrite", 0))

controlDict.add_data(purgeWrite)

writeFormat = Key_C("writeFormat", Enm_P("writeFormat", {"ascii", "binary"}, "ascii"))

controlDict.add_data(writeFormat)

writePrecision = Key_C("writePrecision", Int_P("writePrecision", 6))

controlDict.add_data(writePrecision)

writeCompression = Key_C("writeCompression", Enm_P("writeCompression", {"off", "on"}, "off"))

controlDict.add_data(writeCompression)

timeFormat = Key_C("timeFormat", Enm_P("timeFormat", {"general", "scientific"}, "general"))

controlDict.add_data(timeFormat)

timePrecision = Key_C("timePrecision", Int_P("timePrecision", 6))

controlDict.add_data(timePrecision)

runTimeModifiable = Key_C("runTimeModifiable", Enm_P("runTimeModifiable", {"true", "false"}, "true"))

controlDict.add_data(runTimeModifiable)

writeTo(controlDict, "Demo_case_files/")
66 changes: 66 additions & 0 deletions Demo_case_files/cavity_pyvnt/system/fvSchemes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from pyvnt import *

fvSchemes = Node_C("fvSchemes")

ddtSchemes = Node_C(
"ddtSchemes", fvSchemes, [],
Key_C(
"default",
Enm_P("default", {"Euler", "CrankNicolson"}, "Euler")
)
)

gradSchemes = Node_C(
"gradSchemes", fvSchemes, [],
Key_C(
"default",
Enm_P("def1", {"Gauss", "CrankNicolson", "none"}, "Gauss"),
Enm_P("def2", {"linear", "limitedlinear", "limitedCubic"}, "linear")
),
Key_C(
"grad(p)",
Enm_P("gradp1", {"Gauss", "CrankNicolson", "none"}, "Gauss"),
Enm_P("gradp2", {"linear", "limitedlinear", "limitedCubic"}, "linear")
)
)

divSchemes = Node_C(
"divSchemes", fvSchemes, [],
Key_C(
"default",
Enm_P("def1", {"Gauss", "CrankNicolson", "none"}, "none"),
),
Key_C(
"div(phi,U)",
Enm_P("divphi1", {"Gauss", "CrankNicolson", "none"}, "Gauss"),
Enm_P("divphi2", {"linear", "limitedLinear", "limitedCubic"}, "linear")
)
)

laplacianSchemes = Node_C(
"laplacianSchemes", fvSchemes, [],
Key_C(
"default",
Enm_P("def1", {"Gauss", "CrankNicolson", "none"}, "Gauss"),
Enm_P("def2", {"linear", "limitedLinear", "limitedCubic"}, "linear"),
Enm_P("def3", {"hexagonal", "orthogonal", "skew", "symmetric"}, "orthogonal")
)
)

interpolationSchemes = Node_C(
"interpolationSchemes", fvSchemes, [],
Key_C(
"default",
Enm_P("def1", {"linear", "linearUpwind", "linearLimited", "linearV", "linearVUpwind", "linearVLimited"}, "linear")
)
)

snGradSchemes = Node_C(
"snGradSchemes", fvSchemes, [],
Key_C(
"default",
Enm_P("def1", {"hexagonal", "orthogonal", "skew", "symmetric"}, "orthogonal")
)
)

writeTo(fvSchemes, "Demo_case_files/")
Loading
Loading