CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Write Control at Specified Times

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By clapointe
  • 1 Post By Brandani
  • 1 Post By HPE

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 27, 2020, 10:56
Default Write Control at Specified Times
  #1
New Member
 
Mark
Join Date: Oct 2018
Posts: 18
Rep Power: 7
Brandani is on a distinguished road
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!
Brandani is offline   Reply With Quote

Old   January 27, 2020, 14:48
Default
  #2
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 14
clapointe is on a distinguished road
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
Brandani likes this.
clapointe is offline   Reply With Quote

Old   February 11, 2020, 08:14
Default
  #3
New Member
 
Mark
Join Date: Oct 2018
Posts: 18
Rep Power: 7
Brandani is on a distinguished road
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')
Linmunn likes this.
Brandani is offline   Reply With Quote

Old   February 11, 2020, 08:42
Default
  #4
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
might help a bit?
https://www.openfoam.com/documentati...e-control.html
Brandani likes this.
HPE is offline   Reply With Quote

Old   March 11, 2020, 12:26
Default
  #5
New Member
 
Mark
Join Date: Oct 2018
Posts: 18
Rep Power: 7
Brandani is on a distinguished road
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!
Brandani is offline   Reply With Quote

Reply

Tags
controldict, openfoam v7


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Write data at specific times, not intervals artymk4 OpenFOAM 7 November 13, 2020 02:30
Write control options: Start writing after certain time? redbullah OpenFOAM Running, Solving & CFD 0 December 4, 2018 10:42
Residuals and forces spiraling out of control before failing edomalley1 OpenFOAM Running, Solving & CFD 3 September 7, 2018 10:42
[ANSYS Meshing] Match Control, is this weird or am I stupid? Moufle ANSYS Meshing & Geometry 2 November 18, 2015 16:00
benchmark: flow over a circular cylinder goodegg Main CFD Forum 12 January 22, 2013 11:47


All times are GMT -4. The time now is 01:37.