Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
04c8cdf7
Commit
04c8cdf7
authored
Nov 18, 2008
by
Mark Olesen
Browse files
ListOps with (const UList<label>&) instead of (const labelList&)
PackedList with (const UList<label>&) instead of (const labelList&)
parent
bbb989f8
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/containers/Lists/ListOps/ListOps.C
View file @
04c8cdf7
...
...
@@ -28,7 +28,7 @@ License
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
Foam
::
labelList
Foam
::
invert
(
const
label
len
,
const
label
List
&
map
)
Foam
::
labelList
Foam
::
invert
(
const
label
len
,
const
UList
<
label
>
&
map
)
{
labelList
inverse
(
len
,
-
1
);
...
...
@@ -40,8 +40,8 @@ Foam::labelList Foam::invert(const label len, const labelList& map)
{
if
(
inverse
[
newPos
]
>=
0
)
{
FatalErrorIn
(
"invert(const label, const label
List
&)"
)
<<
"Map is not one
to
one. At index "
<<
i
FatalErrorIn
(
"invert(const label, const
UList<
label
>
&)"
)
<<
"Map is not one
-
to
-
one. At index "
<<
i
<<
" element "
<<
newPos
<<
" has already occurred before"
<<
nl
<<
"Please use invertOneToMany instead"
<<
abort
(
FatalError
);
...
...
@@ -54,7 +54,11 @@ Foam::labelList Foam::invert(const label len, const labelList& map)
}
Foam
::
labelListList
Foam
::
invertOneToMany
(
const
label
len
,
const
labelList
&
map
)
Foam
::
labelListList
Foam
::
invertOneToMany
(
const
label
len
,
const
UList
<
label
>&
map
)
{
labelList
nElems
(
len
,
0
);
...
...
src/OpenFOAM/containers/Lists/ListOps/ListOps.H
View file @
04c8cdf7
...
...
@@ -44,42 +44,42 @@ SourceFiles
namespace
Foam
{
//- Renumber the values (not the indices) of a list.
List elements <= 0 are
// left as is.
//- Renumber the values (not the indices) of a list.
//
List elements < 0 are
left as is.
template
<
class
List
>
List
renumber
(
const
label
List
&
oldToNew
,
const
List
&
);
List
renumber
(
const
UList
<
label
>
&
oldToNew
,
const
List
&
);
//- Inplace renumber the values of a list.
List elements <= 0 are
// left as is.
//- Inplace renumber the values of a list.
//
List elements < 0 are
left as is.
template
<
class
List
>
void
inplaceRenumber
(
const
label
List
&
oldToNew
,
List
&
);
void
inplaceRenumber
(
const
UList
<
label
>
&
oldToNew
,
List
&
);
//- Reorder the elements (indices, not values) of a list.
// List elements <
=
0 are left as is.
// List elements < 0 are left as is.
template
<
class
List
>
List
reorder
(
const
label
List
&
oldToNew
,
const
List
&
);
List
reorder
(
const
UList
<
label
>
&
oldToNew
,
const
List
&
);
//- Inplace reorder the elements of a list.
// List elements <
=
0 are left as is.
// List elements < 0 are left as is.
template
<
class
List
>
void
inplaceReorder
(
const
label
List
&
oldToNew
,
List
&
);
void
inplaceReorder
(
const
UList
<
label
>
&
oldToNew
,
List
&
);
// Variants to work with iterators and sparse tables.
Need to have iterators
// and insert()
// Variants to work with iterators and sparse tables.
//
Need to have iterators
and insert()
//- Map values. Do not map negative values.
template
<
class
Container
>
void
inplaceMapValue
(
const
label
List
&
oldToNew
,
Container
&
);
void
inplaceMapValue
(
const
UList
<
label
>
&
oldToNew
,
Container
&
);
//- Recreate with mapped keys. Remove elements with negative key.
template
<
class
Container
>
void
inplaceMapKey
(
const
label
List
&
oldToNew
,
Container
&
);
void
inplaceMapKey
(
const
UList
<
label
>
&
oldToNew
,
Container
&
);
//- Extract elements of List whose region is certain value.
Use e.g.
// to extract all selected elements:
// subset<boolList, labelList>(selectedElems, true, lst);
//- Extract elements of List whose region is certain value.
//
Use e.g.
to extract all selected elements:
//
subset<boolList, labelList>(selectedElems, true, lst);
template
<
class
T
,
class
List
>
List
subset
(
const
UList
<
T
>&
regions
,
const
T
&
region
,
const
List
&
);
...
...
@@ -90,10 +90,10 @@ template<class T, class List>
void
inplaceSubset
(
const
UList
<
T
>&
regions
,
const
T
&
region
,
List
&
);
//- Invert one-to-one map. Unmapped elements will be -1.
labelList
invert
(
const
label
len
,
const
labelList
&
oldToNew
);
labelList
invert
(
const
label
len
,
const
UList
<
label
>&
);
//- Invert one-to-many map. Unmapped elements will be size 0.
labelListList
invertOneToMany
(
const
label
len
,
const
label
List
&
);
labelListList
invertOneToMany
(
const
label
len
,
const
UList
<
label
>
&
);
//- Invert many-to-many. Input and output types need to be inherited
// from List. E.g. faces to pointFaces.
...
...
@@ -135,7 +135,7 @@ template<class List>
void
setValues
(
List
&
,
const
label
List
&
indices
,
const
UList
<
label
>
&
indices
,
typename
List
::
const_reference
);
...
...
@@ -145,7 +145,7 @@ List createWithValues
(
const
label
sz
,
const
typename
List
::
const_reference
initValue
,
const
label
List
&
indices
,
const
UList
<
label
>
&
indices
,
typename
List
::
const_reference
setValue
);
...
...
src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C
View file @
04c8cdf7
...
...
@@ -31,7 +31,7 @@ License
template
<
class
List
>
List
Foam
::
renumber
(
const
label
List
&
oldToNew
,
const
UList
<
label
>
&
oldToNew
,
const
List
&
lst
)
{
...
...
@@ -53,7 +53,7 @@ List Foam::renumber
template
<
class
List
>
void
Foam
::
inplaceRenumber
(
const
label
List
&
oldToNew
,
const
UList
<
label
>
&
oldToNew
,
List
&
lst
)
{
...
...
@@ -70,7 +70,7 @@ void Foam::inplaceRenumber
template
<
class
List
>
List
Foam
::
reorder
(
const
label
List
&
oldToNew
,
const
UList
<
label
>
&
oldToNew
,
const
List
&
lst
)
{
...
...
@@ -95,7 +95,7 @@ List Foam::reorder
template
<
class
List
>
void
Foam
::
inplaceReorder
(
const
label
List
&
oldToNew
,
const
UList
<
label
>
&
oldToNew
,
List
&
lst
)
{
...
...
@@ -121,7 +121,7 @@ void Foam::inplaceReorder
template
<
class
Container
>
void
Foam
::
inplaceMapValue
(
const
label
List
&
oldToNew
,
const
UList
<
label
>
&
oldToNew
,
Container
&
lst
)
{
...
...
@@ -143,7 +143,7 @@ void Foam::inplaceMapValue
template
<
class
Container
>
void
Foam
::
inplaceMapKey
(
const
label
List
&
oldToNew
,
const
UList
<
label
>
&
oldToNew
,
Container
&
lst
)
{
...
...
@@ -161,7 +161,7 @@ void Foam::inplaceMapKey
newLst
.
insert
(
oldToNew
[
iter
.
key
()],
iter
());
}
}
lst
.
transfer
(
newLst
);
}
...
...
@@ -330,7 +330,7 @@ template<class List>
void
Foam
::
setValues
(
List
&
l
,
const
label
List
&
indices
,
const
UList
<
label
>
&
indices
,
typename
List
::
const_reference
t
)
{
...
...
@@ -346,7 +346,7 @@ List Foam::createWithValues
(
const
label
sz
,
const
typename
List
::
const_reference
initValue
,
const
label
List
&
indices
,
const
UList
<
label
>
&
indices
,
typename
List
::
const_reference
setValue
)
{
...
...
@@ -489,31 +489,31 @@ Foam::label Foam::findLower
template
<
class
Container
,
class
T
,
int
nRows
>
Foam
::
List
<
Container
>
Foam
::
initList
(
const
T
elems
[
nRows
])
{
List
<
Container
>
faces
(
nRows
);
List
<
Container
>
lst
(
nRows
);
forAll
(
faces
,
face
I
)
forAll
(
lst
,
row
I
)
{
faces
[
face
I
]
=
Container
(
elems
[
face
I
]);
lst
[
row
I
]
=
Container
(
elems
[
row
I
]);
}
return
faces
;
return
lst
;
}
template
<
class
Container
,
class
T
,
int
nRows
,
int
nColumns
>
Foam
::
List
<
Container
>
Foam
::
initListList
(
const
T
elems
[
nRows
][
nColumns
])
{
List
<
Container
>
faces
(
nRows
);
List
<
Container
>
lst
(
nRows
);
Container
f
(
nColumns
);
forAll
(
faces
,
face
I
)
Container
cols
(
nColumns
);
forAll
(
lst
,
row
I
)
{
forAll
(
f
,
i
)
forAll
(
cols
,
colI
)
{
f
[
i
]
=
elems
[
faceI
][
i
];
cols
[
colI
]
=
elems
[
rowI
][
colI
];
}
faces
[
face
I
]
=
f
;
lst
[
row
I
]
=
cols
;
}
return
faces
;
return
lst
;
}
...
...
src/OpenFOAM/containers/Lists/PackedList/PackedList.C
View file @
04c8cdf7
...
...
@@ -26,16 +26,10 @@ License
#include
"PackedList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct with given size and value for all elements.
template
<
int
nBits
>
PackedList
<
nBits
>::
PackedList
(
const
label
size
,
const
unsigned
int
val
)
Foam
::
PackedList
<
nBits
>::
PackedList
(
const
label
size
,
const
unsigned
int
val
)
:
List
<
unsigned
int
>
(
intSize
(
size
)),
size_
(
size
)
...
...
@@ -44,26 +38,23 @@ PackedList<nBits>::PackedList(const label size, const unsigned int val)
}
//- Copy constructor.
template
<
int
nBits
>
PackedList
<
nBits
>::
PackedList
(
const
PackedList
<
nBits
>&
PLi
st
)
Foam
::
PackedList
<
nBits
>::
PackedList
(
const
PackedList
<
nBits
>&
l
st
)
:
List
<
unsigned
int
>
(
PLi
st
),
size_
(
PLi
st
.
size
())
List
<
unsigned
int
>
(
l
st
),
size_
(
l
st
.
size
())
{}
template
<
int
nBits
>
PackedList
<
nBits
>::
PackedList
(
const
xfer
<
PackedList
<
nBits
>
>&
lst
)
Foam
::
PackedList
<
nBits
>::
PackedList
(
const
xfer
<
PackedList
<
nBits
>
>&
lst
)
{
transfer
(
lst
());
}
//- Construct from labelList
template
<
int
nBits
>
PackedList
<
nBits
>::
PackedList
(
const
label
List
&
lst
)
Foam
::
PackedList
<
nBits
>::
PackedList
(
const
UList
<
label
>
&
lst
)
:
List
<
unsigned
int
>
(
intSize
(
lst
.
size
()),
0
),
size_
(
lst
.
size
())
...
...
@@ -76,7 +67,7 @@ PackedList<nBits>::PackedList(const labelList& lst)
template
<
int
nBits
>
autoPtr
<
PackedList
<
nBits
>
>
PackedList
<
nBits
>::
clone
()
const
Foam
::
autoPtr
<
Foam
::
PackedList
<
nBits
>
>
Foam
::
PackedList
<
nBits
>::
clone
()
const
{
return
autoPtr
<
PackedList
<
nBits
>
>
(
new
PackedList
<
nBits
>
(
*
this
));
}
...
...
@@ -84,24 +75,24 @@ autoPtr<PackedList<nBits> > PackedList<nBits>::clone() const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
int
nBits
>
void
PackedList
<
nBits
>::
setSize
(
const
label
size
)
template
<
int
nBits
>
void
Foam
::
PackedList
<
nBits
>::
setSize
(
const
label
size
)
{
List
<
unsigned
int
>::
setSize
(
intSize
(
size
));
size_
=
size
;
}
template
<
int
nBits
>
void
PackedList
<
nBits
>::
clear
()
template
<
int
nBits
>
void
Foam
::
PackedList
<
nBits
>::
clear
()
{
List
<
unsigned
int
>::
clear
();
size_
=
0
;
}
template
<
int
nBits
>
void
PackedList
<
nBits
>::
transfer
(
PackedList
<
nBits
>&
lst
)
template
<
int
nBits
>
void
Foam
::
PackedList
<
nBits
>::
transfer
(
PackedList
<
nBits
>&
lst
)
{
size_
=
lst
.
size
();
List
<
unsigned
int
>::
transfer
(
lst
);
...
...
@@ -111,16 +102,16 @@ void PackedList<nBits>::transfer(PackedList<nBits>& lst)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// Assignment.
template
<
int
nBits
>
void
PackedList
<
nBits
>::
operator
=
(
const
PackedList
<
nBits
>&
p
l
)
template
<
int
nBits
>
void
Foam
::
PackedList
<
nBits
>::
operator
=
(
const
PackedList
<
nBits
>&
l
st
)
{
setSize
(
p
l
.
size
());
List
<
unsigned
int
>::
operator
=
(
p
l
);
setSize
(
l
st
.
size
());
List
<
unsigned
int
>::
operator
=
(
l
st
);
}
template
<
int
nBits
>
labelList
PackedList
<
nBits
>::
operator
()()
const
template
<
int
nBits
>
Foam
::
labelList
Foam
::
PackedList
<
nBits
>::
operator
()()
const
{
labelList
elems
(
size
());
...
...
@@ -134,17 +125,14 @@ labelList PackedList<nBits>::operator()() const
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
//template
<int nBits>
//Ostream& ::Foam::operator<<(Ostream& os, const PackedList<nBits>&
PL
)
//template<int nBits>
//
Foam::
Ostream& ::Foam::operator<<(Ostream& os, const PackedList<nBits>&
lst
)
//{
// os <<
PL
();
// os <<
lst
();
// return os;
//}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// ************************************************************************* //
src/OpenFOAM/containers/Lists/PackedList/PackedList.H
View file @
04c8cdf7
...
...
@@ -26,7 +26,8 @@ Class
Foam::PackedList
Description
List of packed unsigned ints. Gets given the number of bits per item.
List of packed unsigned ints.
Gets given the number of bits per item.
SourceFiles
PackedListI.H
...
...
@@ -47,14 +48,14 @@ namespace Foam
/*---------------------------------------------------------------------------*\
Class PackedListName Declaration
Class PackedListName Declaration
\*---------------------------------------------------------------------------*/
TemplateName
(
PackedList
);
/*---------------------------------------------------------------------------*\
Class PackedList Declaration
Class PackedList Declaration
\*---------------------------------------------------------------------------*/
//- For PackedList
...
...
@@ -137,8 +138,8 @@ public:
//- Construct by transferring the parameter contents
PackedList
(
const
xfer
<
PackedList
<
nBits
>
>&
);
//- Construct from
labelList.
PackedList
(
const
label
List
&
);
//- Construct from
a list of labels
PackedList
(
const
UList
<
label
>
&
);
//- Clone
inline
autoPtr
<
PackedList
<
nBits
>
>
clone
()
const
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment