diff --git a/meshLibrary/utilities/containers/DynList/DynList.H b/meshLibrary/utilities/containers/DynList/DynList.H index 365a33d12a8f91f9c42c66d017ecf721e71c4861..c5ee94274110e6f408ba22e5f10e7fe7448a01c6 100644 --- a/meshLibrary/utilities/containers/DynList/DynList.H +++ b/meshLibrary/utilities/containers/DynList/DynList.H @@ -77,7 +77,7 @@ template<class T, Foam::label staticSize = 16> class DynList { // Private data - + // //- pointer to the data T* dataPtr_; @@ -108,14 +108,6 @@ class DynList //- check if nAllocated_ is greater or equal to nextFree_ inline void checkAllocation() const; - //- Copy construct from almost any other type of list - template<class ListType> - inline void copyConstructList(const ListType& lst); - - //- Copy assign from almost any other type of list - template<class ListType> - inline void copyAssignList(const ListType& lst); - public: @@ -125,15 +117,7 @@ public: inline DynList(); //- Construct given size - explicit inline DynList(const label nElem); - - //- Construct given integer size - #if WM_LABEL_SIZE == 64 - explicit inline DynList(const int32_t nElem) - : - DynList(label(nElem)) - {} - #endif + explicit inline DynList(const label); //- Construct from given size and defualt value explicit inline DynList(const label, const T&); @@ -228,18 +212,14 @@ public: inline const T& rcValue(const label index) const; //- Assignment of all entries to the given value - inline void operator=(const T& val); - - //- Copy of another list - template<label AnySize> - inline void operator=(const DynList<T, AnySize>&); + inline void operator=(const T&); //- Copy of another list - inline void operator=(const UList<T>& lst); + inline void operator=(const DynList<T, staticSize>&); - //- Copy of another list - template<unsigned FixedSize> - inline void operator=(const FixedList<T, FixedSize>& lst); + //- Copy of another list type + template<class ListType> + inline void operator=(const ListType&); //- Compare the list with the another one inline bool operator==(const DynList<T, staticSize>&) const; diff --git a/meshLibrary/utilities/containers/DynList/DynListI.H b/meshLibrary/utilities/containers/DynList/DynListI.H index f64af41ffeb181deb731577f2a994f8d766d5b43..37902f4f92257a4188e253d5feef37219c047c10 100644 --- a/meshLibrary/utilities/containers/DynList/DynListI.H +++ b/meshLibrary/utilities/containers/DynList/DynListI.H @@ -124,50 +124,6 @@ inline void Foam::Module::DynList<T, staticSize>::checkAllocation() const } -template<class T, Foam::label staticSize> -template<class ListType> -inline void Foam::Module::DynList<T, staticSize>::copyConstructList -( - const ListType& lst -) -{ - setSize(lst.size()); - for (label i = 0; i < nextFree_; ++i) - { - this->operator[](i) = lst[i]; - } - - # ifdef DEBUG - checkAllocation(); - # endif -} - - -template<class T, Foam::label staticSize> -template<class ListType> -inline void Foam::Module::DynList<T, staticSize>::copyAssignList -( - const ListType& lst -) -{ - # ifdef DEBUG - checkAllocation(); - # endif - - allocateSize(lst.size()); - nextFree_ = lst.size(); - - # ifdef DEBUG - checkAllocation(); - # endif - - for (label i = 0; i < nextFree_; ++i) - { - this->operator[](i) = lst[i]; - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class T, Foam::label staticSize> @@ -179,25 +135,35 @@ inline Foam::Module::DynList<T, staticSize>::DynList() nextFree_(0) { setSize(0); + + # ifdef DEBUG + checkAllocation(); + # endif + } template<class T, Foam::label staticSize> -inline Foam::Module::DynList<T, staticSize>::DynList(const label nElem) +inline Foam::Module::DynList<T, staticSize>::DynList(const label s) : dataPtr_(nullptr), nAllocated_(0), staticData_(), nextFree_(0) { - setSize(nElem); + setSize(s); + + # ifdef DEBUG + checkAllocation(); + # endif + } template<class T, Foam::label staticSize> inline Foam::Module::DynList<T, staticSize>::DynList ( - const label nElem, + const label s, const T& val ) : @@ -206,44 +172,65 @@ inline Foam::Module::DynList<T, staticSize>::DynList staticData_(), nextFree_(0) { - setSize(nElem); + setSize(s); - for (label i = 0; i < nElem; ++i) + for (label i = 0; i < s; ++i) { this->operator[](i) = val; } + + # ifdef DEBUG + checkAllocation(); + # endif } template<class T, Foam::label staticSize> -inline Foam::Module::DynList<T, staticSize>::DynList(const UList<T>& lst) +inline Foam::Module::DynList<T, staticSize>::DynList(const UList<T>& ul) : dataPtr_(nullptr), nAllocated_(0), staticData_(), nextFree_(0) { - copyConstructList(lst); + setSize(ul.size()); + + forAll(ul, i) + { + this->operator[](i) = ul[i]; + } + + # ifdef DEBUG + checkAllocation(); + # endif } template<class T, Foam::label staticSize> template<class ListType> -inline Foam::Module::DynList<T, staticSize>::DynList(const ListType& lst) +inline Foam::Module::DynList<T, staticSize>::DynList(const ListType& l) : dataPtr_(nullptr), nAllocated_(0), staticData_(), nextFree_(0) { - copyConstructList(lst); + setSize(l.size()); + for (label i = 0; i < nextFree_; ++i) + { + this->operator[](i) = l[i]; + } + + # ifdef DEBUG + checkAllocation(); + # endif } template<class T, Foam::label staticSize> inline Foam::Module::DynList<T, staticSize>::DynList ( - const DynList<T, staticSize>& lst + const DynList<T, staticSize>& dl ) : dataPtr_(nullptr), @@ -251,7 +238,15 @@ inline Foam::Module::DynList<T, staticSize>::DynList staticData_(), nextFree_(0) { - copyConstructList(lst); + setSize(dl.size()); + for (label i = 0; i < nextFree_; ++i) + { + this->operator[](i) = dl[i]; + } + + # ifdef DEBUG + checkAllocation(); + # endif } @@ -588,34 +583,48 @@ inline void Foam::Module::DynList<T, staticSize>::operator=(const T& t) template<class T, Foam::label staticSize> -template<Foam::label AnySize> inline void Foam::Module::DynList<T, staticSize>::operator= ( - const DynList<T, AnySize>& lst + const DynList<T, staticSize>& dl ) { - copyAssignList(lst); -} + # ifdef DEBUG + checkAllocation(); + # endif + allocateSize(dl.size()); + nextFree_ = dl.size(); -template<class T, Foam::label staticSize> -inline void Foam::Module::DynList<T, staticSize>::operator= -( - const UList<T>& lst -) -{ - copyAssignList(lst); + # ifdef DEBUG + checkAllocation(); + # endif + + for (label i = 0; i < nextFree_; ++i) + { + this->operator[](i) = dl[i]; + } } template<class T, Foam::label staticSize> -template<unsigned FixedSize> -inline void Foam::Module::DynList<T, staticSize>::operator= -( - const FixedList<T, FixedSize>& lst -) +template<class ListType> +inline void Foam::Module::DynList<T, staticSize>::operator=(const ListType& l) { - copyAssignList(lst); + # ifdef DEBUG + checkAllocation(); + # endif + + allocateSize(l.size()); + nextFree_ = l.size(); + + # ifdef DEBUG + checkAllocation(); + # endif + + for (label i = 0; i < nextFree_; ++i) + { + this->operator[](i) = l[i]; + } } diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctree.C b/meshLibrary/utilities/octrees/meshOctree/meshOctree.C index 4331d70d4ea6a0063294f0aa67599b48db92bac1..557e1ad322380b676e6896cc6e0e0119caff1d8a 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctree.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctree.C @@ -121,7 +121,7 @@ void Foam::Module::meshOctree::setOctantVectorsAndPositions() // set vrtLeavesPos_ for (label vrtI = 0; vrtI < 8; ++vrtI) { - FixedList<label, 3> vc(Zero); + FixedList<label, 3> vc(0); if (vrtI & 1) { @@ -142,7 +142,7 @@ void Foam::Module::meshOctree::setOctantVectorsAndPositions() for (label i = 0; i < 8; ++i) { - FixedList<label, 3> pos(Zero); + FixedList<label, 3> pos; for (label j = 0; j < 3; ++j) { diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.C index 6471a762fc3b7b285ac10d142eedaa8d66285ea9..b79ef18d54523ea25e711e21a744bb015a0ecf51 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeAutomaticRefinement/meshOctreeAutomaticRefinement.C @@ -136,7 +136,7 @@ void Foam::Module::meshOctreeAutomaticRefinement::setMaxRefLevel() { finished = false; - const scalar lSize = size/pow(label(2), label(maxRefLevel_)); + const scalar lSize = size/pow(2, label(maxRefLevel_)); if (lSize < cs) { diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeCreator/meshOctreeCreatorCreateOctreeBoxes.C b/meshLibrary/utilities/octrees/meshOctree/meshOctreeCreator/meshOctreeCreatorCreateOctreeBoxes.C index 214cf5f00b169aa007dbf7508427fe8229bfc422..374c00c5c5a0012aea4e627ff9833707b582ee7f 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeCreator/meshOctreeCreatorCreateOctreeBoxes.C +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeCreator/meshOctreeCreatorCreateOctreeBoxes.C @@ -81,12 +81,12 @@ void Foam::Module::meshOctreeCreator::setRootCubeSizeAndRefParameters() { finished = false; - const scalar lSize = size/Foam::pow(label(2), label(globalRefLevel_)); + const scalar lSize = size/Foam::pow(2, label(globalRefLevel_)); if (lSize <(maxSize*(1.0 - SMALL))) { const scalar bbSize = - 0.5*maxSize*Foam::pow(label(2), label(globalRefLevel_)); + 0.5*maxSize*Foam::pow(2, label(globalRefLevel_)); rootBox.max() = c + point(bbSize, bbSize, bbSize); rootBox.min() = c - point(bbSize, bbSize, bbSize); finished = true; @@ -132,7 +132,7 @@ void Foam::Module::meshOctreeCreator::setRootCubeSizeAndRefParameters() { finished = false; - const scalar lSize = maxSize/Foam::pow(label(2), addLevel); + const scalar lSize = maxSize/Foam::pow(2, addLevel); if (lSize <= cs) { @@ -237,7 +237,7 @@ void Foam::Module::meshOctreeCreator::setRootCubeSizeAndRefParameters() { finished = false; - const scalar lSize = maxSize/Foam::pow(label(2), addLevel); + const scalar lSize = maxSize/Foam::pow(2, addLevel); if (lSize <= cs) { @@ -321,7 +321,7 @@ void Foam::Module::meshOctreeCreator::setRootCubeSizeAndRefParameters() { finished = false; - const scalar lSize = maxSize/Foam::pow(label(2), addLevel); + const scalar lSize = maxSize/Foam::pow(2, addLevel); if (lSize <= cs) { @@ -405,8 +405,7 @@ void Foam::Module::meshOctreeCreator::setRootCubeSizeAndRefParameters() { finished = false; - const scalar lSize = - maxSize/Foam::pow(label(2), nLevel); + const scalar lSize = maxSize/Foam::pow(2, nLevel); if (lSize <= cs) { diff --git a/meshLibrary/utilities/octrees/meshOctree/meshOctreeCube/meshOctreeCubeCoordinatesI.H b/meshLibrary/utilities/octrees/meshOctree/meshOctreeCube/meshOctreeCubeCoordinatesI.H index e32d1c749def8dfb48ee4e408dbef939e71c7ceb..2679e329ff64b13fb0ea9710f58b8a29019a9323 100644 --- a/meshLibrary/utilities/octrees/meshOctree/meshOctreeCube/meshOctreeCubeCoordinatesI.H +++ b/meshLibrary/utilities/octrees/meshOctree/meshOctreeCube/meshOctreeCubeCoordinatesI.H @@ -96,7 +96,7 @@ Foam::Module::meshOctreeCubeCoordinates::refineForPosition ) const { //- create new boxes in z-order fashion - FixedList<label, 3> addPos(Zero); + FixedList<label, 3> addPos(0); if (i & 1) { addPos[0] = 1;