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/)
-   -   Calculations and Dimensions (https://www.cfd-online.com/Forums/openfoam-programming-development/130949-calculations-dimensions.html)

maybee March 6, 2014 08:04

Calculations and Dimensions
 
Hi,

I am working with the multiphaseEulerFoam and I recognized that sometimes fields are initialized like

Code:

volScalarField p
    (
        IOobject
        (
            "p",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

without getting dimensions. On the other hand some fields are initialized like

Code:

volVectorField U
    (
        IOobject
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        mesh,
        dimensionedVector("U", dimVelocity, vector::zero)
    );

Should I initialize fields generally with a dimensioned type especially when using them for calculations or should I initialize fields without any dimension type (-> are they dimless then?) ?

Lieven March 6, 2014 08:23

Hi Maybee,

The clue is in the way the field is read:

In case of your 'p'-example, the p-field must be read (IOobject::MUST_READ). Initial value of the field and also the dimensions are read from the field in the time folder "runTime.timeName()".

In case of the velocity field U. You specify IOobject::NO_READ meaning that OF will not search for an input file in the time folder but that the field is initialized by the dimensions vector (which automatically defines the dimensions).

There is an other option possible: READ_IF_PRESENT which basically combines the two previous ones. (in fact also a fourth, MUST_READ_IF_MODIFIED, but this is less relevant in the present context).

Hope this clarifies things...

Cheers,

L

maybee March 6, 2014 12:09

Thx. got it now. :)

Z.Q. Niu December 26, 2014 07:06

Hi Lieven, I want to define volSymmetryField, but I don't know know how to write the code of demensioneSet and initialize it. Would you mind giving me some advice? Thanks!


All times are GMT -4. The time now is 10:41.