CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Liquid phase volume fraction (http://www.cfd-online.com/Forums/openfoam-solving/58624-liquid-phase-volume-fraction.html)

 sega June 19, 2008 12:48

Hello. Is it possible to ca

Hello.

Is it possible to calculate the liquid phase volume fraction of one of two individual regions containing the same fluid?

I'm simulation a nucleate-boiling case and need some information about the bubble volume after it has detached from the base.

http://www.cfd-online.com/OpenFOAM_D...ges/1/8099.png

Of course I can't use the information from the interFoam Solver because the lpvf given by the solver itself contains both areas ...

Any ideas?

 ngj June 20, 2008 05:10

Hi Sebastian Well it is kin

Hi Sebastian

Well it is kind of a hack, but what about searching along the boundary patch to the left.

You go from the bottom and note when the phase the first time to from air to water, and then note when it goes from water to air. You take the average of these two y-coordinates, and then you have a lower limit for your liquid phase volume. Kind of this:

scalar phaseFraction(0), volumePart(0);
forAll(gamma,gI)
{
if(mesh.C()[gI].component(1) > lowerLimit)
{
volumePart += mesh[gI].V();
phaseFraction += mesh[gI].V() * gamma[gI];
}
}
Info << "Phase fraction: " << phaseFraction / volumePart << endl;

Have a nice weekend,

 sega June 24, 2008 04:48

Hello Niels. Thanks for you

Hello Niels.

I have thought about it some time, but I don't understand, how this can work.

If I have a information containing an average of two y-coordinates I still don't have information about volumes?

And as a matter of fact I'm totally unfamiliar with the code you have posted. Am I guessing right, that I have to put this directly into my interFoam solver?

Maybe some further information:
I'm searching for the volume of the detached (the upper) bubble. Does you code calculate for the upper or lower bubble volume? And what happens if there are more than two?

Greetings.
Sebastian

 sega June 24, 2008 04:57

Just for fun: Here is a video

Just for fun:
Here is a video of the nucleate boiling case

http://therealsega.th.funpic.de/openfoam/nb.mpg

(Static contact angle, constant flow regime)

 ngj June 24, 2008 05:36

Hi Sebastian I can see from

Hi Sebastian

I can see from your movie that your system i somewhat more complex than I thought. But still, the main features can still be used.

lowerLimit:= the average defined as above.
upperLimit:= above the first detached bubble.

1:> scalar phaseFraction(0), volumePart(0);
2:> forAll(gamma,gI)
3:> {
4:> if(mesh.C()[gI].component(1) > lowerLimit && mesh.C()[gI].component(1) < upperLimit)
5:> {
6:> volumePart += mesh[gI].V();
7:> phaseFraction += mesh[gI].V() * gamma[gI];
8:> }
9:> }
10:> Info << "Phase fraction: " << phaseFraction / volumePart << endl;

In line 2 you loop over all elements in gamma.
In line 4 you see if the coordinat of that cells is within the upper and lower limits.
In line 6 the volume of the cell is added to "volumePart" if the cell is within the limits.
In line 7 the volume of air/water is added to phaseFraction. If this is precisely identical to volumePart the phaseFraction / volumePart will become 1.
On the other hand, you will be able to find volume of bubbles by
(1 - phaseFraction / volumeFraction) * volumeFraction.

Just insert is directly into interFoam, it should work as soon as you have upperLimit and lowerLimit.

Nice movie, btw.

/ Niels

 sega June 24, 2008 06:06

Ok, Thanks. I will have a l

Ok, Thanks.

I will have a look into it.

First question: Is it possible to calculate this outside of the interFoam solver?
As a post processing tool?

I want to skip the 4 hours calculation ...

 ngj June 24, 2008 06:49

The question would be yes. Loo

The question would be yes. Look here and be inspired:

~/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/postProcessing

/ Niels

 sega June 25, 2008 11:28

Thanks for your help so far.

Thanks for your help so far.

But there are some severe problems compiling your code.
I have put your code into a C-File from another post-processing tool I used to calculate the barycenter.

I think there are some problems with the dependencies of the C-File.
But I really don't have an idea, which files I need, and which I don't.

Furter there seems to be some wrong coding, because there are several errors with the brackets ( and { respectively } and ) ...

Is it possible, that you have a look over the code.
First of all, this is the error code:

sega@M1530:~/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/postProcessing/liquidPhaseVolu meFraction\$ wmake Making dependency list for source file liquidPhaseVolumeFraction.C
could not open file createFields.H for source file liquidPhaseVolumeFraction.C
SOURCE=liquidPhaseVolumeFraction.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/transportModels -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/transportModels/incompressible/lnInclud e -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/transportModels/interfaceProperties/lnI nclude -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -pthread -c \$SOURCE -o Make/linuxGccDPOpt/liquidPhaseVolumeFraction.o
liquidPhaseVolumeFraction.C:52:29: error: createFields.H: No such file or directory In file included from /home/sega/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude/setInitialDeltaT.H :36,
from liquidPhaseVolumeFraction.C:55:
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude/CourantNo.H: In function 'int main(int, char**)':
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude/CourantNo.H:39: error: 'phi' was not declared in this scope
liquidPhaseVolumeFraction.C:61: error: request for member 'size' in 'gamma', which is of non-class type 'double ()(double)throw ()'
liquidPhaseVolumeFraction.C:63: error: 'lowerLimit' was not declared in this scope
liquidPhaseVolumeFraction.C:64: error: expected `)' before '{' token
liquidPhaseVolumeFraction.C:68: error: expected primary-expression before '}' token
liquidPhaseVolumeFraction.C:68: error: expected `;' before '}' token
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude/readPISOControls.H :3: warning: unused variable 'nCorr'
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude/initContinuityErrs .H:38: warning: unused variable 'cumulativeContErr'
make: *** [Make/linuxGccDPOpt/liquidPhaseVolumeFraction.o] Fehler 1

http://therealsega.funpic.de/openfoa...raction.tar.gz

 ngj June 25, 2008 15:42

1. You have not copy-pasted th

1. You have not copy-pasted the entire expression, i.e. ')'-errors. Thus please check your own work, before you call it "wrong coding".
2. createFields.H is utility-specific, thus is needs to be present in the same folder.
3. You have neither defined upperLimit or lowerLimit.

 sega July 1, 2008 10:03

Hello again. I have looked

Hello again.

I have looked into it another time.
Its still not working due to my poor C++ experience, but I know now how it should be.

I would like to go back to the first message from Niels:
You go from the bottom and note when the phase the first time from air to water, and then note when it goes from water to air. You take the average of these two y-coordinates, and then you have a lower limit for your liquid phase volume

Is it possible to do this automatically?
Or do I have to specify the lower directly inside the code by measuring in any way (e.g. with a ruler and a plot)?

I think this will not work automatically for every timestep. I thought about calculating this for a single timestep I chose. For example any timestep where the bubble is below the upper limit.

How can I tell the tool to just calculate for a singe timestep directory?

 ngj July 2, 2008 05:19

Hi > Is it possible to do t

Hi

> Is it possible to do this automatically?
Yes, indeed, but you will run into problems if the upper bubble is concave and in the inner of the domain extend below the limit defined at the boundary.

> How can I tell the tool to just calculate for a singe timestep directory?
E.g. reconstructPar has a option called -time where you can specify a specific time. Look into that and be inspired.

/ Niels

 sega July 2, 2008 07:03

Ok, I put together some rough

Ok, I put together some rough code.
At least the bracket-errors are solved.

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif liquidPhaseVolumeFraction.C

Leaving the upper and lower limit aside (will get to it later) I get this message when compiling the code:

Making dependency list for source file liquidPhaseVolumeFraction.C
SOURCE=liquidPhaseVolumeFraction.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/transportModels -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/transportModels/incompressible/lnInclude -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/transportModels/interfaceProperties/lnInclude -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -pthread -c \$SOURCE -o Make/linuxGccDPOpt/liquidPhaseVolumeFraction.o
liquidPhaseVolumeFraction.C: In function 'int main(int, char**)':
liquidPhaseVolumeFraction.C:68: error: request for member 'operator[]' is ambiguous
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/dictionary.H:209: error: candidates are: Foam::ITstream& Foam::dictionary::operator[](const Foam::word&) const
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/dictionary.H:209: error: Foam::ITstream& Foam::dictionary::operator[](const Foam::word&) const
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/HashTableI.H:84: error: const T& Foam::HashTable<t,>::operator[](const Key&) const [with T = Foam::regIOobject*, Key = Foam::word, Hash = Foam::string::hash]
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/HashTableI.H:68: error: T& Foam::HashTable<t,>::operator[](const Key&) [with T = Foam::regIOobject*, Key = Foam::word, Hash = Foam::string::hash]
liquidPhaseVolumeFraction.C:69: error: request for member 'operator[]' is ambiguous
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/dictionary.H:209: error: candidates are: Foam::ITstream& Foam::dictionary::operator[](const Foam::word&) const
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/dictionary.H:209: error: Foam::ITstream& Foam::dictionary::operator[](const Foam::word&) const
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/HashTableI.H:84: error: const T& Foam::HashTable<t,>::operator[](const Key&) const [with T = Foam::regIOobject*, Key = Foam::word, Hash = Foam::string::hash]
/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/HashTableI.H:68: error: T& Foam::HashTable<t,>::operator[](const Key&) [with T = Foam::regIOobject*, Key = Foam::word, Hash = Foam::string::hash]
make: *** [Make/linuxGccDPOpt/liquidPhaseVolumeFraction.o] Fehler 1

Whats wrong with this operator[] ?

 ngj July 2, 2008 07:27

Sorry.

/ Niels

 sega July 2, 2008 14:10

Hello. Thank you Niels, the

Hello.

Thank you Niels, the tool is compiling now!

I had a look into the reconstructPar.C file.
Well, I can't get anything useful out of it, sorry.
From my experiences with the parabolic inlet files I have guessed that the input-options (like time in this case) are read from the shell using some kind of
argList::validOptions or argList::validArgs statement. I cant find anything in reconstructPar.C that looks similar.

So, I think I need some further information about how to read a time option from the shell, and how to get the code work only on this special time-directory.

 ngj July 3, 2008 04:48

Well, suggested reconstructPar

Well, suggested reconstructPar because I know you can specify a specific time.
The argList is like the way to go, thus find a utility which allows you to use a specific time. If you call a utility without any options, then you get a list of possible options. I believe that would be the fastest way to find what you are looking for.

/ Niels

 sega July 14, 2008 07:42

Well I'm still stuck with this

Well I'm still stuck with this.

Is there a possibility to do this with ParaView?
Extracting part of the computational domain by upper and lower limits and calculating the phase fraction on this cut?

I have toyed around with the filters but found no satisfying solution ...

 sega July 15, 2008 08:23

Ok, back to the code. I'm s

Ok, back to the code.

I'm still not getting how to read a time option and to make the code work at a specific time directory.

There are so many tools using time options but I just don't know which code snipped is responsible for it.

I thought its about reading from the argList, but none of the tools reads the time option from the argList ...
Some tools do something with runTime or setTime, others use checkTimeOptions.H which is cryptic to me as well.

So, can anybody help?

 ngj July 15, 2008 08:44

Okay Sebastian If you for i

Okay Sebastian

If you for instance take the wallGradU function, to be found in:

remove everything from inside the time-loop which is application specific, then you will have a framework in which you will be able to do what you want, e.g. only solving the bubble size for one specific time step.

/ Niels

 sega August 7, 2008 08:25

Ok, I will try this. Is thi

Ok, I will try this.

Is this the time loop?

for (label i=startTime; i<endTime; i++)
{
}

Greetings. S.

 sega August 7, 2008 08:35

So I did copy my stuff into th

So I did copy my stuff into the timeloop and get this

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif lpvf.C

...and some errors about classes and functions:

Making dependency list for source file lpvf.C
SOURCE=lpvf.C ; g++ -m32 -Dlinux -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/transportModels -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/transportModels/incompressible/lnInclude -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/transportModels/interfaceProperties/lnInclude -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/sega/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude -fPIC -pthread -c \$SOURCE -o Make/linuxGccDPOpt/lpvf.o
lpvf.C: In function 'int main(int, char**)':
lpvf.C:68: error: request for member 'size' in 'gamma', which is of non-class type 'double ()(double)throw ()'
lpvf.C:74: error: pointer to a function used in arithmetic
lpvf.C:74: error: invalid operands of types 'const double' and 'double ()(double)' to binary 'operator*'
make: *** [Make/linuxGccDPOpt/lpvf.o] Fehler 1

So, where is the problem now?

All times are GMT -4. The time now is 17:20.