CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] different values between swakExpression & faceSource areaAverage

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 8, 2014, 12:50
Default different values between swakExpression & faceSource areaAverage
  #1
New Member
 
Fabien DOS SANTOS
Join Date: Oct 2009
Location: Nevers, FRANCE
Posts: 8
Rep Power: 16
Paebin is on a distinguished road
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:




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

Best regards,
Fabien.
Paebin is offline   Reply With Quote

Old   January 8, 2014, 14:03
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Paebin View Post
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:




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?
__________________
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
gschaider is offline   Reply With Quote

Old   January 9, 2014, 05:40
Default
  #3
New Member
 
Fabien DOS SANTOS
Join Date: Oct 2009
Location: Nevers, FRANCE
Posts: 8
Rep Power: 16
Paebin is on a distinguished road
Thanks for your help gschaider!

Quote:
Originally Posted by gschaider View Post
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!



Quote:
Originally Posted by gschaider View Post
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 View Post
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 is offline   Reply With Quote

Old   January 9, 2014, 09:56
Default
  #4
New Member
 
Fabien DOS SANTOS
Join Date: Oct 2009
Location: Nevers, FRANCE
Posts: 8
Rep Power: 16
Paebin is on a distinguished road
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:



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.
Paebin is offline   Reply With Quote

Old   January 9, 2014, 16:27
Default
  #5
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Paebin View Post
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:



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
__________________
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
gschaider is offline   Reply With Quote

Old   January 13, 2014, 03:05
Default
  #6
New Member
 
Fabien DOS SANTOS
Join Date: Oct 2009
Location: Nevers, FRANCE
Posts: 8
Rep Power: 16
Paebin is on a distinguished road
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!
Paebin is offline   Reply With Quote

Old   January 22, 2014, 19:39
Default
  #7
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Paebin View Post
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.
__________________
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
gschaider is offline   Reply With Quote

Old   December 23, 2015, 11:29
Default
  #8
New Member
 
Join Date: Sep 2015
Location: Germany
Posts: 11
Rep Power: 10
Frenk_T is on a distinguished road
Quote:
Originally Posted by Paebin View Post
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?
Frenk_T is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TimeVaryingMappedFixedValue irishdave OpenFOAM Running, Solving & CFD 32 June 16, 2021 06:55
using chemkin JMDag2004 OpenFOAM Pre-Processing 2 March 8, 2016 22:38
Setting patch field values equal to internal field values leroyv OpenFOAM Programming & Development 1 October 21, 2014 15:49
Loading Cell Values in Tecplot P1361 OpenFOAM Post-Processing 3 September 16, 2014 04:02
Plotting raw data values Wilesco Siemens 0 January 5, 2006 05:34


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