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

Mass Flow Rate Over a Sampled Surface

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 3 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 30, 2012, 12:35
Default Mass Flow Rate Over a Sampled Surface
  #1
Member
 
Brock Lee
Join Date: Sep 2012
Location: Midwest
Posts: 40
Rep Power: 13
GRAUPS is on a distinguished road
Hey guys,

I'm looking to calculate the mass flow rate over a sampled surface. The current function I'm using in controlDict looks like this...

Code:
faceObj1
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         true;	
        outputControl   timeStep;
        // Output to log&file (true) or to file only
        log             true;

        // Output field values as well
        valueOutput     false;

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

         // if patch or faceZone: name of patch or faceZone
         //sourceName      movingWall;

        //// if sampledSurface: dictionary with a sampledSurface
        //// Note: will not sample surface fields.
        sampledSurfaceDict
        {
           // Sampling on triSurface
           type        sampledTriSurfaceMesh;
           surface     int_1.stl;
           source      cells;  // sample cells or boundaryFaces
           interpolate true;
        }

        // Operation: areaAverage/sum/weightedAverage ...
        operation       sum;
	
        fields
        (
            phi
        );
    }
However, this does not provide any output (or errors). When I change the function to use a patch instead of a sampled surface (example: inlet), it is fine and outputs mass flow correctly. I have internal faces defined by stl files that I would like to sample though, and for some reason it does not provide the same behavior.

When changing the function to use a weighted average based on a sample surface and phi, I can get it to produce the following error.

Code:
--> FOAM FATAL ERROR: 
[3] Field phi not found in database
[3] 
[3]     From function Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::getFieldValues(const word&, const bool) const
[3]     in file fieldValues/faceSource/faceSourceTemplates.C at line 120.
It almost seems as if phi is inaccessible to the sampled surface or is not being made available by the solver. However, after the first time step, I see a file phi being outputted. Can anyone tell me what I may be doing wrong? Or suggest a better way to do this, perhaps using swak4foam?

Last edited by GRAUPS; November 30, 2012 at 12:57.
GRAUPS is offline   Reply With Quote

Old   November 30, 2012, 13:29
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 GRAUPS View Post
Hey guys,

I'm looking to calculate the mass flow rate over a sampled surface. The current function I'm using in controlDict looks like this...

Code:
faceObj1
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         true;	
        outputControl   timeStep;
        // Output to log&file (true) or to file only
        log             true;

        // Output field values as well
        valueOutput     false;

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

         // if patch or faceZone: name of patch or faceZone
         //sourceName      movingWall;

        //// if sampledSurface: dictionary with a sampledSurface
        //// Note: will not sample surface fields.
        sampledSurfaceDict
        {
           // Sampling on triSurface
           type        sampledTriSurfaceMesh;
           surface     int_1.stl;
           source      cells;  // sample cells or boundaryFaces
           interpolate true;
        }

        // Operation: areaAverage/sum/weightedAverage ...
        operation       sum;
	
        fields
        (
            phi
        );
    }
However, this does not provide any output (or errors). When I change the function to use a patch instead of a sampled surface (example: inlet), it is fine and outputs mass flow correctly. I have internal faces defined by stl files that I would like to sample though, and for some reason it does not provide the same behavior.

When changing the function to use a weighted average based on a sample surface and phi, I can get it to produce the following error.

Code:
--> FOAM FATAL ERROR: 
[3] Field phi not found in database
[3] 
[3]     From function Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::getFieldValues(const word&, const bool) const
[3]     in file fieldValues/faceSource/faceSourceTemplates.C at line 120.
It almost seems as if phi is inaccessible to the sampled surface or is not being made available by the solver. However, after the first time step, I see a file phi being outputted. Can anyone tell me what I may be doing wrong? Or suggest a better way to do this, perhaps using swak4foam?
Haven't looked at the source, but AFAIK these things only work for volume-fields and phi is a surface-field. I don't think that OF even supports interpolation for surfaceFields. And even if it would you'd not be happy with the result: the definition of phi depends on the orientation of the cell faces and during the interpolation that information would get lost.

That being said: something like this could be done in swak4Foam. But for the reason given above (no interpolation, orientation) using phi won't work. Instead you'd have to "emulate" it with an expression like "rho*U & Sf()" (Sf() is the surface vector of a phase) and sum it
GRAUPS, Kummi and Lennart.H like this.
__________________
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 6, 2012, 15:20
Default
  #3
Member
 
Brock Lee
Join Date: Sep 2012
Location: Midwest
Posts: 40
Rep Power: 13
GRAUPS is on a distinguished road
Bernhard, thank you for your response. This is what I have so far...

Code:
flowBeforeSet
    {
        type swakExpression;
        valueType surface;
        surfaceName internal;	
	surface
	{
	    type sampledTriSurfaceMesh;
	    surface     int_1.stl;
            source      cells;  // sample cells or boundaryFaces
            interpolate false;	    
	}	
        expression "rho*U & Sf()"; 
        accumulations (
            sum
        );
        verbose true;
    }
This outputs mass flow values, however they seem a little off. The example case I'm using is a straight pipe with constant mass Flow in. I'm sampling mass flow at the center of the pipe. Shouldn't the mass flow at the center be the same as the mass flow coming in? I'm getting about a three percent difference between in flow and the sampled flow.

Do you know what could be causing this difference? Does the inclusion of Sf() in the swakExpression mean that only the values normal to the surface are being taken into account? Also, is it possible to interpolate the values being used for the mass flow calculation to perhaps get a more accurate results? When I turn interpolate on it throws an error at me. Thanks!

Last edited by GRAUPS; December 6, 2012 at 15:58.
GRAUPS is offline   Reply With Quote

Old   December 7, 2012, 06:36
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 GRAUPS View Post
Bernhard, thank you for your response. This is what I have so far...

Code:
flowBeforeSet
    {
        type swakExpression;
        valueType surface;
        surfaceName internal;	
	surface
	{
	    type sampledTriSurfaceMesh;
	    surface     int_1.stl;
            source      cells;  // sample cells or boundaryFaces
            interpolate false;	    
	}	
        expression "rho*U & Sf()"; 
        accumulations (
            sum
        );
        verbose true;
    }
This outputs mass flow values, however they seem a little off. The example case I'm using is a straight pipe with constant mass Flow in. I'm sampling mass flow at the center of the pipe. Shouldn't the mass flow at the center be the same as the mass flow coming in? I'm getting about a three percent difference between in flow and the sampled flow.

Do you know what could be causing this difference? Does the inclusion of Sf() in the swakExpression mean that only the values normal to the surface are being taken into account? Also, is it possible to interpolate the values being used for the mass flow calculation to perhaps get a more accurate results? When I turn interpolate on it throws an error at me. Thanks!
Yep. "U&Sf()" is the component in normal direction. But the regular phi is calculated the same way ... and the pressure correction is done for that. So that value should be conservative ... on the faces (if you have for instance a faceZone going through the pipe - just consider the flip()-problematic discussed elsewhere). But for a sampled set you might have interpolation issues ... which depend on the amount of flow that doesn't go perpendicular over your surface and the alignment of the surface to the cell faces. You might want to check the ratio of velocity that doesn't go your way with something like (this is unchecked and assumes that no face has velocity 0) "mag(U-normal()*(U & normal())/mag(U)" and accumulations min/max/average and see whether this might be the problem.
__________________
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 7, 2012, 11:33
Default
  #5
Member
 
Brock Lee
Join Date: Sep 2012
Location: Midwest
Posts: 40
Rep Power: 13
GRAUPS is on a distinguished road
Quote:
Originally Posted by gschaider View Post
You might want to check the ratio of velocity that doesn't go your way with something like (this is unchecked and assumes that no face has velocity 0) "mag(U-normal()*(U & normal())/mag(U)" and accumulations min/max/average and see whether this might be the problem.
Ok, I added the check for the ratio of velocity that is not normal... here is the output after a converged solution has been reached...

Code:
Expression Ratio_not_Normal :  min=0.8991376591 max=0.96846234 average=0.9064741362
Expression Sampled_Mass_Flow :  sum=2.775649376
Expression patchMassFlow on inlet:  sum=-2.69375
Expression patchMassFlow on outlet:  sum=2.693749998
So it looks like about 90% of the flow isn't completely normal to the surface? Assuming I'm reading your expression correct. Or does this normal represent the flow going through each cell cut by my sample surface, not the surface itself? And what does this mean for the accuracy of the Sampled_Mass_Flow?

Also, for reference, this is the error I receive when I turn interpolation on for the Sampled_Mass_Flow...

Code:
--> FOAM FATAL ERROR:
 Parser Error at "1.12-11" :"Operands have different sizes: 24 and 22"
"rho*U & Sf()"
"            "

    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 802.

FOAM exiting
Thanks again for your help.
GRAUPS is offline   Reply With Quote

Old   December 7, 2012, 21:03
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 GRAUPS View Post
Ok, I added the check for the ratio of velocity that is not normal... here is the output after a converged solution has been reached...

Code:
Expression Ratio_not_Normal :  min=0.8991376591 max=0.96846234 average=0.9064741362
Expression Sampled_Mass_Flow :  sum=2.775649376
Expression patchMassFlow on inlet:  sum=-2.69375
Expression patchMassFlow on outlet:  sum=2.693749998
So it looks like about 90% of the flow isn't completely normal to the surface? Assuming I'm reading your expression correct. Or does this normal represent the flow going through each cell cut by my sample surface, not the surface itself? And what does this mean for the accuracy of the Sampled_Mass_Flow?
Well. I only suggest the equations. It's your simulation so you have to judge whether they are correct. Have you had a look in paraview whether the 90% are plausible?

With control surfaces that are not aligned to the cell faces you always have got to expect an error. How big it is depends on the circumstances but if the 90% are correct they are not favourable

Quote:
Originally Posted by GRAUPS View Post
Also, for reference, this is the error I receive when I turn interpolation on for the Sampled_Mass_Flow...

Code:
--> FOAM FATAL ERROR:
 Parser Error at "1.12-11" :"Operands have different sizes: 24 and 22"
"rho*U & Sf()"
"            "

    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 802.

FOAM exiting
Thanks again for your help.
That is strange. And looks like a bug. Sf() has as many values as there are faces on the surface and rho and U should get interpolated (and have the same number)
__________________
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 11, 2012, 18:15
Default
  #7
Member
 
Brock Lee
Join Date: Sep 2012
Location: Midwest
Posts: 40
Rep Power: 13
GRAUPS is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Well. I only suggest the equations. It's your simulation so you have to judge whether they are correct. Have you had a look in paraview whether the 90% are plausible?
I would say the 90% is not plausible, as this is a straight 3 meter pipe with constant inflow. When I get the time to come back to this problem, I'll post back with some paraview pics.

Quote:
Originally Posted by gschaider View Post
That is strange. And looks like a bug. Sf() has as many values as there are faces on the surface and rho and U should get interpolated (and have the same number)
I just realized I'm a version behind on swak4foam, and reading the release changes, some of my problems have a chance of being fixed in the new release. When I get the time to recompile and update, I'll try to post back with some more recent tests. Thanks again for your help.
GRAUPS is offline   Reply With Quote

Old   December 12, 2012, 13:15
Default
  #8
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 GRAUPS View Post
I would say the 90% is not plausible, as this is a straight 3 meter pipe with constant inflow. When I get the time to come back to this problem, I'll post back with some paraview pics.
Maybe there's an error in the expression although I don't see where (but it is always the simple things that are problematic).

Quote:
Originally Posted by GRAUPS View Post
I just realized I'm a version behind on swak4foam, and reading the release changes, some of my problems have a chance of being fixed in the new release. When I get the time to recompile and update, I'll try to post back with some more recent tests. Thanks again for your help.
Hoping for the best (I love bugs that are already fixed)
__________________
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   April 21, 2021, 09:11
Default Use normal() instead of Sf()
  #9
New Member
 
Balaji
Join Date: May 2013
Posts: 21
Rep Power: 12
Nealcaffrey is on a distinguished road
To get the correct massflow (m3/s) you need to use the expression.

Where normal() is the normal vector of the plane

expression "(area()*(normal()&U))";

It should work
Nealcaffrey is offline   Reply With Quote

Reply

Tags
functionobjects, mass flow rate, sample surface, swak4foam

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Mass flow rate: calculation v/s computation beguxa FLUENT 5 December 2, 2018 22:02
Mass Flow Rate is not converging destgir448 CFX 5 December 11, 2010 06:55
2D axisymmetric mass flow rate for the plain orifice atomizer jwillie2000 FLUENT 2 September 17, 2010 06:43
mass flow rate error Masood FLUENT 0 May 22, 2005 01:32
CFX4.3 -build analysis form Chie Min CFX 5 July 13, 2001 00:19


All times are GMT -4. The time now is 19:11.