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

[swak4Foam] Massflow Conservation Error through faceSet using swakExpression

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 28, 2014, 15:30
Default Massflow Conservation Error through faceSet using swakExpression
  #1
New Member
 
Luke Weaver
Join Date: Apr 2013
Posts: 4
Rep Power: 13
lukeweaver is on a distinguished road
I'm trying to use an arbitrary "box" to calculate the flux around an actuator disc (reduced-order wind turbine model). However, the calculation for massflow over each surface is not being conserved.

The domain is a rectangular box with axial flow over a plane. The solver is simpleFoam.

The interior box is 80 x 160 x 160 m, and the surfaces are selected using the topoSet with slave cells and faceset as follows:

Code:
{
        name    north1SlaveCells;
        type    cellSet;
        action  new;
        source expressionToCell;
        sourceInfo
        {
            expression "(pos().x<=60 && pos().y>=20 && pos().y<=180 && pos().z>=20 && pos().z<=180)";
        }
}
{
        name    north1;
        type    faceSet;
        action  new;
        source  expressionToFace;
        sourceInfo
        {
            expression "(pos().x<=60 && pos().y>=20 && pos().y<=180 && pos().z>=20 && pos().z<=180)";
        }
}
This is done for all six sides (top, bottom,south,east,west). Here's three of the faceSets shown in paraView.

faceSet.jpg

Imagine the box fitting inside these three with the other three faceSets filling in the open space.

In the controlDict, I calculate the massflow:

Code:
PhiNorth1
        {
                type swakExpression;
                valueType faceSet;
                variables "direction=vector(0,1,0);dir=direction/mag(direction);";
                setName north1;
                //expression "U & Sf()";
                //expression "phi * flip()";
                expression "(U & direction) * area()";
                autoInterpolate true;
                accumulations (
                        sum
                        min //just for reference
                        max //just for reference
                );
                outputControlMode timeStep;
                outputInterval 10;
                verbose true;
        }
I used the swak tutorial angledDuctImplicitTransient files to build my topoSetDict and controlDict files.

I calculated the mass flow on each faceSet, and summing them should give Phi_In - Phi_Out = 0. After summing up the phi values on all faceSets, the values were Phi_In = 203,860 and sumPhi_Out 206,270, for a total difference of -2410.7 kg/s.

Any help/tips/explanations for this error?

EDIT: For the upstream and downstream faces, I use the U & Sf(). The phi*flip() condition didn't seem to work.
lukeweaver is offline   Reply With Quote

Old   July 28, 2014, 18:34
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 lukeweaver View Post
I'm trying to use an arbitrary "box" to calculate the flux around an actuator disc (reduced-order wind turbine model). However, the calculation for massflow over each surface is not being conserved.

The domain is a rectangular box with axial flow over a plane. The solver is simpleFoam.

The interior box is 80 x 160 x 160 m, and the surfaces are selected using the topoSet with slave cells and faceset as follows:

Code:
{
        name    north1SlaveCells;
        type    cellSet;
        action  new;
        source expressionToCell;
        sourceInfo
        {
            expression "(pos().x<=60 && pos().y>=20 && pos().y<=180 && pos().z>=20 && pos().z<=180)";
        }
}
{
        name    north1;
        type    faceSet;
        action  new;
        source  expressionToFace;
        sourceInfo
        {
            expression "(pos().x<=60 && pos().y>=20 && pos().y<=180 && pos().z>=20 && pos().z<=180)";
        }
}
This is done for all six sides (top, bottom,south,east,west). Here's three of the faceSets shown in paraView.

Attachment 32645

Imagine the box fitting inside these three with the other three faceSets filling in the open space.

In the controlDict, I calculate the massflow:

Code:
PhiNorth1
        {
                type swakExpression;
                valueType faceSet;
                variables "direction=vector(0,1,0);dir=direction/mag(direction);";
                setName north1;
                //expression "U & Sf()";
                //expression "phi * flip()";
                expression "(U & direction) * area()";
                autoInterpolate true;
                accumulations (
                        sum
                        min //just for reference
                        max //just for reference
                );
                outputControlMode timeStep;
                outputInterval 10;
                verbose true;
        }
I used the swak tutorial angledDuctImplicitTransient files to build my topoSetDict and controlDict files.

I calculated the mass flow on each faceSet, and summing them should give Phi_In - Phi_Out = 0. After summing up the phi values on all faceSets, the values were Phi_In = 203,860 and sumPhi_Out 206,270, for a total difference of -2410.7 kg/s.

Any help/tips/explanations for this error?

EDIT: For the upstream and downstream faces, I use the U & Sf(). The phi*flip() condition didn't seem to work.
My guess is that you're counting flows that are not perpendicular to the boundary. If your north1 is the red faceSet in your picture then there is one large patch for which your approach would work but several small ones where for instance a velocity (1 0.1 0.5) would yield a contribution "0.1*area()" although either "1*area()" or "0.5*area()" (depending on the side) would be appropriate
__________________
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   July 29, 2014, 13:13
Default
  #3
New Member
 
Luke Weaver
Join Date: Apr 2013
Posts: 4
Rep Power: 13
lukeweaver is on a distinguished road
Bernard, thanks for the reply. It turned out that was the issue. I fixed it by using (U & dir) * (Sf() & dir), which gave the correct mass flow from each side (confirmed using Paraview calculators). Now for another question: can you think of a reason that phi * flip() doesn't work?
lukeweaver is offline   Reply With Quote

Old   July 29, 2014, 18:28
Default
  #4
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 lukeweaver View Post
Bernard, thanks for the reply. It turned out that was the issue. I fixed it by using (U & dir) * (Sf() & dir), which gave the correct mass flow from each side (confirmed using Paraview calculators). Now for another question: can you think of a reason that phi * flip() doesn't work?
No idea.

Check how many faces are flipped by evaluating "flip()" with accumulations "min", "max" and "average"
__________________
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   August 1, 2014, 16:01
Default
  #5
New Member
 
Luke Weaver
Join Date: Apr 2013
Posts: 4
Rep Power: 13
lukeweaver is on a distinguished road
I'm now running into issues with different mesh configurations. When the cell size is something like (4.0 2.0 2.0), the massflow conservation calculation is fine. However, when the cell size isn't an integer, like (4.1667 2.6667 2.6667) or something similar, I'm getting some weird results in the massflow and area calculations. The attached image shows the faceSets that have misplaced cell faces.

error_faceset.jpg

It seems that this is an issue of the faceSet boundaries that are defined in the topoSetDict not landing evenly on the cell boundaries.

So,
a) is there a way to change the topoSetDict so that the faceSet moves until it can read the faces evenly, and/or

b) is there a way to manipulate the swakExpression so that the cell irregularities don't affect the massflow calculations?
lukeweaver is offline   Reply With Quote

Old   August 4, 2014, 07:33
Default
  #6
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 lukeweaver View Post
I'm now running into issues with different mesh configurations. When the cell size is something like (4.0 2.0 2.0), the massflow conservation calculation is fine. However, when the cell size isn't an integer, like (4.1667 2.6667 2.6667) or something similar, I'm getting some weird results in the massflow and area calculations. The attached image shows the faceSets that have misplaced cell faces.

Attachment 32778

It seems that this is an issue of the faceSet boundaries that are defined in the topoSetDict not landing evenly on the cell boundaries.

So,
a) is there a way to change the topoSetDict so that the faceSet moves until it can read the faces evenly, and/or

b) is there a way to manipulate the swakExpression so that the cell irregularities don't affect the massflow calculations?
No idea what exactly happens but your "Lego-mesh" looks like a problem with the numeric comparison (if a number "looks" like 60 it may be something slightly different and 60==60 will fail). And as a consequence (this is a speculation) your face-zone and the slave-cell-zone may be inconsistent.

One way to be sure that they are consistent is to first create the cell-zone and instead of duplicating the rather complicated logical expression use it to create the face-zone with the simple expression "set(mySlaveZone)" (set is true if a cell belongs to the cellSet)
__________________
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

Tags
faceset, massflow, swak, toposet


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
Problem with massflow BC at inlet MrNavierStokes CFX 3 November 7, 2016 03:55
How to use "translation" in solidBodyMotionFunction in OpenFOAM rupesh_w OpenFOAM Running, Solving & CFD 5 August 16, 2016 05:27
Massflow rate at inlet and outlet different | conservation of mass manoj_nav OpenFOAM Verification & Validation 0 March 22, 2016 01:07
Massflow rate at inlet and outlet different | conservation of mass manoj_nav OpenFOAM Post-Processing 0 March 18, 2016 04:26
MassFlow Function? Absolute MassFlow? Failure in Caclulation eRzBeNgEl CFX 0 May 5, 2011 10:46


All times are GMT -4. The time now is 15:21.