CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] Incorrect results of SWAK4FOAM function objects if Parallelisation involved (https://www.cfd-online.com/Forums/openfoam-community-contributions/164282-incorrect-results-swak4foam-function-objects-if-parallelisation-involved.html)

wstapel December 17, 2015 09:57

Incorrect results of SWAK4FOAM function objects if Parallelisation involved
 
Dear Foamers,

I have a flow simulation where groovyBC and several function objects of SWAK4FOAM are utilised. The simulation is an internal flow which consists of a single inlet and some kind of a pipe system with many outlets. These "outlets" are actually predefined faceZones in the internal mesh.

The main idea for the simulation is that the inlet pressure boundary condition is dependent on the total mass output of the system. Hence what the function objects do is to track the flowrate of each outlet at every time step and accumulate it in a global variable called extAgntVol. extAgentVol is handed over to the groovyBC to correct the pressure.

I have added most of the code but not all because it repeads a lot.

Boundary condition

Code:

    INLET    {
        type            groovyBC;
        refValue        uniform 6887.42;
            value          uniform 6887.417;
        valueExpression "p0*(pow((V0/Vneu),kappa))";
            evaluateDuringConstruction 0;
        variables     
        4
        (
            "p0=6887.42;"
            "V0=0.00274;"
            "Vneu=V0+extAgntVol;"
            "kappa=1.4;"
        );
            timelines      ();
            lookuptables    ();
            globalScopes    1(extAgntControl);
    }

Function objects:

Code:

functions
{

// Definition of global varibles

    defineFlowrate {
        type addGlobalVariable;
        // outputControl none;
        // outputInterval 0;
       
        isSingleValue 1;
        noReset 0;
   
        globalScope extAgntControl;
        globalVariables {

            fr_up_SLOT01 {
                valueType scalar;
                value 0.0;
            }   

            fr_up_SLOT02 {
                valueType scalar;
                value 0.0;
            }
           
            ... and many other variables

          extAgntVol {
                valueType scalar;
                value 0.0;
            }

        }
    }         

  // Calculate Flowrate

    calculateFlowrate_for_upper_SLOT01 {
        type calculateGlobalVariables;
        valueType faceZone;
        zoneName int_INT_OUTLET_INNENRING_SLOT-01;
        isSingleValue 1;
        noReset 0;   

   
        toGlobalNamespace extAgntControl;
        globalScopes (
            extAgntControl
        );
        toGlobalVariables (
            fr_up_SLOT01
        );
        variables (
            "fr_up_SLOT01= (-1.0)*sum(phi);"
        );
    }

    ... and for many other outlets

  // sum everything up

        calculateVolume {
        type calculateGlobalVariables;
        valueType faceZone;
        zoneName int_INT_NORMALISER_A;
        isSingleValue 1;
        noReset 0;   

   
        toGlobalNamespace extAgntControl;
        globalScopes (
            extAgntControl
        );
        toGlobalVariables (
            fr_up_SLOT01
        );
       
        ...

            variables (
            "extAgntVol= extAgntVol+(fr_up_SLOT01+fr_up_SLOT02+...+fr_SLOT20)*deltaT();"
        );
    }


If the simulation is performed on a single processor everything works fine. However as soon as it is runs in parallel the tracked flowrates are false (they are always too little). I kind of had the same problem when I wrote the code for the flowrate accumulation directly into the solver. There it was solved by replacing sum(...) with gSum(...). (http://www.cfd-online.com/Forums/ope...n-cluster.html)
But afaik gSum(...) is not available for SWAK4FOAM.

I would be glad for any suggestions and workarounds.


All times are GMT -4. The time now is 11:43.