From 41353e4dacc167cd3bca265f1df7413831b8c147 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 25 May 2017 14:44:59 +0100 Subject: [PATCH] Reorganisation and clean-up --- .../layerAdditionRemoval.H | 5 +- .../polyMeshModifier/polyMeshModifier.H | 5 +- .../polyMeshModifiers/setUpdater/setUpdater.C | 9 - .../polyMeshModifiers/setUpdater/setUpdater.H | 3 +- .../actions/addObject/polyAddCell.H | 23 ++ .../actions/addObject/polyAddFace.H | 301 ++++++++---------- .../actions/addObject/polyAddPoint.H | 65 ++-- .../polyTopoChange/polyTopoChange.H | 5 +- .../polyTopoChanger/polyTopoChanger.H | 7 +- .../polyTopoChangerChangeMesh.C | 2 +- .../lengthScaleEstimator.C | 7 +- 11 files changed, 221 insertions(+), 211 deletions(-) diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H index c13c616fe..566ddf551 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/layerAdditionRemoval.H @@ -166,9 +166,8 @@ public: ); - // Destructor - - virtual ~layerAdditionRemoval(); + //- Destructor + virtual ~layerAdditionRemoval(); // Member Functions diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/polyMeshModifier/polyMeshModifier.H b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/polyMeshModifier/polyMeshModifier.H index ae7285eb8..563987f8e 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/polyMeshModifier/polyMeshModifier.H +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/polyMeshModifier/polyMeshModifier.H @@ -134,9 +134,8 @@ public: ); - // Destructor - - virtual ~polyMeshModifier(); + //- Destructor + virtual ~polyMeshModifier(); // Member Functions diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/setUpdater/setUpdater.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/setUpdater/setUpdater.C index 241a9896e..42e80e885 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/setUpdater/setUpdater.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/setUpdater/setUpdater.C @@ -120,13 +120,4 @@ void Foam::setUpdater::writeDict(Ostream& os) const } -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/setUpdater/setUpdater.H b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/setUpdater/setUpdater.H index 0149023f5..e9a7b4524 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/setUpdater/setUpdater.H +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/setUpdater/setUpdater.H @@ -25,7 +25,7 @@ Class Foam::setUpdater Description - Keeps cell/face/vertex sets uptodate. Both the ones loaded and the ones + Keeps cell/face/vertex sets up-to-date: both the ones loaded and the ones on disk. SourceFiles @@ -116,6 +116,7 @@ public: } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #ifdef NoRepository # include "setUpdaterTemplates.C" #endif diff --git a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddCell.H b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddCell.H index 4a74c7a62..b99ae1503 100644 --- a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddCell.H +++ b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddCell.H @@ -103,6 +103,16 @@ public: zoneID_(zoneID) {} + //- Construct Istream + polyAddCell(Istream& is) + : + masterPointID_(readLabel(is)), + masterEdgeID_(readLabel(is)), + masterFaceID_(readLabel(is)), + masterCellID_(readLabel(is)), + zoneID_(readLabel(is)) + {} + //- Construct and return a clone virtual autoPtr clone() const { @@ -183,6 +193,19 @@ public: return zoneID_; } + + // IOstream Operators + + friend Ostream& operator<<(Ostream& os , const polyAddCell& pac) + { + os << pac.masterPointID_ + << pac.masterEdgeID_ + << pac.masterFaceID_ + << pac.masterCellID_ + << pac.zoneID_; + + return os; + } }; diff --git a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddFace.H b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddFace.H index 25d7cca60..33dec6ada 100644 --- a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddFace.H +++ b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddFace.H @@ -86,6 +86,104 @@ class polyAddFace bool zoneFlip_; + // Private Member Functions + + //- Check + void check() const + { + if (face_.size() < 3) + { + FatalErrorIn("polyAddFace::check()") + << "Invalid face: less than 3 points. " + << "This is not allowed.\n" + << "Face: " << face_ + << " masterPointID:" << masterPointID_ + << " masterEdgeID:" << masterEdgeID_ + << " masterFaceID:" << masterFaceID_ + << " patchID:" << patchID_ + << " owner:" << owner_ + << " neighbour:" << neighbour_ + << abort(FatalError); + } + + if (min(face_) < 0) + { + FatalErrorIn("polyAddFace::check()") + << "Face contains invalid vertex ID: " << face_ << ". " + << "This is not allowed.\n" + << "Face: " << face_ + << " masterPointID:" << masterPointID_ + << " masterEdgeID:" << masterEdgeID_ + << " masterFaceID:" << masterFaceID_ + << " patchID:" << patchID_ + << " owner:" << owner_ + << " neighbour:" << neighbour_ + << abort(FatalError); + } + + if (min(owner_, neighbour_) >= 0 && owner_ == neighbour_) + { + FatalErrorIn("polyAddFace::check()") + << "Face owner and neighbour are identical. " + << "This is not allowed.\n" + << "Face: " << face_ + << " masterPointID:" << masterPointID_ + << " masterEdgeID:" << masterEdgeID_ + << " masterFaceID:" << masterFaceID_ + << " patchID:" << patchID_ + << " owner:" << owner_ + << " neighbour:" << neighbour_ + << abort(FatalError); + } + + if (neighbour_ >= 0 && patchID_ >= 0) + { + FatalErrorIn("polyAddFace::check()") + << "Patch face has got a neighbour. Patch ID: " << patchID_ + << ". This is not allowed.\n" + << "Face: " << face_ + << " masterPointID:" << masterPointID_ + << " masterEdgeID:" << masterEdgeID_ + << " masterFaceID:" << masterFaceID_ + << " patchID:" << patchID_ + << " owner:" << owner_ + << " neighbour:" << neighbour_ + << abort(FatalError); + } + + if (owner_ < 0 && zoneID_ < 0) + { + FatalErrorIn("polyAddFace::check()") + << "Face has no owner and is not in a zone. " + << "This is not allowed.\n" + << "Face: " << face_ + << "Face: " << face_ + << " masterPointID:" << masterPointID_ + << " masterEdgeID:" << masterEdgeID_ + << " masterFaceID:" << masterFaceID_ + << " patchID:" << patchID_ + << " owner:" << owner_ + << " neighbour:" << neighbour_ + << abort(FatalError); + } + + if (zoneID_ == -1 && zoneFlip_) + { + FatalErrorIn("polyAddFace::check()") + << "Specified zone flip for a face that does not " + << "belong to zone. This is not allowed.\n" + << "Face: " << face_ + << " masterPointID:" << masterPointID_ + << " masterEdgeID:" << masterEdgeID_ + << " masterFaceID:" << masterFaceID_ + << " patchID:" << patchID_ + << " owner:" << owner_ + << " neighbour:" << neighbour_ + << abort(FatalError); + } + } + + public: // Static data members @@ -138,174 +236,24 @@ public: zoneID_(zoneID), zoneFlip_(zoneFlip) { - if (face_.size() < 3) - { - FatalErrorIn - ( - "polyAddFace\n" - "(\n" - " const face& f,\n" - " const label owner," - " const label neighbour,\n" - " const label masterPointID,\n" - " const label masterEdgeID,\n" - " const label masterFaceID,\n" - " const bool flipFaceFlux,\n" - " const label patchID,\n" - " const label zoneID,\n" - " const bool zoneFlip\n" - ")" - ) << "Invalid face: less than 3 points. " - << "This is not allowed.\n" - << "Face: " << face_ - << " masterPointID:" << masterPointID_ - << " masterEdgeID:" << masterEdgeID_ - << " masterFaceID:" << masterFaceID_ - << " patchID:" << patchID_ - << " owner:" << owner_ - << " neighbour:" << neighbour_ - << abort(FatalError); - } + check(); + } - if (min(face_) < 0) - { - FatalErrorIn - ( - "polyAddFace\n" - "(\n" - " const face& f,\n" - " const label owner," - " const label neighbour,\n" - " const label masterPointID,\n" - " const label masterEdgeID,\n" - " const label masterFaceID,\n" - " const bool flipFaceFlux,\n" - " const label patchID,\n" - " const label zoneID,\n" - " const bool zoneFlip\n" - ")" - ) << "Face contains invalid vertex ID: " << face_ << ". " - << "This is not allowed.\n" - << "Face: " << face_ - << " masterPointID:" << masterPointID_ - << " masterEdgeID:" << masterEdgeID_ - << " masterFaceID:" << masterFaceID_ - << " patchID:" << patchID_ - << " owner:" << owner_ - << " neighbour:" << neighbour_ - << abort(FatalError); - } - - if (min(owner_, neighbour_) >= 0 && owner_ == neighbour_) - { - FatalErrorIn - ( - "polyAddFace\n" - "(\n" - " const face& f,\n" - " const label owner," - " const label neighbour,\n" - " const label masterPointID,\n" - " const label masterEdgeID,\n" - " const label masterFaceID,\n" - " const bool flipFaceFlux,\n" - " const label patchID,\n" - " const label zoneID,\n" - " const bool zoneFlip\n" - ")" - ) << "Face owner and neighbour are identical. " - << "This is not allowed.\n" - << "Face: " << face_ - << " masterPointID:" << masterPointID_ - << " masterEdgeID:" << masterEdgeID_ - << " masterFaceID:" << masterFaceID_ - << " patchID:" << patchID_ - << " owner:" << owner_ - << " neighbour:" << neighbour_ - << abort(FatalError); - } - - if (neighbour_ >= 0 && patchID >= 0) - { - FatalErrorIn - ( - "polyAddFace\n" - "(\n" - " const face& f,\n" - " const label owner," - " const label neighbour,\n" - " const label masterPointID,\n" - " const label masterEdgeID,\n" - " const label masterFaceID,\n" - " const bool flipFaceFlux,\n" - " const label patchID,\n" - " const label zoneID,\n" - " const bool zoneFlip\n" - ")" - ) << "Patch face has got a neighbour. Patch ID: " << patchID - << ". This is not allowed.\n" - << "Face: " << face_ - << " masterPointID:" << masterPointID_ - << " masterEdgeID:" << masterEdgeID_ - << " masterFaceID:" << masterFaceID_ - << " patchID:" << patchID_ - << " owner:" << owner_ - << " neighbour:" << neighbour_ - << abort(FatalError); - } - - if (owner_ < 0 && zoneID < 0) - { - FatalErrorIn - ( - "polyAddFace\n" - "(\n" - " const face& f,\n" - " const label owner," - " const label neighbour,\n" - " const label patchID,\n" - " const label zoneID" - ")" - ) << "Face has no owner and is not in a zone. " - << "This is not allowed.\n" - << "Face: " << face_ - << "Face: " << face_ - << " masterPointID:" << masterPointID_ - << " masterEdgeID:" << masterEdgeID_ - << " masterFaceID:" << masterFaceID_ - << " patchID:" << patchID_ - << " owner:" << owner_ - << " neighbour:" << neighbour_ - << abort(FatalError); - } - - if (zoneID_ == -1 && zoneFlip) - { - FatalErrorIn - ( - "polyAddFace\n" - "(\n" - " const face& f,\n" - " const label owner," - " const label neighbour,\n" - " const label masterPointID,\n" - " const label masterEdgeID,\n" - " const label masterFaceID,\n" - " const label patchID,\n" - " const label zoneID,\n" - " const bool zoneFlip\n" - ")" - ) << "Specified zone flip for a face that does not " - << "belong to zone. This is not allowed.\n" - << "Face: " << face_ - << " masterPointID:" << masterPointID_ - << " masterEdgeID:" << masterEdgeID_ - << " masterFaceID:" << masterFaceID_ - << " patchID:" << patchID_ - << " owner:" << owner_ - << " neighbour:" << neighbour_ - << abort(FatalError); - } + //- Construct from Istream + polyAddFace(Istream& is) + : + face_(is), + owner_(readLabel(is)), + neighbour_(readLabel(is)), + masterPointID_(readLabel(is)), + masterEdgeID_(readLabel(is)), + masterFaceID_(readLabel(is)), + flipFaceFlux_(readBool(is)), + patchID_(readLabel(is)), + zoneID_(readLabel(is)), + zoneFlip_(readBool(is)) + { + check(); } //- Construct and return a clone @@ -420,6 +368,25 @@ public: { return zoneFlip_; } + + + // IOstream Operators + + friend Ostream& operator<<(Ostream& os , const polyAddFace& paf) + { + os << paf.face_ + << paf.owner_ + << paf.neighbour_ + << paf.masterPointID_ + << paf.masterEdgeID_ + << paf.masterFaceID_ + << paf.flipFaceFlux_ + << paf.patchID_ + << paf.zoneID_ + << paf.zoneFlip_; + + return os; + } }; diff --git a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddPoint.H b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddPoint.H index a886a9036..6d1eb685e 100644 --- a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddPoint.H +++ b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/actions/addObject/polyAddPoint.H @@ -64,6 +64,32 @@ class polyAddPoint bool inCell_; + // Private Member Functions + + //- Check + void check() const + { + if (zoneID_ < 0 && !inCell_) + { + FatalErrorIn + ( + "polyAddPoint\n" + "(\n" + " const point& p,\n" + " const label masterPointID,\n" + " const label zoneID,\n" + " const bool inCell\n" + ")" + ) << "Point is not in a cell and not in a zone. " + << "This is not allowed.\n" + << "point: " << p_ + << " master: " << masterPointID_ + << " zone: " << zoneID_ + << abort(FatalError); + } + } + + public: // Static data members @@ -97,25 +123,18 @@ public: zoneID_(zoneID), inCell_(inCell) { - if (zoneID_ < 0 && !inCell) - { - FatalErrorIn - ( - "polyAddPoint\n" - "(\n" - " const point& p,\n" - " const label masterPointID,\n" - " const label zoneID,\n" - " const bool inCell\n" - ")" - ) << "Point is not in a cell and not in a zone. " - << "This is not allowed.\n" - << "point: " << p - << " master: " << masterPointID_ - << " zone: " << zoneID_ - << abort(FatalError); - } + check(); + } + //- Construct from Istream + polyAddPoint(Istream& is) + : + p_(is), + masterPointID_(readLabel(is)), + zoneID_(readLabel(is)), + inCell_(readBool(is)) + { + check(); } //- Construct and return a clone @@ -165,6 +184,16 @@ public: { return inCell_; } + + + // IOstream Operators + + friend Ostream& operator<<(Ostream& os , const polyAddPoint& pap) + { + os << pap.p_ << pap.masterPointID_ << pap.zoneID_ << pap.inCell_; + + return os; + } }; diff --git a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H index 9f6f6d52b..ea85acf6d 100644 --- a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H +++ b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H @@ -130,9 +130,8 @@ public: polyTopoChange(const polyMesh&); - // Destructor - - ~polyTopoChange(); + //- Destructor + ~polyTopoChange(); // Member Functions diff --git a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H index 7835cdf1f..4dbaeb1c9 100644 --- a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H +++ b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.H @@ -124,10 +124,9 @@ public: explicit polyTopoChanger(polyMesh&); - // Destructor - - virtual ~polyTopoChanger() - {} + //- Destructor + virtual ~polyTopoChanger() + {} // Member functions diff --git a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChangerChangeMesh.C b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChangerChangeMesh.C index 2a7111c0e..7ea68768e 100644 --- a/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChangerChangeMesh.C +++ b/src/dynamicMesh/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChangerChangeMesh.C @@ -417,7 +417,7 @@ Foam::autoPtr Foam::polyTopoChanger::changeMesh if (debug) { - Pout<< "Added retired points: modified = " + Pout<< " modified = " << nNewPoints - debugPointCounter; debugPointCounter = nNewPoints; diff --git a/src/dynamicMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.C b/src/dynamicMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.C index 97d74fdb8..0f092f2a6 100644 --- a/src/dynamicMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.C +++ b/src/dynamicMesh/dynamicTopoFvMesh/lengthScaleEstimator/lengthScaleEstimator.C @@ -1039,6 +1039,9 @@ void lengthScaleEstimator::calculateLengthScale // Lookup various field types, and evaluate the gradient bool invalidObject = true; + // Evaluate using gradient scheme + word gradName("grad(" + field_ + ')'); + // Register field under a name that's unique word registerName("lengthScaleGradient(" + field_ + ')'); @@ -1062,7 +1065,7 @@ void lengthScaleEstimator::calculateLengthScale IOobject::NO_WRITE, false ), - mag(fvc::grad(field)) + mag(fvc::grad(field, gradName)) ) ); @@ -1089,7 +1092,7 @@ void lengthScaleEstimator::calculateLengthScale IOobject::NO_WRITE, false ), - mag(fvc::grad(field)) + mag(fvc::grad(field, gradName)) ) );