scalar ptLoss =0;
forAll(patchIDs, pID)
{
    label pI = patchIDs[pID];
    ptLoss -= gSum
    (
        phi.boundaryField()[pI]*(p.boundaryField()[pI]
        +0.5*magSqr(U.boundaryField()[pI]))
    );
}
ptlFile << runTime.value() << "   " << ptLoss << endl;
