1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "CompactListList_dev.H"
28 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
30 template<class T, class Container>
31 Foam::CompactListList_dev<T, Container>::CompactListList_dev(const List<Container>& ll)
40 sumSize += ll[i].size();
41 offsets_[i+1] = sumSize;
49 const Container& lli = ll[i];
59 template<class T, class Container>
60 Foam::CompactListList_dev<T, Container>::CompactListList_dev
62 const UList<label>& rowSizes
65 size_(rowSizes.size()),
66 offsets_(rowSizes.size()+1)
72 sumSize += rowSizes[i];
73 offsets_[i+1] = sumSize;
80 template<class T, class Container>
81 Foam::CompactListList_dev<T, Container>::CompactListList_dev
83 const UList<label>& rowSizes,
87 size_(rowSizes.size()),
88 offsets_(rowSizes.size()+1)
94 sumSize += rowSizes[i];
95 offsets_[i+1] = sumSize;
98 m_.setSize(sumSize, t);
102 template<class T, class Container>
103 Foam::CompactListList_dev<T, Container>::CompactListList_dev
105 const Xfer<CompactListList_dev<T, Container> >& lst
112 template<class T, class Container>
113 Foam::CompactListList_dev<T, Container>::CompactListList_dev
115 CompactListList_dev<T, Container>& lst,
120 offsets_(lst.offsets_, reUse),
125 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
127 template<class T, class Container>
128 void Foam::CompactListList_dev<T, Container>::setSize(const label nRows)
137 offsets_.setSize(nRows+1);
138 m_.setSize(offsets_[nRows]);
140 else if (nRows > size())
144 "CompactListList_dev<T, Container>::setSize(const label nRows)"
145 ) << "Cannot be used to extend the list from " << offsets_.size()
146 << " to " << nRows << nl
147 << " Please use one of the other setSize member functions"
148 << abort(FatalError);
153 template<class T, class Container>
154 void Foam::CompactListList_dev<T, Container>::setSize
161 offsets_.setSize(nRows+1);
166 template<class T, class Container>
167 void Foam::CompactListList_dev<T, Container>::setSize
175 offsets_.setSize(nRows+1);
176 m_.setSize(nData, t);
180 template<class T, class Container>
181 void Foam::CompactListList_dev<T, Container>::setSize(const UList<label>& rowSizes)
183 size_ = rowSizes.size();
184 offsets_.setSize(rowSizes.size()+1);
190 sumSize += rowSizes[i];
191 offsets_[i+1] = sumSize;
198 template<class T, class Container>
199 Foam::labelList Foam::CompactListList_dev<T, Container>::sizes() const
201 labelList rowSizes(size());
203 if (rowSizes.size() > 0)
207 rowSizes[i] = offsets_[i+1] - offsets_[i];
214 template<class T, class Container>
215 void Foam::CompactListList_dev<T, Container>::clear()
223 template<class T, class Container>
224 void Foam::CompactListList_dev<T, Container>::transfer
226 CompactListList_dev<T, Container>& a
230 offsets_.transfer(a.offsets_);
235 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
237 template<class T, class Container>
238 Foam::List<Container> Foam::CompactListList_dev<T, Container>::operator()()
241 List<Container> ll(size());
245 ll[i] = Container(operator[](i));
252 // * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
254 #include "CompactListList_devIO.C"
256 // ************************ vim: set sw=4 sts=4 et: ************************ //