From 68fd2618cf24ede8b511f7f89e9ab6b76856f098 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 21 Nov 2012 14:55:52 +0000 Subject: [PATCH 1/5] ENH: Updated output quantities for kinematic/thermo surface filme models --- .../kinematicSingleLayer/kinematicSingleLayer.C | 6 ++++-- .../surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C index 941da7e848..430d388303 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C @@ -1048,12 +1048,14 @@ void kinematicSingleLayer::info() const { Info<< "\nSurface film: " << type() << endl; + const vectorField& Uinternal = U_.internalField(); + Info<< indent << "added mass = " << returnReduce(addedMassTotal_, sumOp()) << nl << indent << "current mass = " << gSum((deltaRho_*magSf())()) << nl - << indent << "min/max(mag(U)) = " << min(mag(U_)).value() << ", " - << max(mag(U_)).value() << nl + << indent << "min/max(mag(U)) = " << gMin(mag(Uinternal)) << ", " + << gMax(mag(Uinternal)) << nl << indent << "min/max(delta) = " << min(delta_).value() << ", " << max(delta_).value() << nl << indent << "coverage = " diff --git a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C index 21953ae94c..07a70d651b 100644 --- a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayer.C @@ -727,8 +727,10 @@ void thermoSingleLayer::info() const { kinematicSingleLayer::info(); - Info<< indent << "min/max(T) = " << min(T_).value() << ", " - << max(T_).value() << nl; + const scalarField& Tinternal = T_.internalField(); + + Info<< indent << "min/max(T) = " << gMin(Tinternal) << ", " + << gMax(Tinternal) << nl; phaseChange_->info(Info); } From ed37e317dd69e37aebf0b6ee683442cd578c96d3 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 21 Nov 2012 17:05:04 +0000 Subject: [PATCH 2/5] BUG: Correcte pressure dimension check --- .../functionObjects/utilities/pressureTools/pressureTools.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C index 6d70be969a..0ab986f9ea 100644 --- a/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C +++ b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C @@ -191,7 +191,7 @@ void Foam::pressureTools::read(const dictionary& dict) const volScalarField& p = obr_.lookupObject(pName_); - if (p.dimensions() != p.dimensions()) + if (p.dimensions() != dimPressure) { dict.lookup("rhoRef") >> rhoRef_; } From 37f3793b7a3c9ce850ddf146ded5c0f55c29003a Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 21 Nov 2012 17:05:33 +0000 Subject: [PATCH 3/5] ENH: Added header documentation to pressureTools function object --- .../utilities/pressureTools/pressureTools.H | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H index 702d496199..8b9d468bba 100644 --- a/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H +++ b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H @@ -24,29 +24,55 @@ License Class Foam::pressureTools +Group + grpUtilitiesFunctionObjects + Description This function object includes tools to manipulate the pressure into different forms. These currently include: - static pressure - - p_s = rho*p_k - + \f[ + p_s = \rho p_k + \f] - total pressure - - p_T = pRef + p_s + 0.5 rho |U|^2 - + \f[ + p_T = p_{ref} + p_s + 0.5 \rho |U|^2 + \f] - static pressure coefficient - - Cp_s = p_s / (0.5 rho |U|^2) - + \f[ + Cp_s = \frac{p_s}{0.5 \rho |U|^2} + \f] - total pressure coefficient - - Cp_T = p_T / (0.5 rho |U|^2) + \f[ + Cp_T = \frac{p_T}{0.5 \rho |U|^2} + \f] The function object will operate on both kinematic (p_k) and static pressure (p_s) fields, and the result is written as a volScalarField. + Example of function object specification to calculate pressure coefficient: + \verbatim + pressureTools1 + { + type pressureTools; + functionObjectLibs ("libutilityFunctionObjects.so"); + ... + calcTotal no; + calcCoeff yes; + } + \endverbatim + + \heading Function object usage + \table + Property | Description | Required | Default value + type | type name: pressureTools| yes | + calcCoeff | Calculate pressure coefficient | yes | + calcTotal | Calculate total coefficient | yes | + rhoRef | Reference density for incompressible cases | no | 1 + pRef | Reference pressure for total pressure |no| 0.0 + \endtable + SourceFiles pressureTools.C IOpressureTools.H From c7604c8a7eef78957df3aff894146b768c9d64f0 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 21 Nov 2012 17:11:24 +0000 Subject: [PATCH 4/5] ENH: Re-homed helper list and combine classes --- .../containers/Lists/ListOps/ListOps.H | 9 ++ .../Lists/ListOps/ListOpsTemplates.C | 22 +++++ src/OpenFOAM/primitives/ops/ops.H | 98 ++++++++++++------- .../AMIInterpolation/AMIInterpolation.C | 77 +++------------ 4 files changed, 110 insertions(+), 96 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H index d0689b0eb1..86fdc7ba51 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H @@ -245,6 +245,15 @@ template List initListList(const T[nRows][nColumns]); +//- Helper class for list to append y onto the end of x +template +class ListAppendEqOp +{ +public: + void operator()(List& x, const List& y) const; +}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C index be6337a428..49daa408c1 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C @@ -684,4 +684,26 @@ Foam::List Foam::initListList(const T elems[nRows][nColumns]) } +template +void Foam::ListAppendEqOp::operator()(List& x, const List& y) const +{ + if (y.size()) + { + if (x.size()) + { + label sz = x.size(); + x.setSize(sz + y.size()); + forAll(y, i) + { + x[sz++] = y[i]; + } + } + else + { + x = y; + } + } +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/primitives/ops/ops.H b/src/OpenFOAM/primitives/ops/ops.H index 66d7930849..cab91fcfb5 100644 --- a/src/OpenFOAM/primitives/ops/ops.H +++ b/src/OpenFOAM/primitives/ops/ops.H @@ -90,40 +90,68 @@ EqOp(nopEq, (void)x) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#define Op(opName, op) \ - \ -template \ -class opName##Op3 \ -{ \ -public: \ - \ - T operator()(const T1& x, const T2& y) const \ - { \ - return op; \ - } \ -}; \ - \ -template \ -class opName##Op2 \ -{ \ -public: \ - \ - T1 operator()(const T1& x, const T2& y) const \ - { \ - return op; \ - } \ -}; \ - \ -template \ -class opName##Op \ -{ \ -public: \ - \ - T operator()(const T& x, const T& y) const \ - { \ - return op; \ - } \ -}; +#define Op(opName, op) \ + \ + template \ + class opName##Op3 \ + { \ + public: \ + \ + T operator()(const T1& x, const T2& y) const \ + { \ + return op; \ + } \ + }; \ + \ + template \ + class opName##Op2 \ + { \ + public: \ + \ + T1 operator()(const T1& x, const T2& y) const \ + { \ + return op; \ + } \ + }; \ + \ + template \ + class opName##Op \ + { \ + public: \ + \ + T operator()(const T& x, const T& y) const \ + { \ + return op; \ + } \ + }; + + +#define weightedOp(opName, op) \ + \ + template \ + class opName##WeightedOp \ + { \ + const CombineOp& cop_; \ + \ + public: \ + \ + opName##WeightedOp(const CombineOp& cop) \ + : \ + cop_(cop) \ + {} \ + \ + void operator() \ + ( \ + Type& x, \ + const label index, \ + const Type& y, \ + const scalar weight \ + ) const \ + { \ + cop_(x, op); \ + } \ + }; \ + Op(sum, x + y) @@ -147,6 +175,8 @@ Op(lessEq, x <= y) Op(greater, x > y) Op(greaterEq, x >= y) +weightedOp(multiply, weight * y) + #undef Op diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index 1f9f4c66ec..fc60cd2fbb 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -27,63 +27,6 @@ License #include "meshTools.H" #include "mapDistribute.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - //- Helper class for list - template - class ListPlusEqOp - { - public: - void operator()(List& x, const List y) const - { - if (y.size()) - { - if (x.size()) - { - label sz = x.size(); - x.setSize(sz + y.size()); - forAll(y, i) - { - x[sz++] = y[i]; - } - } - else - { - x = y; - } - } - } - }; - - //- Combine operator for interpolateToSource/Target - template - class combineBinaryOp - { - const CombineOp& cop_; - - public: - - combineBinaryOp(const CombineOp& cop) - : - cop_(cop) - {} - - void operator() - ( - Type& x, - const label faceI, - const Type& y, - const scalar weight - ) const - { - cop_(x, weight*y); - } - }; -} - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template @@ -1550,7 +1493,7 @@ void Foam::AMIInterpolation::update } // send data back to originating procs. Note that contributions - // from different processors get added (ListPlusEqOp) + // from different processors get added (ListAppendEqOp) mapDistribute::distribute ( @@ -1560,7 +1503,7 @@ void Foam::AMIInterpolation::update map.constructMap(), map.subMap(), tgtAddress_, - ListPlusEqOp