mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
sampledSet: Further improvements in robustness for midPoint and midPointAndFace
This commit is contained in:
@ -56,7 +56,6 @@ bool Foam::faceOnlySet::trackToBoundary
|
|||||||
{
|
{
|
||||||
particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
|
particle::TrackingData<passiveParticleCloud> trackData(particleCloud);
|
||||||
|
|
||||||
// Alias
|
|
||||||
const point& trackPt = singleParticle.position();
|
const point& trackPt = singleParticle.position();
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
@ -76,12 +75,12 @@ bool Foam::faceOnlySet::trackToBoundary
|
|||||||
|
|
||||||
if (mag(trackPt - end_) < smallDist)
|
if (mag(trackPt - end_) < smallDist)
|
||||||
{
|
{
|
||||||
// end reached
|
// End reached
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (singleParticle.onBoundary())
|
else if (singleParticle.onBoundary())
|
||||||
{
|
{
|
||||||
// Boundary reached.
|
// Boundary reached
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,31 +47,49 @@ Foam::label Foam::sampledSet::getBoundaryCell(const label faceI) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::sampledSet::getNeighbourCell(const label faceI) const
|
||||||
|
{
|
||||||
|
if (faceI >= mesh().nInternalFaces())
|
||||||
|
{
|
||||||
|
return mesh().faceOwner()[faceI];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return mesh().faceNeighbour()[faceI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::sampledSet::pointInCell
|
Foam::label Foam::sampledSet::pointInCell
|
||||||
(
|
(
|
||||||
const point& p,
|
const point& p,
|
||||||
const label samplei
|
const label samplei
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const label cellio = mesh().faceOwner()[faces_[samplei]];
|
// Collect the face owner and neighbour cells of the sample into an array
|
||||||
const label cellin = mesh().faceNeighbour()[faces_[samplei]];
|
// for convenience
|
||||||
const label celljo = mesh().faceOwner()[faces_[samplei+1]];
|
label cells[4] =
|
||||||
const label celljn = mesh().faceNeighbour()[faces_[samplei+1]];
|
{
|
||||||
|
mesh().faceOwner()[faces_[samplei]],
|
||||||
// If mid-point is in the cell including the sampled faces
|
getNeighbourCell(faces_[samplei]),
|
||||||
// include in list otherwise ignore
|
mesh().faceOwner()[faces_[samplei+1]],
|
||||||
|
getNeighbourCell(faces_[samplei+1])
|
||||||
|
};
|
||||||
|
|
||||||
|
// Find the sampled cell by checking the owners and neighbours of the
|
||||||
|
// sampled faces
|
||||||
label cellm =
|
label cellm =
|
||||||
(cellio == celljo || cellio == celljn) ? cellio
|
(cells[0] == cells[2] || cells[0] == cells[3]) ? cells[0]
|
||||||
: (cellin == celljo || cellin == celljn) ? cellin
|
: (cells[1] == cells[2] || cells[1] == cells[3]) ? cells[1]
|
||||||
: -1;
|
: -1;
|
||||||
|
|
||||||
if (cellm != -1)
|
if (cellm != -1)
|
||||||
{
|
{
|
||||||
// Check the mid-point is in the cell otherwise ignore
|
// If found the sampled cell check the point is in the cell
|
||||||
|
// otherwise ignore
|
||||||
if (!mesh().pointInCell(p, cellm, searchEngine_.decompMode()))
|
if (!mesh().pointInCell(p, cellm, searchEngine_.decompMode()))
|
||||||
{
|
{
|
||||||
cellm = -1;
|
cellm = -1;
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -81,20 +99,33 @@ Foam::label Foam::sampledSet::pointInCell
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (debug)
|
else
|
||||||
{
|
{
|
||||||
WarningInFunction
|
// If the sample does not pass through a single cell check if the point
|
||||||
<< "Could not find cell for mid-point" << nl
|
// is in any of the owners or neighbours otherwise ignore
|
||||||
<< " samplei: " << samplei
|
for (label i=0; i<4; i++)
|
||||||
<< " pts[samplei]: " << operator[](samplei)
|
{
|
||||||
<< " face[samplei]: " << faces_[samplei]
|
if (mesh().pointInCell(p, cells[i], searchEngine_.decompMode()))
|
||||||
<< " pts[samplei+1]: " << operator[](samplei+1)
|
{
|
||||||
<< " face[samplei+1]: " << faces_[samplei+1]
|
return cells[i];
|
||||||
<< " cellio: " << cellio
|
}
|
||||||
<< " cellin: " << cellin
|
}
|
||||||
<< " celljo: " << celljo
|
|
||||||
<< " celljn: " << celljn
|
if (debug)
|
||||||
<< endl;
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Could not find cell for mid-point" << nl
|
||||||
|
<< " samplei: " << samplei
|
||||||
|
<< " pts[samplei]: " << operator[](samplei)
|
||||||
|
<< " face[samplei]: " << faces_[samplei]
|
||||||
|
<< " pts[samplei+1]: " << operator[](samplei+1)
|
||||||
|
<< " face[samplei+1]: " << faces_[samplei+1]
|
||||||
|
<< " cellio: " << cells[0]
|
||||||
|
<< " cellin: " << cells[1]
|
||||||
|
<< " celljo: " << cells[2]
|
||||||
|
<< " celljn: " << cells[3]
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cellm;
|
return cellm;
|
||||||
|
|||||||
@ -92,6 +92,9 @@ protected:
|
|||||||
//- Returns cell next to boundary face
|
//- Returns cell next to boundary face
|
||||||
label getBoundaryCell(const label) const;
|
label getBoundaryCell(const label) const;
|
||||||
|
|
||||||
|
//- Returns the neigbour cell or the owner if face in on the boundary
|
||||||
|
label getNeighbourCell(const label) const;
|
||||||
|
|
||||||
//- Return the cell in which the point on the sample line
|
//- Return the cell in which the point on the sample line
|
||||||
// resides if found otherwise return -1
|
// resides if found otherwise return -1
|
||||||
label pointInCell(const point& p, const label samplei) const;
|
label pointInCell(const point& p, const label samplei) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user