Restarting simulations in openfoam with updated boundary conditions
Hi All,
Suppose I have run a simulation to 2000 iterations with a set of BC's and want to run another 2000 iterations with changed BC's or a new mass flow rate. The iteration should start from 2001 and should use the flow field already developed. Could you let me know how to do this? Thanks, Mahesh |
any reason why you can't simply edit the approriate file (U, p, etc...) in the 2000 directory?
|
U or any file at 2000th iteration is a binary file and will contain the values at each node. So it is not possble to edit these files.
|
I think you can do it using the changeDictionary utility.
|
Quote:
Clone your constant and system folders, along with your 2000 folder. Then change writeFormat on controlDict from binary to ascii. Finally run foamFormatConvert. Then you can change whatever you want. If you proceed in the inverse way you will end up with your new case in binary format again. |
Quote:
|
I would use mapFields have the target mesh equipped with new boundary conditions (and specified at cutting patches)
|
can anyone show me an example for the Mapfieldsdict?
I don know how to create this properly. When I map the fields, I always get the old boundary conditions of the source case. best regards Tobi |
Hi Tobi,
You may want to use the -sourceRegion/-targetRegion options of mapFields, which may be able to limit itself to the internalField (untested, and I would love to hear if it works). But, as mentioned previously you may as well just modify the boundary conditions in the file 2000. My understanding from reading the file is that parts of it are binary but not all and you are likely to be able to edit the boundary condition definition. Below is an extract of one of my file: Code:
LT w@M%ޓ/0|E-̡@K'2Un~;vNLrgk @^) |
Does anyone have any idea how to automatize this?
Say I have to run 5 such instances successively where I change the boundary conditions 5 times. Adding to the complexity, the number of time steps the solution will require to converge will be different for each case (I have modified my solver file to incorporate that). Is there anyway I could access the latestTime from outside Openfoam? |
It depends on your preferred environment, script and/or programming language.
Do recover the latest time, you can just loop through the directories that are numerical values and select the highest one. It should be the latest one. This is a way to do it in ruby (Note: it assumes that time directories are integer, not float. In other words, it works for steady-state simulations): Code:
times = [] |
Editing the phi field to restart a simulation
Hi everyone! Hope i am not boring anyone posting in this "old" thread, but i have a question related to some topics that have been spoken here:
Quote:
To restart the simulation from the 5000 seconds i have already edit the U, p, k and nut files but i am still struggling with the edition of the phi and phi_0 files. Related to this last issue, my questions are:
|
If the mesh is different, you can use the mapFields option to "map" the fields and restart your runs.
Cheers, -J |
If the mesh is the same, use changeDictionary utility.
|
Quote:
|
Quote:
|
Hi all,
I know that this conversation is quite old, but my issue is relative to this topic. I have already run a simulation and I have a serious issue of wave reflection to the outlet boundary, so I would like to take the last path before the wave reflexion and try to change the outlet. For this, initially I tried to use the changeDictionaryDict where I take always the same error: --> FOAM FATAL IO ERROR: keyword sampleMode is undefined in dictionary ".inlet" file: .inlet from line 23 to line 25. From function const Foam::entry& Foam::dictionary::lookupEntry(const Foam::word&, bool, bool) const in file db/dictionary/dictionary.C at line 551. FOAM exiting After, I tried with the MapFields utility by changing the boudary condition in the target and by taking the latestTime information of the source. I take exactly the same error in the execution of mapFields too. Does someone have met a relative error in the past and could explain to me? Thank you in advance :) Georgia |
Hi everyone,
I recently had to go through this problem and I'll share here the solution I've adopted. First of all:
Code:
#!/bin/bash
Code:
startFrom latestTime; Cheers |
This is a nice solution!
Any ideas on how to set the 'value' entry when switching from 'zeroGradient' to something else? externalWallHeatFluxTemperature in my case. Zero gradient doesn't have a value entry because it uses neighboring cell values. I'd like to use those rather than a uniform field. Temperature in my case. PS. It just occurred to me that externalWallHeatFluxTemperature is a mixed type BC so I can have it work like zeroGradient by using HTC=0. It's gonna look illogical but it'll work. |
All times are GMT -4. The time now is 21:10. |