Execution time
Hello,
I'm new at openFoam. I could run a simulation and now I'm wondering how I could get the total time that the simulation took. I open the generated logRun file and it says: Build : 5.0 Exec : simpleFoam -parallel Date : Mar 06 2019 Time : 14:37:33 Host : "stro045.vub.ac.be" PID : 16906 I/O : uncollated Case : /1234/OpenFOAM/ximena5.0/run/casedirectory3 nProcs : 16 Slaves : 15 Then i suppose that the time that the simpleFoam command took is Time:14:37:33. For me it does not look like real time (hr.min.sec.) Is that the real time? if not, how can i convert that to real time (sec)? and how could I get the complete time that my simulation took, I mean generating the blockMesh, snappyHexmexh, decompePar etc? (by the way, I run all the simulation separatelly not just running an Allrun script. Regards Ximena ;) |
Hi Ximena,
14:37:33 was the time of the day when simpleFoam started. Some commands print the execution time in its log file, you could add them. Kind regards, Krapf |
Hi Ximena,
I wrote this Python script to calculate the elapsed time between start and end of any process, you just have to run it before executing the commands and after executing the commands. I should be placed in the same folder as you are running the simulations. Code:
import time Luis |
You can also use the "time" tool in the terminal with any execution for blockMesh, simpleFoam etc. such as;
time simpleFoam at the end of run the time data will be declared... |
Dear lebc,
Thanks a lot for your reply, I tried to implement your Python script by by adding that in the case directory and executing the command importtime and other variations, unfortunately I did not get any results. What is the right way to make it works? Regards Ximena :) ____________ Dear mzzmrt, thanks for your reply, it was really useful. I got the time at the end of the execution as is shown hereunder, by executing the command: mpirun -np 8 time snappyHexMesh -overwrite -parallel >logMsh & I just have two more questions, the time the execution time took is 18.31 minutes, didn't it?, it is possible to record thats information into the logFile? because that info was available just on my terminal window. End Finalising parallel run 428.14user 626.69system 18:31.63elapsed 94%CPU (0avgtext+0avgdata 352268maxresident)k 0inputs+167672outputs (6major+922154minor)pagefaults 0swaps 419.01user 653.49system 18:31.64elapsed 96%CPU (0avgtext+0avgdata 344700maxresident)k 0inputs+165800outputs (2major+991625minor)pagefaults 0swaps 428.49user 637.03system 18:31.62elapsed 95%CPU (0avgtext+0avgdata 332980maxresident)k 0inputs+167240outputs (6major+938355minor)pagefaults 0swaps....... Regards Ximena :) |
You have to save the code I sent you in a .py file and run it before and after your simulation.
Let say that you have an Allrun script that runs everything. This Allrun file would look like something like this: Code:
python elapsed_time.py If you have troubles running it, send me the commands you have to run and I can help you with this Allrun file, I use it all the time! Best Regards, Luis |
Dear lebc,
I really apreciate your help. I was trying to create Allrun file, but it looks more complicated in parallel (since my case is a little too much for my computer, I run it remotely and in parallel) and those are the commands I run: 1. blockMesh 2. decomposePar 3. mpirun -np 32 time snappyHexMesh -overwrite -parallel >logMesh & 4. tail -f logMesh (to visualise when it is finished) 5. reconstructParMesh -constant 6. cp -r 0.boundaryConditions/* 0/ 7. rm -r processor* 8. decomposePar -latestTime 9. mpirun -np 32 time simpleFoam -parallel >logRun & 10. tail -f logRun (to visualise when it is finished) 11. reconstructPar -latestTime 12. checkMesh >logCheck & (to visualise the number of cells) by the way, I create the python "elapsed_time.py" file just by adding the extension .py to the textedit file and coping that to the remote computer, is that right? Thanks again for you help :) |
Hi Ximena,
So your Allrun file using the commands you sent should look like this: Code:
#!/bin/sh Code:
#!/bin/sh I haven't tested the script, so maybe you will need to adjust one or two commands... All the logs should be saved in files, so you can check them whenever you want. Best Regards, Luis |
How can I tweak your python file to show result in minutes?
Thanks lebc,
I got your python file to work, for showing the elapsed time for running a simulation. However, the file it creates shows the ET in seconds, and for a long run time, this can be a large number. In that event, it would be more meaningful for me to see the result in terms of minutes. Can you show how your python file could be edited to do this? |
... just divide through by 60!
Code:
get_time_file.write(str((current_time - initial_time)/60)) |
All times are GMT -4. The time now is 09:52. |