diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions index 8a6301a545..bd1659e6fc 100644 --- a/bin/tools/CleanFunctions +++ b/bin/tools/CleanFunctions @@ -74,6 +74,7 @@ cleanCase() cleanDynamicCode rm -rf processor* > /dev/null 2>&1 + rm -rf postProcessing > /dev/null 2>&1 rm -rf probes* > /dev/null 2>&1 rm -rf forces* > /dev/null 2>&1 rm -rf graphs* > /dev/null 2>&1 diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C index 33564024b1..6bd6102b2e 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C @@ -75,20 +75,23 @@ void Foam::fieldMinMax::calcMinMaxFields forAll(magFieldBoundary, patchI) { const scalarField& mfp = magFieldBoundary[patchI]; - const vectorField& Cfp = CfBoundary[patchI]; - - label minPI = findMin(mfp); - if (mfp[minPI] < minVs[procI]) + if (mfp.size()) { - minVs[procI] = mfp[minPI]; - minCs[procI] = Cfp[minPI]; - } + const vectorField& Cfp = CfBoundary[patchI]; - label maxPI = findMax(mfp); - if (mfp[maxPI] > maxVs[procI]) - { - maxVs[procI] = mfp[maxPI]; - maxCs[procI] = Cfp[maxPI]; + label minPI = findMin(mfp); + if (mfp[minPI] < minVs[procI]) + { + minVs[procI] = mfp[minPI]; + minCs[procI] = Cfp[minPI]; + } + + label maxPI = findMax(mfp); + if (mfp[maxPI] > maxVs[procI]) + { + maxVs[procI] = mfp[maxPI]; + maxCs[procI] = Cfp[maxPI]; + } } } @@ -173,20 +176,23 @@ void Foam::fieldMinMax::calcMinMaxFields forAll(fieldBoundary, patchI) { const Field& fp = fieldBoundary[patchI]; - const vectorField& Cfp = CfBoundary[patchI]; - - label minPI = findMin(fp); - if (fp[minPI] < minVs[procI]) + if (fp.size()) { - minVs[procI] = fp[minPI]; - minCs[procI] = Cfp[minPI]; - } + const vectorField& Cfp = CfBoundary[patchI]; - label maxPI = findMax(fp); - if (fp[maxPI] > maxVs[procI]) - { - maxVs[procI] = fp[maxPI]; - maxCs[procI] = Cfp[maxPI]; + label minPI = findMin(fp); + if (fp[minPI] < minVs[procI]) + { + minVs[procI] = fp[minPI]; + minCs[procI] = Cfp[minPI]; + } + + label maxPI = findMax(fp); + if (fp[maxPI] > maxVs[procI]) + { + maxVs[procI] = fp[maxPI]; + maxCs[procI] = Cfp[maxPI]; + } } } @@ -250,7 +256,14 @@ void Foam::fieldMinMax::calcMinMaxFields } default: { - FatalErrorIn("Foam::fieldMinMax::calcMinMaxFields(const word&)") + FatalErrorIn + ( + "Foam::fieldMinMax::calcMinMaxFields" + "(" + "const word&, " + "const modeType&" + ")" + ) << "Unknown min/max mode: " << modeTypeNames_[mode_] << exit(FatalError); } diff --git a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C index 538fb1040d..0e15ead796 100644 --- a/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C +++ b/src/postProcessing/functionObjects/utilities/CourantNo/CourantNo.C @@ -189,7 +189,7 @@ void Foam::CourantNo::write() CourantNo.write(); Info<< type() << " output:" << nl - << " writing " << CourantNo.name() << "field" << nl << endl; + << " writing " << CourantNo.name() << " field" << nl << endl; } } diff --git a/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C index 0ab986f9ea..3e28db3090 100644 --- a/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C +++ b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C @@ -56,7 +56,7 @@ Foam::word Foam::pressureTools::pName() const } -Foam::dimensionedScalar Foam::pressureTools::rho +Foam::dimensionedScalar Foam::pressureTools::rhoScale ( const volScalarField& p ) const @@ -72,6 +72,38 @@ Foam::dimensionedScalar Foam::pressureTools::rho } +Foam::tmp Foam::pressureTools::rho +( + const volScalarField& p +) const +{ + if (p.dimensions() == dimPressure) + { + return p.mesh().lookupObject(rhoName_); + } + else + { + return + tmp + ( + new volScalarField + ( + IOobject + ( + "rho", + p.mesh().time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + p.mesh(), + dimensionedScalar("zero", dimDensity, rhoRef_) + ) + ); + } +} + + Foam::dimensionedScalar Foam::pressureTools::pRef() const { dimensionedScalar value("pRef", dimPressure, 0.0); @@ -81,11 +113,14 @@ Foam::dimensionedScalar Foam::pressureTools::pRef() const value.value() += pRef_; } - return pRef(); + return value; } -Foam::tmp Foam::pressureTools::pDyn() const +Foam::tmp Foam::pressureTools::pDyn +( + const volScalarField& p +) const { const fvMesh& mesh = refCast(obr_); @@ -110,7 +145,7 @@ Foam::tmp Foam::pressureTools::pDyn() const { const volVectorField& U = obr_.lookupObject(UName_); - tpDyn() == 0.5*magSqr(U); + tpDyn() == rho(p)*0.5*magSqr(U); } return tpDyn; @@ -119,14 +154,15 @@ Foam::tmp Foam::pressureTools::pDyn() const Foam::tmp Foam::pressureTools::convertToCoeff ( - const volScalarField& p + const volScalarField& pCalculated, + const volScalarField& pIn ) const { - tmp tCoeff(p); + tmp tCoeff(pCalculated); if (calcCoeff_) { - tCoeff() /= pDyn(); + tCoeff() /= pDyn(pIn) + dimensionedScalar("p0", dimPressure, SMALL); } return tCoeff; @@ -150,6 +186,7 @@ Foam::pressureTools::pressureTools calcCoeff_(false), pName_("p"), UName_("U"), + rhoName_("rho"), pRef_(0.0), rhoRef_(1.0) { @@ -188,6 +225,7 @@ void Foam::pressureTools::read(const dictionary& dict) { dict.readIfPresent("pName", pName_); dict.readIfPresent("UName", UName_); + dict.readIfPresent("rhoName", rhoName_); const volScalarField& p = obr_.lookupObject(pName_); @@ -234,7 +272,7 @@ void Foam::pressureTools::write() obr_, IOobject::NO_READ ), - convertToCoeff(rho(p)*(p + pDyn()) + pRef()) + convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef(), p) ); pResult.write(); diff --git a/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H index 8b9d468bba..f823c8faea 100644 --- a/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H +++ b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H @@ -125,6 +125,9 @@ class pressureTools //- Name of velocity field, default is "U" word UName_; + //- Name of density field, default is "rho" + word rhoName_; + //- Reference pressure level (used for total pressure) scalar pRef_; @@ -138,16 +141,23 @@ class pressureTools word pName() const; //- Return the density scaling if supplied with kinematic pressure - dimensionedScalar rho(const volScalarField& p) const; + dimensionedScalar rhoScale(const volScalarField& p) const; + + //- Return the density field + tmp rho(const volScalarField& p) const; //- Return the reference pressure dimensionedScalar pRef() const; - //- Calculate and return the (kinematic) dynamic pressure - tmp pDyn() const; + //- Calculate and return the dynamic pressure + tmp pDyn(const volScalarField& p) const; //- Convert to coeff data by applying the pDyn scaling - tmp convertToCoeff(const volScalarField& p) const; + tmp convertToCoeff + ( + const volScalarField& pCalculated, + const volScalarField& pIn + ) const; //- Disallow default bitwise copy construct pressureTools(const pressureTools&); diff --git a/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C b/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C index a7e5e1ee09..9544c8799b 100644 --- a/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C +++ b/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.C @@ -53,34 +53,32 @@ void Foam::wallShearStress::calcShearStress volVectorField& shearStress ) { - forAll(shearStress.boundaryField(), patchI) + forAllConstIter(labelHashSet, patchSet_, iter) { + label patchI = iter.key(); const polyPatch& pp = mesh.boundaryMesh()[patchI]; - if (isA(pp)) + vectorField& ssp = shearStress.boundaryField()[patchI]; + const vectorField& Sfp = mesh.Sf().boundaryField()[patchI]; + const scalarField& magSfp = mesh.magSf().boundaryField()[patchI]; + const symmTensorField& Reffp = Reff.boundaryField()[patchI]; + + ssp = (-Sfp/magSfp) & Reffp; + + vector minSsp = gMin(ssp); + vector maxSsp = gMax(ssp); + + if (Pstream::master()) { - vectorField& ssp = shearStress.boundaryField()[patchI]; - const vectorField& Sfp = mesh.Sf().boundaryField()[patchI]; - const scalarField& magSfp = mesh.magSf().boundaryField()[patchI]; - const symmTensorField& Reffp = Reff.boundaryField()[patchI]; + file() << mesh.time().timeName() << token::TAB + << pp.name() << token::TAB << minSsp + << token::TAB << maxSsp << endl; + } - ssp = (-Sfp/magSfp) & Reffp; - - vector minSsp = gMin(ssp); - vector maxSsp = gMax(ssp); - - if (Pstream::master()) - { - file() << mesh.time().timeName() << token::TAB - << pp.name() << token::TAB << minSsp - << token::TAB << maxSsp << endl; - } - - if (log_) - { - Info<< " min/max(" << pp.name() << ") = " - << minSsp << ", " << maxSsp << endl; - } + if (log_) + { + Info<< " min/max(" << pp.name() << ") = " + << minSsp << ", " << maxSsp << endl; } } } @@ -101,7 +99,8 @@ Foam::wallShearStress::wallShearStress obr_(obr), active_(true), log_(false), - phiName_("phi") + phiName_("phi"), + patchSet_() { // Check if the available mesh is an fvMesh, otherwise deactivate if (!isA(obr_)) @@ -138,6 +137,54 @@ void Foam::wallShearStress::read(const dictionary& dict) { log_ = dict.lookupOrDefault("log", false); phiName_ = dict.lookupOrDefault("phiName", "phi"); + + const fvMesh& mesh = refCast(obr_); + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + + patchSet_ = + mesh.boundaryMesh().patchSet + ( + wordReList(dict.lookupOrDefault("patches", wordReList())) + ); + + Info<< type() << " output:" << nl; + + if (patchSet_.empty()) + { + forAll(pbm, patchI) + { + if (isA(pbm[patchI])) + { + patchSet_.insert(patchI); + } + } + + Info<< " processing all wall patches" << nl << endl; + } + else + { + Info<< " processing wall patches: " << nl; + labelHashSet filteredPatchSet; + forAllConstIter(labelHashSet, patchSet_, iter) + { + label patchI = iter.key(); + if (isA(pbm[patchI])) + { + filteredPatchSet.insert(patchI); + Info<< " " << pbm[patchI].name() << endl; + } + else + { + WarningIn("void wallShearStress::read(const dictionary&)") + << "Requested wall shear stress on non-wall boundary " + << "type patch: " << pbm[patchI].name() << endl; + } + } + + Info<< endl; + + patchSet_ = filteredPatchSet; + } } } diff --git a/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.H b/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.H index 80f12d0c24..ac16eca594 100644 --- a/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.H +++ b/src/postProcessing/functionObjects/utilities/wallShearStress/wallShearStress.H @@ -36,15 +36,34 @@ Description Stress = R \dot n \f] - The shear stress (symmetrical) tensor field is retrieved from the - turbulence model. - where \vartable R | stress tensor n | patch normal vector (into the domain) \endvartable + The shear stress (symmetrical) tensor field is retrieved from the + turbulence model. All wall patches are included by default; to restrict + the calculation to certain patches, use the optional 'patches' entry. + + Example of function object specification: + \verbatim + wallShearStress1 + { + type wallShearStress; + functionObjectLibs ("libutilityFunctionObjects.so"); + ... + patches (".*Wall"); + } + \endverbatim + + \heading Function object usage + \table + Property | Description | Required | Default value + type | type name: wallShearStress | yes | + patches | list of patches to process | no | all wall patches + \endtable + SourceFiles wallShearStress.C IOwallShearStress.H @@ -97,6 +116,9 @@ protected: //- Name of mass/volume flux field (optional, default = phi) word phiName_; + //- Optional list of patches to process + labelHashSet patchSet_; + // Protected Member Functions