CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   Apply deltaT in utility (

botp December 10, 2010 12:39

Apply deltaT in utility
Dear all,

At the moment I am trying to modify a utility file, where I want to multiply a constant by deltaT. I use a fixed Courant number, so I do not know the time step beforehand.

I have tried the following:
where alpha is the expression I want to modify, and C is a constant.

When I recompile the utility I get the following error message: error: ‘runTime’ was not declared in this scope.

I know there is not much information in the post, but if anybody could give me an advise on how to declare runTime, it will be appreciated.

Kind regards,
Bo Terp

Ps. I am using OF 1.5-dev

MartinB December 10, 2010 14:37

Hi Bo Terp,

have a look at /applications/utilities/postProcessing/wall/wallGradU/wallGradU.C for example.

Here is a code snippet that shows how to access the time values:

    ... header from wallGradU.C ...
int main(int argc, char *argv[])
    #include "setRootCase.H"
#  include "createTime.H"
    instantList timeDirs = timeSelector::select0(runTime, args);
#  include "createMesh.H"

    scalar lastTimeStep = 0; // added
    scalar deltaTime = 0; // added
    forAll(timeDirs, timeI)
        runTime.setTime(timeDirs[timeI], timeI);
        deltaTime = timeDirs[timeI].value() - lastTimeStep; // added
        lastTimeStep = timeDirs[timeI].value(); // added

        Info<< "Time = " << runTime.timeName() << endl;
        Info<< "deltaT = " << deltaTime << endl; // added

        ... more code ...


All times are GMT -4. The time now is 18:35.