All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2024 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 reuse as specified.
98  inline CompactListList(CompactListList<T>&, bool reuse);
99 
100  //- Move constructor
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 from UList<T2>
108  template<class T2>
109  CompactListList(const UList<T2>&);
110 
111  //- Construct from UIndirectList<T2>
112  template<class T2>
114 
115  //- Construct given list of row-sizes and a value for all elements
116  CompactListList(const labelUList& rowSizes, const T&);
117 
118  //- Construct from Istream.
120 
121  //- Clone
122  inline autoPtr<CompactListList<T>> clone() const;
123 
124 
125  // Member Functions
126 
127  // Edit
128 
129  //- Reset size of CompactListList.
130  // This form only allows contraction of the CompactListList.
131  void setSize(const label mRows);
132 
133  //- Reset size of CompactListList.
134  void setSize(const label mRows, const label nData);
135 
136  //- Reset sizes of CompactListList and value for new elements.
137  void setSize(const label mRows, const label nData, const T&);
138 
139  //- Reset size of CompactListList.
140  void setSize(const labelUList& rowSizes);
141 
142  //- Reset size of CompactListList to match the given UList<T2>
143  template<class T2>
144  void setSize(const UList<T2>&);
145 
146  //- Reset size of CompactListList to match the given
147  // UIndirectList<T2>
148  template<class T2>
149  void setSize(const UIndirectList<T2>&);
150 
151  //- Reset size of CompactListList.
152  // This form only allows contraction of the CompactListList.
153  inline void resize(const label mRows);
154 
155  //- Reset size of CompactListList.
156  inline void resize(const label mRows, const label nData);
157 
158  //- Reset sizes of CompactListList and value for new elements.
159  inline void resize(const label mRows, const label nData, const T&);
160 
161  //- Reset size of CompactListList.
162  inline void resize(const labelUList& rowSizes);
163 
164  //- Reset size of CompactListList to match the given
165  // UList<T2>
166  template<class T2>
167  void resize(const UList<T2>&);
168 
169  //- Reset size of CompactListList to match the given
170  // UIndirectList<T2>
171  template<class T2>
172  void resize(const UIndirectList<T2>&);
173 
174  //- Clear the CompactListList, i.e. set sizes to zero.
175  void clear();
176 
177  //- Transfer the contents of the argument CompactListList
178  // into this CompactListList and annul the argument list.
180 
181 
182  //- Disallow shallowCopy
183  void shallowCopy(const UCompactListList<T>&) = delete;
184 
185 
186  // Istream operator
187 
188  //- Read CompactListList from Istream, discarding contents
189  // of existing CompactListList.
190  friend Istream& operator>> <T>
191  (
192  Istream&,
194  );
195 };
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 } // End namespace Foam
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #include "CompactListListI.H"
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #ifdef NoRepository
209  #include "CompactListList.C"
210 #endif
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 #endif
215 
216 // ************************************************************************* //
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
CompactListList()
Null constructor.
void shallowCopy(const UCompactListList< T > &)=delete
Disallow shallowCopy.
void transfer(CompactListList< T > &)
Transfer the contents of the argument CompactListList.
void resize(const label mRows)
Reset size of CompactListList.
void clear()
Clear the CompactListList, i.e. set sizes to zero.
void setSize(const label mRows)
Reset size of CompactListList.
autoPtr< CompactListList< T > > clone() const
Clone.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
Unallocated base class of CompactListList.
const UList< label > & offsets() const
Return the offset table (= size()+1)
const UList< T > & m() const
Return the packed matrix of data.
A List with indirect addressing.
Definition: UIndirectList.H:60
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Istream & operator>>(Istream &, pistonPointEdgeData &)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)