CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Write data at specific times, not intervals

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

Like Tree19Likes
  • 1 Post By artymk4
  • 7 Post By dybuk
  • 11 Post By mAlletto

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 9, 2019, 03:49
Default Write data at specific times, not intervals
  #1
Member
 
Martin
Join Date: Aug 2018
Posts: 33
Rep Power: 7
artymk4 is on a distinguished road
Is it possible to write data at specified times (timesteps) instead of fixed intervals?
I want to output data multiple times only at the end of simulation. If I wanted to write data only at the very last time step, I could do this:
Code:
endTime         4000;
deltaT          1;
writeControl    timeStep;
writeInterval   4000;
But I want to write data at time steps 3970, 3980, 3990, 4000. I know I could do this with purgeWrite:
Code:
endTime         4000;
deltaT          1;
writeControl    timeStep;
writeInterval   10;
purgeWrite      4;
But this way my simulation would take much more time because of useless writing every 10 time steps from the beginning (400 times instead of 4).


There's another option, to end simulation at time 3970 with writeInterval 3970 so I get only one output. And then starting simulation again from latest time with writeInterval 10 and endTime 4000. But this is not ideal because it's not automatic, I need to change controlDict during simulation.
My solution would be this:
Code:
endTime         4000;
deltaT          1;
writeControl    timeStep;
writeInterval   (3970 3980 3990 4000);
but it's not working because writeInterval needs to be scalar. Maybe this can be suggestion for next update. Or can I modify OpenFOAM so it will accept more values, not only one interval. But I have no idea how to do that.
Brandani likes this.
artymk4 is offline   Reply With Quote

Old   May 13, 2019, 01:37
Default
  #2
Member
 
W.T
Join Date: Oct 2012
Posts: 35
Rep Power: 13
dybuk is on a distinguished road
You can use systemCall function object and second controlDictfile

For eg.
controlDict

Code:
endTime         4000;
deltaT          1;
writeControl    timeStep;
writeInterval   3970;
newControlDict
Code:
endTime         4000;
deltaT          1;
writeControl    timeStep;
writeInterval   10;

and in systemCall function object setup

Code:
writeCalls
        (
            "cp system/newControlDict system/controlDict"
        );
In time step 3970 you will save the result and change the write interval to 10 so you will end with saved time step 3970 3980 3990 4000
dybuk is offline   Reply With Quote

Old   May 16, 2019, 05:25
Default
  #3
Member
 
Martin
Join Date: Aug 2018
Posts: 33
Rep Power: 7
artymk4 is on a distinguished road
Quote:
Originally Posted by dybuk View Post
You can use systemCall function object and second controlDictfile

For eg.
controlDict

Code:
endTime         4000;
deltaT          1;
writeControl    timeStep;
writeInterval   3970;
newControlDict
Code:
endTime         4000;
deltaT          1;
writeControl    timeStep;
writeInterval   10;
and in systemCall function object setup

Code:
writeCalls
        (
            "cp system/newControlDict system/controlDict"
        );
In time step 3970 you will save the result and change the write interval to 10 so you will end with saved time step 3970 3980 3990 4000
Thanks, I didn't know about function systemCall. However I'm using foam-extend-4.0 which lacks this function. I got error Unknown function type systemCall
artymk4 is offline   Reply With Quote

Old   September 7, 2019, 05:48
Default
  #4
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
Have you added the library to the run?
Code:
functionObjectLibs ( "libsystemCall.so" );
See: https://openfoamwiki.net/index.php/T...ect_systemCall


Actually, you also need this lib:
Code:
libs ( "libutilityFunctionObjects.so" );
jherb is offline   Reply With Quote

Old   April 25, 2020, 04:27
Default
  #5
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
I'll just post the solution I've found just in case someone is interested: I used OF1912 and there you have the function object timeActivatedFileUpdate. Where you basically can update a given file to a specific time step. So each time one wants a different timestep to written the fields out one can update the control dict:


Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v1912                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     rhoPimpleFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         0.26;

deltaT          2e-6;
adjustTimeStep  yes;

maxCo           3.0;


writeControl    adjustable;

#include "writeInterval"

//writeInterval   0.01;

purgeWrite      0;

writeFormat     ascii;

writePrecision   8;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

functions
{
    #includeFunc MachNo
    #includeFunc residuals
    
    fileUpdate1
    {
        type              timeActivatedFileUpdate;
        libs              ("libutilityFunctionObjects.so");
        writeControl      timeStep;
        writeInterval     1;
        fileToUpdate      "<system>/writeInterval";
        timeVsFile
        (
            (-1   "<system>/writeInterval.00")
            (0.002   "<system>/writeInterval.01")
            (0.005 "<system>/writeInterval.02")
            (0.011 "<system>/writeInterval.03")
            (0.022 "<system>/writeInterval.04")
            (0.028 "<system>/writeInterval.05")
            (0.08 "<system>/writeInterval.06")
            (0.09 "<system>/writeInterval.07")
            (0.1 "<system>/writeInterval.08")
            (0.11 "<system>/writeInterval.09")
            (0.153 "<system>/writeInterval.10")
            (0.16   "<system>/writeInterval.11")
            (0.17 "<system>/writeInterval.12")
            (0.18 "<system>/writeInterval.13")
            (0.23 "<system>/writeInterval.14")
            (0.24 "<system>/writeInterval.15")
            (0.25 "<system>/writeInterval.16")
        );
    }


}

The files writeInterval contain the desired time step, e.g. /writeInterval.16 contains the entry:


writeInterval 0.252614931093667;


In this way I could achieve that the fields are written out at irregular time steps.
nimasam, zhangyan, artymk4 and 8 others like this.
mAlletto is offline   Reply With Quote

Old   November 10, 2020, 23:02
Default
  #6
Member
 
Stanley John
Join Date: Sep 2018
Posts: 79
Rep Power: 7
sjohn2 is on a distinguished road
Hi can you post your writeinterval file?
is it valid for foundation version?
sjohn2 is offline   Reply With Quote

Old   November 11, 2020, 03:51
Default
  #7
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
I don't know if it is valid for the foundation version. The file contains simply the entries

Code:
writeInterval 0.252614931093667;
mAlletto is offline   Reply With Quote

Old   November 13, 2020, 02:30
Default Write data as needed in controlDict, of6
  #8
New Member
 
Duc Anh
Join Date: Dec 2018
Posts: 22
Rep Power: 7
anhkenyt is on a distinguished road
Quote:
Originally Posted by dybuk View Post
You can use systemCall function object and second controlDictfile

For eg.
controlDict

Code:
endTime         4000;
deltaT          1;
writeControl    timeStep;
writeInterval   3970;
newControlDict
Code:
endTime         4000;
deltaT          1;
writeControl    timeStep;
writeInterval   10;

and in systemCall function object setup

Code:
writeCalls
        (
            "cp system/newControlDict system/controlDict"
        );
In time step 3970 you will save the result and change the write interval to 10 so you will end with saved time step 3970 3980 3990 4000
Hi foamers,
I want to write data only at the 3 final steps (98 99 100)
Thank dybuk for your interesting answers, but when I use systemCall as you said.
However, nothing happens. Anybody can help me?
This is controlDict
Code:
startFrom       startTime;
startTime       0;
stopAt          endTime;
endTime         0.0001;//0.007; //0.00052;//0.002; //1 first 0.00052;
deltaT          0.000001; //0.0000005;
writeControl    timeStep;//adjustableRunTime;//
writeInterval   96;
purgeWrite      0;
writeFormat     ascii;
writePrecision  6;
writeCompression off;
timeFormat      general;
timePrecision   6;
runTimeModifiable true;
adjustTimeStep	no;
maxCo		0.9;
maxDeltaT	0.1;
writeCalls
(
	"cp system/newControlDict system/controlDict" 
);
and newControlDict
Code:
startFrom       startTime;
startTime       0;
stopAt          endTime;
endTime         0.0001;// 0.007; //0.00052;//0.002; //1 first 0.00052;
deltaT          0.000001; //0.0000005;
writeControl    timeStep;//adjustableRunTime;//
writeInterval   1;
purgeWrite      0;
writeFormat     ascii;
writePrecision  6;
writeCompression off;
timeFormat      general;
timePrecision   6;
runTimeModifiable true;
adjustTimeStep	no;
maxCo		0.9;
maxDeltaT	0.1;
libs ( "libutilityFunctionObjects.so" );
When running has done just have data at 96 steps.
anhkenyt is offline   Reply With Quote

Reply

Tags
data output, specific timesteps, writecontrol, writeinterval

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
CFX ERROR : unable to write the requested IO string array data set. HJH CFX 3 March 18, 2016 03:14
How to extract data from a specific layer of the grids? ripperjack OpenFOAM Post-Processing 1 October 29, 2014 08:57
error message cuteapathy CFX 14 March 20, 2012 06:45
How to extract data of specific variable from PHI and Q1 file? mukut Phoenics 3 October 17, 2011 06:13
Constant velocity of the material Sas CFX 15 July 13, 2010 08:56


All times are GMT -4. The time now is 19:48.