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

[swak4Foam] swakExpressions

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 8, 2012, 18:15
Default swakExpressions
  #1
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Hi All,

First of all thanks to Bernhard Gschaider for swak4Foam (http://openfoamwiki.net/index.php/Contrib/swak4Foam), I am getting into some of the swakExpression stuff to calculate volumetric flow rate across planes. I have been using something like the example:

Code:
    planeAverage
    {
        type swakExpression;
        valueType surface;
        surfaceName middlePlane;
        surface {
            type plane;
            basePoint       (0 0.00125 0);
            normalVector    (0 1 0);
            interpolate false;
        }
        verbose true;
        expression "sum(pos().x*area())/sum(area())";
        accumulations (
            average
        );
    }
    flowThrough
    {
        type swakExpression;
        valueType surface;
        surfaceName middlePlane;
        verbose true;
        expression "U & Sf()";
        accumulations (
            sum
        );
    }

to grab volumetric flow rate and then I will eventually use it for cup-mixing (or mixing-cup?) average (mass flow averaged of a variable) of a system. My question is...is the plane in question a cutting plane or the plane of faced of the cells parallel to the plane I am providing? I ask because I noticed a slight difference between the flowthrough that is stated above and patchMassFlow if I use a simpleFunctionObject on the outlet patch. It could be my mistake on the differences...since I just started messing with this today. Thoughts?

Thanks for your help.
chegdan is offline   Reply With Quote

Old   March 8, 2012, 19:00
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 chegdan View Post
Hi All,

First of all thanks to Bernhard Gschaider for swak4Foam (http://openfoamwiki.net/index.php/Contrib/swak4Foam), I am getting into some of the swakExpression stuff to calculate volumetric flow rate across planes. I have been using something like the example:

Code:
    planeAverage
    {
        type swakExpression;
        valueType surface;
        surfaceName middlePlane;
        surface {
            type plane;
            basePoint       (0 0.00125 0);
            normalVector    (0 1 0);
            interpolate false;
        }
        verbose true;
        expression "sum(pos().x*area())/sum(area())";
        accumulations (
            average
        );
    }
    flowThrough
    {
        type swakExpression;
        valueType surface;
        surfaceName middlePlane;
        verbose true;
        expression "U & Sf()";
        accumulations (
            sum
        );
    }

to grab volumetric flow rate and then I will eventually use it for cup-mixing (or mixing-cup?) average (mass flow averaged of a variable) of a system. My question is...is the plane in question a cutting plane or the plane of faced of the cells parallel to the plane I am providing?
This is really a cutting plane and not aligned to any grid faces.

Therefor sampledSurfaces are computationally expensive and shouldn't be used excessively
Quote:
Originally Posted by chegdan View Post
I ask because I noticed a slight difference between the flowthrough that is stated above and patchMassFlow if I use a simpleFunctionObject on the outlet patch. It could be my mistake on the differences...since I just started messing with this today. Thoughts?
The difference is not your fault: as said above the surface is not aligned with the cell faces AND the values on the surface are not interpolated (for each face of the surface the value of the cell it is in will be used) - as I said above: they need enough CPU-time anyway. BUT: you can switch interpolation on by saying "interpolate on;" (not the ones in your example: one level higher). You'll have to specify an interpolationType as well. With interpolation you SHOULD get slightly better results. But interpolation is only interpolation so you'll be lucky if the results EXACTLY fit the patchMassFlow-results.

If you want a control surface that is aligned with the mesh faces then a faceSet is a better choice (here the mass-flow should be exactly the one going in and out of the simulation ... if the run is converged. For specifying the faceSet you can use the setSet-utility. Either with one of the OF topoSources or the expressionToFace-topoSource that comes with swak (that one picks faces for the faceSet by evaluating a logical expression and taking all faces where the condition is true on one side and false on the other)

For different approaches to control-surfaces have a look at the angledDuct-example that comes with swak
EleCr and arsalan.dryi like this.
gschaider is offline   Reply With Quote

Old   March 9, 2012, 17:06
Default
  #3
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
Thanks for the reply, I believe I just wanted a confirmation that I was thinking correctly and my hunch was correct....and that is what you provided. For others, I will just post the code that I finally come up with. Thanks again.
chegdan is offline   Reply With Quote

Old   November 15, 2013, 17:29
Default
  #4
Member
 
Jace
Join Date: Oct 2012
Posts: 77
Rep Power: 15
zhengzh5 is on a distinguished road
Quote:
Originally Posted by chegdan View Post
Hi All,

First of all thanks to Bernhard Gschaider for swak4Foam (http://openfoamwiki.net/index.php/Contrib/swak4Foam), I am getting into some of the swakExpression stuff to calculate volumetric flow rate across planes. I have been using something like the example:

Code:
    planeAverage
    {
        type swakExpression;
        valueType surface;
        surfaceName middlePlane;
        surface {
            type plane;
            basePoint       (0 0.00125 0);
            normalVector    (0 1 0);
            interpolate false;
        }
        verbose true;
        expression "sum(pos().x*area())/sum(area())";
        accumulations (
            average
        );
    }
    flowThrough
    {
        type swakExpression;
        valueType surface;
        surfaceName middlePlane;
        verbose true;
        expression "U & Sf()";
        accumulations (
            sum
        );
    }

to grab volumetric flow rate and then I will eventually use it for cup-mixing (or mixing-cup?) average (mass flow averaged of a variable) of a system. My question is...is the plane in question a cutting plane or the plane of faced of the cells parallel to the plane I am providing? I ask because I noticed a slight difference between the flowthrough that is stated above and patchMassFlow if I use a simpleFunctionObject on the outlet patch. It could be my mistake on the differences...since I just started messing with this today. Thoughts?

Thanks for your help.
Hi, I'm confused about the planeAverage part. I assume the planeAverage calculates the average area of the cutplane, but why do you need to multiply the x-coordinate (pos().x) of the cell with the area and also what does that area correspond to?

thanks for your help in advance.
zhengzh5 is offline   Reply With Quote

Old   November 18, 2013, 18:28
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 zhengzh5 View Post
Hi, I'm confused about the planeAverage part. I assume the planeAverage calculates the average area of the cutplane, but why do you need to multiply the x-coordinate (pos().x) of the cell with the area and also what does that area correspond to?

thanks for your help in advance.
Nope. He calculates the area-weighted pos().x (probably to get the average position of the plane)
__________________
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

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



All times are GMT -4. The time now is 13:03.