Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
7ec390d2
Commit
7ec390d2
authored
Oct 04, 2010
by
Andrew Heather
Browse files
Merge branch 'olesenm'
parents
8f1a8dd4
4ed8ff2c
Changes
85
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/meshes/polyMesh/zones/ZoneID/polyPatchID
.H
→
applications/test/IndirectList2/IndirectList2
.H
View file @
7ec390d2
...
...
@@ -22,112 +22,128 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::
polyPatchID
Foam::
IndirectList2
Description
A
class holds the data needed to identify a patch in a dynamic mesh
.
A
List with indirect addressing
.
The patch is identified by name and its index in the boundary mesh
is updated if the mesh has changed.
SourceFiles
IndirectListI.H
\*---------------------------------------------------------------------------*/
#ifndef
polyPatchID
_H
#define
polyPatchID
_H
#ifndef
IndirectList2
_H
#define
IndirectList2
_H
#include "
polyBoundaryMesh
.H"
#include "
UIndirectList
.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
// Forward declaration of friend functions and operators
class
polyPatchID
;
Ostream
&
operator
<<
(
Ostream
&
os
,
const
polyPatchID
&
p
);
/*---------------------------------------------------------------------------*\
Class polyPatchID
Declaration
Class IndirectListAddressing
Declaration
\*---------------------------------------------------------------------------*/
class
polyPatchID
//- A helper class for storing addresses.
class
IndirectListAddressing
{
// Private data
//-
Patch name
word
name
_
;
//-
Storage for the list addressing
List
<
label
>
addressing
_
;
//- Patch index
label
index_
;
// Private Member Functions
public:
//- Disallow default bitwise copy construct
IndirectListAddressing
(
const
IndirectListAddressing
&
);
//- Disallow default bitwise assignment
void
operator
=
(
const
IndirectListAddressing
&
);
protected:
// Constructors
//- Construct from name
polyPatchID
(
const
word
&
name
,
const
polyBoundaryMesh
&
bm
)
:
name_
(
name
),
index_
(
bm
.
findPatchID
(
name
))
{}
//- Construct by copying the addressing array
explicit
inline
IndirectListAddressing
(
const
UList
<
label
>&
addr
);
//- Construct from Istream
polyPatchID
(
Istream
&
is
,
const
polyBoundaryMesh
&
bm
)
:
name_
(
is
),
index_
(
bm
.
findPatchID
(
name_
))
{}
//- Construct by transferring addressing array
explicit
inline
IndirectListAddressing
(
const
Xfer
<
List
<
label
>
>&
addr
);
// Member Functions
// Access
//- Return name
const
word
&
name
()
const
{
return
name_
;
}
//- Return the list addressing
inline
const
List
<
label
>&
addressing
()
const
;
//- Return index
label
index
()
const
{
return
index_
;
}
// Edit
//- Has the patch been found
bool
active
()
const
{
return
index_
>
-
1
;
}
//- Reset addressing
inline
void
resetAddressing
(
const
UList
<
label
>&
);
inline
void
resetAddressing
(
const
Xfer
<
List
<
label
>
>&
);
};
// Edit
//- Update
void
update
(
const
polyBoundaryMesh
&
bm
)
{
index_
=
bm
.
findPatchID
(
name_
);
}
/*---------------------------------------------------------------------------*\
Class IndirectList2 Declaration
\*---------------------------------------------------------------------------*/
template
<
class
T
>
class
IndirectList2
:
private
IndirectListAddressing
,
public
UIndirectList
<
T
>
{
// Private Member Functions
//- Disable default assignment operator
void
operator
=
(
const
IndirectList2
<
T
>&
);
//- Disable assignment from UIndirectList
void
operator
=
(
const
UIndirectList
<
T
>&
);
public:
// Constructors
// Ostream Operator
//- Construct given the complete list and the addressing array
inline
IndirectList2
(
const
UList
<
T
>&
,
const
UList
<
label
>&
);
friend
Ostream
&
operator
<<
(
Ostream
&
os
,
const
polyPatchID
&
p
)
{
os
<<
token
::
BEGIN_LIST
<<
p
.
name_
<<
token
::
SPACE
<<
p
.
index_
<<
token
::
END_LIST
;
//- Construct given the complete list and by transferring addressing
inline
IndirectList2
(
const
UList
<
T
>&
,
const
Xfer
<
List
<
label
>
>&
);
// Check state of Ostream
os
.
check
(
"Ostream& operator<<(Ostream&, const polyPatchID&)"
);
//- Copy constructor
inline
IndirectList2
(
const
IndirectList2
<
T
>&
);
//- Construct from UIndirectList
explicit
inline
IndirectList2
(
const
UIndirectList
<
T
>&
);
// Member Functions
// Access
//- Return the list addressing
using
UIndirectList
<
T
>::
addressing
;
// Edit
//- Reset addressing
using
IndirectListAddressing
::
resetAddressing
;
// Member Operators
//- Assignment operator
using
UIndirectList
<
T
>::
operator
=
;
return
os
;
}
};
...
...
@@ -137,6 +153,10 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "IndirectList2I.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
applications/test/IndirectList2/IndirectList2I.H
0 → 100644
View file @
7ec390d2
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline
Foam
::
IndirectListAddressing
::
IndirectListAddressing
(
const
UList
<
label
>&
addr
)
:
addressing_
(
addr
)
{}
inline
Foam
::
IndirectListAddressing
::
IndirectListAddressing
(
const
Xfer
<
List
<
label
>
>&
addr
)
:
addressing_
(
addr
)
{}
template
<
class
T
>
inline
Foam
::
IndirectList2
<
T
>::
IndirectList2
(
const
UList
<
T
>&
completeList
,
const
UList
<
label
>&
addr
)
:
IndirectListAddressing
(
addr
),
UIndirectList
<
T
>
(
completeList
,
IndirectListAddressing
::
addressing
()
)
{}
template
<
class
T
>
inline
Foam
::
IndirectList2
<
T
>::
IndirectList2
(
const
UList
<
T
>&
completeList
,
const
Xfer
<
List
<
label
>
>&
addr
)
:
IndirectListAddressing
(
addr
),
UIndirectList
<
T
>
(
completeList
,
IndirectListAddressing
::
addressing
()
)
{}
template
<
class
T
>
inline
Foam
::
IndirectList2
<
T
>::
IndirectList2
(
const
IndirectList2
<
T
>&
lst
)
:
IndirectListAddressing
(
lst
.
addressing
()),
UIndirectList
<
T
>
(
lst
.
completeList
(),
IndirectListAddressing
::
addressing
()
)
{}
template
<
class
T
>
inline
Foam
::
IndirectList2
<
T
>::
IndirectList2
(
const
UIndirectList
<
T
>&
lst
)
:
IndirectListAddressing
(
lst
.
addressing
()),
UIndirectList
<
T
>
(
lst
.
completeList
(),
IndirectListAddressing
::
addressing
()
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline
const
Foam
::
List
<
Foam
::
label
>&
Foam
::
IndirectListAddressing
::
addressing
()
const
{
return
addressing_
;
}
inline
void
Foam
::
IndirectListAddressing
::
resetAddressing
(
const
UList
<
label
>&
addr
)
{
addressing_
=
addr
;
}
inline
void
Foam
::
IndirectListAddressing
::
resetAddressing
(
const
Xfer
<
List
<
label
>
>&
addr
)
{
addressing_
.
transfer
(
addr
());
}
// ************************************************************************* //
applications/test/IndirectList2/IndirectListTest2.C
0 → 100644
View file @
7ec390d2
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 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 3 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, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/
#include "IndirectList2.H"
#include "IOstreams.H"
using
namespace
Foam
;
template
<
class
ListType
>
void
printInfo
(
const
ListType
&
lst
)
{
Info
<<
"addr: "
<<
lst
.
addressing
()
<<
nl
<<
"list: "
<<
lst
<<
nl
<<
endl
;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int
main
(
int
argc
,
char
*
argv
[])
{
List
<
double
>
completeList
(
10
);
forAll
(
completeList
,
i
)
{
completeList
[
i
]
=
0
.
1
*
i
;
}
Info
<<
"raw : "
<<
completeList
<<
nl
<<
endl
;
List
<
label
>
addresses
(
5
);
addresses
[
0
]
=
1
;
addresses
[
1
]
=
0
;
addresses
[
2
]
=
7
;
addresses
[
3
]
=
8
;
addresses
[
4
]
=
5
;
IndirectList2
<
double
>
idl1
(
completeList
,
addresses
);
printInfo
(
idl1
);
addresses
[
4
]
=
1
;
addresses
[
3
]
=
0
;
addresses
[
2
]
=
7
;
addresses
[
1
]
=
8
;
addresses
[
0
]
=
5
;
idl1
.
resetAddressing
(
addresses
.
xfer
());
printInfo
(
idl1
);
// test copying
UIndirectList
<
double
>
uidl1
(
idl1
);
IndirectList2
<
double
>
idl2
(
uidl1
);
IndirectList2
<
double
>
idl3
(
idl2
);
printInfo
(
uidl1
);
idl1
.
resetAddressing
(
List
<
label
>
());
// idl2.resetAddressing(List<label>());
Info
<<
"after resetAddressing:"
<<
nl
<<
endl
;
printInfo
(
uidl1
);
printInfo
(
idl1
);
printInfo
(
idl2
);
printInfo
(
idl3
);
Info
<<
"End
\n
"
<<
endl
;
return
0
;
}
// ************************************************************************* //
applications/test/IndirectList2/Make/files
0 → 100644
View file @
7ec390d2
IndirectListTest2.C
EXE = $(FOAM_USER_APPBIN)/IndirectListTest2
applications/test/IndirectList2/Make/options
0 → 100644
View file @
7ec390d2
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
/* EXE_LIBS = -lfiniteVolume */
applications/test/PackedList/PackedListTest.C
View file @
7ec390d2
...
...
@@ -166,7 +166,7 @@ int main(int argc, char *argv[])
if
(
args
.
optionFound
(
"info"
))
{
packLst
.
print
(
Info
);
packLst
.
print
Info
(
Info
);
}
Info
<<
nl
;
...
...
applications/test/PackedList1/PackedListTest1.C
View file @
7ec390d2
...
...
@@ -42,42 +42,42 @@ int main(int argc, char *argv[])
Info
<<
"
\n
test allocation with value
\n
"
;
PackedList
<
3
>
list1
(
5
,
1
);
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test assign uniform value
\n
"
;
list1
=
3
;
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test assign uniform value (with overflow)
\n
"
;
list1
=
-
1
;
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test zero
\n
"
;
list1
=
0
;
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test set() with default argument (max_value)
\n
"
;
list1
.
set
(
1
);
list1
.
set
(
3
);
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test unset() with in-range and out-of-range
\n
"
;
list1
.
unset
(
3
);
list1
.
unset
(
100000
);
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test assign between references
\n
"
;
list1
[
2
]
=
3
;
list1
[
4
]
=
list1
[
2
];
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test assign between references, with chaining
\n
"
;
list1
[
0
]
=
list1
[
4
]
=
1
;
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test assign between references, with chaining and auto-vivify
\n
"
;
list1
[
1
]
=
list1
[
8
]
=
list1
[
10
]
=
list1
[
14
]
=
2
;
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test operator== between references
\n
"
;
...
...
@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
{
const
PackedList
<
3
>&
constLst
=
list1
;
Info
<<
"
\n
test operator[] const with out-of-range index
\n
"
;
constLst
.
print
(
Info
);
constLst
.
print
Info
(
Info
,
true
);
if
(
constLst
[
20
])
{
Info
<<
"[20] is true (unexpected)
\n
"
;
...
...
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
Info
<<
"[20] is false (expected) list size should be unchanged "
<<
"(const)
\n
"
;
}
constLst
.
print
(
Info
);
constLst
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test operator[] non-const with out-of-range index
\n
"
;
if
(
list1
[
20
])
...
...
@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
Info
<<
"[20] is false (expected) but list was resized?? "
<<
"(non-const)
\n
"
;
}
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
}
...
...
@@ -157,85 +157,85 @@ int main(int argc, char *argv[])
{
Info
<<
"[20] is false, as expected
\n
"
;
}
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test resize with value (without reallocation)
\n
"
;
list1
.
resize
(
8
,
list1
.
max_value
());
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test flip() function
\n
"
;
list1
.
flip
();
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
re-flip()
\n
"
;
list1
.
flip
();
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test set() function
\n
"
;
list1
.
set
(
1
,
5
);
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test assign bool
\n
"
;
list1
=
false
;
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test assign bool
\n
"
;
list1
=
true
;
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test resize without value (with reallocation)
\n
"
;
list1
.
resize
(
12
);
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test resize with value (with reallocation)
\n
"
;
list1
.
resize
(
25
,
list1
.
max_value
());
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test resize smaller (should not touch allocation)
\n
"
;
list1
.
resize
(
8
);
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test append() operation
\n
"
;
list1
.
append
(
2
);
list1
.
append
(
3
);
list1
.
append
(
4
);
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test reserve() operation
\n
"
;
list1
.
reserve
(
32
);
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test shrink() operation
\n
"
;
list1
.
shrink
();
list1
.
print
(
Info
);
list1
.
print
Info
(
Info
,
true
);
Info
<<
"
\n
test setCapacity() operation
\n
"
;
list1
.
setCapacity
(
15
);
list1
.
print