CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Problems with extracting data (http://www.cfd-online.com/Forums/openfoam-post-processing/72089-problems-extracting-data.html)

Alicelin January 25, 2010 08:54

Problems with extracting data
 
Hi everyone,

I got a problem when extracting values from a specific time step, the following is my code:

Code:

#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{

#  include "addTimeOptions.H"
#  include "setRootCase.H"

#  include "createTime.H"

    // Get times list
    instantList Times = runTime.times();

    // set startTime and endTime depending on -time and -latestTime options
#  include "checkTimeOptions.H"

    runTime.setTime(Times[startTime], startTime);

#  include "createMesh.H"

    for (label i=startTime; i<endTime; i++)
    {
        runTime.setTime(Times[i], i);

        Info<< "Time = " << runTime.timeName() << endl;
        Info<< "Start Time = " << startTime << endl;
        Info<< "End Time = " << endTime << endl;
       
    volScalarField UMeanNorm
    (
        IOobject
        (
          "UMeanNorm",
          runTime.timeName(endTime),
          mesh,
          IOobject::MUST_READ
        ),
        mesh
    );

As I want to extract UMeanNorm from the last time step (that is Time = 5), I set runTime.timeName(endTime) for UMeanNorm, but it turned out that the time that was chosen was 52 not 5 (but Time=52 doesn't exist!). I wonder how can I re-set the things so that the time chosen for extracting the data is the last time step:confused:
The following is the controlDict code:
Code:

FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application turbFoam;

startFrom      startTime;

startTime      0;

stopAt          endTime;

endTime        5;

deltaT          0.001;

writeControl    timeStep;

writeInterval  100;

purgeWrite      0;

writeFormat    ascii;

writePrecision  6;

writeCompression uncompressed;

timeFormat      general;

timePrecision  6;

runTimeModifiable yes;

It would be great if anyone could help me:)

Thanks!

Alice


All times are GMT -4. The time now is 00:45.