CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] different values between swakExpression & faceSource areaAverage (https://www.cfd-online.com/Forums/openfoam-community-contributions/128299-different-values-between-swakexpression-facesource-areaaverage.html)

Paebin January 8, 2014 12:50

different values between swakExpression & faceSource areaAverage
 
Hello,

I'm trying to calculate an area-weighted averaging of a field (gamma) in a arbitrary plane.

First at all I did it with faceSource, cuttingPlane and the operation areaAverage:

PHP Code:

 plan0_average
     
{
         
type            faceSource;
         
functionObjectLibs ("libfieldFunctionObjects.so");

         
enabled         true;
         
outputControl   timeStep//outputTime timeStep
         
outputInterval  200;

         
// Output to log&file (true) or to file only
         
log             true;

         
// Output field values as well
         
valueOutput     false;  //true;

         // Type of source: patch/faceZone/sampledSurface
         
source          sampledSurface;

         
sampledSurfaceDict
         
{
                 
type cuttingPlane;
                 
planeType           pointAndNormal;
                 
pointAndNormalDict
                 
{
                         
basePoint       (0 0 0);
                         
normalVector    (1 0 0);
                 }
                 
source cells// sample cells or boundaryFaces
                 
interpolate true;
         }

         
// Operation: areaAverage/sum/weightedAverage ...
         
operation       areaAverage;

         
fields          (gamma);
     } 

It seemed to work. But I also do other post-processing calculations by using the swakExpression library, and the output text file look better for me than the faceSource's one. So I decided to also calculate the area average by using a swakExpression instead of faceSource.

I'm using this code:

PHP Code:

 Test_plan0_average
     
{
         
type            swakExpression;

         
outputControlMode   timestep//outputTime timestep
         
outputInterval  200;

         
expression "gamma*area()/sum(area())"// momentum Flux [N]

         
valueType surface;
         
surfaceName plan01;
         
surface
             
{
                 
type plane;
                 
basePoint   (0 0 0);
                 
normalVector     (1 0 0);
                 
interpolate     true;
             }

         
// Operation: sumMag/min/max/weightedAverage/average/sum
         
accumulations       (sum);
verbose true;
     } 

For me the result should be the same than previously but it is not! Here is a comparison:

http://img32.imageshack.us/img32/9551/v0rn.jpg


Someone can explain me what is the problem with my swakExpression ? Or maybe the problem comes from faceSource ??

Best regards,
Fabien.

gschaider January 8, 2014 14:03

Quote:

Originally Posted by Paebin (Post 469172)
Hello,

I'm trying to calculate an area-weighted averaging of a field (gamma) in a arbitrary plane.

First at all I did it with faceSource, cuttingPlane and the operation areaAverage:

PHP Code:

 plan0_average
     
{
         
type            faceSource;
         
functionObjectLibs ("libfieldFunctionObjects.so");

         
enabled         true;
         
outputControl   timeStep//outputTime timeStep
         
outputInterval  200;

         
// Output to log&file (true) or to file only
         
log             true;

         
// Output field values as well
         
valueOutput     false;  //true;

         // Type of source: patch/faceZone/sampledSurface
         
source          sampledSurface;

         
sampledSurfaceDict
         
{
                 
type cuttingPlane;
                 
planeType           pointAndNormal;
                 
pointAndNormalDict
                 
{
                         
basePoint       (0 0 0);
                         
normalVector    (1 0 0);
                 }
                 
source cells// sample cells or boundaryFaces
                 
interpolate true;
         }

         
// Operation: areaAverage/sum/weightedAverage ...
         
operation       areaAverage;

         
fields          (gamma);
     } 

It seemed to work. But I also do other post-processing calculations by using the swakExpression library, and the output text file look better for me than the faceSource's one. So I decided to also calculate the area average by using a swakExpression instead of faceSource.

I'm using this code:

PHP Code:

 Test_plan0_average
     
{
         
type            swakExpression;

         
outputControlMode   timestep//outputTime timestep
         
outputInterval  200;

         
expression "gamma*area()/sum(area())"// momentum Flux [N]

         
valueType surface;
         
surfaceName plan01;
         
surface
             
{
                 
type plane;
                 
basePoint   (0 0 0);
                 
normalVector     (1 0 0);
                 
interpolate     true;
             }

         
// Operation: sumMag/min/max/weightedAverage/average/sum
         
accumulations       (sum);
verbose true;
     } 

For me the result should be the same than previously but it is not! Here is a comparison:

http://img32.imageshack.us/img32/9551/v0rn.jpg


Someone can explain me what is the problem with my swakExpression ? Or maybe the problem comes from faceSource ??

Best regards,
Fabien.

The swak-Expression looks OK with me.

This sounds completely stupid but could you please try the same surface-type (cuttingPlane) with swak (I've seen differences in the results in the past with plane vs cuttingPlane). Also try "area()" and see if the total area of the plane is correct (you should know that from your geometry).

If the problem persists: which swak-version? Which OF-version?

Paebin January 9, 2014 05:40

Thanks for your help gschaider!

Quote:

Originally Posted by gschaider (Post 469177)
This sounds completely stupid but could you please try the same surface-type (cuttingPlane) with swak (I've seen differences in the results in the past with plane vs cuttingPlane).

I tried with my swakExpression but with a cuttingPlane as you said, and the result is different from the other two!

http://img13.imageshack.us/img13/9515/1awl.jpg

Quote:

Originally Posted by gschaider (Post 469177)
Also try "area()" and see if the total area of the plane is correct (you should know that from your geometry).

the total area of the three methods is the same, and it corresponds to reality. :)

Quote:

Originally Posted by gschaider (Post 469177)
If the problem persists: which swak-version? Which OF-version?

I'm using openFoam 2.2.2 and swak4Foam-OF22X, ubuntu

Best regards,
Fabien

Paebin January 9, 2014 09:56

I think the problem of the configuration swak+cuttingPlane comes from the interpolate function. All the previous results used "interpolate true;". I changed it to "interpolate false;", then faceSource and swak with cuttingPlane give me (almost) the same result:

http://imageshack.us/a/img542/2724/oeei.jpg

I tried also to used "plane" with faceSource and it gives the same results that "plane" with swak. So the main difference is between plane and cutting plane. Also, there is a difference on the face number: 31 for plane and much more for cuttingPlane (129). In reality I have 16 cells. So I think the plane's average result should be the correct answer.

Someone can explain me what is the difference between cuttingPlane and Plane ??

best regards,
Fabien.

gschaider January 9, 2014 16:27

Quote:

Originally Posted by Paebin (Post 469286)
I think the problem of the configuration swak+cuttingPlane comes from the interpolate function. All the previous results used "interpolate true;". I changed it to "interpolate false;", then faceSource and swak with cuttingPlane give me (almost) the same result:

http://imageshack.us/a/img542/2724/oeei.jpg

I tried also to used "plane" with faceSource and it gives the same results that "plane" with swak. So the main difference is between plane and cutting plane. Also, there is a difference on the face number: 31 for plane and much more for cuttingPlane (129). In reality I have 16 cells. So I think the plane's average result should be the correct answer.

Someone can explain me what is the difference between cuttingPlane and Plane ??

Not sure. I'd have to look at the source myself

Paebin January 13, 2014 03:05

Ok thanks.

So plane with faceSource or swak gives the same results when I don't use interpolation. If I active interpolation, I get a different result than previously (why not!), but the problem is that the result is different between faceSource and swak...

I don't know where is the truth! :(

gschaider January 22, 2014 19:39

Quote:

Originally Posted by Paebin (Post 469738)
Ok thanks.

So plane with faceSource or swak gives the same results when I don't use interpolation. If I active interpolation, I get a different result than previously (why not!), but the problem is that the result is different between faceSource and swak...

I don't know where is the truth! :(

To further complicate things: have you tried faceSource with plane (I've only seen cuttingPlane).

One possibility to check the "truth" is to calculate an expression whose value depends on the surface but whose value you already know. For instance the sum of "area()" (that should be the total area of the plane) - that would be independent of the interpolation.

Frenk_T December 23, 2015 11:29

Quote:

Originally Posted by Paebin (Post 469738)
Ok thanks.

So plane with faceSource or swak gives the same results when I don't use interpolation. If I active interpolation, I get a different result than previously (why not!), but the problem is that the result is different between faceSource and swak...

I don't know where is the truth! :(

I came across the same problem. Swak and faceSource give the same value if interpolate is set to false. However this value is different for cuttingPlane and plane. In my case the value given by cuttingPlane is closer to Paraview, so I assume that it's the correct one. Anyone has faced the same problem or knows more?


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