CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Restarting simulations in openfoam with updated boundary conditions (http://www.cfd-online.com/Forums/openfoam/114435-restarting-simulations-openfoam-updated-boundary-conditions.html)

maheshraj March 11, 2013 07:24

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

sail March 11, 2013 10:48

any reason why you can't simply edit the approriate file (U, p, etc...) in the 2000 directory?

maheshraj March 12, 2013 12:18

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.

julien.decharentenay March 13, 2013 19:39

I think you can do it using the changeDictionary utility.

Phicau March 14, 2013 03:45

Quote:

Originally Posted by maheshraj (Post 413486)
U or any file at 2000th iteration is a binary file and will contain the values at each node. So it is not possible to edit these files.

Yes you can, not directly, but it takes 3 steps.

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.

sail March 14, 2013 13:05

Quote:

Originally Posted by maheshraj (Post 413486)
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.

sorry, i usually keep my writeFormat in ascii, mor ease of modification and readability.

mturcios777 March 14, 2013 14:36

I would use mapFields have the target mesh equipped with new boundary conditions (and specified at cutting patches)

Tobias Adam January 24, 2014 10:04

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

julien.decharentenay January 25, 2014 01:44

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        @^)
3rINwȔ@(<V^M&#B|-@y{Jj\
X@N<9&m);

boundaryField
{
    minX
    {
        type            zeroGradient;
    }
    maxX
    {
        type            zeroGradient;
    }

There is some binary for the fields values, but the boundary conditions are in plain text...

ripudaman January 26, 2014 14:50

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?

julien.decharentenay January 28, 2014 07:38

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 = []
Dir.foreach(".") { |f|
 times.push(f.to_f) if ((File.directory?(f)) and (f =~ /\d+/))
}
latestTime = times.max()



All times are GMT -4. The time now is 04:24.