diff --git a/applications/test/CompactListList/CompactListListTest.C b/applications/test/CompactListList/CompactListListTest.C index 136b5f458375fc9bad625135fd8439919970c257..cd3270a169c6d953616b8e6cf6280fd90725af44 100644 --- a/applications/test/CompactListList/CompactListListTest.C +++ b/applications/test/CompactListList/CompactListListTest.C @@ -32,6 +32,9 @@ Description #include "CompactListList.H" #include "IOstreams.H" +#include "OStringStream.H" +#include "IStringStream.H" +#include "faceList.H" using namespace Foam; @@ -40,7 +43,29 @@ using namespace Foam; int main(int argc, char *argv[]) { - CompactListList<label> cll1; + { + // null construct + CompactListList<label> cll1; + Info<< "cll1:" << cll1 << endl; + + // Resize and assign row by row + labelList row0(2, 0); + labelList row1(3, 1); + + labelList rowSizes(2); + rowSizes[0] = row0.size(); + rowSizes[1] = row1.size(); + cll1.resize(rowSizes); + + cll1[0].assign(row0); //note: operator= will not work since UList + cll1[1].assign(row1); + Info<< "cll1:" << cll1 << endl; + + forAll(cll1.m(), i) + { + Info<< "i:" << i << " whichRow:" << cll1.whichRow(i) << endl; + } + } List<List<label> > lll(5); lll[0].setSize(3, 0); @@ -60,14 +85,21 @@ int main(int argc, char *argv[]) Info<< endl; + Info<< "cll2(2, 3) = " << cll2(2, 3) << nl << endl; + cll2(2, 3) = 999; Info<< "cll2(2, 3) = " << cll2(2, 3) << nl << endl; - Info<< "cll2 as List<List<label > > " << List<List<label > >(cll2) << endl; + Info<< "cll2 as List<List<label > > " << cll2() + << endl; cll2.setSize(3); Info<< "cll2 = " << cll2 << endl; + cll2.setSize(0); + + Info<< "cll2 = " << cll2 << endl; + List<label> rowSizes(5); rowSizes[0] = 2; @@ -87,6 +119,39 @@ int main(int argc, char *argv[]) Info<< "cll3 = " << cll3 << endl; Info<< "cll4 = " << cll4 << endl; + + { + // IO + OStringStream ostr; + ostr << cll4; + + IStringStream istr(ostr.str()); + CompactListList<label> cll5(istr); + Info<< "cll5 = " << cll5 << endl; + } + { + // IO + cll4.clear(); + OStringStream ostr; + ostr << cll4; + + IStringStream istr(ostr.str()); + CompactListList<label> cll5(istr); + Info<< "cll5 = " << cll5 << endl; + } + + { + faceList fcs(2); + fcs[0] = face(labelList(1, 111)); + fcs[1] = face(labelList(2, 222)); + + CompactListList<label, face> compactFcs(fcs); + Info<< "comactFcs:" << compactFcs << endl; + + faceList fcs2 = compactFcs(); + Info<< "fcs2:" << fcs2 << endl; + } + return 0; } diff --git a/applications/test/globalIndex/Make/files b/applications/test/globalIndex/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd88f145991084bea588c9cb7d1cab9924b63 --- /dev/null +++ b/applications/test/globalIndex/Make/files @@ -0,0 +1,4 @@ +globalIndex.C +globalIndexTest.C + +EXE = $(FOAM_USER_APPBIN)/globalIndexTest diff --git a/applications/test/globalIndex/Make/options b/applications/test/globalIndex/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..90f18e878fb879774c8cf332dfab8a0cb5e3eaa6 --- /dev/null +++ b/applications/test/globalIndex/Make/options @@ -0,0 +1 @@ +EXE_INC = /* -DFULLDEBUG -g -O0 */ diff --git a/applications/test/globalIndex/globalIndexTest.C b/applications/test/globalIndex/globalIndexTest.C new file mode 100644 index 0000000000000000000000000000000000000000..60650cd93af79ef07e2dcfdd5e7cf7de413329e1 --- /dev/null +++ b/applications/test/globalIndex/globalIndexTest.C @@ -0,0 +1,171 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + globalIndexTest + +Description + Simple demonstration and test application for the globalIndex class. + +\*---------------------------------------------------------------------------*/ + +#include "globalIndex.H" +#include "argList.H" +#include "Time.H" +#include "polyMesh.H" +#include "IOstreams.H" +#include "OStringStream.H" +#include "IStringStream.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ +# include "setRootCase.H" +# include "createTime.H" +# include "createPolyMesh.H" + + // Global numbering of cells (proc0 elements first, then proc1, etc.) + globalIndex globalNumbering(mesh.nCells()); + + if (globalNumbering.localSize() != mesh.nCells()) + { + FatalErrorIn(args.executable()) + << "Problem." << abort(FatalError); + } + + + if (!Pstream::parRun()) + { + WarningIn(args.executable()) + << "globalIndex class is only useful in parallel code." + << endl; + } + + // convert from local to global and back. + for (label cellI = 0; cellI < mesh.nCells(); cellI++) + { + // to global index + label globalCellI = globalNumbering.toGlobal(cellI); + + // and back + label procI = globalNumbering.whichProcID(globalCellI); + label localCellI = globalNumbering.toLocal(globalCellI); + + if (procI != Pstream::myProcNo() || localCellI != cellI) + { + FatalErrorIn(args.executable()) + << "Problem. cellI:" << cellI << " localCellI:" << localCellI + << " procI:" << procI << abort(FatalError); + } + + if (!globalNumbering.isLocal(globalCellI)) + { + FatalErrorIn(args.executable()) + << "Problem. cellI:" << cellI << " globalCellI:" << globalCellI + << " not local" << abort(FatalError); + } + } + + + // Try whichProcID on a few borderline cases. + + if (mesh.nCells() < 1) + { + FatalErrorIn(args.executable()) + << "Test needs to be run on a case with at least one" + << " cell per processor." << abort(FatalError); + } + + if (Pstream::myProcNo() > 0) + { + // We already checked that toGlobal(0) maps back correctly to myProcNo + // so now check that the index one before maps to the previous processor + label prevProcCellI = globalNumbering.toGlobal(0)-1; + label procI = globalNumbering.whichProcID(prevProcCellI); + + if (procI != Pstream::myProcNo()-1) + { + FatalErrorIn(args.executable()) + << "Problem. global:" << prevProcCellI + << " expected on processor:" << Pstream::myProcNo()-1 + << " but is calculated to be on procI:" << procI + << abort(FatalError); + } + + if (globalNumbering.isLocal(prevProcCellI)) + { + FatalErrorIn(args.executable()) + << "Problem. globalCellI:" << prevProcCellI + << " calculated as local" << abort(FatalError); + } + + if (!globalNumbering.isLocal(procI, prevProcCellI)) + { + FatalErrorIn(args.executable()) + << "Problem. globalCellI:" << prevProcCellI + << " not calculated as local on processor:" << procI + << abort(FatalError); + } + } + + + if (Pstream::myProcNo() < Pstream::nProcs()-1) + { + label nextProcCellI = globalNumbering.toGlobal(mesh.nCells()-1)+1; + label procI = globalNumbering.whichProcID(nextProcCellI); + + if (procI != Pstream::myProcNo()+1) + { + FatalErrorIn(args.executable()) + << "Problem. global:" << nextProcCellI + << " expected on processor:" << Pstream::myProcNo()+1 + << " but is calculated to be on procI:" << procI + << abort(FatalError); + } + + if (globalNumbering.isLocal(nextProcCellI)) + { + FatalErrorIn(args.executable()) + << "Problem. globalCellI:" << nextProcCellI + << " calculated as local" << abort(FatalError); + } + + if (!globalNumbering.isLocal(procI, nextProcCellI)) + { + FatalErrorIn(args.executable()) + << "Problem. globalCellI:" << nextProcCellI + << " not calculated as local on processor:" << procI + << abort(FatalError); + } + } + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index 3732c7e4ec1d9d17f5f55226666ba345b4a0e463..7b348015d40cf5147d80f8eb5868b398bf086c5c 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -283,11 +283,11 @@ void printHelp(Ostream& os) << " cellSet c0 list" << endl << endl << "Zones can be set using zoneSets from corresponding sets:" << endl - << " cellZoneSet c0Zone new setToZone c0" << endl - << " faceZoneSet f0Zone new setToZone f0" << endl + << " cellZoneSet c0Zone new setToCellZone c0" << endl + << " faceZoneSet f0Zone new setToFaceZone f0" << endl << endl << "or if orientation is important:" << endl - << " faceZoneSet f0Zone new setsToZone f0 c0" << endl + << " faceZoneSet f0Zone new setsToFaceZone f0 c0" << endl << endl << "ZoneSets can be manipulated using the general actions:" << endl << " list - prints the contents of the set" << endl diff --git a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C index bc193810bd96c1c43fb4739cf734c5363a54a11f..de6d5c10e4ec187c3f0b6c1999772120e62be77a 100644 --- a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C +++ b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C @@ -163,10 +163,13 @@ int main(int argc, char *argv[]) // Addressing on faces only in mesh vertices. primitiveFacePatch fPatch ( - UIndirectList<face> + faceList ( - mesh.faces(), - faces + UIndirectList<face> + ( + mesh.faces(), + faces + ) ), mesh.points() ); diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C index 8e802fe48ea5453089c9073d792d15108ed4284c..e91b725624f8344881d99dc00e89672f59bf6fbe 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C @@ -28,16 +28,18 @@ License // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // -template<class T> -Foam::CompactListList<T>::CompactListList(const List<List<T> >& ll) +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList(const List<Container>& ll) : - offsets_(ll.size()) + size_(ll.size()), + offsets_(ll.size()+1) { label sumSize = 0; + offsets_[0] = 0; forAll(ll, i) { sumSize += ll[i].size(); - offsets_[i] = sumSize; + offsets_[i+1] = sumSize; } m_.setSize(sumSize); @@ -45,7 +47,7 @@ Foam::CompactListList<T>::CompactListList(const List<List<T> >& ll) label k = 0; forAll(ll, i) { - const List<T>& lli = ll[i]; + const Container& lli = ll[i]; forAll(lli, j) { @@ -55,62 +57,67 @@ Foam::CompactListList<T>::CompactListList(const List<List<T> >& ll) } -template<class T> -Foam::CompactListList<T>::CompactListList +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList ( const UList<label>& rowSizes ) : - offsets_(rowSizes.size()) + size_(rowSizes.size()), + offsets_(rowSizes.size()+1) { label sumSize = 0; + offsets_[0] = 0; forAll(rowSizes, i) { sumSize += rowSizes[i]; - offsets_[i] = sumSize; + offsets_[i+1] = sumSize; } m_.setSize(sumSize); } -template<class T> -Foam::CompactListList<T>::CompactListList +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList ( const UList<label>& rowSizes, const T& t ) : - offsets_(rowSizes.size()) + size_(rowSizes.size()), + offsets_(rowSizes.size()+1) { label sumSize = 0; + offsets_[0] = 0; forAll(rowSizes, i) { sumSize += rowSizes[i]; - offsets_[i] = sumSize; + offsets_[i+1] = sumSize; } m_.setSize(sumSize, t); } -template<class T> -Foam::CompactListList<T>::CompactListList +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList ( - const Xfer<CompactListList<T> >& lst + const Xfer<CompactListList<T, Container> >& lst ) { transfer(lst()); } -template<class T> -Foam::CompactListList<T>::CompactListList +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList ( - CompactListList<T>& lst, + CompactListList<T, Container>& lst, bool reUse ) : + size_(lst.size()), offsets_(lst.offsets_, reUse), m_(lst.m_, reUse) {} @@ -118,22 +125,25 @@ Foam::CompactListList<T>::CompactListList // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class T> -void Foam::CompactListList<T>::setSize(const label nRows) +template<class T, class Container> +void Foam::CompactListList<T, Container>::setSize(const label nRows) { if (nRows == 0) { clear(); } - if (nRows < offsets_.size()) + if (nRows < size()) { - offsets_.setSize(nRows); - m_.setSize(offsets_[nRows - 1]); + size_ = nRows; + offsets_.setSize(nRows+1); + m_.setSize(offsets_[nRows]); } - else if (nRows > offsets_.size()) + else if (nRows > size()) { - FatalErrorIn("CompactListList<T>::setSize(const label nRows)") - << "Cannot be used to extend the list from " << offsets_.size() + FatalErrorIn + ( + "CompactListList<T, Container>::setSize(const label nRows)" + ) << "Cannot be used to extend the list from " << offsets_.size() << " to " << nRows << nl << " Please use one of the other setSize member functions" << abort(FatalError); @@ -141,73 +151,83 @@ void Foam::CompactListList<T>::setSize(const label nRows) } -template<class T> -void Foam::CompactListList<T>::setSize +template<class T, class Container> +void Foam::CompactListList<T, Container>::setSize ( const label nRows, const label nData ) { - offsets_.setSize(nRows); + size_ = nRows; + offsets_.setSize(nRows+1); m_.setSize(nData); } -template<class T> -void Foam::CompactListList<T>::setSize +template<class T, class Container> +void Foam::CompactListList<T, Container>::setSize ( const label nRows, const label nData, const T& t ) { - offsets_.setSize(nRows); + size_ = nRows; + offsets_.setSize(nRows+1); m_.setSize(nData, t); } -template<class T> -void Foam::CompactListList<T>::setSize(const UList<label>& rowSizes) +template<class T, class Container> +void Foam::CompactListList<T, Container>::setSize(const UList<label>& rowSizes) { - offsets_.setSize(rowSizes.size()); + size_ = rowSizes.size(); + offsets_.setSize(rowSizes.size()+1); label sumSize = 0; + offsets_[0] = 0; forAll(rowSizes, i) { sumSize += rowSizes[i]; - offsets_[i] = sumSize; + offsets_[i+1] = sumSize; } m_.setSize(sumSize); } -template<class T> -Foam::labelList Foam::CompactListList<T>::sizes() const +template<class T, class Container> +Foam::labelList Foam::CompactListList<T, Container>::sizes() const { - labelList rowSizes(offsets_.size()); + labelList rowSizes(size()); - label prevOffset = 0; - forAll(offsets_, i) + if (rowSizes.size() > 0) { - rowSizes[i] = offsets_[i]-prevOffset; - prevOffset = offsets_[i]; + forAll(rowSizes, i) + { + rowSizes[i] = offsets_[i+1] - offsets_[i]; + } } return rowSizes; } -template<class T> -void Foam::CompactListList<T>::clear() +template<class T, class Container> +void Foam::CompactListList<T, Container>::clear() { + size_ = 0; offsets_.clear(); m_.clear(); } -template<class T> -void Foam::CompactListList<T>::transfer(CompactListList<T>& a) +template<class T, class Container> +void Foam::CompactListList<T, Container>::transfer +( + CompactListList<T, Container>& a +) { + size_ = a.size_; offsets_.transfer(a.offsets_); m_.transfer(a.m_); } @@ -215,24 +235,15 @@ void Foam::CompactListList<T>::transfer(CompactListList<T>& a) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template<class T> -Foam::List<Foam::List<T> > Foam::CompactListList<T>::operator()() const +template<class T, class Container> +Foam::List<Container> Foam::CompactListList<T, Container>::operator()() +const { - List<List<T> > ll(offsets_.size()); + List<Container> ll(size()); - label offsetPrev = 0; - forAll(offsets_, i) + forAll(ll, i) { - List<T>& lst = ll[i]; - - lst.setSize(offsets_[i] - offsetPrev); - - forAll(lst, j) - { - lst[j] = m_[offsetPrev + j]; - } - - offsetPrev = offsets_[i]; + ll[i] = Container(operator[](i)); } return ll; diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H index f0a80cc1bd8eacd86f6f65b87f07ed9002ce4335..f1875dde70da930c069503e1d9a2e1b1e7ebf956 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H @@ -29,15 +29,17 @@ Description A packed storage unstructured matrix of objects of type \<T\> using an offset table for access. - The offset table is the size of the number of rows whose elements are the + The offset table is the size of the number of rows+1 + whose elements are the accumulated sizes of the rows, i.e. - - offset[i] gives the index of first element of row i + 1 - - offset[i] - offset[i-1] is the number of elements in row i - - and for i = 0, offset[i-1] = 0. + - offset[i] gives the index of first element of row i + - offset[i+1] - offset[i] is the number of elements in row i Storage is allocated on free-store during construction. + As a special case a null-contructed CompactListList has an empty + offsets_ (instead of size 1). + SourceFiles CompactListList.C CompactListListI.H @@ -57,21 +59,23 @@ namespace Foam // Forward declaration of friend functions and operators -template<class T> class CompactListList; +template<class T, class Container> class CompactListList; -template<class T> Istream& operator>>(Istream&, CompactListList<T>&); -template<class T> Ostream& operator<<(Ostream&, const CompactListList<T>&); +template<class T, class Container> Istream& operator>>(Istream&, CompactListList<T, Container>&); +template<class T, class Container> Ostream& operator<<(Ostream&, const CompactListList<T, Container>&); /*---------------------------------------------------------------------------*\ Class CompactListList Declaration \*---------------------------------------------------------------------------*/ -template<class T> +template<class T, class Container = List<T> > class CompactListList { // Private data + label size_; + //- Offset table List<label> offsets_; @@ -84,7 +88,7 @@ public: // Static Member Functions //- Return a null CompactListList - inline static const CompactListList<T>& null(); + inline static const CompactListList<T, Container>& null(); // Constructors @@ -92,7 +96,7 @@ public: inline CompactListList(); //- Construct by converting given List<List<T> > - CompactListList(const List<List<T> >&); + explicit CompactListList(const List<Container>&); //- Construct given size of offset table (number of rows) // and number of data. @@ -103,22 +107,22 @@ public: inline CompactListList(const label nRows, const label nData, const T&); //- Construct given list of row-sizes. - CompactListList(const UList<label>& rowSizes); + explicit CompactListList(const UList<label>& rowSizes); //- Construct given list of row-sizes CompactListList(const UList<label>& rowSizes, const T&); //- Construct by transferring the parameter contents - CompactListList(const Xfer<CompactListList<T> >&); + explicit CompactListList(const Xfer<CompactListList<T, Container> >&); //- Construct as copy or re-use as specified. - CompactListList(CompactListList<T>&, bool reUse); + CompactListList(CompactListList<T, Container>&, bool reUse); //- Construct from Istream. CompactListList(Istream&); //- Clone - inline autoPtr<CompactListList<T> > clone() const; + inline autoPtr<CompactListList<T, Container> > clone() const; // Member Functions @@ -131,7 +135,7 @@ public: //- Return true if the number of rows is zero inline bool empty() const; - //- Return the offset table + //- Return the offset table (= size()+1) inline const List<label>& offsets() const; //- Return non-const access to the offset table @@ -180,10 +184,10 @@ public: //- Transfer the contents of the argument CompactListList // into this CompactListList and annull the argument list. - void transfer(CompactListList<T>&); + void transfer(CompactListList<T, Container>&); //- Transfer the contents to the Xfer container - inline Xfer<CompactListList<T> > xfer(); + inline Xfer<CompactListList<T, Container> > xfer(); // Other @@ -211,8 +215,8 @@ public: //- Return const subscript-checked element. inline const T& operator()(const label i, const label j) const; - //- Return as List<List<T> > - List<List<T> > operator()() const; + //- Return as List<Container> + List<Container> operator()() const; //- Assignment of all entries to the given value inline void operator=(const T&); @@ -222,10 +226,18 @@ public: //- Read CompactListList from Istream, discarding contents // of existing CompactListList. - friend Istream& operator>> <T>(Istream&, CompactListList<T>&); + friend Istream& operator>> <T, Container> + ( + Istream&, + CompactListList<T, Container>& + ); // Write CompactListList to Ostream. - friend Ostream& operator<< <T>(Ostream&, const CompactListList<T>&); + friend Ostream& operator<< <T, Container> + ( + Ostream&, + const CompactListList<T, Container>& + ); }; diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H index dc57627911d5c63e8175b059731bf6d1ded3f27e..59a2ba8ddd75fad08ef0ccedf66c0a25a0970169 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H @@ -24,142 +24,140 @@ License \*---------------------------------------------------------------------------*/ +#include "ListOps.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class T> -inline Foam::CompactListList<T>::CompactListList() +template<class T, class Container> +inline Foam::CompactListList<T, Container>::CompactListList() +: + size_(0) {} -template<class T> -inline Foam::CompactListList<T>::CompactListList +template<class T, class Container> +inline Foam::CompactListList<T, Container>::CompactListList ( const label nRows, const label nData ) : - offsets_(nRows, 0), + size_(nRows), + offsets_(nRows+1, 0), m_(nData) {} -template<class T> -inline Foam::CompactListList<T>::CompactListList +template<class T, class Container> +inline Foam::CompactListList<T, Container>::CompactListList ( const label nRows, const label nData, const T& t ) : - offsets_(nRows, 0), + size_(nRows), + offsets_(nRows+1, 0), m_(nData, t) {} -template<class T> -inline Foam::autoPtr<Foam::CompactListList<T> > -Foam::CompactListList<T>::clone() const +template<class T, class Container> +inline Foam::autoPtr<Foam::CompactListList<T, Container> > +Foam::CompactListList<T, Container>::clone() const { - return autoPtr<CompactListList<T> >(new CompactListList<T>(*this)); + return autoPtr<CompactListList<T, Container> > + ( + new CompactListList<T, Container>(*this) + ); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class T> -inline const Foam::CompactListList<T>& Foam::CompactListList<T>::null() +template<class T, class Container> +inline const Foam::CompactListList<T, Container>& +Foam::CompactListList<T, Container>::null() { - return *reinterpret_cast< CompactListList<T>* >(0); + return *reinterpret_cast< CompactListList<T, Container>* >(0); } -template<class T> -inline Foam::label Foam::CompactListList<T>::size() const +template<class T, class Container> +inline Foam::label Foam::CompactListList<T, Container>::size() const { - return offsets_.size(); + return size_; } -template<class T> -inline bool Foam::CompactListList<T>::empty() const +template<class T, class Container> +inline bool Foam::CompactListList<T, Container>::empty() const { - return offsets_.empty(); + return !size_; } -template<class T> -inline const Foam::List<Foam::label>& Foam::CompactListList<T>::offsets() const +template<class T, class Container> +inline const Foam::List<Foam::label>& +Foam::CompactListList<T, Container>::offsets() const { return offsets_; } -template<class T> -inline Foam::List<Foam::label>& Foam::CompactListList<T>::offsets() +template<class T, class Container> +inline Foam::List<Foam::label>& Foam::CompactListList<T, Container>::offsets() { return offsets_; } -template<class T> -inline const Foam::List<T>& Foam::CompactListList<T>::m() const +template<class T, class Container> +inline const Foam::List<T>& Foam::CompactListList<T, Container>::m() +const { return m_; } -template<class T> -inline Foam::List<T>& Foam::CompactListList<T>::m() +template<class T, class Container> +inline Foam::List<T>& Foam::CompactListList<T, Container>::m() { return m_; } -template<class T> -inline Foam::label Foam::CompactListList<T>::index +template<class T, class Container> +inline Foam::label Foam::CompactListList<T, Container>::index ( const label i, const label j ) const { - if (i == 0) - { - return j; - } - else - { - return offsets_[i-1] + j; - } + return offsets_[i] + j; } -template<class T> -inline Foam::label Foam::CompactListList<T>::whichRow(const label i) const +template<class T, class Container> +inline Foam::label Foam::CompactListList<T, Container>::whichRow(const label i) +const { if (i < 0 || i >= m_.size()) { FatalErrorIn ( - "CompactListList<T>::whichRow(const label) const" + "CompactListList<T, Container>::whichRow(const label) const" ) << "Index " << i << " outside 0.." << m_.size() << abort(FatalError); } - forAll(offsets_, rowI) - { - if (i < offsets_[rowI]) - { - return rowI; - } - } - - return -1; + return findLower(offsets_, i+1); } -template<class T> -inline Foam::label Foam::CompactListList<T>::whichColumn +template<class T, class Container> +inline Foam::label Foam::CompactListList<T, Container>::whichColumn ( const label row, const label i @@ -169,22 +167,23 @@ inline Foam::label Foam::CompactListList<T>::whichColumn } -template<class T> -inline Foam::Xfer<Foam::CompactListList<T> > Foam::CompactListList<T>::xfer() +template<class T, class Container> +inline Foam::Xfer<Foam::CompactListList<T, Container> > +Foam::CompactListList<T, Container>::xfer() { return xferMove(*this); } -template<class T> -inline void Foam::CompactListList<T>::resize(const label nRows) +template<class T, class Container> +inline void Foam::CompactListList<T, Container>::resize(const label nRows) { this->setSize(nRows); } -template<class T> -inline void Foam::CompactListList<T>::resize +template<class T, class Container> +inline void Foam::CompactListList<T, Container>::resize ( const label nRows, const label nData @@ -194,8 +193,8 @@ inline void Foam::CompactListList<T>::resize } -template<class T> -inline void Foam::CompactListList<T>::resize +template<class T, class Container> +inline void Foam::CompactListList<T, Container>::resize ( const label nRows, const label nData, @@ -206,8 +205,11 @@ inline void Foam::CompactListList<T>::resize } -template<class T> -inline void Foam::CompactListList<T>::resize(const UList<label>& rowSizes) +template<class T, class Container> +inline void Foam::CompactListList<T, Container>::resize +( + const UList<label>& rowSizes +) { this->setSize(rowSizes); } @@ -215,42 +217,35 @@ inline void Foam::CompactListList<T>::resize(const UList<label>& rowSizes) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template<class T> -inline Foam::UList<T> Foam::CompactListList<T>::operator[] +template<class T, class Container> +inline Foam::UList<T> Foam::CompactListList<T, Container>::operator[] ( const label i ) { - if (i == 0) - { - return UList<T>(m_.begin(), offsets_[i]); - } - else - { - return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]); - } + label start = offsets_[i]; + return UList<T>(&m_[start], offsets_[i+1] - start); } -template<class T> -inline const Foam::UList<T> Foam::CompactListList<T>::operator[] +template<class T, class Container> +inline const Foam::UList<T> +Foam::CompactListList<T, Container>::operator[] ( const label i ) const { - if (i == 0) - { - return UList<T>(m_.begin(), offsets_[i]); - } - else - { - return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]); - } + label start = offsets_[i]; + return UList<T> + ( + const_cast<T*>(&m_[start]), + offsets_[i+1] - start + ); } -template<class T> -inline T& Foam::CompactListList<T>::operator() +template<class T, class Container> +inline T& Foam::CompactListList<T, Container>::operator() ( const label i, const label j @@ -260,8 +255,8 @@ inline T& Foam::CompactListList<T>::operator() } -template<class T> -inline const T& Foam::CompactListList<T>::operator() +template<class T, class Container> +inline const T& Foam::CompactListList<T, Container>::operator() ( const label i, const label j @@ -271,8 +266,8 @@ inline const T& Foam::CompactListList<T>::operator() } -template<class T> -inline void Foam::CompactListList<T>::operator=(const T& t) +template<class T, class Container> +inline void Foam::CompactListList<T, Container>::operator=(const T& t) { m_ = t; } diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListIO.C b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListIO.C index 0360e60ee6b9ef55dc2ec1f4cd0aa73defd4500b..54fe3e3c70b7f3be69c18b863f0386873b7eae17 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListIO.C +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListIO.C @@ -29,8 +29,8 @@ License // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // -template<class T> -Foam::CompactListList<T>::CompactListList(Istream& is) +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList(Istream& is) { operator>>(is, *this); } @@ -38,16 +38,25 @@ Foam::CompactListList<T>::CompactListList(Istream& is) // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // -template<class T> -Foam::Istream& Foam::operator>>(Istream& is, CompactListList<T>& lst) +template<class T, class Container> +Foam::Istream& Foam::operator>>(Istream& is, CompactListList<T, Container>& lst) { is >> lst.offsets_ >> lst.m_; + // Note: empty list gets output as two empty lists + if (lst.offsets_.size() == 0) + { + lst.size_ = 0; + } + else + { + lst.size_ = lst.offsets_.size()-1; + } return is; } -template<class T> -Foam::Ostream& Foam::operator<<(Ostream& os, const CompactListList<T>& lst) +template<class T, class Container> +Foam::Ostream& Foam::operator<<(Ostream& os, const CompactListList<T, Container>& lst) { os << lst.offsets_ << lst.m_; return os; diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index 76f9527701d4eec378553f1f4767572be282055a..0e59184f668d5efa825f609be1875b73e4763df3 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -109,17 +109,17 @@ public: //- Null constructor. inline FixedList(); - //- Construct from components - inline FixedList(const T v[Size]); + //- Construct from C-array. + explicit inline FixedList(const T v[Size]); //- Construct from value - inline FixedList(const T&); + explicit inline FixedList(const T&); //- Construct from UList. - inline FixedList(const UList<T>&); + explicit inline FixedList(const UList<T>&); //- Construct from SLList. - inline FixedList(const SLList<T>&); + explicit inline FixedList(const SLList<T>&); //- Copy constructor. inline FixedList(const FixedList<T, Size>&); diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index b89f6c95a9f15c2bfe07eddfb3aa537a30c1d9b1..7e623f6560f8008fdedbaa0d132651d8c0c2d0f4 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -123,22 +123,22 @@ public: //- Construct as copy of FixedList<T, Size> template<unsigned Size> - List(const FixedList<T, Size>&); + explicit List(const FixedList<T, Size>&); //- Construct as copy of PtrList<T> - List(const PtrList<T>&); + explicit List(const PtrList<T>&); //- Construct as copy of SLList<T> - List(const SLList<T>&); + explicit List(const SLList<T>&); //- Construct as copy of IndirectList<T> - List(const IndirectList<T>&); + explicit List(const IndirectList<T>&); //- Construct as copy of UIndirectList<T> - List(const UIndirectList<T>&); + explicit List(const UIndirectList<T>&); //- Construct as copy of BiIndirectList<T> - List(const BiIndirectList<T>&); + explicit List(const BiIndirectList<T>&); //- Construct from Istream. List(Istream&); diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index 1e6070e8368ad3a93d765fa112f0febe4ecb9452..82ac19fc0e532305100010cb82cb3fab17bc3899 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -162,7 +162,7 @@ public: inline PackedList(); //- Construct with given size, initializes list to 0. - inline PackedList(const label size); + explicit inline PackedList(const label size); //- Construct with given size and value for all elements. PackedList(const label size, const unsigned val); @@ -174,7 +174,7 @@ public: inline PackedList(const Xfer< PackedList<nBits> >&); //- Construct from a list of labels - PackedList(const UList<label>&); + explicit PackedList(const UList<label>&); //- Clone inline autoPtr< PackedList<nBits> > clone() const; diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H index b5167e5ef8977f02334642c9d31f32ed91ac16e3..3f3e6d8fe6c284e32d1683ca6ab0010854c73b40 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H @@ -136,7 +136,7 @@ public: PtrList(PtrList<T>&, bool reUse); //- Construct as copy of SLPtrList<T> - PtrList(const SLPtrList<T>&); + explicit PtrList(const SLPtrList<T>&); //- Construct from Istream using given Istream constructor class template<class INew> diff --git a/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C b/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C index cc7cf978bdf96420904f44e75e17306524e65e4e..625ac53bd9ab892f1e359167e66b973df91ef5bb 100644 --- a/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C +++ b/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C @@ -22,8 +22,6 @@ 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 "tetCell.H" @@ -44,7 +42,7 @@ Foam::cellShape Foam::tetCell::tetCellShape() const const cellModel& tet = *tetModelPtr_; - return cellShape(tet, *this); + return cellShape(tet, labelList(*this)); } diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C index 54cfc5eea56f674da929a8790888e003a5ba0fde..37481760bab41b344c285bd1a7237f3bbcfcbca3 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C @@ -30,7 +30,7 @@ License Foam::globalIndex::globalIndex(const label localSize) : - offsets_(Pstream::nProcs()) + offsets_(Pstream::nProcs()+1) { labelList localSizes(Pstream::nProcs()); localSizes[Pstream::myProcNo()] = localSize; @@ -38,7 +38,8 @@ Foam::globalIndex::globalIndex(const label localSize) Pstream::scatterList(localSizes); // just to balance out comms label offset = 0; - forAll(offsets_, procI) + offsets_[0] = 0; + for (label procI = 0; procI < Pstream::nProcs(); procI++) { label oldOffset = offset; offset += localSizes[procI]; @@ -51,7 +52,7 @@ Foam::globalIndex::globalIndex(const label localSize) << "). Please recompile with larger datatype for label." << exit(FatalError); } - offsets_[procI] = offset; + offsets_[procI+1] = offset; } } diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H index e394f679d042dd0c425f6fa7a869ebafeb5f2a4a..4bf4f4a4ba8de1257351e1408af35400c74eb585 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H @@ -64,7 +64,7 @@ class globalIndex { // Private data - //- Start off procI+1. (so like CompactListList) + //- Start of procI. Size is nProcs()+1. (so like CompactListList) labelList offsets_; @@ -81,10 +81,6 @@ public: // Member Functions - ////- Start of procI+1 data - //inline const labelList& offsets() const; - - // Queries relating to my processor //- my local size diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H index d7c44107c665e29d0fd38900b2767e116b5e1b57..f00fbbeb81f00568b529dff285082ef7bbd1d28a 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H @@ -28,26 +28,15 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//inline const Foam::labelList& Foam::globalIndex::offsets() const -//{ -// return offsets_; -//} - - inline Foam::label Foam::globalIndex::offset(const label procI) const { - return (procI == 0 ? 0 : offsets_[procI-1]); + return offsets_[procI]; } inline Foam::label Foam::globalIndex::localSize(const label procI) const { - return - ( - procI == 0 - ? offsets_[procI] - : offsets_[procI] - offsets_[procI-1] - ); + return offsets_[procI+1] - offsets_[procI]; } @@ -59,7 +48,7 @@ inline Foam::label Foam::globalIndex::localSize() const inline Foam::label Foam::globalIndex::size() const { - return offsets_[Pstream::nProcs()-1]; + return offsets_[Pstream::nProcs()]; } @@ -69,7 +58,7 @@ inline Foam::label Foam::globalIndex::toGlobal const label i ) const { - return(procI == 0 ? i : i + offsets_[procI-1]); + return i + offsets_[procI]; } @@ -82,9 +71,7 @@ inline Foam::label Foam::globalIndex::toGlobal(const label i) const //- Is on local processor inline bool Foam::globalIndex::isLocal(const label procI, const label i) const { - return - (i < offsets_[procI]) - && (i >= (procI == 0 ? 0 : offsets_[procI-1])); + return i >= offsets_[procI] && i < offsets_[procI+1]; } @@ -97,9 +84,9 @@ inline bool Foam::globalIndex::isLocal(const label i) const inline Foam::label Foam::globalIndex::toLocal(const label procI, const label i) const { - label localI = (procI == 0 ? i : i - offsets_[procI-1]); + label localI = i - offsets_[procI]; - if (localI < 0 || i >= offsets_[procI]) + if (localI < 0 || i >= offsets_[procI+1]) { FatalErrorIn("globalIndex::toLocal(const label, const label)") << "Global " << i << " does not belong on processor " @@ -118,9 +105,7 @@ inline Foam::label Foam::globalIndex::toLocal(const label i) const inline Foam::label Foam::globalIndex::whichProcID(const label i) const { - label index = findLower(offsets_, i+1); - - if (index == Pstream::nProcs()-1) + if (i < 0 || i >= offsets_[Pstream::nProcs()]) { FatalErrorIn("globalIndex::whichProcID(const label)") << "Global " << i << " does not belong on any processor." @@ -128,7 +113,7 @@ inline Foam::label Foam::globalIndex::whichProcID(const label i) const << abort(FatalError); } - return index+1; + return findLower(offsets_, i+1); } diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index 01b30ea60ac06a1b31f0e90087c2f405d24e5850..47620111b8244b2b105dba09ec725442935fc2ce 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -124,7 +124,7 @@ Foam::List<Foam::labelPair> Foam::mapDistribute::schedule ); // Processors involved in my schedule - return UIndirectList<labelPair>(allComms, mySchedule); + return List<labelPair>(UIndirectList<labelPair>(allComms, mySchedule)); //if (debug) diff --git a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C index 2be5111187b68a3fb0c978808db3733e2bb6144b..bfa9b2ca0c1df82ad0ec9a854c5293bc365e34ab 100644 --- a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C +++ b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C @@ -1761,10 +1761,13 @@ void Foam::faceCoupleInfo::subDivisionMatch writeOBJ ( "errorEdges.obj", - UIndirectList<edge> + edgeList ( - cutFaces().edges(), - cutFaces().pointEdges()[cutPointI] + UIndirectList<edge> + ( + cutFaces().edges(), + cutFaces().pointEdges()[cutPointI] + ) ), cutFaces().localPoints(), false diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C index a2b5b08108cedd6969095e1ac4e11f2431c02bd0..41ba56aedba532d58a11226e2a264598cf558e1a 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C @@ -110,7 +110,7 @@ Foam::labelListList Foam::addPatchCellLayer::calcGlobalEdgeFaces ); // Extract pp part - return UIndirectList<labelList>(globalEdgeFaces, meshEdges); + return labelListList(UIndirectList<labelList>(globalEdgeFaces, meshEdges)); } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 6b1874dc4b846850035734e4a009c5f0b421eb9b..fc405b2d0e2b3e56523aa642ed5eba03f15127e0 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -39,6 +39,7 @@ License #include "objectMap.H" #include "processorPolyPatch.H" #include "fvMesh.H" +#include "CompactListList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -488,9 +489,6 @@ void Foam::polyTopoChange::makeCellCells // Neighbours per cell labelList nNbrs(cellMap_.size(), 0); - // Overall number of cellCells - label nCellCells = 0; - // 1. Count neighbours (through internal faces) per cell for (label faceI = 0; faceI < nActiveFaces; faceI++) @@ -499,22 +497,12 @@ void Foam::polyTopoChange::makeCellCells { nNbrs[faceOwner_[faceI]]++; nNbrs[faceNeighbour_[faceI]]++; - nCellCells += 2; } } - cellCells.setSize(cellMap_.size(), nCellCells); - - // 2. Calculate offsets - - labelList& offsets = cellCells.offsets(); + // 2. Construct csr + cellCells.setSize(nNbrs); - label sumSize = 0; - forAll(nNbrs, cellI) - { - sumSize += nNbrs[cellI]; - offsets[cellI] = sumSize; - } // 3. Fill faces per cell @@ -543,8 +531,6 @@ Foam::label Foam::polyTopoChange::getCellOrder labelList& oldToNew ) const { - const labelList& offsets = cellCellAddressing.offsets(); - labelList newOrder(cellCellAddressing.size()); // Fifo buffer for string of cells @@ -560,7 +546,7 @@ Foam::label Foam::polyTopoChange::getCellOrder forAll (visited, cellI) { // find the first non-removed cell that has not been visited yet - if (!cellRemoved(cellI) && visited.get(cellI) == 0) + if (!cellRemoved(cellI) && visited[cellI] == 0) { // use this cell as a start nextCell.append(cellI); @@ -574,23 +560,22 @@ Foam::label Foam::polyTopoChange::getCellOrder { label currentCell = nextCell.removeHead(); - if (visited.get(currentCell) == 0) + if (visited[currentCell] == 0) { - visited.set(currentCell, 1); + visited[currentCell] = 1; // add into cellOrder newOrder[cellInOrder] = currentCell; cellInOrder++; // find if the neighbours have been visited - label i0 = (currentCell == 0 ? 0 : offsets[currentCell-1]); - label i1 = offsets[currentCell]; + const UList<label> cCells = cellCellAddressing[currentCell]; - for (label i = i0; i < i1; i++) + forAll(cCells, i) { - label nbr = cellCellAddressing.m()[i]; + label nbr = cCells[i]; - if (!cellRemoved(nbr) && visited.get(nbr) == 0) + if (!cellRemoved(nbr) && visited[nbr] == 0) { // not visited, add to the list nextCell.append(nbr); diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H index e7a0ba8fb380fd8a258cebf98baa1400440f134e..398ced6b0de6d1ae6df02030fc0d0050b647619a 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H @@ -64,18 +64,12 @@ SourceFiles #ifndef polyTopoChange_H #define polyTopoChange_H -#include "autoPtr.H" #include "DynamicList.H" #include "labelList.H" -#include "IOobject.H" -#include "typeInfo.H" #include "pointField.H" -#include "PtrList.H" -#include "cellList.H" #include "Map.H" #include "HashSet.H" #include "mapPolyMesh.H" -#include "CompactListList.H" #include "PackedBoolList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -95,6 +89,8 @@ class polyPatch; class dictionary; class topoAction; class objectMap; +class IOobject; +template<class T, class Container> class CompactListList; /*---------------------------------------------------------------------------*\ Class polyTopoChange Declaration @@ -273,11 +269,15 @@ class polyTopoChange void makeCellCells ( const label nActiveFaces, - CompactListList<label>& cellCells + CompactListList<label, labelList>& cellCells ) const; //- Cell ordering (bandCompression). Returns number of remaining cells. - label getCellOrder(const CompactListList<label>&, labelList&) const; + label getCellOrder + ( + const CompactListList<label, labelList>&, + labelList& + ) const; //- Do upper-triangular ordering and patch ordering. void getFaceOrder diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeI.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeI.H index e2ea3c2869ed221a50c265a1b6a59238879e6af9..118733ce4228dc75f303fff6066af0119965951d 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeI.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeI.H @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ +#include "face.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/mesh/blockMesh/blockMesh/blockMeshTopology.C b/src/mesh/blockMesh/blockMesh/blockMeshTopology.C index 97ad739d60af056510d09f83571f95a673cdd2f0..533054e3c2c9d021b339fc396a78233086641a02 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshTopology.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshTopology.C @@ -313,14 +313,10 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict) Info<< "Creating topology mesh" << endl; } - PtrList<cellShape> tmpBlockShapes(blocks.size()); + cellShapeList tmpBlockShapes(blocks.size()); forAll(blocks, blockI) { - tmpBlockShapes.set - ( - blockI, - new cellShape(blocks[blockI].blockShape()) - ); + tmpBlockShapes[blockI] = cellShape(blocks[blockI].blockShape()); if (tmpBlockShapes[blockI].mag(blockPointField_) < 0.0) { diff --git a/src/meshTools/octree/treeBoundBox.C b/src/meshTools/octree/treeBoundBox.C index 6133bc3106f9c3e8e07edd53b0d3e7a639211bda..e93e7b9f65e4a144e2fbee74bfc80dad8e0263bd 100644 --- a/src/meshTools/octree/treeBoundBox.C +++ b/src/meshTools/octree/treeBoundBox.C @@ -85,7 +85,8 @@ const Foam::label edgesArray[12][2] = const Foam::edgeList Foam::treeBoundBox::edges ( - initListList<edge, label, 12, 2>(edgesArray) + //initListList<edge, label, 12, 2>(edgesArray) + calcEdges(edgesArray) ); @@ -97,6 +98,18 @@ const Foam::FixedList<Foam::vector, 6> Foam::treeBoundBox::faceNormals // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +Foam::edgeList Foam::treeBoundBox::calcEdges(const label edgesArray[12][2]) +{ + edgeList edges(12); + forAll(edges, edgeI) + { + edges[edgeI][0] = edgesArray[edgeI][0]; + edges[edgeI][1] = edgesArray[edgeI][1]; + } + return edges; +} + + Foam::FixedList<Foam::vector, 6> Foam::treeBoundBox::calcFaceNormals() { FixedList<vector, 6> normals; diff --git a/src/meshTools/octree/treeBoundBox.H b/src/meshTools/octree/treeBoundBox.H index 04b420a531517bd461c0359b27b4576521dea0a9..01660d618d33e5eb05d6e9a101519dc51d6f4858 100644 --- a/src/meshTools/octree/treeBoundBox.H +++ b/src/meshTools/octree/treeBoundBox.H @@ -80,6 +80,9 @@ class treeBoundBox private: + //- To initialise edges. + static edgeList calcEdges(const label[12][2]); + //- To initialise faceNormals. static FixedList<vector, 6> calcFaceNormals(); diff --git a/src/meshTools/searchableSurface/searchableSurfaceCollection.C b/src/meshTools/searchableSurface/searchableSurfaceCollection.C index 306e78df25fd8242892b219ae4a9e63daf633be0..ba1dd32988e47a2aa53eb001e1014ad1686f83d2 100644 --- a/src/meshTools/searchableSurface/searchableSurfaceCollection.C +++ b/src/meshTools/searchableSurface/searchableSurfaceCollection.C @@ -464,7 +464,10 @@ void Foam::searchableSurfaceCollection::getRegion labelList surfRegion; subGeom_[surfI].getRegion ( - UIndirectList<pointIndexHit>(info, indices), + List<pointIndexHit> + ( + UIndirectList<pointIndexHit>(info, indices) + ), surfRegion ); forAll(indices, i) @@ -528,7 +531,10 @@ void Foam::searchableSurfaceCollection::getNormal vectorField surfNormal; subGeom_[surfI].getNormal ( - UIndirectList<pointIndexHit>(info, indices), + List<pointIndexHit> + ( + UIndirectList<pointIndexHit>(info, indices) + ), surfNormal ); forAll(indices, i) diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index 4d71403277a790c84179c0f5612cbff226f6754e..a964cab15293f9e5ccbf107391496604eccee903 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -212,7 +212,7 @@ void Foam::sampledSets::combineSampledSets ( samplePts.name(), samplePts.axis(), - UIndirectList<point>(allPts, indexSets[seti]), + List<point>(UIndirectList<point>(allPts, indexSets[seti])), refPt ) ); diff --git a/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C index 0247c643dfa4cbf72007e90d98979d969ca9f44a..ea80e5645d6231e06ebb59c409c7316ba02bb658 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C @@ -49,7 +49,10 @@ Foam::reactingMixture<ThermoType>::reactingMixture ), PtrList<Reaction<ThermoType> > ( - autoPtr<chemistryReader<ThermoType> >::operator()().reactions(), + PtrList<Reaction<ThermoType> > + ( + autoPtr<chemistryReader<ThermoType> >::operator()().reactions() + ), this->species_ ) {