From ac74494b2a592a0e305747c1eca803a58e3a1105 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 17 Aug 2009 11:24:22 +0100 Subject: [PATCH 1/7] use of virtual functions --- .../alphatWallFunction/alphatWallFunctionFvPatchScalarField.H | 2 +- .../kqRWallFunction/kqRWallFunctionFvPatchField.H | 2 +- .../kqRWallFunction/kqRWallFunctionFvPatchField.H | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H index 4f21ba6472..60c90b1288 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.H @@ -147,7 +147,7 @@ public: // I-O //- Write - void write(Ostream&) const; + virtual void write(Ostream&) const; }; diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H index 7d1954f982..4db7a49d65 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H @@ -147,7 +147,7 @@ public: // I-O //- Write - void write(Ostream&) const; + virtual void write(Ostream&) const; }; diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H index e7405e9146..ef9f2747f1 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/kqRWallFunctions/kqRWallFunction/kqRWallFunctionFvPatchField.H @@ -147,7 +147,7 @@ public: // I-O //- Write - void write(Ostream&) const; + virtual void write(Ostream&) const; }; From e4727a486056ed9887fcc8f324ccc9783492170e Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 17 Aug 2009 12:49:32 +0100 Subject: [PATCH 2/7] refactoring --- .../faceZonesIntegration.C | 73 +++++++++---------- .../faceZonesIntegration.H | 24 +++--- 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.C b/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.C index e048920899..36740cbf11 100644 --- a/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.C +++ b/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.C @@ -57,7 +57,7 @@ Foam::faceZonesIntegration::faceZonesIntegration log_(false), faceZonesSet_(), fItems_(), - faceZonesIntegrationFilePtr_(NULL) + filePtr_(NULL) { // Check if the available mesh is an fvMesh otherise deactivate if (!isA(obr_)) @@ -104,7 +104,7 @@ void Foam::faceZonesIntegration::read(const dictionary& dict) void Foam::faceZonesIntegration::makeFile() { // Create the face Zone file if not already created - if (faceZonesIntegrationFilePtr_.empty()) + if (filePtr_.empty()) { if (debug) { @@ -132,7 +132,7 @@ void Foam::faceZonesIntegration::makeFile() mkDir(faceZonesIntegrationDir); // Open new file at start up - faceZonesIntegrationFilePtr_.resize(fItems_.size()); + filePtr_.resize(fItems_.size()); forAll(fItems_, Ifields) { @@ -143,7 +143,7 @@ void Foam::faceZonesIntegration::makeFile() faceZonesIntegrationDir/fieldName ); - faceZonesIntegrationFilePtr_.insert(fieldName, sPtr); + filePtr_.insert(fieldName, sPtr); } // Add headers to output data @@ -155,11 +155,11 @@ void Foam::faceZonesIntegration::makeFile() void Foam::faceZonesIntegration::writeFileHeader() { - forAllIter(HashPtrTable, faceZonesIntegrationFilePtr_, iter) + forAllIter(HashPtrTable, filePtr_, iter) { unsigned int w = IOstream::defaultPrecision() + 7; - OFstream& os = *faceZonesIntegrationFilePtr_[iter.key()]; + OFstream& os = *filePtr_[iter.key()]; os << "#Time " << setw(w); @@ -196,10 +196,10 @@ void Foam::faceZonesIntegration::write() { const word& fieldName = fItems_[fieldI]; - const surfaceScalarField& fD = + const surfaceScalarField& sField = obr_.lookupObject(fieldName); - const fvMesh& mesh = fD.mesh(); + const fvMesh& mesh = sField.mesh(); // 1. integrate over all face zones @@ -211,11 +211,11 @@ void Foam::faceZonesIntegration::write() label zoneID = mesh.faceZones().findZoneID(name); - const faceZone& fz = mesh.faceZones()[zoneID]; + const faceZone& fZone = mesh.faceZones()[zoneID]; integralVals[setI] = returnReduce ( - calcFaceZonesIntegral(fD, fz), + calcIntegral(sField, fZone), sumOp() ); } @@ -225,13 +225,9 @@ void Foam::faceZonesIntegration::write() // 2. Write only on master - if - ( - Pstream::master() - && faceZonesIntegrationFilePtr_.found(fieldName) - ) + if (Pstream::master() && filePtr_.found(fieldName)) { - OFstream& os = *faceZonesIntegrationFilePtr_(fieldName); + OFstream& os = *filePtr_(fieldName); os << obr_.time().value(); @@ -242,7 +238,8 @@ void Foam::faceZonesIntegration::write() if (log_) { Info<< "faceZonesIntegration output:" << nl - << " Integration" << integralVals[setI] << endl; + << " Integration[" << setI << "] " + << integralVals[setI] << endl; } } @@ -253,45 +250,47 @@ void Foam::faceZonesIntegration::write() } -Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral +Foam::scalar Foam::faceZonesIntegration::calcIntegral ( - const surfaceScalarField& fD, - const faceZone& fz + const surfaceScalarField& sField, + const faceZone& fZone ) const { - scalar dm = 0.0; - const fvMesh& mesh = fD.mesh(); + scalar sum = 0.0; + const fvMesh& mesh = sField.mesh(); - forAll (fz, i) + forAll (fZone, i) { - label faceI = fz[i]; + label faceI = fZone[i]; if (mesh.isInternalFace(faceI)) { - if (fz.flipMap()[i]) + if (fZone.flipMap()[i]) { - dm -= fD[faceI]; + sum -= sField[faceI]; } else { - dm += fD[faceI]; + sum += sField[faceI]; } } else { label patchI = mesh.boundaryMesh().whichPatch(faceI); const polyPatch& pp = mesh.boundaryMesh()[patchI]; + const fvsPatchScalarField& bField = sField.boundaryField()[patchI]; if (isA(pp)) { if (refCast(pp).owner()) { - if (fz.flipMap()[i]) + label patchFaceI = pp.whichFace(faceI); + if (fZone.flipMap()[i]) { - dm -= fD.boundaryField()[patchI][pp.whichFace(faceI)]; + sum -= bField[patchFaceI]; } else { - dm += fD.boundaryField()[patchI][pp.whichFace(faceI)]; + sum += bField[patchFaceI]; } } } @@ -300,32 +299,32 @@ Foam::scalar Foam::faceZonesIntegration::calcFaceZonesIntegral label patchFaceI = faceI - pp.start(); if (patchFaceI < pp.size()/2) { - if (fz.flipMap()[i]) + if (fZone.flipMap()[i]) { - dm -= fD.boundaryField()[patchI][patchFaceI]; + sum -= bField[patchFaceI]; } else { - dm += fD.boundaryField()[patchI][patchFaceI]; + sum += bField[patchFaceI]; } } } else if (!isA(pp)) { label patchFaceI = faceI - pp.start(); - if (fz.flipMap()[i]) + if (fZone.flipMap()[i]) { - dm -= fD.boundaryField()[patchI][patchFaceI]; + sum -= bField[patchFaceI]; } else { - dm += fD.boundaryField()[patchI][patchFaceI]; + sum += bField[patchFaceI]; } } } } - return dm; + return sum; } diff --git a/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.H b/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.H index 87659ac340..c2f3ad9d4b 100644 --- a/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.H +++ b/src/postProcessing/functionObjects/zones/faceZoneIntegration/faceZonesIntegration.H @@ -57,7 +57,7 @@ class dictionary; class mapPolyMesh; /*---------------------------------------------------------------------------*\ - Class faceZonesIntegration Declaration + Class faceZonesIntegration Declaration \*---------------------------------------------------------------------------*/ class faceZonesIntegration @@ -65,17 +65,18 @@ class faceZonesIntegration protected: - // Private data + // Protected data //- Name of this set of face zone integration, - // Also used as the name of the probes directory. + // Also used as the name of the output directory. word name_; const objectRegistry& obr_; + // Read from dictionary - //- on/off switch + //- On/off switch bool active_; //- Switch to send output to Info as well as to file @@ -89,19 +90,19 @@ protected: //- Current open files - HashPtrTable faceZonesIntegrationFilePtr_; + HashPtrTable filePtr_; - // Private Member Functions + // Protected Member Functions //- If the integration file has not been created create it void makeFile(); - scalar calcFaceZonesIntegral + scalar calcIntegral ( - const surfaceScalarField& fD, - const faceZone& fz + const surfaceScalarField& sField, + const faceZone& fZone ) const; @@ -134,9 +135,8 @@ public: ); - // Destructor - - virtual ~faceZonesIntegration(); + //- Destructor + virtual ~faceZonesIntegration(); // Member Functions From 6302bef15921b57ddf3a9c2353101add1763c2fa Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 17 Aug 2009 14:32:44 +0100 Subject: [PATCH 3/7] removed duplicate comment lines --- src/OpenFOAM/meshes/polyMesh/zones/cellZone/newCellZone.C | 8 +------- src/OpenFOAM/meshes/polyMesh/zones/faceZone/newFaceZone.C | 8 +------- .../meshes/polyMesh/zones/pointZone/newPointZone.C | 7 +------ 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/newCellZone.C b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/newCellZone.C index 1905c9beda..607f47511a 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/newCellZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/newCellZone.C @@ -22,15 +22,11 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "cellZone.H" #include "dictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::autoPtr Foam::cellZone::New @@ -61,7 +57,7 @@ Foam::autoPtr Foam::cellZone::New "const label, const cellZoneMesh&)", dict ) << "Unknown cellZone type " << zoneType << endl << endl - << "Valid cellZone types are :" << endl + << "Valid cellZone types are:" << nl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalIOError); } @@ -70,6 +66,4 @@ Foam::autoPtr Foam::cellZone::New } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/newFaceZone.C b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/newFaceZone.C index 91506f5ce8..07f85cc180 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/newFaceZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/newFaceZone.C @@ -22,15 +22,11 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "faceZone.H" #include "dictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::autoPtr Foam::faceZone::New @@ -61,7 +57,7 @@ Foam::autoPtr Foam::faceZone::New "const label, const faceZoneMesh&)", dict ) << "Unknown faceZone type " << zoneType << endl << endl - << "Valid faceZone types are :" << endl + << "Valid faceZone types are:" << nl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalIOError); } @@ -70,6 +66,4 @@ Foam::autoPtr Foam::faceZone::New } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/newPointZone.C b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/newPointZone.C index 015bdea318..695e9f3bb6 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/pointZone/newPointZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/pointZone/newPointZone.C @@ -22,15 +22,11 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "pointZone.H" #include "dictionary.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::autoPtr Foam::pointZone::New @@ -61,7 +57,7 @@ Foam::autoPtr Foam::pointZone::New "const label, const pointZoneMesh&)", dict ) << "Unknown pointZone type " << zoneType << endl << endl - << "Valid pointZone types are :" << endl + << "Valid pointZone types are:" << nl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalIOError); } @@ -69,6 +65,5 @@ Foam::autoPtr Foam::pointZone::New return autoPtr(cstrIter()(name, dict, index, zm)); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // ************************************************************************* // From 52a389786347da4083047a5affb3b554befe23d5 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 17 Aug 2009 17:36:37 +0100 Subject: [PATCH 4/7] restructured zones - now have common base (zone) --- src/OpenFOAM/Make/files | 3 + .../meshes/polyMesh/zones/ZoneID/ZoneID.H | 1 + .../meshes/polyMesh/zones/cellZone/cellZone.C | 149 ++----------- .../meshes/polyMesh/zones/cellZone/cellZone.H | 57 +---- .../meshes/polyMesh/zones/faceZone/faceZone.C | 143 ++---------- .../meshes/polyMesh/zones/faceZone/faceZone.H | 56 ++--- .../polyMesh/zones/pointZone/pointZone.C | 157 ++----------- .../polyMesh/zones/pointZone/pointZone.H | 60 ++--- .../meshes/polyMesh/zones/zone/zone.C | 209 ++++++++++++++++++ .../meshes/polyMesh/zones/zone/zone.H | 207 +++++++++++++++++ 10 files changed, 516 insertions(+), 526 deletions(-) create mode 100644 src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C create mode 100644 src/OpenFOAM/meshes/polyMesh/zones/zone/zone.H diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index e608e4695b..7bff2143ec 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -345,6 +345,9 @@ $(globalMeshData)/globalIndex.C $(polyMesh)/syncTools/syncTools.C +zone = $(polyMesh)/zones/zone +$(zone)/zone.C + cellZone = $(polyMesh)/zones/cellZone $(cellZone)/cellZone.C $(cellZone)/newCellZone.C diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneID/ZoneID.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneID/ZoneID.H index 5c98efd84a..b6800dceb6 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneID/ZoneID.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneID/ZoneID.H @@ -114,6 +114,7 @@ public: return index_ > -1; } + // Edit //- Update diff --git a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C index ff8041fc60..a6c3293466 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/cellZone/cellZone.C @@ -45,59 +45,9 @@ namespace Foam addToRunTimeSelectionTable(cellZone, cellZone, dictionary); } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -const Foam::Map& Foam::cellZone::cellLookupMap() const -{ - if (!cellLookupMapPtr_) - { - calcCellLookupMap(); - } - - return *cellLookupMapPtr_; -} - - -void Foam::cellZone::calcCellLookupMap() const -{ - if (debug) - { - Info<< "void cellZone::calcCellLookupMap() const : " - << "Calculating cell lookup map" - << endl; - } - - if (cellLookupMapPtr_) - { - FatalErrorIn - ( - "void cellZone::calcCellLookupMap() const" - ) << "cell lookup map already calculated" - << abort(FatalError); - } - - const labelList& addr = *this; - - cellLookupMapPtr_ = new Map