|
[Sponsors] |
May 19, 2008, 14:36 |
I posted the question some tim
|
#1 |
Member
Heng Xiao
Join Date: Mar 2009
Location: Zurich, Switzerland
Posts: 58
Rep Power: 17 |
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 |
|
May 20, 2008, 05:16 |
Hi Heng
Have a look at how
|
#2 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
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. |
|
May 21, 2008, 18:32 |
Hi Niels,
Thank you for th
|
#3 |
Member
Heng Xiao
Join Date: Mar 2009
Location: Zurich, Switzerland
Posts: 58
Rep Power: 17 |
Hi Niels,
Thank you for the information! Best, Heng |
|
May 21, 2008, 18:57 |
Hi Niels,
Following the su
|
#4 |
Member
Heng Xiao
Join Date: Mar 2009
Location: Zurich, Switzerland
Posts: 58
Rep Power: 17 |
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) ) ------------------------------ |
|
May 21, 2008, 19:06 |
Hi Niels,
Another aside qu
|
#5 |
Member
Heng Xiao
Join Date: Mar 2009
Location: Zurich, Switzerland
Posts: 58
Rep Power: 17 |
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() ); |
|
May 22, 2008, 04:30 |
Hi Heng
@03:57-question:
|
#6 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,902
Rep Power: 37 |
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. |
|
June 18, 2008, 13:09 |
hi
i face the same problem wi
|
#7 |
Senior Member
|
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 |
|
June 26, 2008, 07:29 |
hi,
i have an already solved
|
#8 |
Member
davey david
Join Date: Mar 2009
Posts: 54
Rep Power: 17 |
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 |
|
June 26, 2008, 09:21 |
Make a scalarIOField instead a
|
#9 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33 |
Make a scalarIOField instead and... enjoy!
Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
July 22, 2010, 04:23 |
|
#10 |
Member
George Pichurov
Join Date: Jul 2010
Posts: 52
Rep Power: 16 |
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. |
|
|
|
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 |