CompactListList.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Class
25  Foam::CompactListList
26 
27 Description
28  A packed storage unstructured matrix of objects of type <T>
29  using an offset table for access.
30 
31  The offset table is the size of the number of rows+1
32  whose elements are the
33  accumulated sizes of the rows, i.e.
34  - offset[i] gives the index of first element of row i
35  - offset[i+1] - offset[i] is the number of elements in row i
36 
37  Storage is allocated on free-store during construction.
38 
39 SourceFiles
40  CompactListList.C
41  CompactListListI.H
42  CompactListListIO.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef CompactListList_H
47 #define CompactListList_H
48 
49 #include "UCompactListList.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // Forward declaration of friend functions and operators
57 
58 template<class T> class CompactListList;
59 
60 template<class T> Istream& operator>>(Istream&, CompactListList<T>&);
61 
62 
63 /*---------------------------------------------------------------------------*\
64  Class CompactListList Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 template<class T>
68 class CompactListList
69 :
70  public UCompactListList<T>
71 {
72  // Private Data
73 
74  //- Offset table
75  List<label> offsets_;
76 
77  //- Packed matrix of data
78  List<T> m_;
79 
80 
81 public:
82 
83  // Static Member Functions
84 
85  //- Return a null CompactListList
86  inline static const CompactListList<T>& null();
87 
88 
89  // Constructors
90 
91  //- Null constructor.
92  inline CompactListList();
93 
94  //- Construct from components
95  inline CompactListList(const UList<label>& offsets, const UList<T>& m);
96 
97  //- Construct as copy or re-use as specified.
98  inline CompactListList(CompactListList<T>&, bool reuse);
99 
100  //- Move constructor
101  inline CompactListList(CompactListList<T>&&);
102 
103  //- Construct given size of offset table (number of rows),
104  // the number of data and a value for all elements.
105  inline CompactListList(const label mRows, const label nData, const T&);
106 
107  //- Construct by converting given List<Container>
108  template<class Container>
109  CompactListList(const List<Container>&);
110 
111  //- Construct given list of row-sizes and a value for all elements
112  CompactListList(const labelUList& rowSizes, const T&);
113 
114  //- Construct from Istream.
115  CompactListList(Istream&);
116 
117  //- Clone
118  inline autoPtr<CompactListList<T>> clone() const;
119 
120 
121  // Member Functions
122 
123  // Edit
124 
125  //- Reset size of CompactListList.
126  // This form only allows contraction of the CompactListList.
127  void setSize(const label mRows);
128 
129  //- Reset size of CompactListList.
130  void setSize(const label mRows, const label nData);
131 
132  //- Reset sizes of CompactListList and value for new elements.
133  void setSize(const label mRows, const label nData, const T&);
134 
135  //- Reset size of CompactListList.
136  void setSize(const labelUList& rowSizes);
137 
138  //- Reset size of CompactListList.
139  // This form only allows contraction of the CompactListList.
140  inline void resize(const label mRows);
141 
142  //- Reset size of CompactListList.
143  inline void resize(const label mRows, const label nData);
144 
145  //- Reset sizes of CompactListList and value for new elements.
146  inline void resize(const label mRows, const label nData, const T&);
147 
148  //- Reset size of CompactListList.
149  inline void resize(const labelUList& rowSizes);
150 
151  //- Clear the CompactListList, i.e. set sizes to zero.
152  void clear();
153 
154  //- Transfer the contents of the argument CompactListList
155  // into this CompactListList and annul the argument list.
156  void transfer(CompactListList<T>&);
157 
158 
159  //- Disallow shallowCopy
160  void shallowCopy(const UCompactListList<T>&) = delete;
161 
162 
163  // Istream operator
164 
165  //- Read CompactListList from Istream, discarding contents
166  // of existing CompactListList.
167  friend Istream& operator>> <T>
168  (
169  Istream&,
170  CompactListList<T>&
171  );
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace Foam
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #include "CompactListListI.H"
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #ifdef NoRepository
186  #include "CompactListList.C"
187 #endif
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
const UList< T > & m() const
Return the packed matrix of data.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void shallowCopy(const UCompactListList< T > &)=delete
Disallow shallowCopy.
void clear()
Clear the CompactListList, i.e. set sizes to zero.
void transfer(CompactListList< T > &)
Transfer the contents of the argument CompactListList.
UList< label > labelUList
Definition: UList.H:65
static const CompactListList< T > & null()
Return a null CompactListList.
autoPtr< CompactListList< T > > clone() const
Clone.
Istream & operator>>(Istream &, directionInfo &)
CompactListList()
Null constructor.
void resize(const label mRows)
Reset size of CompactListList.
void setSize(const label mRows)
Reset size of CompactListList.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const UList< label > & offsets() const
Return the offset table (= size()+1)
Namespace for OpenFOAM.