CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Calculating mean velocity in each cell

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Nicole
  • 1 Post By Nicole

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 26, 2015, 19:00
Default Calculating mean velocity in each cell
  #1
Member
 
HM
Join Date: Apr 2015
Posts: 30
Rep Power: 11
hojjat.m is on a distinguished road
Hi there,
I had a question regarding the velocity values that we get. So I need to calculate the mean velocity of each cell center (volumetric average of each point in my geometry), and do further analysis on the resulting datas'.
After the run has been finished, can we post-process on the datas'? I mean, suppose that we have the velocity of each point, and now we want to calculate the average velocity (volumetric average not temporal average) of each point, and then mess up further with data, for instance find the kinetic energy at each point in the domain.
Or, do we need to program, based on the parameters that we are interested. Any feedback would be appreciated.
hojjat.m is offline   Reply With Quote

Old   May 27, 2015, 07:20
Default
  #2
Member
 
Nicole Andrew
Join Date: Sep 2014
Location: Pretoria, South Africa
Posts: 58
Rep Power: 12
Nicole is on a distinguished road
Hi Hojjat,

You can do calculations in paraview (look for the little calculator icon), so this might be sufficient for you.

Otherwise in my (very) limited experience I would recommend using a function object in the controlDict file. This is a super useful tool that compiles the code for you at run time and does your calculations. You have to code them in openfoam's c++ style though.

Please let me know if paraview works for you, or if you need more info about function objects.

Regards,
Nicole
hojjat.m likes this.
Nicole is offline   Reply With Quote

Old   May 27, 2015, 11:08
Default
  #3
Member
 
HM
Join Date: Apr 2015
Posts: 30
Rep Power: 11
hojjat.m is on a distinguished road
Nick,
Thanks for your suggestions, since, I've been using tecplot for postprocessing, I think it would be better to write a function object in controlDict file. Any suggestions for that, how I can start? Sorry but I have a Fortran background and I am not familiar with C++, so any suggestions will really help. Thanks
hojjat.m is offline   Reply With Quote

Old   May 28, 2015, 04:01
Default
  #4
Member
 
Nicole Andrew
Join Date: Sep 2014
Location: Pretoria, South Africa
Posts: 58
Rep Power: 12
Nicole is on a distinguished road
Hi Hojjat,

Sure, I can give it a try. Please could you just let me know which version of OpenFOAM you are using because I think the function object stuff has changed slightly recently.

Also, do you want to calculate the magnitude of the velocity in each cell when calculating the average? Or only the component in a specific direction, eg: the x direction, or bulk flow direction?

Do you have different zones/regions in your geometry, or is it all one zone?

Regards,
Nicole
Nicole is offline   Reply With Quote

Old   May 28, 2015, 10:57
Default
  #5
Member
 
HM
Join Date: Apr 2015
Posts: 30
Rep Power: 11
hojjat.m is on a distinguished road
Nick,
Thanks for your help. I am using OpenFOAM 2.3.X.
Basically, I want to calculate the volumetric mean velocity (umean) at each cell center, and then calculate the fluctuating part (u*) by
u*=u-umean
for each cell center point. u is the velocity at each cell center point. This has to be calculated for 3 directions separately, so at the end we will have u* (fluctuating velocity component of x direction), v* (fluctuating velocity component of y direction), and w* (fluctuating velocity component of z direction).
I have just one internal field.
Thanks in advance,
hojjat.m is offline   Reply With Quote

Old   May 28, 2015, 12:25
Default
  #6
Member
 
Nicole Andrew
Join Date: Sep 2014
Location: Pretoria, South Africa
Posts: 58
Rep Power: 12
Nicole is on a distinguished road
Hi,

I am definitely still a novice myself, but I hope this helps to get you started. You can just copy this to the end of your control dict file and start playing. I have not tested this. I assume that your velocity field is called "v", you might have to edit my code if this is different.

Code:
functions
{
    WriteArea
    {
        type coded;
        functionObjectLibs 
        ( 
            "libutilityFunctionObjects.so"
         );
        redirectType writeArea;
        code
        #{
             // You can comment like this
             // Print output statements like this:
             Info << "My text here " << variableName << endl;

             // Declare variables like this (c++ needs you to declare EVERYTHING):
             scalar myScalarVariableName = 0;
             // using an openfoam type:
             // Note: you can call any of the variables in your 0 folder here, by name
             volScalarField magnitudeVelocity = mag(v); // I think this will work

             // If you want volume weighted velocity, try something like this:
             const volScalarField::DimensionedInternalField& Vol = mesh.V(); // volumes of all cells
             const scalar meanV = sum(mag(v)*Vol)/sum(Vol);

             // NB: Don't forget ; on the end of all your lines or it will throw crazy errors


        #};
    }
}
I'm afraid I am not sure how to get the x,y,z components of the velocity. I'll let you know if I find anything.

I'm not sure if you have heard of swak4Foam, there may be some utilites built in there to help you, but in my (incredibly limited) experience it is better to just spend the time learning the OpenFOAM/C++ syntax because you will want to use it eventually.

Let me know how it goes!
hojjat.m likes this.
Nicole is offline   Reply With Quote

Old   May 28, 2015, 12:27
Default
  #7
Member
 
HM
Join Date: Apr 2015
Posts: 30
Rep Power: 11
hojjat.m is on a distinguished road
Thanks Nick, I'll try that, and will let you know in a couple of days.
Thanks again.
hojjat.m is offline   Reply With Quote

Old   May 28, 2015, 15:03
Default
  #8
Member
 
HM
Join Date: Apr 2015
Posts: 30
Rep Power: 11
hojjat.m is on a distinguished road
Nick,
I was curious to know how u do it in paraView?
Thanks
hojjat.m is offline   Reply With Quote

Old   May 29, 2015, 04:02
Default
  #9
Member
 
Nicole Andrew
Join Date: Sep 2014
Location: Pretoria, South Africa
Posts: 58
Rep Power: 12
Nicole is on a distinguished road
There is a calculator icon at the top somewhere. It's on the far left for me. You might be able to use that.
Nicole is offline   Reply With Quote

Reply

Tags
cell center, interfoam, kinetic energy, mean velocity, spatial average


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
Wrong velocities at first cell of velocity inlet boundaries Bahram OpenFOAM Bugs 9 September 24, 2015 11:52
'cell relative: velocity magnitude' vs 'velocity magnitude' alpharays Main CFD Forum 2 June 18, 2015 08:24
Calculating velocity for partially flowing pipe Tanjina FLUENT 1 December 5, 2014 00:23
extract velocity of each cell in last time step?? Sebaj OpenFOAM 2 August 9, 2011 09:12
Conversion of cell velocity derivatives Manoj FLUENT 0 November 30, 2005 12:08


All times are GMT -4. The time now is 23:45.