Write Control at Specified Times
I am running a combustion simulation model in OpenFoam and would like to write out my solution only at specified times.
So, my model runs for 8000 timeSteps and I would like to only write down solutions at 5500, 5782, 6245 and other times. I can create a separate case and change its end-time to those specified times as follows: foamDictionary -entry "writeInterval" -set "1" system/controlDict foamDictionary -entry "purgeWrite" -set "1" system/controlDict foamDictionary -entry "endTime" -set "5782" system/controlDict However, with the above method, I need to clone the case and change my endTime for every desired time-based solution. I would like to sample about 30 different solution times quite far from each other meaning I cannot write out all 8000 time-steps due to storage issues. Is there any way to do that? Thank you! |
Couldn't you, with a single simulation, run until 5500 and (write and) stop. Then restart and run until your next cutoff (and stop), etc... ? You would just need to edit the controlDict accordingly before each restart (and make sure to make startTime latestTime). No programming necessary.
Caelan |
Thank you for this suggestion!
I did just that and wrote a small python script that generates text that can be directly copied into your Allrun script: from itertools import tee, islice, chain def previous_and_next(some_iterable): prevs, items, nexts = tee(some_iterable, 3) prevs = chain([None], prevs) nexts = chain(islice(nexts, 1, None), [None]) return zip(prevs, items, nexts) list_of_times = [2425, 2733, 2735, 2737, 2738, 2984, 3001, 3307, 3309, 3311, 3312] for previous, item, nxt in previous_and_next(list_of_times): print('foamDictionary -entry "startTime" -set "%d" system/controlDict' %item) print('foamDictionary -entry "writeInterval" -set "1" system/controlDict') print('foamDictionary -entry "purgeWrite" -set "1" system/controlDict') print('foamDictionary -entry "endTime" -set "%d" system/controlDict' %nxt) print('runParallel -o $application') |
might help a bit?
https://www.openfoam.com/documentati...e-control.html |
Hi! Thanks for your response but I cannot seem to find (in the link you shared) a tool that would help me? I see conditioning like stop simulation if x occurs but not how to write out custom time steps? Thanks!
|
All times are GMT -4. The time now is 04:27. |