# Area/Mass weighted average at any arbitrary location

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

 September 23, 2012, 05:51 Area/Mass weighted average at any arbitrary location #1 New Member   Join Date: Sep 2012 Posts: 5 Rep Power: 7 Hello all, I am trying to calculate area weighted average of velocity and pressure at any given time and arbitrary location. I was not able to find any utility for doing it. I saw this link http://openfoamwiki.net/index.php/Co...unctionObjects but to use it you need to know the name of patches (which i only know for the boundary patches (eg inlet outlet). What if I want it at centre of my grid?. I have to do it for lots of time interval so using parafoam integration function is also not efficient. Currently I calculate it using matlab by taking sample points at that location. But it will be very helpful if someone can highlight a method so that it can be done directly from open foam. Thanks & Regards

September 23, 2012, 10:18
#2
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,020
Rep Power: 43
Quote:
 Originally Posted by aship Hello all, I am trying to calculate area weighted average of velocity and pressure at any given time and arbitrary location. I was not able to find any utility for doing it. I saw this link http://openfoamwiki.net/index.php/Co...unctionObjects but to use it you need to know the name of patches (which i only know for the boundary patches (eg inlet outlet). What if I want it at centre of my grid?. I have to do it for lots of time interval so using parafoam integration function is also not efficient. Currently I calculate it using matlab by taking sample points at that location. But it will be very helpful if someone can highlight a method so that it can be done directly from open foam. Thanks & Regards
http://openfoamwiki.net/index.php/Contrib/swak4Foam of which the simpleFunctionObjects are now a part has a functionObject that allows arbitrary calculations on sampledSurfaces (I think that is what you mean with "arbitrary location"). There is also the possibility to do it on faceSets/Zones which is computationally less expensive (but you've got to add the sets/zones) during preprocessing
__________________
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

 September 23, 2012, 12:26 #3 New Member   Join Date: Sep 2012 Posts: 5 Rep Power: 7 Thanks for your reply..but i couldn't understand your suggestion...simplefunctionobject has utility named patchaverage by which i can do this area weighted calculation but the problem is that we have to give the name of patch to it (which is only available for boundaries)...let us say i have a channel flow so i will have patches named inlet, outlet, top wall, bottom wall but how about if i want to calculate area weight average at centre of channel (i dnt know the patch name here), i tried to create a interior boundary in mesh formation in gambit and named it there as x=0.5 but when i convert it into openfoam format it is just treated it as internal patch and doesnt differentiate it or list it in the boundary file...

September 23, 2012, 18:05
#4
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,020
Rep Power: 43
Quote:
 Originally Posted by aship Thanks for your reply..but i couldn't understand your suggestion...simplefunctionobject has utility named patchaverage by which i can do this area weighted calculation but the problem is that we have to give the name of patch to it (which is only available for boundaries)...let us say i have a channel flow so i will have patches named inlet, outlet, top wall, bottom wall but how about if i want to calculate area weight average at centre of channel (i dnt know the patch name here), i tried to create a interior boundary in mesh formation in gambit and named it there as x=0.5 but when i convert it into openfoam format it is just treated it as internal patch and doesnt differentiate it or list it in the boundary file...
The you're in the faceSet/faceZone-scenario. These two things are the nearest thing to a "internal boundary" OpenFOAM has. Have a look in the polyMesh-directory of the case. Either you have file called fileZones or a directory sets with a file in it that is named like your internal boundary. t depends a bit on the converter you used to create the mesh because with one of them you need to and option (I think -writeZones) to write the faceZones

And on these faceZones or faceSets swak can do calculations like the mass flow.
__________________
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

 September 24, 2012, 05:05 #5 Member   Jan Join Date: Dec 2009 Location: Berlin Posts: 50 Rep Power: 11 Are you looking for probeLocations? There is a post-processing tool that need a probesDict in the system folder, but you can also use it during runtime by adding this to your controlDict: Code: ```functions ( probes { type probes; functionObjectLibs ("libsampling.so"); fields ( p_rgh U ); probeLocations ( (1.0 0 0) (1.5 0 0) (2.0 0 0) (1.0 0 0.5) (1.5 0 1.0) (2.0 0 1.5) ); outputControl timeStep; outputInterval 10; } )``` it will create a folder called "probes" with the interpolated values of the fields "U" and "p_rgh" at the six probe locations (I'm using interFoam here). The probe locations are defined as (Xposition Yposition Zposition). You can then plot those using gnuplot, i.e. by the command "gnuplot --persist" (persist to keep the window open after plotting) Code: ``` set xlabel 'time [s]' set ylabel 'pressure [Pa]' plot 'probes/0/p_rgh' u 1:2 t '1st probe location' w lines,\ 'probes/0/p_rgh' u 1:3 t '2nd probe location' w lines,\ 'probes/0/p_rgh' u 1:4 t '3rd probe location' w lines,\ 'probes/0/p_rgh' u 1:5 t '1st probe location' w lines``` Its plotting the pressure vs time from the file "probes/0/p_rgh" Is that what you wanted? Greetings Jan __________________ ~~~_/)~~~

September 24, 2012, 13:27
#6
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,020
Rep Power: 43
Quote:
 Originally Posted by SirWombat Are you looking for probeLocations? There is a post-processing tool that need a probesDict in the system folder, but you can also use it during runtime by adding this to your controlDict: Is that what you wanted? Greetings Jan
The original posting started with "I am trying to calculate area weighted average" so I think probes are not the solution here.
__________________
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

 September 24, 2012, 14:14 #7 New Member   Join Date: Sep 2012 Posts: 5 Rep Power: 7 i dont think probesDict will serve the purpose as it gives the values of U and P at a particular point over the time...I get that along a plane/line (in 2d) using sampleDict...i want to perform calculations like patchaverage along a line/plane...problem is i dont know how to reference a patch which is not a boundary @Gschaider I didnt see any directory named files zone or any other which contains the information of the line/plane i defined in gambit...i used fluentMesh2foam command....

September 24, 2012, 14:30
#8
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,020
Rep Power: 43
Quote:
 Originally Posted by aship @Gschaider I didnt see any directory named files zone or any other which contains the information of the line/plane i defined in gambit...i used fluentMesh2foam command....
That one needs to be "pushed" with an option to generate them. The -h-option is your friend. Call

fluentMeshToFoam -h

and pick an option that you like
__________________
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

 September 26, 2012, 05:51 #9 New Member   Join Date: Sep 2012 Posts: 5 Rep Power: 7 It didnt work I named two lines in gambit with a boundary type interior and then i used fluentMeshToFoam -writeSets and also fluentMeshToFoam -writeZones but I couldnt find anything in the set folder that could be used to reference in patchAverage utility also the facezones and cellzones file were empty

September 26, 2012, 06:06
#10
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,020
Rep Power: 43
Quote:
 Originally Posted by aship It didnt work I named two lines in gambit with a boundary type interior and then i used fluentMeshToFoam -writeSets and also fluentMeshToFoam -writeZones but I couldnt find anything in the set folder that could be used to reference in patchAverage utility also the facezones and cellzones file were empty
patchAverage can't work with zones or sets anyway. You'll have to go for the swakExpression-functionObject

The zones-files are there but empty? Strange

Have you tried the "other" fluent-converter?
__________________
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

 September 26, 2012, 06:41 #11 New Member   Join Date: Sep 2012 Posts: 5 Rep Power: 7 Building boundary and internal patches. Creating patch 0 for zone: 3 start: 1 end: 100 type: pressure-outlet name: pressure_outlet.4 Creating patch 1 for zone: 4 start: 101 end: 400 type: axis name: axis.3 Creating patch 2 for zone: 5 start: 401 end: 500 type: velocity-inlet name: velocity_inlet.2 Creating patch 3 for zone: 6 start: 501 end: 800 type: wall name: wall Creating patch 4 for zone: 8 start: 801 end: 60400 type: interior name: default-interior Creating patch for front and back planes Adding new patch pressure_outlet.4 of type patch as patch 0 Adding new patch axis.3 of type symmetryPlane as patch 1 Adding new patch velocity_inlet.2 of type patch as patch 2 Adding new patch wall of type wall as patch 3 Patch default-interior is internal to the mesh and is not being added to the boundary. Adding new patch frontAndBackPlanes of type empty as patch 4 this is what i get when i run fluentMeshToFoam -writeZones and when i run writesets there is a folder named sets in which u have the boundary files and default interior file (but no file abt the dummy lines i made) the facezones file reads like this FoamFile { version 2.0; format ascii; class regIOobject; location "constant/polyMesh"; object faceZones; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 0 () I am sorry but i dnt know any other converter which can convert a .msh file into openfoam format

September 26, 2012, 07:02
#12
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,020
Rep Power: 43
Quote:
 Originally Posted by aship Building boundary and internal patches. Creating patch 0 for zone: 3 start: 1 end: 100 type: pressure-outlet name: pressure_outlet.4 Creating patch 1 for zone: 4 start: 101 end: 400 type: axis name: axis.3 Creating patch 2 for zone: 5 start: 401 end: 500 type: velocity-inlet name: velocity_inlet.2 Creating patch 3 for zone: 6 start: 501 end: 800 type: wall name: wall Creating patch 4 for zone: 8 start: 801 end: 60400 type: interior name: default-interior Creating patch for front and back planes Adding new patch pressure_outlet.4 of type patch as patch 0 Adding new patch axis.3 of type symmetryPlane as patch 1 Adding new patch velocity_inlet.2 of type patch as patch 2 Adding new patch wall of type wall as patch 3 Patch default-interior is internal to the mesh and is not being added to the boundary. Adding new patch frontAndBackPlanes of type empty as patch 4 this is what i get when i run fluentMeshToFoam -writeZones and when i run writesets there is a folder named sets in which u have the boundary files and default interior file (but no file abt the dummy lines i made) the facezones file reads like this FoamFile { version 2.0; format ascii; class regIOobject; location "constant/polyMesh"; object faceZones; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 0 () I am sorry but i dnt know any other converter which can convert a .msh file into openfoam format
The name of the "other" converter is fluent3DMeshToFoam (the tab-completion of the shell is your friend)

Check whether your interior boundary is actually in the mesh. Either have a look at the end of the msh-file (as far as I remember the boundaries are listed there) or grep for the name you gave it
__________________
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

January 13, 2015, 15:25
#13
New Member

Luca Franceschini
Join Date: Aug 2012
Posts: 29
Rep Power: 7
Quote:
 Originally Posted by gschaider There is also the possibility to do it on faceSets/Zones which is computationally less expensive (but you've got to add the sets/zones) during preprocessing
Hello,

I am also trying to do computations on planes inside the domain.
But i have some difficulties on creating the faceSets/Zones required.

According to you which is the best way to create 10 of such arbitrary planes?

Thank you a lot

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post SAM Main CFD Forum 24 July 8, 2015 06:15 giogio FLUENT 4 September 25, 2012 01:36 Vorch FLUENT 0 May 28, 2012 16:29 unoder OpenFOAM Installation 11 January 30, 2008 21:30 Sireesha Pasari FLUENT 1 April 4, 2004 13:06

All times are GMT -4. The time now is 00:24.