Contrib/swak4Foam/Example calcPressureDifference

From OpenFOAMWiki
< Contrib‎ | swak4Foam
Revision as of 15:06, 27 November 2012 by Bgschaid (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

One way to calculate the pressure difference between two patches is by calculating the difference between the averages weighted by the face-sizes on the other patch to the current patch:

 
    pressureDrop
    {
        type patchExpression;
        variables ( "pOut{patch'outlet}=sum(p*area())/sum(area());");
        accumulations (
           min
           max
        );
        patches (
            inlet
        );
        expression "p-pOut";
        verbose true;
    }

Another possibility would be to compare the difference of the averages:

 
    pressureDrop
    {
        type patchExpression;
        variables ( 
            "pOut{patch'outlet}=sum(p*area())/sum(area());"
            "inArea=sum(area());"
        );
        accumulations (
           sum
        );
        patches (
            inlet
        );
        expression "area()*(p-pOut)/inArea";
        verbose true;
    }

Pressure-drops to other entities can be calculated similarily:

 
    pressureOverFilter
    {
        type swakExpression;
        valueType faceZone;
        zoneName beforeFilter;
        variables (
            "pAfter{faceSet'afterFilter}=average(p);"
        );
        accumulations (
            average
        );
        expression "p-pAfter";
        verbose true;
        autoInterpolate true;
        warnAutoInterpolate false;
    }

Note: how you define "pressure difference" (face weighted, arithmetic average, min/max ...) is up to you