CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Questions about data output (http://www.cfd-online.com/Forums/openfoam-solving/78894-questions-about-data-output.html)

 aki_yafuji August 5, 2010 04:37

Questions about data output

Dear FOAMers,

I am now studying OpenFOAM by modifying some tutorials,
especially dam break tutorial by supposing the kEpsilon
model for turbulence.
I have a couple of questions about data output...
If you wouldn't mind, would you please give me some advice?

1. I could understand that when I want to control data output,
I should modify "createFields.H", but I am not sure the
description well.
For example, pressure "p" and density "rho" are written in
createFields.H as follows,

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

volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
),
alpha1*rho1 + (scalar(1) - alpha1)*rho2,
alpha1.boundaryField().types()
);
-----------------------------------------------------

My question is what does "mesh" in p mean?
For rho, concrete descriptions
"alpha1*rho1 + (scalar(1) - alpha1)*rho2,
alpha1.boundaryField().types()"
are written instead of "mesh".

2. We can find turbulent viscosity: nut and Reynolds
stress tensor: R in kEpsilon.C.
Of them, nut is written in Constructors,

-----------------------------------------------------
nut_
(
IOobject
(
"nut",
runTime_.timeName(),
mesh_,
),
autoCreateNut("nut", mesh_)
)
{
nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
nut_.correctBoundaryConditions();

printCoeffs();
}
-----------------------------------------------------

on the other hand, R is written in Member Functions,

-----------------------------------------------------
tmp<volSymmTensorField> kEpsilon::R() const
{
return tmp<volSymmTensorField>
(
new volSymmTensorField
(
IOobject
(
"R",
runTime_.timeName(),
mesh_,
IOobject::NO_WRITE
),
k_.boundaryField().types()
)
);
}
-----------------------------------------------------

As for nut (which is described in Constructors),
I can get its value at each time step when I add
"IOobject::AUTO_WRITE".
But I could not output R (which is described in
Member Functions), even if I use
"IOobject::AUTO_WRITE"
"IOobject::NO_WRITE".

What should I do when I want to output the Reynolds stress
tensor R (such as values that are written in Member Functions)?
I can not output R either even if I type "R" in post-processing.

3. I think "U" in OpenFOAM means the total velocity which is the sum of
mean and perturbation velocities.
Where are the mean velocity (UMean) and the perturbation velocity
(UPrime = U - UMean) in the code? I would like you to tell me
how you output the three components (i.e., x, y, and z components)
of both mean and perturbation velocities.

4. I would like to calculate potential energy: rho*g*x,
but I am not sure how the x-coordinate is stored in the code.
Would you please tell me how do you output the x-coordinate?

Maybe these question arises from a lack of understanding of C++,
it would give me a great deal of pleasure if you give me some

aki

 nimasam August 5, 2010 08:33

hi friend you have too questions here :)
1. look following address you will find more about out put input to the openFoam
http://openfoamwiki.net/index.php/In...IOobject_class

 marupio August 5, 2010 11:22

Quote:
 Originally Posted by aki_yafuji (Post 270358) 1. My question is what does "mesh" in p mean?
These are all constructors for volScalarField, which is a GeometricField. There are 13 different constructors defined for the GeometricField, and p is being created using this one:

Code:

```        //- Construct and read given IOobject         GeometricField         (             const IOobject&,             const Mesh&         );```
The first argument is an IOobject, and is defined by:

Code:

```        IOobject         (             "p",             runTime.timeName(),             mesh,             IOobject::MUST_READ,             IOobject::AUTO_WRITE         )```
IOobjects are part of the objectRegistry system which is what OpenFOAM uses to manage its model-related data. As nima says there are good references on the wiki. Also check out:

http://openfoamwiki.net/index.php/Op...objectRegistry

The second argument is a reference to the mesh, which the GeometricField needs to build itself. There are no other arguments, so GeometricField looks in your case directory for the file [time]/p and reads this file.

On the other hand, rho is not (necessarily) defined in the case directory, rather it is derived from other variables. To accomplish this a different GeometricField constructor is used:

Code:

```        //- Construct as copy resetting IO parameters and boundary types         GeometricField         (             const IOobject&,             const GeometricField<Type, PatchField, GeoMesh>&,             const wordList& patchFieldTypes         );```
The first parameter is another IOobject. For the second parameter, we have:
Code:

`alpha1*rho1 + (scalar(1) - alpha1)*rho2`
This is the equation that is used to calculate the value for rho at every point. Lastly, is the patchField list:
Code:

`alpha1.boundaryField().types()`
Quote:
 Originally Posted by aki_yafuji (Post 270358) 2. nut is written in Constructors, R is written in Member Functions I can get the value for nut at each time step when I add "IOobject::AUTO_WRITE". But I could not output R (which is described in Member Functions), even if I use "IOobject::AUTO_WRITE" instead of "IOobject::NO_WRITE". What should I do when I want to output the Reynolds stress tensor R (such as values that are written in Member Functions)?
This is because R is transient (comes and goes), whereas nut is always in memory.

The changes you suggest above are to the turbulence model itself, part of the core of OpenFOAM. I'd recommend against changing these, as it will impact the behaviour of every solver in existence. I'd recommend changing the solver if anything.

I'm sure there's easier ways, but one thing you could try is adding another field to the end of createFields.H, such as:

Code:

```    volSymmTensorField R     (         IOobject         (             "R",             runTime.timeName(),             mesh,             IOobject::NO_READ             IOobject::AUTO_WRITE         ),         turbulence->R()     );```
Lastly, in your solver loop, just before runTime.write(), you have to update the field:
Code:

`    R = turbulence->R();`
Quote:
 Originally Posted by aki_yafuji (Post 270358) 3. I think "U" in OpenFOAM means the total velocity which is the sum of mean and perturbation velocities.
You are using a RAS turbulence model which is averaging already. The perturbed velocities are not directly calculated when using models such as k-epsilon. Their effect is accounted for using the turbulence model variables, such as nut, k and epsilon. That is not OpenFOAM specific, you should be able to find this in any information resource on turbulence modelling. Try looking for the eddy-viscosity hypothesis.

Quote:
 Originally Posted by aki_yafuji (Post 270358) 4. I would like to calculate potential energy: rho*g*x, but I am not sure how the x-coordinate is stored in the code. Would you please tell me how do you output the x-coordinate?
Translating the text-file data output to usable data by coordinates is a pain. You should look into using the data sampling utility (sample), or I've heard the calculator in paraFoam isn't bad either.

Good luck!

-dave

 aki_yafuji September 9, 2010 01:59

I am so sorry to be late that I could not reply you sooner,
because I attended a training camp...

Dear nima,
Thank you for letting me know good references on the wiki.
I am not clear about hierarchy of codes yet, but I'll try to read
the reference until I figure it out.

Dear dave,
Thank you very much for all the advices and help you gave me!!
Your advices become informative guide to understand OpenFOAM!
I tried to modify the code based on your guide, some additional
questions are popped up. May I also know more about the way for
data output? It would make me very happy if you gave me more advices.

Q1.
Quote:
 Originally Posted by marupio (Post 270429) I'm sure there's easier ways, but one thing you could try is adding another field to the end of createFields.H, such as: Code: ```    volSymmTensorField R     (         IOobject         (             "R",             runTime.timeName(),             mesh,             IOobject::NO_READ,             IOobject::AUTO_WRITE         ),         turbulence->R()     );``` Lastly, in your solver loop, just before runTime.write(), you have to update the field: Code: `    R = turbulence->R();`
In accordance with your advice, I can obtain R data!
But, R file is written at each time step. (Other files such as p and U are written at
constant 'writeInterval' time step. On the other hand, although 'writeInterval' = 0.001,
every folders such as '0.000119048', '0.000260204', '0.000428132'... are created
and only R files are stored in them. )
If possible, please let me know if you can help in some other way to write R files
at constant 'writeInterval' time step, similar to other files such as p and U.

Q2.
Now I am using the standard kEpsilon solver.
The rate of turbulence energy production is defined in the 217 line from the top
in /src/turbulenceModels/incompressible/RAS/kEpsilon/kEpsilon.C as 'G',
Code:

`00217    volScalarField G("RASModel::G", nut_*2*magSqr(symm(fvc::grad(U_))));`
I would like to output G at every 'writeInterval' time step, how should I modify kEpsilon.C?

It would be very helpful if you could give me some advices!

aki

 All times are GMT -4. The time now is 19:37.