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
f76552f7
Commit
f76552f7
authored
Oct 06, 2017
by
Mark OLESEN
Browse files
STYLE: rebase edge on labelPair, additional methods in Pair
- use FixedList first/last in Pair first/second - consistent first/second access for line
parent
049617d0
Changes
17
Hide whitespace changes
Inline
Side-by-side
applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C
View file @
f76552f7
...
...
@@ -282,7 +282,7 @@ Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load()
forAll
(
surface_
,
fI
)
{
faces
[
fI
]
=
surface_
.
triSurface
::
operator
[](
fI
)
.
triFaceFace
()
;
faces
[
fI
]
=
surface_
.
triSurface
::
operator
[](
fI
);
}
vtkSurfaceWriter
().
write
...
...
applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C
View file @
f76552f7
...
...
@@ -721,7 +721,7 @@ int main(int argc, char *argv[])
isoFaces
.
setSize
(
iso
.
size
());
forAll
(
isoFaces
,
i
)
{
isoFaces
[
i
]
=
iso
[
i
]
.
triFaceFace
()
;
isoFaces
[
i
]
=
iso
[
i
];
}
isoPoints
=
iso
.
points
();
}
...
...
applications/utilities/surface/surfaceCheck/surfaceCheck.C
View file @
f76552f7
...
...
@@ -150,7 +150,7 @@ void writeZoning
faceList
faces
(
surf
.
size
());
forAll
(
surf
,
i
)
{
faces
[
i
]
=
surf
[
i
]
.
triFaceFace
()
;
faces
[
i
]
=
surf
[
i
];
}
vtkSurfaceWriter
().
write
...
...
applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C
View file @
f76552f7
...
...
@@ -368,7 +368,7 @@ int main(int argc, char *argv[])
faces
.
setSize
(
surf
.
size
());
forAll
(
surf
,
fi
)
{
faces
[
fi
]
=
surf
[
fi
]
.
triFaceFace
()
;
faces
[
fi
]
=
surf
[
fi
];
}
}
...
...
src/OpenFOAM/meshes/meshShapes/edge/edge.H
View file @
f76552f7
...
...
@@ -28,7 +28,7 @@ Description
An edge is a list of two point labels. The functionality it provides
supports the discretisation on a 2-D flat mesh.
The edge is implemented as a FixedList of labels.
The edge is implemented as a
Pair/
FixedList of labels.
As well as geometrically relevant methods, it also provides methods
similar to HashSet for additional convenience.
Valid point labels are always non-negative (since they correspond to
...
...
@@ -37,6 +37,7 @@ Description
can be filled with a HashSet-like functionality.
SourceFiles
edge.C
edgeI.H
\*---------------------------------------------------------------------------*/
...
...
@@ -44,10 +45,9 @@ SourceFiles
#ifndef edge_H
#define edge_H
#include
"FixedList.H"
#include
"labelPair.H"
#include
"pointField.H"
#include
"linePointRef.H"
#include
"pointField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -60,7 +60,7 @@ namespace Foam
class
edge
:
public
FixedList
<
label
,
2
>
public
label
Pair
{
// Private Member Functions
...
...
@@ -93,19 +93,19 @@ public:
//- Construct null with invalid point labels (-1)
inline
edge
();
//- Construct from
component
s
//- Construct from
two point label
s
inline
edge
(
const
label
from
,
const
label
to
);
//- Construct, optionally sorted with start less-than end
inline
edge
(
const
label
from
,
const
label
to
,
const
bool
doSort
);
//- Construct from two labels
//- Construct from pair of labels
inline
edge
(
const
labelPair
&
pair
);
//- Construct from
FixedL
ist
//- Construct from
l
ist
inline
edge
(
const
FixedList
<
label
,
2
>&
lst
);
//- Construct, optionally sorted with start less-than end
//- Construct from two point labels, sorted with first less-than second
inline
edge
(
const
label
from
,
const
label
to
,
const
bool
doSort
);
//- Construct from list, sorted with first less-than second
inline
edge
(
const
FixedList
<
label
,
2
>&
lst
,
const
bool
doSort
);
//- Construct from Istream
...
...
@@ -116,16 +116,26 @@ public:
// Access
//- Return start vertex label
//- Return first vertex label
using
labelPair
::
first
;
//- Return last (second) vertex label
using
labelPair
::
last
;
//- Return second (last) vertex label
using
labelPair
::
second
;
//- Return start (first) vertex label
inline
label
start
()
const
;
//- Return start vertex label
//- Return start
(first)
vertex label
inline
label
&
start
();
//- Return end vertex label
//- Return end
(last/second)
vertex label
inline
label
end
()
const
;
//- Return end vertex label
//- Return end
(last/second)
vertex label
inline
label
&
end
();
//- Return reverse edge as copy.
...
...
@@ -143,10 +153,6 @@ public:
// No special handling of negative point labels.
inline
label
maxVertex
()
const
;
//- True if start() is less-than end()
// No special handling of negative point labels.
inline
bool
sorted
()
const
;
//- Return true if point label is found in edge.
// Always false for a negative label.
inline
bool
found
(
const
label
pointLabel
)
const
;
...
...
@@ -175,14 +181,6 @@ public:
// Return the effective size after collapsing.
inline
label
collapse
();
//- Flip the edge in-place.
// No special handling of negative point labels.
inline
void
flip
();
//- Sort so that start() is less-than end()
// No special handling of negative point labels.
inline
void
sort
();
// Hash-like functions
...
...
@@ -211,8 +209,8 @@ public:
// Returns true on success. Negative labels never insert.
// Return the number of slots filled.
// Similar to a HashTable::insert().
template
<
unsigned
Any
Size
>
inline
label
insert
(
const
FixedList
<
label
,
Any
Size
>&
lst
);
template
<
unsigned
Size
>
inline
label
insert
(
const
FixedList
<
label
,
Size
>&
lst
);
//- Fill open slots with the indices if they did not previously exist.
// Returns true on success. Negative labels never insert.
...
...
@@ -231,8 +229,8 @@ public:
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.
template
<
unsigned
Any
Size
>
inline
label
erase
(
const
FixedList
<
label
,
Any
Size
>&
lst
);
template
<
unsigned
Size
>
inline
label
erase
(
const
FixedList
<
label
,
Size
>&
lst
);
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.
...
...
@@ -265,7 +263,7 @@ public:
// Comparison
//- Compare edges
//
R
eturn
s:
//
\r
eturn
// - 0: different
// - +1: identical values and order used
// - -1: identical values, but in different order
...
...
@@ -274,7 +272,14 @@ public:
};
// Global Operators
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
//- Return reverse of an edge
inline
edge
reverse
(
const
edge
&
e
)
{
return
edge
(
e
.
second
(),
e
.
first
());
}
//- Compare edges for equal content, ignoring orientation
inline
bool
operator
==
(
const
edge
&
a
,
const
edge
&
b
);
...
...
@@ -290,15 +295,15 @@ inline unsigned Hash<edge>::operator()(const edge& e, unsigned seed) const
{
unsigned
val
=
seed
;
if
(
e
[
0
]
<
e
[
1
]
)
if
(
e
.
first
()
<
e
.
second
()
)
{
val
=
Hash
<
label
>
()(
e
[
0
]
,
val
);
val
=
Hash
<
label
>
()(
e
[
1
]
,
val
);
val
=
Hash
<
label
>
()(
e
.
first
()
,
val
);
val
=
Hash
<
label
>
()(
e
.
second
()
,
val
);
}
else
{
val
=
Hash
<
label
>
()(
e
[
1
]
,
val
);
val
=
Hash
<
label
>
()(
e
[
0
]
,
val
);
val
=
Hash
<
label
>
()(
e
.
second
()
,
val
);
val
=
Hash
<
label
>
()(
e
.
first
()
,
val
);
}
return
val
;
...
...
@@ -313,7 +318,7 @@ inline unsigned Hash<edge>::operator()(const edge& e) const
return
Hash
<
edge
>
()(
e
,
0
);
}
// Edges are a pair of labels - thus contiguous
template
<
>
inline
bool
contiguous
<
edge
>
()
{
return
true
;}
...
...
src/OpenFOAM/meshes/meshShapes/edge/edgeI.H
View file @
f76552f7
...
...
@@ -24,24 +24,12 @@ License
\*---------------------------------------------------------------------------*/
#include
"IOstreams.H"
#include
"Swap.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
inline
int
Foam
::
edge
::
compare
(
const
edge
&
a
,
const
edge
&
b
)
{
if
(
a
[
0
]
==
b
[
0
]
&&
a
[
1
]
==
b
[
1
])
{
return
1
;
}
else
if
(
a
[
0
]
==
b
[
1
]
&&
a
[
1
]
==
b
[
0
])
{
return
-
1
;
}
else
{
return
0
;
}
return
labelPair
::
compare
(
a
,
b
);
}
...
...
@@ -56,7 +44,7 @@ inline Foam::label Foam::edge::insertMultiple
{
// Available slots.
// Don't use count() since it has special treatment for duplicates
const
int
maxChange
=
(
star
t
()
<
0
?
1
:
0
)
+
(
e
nd
()
<
0
?
1
:
0
);
const
int
maxChange
=
(
firs
t
()
<
0
?
1
:
0
)
+
(
seco
nd
()
<
0
?
1
:
0
);
int
changed
=
0
;
if
(
maxChange
)
...
...
@@ -86,7 +74,7 @@ inline Foam::label Foam::edge::eraseMultiple
{
// Occupied slots.
// Don't use count() since it has special treatment for duplicates
const
int
maxChange
=
(
star
t
()
>=
0
?
1
:
0
)
+
(
e
nd
()
>=
0
?
1
:
0
);
const
int
maxChange
=
(
firs
t
()
>=
0
?
1
:
0
)
+
(
seco
nd
()
>=
0
?
1
:
0
);
int
changed
=
0
;
if
(
maxChange
)
...
...
@@ -109,64 +97,43 @@ inline Foam::label Foam::edge::eraseMultiple
inline
Foam
::
edge
::
edge
()
:
FixedList
<
label
,
2
>
(
-
1
)
labelPair
(
-
1
,
-
1
)
{}
inline
Foam
::
edge
::
edge
(
const
label
from
,
const
label
to
)
{
start
()
=
from
;
end
()
=
to
;
}
inline
Foam
::
edge
::
edge
(
const
label
from
,
const
label
to
,
const
bool
doSort
)
{
if
(
doSort
&&
from
>
to
)
{
start
()
=
to
;
end
()
=
from
;
}
else
{
start
()
=
from
;
end
()
=
to
;
}
}
:
labelPair
(
from
,
to
)
{}
inline
Foam
::
edge
::
edge
(
const
labelPair
&
pair
)
{
start
()
=
pair
.
first
();
end
()
=
pair
.
second
();
}
:
labelPair
(
pair
.
first
(),
pair
.
second
())
{}
inline
Foam
::
edge
::
edge
(
const
FixedList
<
label
,
2
>&
lst
)
{
start
()
=
lst
[
0
];
end
()
=
lst
[
1
];
}
:
labelPair
(
lst
.
first
(),
lst
.
last
())
{}
inline
Foam
::
edge
::
edge
(
const
label
from
,
const
label
to
,
const
bool
doSort
)
:
labelPair
(
from
,
to
,
doSort
)
{}
inline
Foam
::
edge
::
edge
(
const
FixedList
<
label
,
2
>&
lst
,
const
bool
doSort
)
{
if
(
doSort
&&
lst
[
0
]
>
lst
[
1
])
{
start
()
=
lst
[
1
];
end
()
=
lst
[
0
];
}
else
{
start
()
=
lst
[
0
];
end
()
=
lst
[
1
];
}
}
:
labelPair
(
lst
,
doSort
)
{}
inline
Foam
::
edge
::
edge
(
Istream
&
is
)
:
FixedList
<
label
,
2
>
(
is
)
label
Pair
(
is
)
{}
...
...
@@ -174,42 +141,47 @@ inline Foam::edge::edge(Istream& is)
inline
Foam
::
label
Foam
::
edge
::
start
()
const
{
return
operator
[](
0
);
return
first
(
);
}
inline
Foam
::
label
&
Foam
::
edge
::
start
()
{
return
operator
[](
0
);
return
first
(
);
}
inline
Foam
::
label
Foam
::
edge
::
end
()
const
{
return
operator
[](
1
);
return
second
(
);
}
inline
Foam
::
label
&
Foam
::
edge
::
end
()
{
return
operator
[](
1
);
return
second
(
);
}
inline
Foam
::
label
Foam
::
edge
::
minVertex
()
const
{
return
(
star
t
()
<
e
nd
()
?
star
t
()
:
e
nd
());
return
(
firs
t
()
<
seco
nd
()
?
firs
t
()
:
seco
nd
());
}
inline
Foam
::
label
Foam
::
edge
::
maxVertex
()
const
{
return
(
star
t
()
>
e
nd
()
?
star
t
()
:
e
nd
());
return
(
firs
t
()
>
seco
nd
()
?
firs
t
()
:
seco
nd
());
}
inline
bool
Foam
::
edge
::
found
(
const
label
pointLabel
)
const
{
// -1: always false
return
(
pointLabel
>=
0
&&
(
pointLabel
==
start
()
||
pointLabel
==
end
()));
return
(
pointLabel
>=
0
&&
(
pointLabel
==
first
()
||
pointLabel
==
second
())
);
}
...
...
@@ -218,11 +190,11 @@ inline Foam::label Foam::edge::which(const label pointLabel) const
// -1: always false
if
(
pointLabel
>=
0
)
{
if
(
pointLabel
==
star
t
())
if
(
pointLabel
==
firs
t
())
{
return
0
;
}
if
(
pointLabel
==
e
nd
())
if
(
pointLabel
==
seco
nd
())
{
return
1
;
}
...
...
@@ -233,43 +205,39 @@ inline Foam::label Foam::edge::which(const label pointLabel) const
inline
bool
Foam
::
edge
::
connects
(
const
edge
&
other
)
const
{
return
(
other
.
found
(
star
t
())
||
other
.
found
(
e
nd
()));
return
(
other
.
found
(
firs
t
())
||
other
.
found
(
seco
nd
()));
}
inline
Foam
::
label
Foam
::
edge
::
commonVertex
(
const
edge
&
other
)
const
{
if
(
other
.
found
(
start
()))
{
return
start
();
}
else
if
(
other
.
found
(
end
()))
if
(
other
.
found
(
first
()))
{
return
end
();
return
first
();
}
else
if
(
other
.
found
(
second
()))
{
// No shared vertex.
return
-
1
;
return
second
();
}
// No shared vertex.
return
-
1
;
}
inline
Foam
::
label
Foam
::
edge
::
otherVertex
(
const
label
index
)
const
{
if
(
index
==
start
())
{
return
end
();
}
else
if
(
index
==
end
())
if
(
index
==
first
())
{
return
s
tart
();
return
s
econd
();
}
else
if
(
index
==
second
())
{
// The given vertex is not on the edge in the first place.
return
-
1
;
return
first
();
}
// The given vertex is not on the edge in the first place.
return
-
1
;
}
...
...
@@ -280,12 +248,12 @@ inline Foam::label Foam::edge::collapse()
// catch any '-1' (eg, if called multiple times)
label
n
=
2
;
if
(
star
t
()
==
e
nd
()
||
e
nd
()
<
0
)
if
(
firs
t
()
==
seco
nd
()
||
seco
nd
()
<
0
)
{
e
nd
()
=
-
1
;
seco
nd
()
=
-
1
;
--
n
;
}
if
(
star
t
()
<
0
)
if
(
firs
t
()
<
0
)
{
--
n
;
}
...
...
@@ -294,48 +262,27 @@ inline Foam::label Foam::edge::collapse()
}
inline
bool
Foam
::
edge
::
sorted
()
const
{
return
(
start
()
<
end
());
}
inline
void
Foam
::
edge
::
sort
()
{
if
(
start
()
>
end
())
{
flip
();
}
}
inline
void
Foam
::
edge
::
flip
()
{
Swap
(
operator
[](
0
),
operator
[](
1
));
}
inline
Foam
::
edge
Foam
::
edge
::
reverseEdge
()
const
{
return
edge
(
e
nd
(),
star
t
());
return
edge
(
seco
nd
(),
firs
t
());
}
inline
void
Foam
::
edge
::
clear
()
{
star
t
()
=
-
1
;
e
nd
()
=
-
1
;
firs
t
()
=
-
1
;
seco
nd
()
=
-
1
;
}
inline
Foam
::
label
Foam
::
edge
::
count
()
const
{
label
n
=
2
;
if
(
star
t
()
==
e
nd
()
||
e
nd
()
<
0
)
if
(
firs
t
()
==
seco
nd
()
||
seco
nd
()
<
0
)
{
--
n
;
}
if
(
star
t
()
<
0
)
if
(
firs
t
()
<
0
)
{
--
n
;
}
...
...
@@ -346,7 +293,7 @@ inline Foam::label Foam::edge::count() const
inline
bool
Foam
::
edge
::
empty
()
const
{
return
(
star
t
()
<
0
&&
e
nd
()
<
0
);
return
(
firs
t
()
<
0
&&
seco
nd
()
<
0
);
}
...
...
@@ -358,21 +305,21 @@ inline bool Foam::edge::insert(const label index)
return
false
;
}
if
(
star
t
()
<
0
)
if
(
firs
t
()
<
0
)
{
// Store at
[0]
, if not duplicate of
[1]
if
(
index
!=
e
nd
())
// Store at
first
, if not duplicate of
second
if
(
index
!=
seco
nd
())
{
star
t
()
=
index
;
firs
t
()
=
index
;
return
true
;
}
}
else
if
(
e
nd
()
<
0
)
else
if
(
seco
nd
()
<
0
)
{
// Store at
[1]
, if not duplicate of
[0]
if
(
index
!=
star
t
())
// Store at
second
, if not duplicate of
first
if
(
index
!=
firs
t
())
{
e
nd
()
=
index
;
seco
nd
()
=
index
;
return
true
;
}
}
...
...
@@ -387,8 +334,8 @@ inline Foam::label Foam::edge::insert(const UList<label>& lst)
}
template
<
unsigned
Any
Size
>
inline
Foam
::
label
Foam
::
edge
::
insert
(
const
FixedList
<
label
,
Any
Size
>&
lst
)
template
<
unsigned
Size
>
inline
Foam
::
label
Foam
::
edge
::
insert
(
const
FixedList
<
label
,
Size
>&
lst
)
{
return
insertMultiple
(
lst
.
begin
(),
lst
.
end
());
}
...
...
@@ -409,16 +356,16 @@ inline Foam::label Foam::edge::erase(const label index)
}
label
n
=
0
;
if
(
index
==
star
t
())
if
(
index
==
firs
t
())
{
star
t
()
=
-
1
;