UCompactListList.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::UCompactListList
26 
27 Description
28  Unallocated base class of CompactListList
29 
30 SourceFiles
31  UCompactListList.C
32  UCompactListListI.H
33  UCompactListListIO.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef UCompactListList_H
38 #define UCompactListList_H
39 
40 #include "labelList.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward declaration of friend functions and operators
48 
49 template<class T> class UCompactListList;
50 
51 template<class T> Ostream& operator<<(Ostream&, const UCompactListList<T>&);
52 
53 /*---------------------------------------------------------------------------*\
54  Class UCompactListList Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 template<class T>
58 class UCompactListList
59 {
60  // Private Data
61 
62  //- Offset table
63  UList<label> offsets_;
64 
65  //- Packed matrix of data
66  UList<T> m_;
67 
68 
69 public:
70 
71  // Static Member Functions
72 
73  //- Return a null UCompactListList
74  inline static const UCompactListList<T>& null();
75 
76 
77  // Constructors
78 
79  //- Null constructor.
80  inline UCompactListList();
81 
82  //- Construct from components
83  inline UCompactListList(const UList<label>& offsets, const UList<T>& m);
84 
85 
86  // Member Functions
87 
88  // Access
89 
90  //- Return the primary size, i.e. the number of rows
91  inline label size() const;
92 
93  //- Return true if the number of rows is zero
94  inline bool empty() const;
95 
96  //- Return the offset table (= size()+1)
97  inline const UList<label>& offsets() const;
98 
99  //- Return non-const access to the offset table
100  inline UList<label>& offsets();
101 
102  //- Return the packed matrix of data
103  inline const UList<T>& m() const;
104 
105  //- Return non-const access to the packed matrix of data
106  inline UList<T>& m();
107 
108 
109  //- Copy the ULists, but not the underlying data
110  inline void shallowCopy(const UCompactListList<T>&);
111 
112  //- Copy the underlying data
113  inline void deepCopy(const UCompactListList<T>&);
114 
115  //- Return index into m
116  inline label index(const label row, const label col) const;
117 
118  //- Get row for index into m.
119  inline label whichRow(const label index) const;
120 
121  //- Get column index (j) given above row
122  inline label whichColumn(const label row, const label index) const;
123 
124  //- Return sizes (to be used e.g. for construction)
125  labelList sizes() const;
126 
127  //- Convert to List<Container>
128  template<class Container = List<T>>
129  List<Container> list() const;
130 
131 
132  // Member Operators
133 
134  //- Return subscript-checked row as UList.
135  inline UList<T> operator[](const label i);
136 
137  //- Return const subscript-checked row as UList.
138  inline const UList<T> operator[](const label i) const;
139 
140  //- Return subscript-checked element.
141  inline T& operator()(const label i, const label j);
142 
143  //- Return const subscript-checked element.
144  inline const T& operator()(const label i, const label j) const;
145 
146  //- Assignment of all entries to the given value
147  inline void operator=(const T&);
148 
149 
150  // Istream operator
151 
152  // Write UCompactListList to Ostream.
153  friend Ostream& operator<< <T>
154  (
155  Ostream&,
156  const UCompactListList<T>&
157  );
158 };
159 
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #include "UCompactListListI.H"
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #ifdef NoRepository
172  #include "UCompactListList.C"
173 #endif
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
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.
label size() const
Return the primary size, i.e. the number of rows.
T & operator()(const label i, const label j)
Return subscript-checked element.
void shallowCopy(const UCompactListList< T > &)
Copy the ULists, but not the underlying data.
List< Container > list() const
Convert to List<Container>
labelList sizes() const
Return sizes (to be used e.g. for construction)
List< label > labelList
A List of labels.
Definition: labelList.H:56
UList< T > operator[](const label i)
Return subscript-checked row as UList.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
label index(const label row, const label col) const
Return index into m.
UCompactListList()
Null constructor.
void operator=(const T &)
Assignment of all entries to the given value.
const UList< label > & offsets() const
Return the offset table (= size()+1)
void deepCopy(const UCompactListList< T > &)
Copy the underlying data.
label whichRow(const label index) const
Get row for index into m.
static const UCompactListList< T > & null()
Return a null UCompactListList.
label whichColumn(const label row, const label index) const
Get column index (j) given above row.
Namespace for OpenFOAM.
bool empty() const
Return true if the number of rows is zero.