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
e105e30b
Commit
e105e30b
authored
May 04, 2017
by
Mark OLESEN
Browse files
STYLE: add edge(labelPair) constructor, debug info etc.
parent
f7e502d4
Changes
4
Hide whitespace changes
Inline
Side-by-side
applications/test/SLList/Test-SLList.C
View file @
e105e30b
...
...
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
Info
<<
nl
<<
"And again using STL iterator: "
<<
nl
<<
endl
;
for
(
auto
const
&
val
:
myList
)
for
(
const
auto
&
val
:
myList
)
{
Info
<<
"element:"
<<
val
<<
endl
;
}
...
...
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
myList
.
remove
(
iter
);
}
for
(
auto
const
&
val
:
const_myList
)
for
(
const
auto
&
val
:
const_myList
)
{
Info
<<
"element:"
<<
val
<<
endl
;
}
...
...
applications/test/edges/Test-edges.C
View file @
e105e30b
...
...
@@ -67,6 +67,17 @@ int main(int argc, char *argv[])
Info
<<
e3
<<
" connects "
<<
e2
<<
" => "
<<
e2
.
connects
(
e3
)
<<
endl
;
labelPair
labels
(
e3
);
Info
<<
"as labelPair: "
<<
labels
<<
endl
;
edge
e5
;
// Good: this fails (explicit constructor): printInfo(labels);
// Good: this also fails (no assignment operator): e5 = labels;
// OK: explicit
edge
e6
(
labels
);
Info
<<
nl
<<
"hash-like functionality"
<<
nl
;
// doesn't work e4 = -1;
...
...
src/OpenFOAM/meshes/meshShapes/edge/edge.H
View file @
e105e30b
...
...
@@ -45,6 +45,7 @@ SourceFiles
#define edge_H
#include
"FixedList.H"
#include
"labelPair.H"
#include
"pointField.H"
#include
"linePointRef.H"
...
...
@@ -65,7 +66,7 @@ class edge
//- Insert values, using begin/end iterators.
template
<
class
InputIter
>
inline
int
insertMultiple
inline
label
insertMultiple
(
const
InputIter
begIter
,
const
InputIter
endIter
...
...
@@ -73,7 +74,7 @@ class edge
//- Remove values, using begin/end iterators.
template
<
class
InputIter
>
inline
int
eraseMultiple
inline
label
eraseMultiple
(
const
InputIter
begIter
,
const
InputIter
endIter
...
...
@@ -98,6 +99,9 @@ public:
//- Construct, optionally sorted with start less-than end
inline
edge
(
const
label
from
,
const
label
to
,
const
bool
doSort
);
//- Construct from two labels
inline
edge
(
const
labelPair
&
pair
);
//- Construct from FixedList
inline
edge
(
const
FixedList
<
label
,
2
>&
lst
);
...
...
@@ -165,7 +169,7 @@ public:
//- 'Collapse' edge by marking duplicate point labels as '-1',
// the lower vertex is retained.
// Return the effective size after collapsing.
inline
int
collapse
();
inline
label
collapse
();
//- Flip the edge in-place.
// No special handling of negative point labels.
...
...
@@ -180,7 +184,7 @@ public:
//- Return the number of unique, valid (non -1) point labels.
// Similar to a HashTable::size().
inline
int
count
()
const
;
inline
label
count
()
const
;
//- Return true if edge has no valid point labels.
inline
bool
empty
()
const
;
...
...
@@ -194,41 +198,41 @@ public:
inline
bool
insert
(
const
label
index
);
//- Fill open slots with the indices if they did not previously exist.
// Returns true on success. Negative labels never insert
s
.
// Returns true on success. Negative labels never insert.
// Return the number of slots filled.
// Similar to a HashTable::insert().
inline
int
insert
(
const
UList
<
label
>&
lst
);
inline
label
insert
(
const
UList
<
label
>&
lst
);
//- Fill open slots with the indices if they did not previously exist.
// Returns true on success. Negative labels never insert
s
.
// Returns true on success. Negative labels never insert.
// Return the number of slots filled.
// Similar to a HashTable::insert().
template
<
unsigned
AnySize
>
inline
int
insert
(
const
FixedList
<
label
,
AnySize
>&
lst
);
inline
label
insert
(
const
FixedList
<
label
,
AnySize
>&
lst
);
//- Fill open slots with the indices if they did not previously exist.
// Returns true on success. Negative labels never insert
s
.
// Returns true on success. Negative labels never insert.
// Return the number of slots filled.
// Similar to a HashTable::insert().
inline
int
insert
(
std
::
initializer_list
<
label
>
lst
);
inline
label
insert
(
std
::
initializer_list
<
label
>
lst
);
//- Remove an existing index from the edge and set its location to '-1'.
// Returns the number of changes. A negative label never removes.
// Similar to a HashTable::erase().
inline
int
erase
(
const
label
index
);
inline
label
erase
(
const
label
index
);
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.
inline
int
erase
(
const
UList
<
label
>&
lst
);
inline
label
erase
(
const
UList
<
label
>&
lst
);
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.
template
<
unsigned
AnySize
>
inline
int
erase
(
const
FixedList
<
label
,
AnySize
>&
lst
);
inline
label
erase
(
const
FixedList
<
label
,
AnySize
>&
lst
);
//- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes.
inline
int
erase
(
std
::
initializer_list
<
label
>
lst
);
inline
label
erase
(
std
::
initializer_list
<
label
>
lst
);
// Geometric functions
...
...
src/OpenFOAM/meshes/meshShapes/edge/edgeI.H
View file @
e105e30b
...
...
@@ -48,7 +48,7 @@ inline int Foam::edge::compare(const edge& a, const edge& b)
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class
InputIter
>
inline
int
Foam
::
edge
::
insertMultiple
inline
Foam
::
label
Foam
::
edge
::
insertMultiple
(
const
InputIter
begIter
,
const
InputIter
endIter
...
...
@@ -78,7 +78,7 @@ inline int Foam::edge::insertMultiple
template
<
class
InputIter
>
inline
int
Foam
::
edge
::
eraseMultiple
inline
Foam
::
label
Foam
::
edge
::
eraseMultiple
(
const
InputIter
begIter
,
const
InputIter
endIter
...
...
@@ -135,6 +135,13 @@ inline Foam::edge::edge(const label from, const label to, const bool doSort)
}
inline
Foam
::
edge
::
edge
(
const
labelPair
&
pair
)
{
start
()
=
pair
.
first
();
end
()
=
pair
.
second
();
}
inline
Foam
::
edge
::
edge
(
const
FixedList
<
label
,
2
>&
lst
)
{
start
()
=
lst
[
0
];
...
...
@@ -248,13 +255,13 @@ inline Foam::label Foam::edge::otherVertex(const label index) const
}
inline
int
Foam
::
edge
::
collapse
()
inline
Foam
::
label
Foam
::
edge
::
collapse
()
{
// Cannot resize FixedList, so mark duplicates with '-1'
// (the lower vertex is retained)
// catch any '-1' (eg, if called multiple times)
int
n
=
2
;
label
n
=
2
;
if
(
start
()
==
end
()
||
end
()
<
0
)
{
end
()
=
-
1
;
...
...
@@ -303,7 +310,7 @@ inline void Foam::edge::clear()
}
inline
int
Foam
::
edge
::
count
()
const
inline
Foam
::
label
Foam
::
edge
::
count
()
const
{
label
n
=
2
;
if
(
start
()
==
end
()
||
end
()
<
0
)
...
...
@@ -356,24 +363,26 @@ inline bool Foam::edge::insert(const label index)
}
inline
int
Foam
::
edge
::
insert
(
const
UList
<
label
>&
lst
)
inline
Foam
::
label
Foam
::
edge
::
insert
(
const
UList
<
label
>&
lst
)
{
return
insertMultiple
(
lst
.
begin
(),
lst
.
end
());
}
template
<
unsigned
AnySize
>
inline
int
Foam
::
edge
::
insert
(
const
FixedList
<
label
,
AnySize
>&
lst
)
inline
Foam
::
label
Foam
::
edge
::
insert
(
const
FixedList
<
label
,
AnySize
>&
lst
)
{
return
insertMultiple
(
lst
.
begin
(),
lst
.
end
());
}
inline
int
Foam
::
edge
::
insert
(
std
::
initializer_list
<
label
>
lst
)
inline
Foam
::
label
Foam
::
edge
::
insert
(
std
::
initializer_list
<
label
>
lst
)
{
return
insertMultiple
(
lst
.
begin
(),
lst
.
end
());
}
inline
int
Foam
::
edge
::
erase
(
const
label
index
)
inline
Foam
::
label
Foam
::
edge
::
erase
(
const
label
index
)
{
if
(
index
<
0
)
{
...
...
@@ -381,7 +390,7 @@ inline int Foam::edge::erase(const label index)
return
0
;
}
int
n
=
0
;
label
n
=
0
;
if
(
index
==
start
())
{
start
()
=
-
1
;
...
...
@@ -399,18 +408,20 @@ inline int Foam::edge::erase(const label index)
}
inline
int
Foam
::
edge
::
erase
(
const
UList
<
label
>&
lst
)
inline
Foam
::
label
Foam
::
edge
::
erase
(
const
UList
<
label
>&
lst
)
{
return
eraseMultiple
(
lst
.
begin
(),
lst
.
end
());
}
template
<
unsigned
AnySize
>
inline
int
Foam
::
edge
::
erase
(
const
FixedList
<
label
,
AnySize
>&
lst
)
inline
Foam
::
label
Foam
::
edge
::
erase
(
const
FixedList
<
label
,
AnySize
>&
lst
)
{
return
eraseMultiple
(
lst
.
begin
(),
lst
.
end
());
}
inline
int
Foam
::
edge
::
erase
(
std
::
initializer_list
<
label
>
lst
)
inline
Foam
::
label
Foam
::
edge
::
erase
(
std
::
initializer_list
<
label
>
lst
)
{
return
eraseMultiple
(
lst
.
begin
(),
lst
.
end
());
}
...
...
@@ -420,18 +431,45 @@ inline int Foam::edge::erase(std::initializer_list<label> lst)
inline
Foam
::
point
Foam
::
edge
::
centre
(
const
UList
<
point
>&
pts
)
const
{
#ifdef FULLDEBUG
if
(
start
()
<
0
||
end
()
<
0
)
{
FatalErrorInFunction
<<
"negative point index on edge "
<<
*
this
<<
abort
(
FatalError
);
}
#endif
return
0.5
*
(
pts
[
start
()]
+
pts
[
end
()]);
}
inline
Foam
::
vector
Foam
::
edge
::
vec
(
const
UList
<
point
>&
pts
)
const
{
#ifdef FULLDEBUG
if
(
start
()
<
0
||
end
()
<
0
)
{
FatalErrorInFunction
<<
"negative point index on edge "
<<
*
this
<<
abort
(
FatalError
);
}
#endif
return
pts
[
end
()]
-
pts
[
start
()];
}
inline
Foam
::
vector
Foam
::
edge
::
unitVec
(
const
UList
<
point
>&
pts
)
const
{
#ifdef FULLDEBUG
if
(
start
()
<
0
||
end
()
<
0
)
{
FatalErrorInFunction
<<
"negative point index on edge "
<<
*
this
<<
abort
(
FatalError
);
}
#endif
Foam
::
vector
v
=
pts
[
end
()]
-
pts
[
start
()];
v
/=
::
Foam
::
mag
(
v
)
+
VSMALL
;
...
...
@@ -447,6 +485,15 @@ inline Foam::scalar Foam::edge::mag(const UList<point>& pts) const
inline
Foam
::
linePointRef
Foam
::
edge
::
line
(
const
UList
<
point
>&
pts
)
const
{
#ifdef FULLDEBUG
if
(
start
()
<
0
||
end
()
<
0
)
{
FatalErrorInFunction
<<
"negative point index on edge "
<<
*
this
<<
abort
(
FatalError
);
}
#endif
return
linePointRef
(
pts
[
start
()],
pts
[
end
()]);
}
...
...
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