CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Solver looking for Foam::NO_READ fields ... (https://www.cfd-online.com/Forums/openfoam-programming-development/226272-solver-looking-foam-no_read-fields.html)

Gerry Kan April 22, 2020 11:06

Solver looking for Foam::NO_READ fields ...
 
Howdy Foamers:

I have something which I can't quite understand. Perhaps you could spot what the problem could be.

In my solver implemention, I have two variables set to IOobject::NO_READ in source file createFields.H:

Code:

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

volVectorField rhoG  (
    IOobject  (
        "rhoG",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    mesh
);

The code compiled without warnings (aside from a few unused variables which I expected to see). When the solver started, it complained about rhoG not being defined in the 0/ folder, while it not have any problems with rho at all.

In the end, I just wanted to have the field "rhoG" as temporary storage, as it will be used in a number of equations and I only wanted to calculate it once per outer iteration. I could define calculated boundary conditions in the 0 folder for rhoG, but ultimately I would like to hide that from the end user. How would I go about doing that?

Thanks in advance, Gerry.

Gerry Kan April 23, 2020 08:09

I realized what happened. In the above example, rho is constructed from an existing volScalarField thermo.rho(), so the solver did not need to look for values.

So in my case, the constructor for rhoG was modified to this:

Code:

volVectorField rhoG  (
    IOobject  (
        "rhoG",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE
    ),
    thermo.rho() * grav
);

where gravity was already defined prior as:

Code:

dimensionedVector grav    (
    "grav",
    dimensionSet(0,1,-2,0,0,0,0),
    ( 0 0 -9.81 ) );

With these changes, the code compiled and ran without problems.


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