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

table format writeInterval in controlDict?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By sourav90
  • 1 Post By courant_numero_uno

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 20, 2021, 15:04
Default table format writeInterval in controlDict?
  #1
Member
 
Sourav Mandal
Join Date: Jul 2019
Posts: 55
Rep Power: 6
sourav90 is on a distinguished road
Dear FOAMers,

Sometimes I feel the need to change the writeInterval from prior knowledge & in stead of modifying the controlDict every time, I wonder if it's possible to do like this:

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

application         particleFoam;

startFrom           startTime;
startTime           0;
stopAt               endTime;
endTime            1000;

deltaT                1e-1;
writeControl        runTime;
// writeInterval       10;

// my wish :) 
writeInterval      table
(
    (
0           1// start with interval of 1
    
(10       10// from T=10, writeInterval 10
    
(1000   50// use 50 from T=10 until the end
);


purgeWrite          0;
writeFormat         binary;
writePrecision      6;
writeCompression    off;

timeFormat          general;
timePrecision       6;
runTimeModifiable   yes;

functions{
... 

I find two similar examples, but applicable for other objects
  1. HIstorically, page 9 of this example shows such implimentation: https://www.dhcae-tools.com/images/d...rcelSolver.pdf
  2. Time-varied boundary condition table: This is presently available as options in current OpenFOAM distribution: 2nd or 3rd example in section 5.2.3.4 of https://cfd.direct/openfoam/user-gui...25-1790005.2.2

    Code:
    inlet 
    { 
        type         uniformFixedValue; 
        uniformValue table ((0 0) (10 2)); 
    }

Anyone knows if it's possible, or how to implement? thanks.
sourav90 is offline   Reply With Quote

Old   August 23, 2021, 10:31
Default
  #2
Member
 
Sourav Mandal
Join Date: Jul 2019
Posts: 55
Rep Power: 6
sourav90 is on a distinguished road
Thanks to MartinB, who provided this working example of using functionObject in controlDict.

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

  
application     simpleFoam;

  
startFrom       startTime;

  
startTime       0;

  
stopAt          endTime;

  
endTime         2000;

  
deltaT          1;

  
writeControl    timeStep;

  
writeInterval   100000// <------ big number

  
purgeWrite      0;

  
writeFormat     ascii;

  
writePrecision  6;

  
writeCompression off;

  
timeFormat      general;

  
timePrecision   6;

  
runTimeModifiable true;

  
functions
  
{
      
userWriteInterval
      
{
          
type coded;
          
libs            ("libutilityFunctionObjects.so");
          
name writeInterval;

          
code
          
#{
          #};

          
codeExecute
          
#{
              
const TimerunTime mesh().time();
              
scalar myWriteInterval(1);

              
// better logic here:
              // for example with a function1
              
if (runTime.value() > 10)
              {
                  
myWriteInterval 10;
              }
              if (
runTime.value() > 50)
              {
                  
myWriteInterval 50;
              }

              if (!(
runTime.timeIndex() % label(myWriteInterval)))
              {
                  
const_cast<Time&>(runTime).writeNow();
              }
          
#};
      
}

  }

  
// ************************************************************************* // 
The `$FOAM_INST_DIR/OpenFOAM-x/applications/test/Function1` can be referred if someone understands the C++ code well enough
AtoHM likes this.

Last edited by sourav90; August 26, 2021 at 12:59.
sourav90 is offline   Reply With Quote

Old   August 15, 2022, 02:37
Default
  #3
Senior Member
 
M
Join Date: Dec 2017
Posts: 642
Rep Power: 12
AtoHM is on a distinguished road
Thanks for providing the solution here.

Just one question, as I am not very skilled at understanding c++: it seems from my test, that the writeInterval set here does act on the iteration number and not the physical time.
How can I make sure, that output is written at fixed physical time intervals? Example: with the current setting lets say I provided writeInterval of 100. The solver dt varies between 0.0012 and 0.0018. This causes output in the physical interval of 0.12 - 0.18 s depending on the intermediate time steps.
What do I have to change, that the provided writeInterval is interpreted as the physical interval?
AtoHM is offline   Reply With Quote

Old   September 23, 2022, 12:34
Default
  #4
New Member
 
Join Date: Sep 2019
Posts: 17
Rep Power: 6
courant_numero_uno is on a distinguished road
You could change "writeInterval" to "runTime" in the code above, and adjust the if statement switches as you wish.
writeControl can write based on several criteria, see below for 2112.
https://www.openfoam.com/documentati...n-objects.html
AtoHM likes this.
courant_numero_uno is offline   Reply With Quote

Reply

Tags
dictionary, table, table data


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
Run time Selection Mechanism - Some help required to understand jaswi OpenFOAM Programming & Development 3 October 29, 2015 13:42
Problem in3D model processing mebinitap OpenFOAM 2 December 12, 2014 04:40
cannot find file constant/boundaryData/outlet/points assert OpenFOAM Running, Solving & CFD 1 April 25, 2014 09:36
NASTRAN Data format Srinivasan Arunajatesan Main CFD Forum 1 January 2, 2014 06:20
Table Manipulation furkan Siemens 0 April 4, 2006 10:23


All times are GMT -4. The time now is 14:37.