From 31cea98bda88c4c3652339d51eed98afac3224a5 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 16 May 2008 15:39:14 +0100 Subject: [PATCH 1/2] added surfaceScalarField functionality --- .../patch/patchIntegrate/patchIntegrate.C | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C index ffae161132..7f5bcf2734 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) + if (patchi < 0) { + FatalError + << "Unable to find patch " << patchName << nl + << exit(FatalError); + } + + 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 From 40bd183de215d9cc46bf080b44169b3328c58306 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 19 May 2008 12:57:39 +0100 Subject: [PATCH 2/2] Added check for zero-size insertdictionaryIstreamMemberFunctionTable --- .../functionEntry/functionEntry.C | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C index b051949884..7e53591c64 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C @@ -63,6 +63,17 @@ bool Foam::functionEntry::insert "primitiveEntry& entry, Istream& is)" ); + if (!insertprimitiveEntryIstreamMemberFunctionTablePtr_) + { + cerr<<"functionEntry::insert" + << "(const word&, dictionary&, primitiveEntry&, Istream&)" + << " not yet initialized, function = " + << functionName.c_str() << std::endl; + + // return true to keep reading anyhow + return true; + } + insertprimitiveEntryIstreamMemberFunctionTable::iterator mfIter = insertprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName); @@ -97,6 +108,17 @@ bool Foam::functionEntry::insert "(const word& functionName, dictionary& parentDict, Istream& is)" ); + if (!insertdictionaryIstreamMemberFunctionTablePtr_) + { + cerr<<"functionEntry::insert" + << "(const word&, dictionary&, Istream&)" + << " not yet initialized, function = " + << functionName.c_str() << std::endl; + + // Return true to keep reading + return true; + } + insertdictionaryIstreamMemberFunctionTable::iterator mfIter = insertdictionaryIstreamMemberFunctionTablePtr_->find(functionName);