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

Area/Mass weighted average at any arbitrary location

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 23, 2012, 05:51
Default Area/Mass weighted average at any arbitrary location
  #1
New Member
 
Join Date: Sep 2012
Posts: 5
Rep Power: 4
aship is on a distinguished road
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
aship is offline   Reply With Quote

Old   September 23, 2012, 10:18
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by aship View Post
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
gschaider is offline   Reply With Quote

Old   September 23, 2012, 12:26
Default
  #3
New Member
 
Join Date: Sep 2012
Posts: 5
Rep Power: 4
aship is on a distinguished road
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...
aship is offline   Reply With Quote

Old   September 23, 2012, 18:05
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by aship View Post
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
gschaider is offline   Reply With Quote

Old   September 24, 2012, 05:05
Default
  #5
Member
 
Jan
Join Date: Dec 2009
Location: Berlin
Posts: 50
Rep Power: 9
SirWombat is on a distinguished road
Send a message via Skype™ to 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:

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
__________________
~~~_/)~~~
SirWombat is offline   Reply With Quote

Old   September 24, 2012, 13:27
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by SirWombat View Post
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:

<snip>

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
gschaider is offline   Reply With Quote

Old   September 24, 2012, 14:14
Default
  #7
New Member
 
Join Date: Sep 2012
Posts: 5
Rep Power: 4
aship is on a distinguished road
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....
aship is offline   Reply With Quote

Old   September 24, 2012, 14:30
Default
  #8
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by aship View Post
@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
gschaider is offline   Reply With Quote

Old   September 26, 2012, 05:51
Default
  #9
New Member
 
Join Date: Sep 2012
Posts: 5
Rep Power: 4
aship is on a distinguished road
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
aship is offline   Reply With Quote

Old   September 26, 2012, 06:06
Default
  #10
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by aship View Post
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
gschaider is offline   Reply With Quote

Old   September 26, 2012, 06:41
Default
  #11
New Member
 
Join Date: Sep 2012
Posts: 5
Rep Power: 4
aship is on a distinguished road
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
aship is offline   Reply With Quote

Old   September 26, 2012, 07:02
Default
  #12
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by aship View Post
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
gschaider is offline   Reply With Quote

Old   January 13, 2015, 15:25
Default
  #13
New Member
 
Luca Franceschini
Join Date: Aug 2012
Posts: 27
Rep Power: 5
Luchini is on a distinguished road
Quote:
Originally Posted by gschaider View Post
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
Luchini is offline   Reply With Quote

Reply

Thread Tools
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 On
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 24 July 8, 2015 06:15
Diffference between mass weighted average and Area giogio FLUENT 4 September 25, 2012 01:36
PLOTING weighted average vs distance Vorch FLUENT 0 May 28, 2012 16:29
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 21:30
area weighted average Sireesha Pasari FLUENT 1 April 4, 2004 13:06


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