mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: moved findCellFacePt and findTetFacePt methods from Cloud to polyMesh
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -1183,10 +1183,123 @@ void Foam::polyMesh::removeFiles(const fileName& instanceDir) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::polyMesh::removeFiles() const
|
void Foam::polyMesh::removeFiles() const
|
||||||
{
|
{
|
||||||
removeFiles(instance());
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -34,6 +34,7 @@ SourceFiles
|
|||||||
polyMeshFromShapeMesh.C
|
polyMeshFromShapeMesh.C
|
||||||
polyMeshIO.C
|
polyMeshIO.C
|
||||||
polyMeshUpdate.C
|
polyMeshUpdate.C
|
||||||
|
polyMeshFindCell.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -391,6 +392,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Mesh motion
|
// Mesh motion
|
||||||
|
|
||||||
//- Is mesh moving
|
//- Is mesh moving
|
||||||
@ -508,6 +510,28 @@ public:
|
|||||||
|
|
||||||
//- Remove all files from mesh instance()
|
//- Remove all files from mesh instance()
|
||||||
void removeFiles() const;
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user