CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   OpenFoam basic (http://www.cfd-online.com/Forums/openfoam-solving/59901-openfoam-basic.html)

liton December 9, 2006 20:25

In the OpenFoam, following few
 
In the OpenFoam, following few lines are very common for variable declearation.

IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ, // or NO_READ
IOobject::AUTO_WRITE // or NO_WRITE
),
mesh

In third argument, there is a term "mesh", what does this mean with respect to the variable "T". Also at the end the same "mesh" term. sometimes, this position there is some calculations like 2/3*p+... . Finally, "IOobject::MUST_READ", what does this reply. Does some one have time to explain me these very basic terms.

Liton

alberto December 10, 2006 16:14

Hello Liton, to reuse your ex
 
Hello Liton,
to reuse your example, I will consider the case of a temperature field, for which the full declaration is:
<pre>
volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::MUST_READ, // or NO_READ
IOobject::AUTO_WRITE // or NO_WRITE
),
mesh
);
</pre>

A volScalarField actually is a geometricField of scalars, so the constructors used are the same for them both.
You can find them here: http://foam.sourceforge.net/doc/Doxygen/html/de/d5c/classFoam_1_1GeometricField. html

A common way to declare a field when you want to read it from a file at the beginning (or restart) of a calculation is to use IOobject and the mesh, as done before.

In such a case, you need to set IOobject::MUST_READ, to make OpenFOAM read it at construction time.

If you don't want to read the field from a file, but just declare it, and initialize it to something, you can use this syntax:
<pre>
volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE // or NO_WRITE
),
3/2*alpha*beta
);
</pre>
with IOobject::NO_READ. Alpha and beta are others volScalarField and you initialize the field to the value of 3/2*alpha*beta.

"T" -> is the name of the file on the disk from/to which OpenFOAM will read/write. Usually it's the same of the variable.

IOobject::AUTO_WRITE -> automatically saves the field at write time (for example, ever a predetermined number of iterations, set in the controlDict of the simulation case).

IOobject::NO_WRITE -> never writes the field to a file.

I hope this helps.

Regards,
Alberto


All times are GMT -4. The time now is 14:50.