CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   fieldAverage fails to continue averaging the fields (https://www.cfd-online.com/Forums/openfoam-programming-development/163903-fieldaverage-fails-continue-averaging-fields.html)

FernandoSoares December 7, 2015 16:10

fieldAverage fails to continue averaging the fields
 
2 Attachment(s)
Hi there dear Foamers,

I am currently running some simple LES cases and I wish to, during runTime, average some fields of interest. For instance I'm using fieldAverage in my controlDict in the following way

Code:

funtions
{
    fieldAverage
    {
        type                    fieldAverage;
        functionObjectLibs      ("libfieldFunctionObjects.so");
        enabled                true;
        cleanRestart            false;
        outputControl          outputTime;
        resetOnOutput          false;
        resetOnRestart          false;
        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            p
            {
              mean        on;
              prime2Mean  off;
              base        time;
            }

        );
    }
}

Right now I face multiple 'sudden-stops' here at the University and every time I restart the simulation from its latestTime the averages, specially UPrime2Mean, start all over again. How could I avoid such an issue? Am I setting the controlDict (functions) incorrectly?

Could any expert or someone who has already experienced a similar situation advise me?

Thanks in advance and best regards,

F. Soares.

wyldckat December 8, 2015 04:12

Quick answer: I vaguely remember there was a bug related to this in one of OpenFOAM's older versions. I've found the bug report for it: http://www.openfoam.org/mantisbt/view.php?id=898

Which version of OpenFOAM are you using?

FernandoSoares December 8, 2015 07:48

Sorry, I should have attached the other threads I was reading about this issue. I currently use OpenFOAM 2.4.x.

wyldckat December 8, 2015 07:56

A few quick questions:
  1. Does your "controlDict" really have then entry named "funtions", or did you only mistype here on the post? Notice that it's missing a "c".
  2. Do you know which is the latest commit of 2.4.x you have? You can check with the following command:
    Code:

    blockMesh -help
    the hash number is shown near the end, associated to the version number.
  3. Can you provide a quick test case with which this issue can be reproduced? For example, can you reproduce this with one of the tutorial cases from OpenFOAM?

FernandoSoares December 8, 2015 12:30

According to 'blockMesh -help' I am currently

Code:

Using: OpenFOAM-2.4.x (see www.OpenFOAM.org)
Build: 2.4.x-e713234c04f6

Sorry about that, typo common mistake. My controlDict file is

Code:

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

application    pisoFoam;

startFrom      startTime;

startTime      200;

stopAt          endTime;

endTime        3000;

deltaT          2e-04;

writeControl    adjustableRunTime;

writeInterval  0.25;

purgeWrite      1;

writeFormat    ascii;

writePrecision  6;

writeCompression uncompressed;

timeFormat      general;

timePrecision  6;

runTimeModifiable yes;

adjustTimeStep  on;

maxCo          0.250000;

maxDeltaT      0.001500;



functions
{
 
    fieldAverage1
    {
        type                fieldAverage;
        functionObjectLibs    ("libfieldFunctionObjects.so");
        enabled            true;
        cleanRestart        false;
        outputControl      outputTime;
        resetOnOutput      false;
        resetOnRestart      false;
        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            p
            {
              mean        on;
              prime2Mean  off;
              base        time;
            }

        );
    }


   
    epsilon
    {
      type              epsilonTsr;
        UName          U;
        UMeanName      UMean;
        functionObjectLibs ("myTurbFieldsFunctionObjects.so");
        enabled        true;
        outputControl  outputTime;
    } 

    epsilonTrue
    {
        type              epsilonTsrTrue;
        UName          U;
        UMeanName      UMean;
        functionObjectLibs ("myTurbFieldsFunctionObjects.so");
        enabled        true;
        outputControl  outputTime;
    } 

    pStrain
    {
        type              pStrain;
        UName          U;
        UMeanName      UMean;
        pName            p;
        pMeanName        pMean;
        functionObjectLibs ("myTurbFieldsFunctionObjects.so");
        enabled        true;
        outputControl  outputTime;
    }

    pU
    {
        type            pU;
        UName          U;
        UMeanName      UMean;
        pName            p;
        pMeanName        pMean;
        functionObjectLibs ("myTurbFieldsFunctionObjects.so");
        enabled        true;
        outputControl  outputTime;
    }

    triU
    {
        type            triU;
        UName          U;
        UMeanName      UMean;
        functionObjectLibs ("myTurbFieldsFunctionObjects.so");
        enabled        true;
        outputControl  outputTime;
    }


    fieldAverage2
    {
        type                fieldAverage;
        functionObjectLibs    ("libfieldFunctionObjects.so");
        enabled                true;
        cleanRestart            false;
        outputControl          outputTime;
        resetOnOutput          false;
        resetOnRestart          false;
        fields
        ( 
        epsilonTsr
        {
        mean        on;
        prime2Mean  off;
        base        time;
        }

        epsilonTsrTrue
        {
        mean        on;
        prime2Mean  off;
        base        time;
        }

        pStrain
        {
        mean        on;
        prime2Mean  off;
        base        time;
        }

        pU
        {
        mean        on;
        prime2Mean  off;
        base        time;
        }

        triU
        {
        mean        on;
        prime2Mean  off;
        base        time;
        }
        );
  }



    probes
    {
        type            probes;
        functionObjectLibs ("libsampling.so");
        enabled        true;
        outputControl  timeStep;
        outputInterval  10;

        fields
        (
        // inst fields
    /*
        U       
        p
        k
    */
        // mean fields
   
        UMean
            pMean
        UPrime2Mean
        epsilonTsrMean
        epsilonTsrTrueMean
        pStrainMean
        pUMean
        triUMean       
   
        );

        probeLocations
        (
        (0.125 0.95 0)
        (0.250 0.95 0)
        (0.375 0.95 0)
        (0.500 0.95 0)
        (0.625 0.95 0)
        (0.750 0.95 0)
        (0.875 0.95 0)

        (0.125 0.85 0)
        (0.250 0.85 0)
        (0.375 0.85 0)
        (0.500 0.85 0)
        (0.625 0.85 0)
        (0.750 0.85 0)
        (0.875 0.85 0)

        (0.125 0.7 0)
        (0.250 0.7 0)
        (0.375 0.7 0)
        (0.500 0.7 0)
        (0.625 0.7 0)
        (0.750 0.7 0)
        (0.875 0.7 0)

        (0.125 0.6 0)
        (0.250 0.6 0)
        (0.375 0.6 0)
        (0.500 0.6 0)
        (0.625 0.6 0)
        (0.750 0.6 0)
        (0.875 0.6 0)
        );

    }

}

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

The other fields I am trying to take averages are related to the transport of the Reynolds stress. So I'm in fact doing two averages in my simulation: fieldAverage1 and fieldAverage2.

Once again thank you for your time and patience Mr. Santos,

F. Soares.

FernandoSoares December 8, 2015 13:39

I forgot to address a similar tutorial in my last reply. In $FOAM_TUTORIALS/incompressible/pisoFoam/les/pitzDaily there is a similar structure to the case I am trying to run here. However modifying the controlFidct file

Code:

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

application    pisoFoam;

//startFrom      startTime;
startFrom      latestTime;

startTime      0;

stopAt          endTime;

//endTime        10e-05;
endTime        20e-05;

deltaT          1e-05;

writeControl    timeStep;

writeInterval  1;

purgeWrite      1;

writeFormat    ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision  6;

runTimeModifiable true;

functions
{
    fieldAverage1
    {
        type            fieldAverage;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled        true;
        outputControl  outputTime;
        timeStart      3e-05;
        fields
        (
            U
            {
                mean        on;
                prime2Mean  off;
                base        time;
            }

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

    fieldAverage2
    {
        type            fieldAverage;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled        true;
        outputControl  outputTime;
        timeStart      9e-05;
        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;                base        time;
            }
        );
    }
}

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

so to use fieldAverage twice (one for obtaining p and U mean field and another for UPrime2Mean) doesn't seem to yield the problem I've been having all this time. According to the log after restarting the simulation under the programmed stop

Code:

Starting time loop

fieldAverage fieldAverage1:
    Restarting averaging for fields:
        U iters = 5 time = 5e-05

fieldAverage fieldAverage2:
    Restarting averaging for fields:
        U iters = 5 time = 5e-05

Apparently OF is working for this specific tutorial. Any ideas why?

wyldckat December 8, 2015 15:43

Hi F. Soares,

This is starting to look like it's a somewhat severe bug. The case you prepared with the tutorial has the function objects prepared differently and that could be enough for the first one to not conflict with the second one, given that you gave two different start times and different averaging mechanisms.

And I went looking for bug reports about "fieldAverage" and found the following issue still open: http://www.openfoam.org/mantisbt/view.php?id=1336 - it seems to be related to your issue.

I'm adding this to my to-do list for the upcoming weekend. If you can figure out a way to reproduce this issue with the tutorial case, it would help a lot in isolating the origin of the problem and to fix it.
The other possibility for the origin of this bug is if you are running in parallel at the University, which could potentially also bring up other problems.

Best regards,
Bruno


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