Contrib/swak4Foam/Example calcMassFlow
From OpenFOAMWiki
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