From 1452de4babc5ebf2d6fe48df1de57599ad6d2d13 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Mon, 2 Nov 2015 17:29:19 +0000 Subject: [PATCH] Clean-up of extended addressing and matrix --- .../extendedBlockLduMatrix.C | 18 ++-- .../extendedBlockLduMatrix.H | 17 +-- .../extendedLduAddressing.C | 102 +++++++++--------- .../extendedLduAddressing.H | 2 +- .../extendedLduMatrix/extendedLduMatrix.C | 20 ++-- .../extendedLduMatrix/extendedLduMatrix.H | 6 ++ 6 files changed, 89 insertions(+), 76 deletions(-) diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.C b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.C index ff209c3d5..f2886e99f 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.C +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.C @@ -27,6 +27,14 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +template +void Foam::extendedBlockLduMatrix::clearOut() +{ + deleteDemandDrivenData(extendedLowerPtr_); + deleteDemandDrivenData(extendedUpperPtr_); +} + + template void Foam::extendedBlockLduMatrix::mapOffDiagCoeffs ( @@ -253,15 +261,7 @@ Foam::extendedBlockLduMatrix::extendedBlockLduMatrix template Foam::extendedBlockLduMatrix::~extendedBlockLduMatrix() { - if (extendedLowerPtr_) - { - delete extendedLowerPtr_; - } - - if (extendedUpperPtr_) - { - delete extendedUpperPtr_; - } + clearOut(); } diff --git a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.H b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.H index 0b9dfa6b9..da1cdbe2d 100644 --- a/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.H +++ b/src/foam/matrices/blockLduMatrix/BlockLduMatrix/extendedBlockLduMatrix/extendedBlockLduMatrix.H @@ -85,9 +85,15 @@ private: //- Disallow default bitwise assignement void operator=(const extendedBlockLduMatrix&); - //- Map upper and lower coeffs from ordinary block matrix to extended - // block matrix - void mapOffDiagCoeffs(const BlockLduMatrix&); + + // Helper functions + + //- Clear all demand driven data - helper function + void clearOut(); + + //- Map upper and lower coeffs from ordinary block matrix to + // extended block matrix + void mapOffDiagCoeffs(const BlockLduMatrix&); public: @@ -106,9 +112,8 @@ public: ); - // Destructor - - ~extendedBlockLduMatrix(); + //- Destructor + ~extendedBlockLduMatrix(); // Member functions diff --git a/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.C b/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.C index 8e0aa6a37..c4112cb84 100644 --- a/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.C +++ b/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.C @@ -35,58 +35,9 @@ namespace Foam } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::extendedLduAddressing::extendedLduAddressing -( - const lduAddressing& lduAddr, - const label extensionLevel -) -: - lduAddr_(lduAddr), - p_(extensionLevel), - extendedLowerPtr_(NULL), - extendedUpperPtr_(NULL), - faceMapPtr_(NULL), - extendedLosortPtr_(NULL), - extendedOwnerStartPtr_(NULL), - extendedLosortStartPtr_(NULL) -{ - // Issue an error if a negative extension level is selected - if (p_ < 0) - { - FatalErrorIn - ( - "extendedLduAddressing::extendedLduAddressing" - ) - << "Negative extension level not allowed." - << abort(FatalError); - } - // Disallow extension level 0 as it is the same as ordinary lduAddressing - else if (p_ == 0) - { - FatalErrorIn - ( - "extendedLduAddressing::extendedLduAddressing" - ) - << "Extension level 0 not allowed as it is the same as ordinary " - << "lduAddressing." - << abort(FatalError); - } -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * / - -Foam::extendedLduAddressing::~extendedLduAddressing() -{ - clearAllDemandDrivenData(); -} - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::extendedLduAddressing::clearAllDemandDrivenData() const +void Foam::extendedLduAddressing::clearOut() const { deleteDemandDrivenData(extendedLowerPtr_); deleteDemandDrivenData(extendedUpperPtr_); @@ -460,6 +411,55 @@ void Foam::extendedLduAddressing::calcExtendedLosortStart() const } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::extendedLduAddressing::extendedLduAddressing +( + const lduAddressing& lduAddr, + const label extensionLevel +) +: + lduAddr_(lduAddr), + p_(extensionLevel), + extendedLowerPtr_(NULL), + extendedUpperPtr_(NULL), + faceMapPtr_(NULL), + extendedLosortPtr_(NULL), + extendedOwnerStartPtr_(NULL), + extendedLosortStartPtr_(NULL) +{ + // Issue an error if a negative extension level is selected + if (p_ < 0) + { + FatalErrorIn + ( + "extendedLduAddressing::extendedLduAddressing" + ) + << "Negative extension level not allowed." + << abort(FatalError); + } + // Disallow extension level 0 as it is the same as ordinary lduAddressing + else if (p_ == 0) + { + FatalErrorIn + ( + "extendedLduAddressing::extendedLduAddressing" + ) + << "Extension level 0 not allowed as it is the same as ordinary " + << "lduAddressing." + << abort(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * / + +Foam::extendedLduAddressing::~extendedLduAddressing() +{ + clearOut(); +} + + // * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * * // const Foam::unallocLabelList& @@ -591,7 +591,7 @@ bool Foam::extendedLduAddressing::updateMesh(const mapPolyMesh& mpm) const ) << "Clearing extendedLduAddressing data" << endl; } - clearAllDemandDrivenData(); + clearOut(); return true; } diff --git a/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.H b/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.H index e6b1bf539..8d3e3d948 100644 --- a/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.H +++ b/src/foam/matrices/lduMatrix/lduAddressing/extendedLduAddressing/extendedLduAddressing.H @@ -106,7 +106,7 @@ class extendedLduAddressing // Helper functions //- Clear all demand driven data - helper function - void clearAllDemandDrivenData() const; + void clearOut() const; //- Recursive function that inserts cell neighbours in a hash set // Parameters: diff --git a/src/foam/matrices/lduMatrix/lduMatrix/extendedLduMatrix/extendedLduMatrix.C b/src/foam/matrices/lduMatrix/lduMatrix/extendedLduMatrix/extendedLduMatrix.C index 711a2f28d..1668e2084 100644 --- a/src/foam/matrices/lduMatrix/lduMatrix/extendedLduMatrix/extendedLduMatrix.C +++ b/src/foam/matrices/lduMatrix/lduMatrix/extendedLduMatrix/extendedLduMatrix.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "extendedLduMatrix.H" +#include "demandDrivenData.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -33,6 +34,15 @@ namespace Foam } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::extendedLduMatrix::clearOut() +{ + deleteDemandDrivenData(extendedLowerPtr_); + deleteDemandDrivenData(extendedUpperPtr_); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::extendedLduMatrix::extendedLduMatrix @@ -118,15 +128,7 @@ Foam::extendedLduMatrix::extendedLduMatrix Foam::extendedLduMatrix::~extendedLduMatrix() { - if (extendedLowerPtr_) - { - delete extendedLowerPtr_; - } - - if (extendedUpperPtr_) - { - delete extendedUpperPtr_; - } + clearOut(); } diff --git a/src/foam/matrices/lduMatrix/lduMatrix/extendedLduMatrix/extendedLduMatrix.H b/src/foam/matrices/lduMatrix/lduMatrix/extendedLduMatrix/extendedLduMatrix.H index d1300200a..e24aaf65d 100644 --- a/src/foam/matrices/lduMatrix/lduMatrix/extendedLduMatrix/extendedLduMatrix.H +++ b/src/foam/matrices/lduMatrix/lduMatrix/extendedLduMatrix/extendedLduMatrix.H @@ -78,6 +78,12 @@ class extendedLduMatrix void operator=(const extendedLduMatrix&); + // Helper functions + + //- Clear all demand driven data - helper function + void clearOut(); + + public: