Skip to content
Snippets Groups Projects
Commit 4faec129 authored by graham's avatar graham
Browse files

ENH: InteractionLists. Adding directWallFaces for real face

interactions and uncommenting/modifying collision with these faces in
PairCollision.  No collisions will occur with referred faces.

STYLE: InteractionLists. Using mesh_ reference once initialised for
the rest of the constructor.
parent 0a4a3664
Branches
Tags
No related merge requests found
......@@ -398,6 +398,7 @@ Foam::InteractionLists<ParticleType>::InteractionLists
globalTransforms_(mesh_),
maxDistance_(maxDistance),
dil_(),
directWallFaces_(),
ril_(),
rilInverse_(),
cellIndexAndTransformToDistribute_(),
......@@ -409,7 +410,7 @@ Foam::InteractionLists<ParticleType>::InteractionLists
const vector interactionVec = maxDistance_*vector::one;
treeBoundBox procBb(treeBoundBox(mesh.points()));
treeBoundBox procBb(treeBoundBox(mesh_.points()));
treeBoundBox extendedProcBb
(
......@@ -439,16 +440,16 @@ Foam::InteractionLists<ParticleType>::InteractionLists
extendedProcBbsOrigProc
);
treeBoundBoxList cellBbs(mesh.nCells());
treeBoundBoxList cellBbs(mesh_.nCells());
forAll(cellBbs, cellI)
{
cellBbs[cellI] = treeBoundBox
(
mesh.cells()[cellI].points
mesh_.cells()[cellI].points
(
mesh.faces(),
mesh.points()
mesh_.faces(),
mesh_.points()
)
);
}
......@@ -456,7 +457,7 @@ Foam::InteractionLists<ParticleType>::InteractionLists
// Recording which cells are in range of an extended boundBox, as
// only these cells will need to be tested to determine which
// referred cells that they interact with.
PackedBoolList cellInRangeOfCoupledPatch(mesh.nCells(), false);
PackedBoolList cellInRangeOfCoupledPatch(mesh_.nCells(), false);
// IAndT: index and transform
DynamicList<labelPair> globalIAndTToExchange;
......@@ -518,11 +519,14 @@ Foam::InteractionLists<ParticleType>::InteractionLists
}
}
treeBoundBox procBbRndExt(treeBoundBox(mesh.points()).extend(rndGen, 1e-4));
treeBoundBox procBbRndExt
(
treeBoundBox(mesh_.points()).extend(rndGen, 1e-4)
);
indexedOctree<treeDataCell> coupledPatchRangeTree
(
treeDataCell(true, mesh, coupledPatchRangeCells),
treeDataCell(true, mesh_, coupledPatchRangeCells),
procBbRndExt,
8, // maxLevel,
10, // leafSize,
......@@ -632,7 +636,7 @@ Foam::InteractionLists<ParticleType>::InteractionLists
// Determine inverse addressing for referred cells
rilInverse_.setSize(mesh.nCells());
rilInverse_.setSize(mesh_.nCells());
// Temporary Dynamic lists for accumulation
List<DynamicList<label> > rilInverseTemp(rilInverse_.size());
......@@ -663,14 +667,14 @@ Foam::InteractionLists<ParticleType>::InteractionLists
indexedOctree<treeDataCell> allCellsTree
(
treeDataCell(true, mesh),
treeDataCell(true, mesh_),
procBbRndExt,
8, // maxLevel,
10, // leafSize,
100.0
);
dil_.setSize(mesh.nCells());
dil_.setSize(mesh_.nCells());
forAll(cellBbs, cellI)
{
......@@ -711,6 +715,95 @@ Foam::InteractionLists<ParticleType>::InteractionLists
dil_[cellI].transfer(cellDIL);
}
// Direct wall faces
// DynamicLists for data gathering
DynamicList<label> thisCellOnlyWallFaces;
DynamicList<label> otherCellOnlyWallFaces;
List<DynamicList<label> > wallFacesTemp(mesh_.nCells());
const labelList& patchID = mesh_.boundaryMesh().patchID();
label nInternalFaces = mesh_.nInternalFaces();
forAll(wallFacesTemp, thisCellI)
{
// Find all of the wall faces for the current cell
const labelList& thisCellFaces = mesh_.cells()[thisCellI];
DynamicList<label>& thisCellWallFaces = wallFacesTemp[thisCellI];
thisCellOnlyWallFaces.clear();
forAll(thisCellFaces, tCFI)
{
label faceI = thisCellFaces[tCFI];
if (!mesh_.isInternalFace(faceI))
{
label patchI = patchID[faceI - nInternalFaces];
const polyPatch& patch = mesh_.boundaryMesh()[patchI];
if (isA<wallPolyPatch>(patch))
{
thisCellOnlyWallFaces.append(faceI);
}
}
}
// Add all the found wall faces to this cell's list, and
// retain the wall faces for this cell only to add to other
// cells.
thisCellWallFaces.append(thisCellOnlyWallFaces);
// Loop over all of the cells in the dil for this cell, adding
// the wallFaces for this cell to the other cell's wallFace
// list, and all of the wallFaces for the other cell to this
// cell's list
const labelList& cellDil = dil_[thisCellI];
forAll(cellDil, i)
{
label otherCellI = cellDil[i];
const labelList& otherCellFaces = mesh_.cells()[otherCellI];
DynamicList<label>& otherCellWallFaces = wallFacesTemp[otherCellI];
otherCellOnlyWallFaces.clear();
forAll(otherCellFaces, oCFI)
{
label faceI = otherCellFaces[oCFI];
if (!mesh_.isInternalFace(faceI))
{
label patchI = patchID[faceI - nInternalFaces];
const polyPatch& patch = mesh_.boundaryMesh()[patchI];
if (isA<wallPolyPatch>(patch))
{
otherCellOnlyWallFaces.append(faceI);
}
}
}
thisCellWallFaces.append(otherCellOnlyWallFaces);
otherCellWallFaces.append(thisCellOnlyWallFaces);
}
}
directWallFaces_.setSize(mesh_.nCells());
forAll(directWallFaces_, i)
{
directWallFaces_[i].transfer(wallFacesTemp[i]);
}
}
......
......@@ -99,6 +99,12 @@ class InteractionLists
//- Direct interaction list
labelListList dil_;
//- Wall faces on this processor that are in interaction range
// of each each cell, data subordinate to dil, i.e. if a cell
// B is on cell A's dil, then all of cell B's wall faces are
// considered posible interactions for cell A.
labelListList directWallFaces_;
//- Referred interaction list - which real cells are to be
// supplied with particles from the referred particle
// container with the same index.
......@@ -201,6 +207,9 @@ public:
//- Return access to the direct interaction list
inline const labelListList& dil() const;
//- Return access to the direct wall faces
inline const labelListList& directWallFaces() const;
//- Return access to the referred interaction list
inline const labelListList& ril() const;
......
......@@ -57,6 +57,14 @@ const Foam::labelListList& Foam::InteractionLists<ParticleType>::dil() const
}
template<class ParticleType>
const Foam::labelListList&
Foam::InteractionLists<ParticleType>::directWallFaces() const
{
return directWallFaces_;
}
template<class ParticleType>
const Foam::labelListList& Foam::InteractionLists<ParticleType>::ril() const
{
......
......@@ -169,224 +169,225 @@ void Foam::PairCollision<CloudType>::realReferredInteraction()
template<class CloudType>
void Foam::PairCollision<CloudType>::wallInteraction()
{
// const polyMesh& mesh = this->owner().mesh();
const polyMesh& mesh = this->owner().mesh();
// const DirectInteractionList<typename CloudType::parcelType>& dil =
// il_.dil();
const labelListList& dil = il_.dil();
const labelListList directWallFaces = il_.directWallFaces();
// const ReferredCellList<typename CloudType::parcelType>& ril = il_.ril();
// // Storage for the wall interaction sites
// DynamicList<point> flatSites;
// DynamicList<scalar> flatSiteExclusionDistancesSqr;
// DynamicList<point> otherSites;
// DynamicList<scalar> otherSiteDistances;
// DynamicList<point> sharpSites;
// DynamicList<scalar> sharpSiteExclusionDistancesSqr;
// forAll(dil, realCellI)
// {
// // The real wall faces in range of this real cell
// const labelList& realWallFaces = dil.wallFaces()[realCellI];
// // The labels of referred cells in range of this real cell
// const labelList& referredCellsInRange =
// dil.referredCellsForInteraction()[realCellI];
// // Loop over all Parcels in cell
// forAll(cellOccupancy_[realCellI], cellParticleI)
// {
// flatSites.clear();
// flatSiteExclusionDistancesSqr.clear();
// otherSites.clear();
// otherSiteDistances.clear();
// sharpSites.clear();
// sharpSiteExclusionDistancesSqr.clear();
// typename CloudType::parcelType& p =
// *cellOccupancy_[realCellI][cellParticleI];
// const point& pos = p.position();
// scalar r = p.d()/2;
// // real wallFace interactions
// forAll(realWallFaces, realWallFaceI)
// {
// label realFaceI = realWallFaces[realWallFaceI];
// pointHit nearest = mesh.faces()[realFaceI].nearestPoint
// (
// pos,
// mesh.points()
// );
// if (nearest.distance() < r)
// {
// vector normal = mesh.faceAreas()[realFaceI];
// normal /= mag(normal);
// const vector& nearPt = nearest.rawPoint();
// vector pW = nearPt - pos;
// scalar normalAlignment = normal & pW/mag(pW);
// if (normalAlignment > cosPhiMinFlatWall)
// {
// // Guard against a flat interaction being
// // present on the boundary of two or more
// // faces, which would create duplicate contact
// // points. Duplicates are discarded.
// if
// (
// !duplicatePointInList
// (
// flatSites,
// nearPt,
// sqr(r*flatWallDuplicateExclusion)
// )
// )
// {
// flatSites.append(nearPt);
// flatSiteExclusionDistancesSqr.append
// (
// sqr(r) - sqr(nearest.distance())
// );
// }
// }
// else
// {
// otherSites.append(nearPt);
// otherSiteDistances.append(nearest.distance());
// }
// }
// }
// // referred wallFace interactions
// forAll(referredCellsInRange, refCellInRangeI)
// {
// const ReferredCell<typename CloudType::parcelType>& refCell =
// ril[referredCellsInRange[refCellInRangeI]];
// const labelList& refWallFaces = refCell.wallFaces();
// forAll(refWallFaces, refWallFaceI)
// {
// label refFaceI = refWallFaces[refWallFaceI];
// pointHit nearest = refCell.faces()[refFaceI].nearestPoint
// (
// pos,
// refCell.points()
// );
// if (nearest.distance() < r)
// {
// vector normal = refCell.faceAreas()[refFaceI];
// normal /= mag(normal);
// const vector& nearPt = nearest.rawPoint();
// vector pW = nearPt - pos;
// scalar normalAlignment = normal & pW/mag(pW);
// if (normalAlignment > cosPhiMinFlatWall)
// {
// // Guard against a flat interaction being
// // present on the boundary of two or more
// // faces, which would create duplicate contact
// // points. Duplicates are discarded.
// if
// (
// !duplicatePointInList
// (
// flatSites,
// nearPt,
// sqr(r*flatWallDuplicateExclusion)
// )
// )
// {
// flatSites.append(nearPt);
// flatSiteExclusionDistancesSqr.append
// (
// sqr(r) - sqr(nearest.distance())
// );
// }
// }
// else
// {
// otherSites.append(nearPt);
// otherSiteDistances.append(nearest.distance());
// }
// }
// }
// }
// // All flat interaction sites found, now classify the
// // other sites as being in range of a flat interaction, or
// // a sharp interaction, being aware of not duplicating the
// // sharp interaction sites.
// // The "other" sites need to evaluated in order of
// // ascending distance to their nearest point so that
// // grouping occurs around the closest in any group
// labelList sortedOtherSiteIndices;
// sortedOrder(otherSiteDistances, sortedOtherSiteIndices);
// forAll(sortedOtherSiteIndices, siteI)
// {
// label orderedIndex = sortedOtherSiteIndices[siteI];
// const point& otherPt = otherSites[orderedIndex];
// if
// (
// !duplicatePointInList
// (
// flatSites,
// otherPt,
// flatSiteExclusionDistancesSqr
// )
// )
// {
// // Not in range of a flat interaction, must be a
// // sharp interaction.
// if
// (
// !duplicatePointInList
// (
// sharpSites,
// otherPt,
// sharpSiteExclusionDistancesSqr
// )
// )
// {
// sharpSites.append(otherPt);
// sharpSiteExclusionDistancesSqr.append
// (
// sqr(r) - sqr(otherSiteDistances[orderedIndex])
// );
// }
// }
// }
// evaluateWall(p, flatSites, sharpSites);
// }
// }
// Storage for the wall interaction sites
DynamicList<point> flatSites;
DynamicList<scalar> flatSiteExclusionDistancesSqr;
DynamicList<point> otherSites;
DynamicList<scalar> otherSiteDistances;
DynamicList<point> sharpSites;
DynamicList<scalar> sharpSiteExclusionDistancesSqr;
forAll(dil, realCellI)
{
// The real wall faces in range of this real cell
const labelList& realWallFaces = directWallFaces[realCellI];
// Loop over all Parcels in cell
forAll(cellOccupancy_[realCellI], cellParticleI)
{
flatSites.clear();
flatSiteExclusionDistancesSqr.clear();
otherSites.clear();
otherSiteDistances.clear();
sharpSites.clear();
sharpSiteExclusionDistancesSqr.clear();
typename CloudType::parcelType& p =
*cellOccupancy_[realCellI][cellParticleI];
const point& pos = p.position();
scalar r = p.d()/2;
// real wallFace interactions
forAll(realWallFaces, realWallFaceI)
{
label realFaceI = realWallFaces[realWallFaceI];
pointHit nearest = mesh.faces()[realFaceI].nearestPoint
(
pos,
mesh.points()
);
if (nearest.distance() < r)
{
vector normal = mesh.faceAreas()[realFaceI];
normal /= mag(normal);
const vector& nearPt = nearest.rawPoint();
vector pW = nearPt - pos;
scalar normalAlignment = normal & pW/mag(pW);
if (normalAlignment > cosPhiMinFlatWall)
{
// Guard against a flat interaction being
// present on the boundary of two or more
// faces, which would create duplicate contact
// points. Duplicates are discarded.
if
(
!duplicatePointInList
(
flatSites,
nearPt,
sqr(r*flatWallDuplicateExclusion)
)
)
{
flatSites.append(nearPt);
flatSiteExclusionDistancesSqr.append
(
sqr(r) - sqr(nearest.distance())
);
}
}
else
{
otherSites.append(nearPt);
otherSiteDistances.append(nearest.distance());
}
}
}
// // referred wallFace interactions
// // The labels of referred cells in range of this real cell
// const labelList& referredCellsInRange =
// dil.referredCellsForInteraction()[realCellI];
// forAll(referredCellsInRange, refCellInRangeI)
// {
// const ReferredCell<typename CloudType::parcelType>& refCell =
// ril[referredCellsInRange[refCellInRangeI]];
// const labelList& refWallFaces = refCell.wallFaces();
// forAll(refWallFaces, refWallFaceI)
// {
// label refFaceI = refWallFaces[refWallFaceI];
// pointHit nearest = refCell.faces()[refFaceI].nearestPoint
// (
// pos,
// refCell.points()
// );
// if (nearest.distance() < r)
// {
// vector normal = refCell.faceAreas()[refFaceI];
// normal /= mag(normal);
// const vector& nearPt = nearest.rawPoint();
// vector pW = nearPt - pos;
// scalar normalAlignment = normal & pW/mag(pW);
// if (normalAlignment > cosPhiMinFlatWall)
// {
// // Guard against a flat interaction being
// // present on the boundary of two or more
// // faces, which would create duplicate contact
// // points. Duplicates are discarded.
// if
// (
// !duplicatePointInList
// (
// flatSites,
// nearPt,
// sqr(r*flatWallDuplicateExclusion)
// )
// )
// {
// flatSites.append(nearPt);
// flatSiteExclusionDistancesSqr.append
// (
// sqr(r) - sqr(nearest.distance())
// );
// }
// }
// else
// {
// otherSites.append(nearPt);
// otherSiteDistances.append(nearest.distance());
// }
// }
// }
// }
// All flat interaction sites found, now classify the
// other sites as being in range of a flat interaction, or
// a sharp interaction, being aware of not duplicating the
// sharp interaction sites.
// The "other" sites need to evaluated in order of
// ascending distance to their nearest point so that
// grouping occurs around the closest in any group
labelList sortedOtherSiteIndices;
sortedOrder(otherSiteDistances, sortedOtherSiteIndices);
forAll(sortedOtherSiteIndices, siteI)
{
label orderedIndex = sortedOtherSiteIndices[siteI];
const point& otherPt = otherSites[orderedIndex];
if
(
!duplicatePointInList
(
flatSites,
otherPt,
flatSiteExclusionDistancesSqr
)
)
{
// Not in range of a flat interaction, must be a
// sharp interaction.
if
(
!duplicatePointInList
(
sharpSites,
otherPt,
sharpSiteExclusionDistancesSqr
)
)
{
sharpSites.append(otherPt);
sharpSiteExclusionDistancesSqr.append
(
sqr(r) - sqr(otherSiteDistances[orderedIndex])
);
}
}
}
evaluateWall(p, flatSites, sharpSites);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment