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
d7e88028
Commit
d7e88028
authored
Nov 11, 2009
by
mattijs
Browse files
removed octreeDataFaceList; created generic PrimitivePatch search one
parent
dd746d4e
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
src/dynamicMesh/Make/files
View file @
d7e88028
...
...
@@ -49,7 +49,6 @@ perfectInterface/perfectInterface.C
boundaryMesh/boundaryMesh.C
boundaryPatch/boundaryPatch.C
boundaryMesh/octreeDataFaceList.C
setUpdater/setUpdater.C
meshModifiers = meshCut/meshModifiers
...
...
src/dynamicMesh/boundaryMesh/boundaryMesh.C
View file @
d7e88028
...
...
@@ -29,11 +29,12 @@ License
#include
"polyMesh.H"
#include
"repatchPolyTopoChanger.H"
#include
"faceList.H"
#include
"
o
ctree.H"
#include
"
oc
treeData
FaceList
.H"
#include
"
indexedO
ctree.H"
#include
"treeData
PrimitivePatch
.H"
#include
"triSurface.H"
#include
"SortableList.H"
#include
"OFstream.H"
#include
"uindirectPrimitivePatch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...
...
@@ -892,6 +893,17 @@ Foam::labelList Foam::boundaryMesh::getNearest
<<
endl
;
}
uindirectPrimitivePatch
leftPatch
(
UIndirectList
<
face
>
(
mesh
(),
leftFaces
),
mesh
().
points
()
);
uindirectPrimitivePatch
rightPatch
(
UIndirectList
<
face
>
(
mesh
(),
rightFaces
),
mesh
().
points
()
);
// Overall bb
treeBoundBox
overallBb
(
mesh
().
localPoints
());
...
...
@@ -911,29 +923,35 @@ Foam::labelList Foam::boundaryMesh::getNearest
bbMax
.
z
()
+=
2
*
tol
;
// Create the octrees
octree
<
octreeDataFaceList
>
leftTree
indexedOctree
<
treeDataPrimitivePatch
<
face
,
UIndirectList
,
const
pointField
&>
>
leftTree
(
overallBb
,
octreeDataFaceList
treeDataPrimitivePatch
<
face
,
UIndirectList
,
const
pointField
&>
(
mesh
(),
left
Faces
false
,
// cacheBb
left
Patch
),
1
,
20
,
10
overallBb
,
10
,
// maxLevel
10
,
// leafSize
3
.
0
// duplicity
);
octree
<
octreeDataFaceList
>
rightTree
indexedOctree
<
treeDataPrimitivePatch
<
face
,
UIndirectList
,
const
pointField
&>
>
rightTree
(
overallBb
,
octreeDataFaceList
treeDataPrimitivePatch
<
face
,
UIndirectList
,
const
pointField
&>
(
mesh
(),
right
Faces
false
,
// cacheBb
right
Patch
),
1
,
20
,
10
overallBb
,
10
,
// maxLevel
10
,
// leafSize
3
.
0
// duplicity
);
if
(
debug
)
...
...
@@ -953,7 +971,7 @@ Foam::labelList Foam::boundaryMesh::getNearest
treeBoundBox
tightest
;
const
scalar
searchDim
=
mag
(
searchSpan
);
const
scalar
searchDim
Sqr
=
mag
Sqr
(
searchSpan
);
forAll
(
nearestBFaceI
,
patchFaceI
)
{
...
...
@@ -982,50 +1000,25 @@ Foam::labelList Foam::boundaryMesh::getNearest
}
// Search right tree
tightest
.
min
()
=
ctr
-
searchSpan
;
tightest
.
max
()
=
ctr
+
searchSpan
;
scalar
rightDist
=
searchDim
;
label
rightI
=
rightTree
.
findNearest
(
ctr
,
tightest
,
rightDist
);
pointIndexHit
rightInfo
=
rightTree
.
findNearest
(
ctr
,
searchDimSqr
);
// Search left tree. Note: could start from rightDist bounding box
// instead of starting from top.
tightest
.
min
()
=
ctr
-
searchSpan
;
tightest
.
max
()
=
ctr
+
searchSpan
;
scalar
leftDist
=
searchDim
;
label
leftI
=
leftTree
.
findNearest
(
ctr
,
tightest
,
leftDist
);
pointIndexHit
leftInfo
=
leftTree
.
findNearest
(
ctr
,
searchDimSqr
);
if
(
rightI
==
-
1
)
{
// No face found in right tree.
if
(
leftI
==
-
1
)
{
// No face found in left tree.
nearestBFaceI
[
patchFaceI
]
=
-
1
;
}
else
{
// Found in left but not in right. Choose left regardless if
// correct sign. Note: do we want this?
nearestBFaceI
[
patchFaceI
]
=
leftFaces
[
leftI
];
}
}
else
if
(
rightInfo
.
hit
())
{
if
(
leftI
==
-
1
)
{
// Found in right but not in left. Choose right regardless if
// correct sign. Note: do we want this?
nearestBFaceI
[
patchFaceI
]
=
rightFaces
[
rightI
];
}
else
if
(
leftInfo
.
hit
())
{
// Found in both trees. Compare normals.
label
rightFaceI
=
rightFaces
[
rightInfo
.
index
()];
label
leftFaceI
=
leftFaces
[
leftInfo
.
index
()];
label
rightDist
=
mag
(
rightInfo
.
hitPoint
()
-
ctr
);
label
leftDist
=
mag
(
leftInfo
.
hitPoint
()
-
ctr
);
scalar
rightSign
=
n
&
ns
[
rightFace
s
[
rightI
]
];
scalar
leftSign
=
n
&
ns
[
leftFace
s
[
leftI
]
];
scalar
rightSign
=
n
&
ns
[
rightFace
I
];
scalar
leftSign
=
n
&
ns
[
leftFace
I
];
if
(
...
...
@@ -1036,11 +1029,11 @@ Foam::labelList Foam::boundaryMesh::getNearest
// Both same sign. Choose nearest.
if
(
rightDist
<
leftDist
)
{
nearestBFaceI
[
patchFaceI
]
=
rightFace
s
[
rightI
]
;
nearestBFaceI
[
patchFaceI
]
=
rightFace
I
;
}
else
{
nearestBFaceI
[
patchFaceI
]
=
leftFace
s
[
leftI
]
;
nearestBFaceI
[
patchFaceI
]
=
leftFace
I
;
}
}
else
...
...
@@ -1059,11 +1052,11 @@ Foam::labelList Foam::boundaryMesh::getNearest
// Different sign and nearby. Choosing matching normal
if
(
rightSign
>
0
)
{
nearestBFaceI
[
patchFaceI
]
=
rightFace
s
[
rightI
]
;
nearestBFaceI
[
patchFaceI
]
=
rightFace
I
;
}
else
{
nearestBFaceI
[
patchFaceI
]
=
leftFace
s
[
leftI
]
;
nearestBFaceI
[
patchFaceI
]
=
leftFace
I
;
}
}
else
...
...
@@ -1071,15 +1064,38 @@ Foam::labelList Foam::boundaryMesh::getNearest
// Different sign but faraway. Choosing nearest.
if
(
rightDist
<
leftDist
)
{
nearestBFaceI
[
patchFaceI
]
=
rightFace
s
[
rightI
]
;
nearestBFaceI
[
patchFaceI
]
=
rightFace
I
;
}
else
{
nearestBFaceI
[
patchFaceI
]
=
leftFace
s
[
leftI
]
;
nearestBFaceI
[
patchFaceI
]
=
leftFace
I
;
}
}
}
}
else
{
// Found in right but not in left. Choose right regardless if
// correct sign. Note: do we want this?
label
rightFaceI
=
rightFaces
[
rightInfo
.
index
()];
nearestBFaceI
[
patchFaceI
]
=
rightFaceI
;
}
}
else
{
// No face found in right tree.
if
(
leftInfo
.
hit
())
{
// Found in left but not in right. Choose left regardless if
// correct sign. Note: do we want this?
nearestBFaceI
[
patchFaceI
]
=
leftFaces
[
leftInfo
.
index
()];
}
else
{
// No face found in left tree.
nearestBFaceI
[
patchFaceI
]
=
-
1
;
}
}
}
...
...
src/meshTools/Make/files
View file @
d7e88028
...
...
@@ -50,6 +50,7 @@ indexedOctree/treeDataCell.C
indexedOctree/treeDataEdge.C
indexedOctree/treeDataFace.C
indexedOctree/treeDataPoint.C
indexedOctree/treeDataPrimitivePatchName.C
indexedOctree/treeDataTriSurface.C
searchableSurface = searchableSurface
...
...
src/
dynamicMesh/boundaryMesh/octreeDataFaceList
.C
→
src/
meshTools/indexedOctree/treeDataPrimitivePatch
.C
View file @
d7e88028
This diff is collapsed.
Click to expand it.
src/
dynamicMesh/boundaryMesh/octreeDataFaceList
.H
→
src/
meshTools/indexedOctree/treeDataPrimitivePatch
.H
View file @
d7e88028
...
...
@@ -23,26 +23,22 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::
oc
treeData
FaceList
Foam::treeData
PrimitivePatch
Description
Holds data for octree to work on list of faces on a bMesh
(= PrimitivePatch which holds faces, not references them)
Same as octreeDataFace except for that.
Encapsulation of data needed to search on PrimitivePatches
SourceFiles
oc
treeData
FaceList
.C
treeData
PrimitivePatch
.C
\*---------------------------------------------------------------------------*/
#ifndef
oc
treeData
FaceList
_H
#define
oc
treeData
FaceList
_H
#ifndef treeData
PrimitivePatch
_H
#define treeData
PrimitivePatch
_H
#include
"PrimitivePatch.H"
//#include "indexedOctree.H"
#include
"treeBoundBoxList.H"
#include
"faceList.H"
#include
"point.H"
#include
"className.H"
#include
"bMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
@@ -50,97 +46,98 @@ namespace Foam
{
// Forward declaration of classes
template
<
class
Type
>
class
octree
;
template
<
class
Type
>
class
indexedOctree
;
/*---------------------------------------------------------------------------*\
Class
oc
treeData
FaceList
Declaration
Class treeData
PrimitivePatchName
Declaration
\*---------------------------------------------------------------------------*/
class
octreeDataFaceList
{
// Static data
TemplateName
(
treeDataPrimitivePatch
);
//- tolerance on linear dimensions
static
scalar
tol
;
/*---------------------------------------------------------------------------*\
Class treeDataPrimitivePatch Declaration
\*---------------------------------------------------------------------------*/
// Static function
static
inline
label
nexti
(
label
max
,
label
i
)
{
return
(
i
+
1
)
%
max
;
}
template
<
class
Face
,
template
<
class
>
class
FaceList
,
class
PointField
,
class
PointType
=
point
>
class
treeDataPrimitivePatch
:
public
treeDataPrimitivePatchName
{
// Static data
//- tolerance on linear dimensions
static
scalar
tolSqr
;
// Private data
//-
the mesh
const
bMesh
&
mes
h_
;
//-
Underlying geometry
const
PrimitivePatch
<
Face
,
FaceList
,
PointField
,
PointType
>&
patc
h_
;
//-
labels (in mesh indexing) of faces
labelList
faceLabels
_
;
//-
Whether to precalculate and store face bounding box
const
bool
cacheBb
_
;
//-
bbs for all above faces
treeBoundBoxList
allBb
_
;
//-
face bounding boxes (valid only if cacheBb_)
treeBoundBoxList
bbs
_
;
// Private Member Functions
//-
Set allBb to tight fitting
bounding box
void
calcBb
(
);
//-
Calculate face
bounding box
static
treeBoundBox
calcBb
(
const
pointField
&
,
const
face
&
);
public:
//- Initialise all member data
void
update
();
// Declare name of the class and its debug switch
ClassName
(
"octreeDataFaceList"
);
public:
// Constructors
//- Construct from all faces in bMesh.
octreeDataFaceList
(
const
bMesh
&
mesh
);
//- Construct from selected faces in bMesh.
octreeDataFaceList
(
const
bMesh
&
mesh
,
const
labelList
&
faceLabels
);
//- Construct as copy
octreeDataFaceList
(
const
octreeDataFaceList
&
);
// Destructor
~
octreeDataFaceList
();
//- Construct from patch.
treeDataPrimitivePatch
(
const
bool
cacheBb
,
const
PrimitivePatch
<
Face
,
FaceList
,
PointField
,
PointType
>&
);
// Member Functions
// Access
const
bMesh
&
mesh
()
const
{
return
mesh_
;
}
const
labelList
&
faceLabels
()
const
label
size
()
const
{
return
faceLabels_
;
return
patch_
.
size
()
;
}
const
treeBoundBoxList
&
allBb
()
const
{
return
allBb_
;
}
//- Get representative point cloud for all shapes inside
// (one point per shape)
pointField
points
()
const
;
label
size
()
const
{
return
allBb_
.
size
();
}
// Search
//- Get type of sample
label
getSampleType
//- Get type (inside,outside,mixed,unknown) of point w.r.t. surface.
// Only makes sense for closed surfaces.
label
getVolumeType
(
const
octree
<
octreeDataFaceList
>&
,
const
indexedOctree
<
treeDataPrimitivePatch
<
Face
,
FaceList
,
PointField
,
PointType
>
>&
,
const
point
&
)
const
;
...
...
@@ -151,60 +148,48 @@ public:
const
treeBoundBox
&
sampleBb
)
const
;
//- Does shape at index contain sample
bool
contains
(
const
label
index
,
const
point
&
sample
)
const
;
//- Segment (from start to end) intersection with shape
// at index. If intersects returns true and sets intersectionPoint
bool
intersects
(
const
label
index
,
const
point
&
start
,
const
point
&
end
,
point
&
intersectionPoint
)
const
;
//- Sets newTightest to bounding box (and returns true) if
// nearer to sample than tightest bounding box. Otherwise
// returns false.
bool
findTightest
//- Calculates nearest (to sample) point in shape.
// Returns actual point and distance (squared)
void
findNearest
(
const
label
index
,
const
label
List
&
indices
,
const
point
&
sample
,
treeBoundBox
&
tightest
scalar
&
nearestDistSqr
,
label
&
nearestIndex
,
point
&
nearestPoint
)
const
;
//- Given index get unit normal and calculate (numerical) sign
// of sample.
// Used to determine accuracy of calcNearest or inside/outside.
scalar
calcSign
//- Calculates nearest (to line) point in shape.
// Returns point and distance (squared)
void
findNearest
(
const
label
index
,
const
point
&
sample
,
vector
&
n
)
const
;
const
labelList
&
indices
,
const
linePointRef
&
ln
,
treeBoundBox
&
tightest
,
label
&
minIndex
,
point
&
linePoint
,
point
&
nearestPoint
)
const
{
notImplemented
(
"treeDataPrimitivePatch::findNearest"
"(const labelList&, const linePointRef&, ..)"
);
}
//- Calculates nearest (to sample) point in shape.
// Returns point and mag(nearest - sample). Returns GREAT if
// sample does not project onto (triangle decomposition) of face.
scalar
calcNearest
//- Calculate intersection of shape with ray. Sets result
// accordingly
bool
intersects
(
const
label
index
,
const
point
&
sample
,
point
&
nearest
const
point
&
start
,
const
point
&
end
,
point
&
result
)
const
;
// Edit
// Write
//- Write shape at index
void
write
(
Ostream
&
os
,
const
label
index
)
const
;
};
...
...
@@ -214,6 +199,11 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "treeDataPrimitivePatch.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
...
...
src/meshTools/indexedOctree/treeDataPrimitivePatchName.C
0 → 100644
View file @
d7e88028
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include
"treeDataPrimitivePatch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug
(
Foam
::
treeDataPrimitivePatchName
,
0
);
// ************************************************************************* //
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