Postprocessing [2]

This commit is contained in:
L-Nafaryus 2021-04-13 22:06:25 +05:00
parent f108fda5c7
commit 8f941bc451
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
4 changed files with 60 additions and 14 deletions

36
run.py
View File

@ -93,7 +93,6 @@ def createMesh(tasks):
def calculate(tasks):
foamCase = [ "0", "constant", "system" ]
rmDirs = ["0", "constant", "system", "postProcessing", "logs"] + [ "processor{}".format(n) for n in range(4)]
#fancyline = "--------------------------------------------------------------------------------"
for task in tasks:
@ -158,9 +157,22 @@ def calculate(tasks):
def postprocessing(tasks):
surfaceFieldValue = []
dat = [ line.strip().split() for line in open("surfaceFieldValue.dat", "r").readlines() ]
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.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__":
@ -180,22 +192,25 @@ if __name__ == "__main__":
])
# TODO: add force arg
Args = namedtuple("Args", ["mesh", "calc"])
Args = namedtuple("Args", ["mesh", "calc", "pp"])
if len(sys.argv) > 1:
action = sys.argv[1]
if action == "mesh":
args = Args(True, False)
args = Args(True, False, False)
elif action == "calc":
args = Args(False, True)
args = Args(False, True, False)
elif action == "pp":
args = Args(False, False, True)
elif action == "all":
args = Args(True, True)
args = Args(True, True, True)
else:
args = Args(True, True)
args = Args(True, True, True)
tasks = createTasks()
logging.info("Tasks: {}".format(len(tasks)))
@ -221,5 +236,6 @@ if __name__ == "__main__":
logging.info("-" * 80)
logging.info("Elapsed time: {}".format(timedelta(seconds=end_time - start_time)))
if args.pp:
postprocessing(tasks)

View File

@ -63,13 +63,14 @@ def genMesh(stype, theta, fillet, direction, saveto):
[length, surfaceArea, volume] = geompy.BasicProperties(shape, theTolerance = 1e-06)
logging.info("""shape:
edges length:\t{}
surface area:\t{}
volume:\t{}""".format(surfaceArea, volume))
volume:\t{}""".format(length, surfaceArea, volume))
###
# Mesh
##
fineness = 1
fineness = 0
parameters = mesh_utils.Parameters(
minSize = 0.001,
maxSize = 0.1,

28
src/paraview_utils.py Normal file
View 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()

View File

@ -185,5 +185,6 @@ clip1Display.SetScalarBarVisibility(renderView1, True)
# ----------------------------------------------------------------
# finally, restore active source
SetActiveSource(clip1)
# ----------------------------------------------------------------
SetActiveSource(clip1Display)
# ----------------------------------------------------------------
SaveScreenshot("test.png", renderView1)