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

using fieldAverage library to average postprocessing

Register Blogs Community New Posts Updated Threads Search

Like Tree61Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 4, 2013, 07:43
Default
  #21
Senior Member
 
Jie
Join Date: Jan 2010
Location: Australia
Posts: 134
Rep Power: 16
jiejie is on a distinguished road
Quote:
Originally Posted by Hanzo View Post
If my calculations are right then UPrime2Mean should exactly be what it says:
U-prime, squared and averaged = <u'^2>. To check this, you can compute u' using U and <U> , calculate u'^2 and average it manually. I did this for a series of data sets and when I compared UPrime2Mean with manually generated <u'^2> they turned out to be the same.

Another hint is the magnitude. In my computations, the biggest components of UMean_X are around 0.97 and UPrime2Mean_XX of 0.0025.
UPrime2Mean cannot be U^2
Hi Hanzo

Thanks for your quick reply. I was not saying UPrime2Mean is U^2. I calculate the UPrime and found it is the same as sqrt(UPrime2Mean). I got confused as eelcovv hinted " you can obtain the <u'^2> by subtracting the Umean squared from the Uprime2mean". I am not trying to offend anyone but find the right meaning of UPrime2Mean.

Thanks

jiejie
jiejie is offline   Reply With Quote

Old   April 4, 2013, 08:47
Default
  #22
Member
 
Join Date: Nov 2010
Location: Tokyo / Japan
Posts: 40
Rep Power: 15
Hanzo is on a distinguished road
Quote:
Originally Posted by jiejie View Post
I am not trying to offend anyone but find the right meaning of UPrime2Mean.
I am sorry if my comment let you feel like this. I did not want to say that you are offending anyone. It's just my raw english I am also highly interested in the correct meaning of UPrime2Mean.

Quote:
Originally Posted by jiejie View Post
Hi Hanzo

Thanks for your quick reply. I was not saying UPrime2Mean is U^2. I calculate the UPrime and found it is the same as sqrt(UPrime2Mean). I got confused as eelcovv hinted " you can obtain the <u'^2> by subtracting the Umean squared from the Uprime2mean".
How did you compute UPrime? Did you take U - UMean and averaged this over several time steps? Or for a single realization only?
Averaging this would give <u'> (should be a value close to zero, right?). And then you compared to sqrt( UPrime2Mean ) (which is related to the rms value sqrt(<u'^2>) according to my understanding).
If you are right then UPrime2Mean gives <u'>^2.

Could you describe a little bit more in detail what you calculated?
I really hope that UPrime2Mean_XX corresponds to <u_x'^2>,
UPrime2Mean_YY to <u_y'^2> and so on. If not I have to recheck quite some of my results
Hanzo is offline   Reply With Quote

Old   April 4, 2013, 08:58
Default
  #23
Senior Member
 
Jie
Join Date: Jan 2010
Location: Australia
Posts: 134
Rep Power: 16
jiejie is on a distinguished road
Quote:
Originally Posted by Hanzo View Post
I am sorry if my comment let you feel like this. I did not want to say that you are offending anyone. It's just my raw english I am also highly interested in the correct meaning of UPrime2Mean.

Could you describe a little bit more in detail what you calculated?
I really hope that UPrime2Mean_XX corresponds to <u_x'^2>,
UPrime2Mean_YY to <u_y'^2> and so on. If not I have to recheck quite some of my results
Hi Hanzo

I thought I might upset eelcovv as I was confused with his hint . Anyway, I actually output the flow field for every single time step and use the postprocessing utility sample to probe the velocity at a few locations. Then, I calculate the the veocity RMS by its definition, which should be the UPrime^2. I did this a while ago, I think the RMS value is very close to the sqrt of UPrime2Mean. That's why I am thinking UPrime2Mean is giving the correct result.

jiejie
Hanzo likes this.
jiejie is offline   Reply With Quote

Old   July 22, 2013, 16:26
Default
  #24
Senior Member
 
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19
eelcovv is on a distinguished road
Hi jiejie,

You are correct, my hint in an ealier post is misleading. The uprime2suare is already correct for U^2.
So if you define U(t)=<U>+u'(t) then the uprime2square constains the in this order:

<u'^2> <uv> <uw> <v'^2> <vw> <w'^2>

no need to subtract anything. Forget my remark about that.

If you want to plot for instance the turbulent kinetic energy k over a line sampled from you uprima2square you can just do

plot 'sampledline_with_UPrime2Square' u 10.5*($2+$5+$7))

cheers
alquimista likes this.
eelcovv is offline   Reply With Quote

Old   November 14, 2013, 07:03
Default
  #25
New Member
 
Rallou Dadioti
Join Date: May 2013
Posts: 1
Rep Power: 0
snappyHex is on a distinguished road
Hi eelcovv,

Thanks for the utility, it is really helpful!
However I am not getting the results that I would expect.
I have two time directories (0 and 90) and I want to get the average of the U field. Running the application I get the Umean file but the results are not correct,
i.e. U in 0 : (0.1107 -0.0027 0.0006),
U in 90: (0.0036 -0.1216 -0.0004)

and the average I get is: (0.1017 -0.0126 0.0005).

Could you give me any hint of what it can be wrong?
Thanks!

My controlDict:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.1.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     simpleFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime        90;

deltaT          1;

writeControl    timeStep;

writeInterval   90;

purgeWrite      0;

writeFormat     ascii;

writePrecision  7;

writeCompression on;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;
functions
{
    fieldAverage1
    {
        type            fieldAverage;
        functionObjectLibs ( "libfieldFunctionObjects.so" );
        enabled         true;
        cleanRestart        true;
        outputControl   timeStep;
  //      outputControl   outputTime;
        outputInterval  1;
        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

         
        );
    }
}
snappyHex is offline   Reply With Quote

Old   January 28, 2014, 14:28
Exclamation
  #26
Member
 
Join Date: Aug 2012
Posts: 68
Blog Entries: 1
Rep Power: 13
Nucleophobe is on a distinguished road
Quote:
Originally Posted by snappyHex View Post
Hi eelcovv,

Thanks for the utility, it is really helpful!
However I am not getting the results that I would expect.
I have two time directories (0 and 90) and I want to get the average of the U field. Running the application I get the Umean file but the results are not correct,
i.e. U in 0 : (0.1107 -0.0027 0.0006),
U in 90: (0.0036 -0.1216 -0.0004)

and the average I get is: (0.1017 -0.0126 0.0005).
snappyHex,

I know this is an old thread, but I am trying to understand what's going on with the postAverage utility as well. Did you ever resolve the problem?

I tried to replicate your results, but I instead get
(0.075 -0.04233333333 0.0002666666667)
in 90/UMean. Strange.


I tried creating a single-cell mesh with a uniform velocity of (1 0 0) in timestep '0', and a uniform velocity of (2 0 0) in timestep '1'. Rather than a result of (1.5 0 0), I get (1.333333333 0 0)!

I have attached the case for reference (see README file).

Edit: This seems to be the same problem Yann was having:
http://www.cfd-online.com/Forums/ope...tml#post384964

I think the key lies in the 'uniform/time' files saved in each timestep directory; the information in these files (e.g. deltaT) determines how the averaging is performed! Removing all 'uniform' directories via 'rm -r */uniform' (be careful) changes the results for me. However, it's still not quite right.


For now, I am using ParaView's 'Temporal Statistics' filter and saving the resulting data to VTK (Save Data -> .vtm filetype).
Attached Files
File Type: gz postAverageProblem.tar.gz (94.5 KB, 35 views)

Last edited by Nucleophobe; January 29, 2014 at 00:24. Reason: Grammar, update on progress
Nucleophobe is offline   Reply With Quote

Old   January 29, 2014, 15:40
Default postAverage 'bug' fix
  #27
Member
 
Join Date: Aug 2012
Posts: 68
Blog Entries: 1
Rep Power: 13
Nucleophobe is on a distinguished road
All,

EDIT: the original code for postAverage seems to work fine on OpenFOAM/2.2.0/051613. I was having problems with OpenFOAM/2.1.x/071612. If in doubt, check your setup with the case I posted above or something similar.

I have found a solution, but so far it only works if your data is saved at consistent time intervals (1, 2, 3 etc., not 1, 3, 4, 4.5 5.1...).

The utility was counting values from the first timestep twice when computing the average. So, for instance, the average of '1' and '2' was (1 + 1 + 2)/3 = 1.3333 instead of (1 + 2) / 2 = 1.5. This may or may not be a big deal; if you are averaging a lot of data with a small standard deviation, you won't even notice. However, if you are trying to average only a few time directories, it can make a big difference.

I have fixed the problem by subtracting one from the startTime index 'timeI'. You should also clear or move your '(time)/uniform' directories, or else the '(time)/uniform/time' files will mess up the average. Perhaps changing the functionObject options in 'system/controlDict' would make this unnecessary and allow for averaging data saved at inconsistent time intervals, but I have not tried this yet.

Here is my change to postAverage (see bolded line):
Code:
\*---------------------------------------------------------------------------*/

#include "fvCFD.H"

int main(int argc, char *argv[])
{
    argList::noParallel();
    timeSelector::addOptions();

#   include "setRootCase.H"
#   include "createTime.H"

    instantList timeDirs = timeSelector::select0(runTime, args);
    runTime.setTime(timeDirs[0], 0);
#   include "createMesh.H"

    // Cycle through time directories
    forAll(timeDirs, timeI)
    {
       Info<< "Setting startTime index to: " << timeI - 1 << endl;
       // It is important that we set the startTime  index to 'timeI-1' to avoid counting values in the first time directory twice
       runTime.setTime(timeDirs[timeI], timeI - 1);
       Info<< "Adding fields for time " << runTime.timeName() << endl;

#      include "createFields.H"

       runTime.functionObjects().execute();
    }

    Info<< "\nEnd" << endl;


    return 0;
}

// ************************************************************************* //
This is giving me the results I expect. If someone else knows a better way to fix this problem, please chime in!

Good luck,
-Nuc
angelmonsalve and beatlejuice like this.

Last edited by Nucleophobe; January 29, 2014 at 16:58. Reason: Removed lines in code used for debugging; update on OpenFOAM2.2.0
Nucleophobe is offline   Reply With Quote

Old   September 2, 2015, 04:58
Default
  #28
New Member
 
Join Date: Sep 2014
Posts: 11
Rep Power: 11
Cluap is on a distinguished road
Hi everybody !

Thanks eelcovv for this very usefull tool !

However I am now trying to use it with a dynamic mesh case and I am facing some difficulties.
In order to make it work with a mesh changing over the time I've added #include "dynamicFvMesh.H" in the top of the postAverage.C file, I've switched #include "createMesh.H" to #include "createDynamicFvMesh.H" and I've added the line mesh.readUpdate(); in the time loop.
(see the file attached)

When I run the tool it seems to do the calculations but at the end it gives me completely absurd results.

Anybody knows how to make it work correctly with a dynamic mesh ?

Thanks in advance
Attached Files
File Type: c postAverage.C (2.6 KB, 47 views)
Cluap is offline   Reply With Quote

Old   August 8, 2016, 04:53
Default
  #29
Senior Member
 
Manu Chakkingal
Join Date: Feb 2016
Location: Delft, Netherlands
Posts: 129
Rep Power: 10
manuc is on a distinguished road
Hello

Were you able to write the data only at last time step
__________________
Regards
Manu
manuc is offline   Reply With Quote

Old   May 19, 2017, 08:58
Default unable to run the code
  #30
New Member
 
Bimalendu Mahapatra
Join Date: May 2017
Posts: 6
Rep Power: 8
pintu0101 is on a distinguished road
sir,
plz tell me how to run the given code and how to get time averaged pressure or velocity for the whole domain in a dat file.
pintu0101 is offline   Reply With Quote

Old   July 9, 2017, 06:53
Default
  #31
Member
 
Join Date: Sep 2016
Posts: 63
Rep Power: 9
sitajeje is on a distinguished road
The standard fieldAverage utility in OpenFOAM4.0 with the command "simpleFoam -postProcess" can also do this postAverage job.
sitajeje is offline   Reply With Quote

Old   December 24, 2020, 04:31
Default time average over the all time steps stored in the case file
  #32
Member
 
Arash Mahboubidoust
Join Date: Jun 2013
Location: Iran
Posts: 58
Rep Power: 12
arashfluid is on a distinguished road
Send a message via Yahoo to arashfluid
Dear friends
I want to calculate the average of a variable like a tau over the time steps saved in the case file, and finally, get a Tau_mean file that is the time-average of all stored time steps in the last time directory. How can I do this with the postAverage tool?
arashfluid is offline   Reply With Quote

Old   May 17, 2022, 09:55
Default Extract Data from field average
  #33
New Member
 
zink
Join Date: Oct 2015
Posts: 29
Rep Power: 10
ansab_sindhu is on a distinguished road
Hi,

I have stored Tmean from 500 seconds to 1500 seconds using the field average function object. But, in the time directories, I have stored only last 50 time steps using the purge write option in the control dict.

Can I use this utility to extract field (Tmean) from 1000 seconds to 1500 seconds using post processing. Please note that I have time directories stored from 1450 to 1500.

Really appreaite if anyone can comment.
ansab_sindhu is offline   Reply With Quote

Reply

Tags
fieldaverage, library average, postprocessing


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
Average Facet, Surface Vertex or Area-Weighted Emmanuel FLUENT 3 March 27, 2020 10:55
problem loading UDF library in parallel cluster Veera Gutti FLUENT 8 July 26, 2016 07:24
To compute Average flowfield with oodles flying OpenFOAM Running, Solving & CFD 3 May 5, 2009 08:46
OpenFOAM141dev linking error on IBM AIX 52 matthias OpenFOAM Installation 24 April 28, 2008 15:49
Help! I cann't make library Bowling FLUENT 5 May 12, 2004 04:56


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