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