CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Apply deltaT in utility (https://www.cfd-online.com/Forums/openfoam/82992-apply-deltat-utility.html)

botp December 10, 2010 11: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:
alpha=C*runTime.deltaT().value();
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 13: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:
Code:

    ... header from wallGradU.C ...
int main(int argc, char *argv[])
{
    timeSelector::addOptions();
    #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 ...

Martin


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