|
[Sponsors] |
Displaying OpenFOAM Results Automatically in ParaView through a Single Command |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 21, 2022, 20:28 |
Displaying OpenFOAM Results Automatically in ParaView through a Single Command
|
#1 |
New Member
Erol Bicer
Join Date: Apr 2021
Location: Seoul
Posts: 2
Rep Power: 0 |
I have been doing a parametric study and it was getting heavier on me to manually load a ParaView state file every time I change the working directory. Later I found out that I could change the folder path in the state file and then load it from the terminal. So, I semi-automated the process. However, this still requires going manually to a state file and changing the folder path to the current working directory. This also started to bother me so I found a way to fully automate the process but I am not sure whether this is the most efficient way to do it. So, I will explain below how I did it step by step which might be useful for those who are looking for something similar and I would appreciate it if anyone could tell me an easier way to do it. I also wanted to share the bash script that I am using to automatically run my simulations in parallel. So, the script does everything from pre-processing to post-process.
Task: Automatically run a simulation and display the results in ParaView using an existing state file.
Now the explanation is out of the way, here is my bash script to run a case in parallel using multiphaseEulerFoam. It can be easily tweaked to adjust to your case. Please note that the script assumes you have saved the '0' time directory as '0.orig' which is a good practice in my opinion. Save the code below as whatever name you want (e.g. cRun) and run it as '/cRun ' from the command line. It is also a good practice to separate the bash file into two files in case you want to only clean or only run sometimes. Code:
# CLEANING PART # clean the previous simulation data . $WM_PROJECT_DIR/bin/tools/CleanFunctions # omit this if you don't use '0.orig' rm -rf ./0 cleanCase # the run will be saved to 'log.parallelRun' file with the current directory # name at the first line echo "Case ${PWD##*/}" >> log.parallelRun clear # RUNNING PART # generate mesh # you can just use 'blockMesh' if you use built-in mesh generation utility ideasUnvToFoam yoshidaMeshFiner.unv | tee log.mesh # optional 'changeDictionary' unless you have to change names in the boundaries changeDictionary | tee -a log.mesh checkMesh | tee -a log.mesh # copy '0.orig' folder to '0' folder cp -r ./0.orig ./0 # optional to set the initial conditions properly setFields | tee log.preRun # decompose the mesh for parallel run decomposePar | tee -a log.preRun # run the simulation in parallel with the desired number of cores mpirun -np 16 multiphaseEulerFoam -parallel | tee -a log.parallelRun # reconstruct the time driectories reconstructPar # create dummy.foam touch myUniqueFileName.foam # change the folder path in the file and save it as foldername.pvsm sed 's?myUniqueString?'`pwd`'?' EARLIER_SAVED_STATE_FILE_NAME.pvsm > ${PWD##*/}.pvsm # open in paraview paraview --state=${PWD##*/}.pvsm Happy new year to you all. |
|
Tags |
automate, bash script, paraview, post processing, state file |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM] Cant view the results on ParaView OpenFOAM | saugatshr4 | ParaView | 0 | May 10, 2021 02:23 |
Suggestion for a new sub-forum at OpenFOAM's Forum | wyldckat | Site Help, Feedback & Discussions | 20 | October 28, 2014 10:04 |
OpenFOAM15 installables are incomplete problem with paraFoam | tryingof | OpenFOAM Bugs | 17 | December 7, 2008 05:41 |
Problem of compilation OF 14Allwmake command not found | erik_d | OpenFOAM Bugs | 13 | September 13, 2008 22:45 |
Regarding FoamX running Kindly help out | hariya03 | OpenFOAM Pre-Processing | 0 | April 18, 2008 05:26 |