
[Sponsors] 
January 24, 2013, 19:11 
simpleSwakFunctionObjects

#1 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 7 
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; } ); 

January 25, 2013, 07:31 

#2  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,013
Rep Power: 43 
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)
__________________
Note: I don't use "Friend"feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request 

January 25, 2013, 13:06 

#3 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 7 
Thanks Bernard. It worked (without) rho2 just as you said.


March 18, 2013, 12:31 
Bug with simpleSwakFunctionObjects

#4 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 7 
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); } ); 

March 18, 2013, 16:07 

#5  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,013
Rep Power: 43 
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?)
__________________
Note: I don't use "Friend"feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request 

March 18, 2013, 19:18 

#6 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 7 
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. Last edited by tayo; March 18, 2013 at 20:01. 

March 19, 2013, 06:58 

#7  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,013
Rep Power: 43 
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
__________________
Note: I don't use "Friend"feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request 

March 19, 2013, 13:30 

#8 
Member
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 7 
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 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. Thanks Now I have to figure how to fix the alpha1. Could it be choice of numerical scheme? 

March 19, 2013, 15:10 

#9  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,013
Rep Power: 43 
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
__________________
Note: I don't use "Friend"feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request 

Thread Tools  
Display Modes  

