Contrib/swak4Foam/Example calcMassFlow

From OpenFOAMWiki

To use the following mass flow examples, edit the controlDict file and create a new section at the end of the file called "functions"

The controlDict is located here: OpenFOAM/name-2.1.0/run/casename/system/controlDict


 
functions
{
....(insert the desired mass flow code from the examples below HERE)...
}


Mass flow examples

Usually OpenFOAM solvers define a face-flow field phi that only has to be summed on patches

 
    patchMassFlow
    {
        type patchExpression;
        accumulations (
            sum
        );
        patches (
            inlet
            outlet
        );
        expression "phi";
        verbose true;
    }

On faceZones this is a bit more complicated as the orientation of the face has to be taken into account:

 
    flowBeforeZone
    {
        type swakExpression;
        valueType faceZone;
        zoneName beforeFilter;
        expression "phi*flip()";
        accumulations (
            sum
        );
        verbose true;
    }

similarly for a face set

 
    flowBeforeSet
    {
        type swakExpression;
        valueType faceSet;
        setName beforeFilter;
        expression "phi*flip()";
        accumulations (
            sum
        );
        verbose true;
    }

but beware: for flip to work correctly in this case an appropriate cellSet with the name beforeFilterSlaveCells has to be defined.

If your solver doesn't provide an appropriate field phi then an expression like "rho*(Sf()&U)" (adapt to your solver there may be no density field) can be used to emulate it