Commit fc671971 authored by Franjo's avatar Franjo
Browse files

Functions to selected leaves inside a sphere

parent 5a78f0a1
......@@ -211,6 +211,25 @@ public:
DynList<const meshOctreeCube*, 256>&
) const;
//- find leaves within a sphere
void leavesInSphere
(
const boundBox& rootBox,
const point&,
const scalar,
DynList<label>&
) const;
//- mark leaves within a sphere
void markLeavesInSphere
(
const boundBox& rootBox,
const point&,
const scalar,
labelList&,
bool&
) const;
//- find leaves for a given cube
void findLeaves
(
......
......@@ -85,6 +85,102 @@ void meshOctreeCube::leavesInBox
}
}
void meshOctreeCube::leavesInSphere
(
const boundBox& rootBox,
const point& c,
const scalar r,
DynList<label>& containedLeaves
) const
{
const point cubeCentre = this->centre(rootBox);
const scalar size = 1.732 * this->size(rootBox);
if( magSqr(cubeCentre - c) < sqr(r+size) )
{
if( this->isLeaf() )
{
containedLeaves.append(this->cubeLabel());
}
else
{
for(label scI=0;scI<8;++scI)
{
meshOctreeCube* scPtr = subCubesPtr_[scI];
if( scPtr )
{
scPtr->leavesInSphere
(
rootBox,
c,
r,
containedLeaves
);
}
else if( Pstream::parRun() )
{
meshOctreeCubeCoordinates cc = refineForPosition(scI);
const point sc = cc.centre(rootBox);
if( magSqr(sc - c) < sqr(r+size) )
containedLeaves.append(meshOctreeCube::OTHERPROC);
}
}
}
}
}
void meshOctreeCube::markLeavesInSphere
(
const boundBox& rootBox,
const point& c,
const scalar r,
labelList& markedLeaves,
bool& atProcessorBnd
) const
{
const point cubeCentre = this->centre(rootBox);
const scalar size = 1.732 * this->size(rootBox);
if( magSqr(cubeCentre - c) < sqr(r+size) )
{
if( this->isLeaf() )
{
markedLeaves[this->cubeLabel()] |= 2;
}
else
{
for(label scI=0;scI<8;++scI)
{
meshOctreeCube* scPtr = subCubesPtr_[scI];
if( scPtr )
{
scPtr->markLeavesInSphere
(
rootBox,
c,
r,
markedLeaves,
atProcessorBnd
);
}
else if( Pstream::parRun() )
{
meshOctreeCubeCoordinates cc = refineForPosition(scI);
const point sc = cc.centre(rootBox);
if( magSqr(sc - c) < sqr(r+size) )
{
atProcessorBnd = true;
}
}
}
}
}
}
void meshOctreeCube::findLeaves(LongList<meshOctreeCube*>& leaves) const
{
if( this->isLeaf() )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment