CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

ControlDict

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 22, 2010, 13:19
Default ControlDict
  #1
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 6
Daniele111 is on a distinguished road
hi
Is possible with simpleFoam in time directory write only one data time directory? I want start my simulation from lastTime and when it finish my result must be overwrite on startTime directory, then i restar my simulation and again new result must be overwrite. I want only a directory
Thanks
Daniele111 is offline   Reply With Quote

Old   October 22, 2010, 14:23
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Rotterdam, The Netherlands
Posts: 1,528
Rep Power: 23
ngj will become famous soon enoughngj will become famous soon enough
Hi Daniele

Then you should consider the purgeWrite option. Its functionality is described in details in the User Guide. However, note that it requires the use of the timeStep as writeControl option.

Hope it helps and enjoy your weekend,

Niels
ngj is offline   Reply With Quote

Old   October 23, 2010, 11:37
Default
  #3
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 6
Daniele111 is on a distinguished road
I tried but i have one directory for each simulation, and would only one for many simulation...
Daniele111 is offline   Reply With Quote

Old   October 23, 2010, 12:51
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,116
Blog Entries: 32
Rep Power: 70
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Greetings Danielle and Niels,

Interesting requirement Danielle, but "-overwrite" argument option only exists for meshers, AFAIK, otherwise it would be the perfect solution for you.
But you also left out one crucial piece of information: are the simulations meant to end at the same time snapshot?

For example, there are three scenarios I can think of:
  1. The simulations are meant to always end at time snapshot 1000.
  2. The simulations end at different time snapshots.
  3. The simulations end when the residuals are acceptable, therefore you end it without simpleFoam's prior knowledge. This means that you will need frequent time snapshot writes, in order to keep track of what has happened before you terminate the execution.
For either one of these, I've got a solution for you, but it depends if your system allows symbolic links in the file system. Most Linux boxes that use ext2/3/4 will do fine, but I'm not certain that for example some high end clusters will allow symbolic links...

The concept is quite simple, so here is one solution (out of N possible solutions ) for each scenario, based on the same principle:
  1. If they always end at the same time snapshot, for example 1000 - run this command in your case folder:
    Code:
    ln -s 0 1000
    This will link symbolically the folder 1000 to 0, therefore anything written/read to/from folder 1000, will be in fact the folder 0.
    Then, since you don't need any time snapshots midway, you must do something like this in your controlDict:
    Code:
    startFrom       startTime;
    startTime       0;
    stopAt          endTime;
    endTime         1000;
    deltaT          0.5;
    writeControl    runTime;
    writeInterval   $endTime;
    purgeWrite      0;
    Only deltaT and endTime should be different for your simulation in question! All of these other variables must be kept as they are, otherwise you wont end up with the last time snapshot saved into the desired link folder.
  2. If simulations vary in end time, then in the previous solution you only have to change the controlDict's endTime (and possibly the deltaT), and you must also create a link for that new end time, for example 900.5:
    Code:
    ln -s 0 900.5
  3. If it's unknown when the simulation will be terminated, then writeInterval cannot be the same as the end time. You'll have to stipulate frequent saves, in order to keep losses to a minimum. This will be a serious pain, because you'll need one link per saved snapshot. One way to keep it simple, is to run something like this in the terminal, before each modified run (i.e., if the endTime increases or if your deltaT changes):
    Code:
    endTime=0.5
    deltaT=0.1
    for t in $(seq $deltaT $deltaT $endTime | sed 's=,=\.='); do ln -s 0 $t; done
And there you have it, the solutions for the 3 scenarios I can think of. I hope I've managed to keep it simple and easy to understand. If not, I'll try to rephrase my explanations

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   October 23, 2010, 13:02
Default
  #5
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 6
Daniele111 is on a distinguished road
I think that my case is 3! But i try to explain better my problem. I have a evolutive simulation and I use a matlab code that execute at each time step OpenFoam to calulate wall shear stress, with new wall shear matlab calculate new domain shape and I modify mesh and restart openfoam from lastTime, the problem is that on my university server I have a limited space and the simulation are very long and I can't use a lot of space!
Daniele111 is offline   Reply With Quote

Old   October 23, 2010, 13:33
Default
  #6
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,116
Blog Entries: 32
Rep Power: 70
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Hi Danielle,

Then Niels's solution should also be possible for you, as long as you:
  • Use:
    Code:
    startFrom       lastTime;
    purgeWrite      1;
  • Increment the endTime for each new iteration+simulation, therefore you would have to update controlDict for each simulation.
  • In Matlab, detect which is the last time iteration, in case it ends sooner than expected (i.e., different than endTime).
Either way, you should now have more than one possible solution for your problem

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   October 23, 2010, 14:33
Default
  #7
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 6
Daniele111 is on a distinguished road
"Increment the endTime for each new iteration+simulation, therefore you would have to update controlDict for each simulation."

But I don't know endTime, each OpenFoam simulation stop when residuals are down
Daniele111 is offline   Reply With Quote

Old   October 23, 2010, 15:08
Default
  #8
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Rotterdam, The Netherlands
Posts: 1,528
Rep Power: 23
ngj will become famous soon enoughngj will become famous soon enough
Hi Daniele

The overall framework by Bruno is functional, and if your solver stops at a given residual, you put endTime to something really, really large. Would that work?

If your question about not knowing the endTime is a Matlab issue regarding which time folder to enter to do the post-processing step, I could imagine that you might do as follows inside matlab:

Code:
[s,w] = unix('ls -d [0-9] | sort -g | tail -1 | tr -d ''\n'''); % The ''\n'' is needed, otherwise cd(w) won't work
cd(w);
which will give you the latest time step and enter that time directory.

Best regards,

Niels
ngj is offline   Reply With Quote

Old   October 23, 2010, 15:15
Default
  #9
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 6
Daniele111 is on a distinguished road
Thanks
Doing a small summary, Would you post me an example of a controlDict file to see if i understand yours routine?

Daniele
Daniele111 is offline   Reply With Quote

Old   October 23, 2010, 15:22
Default
  #10
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Rotterdam, The Netherlands
Posts: 1,528
Rep Power: 23
ngj will become famous soon enoughngj will become famous soon enough
Honestly no. Merely combine posts #6 and #8 and you should be fine.

/ Niels
ngj is offline   Reply With Quote

Old   October 23, 2010, 15:25
Default
  #11
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 6
Daniele111 is on a distinguished road
Thanks for all.
In this way Have I always only one time directory ?
Daniele111 is offline   Reply With Quote

Old   October 24, 2010, 05:27
Default
  #12
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 6
Daniele111 is on a distinguished road
Uhmm purgeWrite don't resolve my problem...Example:
I start first simulation in OpenFoam, it converges after 47 time step and simulation stops, so I have 0 and 47 time directory. I star new simulation it starts from 47, and it converges at 56 time step, but in my case directory I don't have only 0 and 56 time directory but 0 47 and 56.
Daniele111 is offline   Reply With Quote

Old   October 24, 2010, 06:21
Default
  #13
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,116
Blog Entries: 32
Rep Power: 70
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Greetings to all!

@Niels: there is a small typo in your command in post #8; it should have an asterisk for the ls:
Code:
ls -d [0-9]*
@Daniele: well in a way it's good to know that purgeWrite doesn't remove the starting snapshot, since this way we have the beginning and the end of the simulation But since this isn't what you want, I suggest what Niels has pretty much already suggested - keep using your current settings in controlDict, but run things like this:
Code:
simpleFoam
rm -rf 0
mv `ls -d [0-9]* | sort -g | tail -1 | tr -d ''\n''` 0
This will run simpleFoam, then remove the 0 snapshot when complete and move/rename the last snapshot to 0. The last two commands can be executed directly in Matlab:
Code:
unix('rm -rf 0; mv `ls -d [0-9]* | sort -g | tail -1 | tr -d ''\n''` 0')
Best regards,
Bruno

Last edited by wyldckat; October 24, 2010 at 06:37. Reason: Ooops, typo in Daniele's name...
wyldckat is offline   Reply With Quote

Old   October 24, 2010, 06:25
Default
  #14
Senior Member
 
Daniele
Join Date: Feb 2010
Posts: 134
Rep Power: 6
Daniele111 is on a distinguished road
Thanks you a lot Bruno, now it is clear! You are very useful!

Daniele
Daniele111 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Representing controlDict information using OpenFOAM classes sanatan OpenFOAM Programming & Development 4 February 28, 2012 06:46
private boundary condition in controlDict strange behaviour markc OpenFOAM Programming & Development 12 November 23, 2011 10:18
writing controlDict as otherfields ubaid OpenFOAM 5 September 29, 2010 07:28
Specifying probe locations in controlDict using dictionary file vincent OpenFOAM Bugs 3 December 31, 2008 04:25
Reading controlDict diegon OpenFOAM Running, Solving & CFD 1 February 6, 2007 12:31


All times are GMT -4. The time now is 06:25.