Skip to content
GitLab
Menu
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
1f160083
Commit
1f160083
authored
Feb 24, 2011
by
andy
Browse files
ENH: moved findCellFacePt and findTetFacePt methods from Cloud to polyMesh
parent
ff98dac1
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/meshes/polyMesh/polyMesh.C
View file @
1f160083
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-201
0
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-201
1
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -1183,10 +1183,123 @@ void Foam::polyMesh::removeFiles(const fileName& instanceDir) const
}
}
void
Foam
::
polyMesh
::
removeFiles
()
const
{
removeFiles
(
instance
());
}
void
Foam
::
polyMesh
::
findCellFacePt
(
const
point
&
pt
,
label
&
cellI
,
label
&
tetFaceI
,
label
&
tetPtI
)
const
{
cellI
=
-
1
;
tetFaceI
=
-
1
;
tetPtI
=
-
1
;
const
indexedOctree
<
treeDataCell
>&
tree
=
cellTree
();
// Find nearest cell to the point
pointIndexHit
info
=
tree
.
findNearest
(
pt
,
sqr
(
GREAT
));
if
(
info
.
hit
())
{
label
nearestCellI
=
tree
.
shapes
().
cellLabels
()[
info
.
index
()];
// Check the nearest cell to see if the point is inside.
findTetFacePt
(
nearestCellI
,
pt
,
tetFaceI
,
tetPtI
);
if
(
tetFaceI
!=
-
1
)
{
// Point was in the nearest cell
cellI
=
nearestCellI
;
return
;
}
else
{
// Check the other possible cells that the point may be in
labelList
testCells
=
tree
.
findIndices
(
pt
);
forAll
(
testCells
,
pCI
)
{
label
testCellI
=
tree
.
shapes
().
cellLabels
()[
testCells
[
pCI
]];
if
(
testCellI
==
nearestCellI
)
{
// Don't retest the nearest cell
continue
;
}
// Check the test cell to see if the point is inside.
findTetFacePt
(
testCellI
,
pt
,
tetFaceI
,
tetPtI
);
if
(
tetFaceI
!=
-
1
)
{
// Point was in the test cell
cellI
=
testCellI
;
return
;
}
}
}
}
else
{
FatalErrorIn
(
"void Foam::polyMesh::findCellFacePt"
"("
"const point&, "
"label&, "
"label&, "
"label&"
") const"
)
<<
"Did not find nearest cell in search tree."
<<
abort
(
FatalError
);
}
}
void
Foam
::
polyMesh
::
findTetFacePt
(
const
label
cellI
,
const
point
&
pt
,
label
&
tetFaceI
,
label
&
tetPtI
)
const
{
const
polyMesh
&
mesh
=
*
this
;
tetFaceI
=
-
1
;
tetPtI
=
-
1
;
List
<
tetIndices
>
cellTets
=
polyMeshTetDecomposition
::
cellTetIndices
(
mesh
,
cellI
);
forAll
(
cellTets
,
tetI
)
{
const
tetIndices
&
cellTetIs
=
cellTets
[
tetI
];
if
(
cellTetIs
.
tet
(
mesh
).
inside
(
pt
))
{
tetFaceI
=
cellTetIs
.
face
();
tetPtI
=
cellTetIs
.
tetPt
();
return
;
}
}
}
// ************************************************************************* //
src/OpenFOAM/meshes/polyMesh/polyMesh.H
View file @
1f160083
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-201
0
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-201
1
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -34,6 +34,7 @@ SourceFiles
polyMeshFromShapeMesh.C
polyMeshIO.C
polyMeshUpdate.C
polyMeshFindCell.C
\*---------------------------------------------------------------------------*/
...
...
@@ -391,6 +392,7 @@ public:
return
*
this
;
}
// Mesh motion
//- Is mesh moving
...
...
@@ -508,6 +510,28 @@ public:
//- Remove all files from mesh instance()
void
removeFiles
()
const
;
// Helper functions
//- Find the cell, tetFaceI and tetPtI for the given position
void
findCellFacePt
(
const
point
&
pt
,
label
&
cellI
,
label
&
tetFaceI
,
label
&
tetPtI
)
const
;
//- Find the tetFaceI and tetPtI for the given position in
// the supplied cell, tetFaceI and tetPtI = -1 if not found
void
findTetFacePt
(
const
label
cellI
,
const
point
&
pt
,
label
&
tetFaceI
,
label
&
tetPtI
)
const
;
};
...
...
Write
Preview
Supports
Markdown
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