Difference between revisions of "HowTo postProcMultiregion"
m (→Generating pseudo case-directories) |
AntonChupin (Talk | contribs) |
||
Line 74: | Line 74: | ||
Note: I'm well aware that there are shorter ways to write this script, but I like the thought that it ''should'' work on Windows should I ever have the misfortune to work on that OS | Note: I'm well aware that there are shorter ways to write this script, but I like the thought that it ''should'' work on Windows should I ever have the misfortune to work on that OS | ||
+ | |||
+ | [[Category:Tutorials]] |
Revision as of 11:18, 21 October 2013
Current versions of paraFoam don't support the postprocessing of simulations that use multiple mesh-regions (like icoStructFoam or the conjugated heat transfer solver. This discribes ways to cope with that shortcomming.
1 Using paraview
To write the data of the two regions for paraview just use foamToVTK:
foamToVTK . icoStructFoamTest -mesh region1 foamToVTK . icoStructFoamTest -mesh region2
2 Generating pseudo case-directories
An alternative Way was described on the Message board:
Basically what you do is create two cases that point to the real data.
Suppose you have your case in aTaleOfTwoMeshes. Create two directories meshCase1, meshCase2. For each directory create these links:
meshCaseX/system -> aTaleOfTwoMeshes/system meshCaseX/constant/polyMesh -> aTaleOfTwoMeshes/constant/regionX/polyMesh meshCaseX/0 -> aTaleOfTwoMeshes/0/regionX
(the last has to be done for every time-step)
Now create a stub in one case (touch meshCase2/meshCase2.foam), open the other case from the command line (paraFoam . meshCase1), in that paraFoam open the stub you created using the File->Open-dialog.
2.1 Example script
An example for the implementation of this strategy would be this script written in Python using the PyFoam-library:
#! /usr/bin/python from os import mkdir,path,symlink,system,listdir import sys from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory def buildCase(original,region): dirName=original+"."+region case=path.basename(original) print "Creating pseudocase",dirName system("rm -rf "+dirName) mkdir(dirName) mkdir(path.join(dirName,"constant")) symlink(path.join(path.pardir,path.pardir,case,"constant",region,"polyMesh"), path.join(dirName,"constant","polyMesh")) symlink(path.join(path.pardir,case,"system"), path.join(dirName,"system")) sol=SolutionDirectory(original) for t in sol.getTimes(): symlink(path.join(path.pardir,case,t,region), path.join(dirName,t)) return dirName caseName=sys.argv[1] if caseName[-1]==path.sep: caseName=caseName[:-1] firstRegion=None for region in listdir(path.join(caseName,"constant")): name=buildCase(caseName,region) if not firstRegion: firstRegion=name else: f=open(path.join(name,path.basename(name)+".foam"),"w") f.close() print "\n\n Open first region with \"paraFoam %s %s\".\n All others from the File menu" % (path.normpath(path.dirname(firstRegion)),path.basename(firstRegion))
It can be used like this (if it saved to buildRegionPseudocases.py):
python buildRegionPseudocases.py thingOnAStick
It builds the directories for the regions it finds.
Note: I'm well aware that there are shorter ways to write this script, but I like the thought that it should work on Windows should I ever have the misfortune to work on that OS