Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
openfoam
Commits
10121efb
Commit
10121efb
authored
12 years ago
by
laurence
Browse files
Options
Downloads
Patches
Plain Diff
ENH: face: Use circulator in compare()
parent
b8280269
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/OpenFOAM/meshes/meshShapes/face/face.C
+49
-104
49 additions, 104 deletions
src/OpenFOAM/meshes/meshShapes/face/face.C
with
49 additions
and
104 deletions
src/OpenFOAM/meshes/meshShapes/face/face.C
+
49
−
104
View file @
10121efb
...
...
@@ -28,6 +28,7 @@ License
#include
"triPointRef.H"
#include
"mathematicalConstants.H"
#include
"Swap.H"
#include
"const_circulator.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...
...
@@ -299,7 +300,6 @@ Foam::face::face(const triFace& f)
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
// return
// 0: no match
// +1: identical
...
...
@@ -314,144 +314,89 @@ int Foam::face::compare(const face& a, const face& b)
label
sizeA
=
a
.
size
();
label
sizeB
=
b
.
size
();
if
(
sizeA
!=
sizeB
)
if
(
sizeA
!=
sizeB
||
sizeA
==
0
)
{
return
0
;
}
const_circulator
<
face
>
aCirc
(
a
);
const_circulator
<
face
>
bCirc
(
b
);
// Full list comparison
const
label
firstA
=
a
[
0
];
label
Bptr
=
-
1
;
forAll
(
b
,
i
)
// Rotate face b until its element matches the starting element of face a.
do
{
if
(
b
[
i
]
==
firstA
)
if
(
aCirc
()
==
bCirc
()
)
{
Bptr
=
i
;
// 'found match' at element 'i'
// Set bCirc fulcrum to its iterator and increment the iterators
bCirc
.
setFulcrumToIterator
();
++
aCirc
;
++
bCirc
;
break
;
}
}
}
while
(
bCirc
.
circulate
(
CirculatorBase
::
CLOCKWISE
));
// If no match was found, return 0
if
(
Bptr
<
0
)
// If the circulator has stopped then faces a and b do not share a matching
// point
if
(
!
bCirc
.
circulate
())
{
return
0
;
}
// Now we must look for the direction, if any
label
secondA
=
a
[
1
];
if
(
sizeA
>
1
&&
(
secondA
==
firstA
||
firstA
==
a
[
sizeA
-
1
]))
// Look forwards around the faces for a match
do
{
face
ca
=
a
;
ca
.
collapse
();
face
cb
=
b
;
cb
.
collapse
();
return
face
::
compare
(
ca
,
cb
);
}
int
dir
=
0
;
// Check whether at top of list
Bptr
++
;
if
(
Bptr
==
b
.
size
())
{
Bptr
=
0
;
if
(
aCirc
()
!=
bCirc
())
{
break
;
}
}
while
(
aCirc
.
circulate
(
CirculatorBase
::
CLOCKWISE
),
bCirc
.
circulate
(
CirculatorBase
::
CLOCKWISE
)
);
//
Test whether upward label matches second A label
if
(
b
[
Bptr
]
==
secondA
)
//
If the circulator has stopped then faces a and b matched.
if
(
!
aCirc
.
circulate
()
)
{
// Yes - direction is 'up'
dir
=
1
;
return
1
;
}
else
{
// No - so look downwards, checking whether at bottom of list
Bptr
-=
2
;
if
(
Bptr
<
0
)
{
// wraparound
Bptr
+=
b
.
size
();
}
// Test whether downward label matches second A label
if
(
b
[
Bptr
]
==
secondA
)
{
// Yes - direction is 'down'
dir
=
-
1
;
}
}
// Check whether a match was made at all, and exit 0 if not
if
(
dir
==
0
)
{
return
0
;
// Reset the circulators back to their fulcrum
aCirc
.
setIteratorToFulcrum
();
bCirc
.
setIteratorToFulcrum
();
++
aCirc
;
--
bCirc
;
}
// Decrement size by 2 to account for first searches
sizeA
-=
2
;
// We now have both direction of search and next element
// to search, so we can continue search until no more points.
label
Aptr
=
1
;
if
(
dir
>
0
)
// Look backwards around the faces for a match
do
{
while
(
sizeA
--
)
if
(
aCirc
()
!=
bCirc
()
)
{
Aptr
++
;
if
(
Aptr
>=
a
.
size
())
{
Aptr
=
0
;
}
Bptr
++
;
if
(
Bptr
>=
b
.
size
())
{
Bptr
=
0
;
}
if
(
a
[
Aptr
]
!=
b
[
Bptr
])
{
return
0
;
}
break
;
}
}
else
{
while
(
sizeA
--
)
{
Aptr
++
;
if
(
Aptr
>=
a
.
size
())
{
Aptr
=
0
;
}
Bptr
--
;
if
(
Bptr
<
0
)
{
Bptr
=
b
.
size
()
-
1
;
}
while
(
aCirc
.
circulate
(
CirculatorBase
::
CLOCKWISE
),
bCirc
.
circulate
(
CirculatorBase
::
ANTICLOCKWISE
)
);
if
(
a
[
Aptr
]
!=
b
[
Bptr
])
{
return
0
;
}
}
// If the circulator has stopped then faces a and b matched.
if
(
!
aCirc
.
circulate
())
{
return
-
1
;
}
// They must be equal - return direction
return
dir
;
return
0
;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam
::
label
Foam
::
face
::
collapse
()
{
if
(
size
()
>
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment