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

Time averaged fields on a defined time range

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

Like Tree5Likes
  • 2 Post By Yann
  • 3 Post By Bernhard

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 2, 2012, 13:44
Default Time averaged fields on a defined time range
  #1
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,233
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
Hi FOAMers,

Here is my problem : I have transient RANS simulations of a two-phase flow (using VOF method) and I would like to calculate the time averaged fields on a defined time range, let's say from t=50s to t=100s.
How can I do that ?

In paraView, the temporalStatistics filter achieve this task but only for all time steps and I cannot specify my own time range.

In OpenFOAM, I tried to use the fieldAverage utility from the fieldFunctionObjects library, using this code in my controlDict :

Code:
fieldAverage1
     {
         type                    fieldAverage;
         functionObjectLibs ( "libfieldFunctionObjects.so" );
         enabled                true;
         outputControl        outputTime;
 
         fields
         (
             U
             {
                 mean          on;
                 prime2Mean  on;
                 base           time;
             }
 
             alpha1
             {
                 mean           on;
                 prime2Mean  on;
                 base           time;
             }
         );
    }
When I re-run a part of my simulation with this function enabled, it works well. In the "case/timeStep/uniform/fieldAveragingProperties" file, the "totalTime" corresponds to the time from the start of the function and it grows accordingly to time steps which is totally logical. The averaged fields seem ok too.

But my problem is to use this function on cases already done.
Using execFlowFunctionObjects with the -noFlow option, I am able to run it after the end of my simulation, but it seems the mean variables written on each time steps start over and don't use the previous values.
For each time step, i have the same "totalTime" values in the "fieldAveragingProperties".

Does anybody have already experienced that kind of problem ? Did I miss a trick somewhere ?

More generally, wanting an averaged field on a defined time range doesn't sound so exotic... Is there somebody who know how to do that in OpenFOAM or paraView ?

Thank you,
Yann
Nucleophobe and kk415 like this.
Yann is offline   Reply With Quote

Old   October 3, 2012, 02:58
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
I don't know which version of OpenFOAM you are using, but fieldAverage later got some additional options:
- resetOnOutput
- timeStart
- timeEnd

See also: http://www.openfoam.org/mantisbt/view.php?id=290
Pagoda, kk415 and Atzori like this.
Bernhard is offline   Reply With Quote

Old   October 3, 2012, 11:00
Default
  #3
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,233
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
Thank you Benhard for your reply. I'm using OF 2.1.0 and I wasn't aware of these additional options which are really useful to control run-time post-processing.

I tried to dig into this problem by testing some things on the damBreak case. I just ran it from 0 to 5s and I set a fieldAverage from 2s to the end thanks to the timeStart and timeEnd options. Here is an extract of my controlDict.

Code:
application     interFoam;
startFrom       startTime;
startTime       0;
stopAt          endTime;
endTime         5;
deltaT          0.001;
writeControl    adjustableRunTime;
writeInterval   0.1;

runTimeModifiable yes;
adjustTimeStep  on;

functions
    {

    fieldAverage1
        {
            type                    fieldAverage;
            functionObjectLibs ( "libfieldFunctionObjects.so" );
            enabled               true;
            outputControl       outputTime;
            timeStart             2;
            timeEnd               5;
            resetOnOutput     false;
                
            fields
            (
                U
                {
                    mean           on;
                    prime2Mean  on;
                    base           time;
                }

                alpha1
                {
                    mean           on;
                    prime2Mean  on;
                    base           time;
                }
            );
        }
    }
The fieldAverage works very well and the mean variables start to be calculated at t=2s, as expected.
Here is what I have in the fieldAveragingProperties of the last timestep :

Code:
U
{
    totalIter        275;
    totalTime       3.00798;
}

alpha1
{
    totalIter        275;
    totalTime       3.00798;
}
The mean variables of the last timestep are calculated on t=5-2=3s, which is exactly what I wanted.

Now, I run the same simulation without fieldAverage and I try to run it as a post-processing tool after the end of my simulation thanks to this command :

Code:
execFlowFunctionObjects -noFlow
The mean variables are actually calculated from t=2 to 5s, but there is something wrong with the calculation. If I look in the fieldAveragingProperties of the last timestep, I find that :

Code:
U
{
    totalIter       2;
    totalTime       0.0285714;
}

alpha1
{
    totalIter       2;
    totalTime       0.0285714;
}
The mean variables aren't calculated with the whole time range but only the last timesteps. As I have 30 saved timesteps from 2 to 5s, i would expect to have mean variables calculated on 30 iterations with a totalTime of 3s.

Am I having a wrong use of the execFlowFunctionObjects ? Should I use or don't use some options ? Or is the fieldAverage function unable to work after the simulation run ?
Yann is offline   Reply With Quote

Old   October 3, 2012, 11:36
Default
  #4
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
Quote:
Originally Posted by Yann View Post
But my problem is to use this function on cases already done.
Hello,

to use functionObjects on cases already finished there is also this:

http://www.cfd-online.com/Forums/ope...revisited.html

However, this seems quite similar to execFlowFunctionsObjects.
GerhardHolzinger is offline   Reply With Quote

Old   October 4, 2012, 15:01
Default
  #5
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,233
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
Thank you Gerhard.
I've run some tests with your utility and I still have an issue on my averaged fields compared to run-time post-processing with fieldAverage.

I run the damBreak case from t=0 to 5s.

For the first case, I use fieldAverage for run-time post-processing, starting from 0. Here is what is in the fieldAveragingProperties file of the last time step:

Code:
    location    "5/uniform";
    object      fieldAveragingProperties;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

U
{
    totalIter       2249;
    totalTime       5.001;
}

alpha1
{
    totalIter       2249;
    totalTime       5.001;
}
Umean and alpha1Mean are indeed calculated on a time range of 5s, which is what I was expecting.

Now, if I run the same simulation without fieldAverage and if I use the postAverage utility for post-processing, the averaged fields aren't calculated on the whole time range of 5s :

Code:
    location    "5/uniform";
    object      fieldAveragingProperties;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

U
{
    totalIter       51;
    totalTime       0.435901;
}

alpha1
{
    totalIter       51;
    totalTime       0.435901;
}
the totalIter is ok : 51 is the number of saved time step (every 0.1s from 0 to 5), but the totalTime doesn't seem ok as I would be expecting to find 5s as for the first case.
I don't understand why totalIter is ok and not totalTime.

To run the postAverage utility, I defined the fieldAverage function in the controlDict :

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

application     interFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         5;

deltaT          0.001;

writeControl    adjustableRunTime;

writeInterval   0.1;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression uncompressed;

timeFormat      general;

timePrecision   6;

runTimeModifiable yes;

adjustTimeStep  on;

maxCo           0.2;
maxAlphaCo      0.2;

maxDeltaT       1;

functions
    {

    fieldAverage1
        {
            type            fieldAverage;
            functionObjectLibs ( "libfieldFunctionObjects.so" );
            enabled         true;
            outputControl   timeStep;
            timeStart        0.1;
            timeEnd            5;
    
            fields
            (
                U
                {
                    mean        on;
                    prime2Mean  on;
                    base        time;
                }

                alpha1
                {
                    mean        on;
                    prime2Mean  on;
                    base        time;
                }
            );
        }
    }



// ************************************************************************* //
Then I run postAverage with this command :

Code:
postAverage -noZero
So it seems I've made a mistake somewhere or I don't use the utility properly.
Just to be sure : if I run the utility on all time steps, the mean values of the last time step should be the average of all time steps together no ?


Yann is offline   Reply With Quote

Old   October 10, 2012, 19:36
Default
  #6
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,233
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
Hi all,

I finally solved my problem with another solution. As I'm unable to obtain what i want with OpenFOAM utilities, I just wrote a shell script to add underscores to the name of the time steps directories that I don't want to average.
So paraFoam just see the time steps I want and I can average them with the temporalStatistics filter.

It isn't an elegant way to do it, but it's doing the job so I'll go for that unless somebody has a better idea.

Thanks to Bernhard and GerhardHolzinger for their ideas and help.
Yann is offline   Reply With Quote

Old   October 15, 2012, 05:30
Default
  #7
Senior Member
 
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19
eelcovv is on a distinguished road
Hi Yann,

I struggeled with the same issue a while ago and wrote a utility for it. You can donwload it from the tread below. Probably needs some modification for you case (the fields to be averaged need to be hard coded), but that should be doable

Regards
Eelco

http://www.cfd-online.com/Forums/ope...rocessing.html
eelcovv is offline   Reply With Quote

Old   November 19, 2014, 09:52
Default
  #8
Senior Member
 
Muhammad Waqas
Join Date: Jul 2014
Location: Germany
Posts: 122
Rep Power: 12
mwaqas is on a distinguished road
Send a message via Skype™ to mwaqas
Hello Everyone

I am beginner in OpenFoam, may be my question looks very busy, I am sorry for that.
I am using fieldAverage to get time-averaged of velocity. I get the time-averaged file in respective time step folder but I don't know how can I view this average field using paraview. When I load my case to paraview, it shows only entities which are present in "0" folder. It does not show averaged field i.e. UMean

Regards
Waqas
mwaqas is offline   Reply With Quote

Old   August 7, 2019, 05:46
Default fieldAverage in a period of time
  #9
Senior Member
 
A. Min
Join Date: Mar 2015
Posts: 308
Rep Power: 12
alimea is on a distinguished road
Hi foamers,

I wanted to average some fields on a period of time (t=0 to t=10s) with fieldAverage FO. However, it gives me the field average in every time step! e.g., in t=5! So, when the period is not finished, what is this average in t=5s?

In addition, I want to average stream function in this period of time which is calculated using "streamFunction" command and is not a common field obtain by solver! What should I do?

Thanks
alimea is offline   Reply With Quote

Reply

Tags
fieldaverage, openfoam, paraview, time averaged

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple floating objects CKH OpenFOAM Running, Solving & CFD 14 February 20, 2019 10:08
separate .vtk files + OpenFOAM fields: synchronous time tomislav_maric OpenFOAM Post-Processing 4 November 21, 2011 10:34
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 05:03
OpenFOAM static build on Cray XT5 asaijo OpenFOAM Installation 9 April 6, 2011 13:21
Modeling in micron scale using icoFoam m9819348 OpenFOAM Running, Solving & CFD 7 October 27, 2007 01:36


All times are GMT -4. The time now is 05:25.