Skip to content
GitLab
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
638b6b2c
Commit
638b6b2c
authored
Jul 26, 2018
by
Mark OLESEN
Browse files
ENH: add get() dereferencing for PtrList iterators
- gets the pointer within the list.
parent
1abacf0d
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/containers/PtrLists/PtrList/PtrList.C
View file @
638b6b2c
...
...
@@ -68,7 +68,7 @@ Foam::PtrList<T>::PtrList(const SLPtrList<T>& list)
template
<
class
T
>
Foam
::
PtrList
<
T
>::~
PtrList
()
{
(
this
->
ptrs_
).
free
();
(
this
->
ptrs_
).
free
();
// free old pointers
}
...
...
src/OpenFOAM/containers/PtrLists/PtrList/PtrListI.H
View file @
638b6b2c
...
...
@@ -31,7 +31,7 @@ License
template
<
class
T
>
inline
void
Foam
::
PtrList
<
T
>::
free
()
{
(
this
->
ptrs_
).
free
();
(
this
->
ptrs_
).
free
();
// free old pointers
}
...
...
@@ -82,7 +82,7 @@ inline Foam::PtrList<T>::PtrList
template
<
class
T
>
inline
void
Foam
::
PtrList
<
T
>::
clear
()
{
(
this
->
ptrs_
).
free
();
(
this
->
ptrs_
).
free
();
// free old pointers
UPtrList
<
T
>::
clear
();
}
...
...
@@ -160,7 +160,7 @@ inline Foam::autoPtr<T> Foam::PtrList<T>::set(label i, const tmp<T>& tptr)
template
<
class
T
>
inline
void
Foam
::
PtrList
<
T
>::
transfer
(
PtrList
<
T
>&
list
)
{
this
->
free
();
// free old pointers
(
this
->
ptrs_
).
free
();
// free old pointers
UPtrList
<
T
>::
transfer
(
list
);
}
...
...
src/OpenFOAM/containers/PtrLists/UPtrList/UPtrList.H
View file @
638b6b2c
...
...
@@ -32,7 +32,7 @@ Description
Note
The class definition is such that it contains a list of pointers, but
itself does not inherit from a list of pointers since this would
wreak havoc later inheritance resolution.
wreak havoc later
with
inheritance resolution.
See Also
Foam::PtrList
...
...
@@ -226,6 +226,11 @@ public:
//- Construct for a given entry
inline
iterator
(
T
**
ptr
);
// Member functions
//- Return pointer, can be nullptr.
inline
pointer
get
()
const
;
// Member operators
inline
bool
operator
==
(
const
iterator
&
iter
)
const
;
...
...
@@ -280,6 +285,11 @@ public:
//- Copy construct from non-const iterator
inline
const_iterator
(
const
iterator
&
iter
);
// Member functions
//- Return pointer, can be nullptr.
inline
pointer
get
()
const
;
// Member operators
inline
bool
operator
==
(
const
const_iterator
&
iter
)
const
;
...
...
src/OpenFOAM/containers/PtrLists/UPtrList/UPtrListI.H
View file @
638b6b2c
...
...
@@ -237,6 +237,13 @@ inline Foam::UPtrList<T>::iterator::iterator(T** ptr)
{}
template
<
class
T
>
inline
T
*
Foam
::
UPtrList
<
T
>::
iterator
::
get
()
const
{
return
*
ptr_
;
}
template
<
class
T
>
inline
bool
Foam
::
UPtrList
<
T
>::
iterator
::
operator
==
(
const
iterator
&
iter
)
const
{
...
...
@@ -403,6 +410,13 @@ inline Foam::UPtrList<T>::const_iterator::const_iterator(const iterator& iter)
{}
template
<
class
T
>
inline
const
T
*
Foam
::
UPtrList
<
T
>::
const_iterator
::
get
()
const
{
return
*
ptr_
;
}
template
<
class
T
>
inline
bool
Foam
::
UPtrList
<
T
>::
const_iterator
::
operator
==
(
...
...
src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C
View file @
638b6b2c
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-201
7
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-201
8
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -366,7 +366,7 @@ Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::findIndices
}
else
{
indices
.
setS
ize
(
this
->
size
());
indices
.
res
ize
(
this
->
size
());
label
count
=
0
;
forAll
(
*
this
,
i
)
{
...
...
@@ -375,7 +375,7 @@ Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::findIndices
indices
[
count
++
]
=
i
;
}
}
indices
.
setS
ize
(
count
);
indices
.
res
ize
(
count
);
}
return
indices
;
...
...
@@ -487,11 +487,12 @@ Foam::bitSet Foam::ZoneMesh<ZoneType, MeshType>::findMatching
bitSet
bitset
;
const
labelList
indices
=
this
->
findIndices
(
key
);
forAll
(
indices
,
i
)
for
(
const
label
zonei
:
indices
)
{
bitset
.
set
(
static_cast
<
const
labelList
&>
(
this
->
operator
[](
indices
[
i
]
))
static_cast
<
const
labelList
&>
(
this
->
operator
[](
zonei
))
);
}
...
...
@@ -499,6 +500,50 @@ Foam::bitSet Foam::ZoneMesh<ZoneType, MeshType>::findMatching
}
template
<
class
ZoneType
,
class
MeshType
>
const
ZoneType
*
Foam
::
ZoneMesh
<
ZoneType
,
MeshType
>::
zonePtr
(
const
word
&
zoneName
)
const
{
const
PtrList
<
ZoneType
>&
zones
=
*
this
;
for
(
auto
iter
=
zones
.
begin
();
iter
!=
zones
.
end
();
++
iter
)
{
const
ZoneType
*
ptr
=
iter
.
get
();
if
(
ptr
&&
zoneName
==
ptr
->
name
())
{
return
ptr
;
}
}
return
nullptr
;
}
template
<
class
ZoneType
,
class
MeshType
>
ZoneType
*
Foam
::
ZoneMesh
<
ZoneType
,
MeshType
>::
zonePtr
(
const
word
&
zoneName
)
{
PtrList
<
ZoneType
>&
zones
=
*
this
;
for
(
auto
iter
=
zones
.
begin
();
iter
!=
zones
.
end
();
++
iter
)
{
ZoneType
*
ptr
=
iter
.
get
();
if
(
ptr
&&
zoneName
==
ptr
->
name
())
{
return
ptr
;
}
}
return
nullptr
;
}
template
<
class
ZoneType
,
class
MeshType
>
void
Foam
::
ZoneMesh
<
ZoneType
,
MeshType
>::
clearAddressing
()
{
...
...
src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H
View file @
638b6b2c
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-201
7
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-201
8
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -49,13 +49,14 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Forward declaration
of friend functions and operator
s
// Forward declarations
template
<
class
ZoneType
,
class
MeshType
>
class
ZoneMesh
;
template
<
class
ZoneType
,
class
MeshType
>
Ostream
&
operator
<<
(
Ostream
&
os
,
const
ZoneMesh
<
ZoneType
,
MeshType
>&
zones
);
/*---------------------------------------------------------------------------*\
Class ZoneMesh Declaration
\*---------------------------------------------------------------------------*/
...
...
@@ -186,6 +187,14 @@ public:
//- Mark items (cells, faces, points) that match the zone specification
bitSet
findMatching
(
const
keyType
&
key
)
const
;
//- Lookup zone by name and return const pointer, nullptr on error.
const
ZoneType
*
zonePtr
(
const
word
&
zoneName
)
const
;
//- Lookup zone by name and return pointer, nullptr on error.
ZoneType
*
zonePtr
(
const
word
&
zoneName
);
//- Clear addressing
void
clearAddressing
();
...
...
@@ -205,6 +214,7 @@ public:
//- writeData member function required by regIOobject
bool
writeData
(
Ostream
&
os
)
const
;
// Member Operators
//- Return const and non-const reference to zone by index.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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