Mod: minor changes
This commit is contained in:
parent
3d4e7abb66
commit
8e1e14217a
@ -1,6 +1,6 @@
|
|||||||
import os, sys
|
import os, sys
|
||||||
import time
|
import time
|
||||||
from datetime import timedelta
|
from datetime import timedelta, datetime
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
ROOT = "/".join(__file__.split("/")[:-2])
|
ROOT = "/".join(__file__.split("/")[:-2])
|
||||||
@ -62,11 +62,14 @@ def main():
|
|||||||
queue = createQueue()
|
queue = createQueue()
|
||||||
|
|
||||||
for n, case in enumerate(queue):
|
for n, case in enumerate(queue):
|
||||||
|
date = datetime.now()
|
||||||
logger.info("-" * 80)
|
logger.info("-" * 80)
|
||||||
logger.info(f"""main:
|
logger.info(f"""main:
|
||||||
task:\t{ n + 1 } / { len(queue) }
|
task:\t{ n + 1 } / { len(queue) }
|
||||||
cpu count:\t{ os.cpu_count() }
|
cpu count:\t{ os.cpu_count() }
|
||||||
case:\t{ case }""")
|
case:\t{ case }
|
||||||
|
date:\t{ date.date() }
|
||||||
|
time:\t{ date.time() }""")
|
||||||
|
|
||||||
###
|
###
|
||||||
# Compute mesh
|
# Compute mesh
|
||||||
@ -84,7 +87,7 @@ def main():
|
|||||||
task = struct(toml.load(taskPath))
|
task = struct(toml.load(taskPath))
|
||||||
|
|
||||||
if not task.status.mesh:
|
if not task.status.mesh:
|
||||||
logger.critical("mesh not computed: Skipping flow computation")
|
logger.critical("mesh not computed: skip flow computation")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
###
|
###
|
||||||
@ -128,7 +131,7 @@ def createQueue():
|
|||||||
case = os.path.join(
|
case = os.path.join(
|
||||||
f"{ BUILD }",
|
f"{ BUILD }",
|
||||||
f"{ structure }",
|
f"{ structure }",
|
||||||
f"direction-{ direction[0] }{ direction [1] }{ direction [2] }",
|
"direction-{}{}{}".format(*direction),
|
||||||
f"theta-{ theta }"
|
f"theta-{ theta }"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -228,7 +231,7 @@ def computeFlow(case):
|
|||||||
_, returncode = openfoam.ideasUnvToFoam("mesh.unv")
|
_, returncode = openfoam.ideasUnvToFoam("mesh.unv")
|
||||||
|
|
||||||
if returncode:
|
if returncode:
|
||||||
os.chdir(config.ROOT)
|
os.chdir(ROOT)
|
||||||
|
|
||||||
return returncode
|
return returncode
|
||||||
|
|
||||||
@ -324,6 +327,14 @@ def computeFlow(case):
|
|||||||
task.status.flow = True
|
task.status.flow = True
|
||||||
task.statistics.flowTime = elapsed
|
task.statistics.flowTime = elapsed
|
||||||
|
|
||||||
|
postProcessing = "postProcessing/flowRatePatch(name=outlet)/0/surfaceFieldValue.dat"
|
||||||
|
|
||||||
|
with open(postProcessing, "r") as io:
|
||||||
|
lastLine = io.readlines()[-1]
|
||||||
|
flowRate = float(lastLine.replace(" ", "").replace("\n", "").split("\t")[1])
|
||||||
|
|
||||||
|
task.statistics.flowRate = flowRate
|
||||||
|
|
||||||
with open(os.path.join(case, "task.toml"), "w") as io:
|
with open(os.path.join(case, "task.toml"), "w") as io:
|
||||||
toml.dump(dict(task), io)
|
toml.dump(dict(task), io)
|
||||||
|
|
||||||
@ -351,24 +362,9 @@ def checkEnv():
|
|||||||
return missed
|
return missed
|
||||||
|
|
||||||
|
|
||||||
def postprocessing(tasks):
|
def postprocessing(queue):
|
||||||
|
|
||||||
surfaceFieldValue = {}
|
|
||||||
porosity = {}
|
|
||||||
|
|
||||||
for task in tasks:
|
|
||||||
direction = "direction-{}{}{}".format(task.direction[0], task.direction[1], task.direction[2])
|
|
||||||
path = os.path.join(BUILD, task.structure, "postProcessing", direction)
|
|
||||||
surfaceFieldValuePath = os.path.join(task.export, "postProcessing", "")
|
|
||||||
|
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
|
|
||||||
surfaceFieldValues = [ line.strip().split() for line in open(surfaceFieldValuePath, "r").readlines() ]
|
|
||||||
|
|
||||||
with open(os.path.join(path, "porosity.dat")) as io:
|
|
||||||
io.write("{}\t{}".format(task.coeff, surfaceFieldValues[-1][1]))
|
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
###
|
###
|
||||||
# Main entry
|
# Main entry
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
###
|
###
|
||||||
# Default config for anisotropy
|
# Default config for anisotropy
|
||||||
#
|
#
|
||||||
# theta = [min, max, step]
|
# Special values:
|
||||||
|
# theta = [min, max, step]
|
||||||
|
# thickness = [min, max]
|
||||||
##
|
##
|
||||||
|
|
||||||
[logger]
|
[logger]
|
||||||
@ -10,7 +12,7 @@ format = "%(levelname)s: %(message)s"
|
|||||||
|
|
||||||
[base]
|
[base]
|
||||||
simple = true
|
simple = true
|
||||||
bodyCentered = true
|
bodyCentered = false
|
||||||
faceCentered = true
|
faceCentered = true
|
||||||
|
|
||||||
###
|
###
|
||||||
@ -63,7 +65,7 @@ directions = [
|
|||||||
fillet = true
|
fillet = true
|
||||||
|
|
||||||
[bodyCentered.mesh]
|
[bodyCentered.mesh]
|
||||||
fineness = 3
|
fineness = 2
|
||||||
minSize = 0.005
|
minSize = 0.005
|
||||||
maxSize = 0.05
|
maxSize = 0.05
|
||||||
growthRate = 0.5
|
growthRate = 0.5
|
||||||
@ -98,7 +100,7 @@ directions = [
|
|||||||
fillet = true
|
fillet = true
|
||||||
|
|
||||||
[faceCentered.mesh]
|
[faceCentered.mesh]
|
||||||
fineness = 3
|
fineness = 2
|
||||||
minSize = 0.005
|
minSize = 0.005
|
||||||
maxSize = 0.05
|
maxSize = 0.05
|
||||||
growthRate = 0.5
|
growthRate = 0.5
|
||||||
@ -136,9 +138,9 @@ outlet.value = 0
|
|||||||
[flow.approx.velocity.boundaryField]
|
[flow.approx.velocity.boundaryField]
|
||||||
inlet.type = "fixedValue"
|
inlet.type = "fixedValue"
|
||||||
inlet.value = [
|
inlet.value = [
|
||||||
[ 6e-5, 6e-5, 0.0 ],
|
[ 6e-5, 6e-5, 0.0 ],
|
||||||
[ 0.0, 0.0, 6e-5 ],
|
[ 0.0, 0.0, 6e-5 ],
|
||||||
[ 6e-5, 6e-5, 6e-5 ]
|
[ 6e-5, 6e-5, 6e-5 ]
|
||||||
]
|
]
|
||||||
outlet.type = "zeroGradient"
|
outlet.type = "zeroGradient"
|
||||||
outlet.value = "None"
|
outlet.value = "None"
|
||||||
|
@ -80,8 +80,8 @@ def genmesh():
|
|||||||
meshParameters.facesToIgnore = facesToIgnore
|
meshParameters.facesToIgnore = facesToIgnore
|
||||||
meshParameters.extrusionMethod = smeshBuilder.SURF_OFFSET_SMOOTH
|
meshParameters.extrusionMethod = smeshBuilder.SURF_OFFSET_SMOOTH
|
||||||
|
|
||||||
mesh = meshCreate(shape, groups, meshParameters)
|
mesh = meshCreate(shape, meshParameters)
|
||||||
returncode = meshCompute(mesh)
|
returncode = meshCompute(mesh, groups)
|
||||||
|
|
||||||
if returncode == 0:
|
if returncode == 0:
|
||||||
config.status.mesh = True
|
config.status.mesh = True
|
||||||
|
@ -9,7 +9,7 @@ def getSmesh():
|
|||||||
return smesh
|
return smesh
|
||||||
|
|
||||||
|
|
||||||
def meshCreate(shape, groups, parameters): #fineness, parameters, viscousLayers = None):
|
def meshCreate(shape, parameters): #fineness, parameters, viscousLayers = None):
|
||||||
"""
|
"""
|
||||||
Creates a mesh from a geometry.
|
Creates a mesh from a geometry.
|
||||||
|
|
||||||
@ -85,16 +85,9 @@ def meshCreate(shape, groups, parameters): #fineness, parameters, viscousLayers
|
|||||||
True if param.GetOptimize() else False))
|
True if param.GetOptimize() else False))
|
||||||
|
|
||||||
|
|
||||||
###
|
|
||||||
# Groups
|
|
||||||
##
|
|
||||||
for group in groups:
|
|
||||||
mesh.GroupOnGeom(group, "{}_".format(group.GetName()), SMESH.FACE)
|
|
||||||
|
|
||||||
###
|
###
|
||||||
# Viscous layers
|
# Viscous layers
|
||||||
##
|
##
|
||||||
#if not viscousLayers is None:
|
|
||||||
vlayer = netgen.ViscousLayers(
|
vlayer = netgen.ViscousLayers(
|
||||||
parameters.thickness,
|
parameters.thickness,
|
||||||
parameters.numberOfLayers,
|
parameters.numberOfLayers,
|
||||||
@ -113,17 +106,10 @@ viscous layers:
|
|||||||
parameters.numberOfLayers,
|
parameters.numberOfLayers,
|
||||||
parameters.stretchFactor))
|
parameters.stretchFactor))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else:
|
|
||||||
# logger.info("""meshCreate:
|
|
||||||
#viscous layers: disabled""")
|
|
||||||
|
|
||||||
|
|
||||||
return mesh
|
return mesh
|
||||||
|
|
||||||
|
|
||||||
def meshCompute(mobj):
|
def meshCompute(mobj, groups):
|
||||||
"""Compute the mesh."""
|
"""Compute the mesh."""
|
||||||
status = mobj.Compute()
|
status = mobj.Compute()
|
||||||
|
|
||||||
@ -149,7 +135,13 @@ def meshCompute(mobj):
|
|||||||
|
|
||||||
mobj.RemoveGroup(pyramidGroup)
|
mobj.RemoveGroup(pyramidGroup)
|
||||||
mobj.RenumberElements()
|
mobj.RenumberElements()
|
||||||
|
|
||||||
|
###
|
||||||
|
# Groups
|
||||||
|
##
|
||||||
|
for group in groups:
|
||||||
|
mobj.GroupOnGeom(group, f"{ group.GetName() }_", SMESH.FACE)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.warning("meshCompute: not computed")
|
logger.warning("meshCompute: not computed")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user