simpleSwakFunctionObjects
Hello,
I want to compute the volume and position of a rising bubble using swak4Foam. The isosurface that computes the surface area works fine but the volume and position keeps giving me issues. Kindly look at the highlighted portion to help correct it. Thanks. functions ( createInterface { type createSampledSurface; outputControl timeStep; outputInterval 1; surfaceName interface; surface { type isoSurface; isoField alpha1; isoValue 0.5; interpolate true; } surface { type swakExpression; valueType surface; surfaceName interface; verbose true; expression "area()"; accumulations (sum); volume { type swakExpression; valueType surface; // > (I have doubts here) surfaceName interface; // > (I have doubts here too) verbose true; expression "(1alpha1)*vol()"; accumulations (sum); } position { type swakExpression; expression ( "y{internalField} = sum(pos().y*vol()*(1alpha1)*rho2)/sum(vol()*(1alpha1)*rho2);" ); accumulations (average); verbose true; } ); 
Quote:
Quote:
Quote:
 general parameters missing  best use a valueType internalField with an expression "(1alpha1)*vol()*pos().y/sum((1alpha1)*vol())" and an accumulation sum (this assumes that there is only one bubble)  added note to above "average" is a pure arithmetic average of the values. It doesn't take cell sizes into account. Most of the time you won't want that for physical values. Do volume weighted average like above instead  I'm not sure whether rho1 and rho2 are stored in memory as fields If you want to use the surface you can calculate the average position of that with "area()*pos().y/sum(area())" (this value will differ for nonspherical bubbles from the above) 
Thanks Bernard. It worked (without) rho2 just as you said.

Bug with simpleSwakFunctionObjects
Hello Bernard,
I have used simpleSwakFunctionObjects to compute instanteneous position, surface area and volume of single bubble in stagnant liquid without any issue. However, when I have the liquid flowing upward with a certain velocity, I start getting weird numbers. I know these because simpleSwaFunctionObjects gives a negative bubble volume when in essence the bubble has not even collapsed when I view it in paraFoam. I also compared the bubble position values from simpleSwaFunctionObjects to an approximate value from paraFoam and the numbers were way off. I initially thought it was my solver but I get same effect even when I use the default interDyMFoam solver. Note that this only happens when I have bulk liquid velocity/turbulence. Is there was way I could correct this? Kindly find how I compute the values in the controlDict file below. Thank you. ........ libs ( "libOpenFOAM.so" // keeps paraFoam happy "libincompressibleTransportModels.so" "libtwoPhaseInterfaceProperties.so" "libinterfaceProperties.so" "libsimpleSwakFunctionObjects.so" "libswakFunctionObjects.so" ); functions ( createInterface { type createSampledSurface; outputControl timeStep; outputInterval 1; surfaceName interface; surface { type isoSurface; isoField alpha1; isoValue 0.5; interpolate true; } } surface { type swakExpression; valueType surface; surfaceName interface; verbose true; expression "area()"; accumulations (sum); } volume { type swakExpression; valueType internalField; verbose true; expression "(1alpha1)*vol()"; accumulations (sum); } zposition { type swakExpression; valueType internalField; verbose true; expression "(1alpha1)*vol()*pos().z/sum((1alpha1)*vol())"; accumulations (sum); } ); 
Quote:
Hm. You mentioned interDyMFoam. My first impulse was "ah. A Moving meshproblem". But then I thought all problems that would come from that would result in totally obscure numbers and/or crashes. And how can it get negative? vol() is positive by definition and (1alpha1) should always be above 0 ... if alpha1 stays below 1". Are you sure that alpha1 is below or equal to 1 (that can happen with unfortunate circumstances)? If not please add a swakExpression or volMinMax to check that this is the case. If alpha1 is OK: HOW is it getting negative: all of a sudden or does the value "drift" into negative territory? (I mean: theoretically the volume should stay constant as this is an incompressible solver, right?) 
First of all, I think I did not explain clearly. The volume started out as positive at time zero but becomes negative at about 0.04sec and stayed negative thereafter. interDyMFoam does not solve phase change so the volume is meant to remain constant for the incompressible solver. And indeed, it seems constant when I view it from paraFoam except that simpleSwakFunctionObject gives a false value (negative volume and ridiculously high position).
I don't think it's a problem with alpha because like I said, viewing it from paraFoam shows everything looks fine. I tried the adaptive mesh for the case of bubble in stagnant fluid and simpleSwakFunctionObject worked perfectly except when I have a bulk velocity. volMinMax should not affect the overall output that's why I though it might be an issue with simpleSwakFunctionObject when used with bulk velocity. Note that the stagnant liquid problem was tried with adaptive mesh and simpleSwakFunctionObject worked fine too. Thank you. 
Quote:
Quote:
a) the numbers are wrong b) swak has a problem with the moving mesh and therefor uses the wrong number of data (because for instance it assumes there are 4000 cells in the mesh while it has grown to 4233 cells) Before a) can't be ruled out I can't be bothered to look into b). So please add the following to your case:  a volMinMaxfunctionObject (or a swakExpression with min/maxaccumulations) to check that alpha1 is within [0,1]  a swakExpression that gets min/max for "vol()" (this is a long shot, but I want to rule that out too because that is the other way how the expression can become negative) If these numbers are OK then I'll assume that it is a swakProblem. If you have case that reproduces the problem, that runs in under an hour and which you can make publicly available then I'll have a look at it (private support and larger cases I only do for a special class of people. Here we call them "clients" and send them invoices). Either publish it here or (that is better) open a bug at http://sourceforge.net/apps/mantisbt...l_bug_page.php 
Thanks your your response Bernard.
The alpha1 values and hence volume gradually increases. Here are some of the numbers for the min and max alpha1 values. time min max 1.19904e05 6.05361e34 1 0.005 3.45139e08 1.09748 0.01 3.14859e08 1.32745 0.015 2.81559e08 1.72453 0.02 2.67275e08 2.1412 0.025 2.56677e08 2.55744 0.03 2.47121e08 3.03828 The alpha1 values are definitely wrong and these make all other values wrong. In short, the simulation actually blew up on alpha1:mad: with me noticing early enough. I think I got so used to interpolate volFields in paraFoam that made me not notice the false alpha1. Swak4Foam is not the problem at all. Sorry for taking your time:o. Thanks Now I have to figure how to fix the alpha1. Could it be choice of numerical scheme:confused:? 
Quote:
No idea about what is causing your problem. May I just interest you in two features that might be of interest for you to find what is the problem?  the panicDumpfuntionObject from the simpleFunctionObject automatically stops a run and writes all fields if some field goes outside the "comfort zone" (for instance 0.05 and 1.1 for alpha1). The advantage is that you get a snapshot *before* the values goes haywire and are therefor unusable  the function maxPosition(alpha1) allows you to track where the maximum is happening 
All times are GMT 4. The time now is 02:28. 