CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Area/Mass weighted average at any arbitrary location (http://www.cfd-online.com/Forums/openfoam-post-processing/107293-area-mass-weighted-average-any-arbitrary-location.html)

aship September 23, 2012 05:51

Area/Mass weighted average at any arbitrary location
 
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

gschaider September 23, 2012 10:18

Quote:

Originally Posted by aship (Post 383186)
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

aship September 23, 2012 12:26

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...

gschaider September 23, 2012 18:05

Quote:

Originally Posted by aship (Post 383208)
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.

SirWombat September 24, 2012 05:05

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

gschaider September 24, 2012 13:27

Quote:

Originally Posted by SirWombat (Post 383288)
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.

aship September 24, 2012 14:14

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....

gschaider September 24, 2012 14:30

Quote:

Originally Posted by aship (Post 383383)
@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

aship September 26, 2012 05:51

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

gschaider September 26, 2012 06:06

Quote:

Originally Posted by aship (Post 383681)
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?

aship September 26, 2012 06:41

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

gschaider September 26, 2012 07:02

Quote:

Originally Posted by aship (Post 383695)
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

Luchini January 13, 2015 15:25

Quote:

Originally Posted by gschaider (Post 383199)
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


All times are GMT -4. The time now is 02:20.