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