Contrib/swak4Foam/Example dropletVelocity

From OpenFOAMWiki

Here is a way of calculating the velocity of a drop falling. This is for a 2D case. First, one can average the velocities of all cells within the drop (for alpha>0.5 for example):

 
    downAverage
    {
        type swakExpression;
        valueType internalField;
        variables (
             "downDirection=vector(0,-1,0);"//select the downwards direction
             "thres=0.5;"//which cells to keep
             "liquidVol=sum(alpha1>thres ? vol() : 0);" //calculates the volume of the drop
             "downVel=alpha1>thres ? (U & downDirection) : 0;" //a & b:inner vector product. Keep the y component of U.
        );
        expression "downVel*vol()/liquidVol";//vol():vol of the cell
        accumulations (
           sum
        );
        
        verbose true;
    }

Another possibility would be to track the evolution of the diameter in the x and y direction:

 
    createInterface
    {
        type createSampledSurface;
        outputControl timeStep;
        outputInterval 1;
        surfaceName interface;
        surface {
            type isoSurface;
            isoField alpha1;
            isoValue 0.5; //select cells with alpha equal to 0.5
            interpolate true;
        }
    }
    
    xDiameter
    {
        type swakExpression;
        valueType surface;
        surfaceName interface;
        verbose true;
        expression "pos().x";
        accumulations (
            min
            max
        );        
    }
    
    yDiameter
    {
        type swakExpression;
        valueType surface;
        surfaceName interface;
        verbose true;
        expression "pos().y";
        accumulations (
            min
            max
        );        
    }

Note: this will generate the horizontal and vertical diameter of the droplet, and by looking at the center of the "cross", one can track the evolution of the whole drop.