Postprocessing [2]
This commit is contained in:
parent
f108fda5c7
commit
8f941bc451
36
run.py
36
run.py
@ -93,7 +93,6 @@ def createMesh(tasks):
|
|||||||
def calculate(tasks):
|
def calculate(tasks):
|
||||||
foamCase = [ "0", "constant", "system" ]
|
foamCase = [ "0", "constant", "system" ]
|
||||||
rmDirs = ["0", "constant", "system", "postProcessing", "logs"] + [ "processor{}".format(n) for n in range(4)]
|
rmDirs = ["0", "constant", "system", "postProcessing", "logs"] + [ "processor{}".format(n) for n in range(4)]
|
||||||
#fancyline = "--------------------------------------------------------------------------------"
|
|
||||||
|
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
|
|
||||||
@ -158,9 +157,22 @@ def calculate(tasks):
|
|||||||
|
|
||||||
|
|
||||||
def postprocessing(tasks):
|
def postprocessing(tasks):
|
||||||
|
|
||||||
surfaceFieldValue = []
|
surfaceFieldValue = {}
|
||||||
dat = [ line.strip().split() for line in open("surfaceFieldValue.dat", "r").readlines() ]
|
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.saveto, "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]))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -180,22 +192,25 @@ if __name__ == "__main__":
|
|||||||
])
|
])
|
||||||
|
|
||||||
# TODO: add force arg
|
# TODO: add force arg
|
||||||
Args = namedtuple("Args", ["mesh", "calc"])
|
Args = namedtuple("Args", ["mesh", "calc", "pp"])
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
action = sys.argv[1]
|
action = sys.argv[1]
|
||||||
|
|
||||||
if action == "mesh":
|
if action == "mesh":
|
||||||
args = Args(True, False)
|
args = Args(True, False, False)
|
||||||
|
|
||||||
elif action == "calc":
|
elif action == "calc":
|
||||||
args = Args(False, True)
|
args = Args(False, True, False)
|
||||||
|
|
||||||
|
elif action == "pp":
|
||||||
|
args = Args(False, False, True)
|
||||||
|
|
||||||
elif action == "all":
|
elif action == "all":
|
||||||
args = Args(True, True)
|
args = Args(True, True, True)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
args = Args(True, True)
|
args = Args(True, True, True)
|
||||||
|
|
||||||
tasks = createTasks()
|
tasks = createTasks()
|
||||||
logging.info("Tasks: {}".format(len(tasks)))
|
logging.info("Tasks: {}".format(len(tasks)))
|
||||||
@ -221,5 +236,6 @@ if __name__ == "__main__":
|
|||||||
logging.info("-" * 80)
|
logging.info("-" * 80)
|
||||||
logging.info("Elapsed time: {}".format(timedelta(seconds=end_time - start_time)))
|
logging.info("Elapsed time: {}".format(timedelta(seconds=end_time - start_time)))
|
||||||
|
|
||||||
|
if args.pp:
|
||||||
|
postprocessing(tasks)
|
||||||
|
|
||||||
|
@ -63,13 +63,14 @@ def genMesh(stype, theta, fillet, direction, saveto):
|
|||||||
[length, surfaceArea, volume] = geompy.BasicProperties(shape, theTolerance = 1e-06)
|
[length, surfaceArea, volume] = geompy.BasicProperties(shape, theTolerance = 1e-06)
|
||||||
|
|
||||||
logging.info("""shape:
|
logging.info("""shape:
|
||||||
|
edges length:\t{}
|
||||||
surface area:\t{}
|
surface area:\t{}
|
||||||
volume:\t{}""".format(surfaceArea, volume))
|
volume:\t{}""".format(length, surfaceArea, volume))
|
||||||
|
|
||||||
###
|
###
|
||||||
# Mesh
|
# Mesh
|
||||||
##
|
##
|
||||||
fineness = 1
|
fineness = 0
|
||||||
parameters = mesh_utils.Parameters(
|
parameters = mesh_utils.Parameters(
|
||||||
minSize = 0.001,
|
minSize = 0.001,
|
||||||
maxSize = 0.1,
|
maxSize = 0.1,
|
||||||
|
28
src/paraview_utils.py
Normal file
28
src/paraview_utils.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from paraview.simple import *
|
||||||
|
|
||||||
|
def plotMagnitude():
|
||||||
|
|
||||||
|
rv = CreateRenderView()
|
||||||
|
rv.ViewSize = [1920, 1080]
|
||||||
|
rv.CameraPosition = [1e-05, 2e-05, 1e-05]
|
||||||
|
rv.CameraFocalPoint = [1e-05, 2e-05, 1e-05]
|
||||||
|
|
||||||
|
|
||||||
|
layout1 = CreateLayout(name='Layout #1')
|
||||||
|
layout1.AssignView(0, rv)
|
||||||
|
|
||||||
|
SetActiveView(rv)
|
||||||
|
|
||||||
|
foam = OpenFOAMReader(FileName = "simple.foam")
|
||||||
|
foam.CaseType = "Decomposed Case"
|
||||||
|
foam.MeshRegions = ["internalMesh"]
|
||||||
|
foam.CellArrays = ["U", "p"]
|
||||||
|
|
||||||
|
SetActiveSource(foam)
|
||||||
|
display = Show(foam, rv, "UnstructuredGridRepresentation")
|
||||||
|
r = Render()
|
||||||
|
|
||||||
|
SaveScreenshot("test.png", r)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
plotMagnitude()
|
@ -185,5 +185,6 @@ clip1Display.SetScalarBarVisibility(renderView1, True)
|
|||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
# finally, restore active source
|
# finally, restore active source
|
||||||
SetActiveSource(clip1)
|
SetActiveSource(clip1Display)
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
SaveScreenshot("test.png", renderView1)
|
||||||
|
Loading…
Reference in New Issue
Block a user