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. |
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; |
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. |
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 |
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 |
Hello,
Thanks for your advi
Hello,
Thanks for your advice and help. I will give this a try and get back. Thanks again! |
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. |
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 |
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 |
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 |
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 |
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 |
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 |
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. |
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 |
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. |
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 |
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. |
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 |
Hello Jaswi,
Thanks for the
Hello Jaswi,
Thanks for the information on documentation of interFoam. With best regards, A A Saha. |
Hello All,
New question: do
Hello All,
New question: does anyone know a code snippet to perform the following task in interFoam-like solvers: - consider a basin with water (and air) with a floating body in it. Now I want to calculate the area of the waterline of the floating body. In other words: the area of the hole in the interface which is made by the floating object. I am considering something like: the still surface is oriented along the X-Y plane. Then sum over all faces of the body patch. If gamma at a face is between 0 and 1, take Y value and multiply with projected cell length in X direction. Repeat for all patch faces. However I think this won't work because with this formulation the interface is not very sharp. Any better ideas? Thanks in advance and best regards, Mark |
Hi Mark
This is coming from
Hi Mark
This is coming from the top of my head, so it is written in pseudo-code, where all values are referring to the hull-patch: missingArea = - gammaPatch * (patch.Sf() & vector(0,0,1)); The thing is, that taking the vertical projection of all faces on the patch should do the trick. If you have a bulb, then the direction of Sf() should remove the opposite contributions. Of course this is assuming that your floating body is not leaking, i.e. having a hole below the water line. Funny little question, it kept bouncing in my head untill I came up with an ideahttp://www.cfd-online.com/OpenFOAM_D...part/happy.gif Best regards, Niels |
N.B.: As long as the water sur
N.B.: As long as the water surface is horizontal this will give something which is correct, but as soon you start getting undulations it will be incorrect, but of course it depends on the physical environment (size of undulations), and to what degree you can accept inaccurate estimates of the area, and the slope of the hull at the interface, as it will not affect the result as long as the hull is vertical.
/Niels |
Hi Mark
Please read my NB c
Hi Mark
Please read my NB carefully, as I write "As long as the water surface is horizontal this will give something which is correct". The trouble arises when you are have, say waves along the side of the ship, and you have to define some average horizontal intersection. Then this procedure might not give the correct result. But as long as the water surface is _horizontal_ then the result must be correct. But it looks reasonable what you are doing, and without giving to too many thoughts your approachs seems to give the average horizontal intersection irrespectively of the sea state. Best regards, Niels |
Niels, you are right: you ment
Niels, you are right: you mentioned the issue yourself already.
Brgds, Mark |
Is it too late to ask some questions about interFoam revision?
I am trying to revise the incompressibleTwoPhaseMixture codes for interFoam solver. I want to put the rho1 (dimensionedScalar) to rho3 (volScalarField), the code is shown in Code:
rho3_ HTML Code:
incompressibleTwoPhaseMixture/twoPhaseMixture.C:137: error: member initializer expression list treated as compound expression Thank you very much. chiven |
All times are GMT -4. The time now is 14:00. |