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/)
-   -   How to set up an AUTO_WRITE scalarField (http://www.cfd-online.com/Forums/openfoam-solving/58778-how-set-up-auto_write-scalarfield.html)

xiao May 19, 2008 13:36

I posted the question some tim
 
I posted the question some time ago but did not get any reply ... so I reformulated it and posting it again. I hope someone with the experience could give me some hints. Thanks!

=====================================
The question is: how to "AUTO-WRITE" a field of type "scalarField" to a file, just in the same way as other fields like "p", and "U"?

I saw the example code in "spray" where a "volScalarField" is set up by reading from a file, or by construction from existing "volScalarField", but in my case, I don't have any existing field of the same type and I don't have any boundary conditions for this field.

I am doing particle-fluid interaction simulation, and in each time step, I calculate the solid volume fraction, and I want it to write itself to a file in the same way as "p" and "U". The gamma field has a value at each cell, no bounary condition or boundary field. HrV said in a post two years ago that it is a "bad idea" for construct a "volScalarField" from a "scalarField".
So... which way should I go in order to achieve this? Could someone give me some brief hint or pointer?

Thanks very much!

Heng

ngj May 20, 2008 04:16

Hi Heng Have a look at how
 
Hi Heng

Have a look at how phi is defined, to be found in

~/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude/createPhi.H

- Niels

xiao May 21, 2008 17:32

Hi Niels, Thank you for th
 
Hi Niels,

Thank you for the information!

Best,
Heng

xiao May 21, 2008 17:57

Hi Niels, Following the su
 
Hi Niels,

Following the suggestions of yours and other warm-hearted persons, I was able to make it working, as below. Have you any idea why the third parameter of IOobject is sometime mesh_, and sometimes U.db()? The function documentation says this is the "registory". What is significance and meaning of this argument? And what's the difference of mesh_, and U.db()?

Best,
Heng

-----------------
gamma_
(
IOobject
(
"gamma",
runTime_.timeName(),
U_.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("zero", dimless, 0.0)
)
------------------------------

xiao May 21, 2008 18:06

Hi Niels, Another aside qu
 
Hi Niels,

Another aside question.
About the example code you referred to earlier, would linearInterpolate(U) result in a velocity field from the original U, which is a volVectorField? I checked the definition of "linearInterpolate" and the specific type (whether it is a vol/surface/point field) is not specified. Any GeometricField would match. How does this work so smartly? i.e. from volField to surface field.

Best,
Heng
------------------
surfaceScalarField phi
(
IOobject
(
"phi",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
linearInterpolate(U) & mesh.Sf()
);

ngj May 22, 2008 03:30

Hi Heng @03:57-question:
 
Hi Heng

@03:57-question:

If you look into the documentation

http://foam.sourceforge.net/doc/Doxygen/html/classFoam_1_1GeometricField.html#d4 06828f1c838f80845be93dad156b21

you will find that a geometricField, which is what you are dealing with, can be constructed in many different ways, where two of them is the ones your are discussing. The geometricfield can be constructed using other field a initializer, read from file, and you can specify the wanted dimensions.

@04:06
I am less confident in this, but as far as I can figure out, the linearInterpolate is a routine, which interpolates the volField onto the surface. The inner product of this with the surface normal vector gives the normal flux through the surface.

Best regards,

Niels

waynezw0618 June 18, 2008 12:09

hi i face the same problem wi
 
hi
i face the same problem with you . i have some question to ask,

surfaceScalarField phi
(
IOobject
(
"phi",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
linearInterpolate(U) & mesh.Sf()is this the definition of "phi"? where is the definition of "gamma_" in Heng`s code? how can i export the some "scalarField" in the turbulence Model when i use the icoFoam(like "F1" in the SST )? can i "AUTOWRITE" it without defining in the code of icoFOAM?
);

thanks
wayne

suredross June 26, 2008 06:29

hi, i have an already solved
 
hi,
i have an already solved electric field in my case.what i want to do next is to write the field values of the immediate cells to the boundary onto the boundary itself.these will then be used to set the boundary conditions for a velocity field.how do i go about such a task?
any help is appreciated.
thanks
davey

hjasak June 26, 2008 08:21

Make a scalarIOField instead a
 
Make a scalarIOField instead and... enjoy!

Hrv

jorkolino July 22, 2010 03:23

Hi XIAO,

could you please post your code on how you did implement the calculation of solid volume fraction? I tried to do that following an example at http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2009/AureliaVallier/Tutorial_icoLagrangianFoam.pdf
chapter 5.3. Unfortunately I get segmentation error on the statement data.cloud().nbPVp()[cell()]+=(4/3*3.14*pow(d(),3)/8); As far as I figured out, data.cloud().nbPVp() is an object of type scalarField. Whenever I try to index such an object with the [] operator, it produces segmentation error.
The solver I use is the Wiki http://openfoamwiki.net/index.php/Co...LagrangianFoam, which I adapted for OF1.6 according to the pdf file, and it works fine until the above statement is hit (actually it compiles fine, but when a particle is injected then the above statement is executed, and segmentation error is produced).
Also I would be curious as to what argument cell() returns to the index, as the body of Foam::cell::cell is empty {}? THank you for replies.


All times are GMT -4. The time now is 13:32.