CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Use of function objects to terminate transient simulations (https://www.cfd-online.com/Forums/openfoam-solving/193868-use-function-objects-terminate-transient-simulations.html)

Luca Cornolti October 5, 2017 08:51

Use of function objects to terminate transient simulations
 
I'm running a free surface problem with the interFoam solver of OpenFOAM v1706.

Schematically, the geometry can be described as a cylindrical tank with an open surface at the top, an outlet duct on the side surface and a inlet on the bottom surface.

From the inlet, I'm filling the tank only with water.
From the outlet duct both air and water flow out, as in a water channel problem.
The height of water adjusts itself such that it allows the amount of water introduced thought the inlet to flow out from the outlet duct.

I'm running some transient simulations to reach the final water level which changes with the inlet flow. In general the time needed to reach the steady state is not known a-rpiori and I have to run many simulations.

Therefore, I'd like to use the function objects in the controlDict to stop the simulation when some criteria are reached. For example, when the total water flow at the inlet at the outlet duct are equal and the outlet flow does not significantly change with time.

I checked this link to get some ideas:

http://www.openfoam.com/releases/ope...on-control.php

And I came out with the following code:
Code:

functions
{

    inletFlux
    {
        type            surfaceFieldValue;
        libs ("libfieldFunctionObjects.so");
        fields
        (
            alphaPhi
        );
        writeFields    false;
        log            true;
        surfaceFormat  null;
        regionType      patch;
        name            inlet;
        operation      sum;
        writeControl    timeStep;
    }

    outletFlux
    {
        $inletFlux;
        name            outlet;
    }

    averageInletFlux
    {
        type                valueAverage;
        functionObjectLibs  ( "libfieldFunctionObjects.so" );

        writeControl        timeStep;
        functionObject    inletFlux;
        fields                (???????);
        window              0.01;
    }

    averageOutletFlux
    {
        $averageInletFlux;
        functionObjectName  outletFlux;
    }

    // Compute flux difference
    Fluxdifference
    {
        type                ??????;
    }

    runTimeControl1
    {
        type                runTimeControl;
        functionObjectLibs  ("libjobControl.so");

        conditions
        {
            // Terminate when inlet and outlet fluxes difference is less than tolerance
            difference
            {
                type                average;
                functionObjectName  Fluxdifference;
                fields              (??????);
                tolerance          1e-4;
                window              50;
            }

            // Terminate when average OutletFlux changes by less than a tolerance
            average1
            {
                type                average;
                functionObjectName  averageOutletFlux;
                fields              (??????);
                tolerance          1e-4;
                window              50;
            }

        }
    }

}

The idea is to compute the total fluxes on the two patches, do a time average of these quantities as they are quite noisy and finally to use the difference of these averages as a criterion to terminate the simulation.

The problem is that I'm missing some information (lines with question marks), specifically:

1) what is the name of the field returned by inletFlux and outletFlux functionObjects on which I can operate (see the link for an example with forceCoeffs functionObjects)?

2) How to compute the difference of these two fluxes?

Thank you for your suggestions,

Luca

kandelabr June 18, 2019 09:07

Hello!

Did you manage to solve this conundrum? I have a very similar case at the moment.

Thanks!


All times are GMT -4. The time now is 19:00.