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

Area Weighted Average

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes
  • 4 Post By santos
  • 2 Post By srv537
  • 1 Post By Gerhard

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 19, 2010, 10:27
Default Area Weighted Average
  #1
Senior Member
 
Balkrishna Patankar
Join Date: Mar 2009
Location: Pune
Posts: 123
Rep Power: 17
balkrishna is on a distinguished road
Please can someone document a method to find the area weighted average of a variable in OpenFOAM. The source code is really complex to figure out for someone who has a basic programmers insight. Would be of great help if anyone would do so . The Doxygen documentation is not very helpful either for beginners .All it gives are links to headers files without actual descripton of what a variable is . Also please comment a lot when writing any solver for OpenFOAM . A very good example is the way Linux source code is written. Loads of comments explaining every line in detail.
balkrishna is offline   Reply With Quote

Old   July 19, 2010, 10:55
Default
  #2
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
It's not entirely clear what you intend by an 'area-weighted' average. Do you intend to perform a weighted average based on mesh face-patch values? OpenFOAM is a three-dimensional code, so volume-weighted averages for cell variables are usually the norm.

Either way, you can perform a weighted average (either patch face-areas or cell-volumes) using the DimensionedField member function:

//- Calculate and return weighted average
dimensioned<Type> weightedAverage
(
const DimensionedField<scalar, GeoMesh>&
) const;

Take a look at $FOAM_SRC/finiteVolume/cfdTools/general/include/volContinuity.H for a cue on how it's done.

Also, writing code is hard work, and documenting it can be often time-consuming, which is why it may not be done at all times. Of course, if you're willing to pay for it, I'm sure you'll find a bunch of people who would oblige.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   July 20, 2010, 02:21
Default
  #3
Senior Member
 
Balkrishna Patankar
Join Date: Mar 2009
Location: Pune
Posts: 123
Rep Power: 17
balkrishna is on a distinguished road
Thanks . But how do i actually use it while solving a case . Like how do I call the function to actually find the volume weighted average .
balkrishna is offline   Reply With Quote

Old   July 20, 2010, 06:10
Default
  #4
Senior Member
 
Balkrishna Patankar
Join Date: Mar 2009
Location: Pune
Posts: 123
Rep Power: 17
balkrishna is on a distinguished road
What i want to calculate is the pressure area weighted average on any face ....
sum(Af*p)/sum(A) on the boundary .... how do I go about it ?
balkrishna is offline   Reply With Quote

Old   July 20, 2010, 06:15
Default
  #5
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18
herbert is on a distinguished road
If you only want to calculate average values on patches for postprocessing, you can use simpleFunctionObjects.

Regards,
Stefan
herbert is offline   Reply With Quote

Old   July 20, 2010, 06:49
Default
  #6
Senior Member
 
santos's Avatar
 
Jose Luis Santos
Join Date: Mar 2009
Location: Portugal
Posts: 215
Rep Power: 18
santos is on a distinguished road
Send a message via Skype™ to santos
Another option is to run:
patchAverage <field> <patch>

Regards,
Jose Santos
santos is offline   Reply With Quote

Old   February 28, 2011, 18:17
Default
  #7
Member
 
Wolfgang W.
Join Date: Nov 2009
Location: Switzerland
Posts: 57
Rep Power: 17
WiWo is on a distinguished road
Hi!

Sorry if this comes like a stupid question ...
I was intending to use the patchAverage utility exactly as described above - works fine. BUT - where are the results actually written to? I don't see any additional files being created anywhere ...

Thanks for your help!
Cheers,
Wolfgang
WiWo is offline   Reply With Quote

Old   February 28, 2011, 18:21
Default
  #8
Senior Member
 
santos's Avatar
 
Jose Luis Santos
Join Date: Mar 2009
Location: Portugal
Posts: 215
Rep Power: 18
santos is on a distinguished road
Send a message via Skype™ to santos
Results are not written to any file unless you instruct it to, they are just output to the terminal.

If you want to write results to a file 'file' without any output in the terminal you can try:
patchAverage <field> <patch> > file &

Regards,
Jose
santos is offline   Reply With Quote

Old   March 1, 2011, 20:21
Default
  #9
Member
 
Wolfgang W.
Join Date: Nov 2009
Location: Switzerland
Posts: 57
Rep Power: 17
WiWo is on a distinguished road
Hi Jose,

Thanks a lot for your expeditious response! I was able to redirect the output of patchAverage to a file.
Unfortunately the style of the output with the accompanying text is not ideal for further processing. Thus I decided to change the code of patchAverage a little :-)

Cheers,
Wolfgang
WiWo is offline   Reply With Quote

Old   March 2, 2011, 08:05
Default
  #10
Senior Member
 
Balkrishna Patankar
Join Date: Mar 2009
Location: Pune
Posts: 123
Rep Power: 17
balkrishna is on a distinguished road
instead of meddling with the code i pass the file through tr and awk filters .... and get the output in the format i want it to be ...
balkrishna is offline   Reply With Quote

Old   February 16, 2017, 08:54
Default
  #11
Member
 
Saurav Kumar
Join Date: Jul 2016
Posts: 80
Rep Power: 10
srv537 is on a distinguished road
Quote:
Originally Posted by santos View Post
Results are not written to any file unless you instruct it to, they are just output to the terminal.

If you want to write results to a file 'file' without any output in the terminal you can try:
patchAverage <field> <patch> > file &

Regards,
Jose
Hi santos,
actually, I am using OpenFOAM4 and interested to find Area Weighted Average for each time step.
I modified pimplefoam and it calculates gradT and average of gradT over patch surface.
Quote:
gradT.boundaryFieldRef()[patchi]=T.boundaryFieldRef()[patchi].snGrad();

scalar area1 = gSum(mesh.magSf().boundaryField()[patchi]);
scalar sumField1 = 0;

if (area1 > 0)
{
sumField1 = gSum
(
mesh.magSf().boundaryField()[patchi]
* gradT.boundaryField()[patchi]
)/ area1;
}

Info<< " Average of gradT over patch 1 = " << sumField1 << endl;
and then i use to calculate Nu=(L/deltaT)*gradT.

in openfoam4 i have used
"mypimpleFoam -postProcess -func 'patchAverage(name=HEATEDWALL,gradT)' >log"
but it gives me Zero value and only at those time that i have saved for postProcessing.

Region type : patch HEATEDWALL
# Faces : 351
# Area : 3.50000000e-03
# Time average(gradT)
0 0.00000000e+00
1 0.00000000e+00
2 0.00000000e+00
3 0.00000000e+00
4 0.00000000e+00
5 0.00000000e+00
6 0.00000000e+00
7 0.00000000e+00
8 0.00000000e+00
9 0.00000000e+00
10 0.00000000e+00
10 0.00000000e+00

I want to save average(gradT) and average(wallShearStress) that i have calculated by " mypimpleFoam -postProcess -func wallShearStress" at all time step how can i do this, please suggest me.

Kind Regards,
srv
Luttappy and elmo555 like this.
srv537 is offline   Reply With Quote

Old   March 14, 2018, 10:41
Default
  #12
New Member
 
Gerhard
Join Date: Mar 2017
Posts: 26
Rep Power: 9
Gerhard is on a distinguished road
Hi
This conversation really helped me. Thank you.

However, patchAverage does not calculate the area weighted average. It only calculates the average.

You can make it calculate the area weighted average by doing the following:
- Copy the patchAverage file from $FOAM_ETC/caseDicts/postProcessing to your case's system file.
- Change operation to areaAverage instead of average.
- include #includeFunc patchAverage under functions in controlDict.
- run the case and once done run: solver -postProcess (eg. simpleFoam -postProcess)

Good luck!
eirinikardabiki likes this.

Last edited by Gerhard; March 14, 2018 at 10:46. Reason: Pressed the send button by accident...
Gerhard is offline   Reply With Quote

Old   October 11, 2021, 23:37
Default
  #13
Member
 
Venkat Ganesh
Join Date: May 2020
Location: Cincinnati, Ohio
Posts: 49
Rep Power: 6
Venky_94 is on a distinguished road
Quote:
Originally Posted by balkrishna View Post
What i want to calculate is the pressure area weighted average on any face ....
sum(Af*p)/sum(A) on the boundary .... how do I go about it ?
Can someone please suggest how to carry this out? I'm trying to do something similar, but within the solver code and not in postprocessing.

I need to obtain an area averaged value for the volume fraction in interfoam.
Attached Images
File Type: jpg Areaaveraging.JPG (31.5 KB, 36 views)
Venky_94 is offline   Reply With Quote

Reply

Tags
area, average, foam, open, weighted


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
Area weighted or mass weighted average SAM Main CFD Forum 31 April 30, 2018 05:12
Diffference between mass weighted average and Area giogio FLUENT 9 March 6, 2018 09:24
CFX Solver Memory Error mike CFX 1 March 19, 2008 08:22
Area weighted average ashish FLUENT 1 April 12, 2005 19:02
area weighted average Sireesha Pasari FLUENT 1 April 4, 2004 14:06


All times are GMT -4. The time now is 17:26.