CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   swak4Foam and swakExpressions (https://www.cfd-online.com/Forums/openfoam-solving/98359-swak4foam-swakexpressions.html)

 chegdan March 8, 2012 19:15

swak4Foam and swakExpressions

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?

 gschaider March 8, 2012 20:00

Quote:
 Originally Posted by chegdan (Post 348449) 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 (Post 348449) 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

 chegdan March 9, 2012 18:06

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.

 zhengzh5 November 15, 2013 18:29

Quote:
 Originally Posted by chegdan (Post 348449) 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?