Clean-up of extended addressing and matrix

This commit is contained in:
Hrvoje Jasak 2015-11-02 17:29:19 +00:00
parent 45838c7dbe
commit 1452de4bab
6 changed files with 89 additions and 76 deletions

View file

@ -27,6 +27,14 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::extendedBlockLduMatrix<Type>::clearOut()
{
deleteDemandDrivenData(extendedLowerPtr_);
deleteDemandDrivenData(extendedUpperPtr_);
}
template<class Type> template<class Type>
void Foam::extendedBlockLduMatrix<Type>::mapOffDiagCoeffs void Foam::extendedBlockLduMatrix<Type>::mapOffDiagCoeffs
( (
@ -253,15 +261,7 @@ Foam::extendedBlockLduMatrix<Type>::extendedBlockLduMatrix
template<class Type> template<class Type>
Foam::extendedBlockLduMatrix<Type>::~extendedBlockLduMatrix() Foam::extendedBlockLduMatrix<Type>::~extendedBlockLduMatrix()
{ {
if (extendedLowerPtr_) clearOut();
{
delete extendedLowerPtr_;
}
if (extendedUpperPtr_)
{
delete extendedUpperPtr_;
}
} }

View file

@ -85,9 +85,15 @@ private:
//- Disallow default bitwise assignement //- Disallow default bitwise assignement
void operator=(const extendedBlockLduMatrix<Type>&); void operator=(const extendedBlockLduMatrix<Type>&);
//- Map upper and lower coeffs from ordinary block matrix to extended
// block matrix // Helper functions
void mapOffDiagCoeffs(const BlockLduMatrix<Type>&);
//- 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<Type>&);
public: public:
@ -106,9 +112,8 @@ public:
); );
// Destructor //- Destructor
~extendedBlockLduMatrix();
~extendedBlockLduMatrix();
// Member functions // Member functions

View file

@ -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 * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::extendedLduAddressing::clearAllDemandDrivenData() const void Foam::extendedLduAddressing::clearOut() const
{ {
deleteDemandDrivenData(extendedLowerPtr_); deleteDemandDrivenData(extendedLowerPtr_);
deleteDemandDrivenData(extendedUpperPtr_); 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 * * * * * * * * * * * * * // // * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * * //
const Foam::unallocLabelList& const Foam::unallocLabelList&
@ -591,7 +591,7 @@ bool Foam::extendedLduAddressing::updateMesh(const mapPolyMesh& mpm) const
) << "Clearing extendedLduAddressing data" << endl; ) << "Clearing extendedLduAddressing data" << endl;
} }
clearAllDemandDrivenData(); clearOut();
return true; return true;
} }

View file

@ -106,7 +106,7 @@ class extendedLduAddressing
// Helper functions // Helper functions
//- Clear all demand driven data - helper function //- Clear all demand driven data - helper function
void clearAllDemandDrivenData() const; void clearOut() const;
//- Recursive function that inserts cell neighbours in a hash set //- Recursive function that inserts cell neighbours in a hash set
// Parameters: // Parameters:

View file

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "extendedLduMatrix.H" #include "extendedLduMatrix.H"
#include "demandDrivenData.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -33,6 +34,15 @@ namespace Foam
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::extendedLduMatrix::clearOut()
{
deleteDemandDrivenData(extendedLowerPtr_);
deleteDemandDrivenData(extendedUpperPtr_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::extendedLduMatrix::extendedLduMatrix Foam::extendedLduMatrix::extendedLduMatrix
@ -118,15 +128,7 @@ Foam::extendedLduMatrix::extendedLduMatrix
Foam::extendedLduMatrix::~extendedLduMatrix() Foam::extendedLduMatrix::~extendedLduMatrix()
{ {
if (extendedLowerPtr_) clearOut();
{
delete extendedLowerPtr_;
}
if (extendedUpperPtr_)
{
delete extendedUpperPtr_;
}
} }

View file

@ -78,6 +78,12 @@ class extendedLduMatrix
void operator=(const extendedLduMatrix&); void operator=(const extendedLduMatrix&);
// Helper functions
//- Clear all demand driven data - helper function
void clearOut();
public: public: