Mod: minor changes
This commit is contained in:
parent
c2ef046f74
commit
7d0fe5a4a9
@ -42,15 +42,11 @@ class UltimateRunner(object):
|
|||||||
params = self.config.cases[0]
|
params = self.config.cases[0]
|
||||||
filename = "shape.step"
|
filename = "shape.step"
|
||||||
|
|
||||||
match params["label"]:
|
self.shape = {
|
||||||
case "simple":
|
"simple": Simple,
|
||||||
self.shape = Simple(params["direction"])
|
"bodyCentered": BodyCentered,
|
||||||
|
"faceCentered": FaceCentered
|
||||||
case "bodyCentered":
|
}[params["label"]](params["direction"])
|
||||||
self.shape = BodyCentered(params["direction"])
|
|
||||||
|
|
||||||
case "faceCentered":
|
|
||||||
self.shape = FaceCentered(params["direction"])
|
|
||||||
|
|
||||||
self.shape.build()
|
self.shape.build()
|
||||||
|
|
||||||
@ -90,22 +86,21 @@ class UltimateRunner(object):
|
|||||||
patches[name] = [ f"patch{ n }" ]
|
patches[name] = [ f"patch{ n }" ]
|
||||||
|
|
||||||
for name in patches.keys():
|
for name in patches.keys():
|
||||||
match name:
|
if name == "inlet":
|
||||||
case "inlet":
|
patchGroup = "inlet"
|
||||||
patchGroup = "inlet"
|
patchType = "patch"
|
||||||
patchType = "patch"
|
|
||||||
|
|
||||||
case "outlet":
|
elif name == "outlet":
|
||||||
patchGroup = "outlet"
|
patchGroup = "outlet"
|
||||||
patchType = "patch"
|
patchType = "patch"
|
||||||
|
|
||||||
case "wall":
|
elif name == "wall":
|
||||||
patchGroup = "wall"
|
patchGroup = "wall"
|
||||||
patchType = "wall"
|
patchType = "wall"
|
||||||
|
|
||||||
case _:
|
else:
|
||||||
patchGroup = "symetry"
|
patchGroup = "symetry"
|
||||||
patchType = "symetryPlane"
|
patchType = "symetryPlane"
|
||||||
|
|
||||||
createPatchDict["patches"].append({
|
createPatchDict["patches"].append({
|
||||||
"name": name,
|
"name": name,
|
||||||
@ -118,35 +113,34 @@ class UltimateRunner(object):
|
|||||||
})
|
})
|
||||||
|
|
||||||
flow.append(createPatchDict)
|
flow.append(createPatchDict)
|
||||||
|
flow.write()
|
||||||
# Build a flow
|
# Build a flow
|
||||||
flow.build()
|
#flow.build()
|
||||||
|
|
||||||
|
|
||||||
def pipeline(self, stage: str = None):
|
def pipeline(self, stage: str = None):
|
||||||
stage = stage or self.config["stage"]
|
stage = stage or self.config["stage"]
|
||||||
|
|
||||||
match stage:
|
if stage in ["shape", "all"]:
|
||||||
case "shape" | "all":
|
with self.database.atomic():
|
||||||
with self.database.atomic():
|
Shape.create(self._exec_id, **self.config.cases[0])
|
||||||
Shape.create(self._exec_id, **self.config.cases[0])
|
|
||||||
|
|
||||||
self.computeShape()
|
self.computeShape()
|
||||||
|
|
||||||
case "mesh" | "all":
|
elif stage in ["mesh", "all"]:
|
||||||
with self.database.atomic():
|
with self.database.atomic():
|
||||||
Mesh.create(self._exec_id)
|
Mesh.create(self._exec_id)
|
||||||
|
|
||||||
self.computeMesh()
|
self.computeMesh()
|
||||||
|
|
||||||
case "flow" | "all":
|
elif stage in ["flow", "all"]:
|
||||||
with self.database.atomic():
|
with self.database.atomic():
|
||||||
Flow.create(self._exec_id)
|
Flow.create(self._exec_id)
|
||||||
|
|
||||||
self.computeFlow()
|
self.computeFlow()
|
||||||
|
|
||||||
case "postProcess" | "all":
|
elif stage in ["postProcess", "all"]:
|
||||||
self.postProcess()
|
self.postProcess()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class FoamFile(object):
|
|||||||
"| \\\\ / O peration |",
|
"| \\\\ / O peration |",
|
||||||
"| \\\\ / A nd | |",
|
"| \\\\ / A nd | |",
|
||||||
"| \\\\/ M anipulation | |",
|
"| \\\\/ M anipulation | |",
|
||||||
"\*---------------------------------------------------------------------------*/"
|
"\\*---------------------------------------------------------------------------*/"
|
||||||
]
|
]
|
||||||
desc[3] += " Version: {}".format(version() or "missed")
|
desc[3] += " Version: {}".format(version() or "missed")
|
||||||
desc[3] += " " * (limit - len(desc[3])) + "|"
|
desc[3] += " " * (limit - len(desc[3])) + "|"
|
||||||
|
@ -28,7 +28,7 @@ def checkMesh(case: str = None) -> str:
|
|||||||
with open("checkMesh.log", "r") as io:
|
with open("checkMesh.log", "r") as io:
|
||||||
warnings = []
|
warnings = []
|
||||||
for line in io:
|
for line in io:
|
||||||
if re.search("\*\*\*", line):
|
if re.search(r"***", line):
|
||||||
warnings.append(line.replace("***", "").strip())
|
warnings.append(line.replace("***", "").strip())
|
||||||
|
|
||||||
if warnings:
|
if warnings:
|
||||||
|
@ -136,8 +136,8 @@ class BodyCentered(Periodic):
|
|||||||
inletface.name = "inlet"
|
inletface.name = "inlet"
|
||||||
|
|
||||||
vecFlow = self.normal(inletface)
|
vecFlow = self.normal(inletface)
|
||||||
self.cell = inletface.Extrude(extr)
|
# ISSUE: don't use face.Extrude(length), only face.Extrude(length, vector)
|
||||||
self.cell = reconstruct(self.cell)
|
self.cell = inletface.Extrude(extr, Vec(*vecFlow))
|
||||||
|
|
||||||
# Boundaries
|
# Boundaries
|
||||||
symetryId = 0
|
symetryId = 0
|
||||||
|
@ -143,8 +143,8 @@ class FaceCentered(Periodic):
|
|||||||
inletface.name = "inlet"
|
inletface.name = "inlet"
|
||||||
|
|
||||||
vecFlow = self.normal(inletface)
|
vecFlow = self.normal(inletface)
|
||||||
self.cell = inletface.Extrude(extr)
|
# ISSUE: don't use face.Extrude(length), only face.Extrude(length, vector)
|
||||||
self.cell = reconstruct(self.cell)
|
self.cell = inletface.Extrude(extr, Vec(*vecFlow))
|
||||||
|
|
||||||
# Boundaries
|
# Boundaries
|
||||||
symetryId = 0
|
symetryId = 0
|
||||||
|
@ -27,15 +27,15 @@ def pos(self) -> numpy.array:
|
|||||||
|
|
||||||
|
|
||||||
# ISSUE: netgen.occ.Face.Extrude: the opposite face has the same name and normal vector as an initial face.
|
# ISSUE: netgen.occ.Face.Extrude: the opposite face has the same name and normal vector as an initial face.
|
||||||
def reconstruct(shape):
|
#def reconstruct(shape):
|
||||||
"""Reconstruct shape with new objects.
|
# """Reconstruct shape with new objects.
|
||||||
"""
|
# """
|
||||||
faces = []
|
# faces = []
|
||||||
|
#
|
||||||
for face in shape.faces:
|
# for face in shape.faces:
|
||||||
faceNew = occ.Face(face.wires[0])
|
# faceNew = occ.Face(face.wires[0])
|
||||||
faceNew.name = face.name
|
# faceNew.name = face.name
|
||||||
faces.append(faceNew)
|
# faces.append(faceNew)
|
||||||
|
#
|
||||||
return occ.Solid(faces)
|
# return occ.Solid(faces)
|
||||||
|
|
||||||
|
@ -131,8 +131,8 @@ class Simple(Periodic):
|
|||||||
inletface.name = "inlet"
|
inletface.name = "inlet"
|
||||||
|
|
||||||
vecFlow = self.normal(inletface)
|
vecFlow = self.normal(inletface)
|
||||||
self.cell = inletface.Extrude(extr * Vec(*vecFlow))
|
# ISSUE: don't use face.Extrude(length), only face.Extrude(length, vector)
|
||||||
self.cell = reconstruct(self.cell)
|
self.cell = inletface.Extrude(extr, Vec(*vecFlow))
|
||||||
|
|
||||||
# Boundaries
|
# Boundaries
|
||||||
symetryId = 0
|
symetryId = 0
|
||||||
@ -140,11 +140,11 @@ class Simple(Periodic):
|
|||||||
for face in self.cell.faces:
|
for face in self.cell.faces:
|
||||||
fNorm = self.normal(face)
|
fNorm = self.normal(face)
|
||||||
fAngle = self.angle(vecFlow, fNorm)
|
fAngle = self.angle(vecFlow, fNorm)
|
||||||
|
|
||||||
if fAngle == 0 or fAngle == numpy.pi:
|
if fAngle == 0 or fAngle == numpy.pi:
|
||||||
if (face.center.pos() == inletface.center.pos()).prod():
|
if (face.center.pos() == inletface.center.pos()).prod():
|
||||||
face.name = "inlet"
|
face.name = "inlet"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
face.name = "outlet"
|
face.name = "outlet"
|
||||||
|
|
||||||
@ -152,6 +152,7 @@ class Simple(Periodic):
|
|||||||
face.name = f"symetry{ symetryId }"
|
face.name = f"symetry{ symetryId }"
|
||||||
symetryId += 1
|
symetryId += 1
|
||||||
|
|
||||||
|
|
||||||
# Main shape
|
# Main shape
|
||||||
self.shape = self.cell - self.lattice
|
self.shape = self.cell - self.lattice
|
||||||
|
|
||||||
|
@ -74,34 +74,33 @@ class OnePhaseFlow(FoamCase):
|
|||||||
|
|
||||||
# ISSUE: add proxy from geometry direction to outlet boundaryField.
|
# ISSUE: add proxy from geometry direction to outlet boundaryField.
|
||||||
for boundary in boundaries:
|
for boundary in boundaries:
|
||||||
match boundary:
|
if boundary == "inlet":
|
||||||
case "inlet":
|
p["boundaryField"][boundary] = dict(
|
||||||
p["boundaryField"][boundary] = dict(
|
type = "fixedValue",
|
||||||
type = "fixedValue",
|
value = "uniform 1e-3"
|
||||||
value = "uniform 1e-3"
|
)
|
||||||
)
|
u["boundaryField"][boundary] = dict(
|
||||||
u["boundaryField"][boundary] = dict(
|
type = "fixedValue",
|
||||||
type = "fixedValue",
|
value = "uniform (0 0 -6e-5)" # * direction
|
||||||
value = "uniform (0 0 -6e-5)" # * direction
|
)
|
||||||
)
|
|
||||||
|
|
||||||
case "outlet":
|
elif boundary == "outlet":
|
||||||
p["boundaryField"][boundary] = dict(
|
p["boundaryField"][boundary] = dict(
|
||||||
type = "fixedValue",
|
type = "fixedValue",
|
||||||
value = "uniform 0"
|
value = "uniform 0"
|
||||||
)
|
)
|
||||||
u["boundaryField"][boundary] = dict(
|
u["boundaryField"][boundary] = dict(
|
||||||
type = "zeroGradient",
|
type = "zeroGradient",
|
||||||
)
|
)
|
||||||
|
|
||||||
case _:
|
else:
|
||||||
p["boundaryField"][boundary] = dict(
|
p["boundaryField"][boundary] = dict(
|
||||||
type = "zeroGradient"
|
type = "zeroGradient"
|
||||||
)
|
)
|
||||||
u["boundaryField"][boundary] = dict(
|
u["boundaryField"][boundary] = dict(
|
||||||
type = "fixedValue",
|
type = "fixedValue",
|
||||||
value = "uniform (0 0 0)"
|
value = "uniform (0 0 0)"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.extend([
|
self.extend([
|
||||||
controlDict,
|
controlDict,
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
name: anisotropy
|
name: anisotropy
|
||||||
channels:
|
channels:
|
||||||
|
- local
|
||||||
- conda-forge
|
- conda-forge
|
||||||
dependencies:
|
dependencies:
|
||||||
- python>=3.9
|
- python>=3.9
|
||||||
- poetry
|
- poetry
|
||||||
- sqlite
|
- sqlite
|
||||||
|
- occt
|
||||||
|
- netgen
|
||||||
|
Loading…
Reference in New Issue
Block a user