CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

How to set up an AUTO_WRITE scalarField

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 19, 2008, 14:36
Default I posted the question some tim
  #1
Member
 
Heng Xiao
Join Date: Mar 2009
Location: Zurich, Switzerland
Posts: 58
Rep Power: 17
xiao is on a distinguished road
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
xiao is offline   Reply With Quote

Old   May 20, 2008, 05:16
Default Hi Heng Have a look at how
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   May 21, 2008, 18:32
Default Hi Niels, Thank you for th
  #3
Member
 
Heng Xiao
Join Date: Mar 2009
Location: Zurich, Switzerland
Posts: 58
Rep Power: 17
xiao is on a distinguished road
Hi Niels,

Thank you for the information!

Best,
Heng
xiao is offline   Reply With Quote

Old   May 21, 2008, 18:57
Default Hi Niels, Following the su
  #4
Member
 
Heng Xiao
Join Date: Mar 2009
Location: Zurich, Switzerland
Posts: 58
Rep Power: 17
xiao is on a distinguished road
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 is offline   Reply With Quote

Old   May 21, 2008, 19:06
Default Hi Niels, Another aside qu
  #5
Member
 
Heng Xiao
Join Date: Mar 2009
Location: Zurich, Switzerland
Posts: 58
Rep Power: 17
xiao is on a distinguished road
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()
);
xiao is offline   Reply With Quote

Old   May 22, 2008, 04:30
Default Hi Heng @03:57-question:
  #6
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
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
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   June 18, 2008, 13:09
Default hi i face the same problem wi
  #7
Senior Member
 
wayne.zhang
Join Date: Mar 2009
Location: Shanghai, Shanghai, P.R.China
Posts: 309
Rep Power: 18
waynezw0618 is on a distinguished road
Send a message via MSN to waynezw0618 Send a message via Skype™ to waynezw0618
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
waynezw0618 is offline   Reply With Quote

Old   June 26, 2008, 07:29
Default hi, i have an already solved
  #8
Member
 
davey david
Join Date: Mar 2009
Posts: 54
Rep Power: 17
suredross is on a distinguished road
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
suredross is offline   Reply With Quote

Old   June 26, 2008, 09:21
Default Make a scalarIOField instead a
  #9
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Make a scalarIOField instead and... enjoy!

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   July 22, 2010, 04:23
Default
  #10
Member
 
George Pichurov
Join Date: Jul 2010
Posts: 52
Rep Power: 16
jorkolino is on a distinguished road
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.
jorkolino is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to sum up scalarField wese OpenFOAM Running, Solving & CFD 2 August 19, 2019 18:30
max for scalarField maka OpenFOAM Bugs 9 February 19, 2009 10:43
ScalarField division maka OpenFOAM Pre-Processing 2 August 27, 2007 06:10
[CGNS] Computing a cellcentered scalarField from a vertexcentered scalarField mbeaudoin OpenFOAM Meshing & Mesh Conversion 10 February 22, 2007 08:43
Replacing components in a scalarField grtabor OpenFOAM Running, Solving & CFD 1 February 5, 2007 13:24


All times are GMT -4. The time now is 21:27.