Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
dynamicMesh
fvMeshDistribute
CompactListList_devI.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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
\*---------------------------------------------------------------------------*/
25
26
#include <
OpenFOAM/ListOps.H
>
27
#include <
OpenFOAM/SubList.H
>
28
29
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30
31
template
<
class
T,
class
Container>
32
inline
Foam::CompactListList_dev<T, Container>::CompactListList_dev
()
33
:
34
size_(0)
35
{}
36
37
38
template
<
class
T,
class
Container>
39
inline
Foam::CompactListList_dev<T, Container>::CompactListList_dev
40
(
41
const
label nRows,
42
const
label nData
43
)
44
:
45
size_(nRows),
46
offsets_(nRows+1, 0),
47
m_(nData)
48
{}
49
50
51
template
<
class
T,
class
Container>
52
inline
Foam::CompactListList_dev<T, Container>::CompactListList_dev
53
(
54
const
label nRows,
55
const
label nData,
56
const
T
& t
57
)
58
:
59
size_(nRows),
60
offsets_(nRows+1, 0),
61
m_(nData, t)
62
{}
63
64
65
template
<
class
T,
class
Container>
66
inline
Foam::autoPtr<Foam::CompactListList_dev<T, Container>
>
67
Foam::CompactListList_dev<T, Container>::clone
()
const
68
{
69
return
autoPtr<CompactListList_dev<T, Container>
>
70
(
71
new
CompactListList_dev<T, Container>
(*this)
72
);
73
}
74
75
76
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
77
78
template
<
class
T,
class
Container>
79
inline
const
Foam::CompactListList_dev<T, Container>
&
80
Foam::CompactListList_dev<T, Container>::null
()
81
{
82
return
*
reinterpret_cast<
CompactListList_dev<T, Container>
*
>
(0);
83
}
84
85
86
template
<
class
T,
class
Container>
87
inline
Foam::label
Foam::CompactListList_dev<T, Container>::size
()
const
88
{
89
return
size_;
90
}
91
92
93
template
<
class
T,
class
Container>
94
inline
bool
Foam::CompactListList_dev<T, Container>::empty
()
const
95
{
96
return
!size_;
97
}
98
99
100
template
<
class
T,
class
Container>
101
inline
const
Foam::List<Foam::label>
&
102
Foam::CompactListList_dev<T, Container>::offsets
()
const
103
{
104
return
offsets_;
105
}
106
107
108
template
<
class
T,
class
Container>
109
inline
Foam::List<Foam::label>
&
Foam::CompactListList_dev<T, Container>::offsets
()
110
{
111
return
offsets_;
112
}
113
114
115
template
<
class
T,
class
Container>
116
inline
const
Foam::List<T>
&
Foam::CompactListList_dev<T, Container>::m
()
117
const
118
{
119
return
m_;
120
}
121
122
123
template
<
class
T,
class
Container>
124
inline
Foam::List<T>
&
Foam::CompactListList_dev<T, Container>::m
()
125
{
126
return
m_;
127
}
128
129
130
template
<
class
T,
class
Container>
131
inline
Foam::label
Foam::CompactListList_dev<T, Container>::index
132
(
133
const
label i,
134
const
label j
135
)
const
136
{
137
return
offsets_[i] + j;
138
}
139
140
141
template
<
class
T,
class
Container>
142
inline
Foam::label
Foam::CompactListList_dev<T, Container>::whichRow
(
const
label i)
143
const
144
{
145
if
(i < 0 || i >= m_.size())
146
{
147
FatalErrorIn
148
(
149
"CompactListList_dev<T, Container>::whichRow(const label) const"
150
) <<
"Index "
<< i <<
" outside 0.."
<< m_.size()
151
<<
abort
(
FatalError
);
152
}
153
154
return
findLower
(offsets_, i+1);
155
}
156
157
158
template
<
class
T,
class
Container>
159
inline
Foam::label
Foam::CompactListList_dev<T, Container>::whichColumn
160
(
161
const
label row,
162
const
label i
163
)
const
164
{
165
return
i - index(row, 0);
166
}
167
168
169
template
<
class
T,
class
Container>
170
inline
Foam::Xfer<Foam::CompactListList_dev<T, Container>
>
171
Foam::CompactListList_dev<T, Container>::xfer
()
172
{
173
return
xferMove
(*
this
);
174
}
175
176
177
template
<
class
T,
class
Container>
178
inline
void
Foam::CompactListList_dev<T, Container>::resize
(
const
label nRows)
179
{
180
this->
setSize
(nRows);
181
}
182
183
184
template
<
class
T,
class
Container>
185
inline
void
Foam::CompactListList_dev<T, Container>::resize
186
(
187
const
label nRows,
188
const
label nData
189
)
190
{
191
this->
setSize
(nRows, nData);
192
}
193
194
195
template
<
class
T,
class
Container>
196
inline
void
Foam::CompactListList_dev<T, Container>::resize
197
(
198
const
label nRows,
199
const
label nData,
200
const
T
& t
201
)
202
{
203
this->
setSize
(nRows, nData, t);
204
}
205
206
207
template
<
class
T,
class
Container>
208
inline
void
Foam::CompactListList_dev<T, Container>::resize
209
(
210
const
UList<label>
& rowSizes
211
)
212
{
213
this->
setSize
(rowSizes);
214
}
215
216
217
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
218
219
template
<
class
T,
class
Container>
220
inline
Foam::UList<T>
Foam::CompactListList_dev<T, Container>::operator
[]
221
(
222
const
label i
223
)
224
{
225
label start = offsets_[i];
226
return
UList<T>
((m_.size() ? &m_[start] : NULL), offsets_[i+1] - start);
227
}
228
229
230
template
<
class
T,
class
Container>
231
inline
const
Foam::UList<T>
232
Foam::CompactListList_dev<T, Container>::operator
[]
233
(
234
const
label i
235
)
const
236
{
237
label start = offsets_[i];
238
return
UList<T>
239
(
240
(m_.size() ?
const_cast<
T
*
>
(&m_[start]) : NULL),
241
offsets_[i+1] - start
242
);
243
}
244
245
246
template
<
class
T,
class
Container>
247
inline
T
&
Foam::CompactListList_dev<T, Container>::operator
()
248
(
249
const
label i,
250
const
label j
251
)
252
{
253
return
m_[index(i, j)];
254
}
255
256
257
template
<
class
T,
class
Container>
258
inline
const
T
&
Foam::CompactListList_dev<T, Container>::operator
()
259
(
260
const
label i,
261
const
label j
262
)
const
263
{
264
return
m_[index(i, j)];
265
}
266
267
268
template
<
class
T,
class
Container>
269
inline
void
Foam::CompactListList_dev<T, Container>::operator=
(
const
T
& t)
270
{
271
m_ = t;
272
}
273
274
275
// ************************ vim: set sw=4 sts=4 et: ************************ //