CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   IOobject returns constant value (https://www.cfd-online.com/Forums/openfoam-solving/232075-ioobject-returns-constant-value.html)

shock77 November 28, 2020 18:25

IOobject returns constant value
 
Hi,


I am trying to create a new IOobject (Reynoldsnumber). Therefore I have added the following lines in my createFields.H and compiled it without errors. Unfortunately only a const value is returned (for Re and nu):


Code:

volScalarField nu
    (
    IOobject
        (
            "nu",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        thermo.mu()/rho
    );


volScalarField L
(
    IOobject
    (
        "L",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    mesh,dimensionedScalar("L", dimensionSet(0,1,0,0,0,0,0),1 )
);

    volScalarField Re
    (
    IOobject
        (
            "Re",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
         
        ),
        mag(U)*0.00095*L/nu
    );


Any idea what I am doing wrong?

Wenyuan November 29, 2020 02:54

Hi,

You need to update such volScalarFields in the time loop. Otherwise, they will always take the initial values defined in createFields.H.

shock77 November 29, 2020 05:58

Thank you very much, it seems to work now!


As you said, I have added the lines in the time loop of my solver:


Code:

nu = thermo.mu()/rho;
L = dimensionedScalar("L", dimensionSet(0,1,0,0,0,0,0),1 );
Re = mag(U)*0.00095*L/nu;



All times are GMT -4. The time now is 23:56.