CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Write field data at a few specific timesteps (https://www.cfd-online.com/Forums/openfoam/128358-write-field-data-few-specific-timesteps.html)

gary7 January 9, 2014 16:45

Write field data at a few specific timesteps
 
Hi All,

Is it possible to control the writing of the filed data happens at some specific timesteps which are not necessarily a multiple of "writingInterval"? Let's say I want the data to be written only at timesteps = 10, 17, 43 and 71. Right now I have to write data out every timestep in order to obtain field at these timesteps.

How can I write data only at the mentioned timesteps?

Cheers,
Kasra.

KateEisenhower October 21, 2016 07:51

Hi Kasra,

have you found any answer to this question? Of course one could write a shell-script which reads the OpenFOAM output and changes the controlDict at the appropriate time, but that isn't very elegant.

Best regards,

Kate

gary7 October 21, 2016 13:40

Hi Kate,

I used a quick hack to do it. It is not the best way to do it but it does the job:

Code:

if
(
  mag(runTime.value() - runTime.deltaT().value() * 10) < SMALL
)
{
    runTime.writeNow();
}

This will write out the results at 10th timestep.

Cheers,
Kasra.

KateEisenhower October 24, 2016 06:12

Hi Kasra,

thanks for your response. This works only for a fixed timestep, right?

Kate

gary7 October 24, 2016 16:42

That's right. You can write the results at specific timesteps, you can add more timesteps using "or" (||) operator. However, the clean and robust way of doing it is defining an IOdictionary and list the required timesteps in there and use those instead of hard coding the timesteps right into the code.

Brandani March 11, 2020 12:31

Hi! Do you happen to know how to use the IO dictionary to make your simulation write out user-specified times?


All times are GMT -4. The time now is 12:32.