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 calculate liquid volume as the interface moves for interFoam Solver (http://www.cfd-online.com/Forums/openfoam-solving/58044-how-calculate-liquid-volume-interface-moves-interfoam-solver.html)

asaha April 17, 2008 16:01

Hello All, How do I calcula
 
Hello All,

How do I calculate the volume of the liquid phase as the interface moves for a transient interFoam simulation. Help from the forum members will be appreciated.

caw April 18, 2008 04:39

hi, i can give you a code s
 
hi,

i can give you a code snipet, that calculates the total mass for fluid 1. just divide this by rho1.
Even simplier: integrate over gamma field with the comand found below ;-)

regards
Christian


volScalarField rho1gamma
(
IOobject
(
"rho1gamma",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
gamma*rho1,
gamma.boundaryField().types()
);



dimensionedScalar totalMass = fvc::domainIntegrate(rho1gamma);

Info << "Mass of Fluid 1 = " << totalMass.value() << " kg" << endl;

asaha April 18, 2008 23:40

Hello Christian, Thanks a l
 
Hello Christian,

Thanks a lot for the code snippet. I have not written/used code earlier in interFoam. I would appreciate if you can give hint on using this appropriately (0, constant, system - directory)?


Thanks.

holger_marschall April 19, 2008 05:12

Hello Asaha, No, that's not
 
Hello Asaha,

No, that's not part of any case dictionary!

The first snippet (IOobject) you'd have to put into the top-level solver file createFields.h. For the second code snippet I recommend a separate header-file (just create one) and include it at the appropriate place in solver.C. Then recompile (wmake).

Btw, I think it's a good idea to make a custom solver (see User Guide for details).

regards
Holger

caw April 19, 2008 05:20

Hi, you have to build this
 
Hi,

you have to build this into the interFoam solver itself. Simply add it to the source code within the timestep loop at the end of each timestep. Then recomplie interFoam: voila.

Look here:
./OpenFOAM/OpenFOAM-1.4.1/applications/solvers/multiphase/interFoam/interFoam.C

If you run interFoam from now on, it states the information you want after each timestep.

Kind regards
Christian

asaha April 19, 2008 11:11

Hello, Thanks for your advi
 
Hello,

Thanks for your advice and help. I will give this a try and get back.


Thanks again!

asaha April 19, 2008 18:03

Hello Christian and Holger,
 
Hello Christian and Holger,

Thanks for your advice and help. I have followed the steps as below:

(1) Added the code snippet in createFields.H file.

volScalarField rho1gamma
(
IOobject
(
"rho1gamma",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
gamma*rho1,
gamma.boundaryField().types()
);


(2)
Then made a rho1gamma.H file having the line

dimensionedScalar totalMass = fvc::domainIntegrate(rho1gamma);

(3) Added the following lines in interFoam.C file

# include rho1gamma.H
Info << "Mass of Fluid 1 = " << totalMass.value() << " kg" << endl;


(4) recompiled interFoam

Please correct me on the above steps.

Upon testing the recompiled code, in the output I do see Mass of Fluid 1 = 3.2e-08 kg, but this value does not change with time after successive iterations? Pl. advice me if I need to make changes.

Regards,

A A Saha.

holger_marschall April 20, 2008 04:46

Hi, Your setup in the top-l
 
Hi,

Your setup in the top-level solver seems to be all right! Why your question? Should the overall fluid mass change with time in your case?

regards,
Holger

caw April 20, 2008 04:56

Hi, you could put the whole
 
Hi,

you could put the whole code in one header File and include this into your solver, it is simplier but has nothing to do with your question.

If your volume fraction should change in your simulation, you have to use an inlet with gamma = 1, right? Check your boundary conditions.

Regards
Christian

asaha April 20, 2008 11:39

Hello Holger and Christian,
 
Hello Holger and Christian,

The mass which is showing up is the initial fluid mass for gamma = 1 set with setFields at the inlet for capillary driven flow in a channel. As the interface moves I expect this value to increase with time for the transient solution. Please correct me if I am making a mistake.

Is there a alternative, I have simulation for a number of old cases and wish to calculate liquid volume as the interface moves with time, because the new solver can be used for only new cases.
Can paraview or tecplot be used?

Kind regards,

A A Saha

ngj April 20, 2008 16:48

Hi, I admit that I have no
 
Hi,

I admit that I have not understood the geometric field completely yet, but

volScalarField rho1gamma
(
IOobject
(
"rho1gamma",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
gamma*rho1,
gamma.boundaryField().types()
);

initializes rho1gamma with gamma*rho1, but it is not updated using this expression each time step, thus you need to add:

rho1gamma = gamma*rho1;

each time step before the integration - please correct me someone, if I am wrong.

Best regards,

Niels

caw April 21, 2008 01:53

Hi Niels, yes you are right
 
Hi Niels,

yes you are right of course....
(so please ignore the second half of the first sentence in my previous post ;-)) )

This is why i put the whole code in one header file and include it at the and of each timestep.
Then the update works...

Kind regards
Christian

jaswi April 21, 2008 05:32

Hi Saha I wonder if this wi
 
Hi Saha

I wonder if this will solve your purpose:

dimensionedScalar totalLiquidVolume = sum(mesh.V()*gamma);

Info << "Total Liquid Volume, Value: "
<< totalLiquidVolume.value() << ", Dimensions = " << totalLiquidVolume.dimensions() << endl;

just include it into your main solver before


runTime.write();

and recompile your solver.

It will print the current volume at each iteration. Check it first on a single processor because you might need to change sum() with gSum().

Let me know if it works.

Regards
Jaswi

asaha April 21, 2008 07:40

Hello Jaswi, Thank you very
 
Hello Jaswi,

Thank you very much for your code snippet. The code is working. The liquid volume is getting upated with time at each iteration.

Please advice me as, I also have simulation data for a number of old cases and wish to calculate liquid volume as the interface moves with time, because the new solver can be used for only new cases.

Thanks again.

Kind regards,

A A Saha.

jaswi April 21, 2008 10:11

Hi Saha yes it can be done.
 
Hi Saha

yes it can be done. just take a look at the utilities folder. in particular take a look at the postprocessing/velocityfield folder. There you will find a number of post processing utilities.

you can adapt any one of those for your own purpose. just take the basic framework and modify it. i suggest magU. study it and then let me know if you have questions.

Regards
Jaswi

asaha April 26, 2008 02:56

Hello Jaswi, I have followe
 
Hello Jaswi,

I have followed the thread http://www.cfd-online.com/cgi-bin/Op...how.cgi?1/7401 and got the required information to resolve my issue.

I have a question regarding the max. and min. gamma values obtained during iterations. Sometimes I get the results something like given below:

Liquid phase volume fraction = 0.130194 Min(gamma) = -7.81823e-47 Max(gamma) = 1.0004

The min. value is less than 0 and max. value is more than 1.

As I understand gamma should be within 0 and 1 for boundedness. Pl. correct me if I may be missing something critical here.

Is something wrong with the simulation results or the values obtained are acceptable for interFoam calculation.

Pl. advise me on this.

Best regards,


A A Saha.

jaswi April 26, 2008 20:00

Hi Saha if one carefully ta
 
Hi Saha

if one carefully takes a look at the min and max values for gamma then one can conclude that
Min(gamma) = -7.81823e-47 implies gamma approximately equals 0 and regarding the Max(gamma) = 1.0004, as far as my understanding goes it can be because of several reasons:

1) set higher value for write precision in the controlDict to reduce rounding off error.

2)you are usng multigird for the pressure equation

3)this might be an intermediate iteration and when you let the solution converge you will get gamma=1.0

hope that helps and settle the doubt a bit :-)

With Best Regards
Jaswi

asaha April 27, 2008 09:39

Hello Jaswi, Thanks for you
 
Hello Jaswi,

Thanks for your post. Yes the pressure equation uses multigrid. The log output for the converged solution is after each time step, so the solution may be converged. I will try to set higher value for write precision in the controlDict and see if this helps.

Is there a specific documentation which clearly mentions how the interface capturing algorithm is implemented in interFoam. Pl. point me to these, if any. I have read HrvojeJasakPhD.pdf, OnnoUbbinkPhD.pdf, HenrikRuschePhD2002.pdf.
I may be missing some other important documentation other than these.

With best regards,

A A Saha.

jaswi April 28, 2008 04:13

Hi Saha These are the texts
 
Hi Saha

These are the texts which I have referred as well.

You can also google search with following combination

1) "multiphase flows" AND VOF filetype:pdf
2) "multiphase flows" AND "ishii" filetype:pdf

and you will come across some PhD and Master's works . Some of these documents have the basic formulation. Also look into David Hill PhD work. It has the twoPhaseEulerFoam formulation explained. For a very detailed description you can also look into the book

Computational Fluid Dynamics with Moving Boundaries by Wei Shyy, H. S. Udaykumar, und Madhukar M. Rao

I will keep you posted if I find any more material

With Best Regards
Jaswi

asaha April 28, 2008 16:59

Hello Jaswi, Thanks for the
 
Hello Jaswi,

Thanks for the information on documentation of interFoam.


With best regards,

A A Saha.


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