CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   How to compute liquid volume of the NOT whole domain (https://www.cfd-online.com/Forums/openfoam-post-processing/61380-how-compute-liquid-volume-not-whole-domain.html)

 snak March 24, 2008 23:17

Hi, I'd like to compute

Hi,

I'd like to compute the liquid volume left in a restricted domain after an interFoam simulation. I'd like to know the liquid volume in the region of z < 1, for instance.

I have found the thread "How to compute total liquid volume of the whole domain?" related to my question.
http://www.cfd-online.com/OpenFOAM_D...tml?1184365098
The source code in the thread is quite impressive. However, I don't know how to limit the region with sum() function.

Would you please give some advice or drop a hint to me?

 jaswi March 25, 2008 15:05

Hi You can iterate over the

Hi

You can iterate over the cells in the domain while checking if cellcentre.z() < 1.0 and if the condition satisfies then add the liquid in that cell to your running sum.

hope that helps

Regards
Jaswi

 snak March 27, 2008 23:53

Hi Jaswi Thank you very muc

Hi Jaswi

I'm gonna try to write short code, though I have to learn a bit more about OpenFOAM source code.

Thanks,
snakagawa

 snak June 24, 2008 23:19

Hi, I added the following s

Hi,

I added the following short code to calculate liquid volume in the specified region.

----------------
Info << " Liquid (whole domain): " << sum(mesh.V()*gamma) << endl;

sumVol = 0;
forAll(mesh.cells(),cellI)
{
if( mesh.C()[cellI].component(0) >= validXmin
& mesh.C()[cellI].component(0) <= validXmax
& mesh.C()[cellI].component(1) >= validYmin
& mesh.C()[cellI].component(1) <= validYmax
& mesh.C()[cellI].component(2) >= validZmin
& mesh.C()[cellI].component(2) <= validZmax )
{sumVol = sumVol + mesh.V()[cellI]*gamma[cellI]; }
}
Info << " Liquid in specified region: " << sumVol << endl;
Info << endl;
----------------

It works fine for a single processor calculation.

With multi-processors, however, the calculated liquid volume in the specified region is not correct. Liquid volume in whole domain is correct. I think that my code have some problem in handling the coordinates in decomposed field.

snakagawa

 gschaider June 25, 2008 07:34

A reduce(sumVol,plusOp

A
reduce(sumVol,plusOp<scalar>());
before the Info might solve that. Have a look elsewhere what it actually does.

Bernhard

 All times are GMT -4. The time now is 06:43.