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);
|
||||
|
||||
// Alias
|
||||
const point& trackPt = singleParticle.position();
|
||||
|
||||
while(true)
|
||||
@ -76,12 +75,12 @@ bool Foam::faceOnlySet::trackToBoundary
|
||||
|
||||
if (mag(trackPt - end_) < smallDist)
|
||||
{
|
||||
// end reached
|
||||
// End reached
|
||||
return false;
|
||||
}
|
||||
else if (singleParticle.onBoundary())
|
||||
{
|
||||
// Boundary reached.
|
||||
// Boundary reached
|
||||
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
|
||||
(
|
||||
const point& p,
|
||||
const label samplei
|
||||
) const
|
||||
{
|
||||
const label cellio = mesh().faceOwner()[faces_[samplei]];
|
||||
const label cellin = mesh().faceNeighbour()[faces_[samplei]];
|
||||
const label celljo = mesh().faceOwner()[faces_[samplei+1]];
|
||||
const label celljn = mesh().faceNeighbour()[faces_[samplei+1]];
|
||||
|
||||
// If mid-point is in the cell including the sampled faces
|
||||
// include in list otherwise ignore
|
||||
// Collect the face owner and neighbour cells of the sample into an array
|
||||
// for convenience
|
||||
label cells[4] =
|
||||
{
|
||||
mesh().faceOwner()[faces_[samplei]],
|
||||
getNeighbourCell(faces_[samplei]),
|
||||
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 =
|
||||
(cellio == celljo || cellio == celljn) ? cellio
|
||||
: (cellin == celljo || cellin == celljn) ? cellin
|
||||
(cells[0] == cells[2] || cells[0] == cells[3]) ? cells[0]
|
||||
: (cells[1] == cells[2] || cells[1] == cells[3]) ? cells[1]
|
||||
: -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()))
|
||||
{
|
||||
cellm = -1;
|
||||
cellm = -1;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
@ -81,20 +99,33 @@ Foam::label Foam::sampledSet::pointInCell
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (debug)
|
||||
else
|
||||
{
|
||||
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: " << cellio
|
||||
<< " cellin: " << cellin
|
||||
<< " celljo: " << celljo
|
||||
<< " celljn: " << celljn
|
||||
<< endl;
|
||||
// If the sample does not pass through a single cell check if the point
|
||||
// is in any of the owners or neighbours otherwise ignore
|
||||
for (label i=0; i<4; i++)
|
||||
{
|
||||
if (mesh().pointInCell(p, cells[i], searchEngine_.decompMode()))
|
||||
{
|
||||
return cells[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
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;
|
||||
|
||||
@ -92,6 +92,9 @@ protected:
|
||||
//- Returns cell next to boundary face
|
||||
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
|
||||
// resides if found otherwise return -1
|
||||
label pointInCell(const point& p, const label samplei) const;
|
||||
|
||||
Reference in New Issue
Block a user