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
0128b2be
Commit
0128b2be
authored
Mar 12, 2009
by
mattijs
Browse files
UIndirectList
parent
6c387489
Changes
49
Hide whitespace changes
Inline
Side-by-side
applications/test/UIndirectListTest/Make/files
0 → 100644
View file @
0128b2be
UIndirectListTest.C
EXE = $(FOAM_USER_APPBIN)/UIndirectListTest
applications/test/UIndirectListTest/Make/options
0 → 100644
View file @
0128b2be
applications/test/IndirectList
/
IndirectList
I.H
→
applications/test/
U
IndirectList
Test/U
IndirectList
Test.C
View file @
0128b2be
...
...
@@ -26,51 +26,68 @@ Description
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
#include
"UIndirectList.H"
#include
"IOstreams.H"
//- Construct given size
template
<
class
T
>
inline
Foam
::
IndirectList
<
T
>::
IndirectList
(
const
Foam
::
UList
<
T
>&
completeList
,
const
Foam
::
List
<
label
>&
addresses
)
:
completeList_
(
completeList
),
addresses_
(
addresses
)
{}
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class
T
>
inline
Foam
::
label
Foam
::
IndirectList
<
T
>::
size
()
const
int
main
(
int
argc
,
char
*
argv
[])
{
return
addresses_
.
size
();
}
List
<
double
>
completeList
(
10
);
forAll
(
completeList
,
i
)
{
completeList
[
i
]
=
0
.
1
*
i
;
}
template
<
class
T
>
inline
const
Foam
::
UList
<
T
>&
Foam
::
IndirectList
<
T
>::
completeList
()
const
{
return
completeList_
;
}
List
<
label
>
addresses
(
5
);
addresses
[
0
]
=
1
;
addresses
[
1
]
=
0
;
addresses
[
2
]
=
7
;
addresses
[
3
]
=
8
;
addresses
[
4
]
=
5
;
UIndirectList
<
double
>
idl
(
completeList
,
addresses
);
template
<
class
T
>
inline
const
Foam
::
List
<
Foam
::
label
>&
Foam
::
IndirectList
<
T
>::
addresses
()
const
{
return
addresses_
;
}
forAll
(
idl
,
i
)
{
Info
<<
idl
[
i
]
<<
token
::
SPACE
;
}
Info
<<
endl
;
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
idl
[
1
]
=
-
666
;
template
<
class
T
>
inline
const
T
&
Foam
::
IndirectList
<
T
>::
operator
[](
const
Foam
::
label
i
)
const
{
return
completeList_
[
addresses_
[
i
]];
Info
<<
"idl[1] changed:"
<<
idl
()
<<
endl
;
idl
=
-
999
;
Info
<<
"idl changed:"
<<
idl
()
<<
endl
;
UIndirectList
<
double
>
idl2
(
idl
);
Info
<<
"idl2:"
<<
idl2
()
<<
endl
;
idl
=
idl2
();
Info
<<
"idl assigned from UList:"
<<
idl
()
<<
endl
;
List
<
double
>
realList
=
UIndirectList
<
double
>
(
completeList
,
addresses
);
Info
<<
"realList:"
<<
realList
<<
endl
;
List
<
double
>
realList2
(
UIndirectList
<
double
>
(
completeList
,
addresses
));
Info
<<
"realList2:"
<<
realList2
<<
endl
;
Info
<<
"
\n
End
\n
"
<<
endl
;
return
0
;
}
...
...
applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C
View file @
0128b2be
...
...
@@ -177,7 +177,7 @@ label mergePatchFaces
List
<
faceList
>
allFaceSetsFaces
(
allFaceSets
.
size
());
forAll
(
allFaceSets
,
setI
)
{
allFaceSetsFaces
[
setI
]
=
IndirectList
<
face
>
allFaceSetsFaces
[
setI
]
=
U
IndirectList
<
face
>
(
mesh
.
faces
(),
allFaceSets
[
setI
]
...
...
applications/utilities/mesh/conversion/polyDualMesh/meshDualiser.C
View file @
0128b2be
...
...
@@ -76,7 +76,7 @@ void Foam::meshDualiser::checkPolyTopoChange(const polyTopoChange& meshMod)
"meshDualiser::checkPolyTopoChange(const polyTopoChange&)"
)
<<
"duplicate verts:"
<<
newToOld
[
newI
]
<<
" coords:"
<<
IndirectList
<
point
>
(
points
,
newToOld
[
newI
])()
<<
U
IndirectList
<
point
>
(
points
,
newToOld
[
newI
])()
<<
abort
(
FatalError
);
}
}
...
...
@@ -226,10 +226,7 @@ Foam::label Foam::meshDualiser::addInternalFace
if
(
debug
)
{
pointField
facePoints
(
IndirectList
<
point
>
(
meshMod
.
points
(),
newFace
)()
);
pointField
facePoints
(
meshMod
.
points
(),
newFace
);
labelList
oldToNew
;
pointField
newPoints
;
...
...
@@ -289,7 +286,7 @@ Foam::label Foam::meshDualiser::addInternalFace
//n /= mag(n);
//Pout<< "Generated internal dualFace:" << dualFaceI
// << " verts:" << newFace
// << " points:" << IndirectList<point>(meshMod.points(), newFace)()
// << " points:" <<
U
IndirectList<point>(meshMod.points(), newFace)()
// << " n:" << n
// << " between dualowner:" << dualCell0
// << " dualneigbour:" << dualCell1
...
...
@@ -316,7 +313,7 @@ Foam::label Foam::meshDualiser::addInternalFace
//n /= mag(n);
//Pout<< "Generated internal dualFace:" << dualFaceI
// << " verts:" << newFace
// << " points:" << IndirectList<point>(meshMod.points(), newFace)()
// << " points:" <<
U
IndirectList<point>(meshMod.points(), newFace)()
// << " n:" << n
// << " between dualowner:" << dualCell1
// << " dualneigbour:" << dualCell0
...
...
@@ -373,7 +370,7 @@ Foam::label Foam::meshDualiser::addBoundaryFace
//n /= mag(n);
//Pout<< "Generated boundary dualFace:" << dualFaceI
// << " verts:" << newFace
// << " points:" << IndirectList<point>(meshMod.points(), newFace)()
// << " points:" <<
U
IndirectList<point>(meshMod.points(), newFace)()
// << " n:" << n
// << " on dualowner:" << dualCellI
// << endl;
...
...
@@ -568,7 +565,7 @@ void Foam::meshDualiser::createFaceFromInternalFace
//Pout<< "createFaceFromInternalFace : At face:" << faceI
// << " verts:" << f
// << " points:" << IndirectList<point>(mesh_.points(), f)()
// << " points:" <<
U
IndirectList<point>(mesh_.points(), f)()
// << " started walking at edge:" << fEdges[fp]
// << " verts:" << mesh_.edges()[fEdges[fp]]
// << endl;
...
...
@@ -617,7 +614,7 @@ void Foam::meshDualiser::createFaceFromInternalFace
{
FatalErrorIn
(
"createFacesFromInternalFace(..)"
)
<<
"face:"
<<
faceI
<<
" verts:"
<<
f
<<
" points:"
<<
IndirectList
<
point
>
(
mesh_
.
points
(),
f
)()
<<
" points:"
<<
U
IndirectList
<
point
>
(
mesh_
.
points
(),
f
)()
<<
" no feature edge between "
<<
f
[
fp
]
<<
" and "
<<
f
[
nextFp
]
<<
" although have different"
<<
" dual cells."
<<
endl
...
...
applications/utilities/mesh/manipulation/setSet/writePointSet.C
View file @
0128b2be
...
...
@@ -70,7 +70,7 @@ void writePointSet
labelList
pointLabels
(
set
.
toc
());
pointField
setPoints
(
IndirectList
<
point
>
(
mesh
.
points
(),
pointLabels
)
())
;
pointField
setPoints
(
mesh
.
points
(),
pointLabels
);
// Write points
...
...
applications/utilities/mesh/manipulation/splitMesh/regionSide.C
View file @
0128b2be
...
...
@@ -22,14 +22,11 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include
"regionSide.H"
#include
"meshTools.H"
#include
"primitiveMesh.H"
#include
"IndirectList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...
...
@@ -113,7 +110,7 @@ Foam::label Foam::regionSide::otherEdge
)
<<
"Cannot find other edge on face "
<<
faceI
<<
" that uses point "
<<
pointI
<<
" but not point "
<<
freePointI
<<
endl
<<
"Edges on face:"
<<
fEdges
<<
" verts:"
<<
IndirectList
<
edge
>
(
mesh
.
edges
(),
fEdges
)()
<<
" verts:"
<<
U
IndirectList
<
edge
>
(
mesh
.
edges
(),
fEdges
)()
<<
" Vertices on face:"
<<
mesh
.
faces
()[
faceI
]
<<
" Vertices on original edge:"
<<
e
<<
abort
(
FatalError
);
...
...
applications/utilities/mesh/manipulation/splitMesh/splitMesh.C
View file @
0128b2be
...
...
@@ -50,15 +50,12 @@ Description
#include
"attachDetach.H"
#include
"attachPolyTopoChanger.H"
#include
"regionSide.H"
#include
"primitiveFacePatch.H"
using
namespace
Foam
;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Calculation engine for set of faces in a mesh
typedef
PrimitivePatch
<
face
,
List
,
const
pointField
&>
facePatch
;
// Find edge between points v0 and v1.
label
findEdge
(
const
primitiveMesh
&
mesh
,
const
label
v0
,
const
label
v1
)
{
...
...
@@ -163,10 +160,16 @@ int main(int argc, char *argv[])
// set of edges on side of this region. Use PrimitivePatch to find these.
//
IndirectList
<
face
>
zoneFaces
(
mesh
.
faces
(),
faces
);
// Addressing on faces only in mesh vertices.
facePatch
fPatch
(
zoneFaces
(),
mesh
.
points
());
primitiveFacePatch
fPatch
(
UIndirectList
<
face
>
(
mesh
.
faces
(),
faces
),
mesh
.
points
()
);
const
labelList
&
meshPoints
=
fPatch
.
meshPoints
();
...
...
applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C
View file @
0128b2be
...
...
@@ -60,7 +60,6 @@ Description
#include
"polyTopoChanger.H"
#include
"mapPolyMesh.H"
#include
"ListOps.H"
#include
"IndirectList.H"
#include
"slidingInterface.H"
#include
"perfectInterface.H"
#include
"IOobjectList.H"
...
...
applications/utilities/postProcessing/dataConversion/foamToVTK/writePointSet.C
View file @
0128b2be
...
...
@@ -22,8 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include
"writePointSet.H"
...
...
@@ -76,7 +74,7 @@ void writePointSet
writeFuns
::
insert
(
IndirectList
<
point
>
(
vMesh
.
mesh
().
points
(),
set
.
toc
())(),
U
IndirectList
<
point
>
(
vMesh
.
mesh
().
points
(),
set
.
toc
())(),
ptField
);
...
...
applications/utilities/surface/surfaceSplitNonManifolds/surfaceSplitNonManifolds.C
View file @
0128b2be
...
...
@@ -306,7 +306,7 @@ label findEdge
FatalErrorIn
(
"findEdge"
)
<<
"Cannot find edge with labels "
<<
v0
<<
' '
<<
v1
<<
" in candidates "
<<
edgeLabels
<<
" with vertices:"
<<
IndirectList
<
edge
>
(
surf
.
edges
(),
edgeLabels
)()
<<
" with vertices:"
<<
U
IndirectList
<
edge
>
(
surf
.
edges
(),
edgeLabels
)()
<<
abort
(
FatalError
);
return
-
1
;
...
...
@@ -346,7 +346,7 @@ label otherEdge
FatalErrorIn
(
"otherEdge"
)
<<
"Cannot find other edge on face "
<<
faceI
<<
" verts:"
<<
surf
.
localPoints
()[
faceI
]
<<
" connected to point "
<<
pointI
<<
" faceEdges:"
<<
IndirectList
<
edge
>
(
surf
.
edges
(),
fEdges
)()
<<
" faceEdges:"
<<
U
IndirectList
<
edge
>
(
surf
.
edges
(),
fEdges
)()
<<
abort
(
FatalError
);
return
-
1
;
...
...
src/OpenFOAM/containers/Lists/List/List.C
View file @
0128b2be
...
...
@@ -31,6 +31,7 @@ License
#include
"PtrList.H"
#include
"SLList.H"
#include
"IndirectList.H"
#include
"UIndirectList.H"
#include
"BiIndirectList.H"
#include
"contiguous.H"
...
...
@@ -321,6 +322,28 @@ Foam::List<T>::List(const IndirectList<T>& lst)
}
// Construct as copy of UIndirectList<T>
template
<
class
T
>
Foam
::
List
<
T
>::
List
(
const
UIndirectList
<
T
>&
lst
)
:
UList
<
T
>
(
NULL
,
lst
.
size
())
{
if
(
this
->
size_
)
{
this
->
v_
=
new
T
[
this
->
size_
];
forAll
(
*
this
,
i
)
{
this
->
operator
[](
i
)
=
lst
[
i
];
}
}
else
{
this
->
v_
=
0
;
}
}
// Construct as copy of BiIndirectList<T>
template
<
class
T
>
Foam
::
List
<
T
>::
List
(
const
BiIndirectList
<
T
>&
lst
)
...
...
@@ -590,6 +613,28 @@ void Foam::List<T>::operator=(const IndirectList<T>& lst)
}
// Assignment operator. Takes linear time.
template
<
class
T
>
void
Foam
::
List
<
T
>::
operator
=
(
const
UIndirectList
<
T
>&
lst
)
{
if
(
lst
.
size
()
!=
this
->
size_
)
{
if
(
this
->
v_
)
delete
[]
this
->
v_
;
this
->
v_
=
0
;
this
->
size_
=
lst
.
size
();
if
(
this
->
size_
)
this
->
v_
=
new
T
[
this
->
size_
];
}
if
(
this
->
size_
)
{
forAll
(
*
this
,
i
)
{
this
->
operator
[](
i
)
=
lst
[
i
];
}
}
}
// Assignment operator. Takes linear time.
template
<
class
T
>
void
Foam
::
List
<
T
>::
operator
=
(
const
BiIndirectList
<
T
>&
lst
)
...
...
src/OpenFOAM/containers/Lists/List/List.H
View file @
0128b2be
...
...
@@ -66,6 +66,7 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
class
DynamicList
;
template
<
class
T
>
class
SortableList
;
template
<
class
T
>
class
IndirectList
;
template
<
class
T
>
class
UIndirectList
;
template
<
class
T
>
class
BiIndirectList
;
typedef
UList
<
label
>
unallocLabelList
;
...
...
@@ -133,6 +134,9 @@ public:
//- Construct as copy of IndirectList<T>
List
(
const
IndirectList
<
T
>&
);
//- Construct as copy of UIndirectList<T>
List
(
const
UIndirectList
<
T
>&
);
//- Construct as copy of BiIndirectList<T>
List
(
const
BiIndirectList
<
T
>&
);
...
...
@@ -210,6 +214,9 @@ public:
//- Assignment from IndirectList operator. Takes linear time.
void
operator
=
(
const
IndirectList
<
T
>&
);
//- Assignment from UIndirectList operator. Takes linear time.
void
operator
=
(
const
UIndirectList
<
T
>&
);
//- Assignment from BiIndirectList operator. Takes linear time.
void
operator
=
(
const
BiIndirectList
<
T
>&
);
...
...
applications/test/
IndirectList/IndirectList.H
→
src/OpenFOAM/containers/Lists/U
IndirectList/
U
IndirectList.H
View file @
0128b2be
...
...
@@ -23,17 +23,19 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::IndirectList
Foam::
U
IndirectList
Description
A List with indirect addressing. Like IndirectList but does not store
addressing.
SourceFiles
IndirectListI.H
U
IndirectListI.H
\*---------------------------------------------------------------------------*/
#ifndef IndirectList_H
#define IndirectList_H
#ifndef
U
IndirectList_H
#define
U
IndirectList_H
#include
"List.H"
...
...
@@ -43,22 +45,16 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class IndirectList Declaration
Class
U
IndirectList Declaration
\*---------------------------------------------------------------------------*/
template
<
class
T
>
class
IndirectList
class
U
IndirectList
{
// Private data
const
UList
<
T
>&
completeList_
;
List
<
label
>
addresses_
;
// Private Member Functions
//- Disallow default bitwise assignment
void
operator
=
(
const
IndirectList
<
T
>&
);
UList
<
T
>&
completeList_
;
const
UList
<
label
>&
addressing_
;
public:
...
...
@@ -66,7 +62,7 @@ public:
// Constructors
//- Construct given the complete list and the addressing array
inline
IndirectList
(
const
UList
<
T
>&
,
const
List
<
label
>&
);
inline
U
IndirectList
(
const
UList
<
T
>&
,
const
U
List
<
label
>&
);
// Member Functions
...
...
@@ -74,14 +70,28 @@ public:
// Access
inline
label
size
()
const
;
inline
bool
empty
()
const
;
inline
const
UList
<
T
>&
completeList
()
const
;
inline
const
List
<
label
>&
address
es
()
const
;
inline
const
List
<
label
>&
address
ing
()
const
;
// Member Operators
//- Return the addressed elements as a List
inline
List
<
T
>
operator
()()
const
;
//- Return non-const access to an element
inline
T
&
operator
[](
const
label
);
//- Return const access to an element
inline
const
T
&
operator
[](
const
label
)
const
;
//- Assignment from UList of addressed elements
inline
void
operator
=
(
const
UList
<
T
>&
);
//- Assignment of all entries to the given value
inline
void
operator
=
(
const
T
&
);
};
...
...
@@ -91,7 +101,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include
"IndirectListI.H"
#include
"
U
IndirectListI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H
0 → 100644
View file @
0128b2be
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
class
T
>
inline
Foam
::
UIndirectList
<
T
>::
UIndirectList
(
const
UList
<
T
>&
completeList
,
const
UList
<
label
>&
addr
)
:
completeList_
(
const_cast
<
UList
<
T
>&>
(
completeList
)),
addressing_
(
addr
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class
T
>
inline
Foam
::
label
Foam
::
UIndirectList
<
T
>::
size
()
const
{
return
addressing_
.
size
();
}
template
<
class
T
>
inline
bool
Foam
::
UIndirectList
<
T
>::
empty
()
const
{
return
addressing_
.
empty
();
}
template
<
class
T
>
inline
const
Foam
::
UList
<
T
>&
Foam
::
UIndirectList
<
T
>::
completeList
()
const
{
return
completeList_
;
}
template
<
class
T
>
inline
const
Foam
::
List
<
Foam
::
label
>&
Foam
::
UIndirectList
<
T
>::
addressing
()
const
{
return
addressing_
;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template
<
class
T
>
inline
Foam
::
List
<
T
>
Foam
::
UIndirectList
<
T
>::
operator
()()
const
{
List
<
T
>
result
(
size
());
forAll
(
*
this
,
i
)
{
result
[
i
]
=
operator
[](
i
);
}
return
result
;
}
template
<
class
T
>
inline
T
&
Foam
::
UIndirectList
<
T
>::
operator
[](
const
label
i
)
{
return
completeList_
[
addressing_
[
i
]];
}
template
<
class
T
>
inline
const
T
&
Foam
::
UIndirectList
<
T
>::
operator
[](
const
label
i
)
const
{
return
completeList_
[
addressing_
[
i
]];
}
template
<
class
T
>
inline
void
Foam
::
UIndirectList
<
T
>::
operator
=
(
const
UList
<
T
>&
ae
)
{
if
(
addressing_
.
size
()
!=
ae
.
size
())
{
FatalErrorIn
(
"UIndirectList<T>::operator=(const UList<T>&)"
)
<<
"Addressing and list of addressed elements "
"have different sizes: "
<<
addressing_
.
size
()
<<
" "
<<
ae
.
size
()