CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Run function objects on final time (https://www.cfd-online.com/Forums/openfoam-post-processing/232374-run-function-objects-final-time.html)

b.simpson December 11, 2020 07:15

Run function objects on final time
 
Hi all,

I am running a range of natural ventilation simulations. I have a handful of function objects and two surfaces files that I want to run on the final time/iteration of the simulation once my convergence criteria has been met.

The problem I am having is that when the simulation converges some of my function objects and my two surface files are not getting updated with the results from the final simulation time. The probes and residual function objects are updated correctly at the end of the simulation but my four volFieldValue, FieldMinMax and surface files are not.

Does anyone know if there is a method by which I can either get my simulation to run all my function objects at time of convergence or re-run them after the simulation has finished?

The postProcessing folder is updated correctly with all my function objects and surface files values at the declared writeIntervals in the controlDict. Ideally, I want to find a way for the simulation to automatically update the postProcessing folder at the end of the simulation instead of me having to manually change the writeInterval when the simulation gets close to converging.

I have looked into the postProcess tool but when I use the -list command their is no volFieldValue in the list of function objects. So I am not sure if that function object is available for use with the postProcess tool.

I am using OpenFOAM 8 on Ubuntu 18.04.2. I am running buoyantSimpleFoam in parallel on 6 processors. My simulations are converging correctly and the reconstruct process appears to be working as intended.

Thank you in advance for any support you can provide me.

Kind regards,

Ben

My controlDict:
Code:

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

application    buoyantSimpleFoam;

startFrom      latestTime;

startTime      0;

stopAt          endTime;

endTime        10000;

deltaT          1;

writeControl    timeStep;

writeInterval  1000;

purgeWrite      3;

writeFormat    ascii;

writePrecision  8;

writeCompression off;

timeFormat      general;

timePrecision  6;

runTimeModifiable true;

functions
{
        #include "surfaces"
        #include "surfaces2"
         
        CO2
                {
                        type                            scalarTransport;
                        libs                                ("libsolverFunctionObjects.so");
                        writeControl              timeStep;
                        writeInterval              1;
                        active                  true;
                        autoSchemes            false;
                        nCorr                  0;
                        resetOnStartUp                false;
                        field                                CO2;
                        fvOptions     
                        {
                       
                        }
                }
               
        comfortAnalysis
                {
                        type            comfort;
                        libs            ("libfieldFunctionObjects.so");
                       
                        metabolicRate        1.2;
                        clothing                0.7;
                        extWork                        0.0;

                        executeControl  writeTime;
                        writeControl    writeTime;

                }
               
        AoA
                {
                        type    scalarTransport;
                        libs        ("libutilityFunctionObjects.so");
                        enabled true;
                        writeControl writeTime;
                        log yes;
                        nCorr 1;

                        field AoA;
                        active          true;
                        autoSchemes    false;
                        resetOnStartUp false;
                        DT              1e-5;
                        nCorr 0;

                        fvOptions
                        {
                                IncrementTime
                                {
                                        type            semiImplicitSource;
                                        active          true;
                                        selectionMode all;
                                        volumeMode  specific;
                                        sources
                                        {
                                                AoA
                                                {
                                                        explicit 1;
                                                        implicit 0;
                                                }
                                        }
                                }
                        }
                }
               
        fieldMinMax
                {
                        type                fieldMinMax;
                        libs                                  ("libfieldFunctionObjects.so");
                        log                yes;
                        writeControl              writeTime;
                        //writeInterval              1;
                        //mode              magnitude;
                        fields                    ( U p T rho CO2 AoA);
                }
               
        breathingZoneAverages
                {
                        type            volFieldValue;
                        libs            ("libfieldFunctionObjects.so");
                        log                                true;
                        writeControl    writeTime;
                        writeFields                true;
                       
                        regionType                cellZone;
                        name                        breathingZone;
                       
                        operation                volAverage;

                        fields
                        (
                                T
                                CO2
                                U
                                PMV
                                PPD
                                AoA
                        );
                }
               
        breathingZoneValuesAvg
                {
                        type            volFieldValue;
                        libs            ("libfieldFunctionObjects.so");
                        log                                true;
                        writeControl    writeTime;
                        writeFields                true;
                       
                        regionType                cellZone;
                        name                        breathingZone;
                       
                        operation                average;

                        fields
                        (
                                T
                                CO2
                                U
                                PMV
                                PPD
                                AoA
                        );
                }
               
        breathingZoneValuesSum
                {
                        type            volFieldValue;
                        libs            ("libfieldFunctionObjects.so");
                        log                                true;
                        writeControl    writeTime;
                        writeFields                true;
                       
                        regionType                cellZone;
                        name                        breathingZone;
                       
                        operation                sum;

                        fields
                        (
                                CO2
                        );
                }
       
        spaceAverage
                {
                        type            volFieldValue;
                        libs            ("libfieldFunctionObjects.so");
                        log                                true;
                        writeControl    writeTime;
                        writeFields                true;
                       
                        regionType                cellZone;
                        name                        spaceZone;
                       
                        operation                volAverage;

                        fields
                        (
                                T
                                CO2
                                U
                                AoA
                        );
                }
       
        residuals
    {
        type            residuals;
        functionObjectLibs ("libutilityFunctionObjects.so");
        enabled        true;
        writeControl  timeStep;
        writeInterval  1;

        fields
        (
            p_rgh
            U
            k
            omega
                        CO2
                        e
        );
    }
       
        probes
    {
        type            probes;
        libs            ("libsampling.so");
        writeControl    timeStep;
        writeInterval  1;

        fields
        (
            p_rgh
                        U
                        T
                        CO2
                        k
                        omega
        );

        probeLocations
        (
            (2.55 1.3 1.5)                //convergence point
        );

    }
}

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

My surface file:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v1812                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/

surfaces
{
    type            surfaces;
    libs            ("libsampling.so");
    writeControl    writeTime;

    surfaceFormat  raw;
    fields          (U T CO2 AoA);

    interpolationScheme cell;

    surfaces
    (
                NorthSlice
        {
            type            cuttingPlane;
            planeType      pointAndNormal;
            pointAndNormalDict
            {
                point  (0 5.15 0);
                normal  (0 1 0);
            }
            interpolate    false;
        }
                SouthSlice
        {
            type            cuttingPlane;
            planeType      pointAndNormal;
            pointAndNormalDict
            {
                point  (0 0.05 0);
                normal  (0 1 0);
            }
            interpolate    false;
        }               
    );
}


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


saurabh1011 September 15, 2022 04:43

Hi,


Did you find solution to your problem? I have the same problem.

b.simpson September 16, 2022 06:19

Hi,

I was unable to find a perfect solution to this problem. So what I have done is after the simulation has converged but before performing the reconstruction tasks I re-ran the solver (buoyantSimpleFoam in my case) but with an edited/updated controlDict file.

In the controlDict, I made sure the startFrom was set to latestTime. I removed the startTime and set the writeInterval to 10. I also increased the endTime abit (by 200 in my case) just in case the simulation didn't converge.

This then re-ran buoyantSimpleFoam from the converged solution but writing all my results every 10 iterations. My simulations usual re-converged very quickly, so it didn't take me too much extra time. Then when they re-converged I had results written out within a few iterations of the final convergence.

This does not seem like a proper solution to the problem but it was the best work around I was able to come up with.

I will include my edited/second controlDict in case that helps, but it will be abit different as my models have changed abit since I created this thread.

I hope this helps.

Regards,

Ben

Code:

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

application    buoyantSimpleFoam;

startFrom      latestTime;

stopAt          endTime;

endTime        5200;

deltaT          1;

writeControl    timeStep;

writeInterval  10;

purgeWrite      3;

writeFormat    ascii;

writePrecision  8;

writeCompression off;

timeFormat      general;

timePrecision  6;

runTimeModifiable true;

/*libs (
      "libOpenFOAM.so"
      "libsimpleSwakFunctionObjects.so"
      "libswakFunctionObjects.so"
      "libgroovyBC.so"
    );*/

functions
{
        #include "surfaces"
        #include "surfaces2"
         
        CO2
                {
                        type                            scalarTransport;
                        libs                                ("libsolverFunctionObjects.so");
                        writeControl              timeStep;
                        writeInterval              1;
                        active                  true;
                        autoSchemes            false;
                        nCorr                  0;
                        resetOnStartUp                false;
                        field                                CO2;
                        fvOptions     
                        {
                                generalSource
                                {
                                        type            semiImplicitSource;
                                        active          true;
                                        selectionMode        cellZone;
                                        cellZone                spaceZone;
                                        volumeMode                absolute;
                                        sources
                                        {
                                                CO2
                                                {
                                                        explicit        1;
                                                        implicit        0;
                                                }
                                        }
                                }
                        }
                }
               
        comfortAnalysis
                {
                        type            comfort;
                        libs            ("libfieldFunctionObjects.so");
                       
                        metabolicRate        1.2;
                        clothing                0.7;
                        extWork                        0.0;

                        executeControl  writeTime;
                        writeControl    writeTime;

                }
               
        AoA
                {
                        type    scalarTransport;
                        libs        ("libutilityFunctionObjects.so");
                        enabled true;
                        writeControl writeTime;
                        log yes;
                        nCorr 1;

                        field AoA;
                        active          true;
                        autoSchemes    false;
                        resetOnStartUp false;
                        DT              1e-5;
                        nCorr 0;

                        fvOptions
                        {
                                IncrementTime
                                {
                                        type            semiImplicitSource;
                                        active          true;
                                        selectionMode all;
                                        volumeMode  specific;
                                        sources
                                        {
                                                AoA
                                                {
                                                        explicit 1;
                                                        implicit 0;
                                                }
                                        }
                                }
                        }
                }
       
        fieldMinMax
                {
                        type                fieldMinMax;
                        libs                                  ("libfieldFunctionObjects.so");
                        log                true;
                        writeControl              writeTime;
                        //writeInterval              1;
                        //mode              magnitude;
                        fields                    ( U p T rho CO2 AoA);
                }
               
        breathingZoneAverages
                {
                        type            volFieldValue;
                        libs            ("libfieldFunctionObjects.so");
                        log                                true;
                        writeControl    writeTime;
                        writeFields                true;
                       
                        regionType                cellZone;
                        name                        breathingZone;
                       
                        operation                volAverage;

                        fields
                        (
                                T
                                CO2
                                U
                                PMV
                                PPD
                                AoA
                        );
                }
               
        breathingZoneValuesAvg
                {
                        type            volFieldValue;
                        libs            ("libfieldFunctionObjects.so");
                        log                                true;
                        writeControl    writeTime;
                        writeFields                true;
                       
                        regionType                cellZone;
                        name                        breathingZone;
                       
                        operation                average;

                        fields
                        (
                                T
                                CO2
                                U
                                PMV
                                PPD
                                AoA
                        );
                }
               
        breathingZoneValuesSum
                {
                        type            volFieldValue;
                        libs            ("libfieldFunctionObjects.so");
                        log                                true;
                        writeControl    writeTime;
                        writeFields                true;
                       
                        regionType                cellZone;
                        name                        breathingZone;
                       
                        operation                sum;

                        fields
                        (
                                T
                                CO2
                                U
                                PMV
                                PPD
                                AoA
                        );
                }
       
        spaceVolAverage
                {
                        type            volFieldValue;
                        libs            ("libfieldFunctionObjects.so");
                        log                                true;
                        writeControl    writeTime;
                        writeFields                true;
                       
                        regionType                cellZone;
                        name                        spaceZone;
                       
                        operation                volAverage;

                        fields
                        (
                                T
                                CO2
                                U
                                AoA
                        );
                }
               
        spaceAverage
                {
                        type            volFieldValue;
                        libs            ("libfieldFunctionObjects.so");
                        log                                true;
                        writeControl    writeTime;
                        writeFields                true;
                       
                        regionType                cellZone;
                        name                        spaceZone;
                       
                        operation                average;

                        fields
                        (
                                T
                                CO2
                                U
                                AoA
                        );
                }
       
        residuals
    {
        type            residuals;
        functionObjectLibs ("libutilityFunctionObjects.so");
        enabled        true;
        writeControl  timeStep;
        writeInterval  1;

        fields
        (
            p_rgh
            U
            nuTilda
                        CO2
                        e
                        AoA
        );
    }
       
        probes
    {
        type            probes;
        libs            ("libsampling.so");
        writeControl    timeStep;
        writeInterval  1;

        fields
        (
            p_rgh
                        U
                        T
                        CO2
                        nuTilda
                        AoA
        );

        probeLocations
        (
            (1.6 3.1 2)                //convergence point Occ1
                        (3.1 3.1 2)                //convergence point Center
                        (4.6 3.1 2)                //convergence point Occ2
        );

    }
}

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


saurabh1011 September 19, 2022 20:09

Hi,


Thanks for the reply. Your solution might work for me even though it is not the best one.



Have a nice day!


All times are GMT -4. The time now is 16:51.