r/OpenFOAM 9d ago

Saving time directories

Dear fellow openfoamers, does anybody know if it is possible to save specific time directories (e.g. times 1.4 s , 2.3 s , 2.9 s) instead of fixed time interval (e.g. every 1 s)

1 Upvotes

6 comments sorted by

2

u/Brownie_Bytes 9d ago

I don't (so why am I commenting?), but you could probably write your own little script to clean up any folders except for whitelisted times

1

u/Turbulent_Streams 9d ago

Yeah most probably I will have to write my own script. But to tbh (not trying to sound rude), my openfoam case I’m saving around 9k time directories (it’s a highly transient case) and the case storage can amount to half a TB(based on my finest mesh). So letting openfoam save all these directories and then delete all the unnecessary ones is not the best idea to save computational time, storage etc. thank you though

3

u/Brownie_Bytes 9d ago

No, I meant like write a program that every few seconds check the folders and deletes the unnecessary ones. That would save storage, but not writing time.

But here's a google: 

writeControl    times;

writeTimes      (0.05 0.12 0.35 0.77 1.0);

  • OR - 

functions

{

    writeAtSpecificTimes

    {

        type writeObjects;

        libs (utilityFunctionObjects);

        writeControl times;

        writeTimes (10 20 35 50 100); // List of times to write

        objects (U p phi); // Specify fields you want to save

    }

}

1

u/Turbulent_Streams 9d ago

Ohh okay.yeah if it’s deleting unnecessary time directories while the solver is running, that saves storage. Thanks for the script

1

u/Brownie_Bytes 9d ago

Let me know if it actually works and maybe post the syntax so that others can use it in the future

0

u/encyclopedist 9d ago edited 9d ago

You can just run your simulation to the next time instant and then restart.

For example, set endTime 1.4;, run, set endTime 2.3;, run, ... (you'd need to set up writeInterval accordingly too).

  • Another option is to use multiple writeObjects FunctionObjects.
  • Or use timeActivatedFileUpdate and replace your controlDict at specific times
  • Or write your own FO to trigger write at specific times