CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   .oldTime() question (http://www.cfd-online.com/Forums/openfoam-programming-development/109003-oldtime-question.html)

chaolian November 6, 2012 21:02

.oldTime() question
 
Info<< "Reading field alphaL\n" << endl;
volScalarField alphaL
(
IOobject
(
"alphaL",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
alphaL.oldTime();
mesh,
dimensionedScalar("alphaL", dimless, scalar(0.0))
);
--------------------------
When compiled, error:
createFields.H:42: error: expected `)' before ';' token
createFields.H:44: warning: left-hand operand of comma has no effect
createFields.H:45: error: expected `;' before ')' token
--------------------------
I cannot figure out where the problem is. Thanks.

kathrin_kissling November 7, 2012 03:36

Hey,

first thing is a general one:

you should not use a ; (semicolon) inside a constructor. These are comma-seperated lists.

second: Check GeometricField class for constructors, I think there is none like the one you stated. What are you trying to do?

Best

Kathrin

chaolian November 7, 2012 07:51

Hi, Kathrin
Thanks for pointing out this mistake.
----------------
volScalarField alphaTemp
(
IOobject
(
"alphaTemp",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("alphaTemp", dimless, 0)
);
alphaTemp.oldTime();
-------------------
Maybe this is the correct way to use. I am trying to store alphaTemp's old value for each time, since I want to use ddt(alphaTemp) later. I am not quite sure whether this is correct.

chaolian November 7, 2012 07:53

Hi, Kathrin
Thanks for pointing out this mistake.
----------------
volScalarField alphaTemp
(
IOobject
(
"alphaTemp",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("alphaTemp", dimless, 0)
);
alphaTemp.oldTime();
-------------------
Maybe this is the correct way to use. I am trying to store alphaTemp's old value for each time, since I want to use ddt(alphaTemp) later. I am not quite sure whether this is correct.


All times are GMT -4. The time now is 02:58.