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

mass flow calculation over a face zone

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 23, 2009, 03:25
Default mass flow calculation over a face zone
  #1
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
Hi

I want to calculate the mass flow over a face zone. I am able to calculate it over a boundary, following the advices in this thread, by means of patchIntegrate. But I'd like to calculate it in an internal surface, so I thought the most suitable way is to define a faceZone and integrate over it. As I'm quite new to OF, I don't know how to do it (extend patchIntegrate?, do it with paraview?,...).

Can someone help?

Juan
mvoss is offline   Reply With Quote

Old   July 23, 2009, 03:56
Default
  #2
Senior Member
 
Henrik Rusche
Join Date: Mar 2009
Location: Wernigerode, Sachsen-Anhalt, Germany
Posts: 281
Rep Power: 18
henrik is on a distinguished road
I think these threads should help to find direction:

http://www.cfd-online.com/Forums/ope...g-faceset.html
http://www.cfd-online.com/Forums/ope...condition.html

Henrik
henrik is offline   Reply With Quote

Old   July 24, 2009, 03:19
Default
  #3
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
I'll try to create a cyclic boundary with the patchCreate utility. Unfortunately, as already reported in some other threads, this utility crashes. I will try it from the 1.5.x installation.
Thx for the prompt support.
mvoss is offline   Reply With Quote

Old   July 31, 2009, 07:58
Default
  #4
Senior Member
 
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20
mvoss is on a distinguished road
That is what I did, for those interested:
- I created two closed volumina and defined a patch in both zones I want to put together
- Then I used createPatch from version 1.6 (1.5 does not work for me)
- I added phi to the fluxRequired variables in fvSchemes, so phi will be written in each time step
- I changed patchIntegrate to correctly calculate the massflow in the cyclic BC (in the original version, it gets cancelled because areas do sum zero) (see attached applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C)

happy Foaming!

Juan

--------------------- CUT HERE -------------------------------
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Application
patchIntegrate

Description
Calculates the integral of the specified field over the specified patch.

\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
#include "cyclicPolyPatch.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:

int main(int argc, char *argv[])
{
timeSelector::addOptions();
argList::validArgs.append("fieldName");
argList::validArgs.append("patchName");
# include "setRootCase.H"
# include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"

word fieldName(args.additionalArgs()[0]);
word patchName(args.additionalArgs()[1]);

forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;

IOobject fieldHeader
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ
);

// Check field exists
if (fieldHeader.headerOk())
{
mesh.readUpdate();

label patchi = mesh.boundaryMesh().findPatchID(patchName);
if (patchi < 0)
{
FatalError
<< "Unable to find patch " << patchName << nl
<< exit(FatalError);
}

// Give patch area
if (isType<cyclicPolyPatch>(mesh.boundaryMesh()[patchi]))
{
Info<< " Cyclic patch vector area: " << nl;
label nFaces = mesh.boundaryMesh()[patchi].size();
vector sum1 = vector::zero;
vector sum2 = vector::zero;
for (label i=0; i<nFaces/2; i++)
{
sum1 += mesh.Sf().boundaryField()[patchi][i];
sum2 += mesh.Sf().boundaryField()[patchi][i+nFaces/2];
}
reduce(sum1, sumOp<vector>());
reduce(sum2, sumOp<vector>());
Info<< " - half 1 = " << sum1 << ", " << mag(sum1) << nl
<< " - half 2 = " << sum2 << ", " << mag(sum2) << nl
<< " - total = " << (sum1 + sum2) << ", "
<< mag(sum1 + sum2) << endl;
Info<< " Cyclic patch area magnitude = "
<< gSum(mesh.magSf().boundaryField()[patchi])/2.0 << endl;

// Read field and calc integral
if (fieldHeader.headerClassName() == volScalarField::typeName)
{
Info<< " Reading " << volScalarField::typeName << " "
<< fieldName << endl;

volScalarField field(fieldHeader, mesh);

vector integral1 = vector::zero;
vector integral2 = vector::zero;
for (label i=0; i<nFaces/2; i++)
{
integral1 += mesh.Sf().boundaryField()[patchi][i] * field.boundaryField()[patchi][i];
integral2 += mesh.Sf().boundaryField()[patchi][i+nFaces/2] * field.boundaryField()[patchi][i+nFaces/2];
}
reduce(integral1, sumOp<vector>());
reduce(integral2, sumOp<vector>());

Info<< " Integral of " << fieldName
<< " over vector area & area magnitude of cyclic patch " << patchName << '[' << patchi << ']' << nl;

Info<< " - half 1 = " << integral1 << ", " << mag(integral1) << nl
<< " - half 2 = " << integral2 << ", " << mag(integral2) << nl
<< " - total = " << (integral1 + integral2) << ", "
<< mag(integral1 + integral2) << endl;

}
else if
(
fieldHeader.headerClassName() == surfaceScalarField::typeName
)
{
Info<< " Reading " << surfaceScalarField::typeName << " "
<< fieldName << endl;

surfaceScalarField field(fieldHeader, mesh);

scalar integral1 = 0.0;
scalar integral2 = 0.0;
for (label i=0; i<nFaces/2; i++)
{
integral1 += field.boundaryField()[patchi][i];
integral2 += field.boundaryField()[patchi][i+nFaces/2];
}

Info<< " Integral of " << fieldName << " over patch "
<< patchName << '[' << patchi << ']' << nl ;

Info<< " - half 1 = " << integral1 << nl
<< " - half 2 = " << integral2 << nl
<< " - total = " << (integral1 + integral2) << endl;

}
else
{
FatalError
<< "Only possible to integrate "
<< volScalarField::typeName << "s "
<< "and " << surfaceScalarField::typeName << "s"
<< nl << exit(FatalError);
}

}
else
{
// Give patch area
Info<< " Area vector of patch "
<< patchName << '[' << patchi << ']' << " = "
<< gSum(mesh.Sf().boundaryField()[patchi]) << endl;
Info<< " Area magnitude of patch "
<< patchName << '[' << patchi << ']' << " = "
<< gSum(mesh.magSf().boundaryField()[patchi]) << endl;


// Read field and calc integral
if (fieldHeader.headerClassName() == volScalarField::typeName)
{
Info<< " Reading " << volScalarField::typeName << " "
<< fieldName << endl;

volScalarField field(fieldHeader, mesh);

Info<< " Integral of " << fieldName
<< " over vector area of patch "
<< patchName << '[' << patchi << ']' << " = "
<< gSum
(
mesh.Sf().boundaryField()[patchi]
*field.boundaryField()[patchi]
)
<< nl;

Info<< " Integral of " << fieldName
<< " over area magnitude of patch "
<< patchName << '[' << patchi << ']' << " = "
<< gSum
(
mesh.magSf().boundaryField()[patchi]
*field.boundaryField()[patchi]
)
<< nl;
}
else if
(
fieldHeader.headerClassName() == surfaceScalarField::typeName
)
{
Info<< " Reading " << surfaceScalarField::typeName << " "
<< fieldName << endl;

surfaceScalarField field(fieldHeader, mesh);
scalar sumField = gSum(field.boundaryField()[patchi]);

Info<< " Integral of " << fieldName << " over patch "
<< patchName << '[' << patchi << ']' << " = "
<< sumField << nl;
}
else
{
FatalError
<< "Only possible to integrate "
<< volScalarField::typeName << "s "
<< "and " << surfaceScalarField::typeName << "s"
<< nl << exit(FatalError);
}
}
}
else
{
Info<< " No field " << fieldName << endl;
}

Info<< endl;
}

Info<< "End\n" << endl;

return 0;
}


// ************************************************** *********************** //

--------------------- CUT HERE -------------------------------
mvoss is offline   Reply With Quote

Old   August 6, 2009, 06:42
Default
  #5
Member
 
Hamed Aghajani
Join Date: Mar 2009
Location: London, UK
Posts: 77
Rep Power: 17
haghajani is on a distinguished road
Dear All,
My problem is an underpressure vessel with a hole on it, and I want to monitor mass flow rate at this hole.
So I need to have face inside to solution domain, why it is not the boundary.
To follow the instructions, posted below;

How should I create the patch/face, defining the interested hole?

Thanks in advance,
Hamed
haghajani is offline   Reply With Quote

Old   August 10, 2009, 10:01
Default Steps to calculate mass flow rate at an internal face
  #6
Member
 
Hamed Aghajani
Join Date: Mar 2009
Location: London, UK
Posts: 77
Rep Power: 17
haghajani is on a distinguished road
Dear All,
I am going to ask my question in a new way, May that was not clear enough.

I want to calculate mass flow rate at cross section different from boundaries; so each cross-section contains many faces wich are (internal). I didn't get the idea of using utilities as faceSet, createPatch or patchIntegrate; Would you please tell me more how I should implement them?
If the solution is what is posted, I do not know

- How to creat closed volumina and defin a patch in zones?
- How to use createPatch?
- How to add phi to the fluxRequired variables in fvSchemes?
...
Please let me know the steps in detail;



Best regards,
Hamed
haghajani is offline   Reply With Quote

Old   August 10, 2009, 11:56
Default
  #7
Senior Member
 
Henrik Rusche
Join Date: Mar 2009
Location: Wernigerode, Sachsen-Anhalt, Germany
Posts: 281
Rep Power: 18
henrik is on a distinguished road
Dear haghajani,

have a look at the faceZoneIntegration-functionObject that comes with 1.6. This should be very close to what you are looking for.

Henrik
henrik is offline   Reply With Quote

Old   September 28, 2009, 08:11
Default
  #8
New Member
 
Giovanni Ricci
Join Date: May 2009
Posts: 12
Rep Power: 16
gricci is on a distinguished road
Send a message via Skype™ to gricci
Unfortunately the faceZonesIntegration-functionObject only works with sufaceScalarField and cannot be used to integrate over internal faces where fields are defined as volScalarFields.

Maybe someone could explain here how to modify this functionObject to handle volScalarFields.

Thanks and keep up the good work!
gricci is offline   Reply With Quote

Old   September 13, 2010, 12:50
Default ...more hints on this topic?
  #9
New Member
 
Steffen
Join Date: Oct 2009
Posts: 7
Rep Power: 16
steve is on a distinguished road
Dear Foamers,

did you figure out a quick solution of the problem "mass flow calculation over face zones"? I tried out several things but did not get any satisfying solution. I keep struggling when trying to access the field data of a face zone.

Did you manage to adjust the faceZoneIntegration - functionObject for this purpose? I would be happy for any hint how to approach this problem.

Kind regards,
Steffen
steve is offline   Reply With Quote

Old   September 14, 2010, 08:57
Default
  #10
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 steve View Post
Dear Foamers,

did you figure out a quick solution of the problem "mass flow calculation over face zones"? I tried out several things but did not get any satisfying solution. I keep struggling when trying to access the field data of a face zone.

Did you manage to adjust the faceZoneIntegration - functionObject for this purpose? I would be happy for any hint how to approach this problem.

Kind regards,
Steffen
Beware: this is advertisment for Beta-software.

Just yesterday I announced this piece of software http://www.cfd-online.com/Forums/ope...tml#post275057 which among other things can do what you're trying to do (have a look at the angledDuct-example that comes with it for an example on "how to calculate a massflow on a faceZone")

And another "advantage": there isn't too much documentation there yet, so you won't have to waste too much time reading

Bernhard
gschaider is offline   Reply With Quote

Old   September 14, 2010, 11:26
Default
  #11
New Member
 
Steffen
Join Date: Oct 2009
Posts: 7
Rep Power: 16
steve is on a distinguished road
Bernhard,

Thanks for the quick reply and this great hint!
I could not manage to get your tool swak4Foam running on OF1.5-dev, though. Is this tool also supported for this OF version or do I have to stick to OF1.6 or OF1.7?

Kind regards,
Steffen
steve is offline   Reply With Quote

Old   September 14, 2010, 11:34
Default
  #12
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 steve View Post
Bernhard,

Thanks for the quick reply and this great hint!
I could not manage to get your tool swak4Foam running on OF1.5-dev, though. Is this tool also supported for this OF version or do I have to stick to OF1.6 or OF1.7?

Kind regards,
Steffen
I'm sorry. I would be surprised if it worked with 1.5 (changes should not be too hard but nevertheless incompatible with 1.6/1.7)

Bernhard
gschaider is offline   Reply With Quote

Reply

Tags
postprocessing mass flow

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
Target Mass Flow Rate Nitin FLUENT 9 June 17, 2017 10:30
Running dieselFoam error adorean OpenFOAM Running, Solving & CFD 119 February 1, 2016 14:41
Calculation of mass flow rate msrinath80 OpenFOAM Running, Solving & CFD 0 April 18, 2007 14:05
Sequential calculation of Temperature and mass tra J.W.Ryu FLUENT 7 June 18, 2002 07:12
Mass flow rate on outflow face TOM FLUENT 1 February 25, 2002 10:27


All times are GMT -4. The time now is 07:50.