From 31cea98bda88c4c3652339d51eed98afac3224a5 Mon Sep 17 00:00:00 2001 From: andy <a.heather@opencfd.co.uk> Date: Fri, 16 May 2008 15:39:14 +0100 Subject: [PATCH] added surfaceScalarField functionality --- .../patch/patchIntegrate/patchIntegrate.C | 44 ++++++++++++++----- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C index ffae1611328..7f5bcf2734b 100644 --- a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C +++ b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C @@ -77,21 +77,45 @@ int main(int argc, char *argv[]) { mesh.readUpdate(); - Info<< " Reading field " << fieldName << endl; - volScalarField field(fieldHeader, mesh); - label patchi = mesh.boundaryMesh().findPatchID(patchName); + if (patchi < 0) + { + FatalError + << "Unable to find patch " << patchName << nl + << exit(FatalError); + } - if (patchi >= 0) + if (fieldHeader.headerClassName() == "volScalarField") { + Info<< " Reading volScalarField " << fieldName << endl; + volScalarField field(fieldHeader, mesh); + + vector sumField = sum + ( + mesh.Sf().boundaryField()[patchi] + *field.boundaryField()[patchi] + ); + Info<< " Integral of " << fieldName << " over patch " << patchName << '[' << patchi << ']' << " = " - << sum - ( - mesh.Sf().boundaryField()[patchi] - *field.boundaryField()[patchi] - ) - << endl; + << sumField << nl; + } + else if (fieldHeader.headerClassName() == "surfaceScalarField") + { + Info<< " Reading surfaceScalarField " << fieldName << endl; + + surfaceScalarField field(fieldHeader, mesh); + scalar sumField = sum(field.boundaryField()[patchi]); + + Info<< " Integral of " << fieldName << " over patch " + << patchName << '[' << patchi << ']' << " = " + << sumField << nl; + } + else + { + FatalError + << "Only possible to integrate volScalarFields " + << "and surfaceScalarFields" << nl << exit(FatalError); } } else -- GitLab