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
bafddd77
Commit
bafddd77
authored
Aug 02, 2018
by
Mark Olesen
Browse files
ENH: use binary search for polyBoundaryMesh::whichPatch() (issue
#801
)
parent
32565b4b
Changes
1
Show whitespace changes
Inline
Side-by-side
src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C
View file @
bafddd77
...
...
@@ -747,36 +747,41 @@ Foam::label Foam::polyBoundaryMesh::whichPatch(const label faceIndex) const
else
if
(
faceIndex
>=
mesh
().
nFaces
())
{
FatalErrorInFunction
<<
"
given label
"
<<
faceIndex
<<
"
greater than the n
umber of geometric faces "
<<
mesh
().
nFaces
()
<<
"
Face
"
<<
faceIndex
<<
"
out of bounds. N
umber of geometric faces "
<<
mesh
().
nFaces
()
<<
abort
(
FatalError
);
}
forAll
(
*
this
,
patchi
)
{
const
polyPatch
&
bp
=
operator
[](
patchi
);
// Patches are ordered, use binary search
if
const
polyPatchList
&
patches
=
*
this
;
const
label
patchi
=
findLower
(
faceIndex
>=
bp
.
start
()
&&
faceIndex
<
bp
.
start
()
+
bp
.
size
()
)
{
return
patchi
;
}
}
patches
,
faceIndex
,
0
,
// Must include the start in the comparison
[](
const
polyPatch
&
p
,
label
val
)
{
return
(
p
.
start
()
<=
val
);
}
);
if
(
patchi
<
0
||
!
patches
[
patchi
].
range
().
found
(
faceIndex
))
{
// If not in any of above, it is trouble!
FatalErrorInFunction
<<
"Cannot find f
ace "
<<
faceIndex
<<
" in any of the patches "
<<
names
()
<<
nl
<<
"It seems your patches are not
consistent with the mesh :"
<<
"F
ace "
<<
faceIndex
<<
"
not found
in any of the patches "
<<
flatOutput
(
names
()
)
<<
nl
<<
"The patches appear to be in
consistent with the mesh :"
<<
" internalFaces:"
<<
mesh
().
nInternalFaces
()
<<
" total number of faces:"
<<
mesh
().
nFaces
()
<<
abort
(
FatalError
);
return
-
1
;
}
return
patchi
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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