CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Not continuous averaging when restarting a calculation (http://www.cfd-online.com/Forums/openfoam/119520-not-continuous-averaging-when-restarting-calculation.html)

nik June 19, 2013 04:22

Not continuous averaging when restarting a calculation
 
1 Attachment(s)
Hi to all,

I am using the fieldAverage function to calculate average quantities. I am using an updated version of OpenFOAM 2.2.x with the necessary fixes for the restarting to work, since there was a bug in the code (see http://www.openfoam.org/mantisbt/view.php?id=854). Restarting works just fine, my problem is that when I restart from a previous calculation, it seems that the averaging is not continuous as it should be. In order to look at the time evolution of a mean value I am using the probeFunction.

I can reproduce my problem using the cavity tutorial. I start averaging from the beginning up to 0.5 sec of simulation time. Then I restart the simulation for another 0.5 sec. Below are the functions objects used at the end of the controlDict:

Code:

functions
{
    fieldAverage1
    {
        type            fieldAverage;
        functionObjectLibs ( "libfieldFunctionObjects.so" );
        enabled        true;
        outputControl  outputTime;
        resetOnOutput  false;
        resetOnRestart  false;

        fields
        (
            p
            {
                mean        on;
                prime2Mean  off;
                base        time;
            }
        );
    }

    probesP
    {
        type probes;
        functionObjectLibs ("libsampling.so");
        probeLocations
        (
            (0.05 0.05 0.0)
        );

        fields
        (
            p pMean
        );
    }
}

I have also attached a figure showing the evolution of pMean with time, at a x=0.05, y=0.05 using the data from the probe function. This figure shows the discontinuous change in the evolution of the mean value, at t=0.5.

Am I doing something wrong with the flags that I am using, or is this a bug?

Thanks,
Nicolas

Bernhard June 19, 2013 10:31

Did you cross-check with calculating the running mean of the sampled pressure itself?

nik June 20, 2013 03:04

1 Attachment(s)
I have attached another figure showing the calculated running average of pressure, based on the values of pressure taken from the probe.

As you can see in the calculated running average there is no discontinuity. However, I can reproduce the discontinuity of pMean shown from the probes values, if I restart the averaging in my calculations, at t=0.5.

To me it is clear, that openFoam restarts the averaging of pMean that is written in the probes. My question is why, since I am telling it not to.

Code:

resetOnRestart  false;
resetOnOutput  false;

Nicolas

h.ono July 6, 2013 21:59

3 Attachment(s)
I encountered the same problem. I noticed that issue by using Prime2Mean option. Prime2Mean value was always reseted to 0 when restarting.

I can reproduce my problem using the pisoFoam/pitzDaily tutorial like Nik done. I start averaging from the beginning up to 0.4 sec . Then I restart the simulation for another 0.4 sec.
When I use 2.2.0, this problem has not appeared. but in 2.2.x (latest), it comes.

I found that Foam::fieldAverage::initialize() function was not loaded in Foam::fieldAverage::read() in 2.2.x. and it will be loaded at 1st time call of Foam::fieldAverage::calcAverage().

https://github.com/OpenFOAM/OpenFOAM...fieldAverage.C
https://github.com/OpenFOAM/OpenFOAM...fieldAverage.C

So, mean and P2Mean values will reset after calculation started.

I thought call of initialize() must be in Foam::fieldAverage::read().
I have tested to fix them with changing code as shown below.

Code:


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

void Foam::fieldAverageFixed::read(const dictionary& dict)
{
    if (active_)
    {
        initialised_ = false;

        dict.readIfPresent("resetOnRestart", resetOnRestart_);
        dict.readIfPresent("resetOnOutput", resetOnOutput_);
        dict.lookup("fields") >> faItems_;

        readAveragingProperties();
    }

    if (!initialised_)
    {
        initialize();
    }


}


void Foam::fieldAverageFixed::execute()
{
    if (active_)
    {
        calcAverages();
    }
}

In my case, it seems to work fine. averaged values are same as using 2.2.0.
But I don't know whether it is truly correct or not.
Please check and post if something is wrong.

nik July 23, 2013 07:43

Dear Hiroki Ono,

thank you very much for the reply and suggested fix. Sorry for the late response but I had reported this bug to OpenFOAM and I was waiting for an official answer. I just got a reply that the issue has been fixed in the new version of 2.2.x. I guess based on your fix.

This thread is located at:
http://www.cfd-online.com/Forums/ope...-new-post.html

Regards,
Nicolas


All times are GMT -4. The time now is 17:38.