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
0d1d3014
Commit
0d1d3014
authored
Sep 09, 2008
by
mattijs
Browse files
indexing fixes
parent
40d72633
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/meshTools/meshSearch/meshSearch.C
View file @
0d1d3014
...
...
@@ -86,7 +86,7 @@ bool Foam::meshSearch::findNearer
if
(
distSqr
<
nearestDistSqr
)
{
nearestDistSqr
=
distSqr
;
nearestI
=
i
;
nearestI
=
pointI
;
nearer
=
true
;
}
}
...
...
@@ -117,18 +117,18 @@ Foam::label Foam::meshSearch::findNearestCellLinear(const point& location) const
{
const
vectorField
&
centres
=
mesh_
.
cellCentres
();
label
nearest
Celli
=
0
;
scalar
minProximity
=
magSqr
(
centres
[
nearest
Celli
]
-
location
);
label
nearest
Index
=
0
;
scalar
minProximity
=
magSqr
(
centres
[
nearest
Index
]
-
location
);
findNearer
(
location
,
centres
,
nearest
Celli
,
nearest
Index
,
minProximity
);
return
nearest
Celli
;
return
nearest
Index
;
}
...
...
@@ -147,30 +147,27 @@ Foam::label Foam::meshSearch::findNearestCellWalk
)
<<
"illegal seedCell:"
<<
seedCellI
<<
exit
(
FatalError
);
}
const
vectorField
&
centres
=
mesh_
.
cellCentres
();
const
labelListList
&
cc
=
mesh_
.
cellCells
();
// Walk in direction of face that decreases distance
label
curCell
=
seedCellI
;
scalar
distanceSqr
=
magSqr
(
c
entres
[
curCell
]
-
location
);
label
curCell
I
=
seedCellI
;
scalar
distanceSqr
=
magSqr
(
mesh_
.
cellC
entres
()
[
curCell
I
]
-
location
);
bool
closer
;
do
{
// Try neighbours of curCellI
closer
=
findNearer
(
location
,
c
entres
,
cc
[
curCell
],
curCell
,
mesh_
.
cellC
entres
()
,
mesh_
.
cellCells
()
[
curCell
I
],
curCell
I
,
distanceSqr
);
}
while
(
closer
);
return
curCell
;
return
curCell
I
;
}
...
...
@@ -195,6 +192,7 @@ Foam::label Foam::meshSearch::findNearestFaceTree(const point& location) const
// Now check any of the faces of the nearest cell
const
vectorField
&
centres
=
mesh_
.
faceCentres
();
const
cell
&
ownFaces
=
mesh_
.
cells
()[
info
.
index
()];
label
nearestFaceI
=
ownFaces
[
0
];
scalar
minProximity
=
magSqr
(
centres
[
nearestFaceI
]
-
location
);
...
...
@@ -251,43 +249,43 @@ Foam::label Foam::meshSearch::findNearestFaceWalk
// Walk in direction of face that decreases distance
label
curFace
=
seedFaceI
;
scalar
distanceSqr
=
magSqr
(
centres
[
curFace
]
-
location
);
label
curFace
I
=
seedFaceI
;
scalar
distanceSqr
=
magSqr
(
centres
[
curFace
I
]
-
location
);
while
(
true
)
{
label
betterFace
=
curFace
;
label
betterFace
I
=
curFace
I
;
findNearer
(
location
,
centres
,
mesh_
.
cells
()[
mesh_
.
faceOwner
()[
curFace
]],
betterFace
,
mesh_
.
cells
()[
mesh_
.
faceOwner
()[
curFace
I
]],
betterFace
I
,
distanceSqr
);
if
(
mesh_
.
isInternalFace
(
curFace
))
if
(
mesh_
.
isInternalFace
(
curFace
I
))
{
findNearer
(
location
,
centres
,
mesh_
.
cells
()[
mesh_
.
faceNeighbour
()[
curFace
]],
betterFace
,
mesh_
.
cells
()[
mesh_
.
faceNeighbour
()[
curFace
I
]],
betterFace
I
,
distanceSqr
);
}
if
(
betterFace
==
curFace
)
if
(
betterFace
I
==
curFace
I
)
{
break
;
}
curFace
=
betterFace
;
curFace
I
=
betterFace
I
;
}
return
curFace
;
return
curFace
I
;
}
...
...
@@ -463,18 +461,20 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree()
treeBoundBox
overallBb
(
mesh_
.
points
());
Random
rndGen
(
123456
);
boundaryTreePtr_
=
new
indexedOctree
<
treeDataFace
>
(
treeDataFace
// all information needed to search faces
(
false
,
// do not cache bb
false
,
// do not cache bb
mesh_
,
bndFaces
// boundary faces only
bndFaces
// boundary faces only
),
overallBb
,
// overall search domain
8
,
// maxLevel
10
,
// leafsize
3
.
0
// duplicity
overallBb
.
extend
(
rndGen
,
1E-3
),
// overall search domain
8
,
// maxLevel
10
,
// leafsize
3
.
0
// duplicity
);
}
...
...
src/meshTools/meshSearch/meshSearch.H
View file @
0d1d3014
...
...
@@ -215,8 +215,8 @@ public:
label
findNearestFace
(
const
point
&
location
,
const
label
seedFaceI
,
const
bool
useTreeSearch
const
label
seedFaceI
=
-
1
,
const
bool
useTreeSearch
=
true
)
const
;
//- Find cell containing (using pointInCell) location.
...
...
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