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.
This commit is contained in:
graham
2010-04-08 18:44:51 +01:00
parent 0a4a3664a4
commit 4faec1291d
4 changed files with 296 additions and 185 deletions

View File

@ -398,6 +398,7 @@ Foam::InteractionLists<ParticleType>::InteractionLists
globalTransforms_(mesh_), globalTransforms_(mesh_),
maxDistance_(maxDistance), maxDistance_(maxDistance),
dil_(), dil_(),
directWallFaces_(),
ril_(), ril_(),
rilInverse_(), rilInverse_(),
cellIndexAndTransformToDistribute_(), cellIndexAndTransformToDistribute_(),
@ -409,7 +410,7 @@ Foam::InteractionLists<ParticleType>::InteractionLists
const vector interactionVec = maxDistance_*vector::one; const vector interactionVec = maxDistance_*vector::one;
treeBoundBox procBb(treeBoundBox(mesh.points())); treeBoundBox procBb(treeBoundBox(mesh_.points()));
treeBoundBox extendedProcBb treeBoundBox extendedProcBb
( (
@ -439,16 +440,16 @@ Foam::InteractionLists<ParticleType>::InteractionLists
extendedProcBbsOrigProc extendedProcBbsOrigProc
); );
treeBoundBoxList cellBbs(mesh.nCells()); treeBoundBoxList cellBbs(mesh_.nCells());
forAll(cellBbs, cellI) forAll(cellBbs, cellI)
{ {
cellBbs[cellI] = treeBoundBox cellBbs[cellI] = treeBoundBox
( (
mesh.cells()[cellI].points mesh_.cells()[cellI].points
( (
mesh.faces(), mesh_.faces(),
mesh.points() mesh_.points()
) )
); );
} }
@ -456,7 +457,7 @@ Foam::InteractionLists<ParticleType>::InteractionLists
// Recording which cells are in range of an extended boundBox, as // Recording which cells are in range of an extended boundBox, as
// only these cells will need to be tested to determine which // only these cells will need to be tested to determine which
// referred cells that they interact with. // referred cells that they interact with.
PackedBoolList cellInRangeOfCoupledPatch(mesh.nCells(), false); PackedBoolList cellInRangeOfCoupledPatch(mesh_.nCells(), false);
// IAndT: index and transform // IAndT: index and transform
DynamicList<labelPair> globalIAndTToExchange; 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 indexedOctree<treeDataCell> coupledPatchRangeTree
( (
treeDataCell(true, mesh, coupledPatchRangeCells), treeDataCell(true, mesh_, coupledPatchRangeCells),
procBbRndExt, procBbRndExt,
8, // maxLevel, 8, // maxLevel,
10, // leafSize, 10, // leafSize,
@ -632,7 +636,7 @@ Foam::InteractionLists<ParticleType>::InteractionLists
// Determine inverse addressing for referred cells // Determine inverse addressing for referred cells
rilInverse_.setSize(mesh.nCells()); rilInverse_.setSize(mesh_.nCells());
// Temporary Dynamic lists for accumulation // Temporary Dynamic lists for accumulation
List<DynamicList<label> > rilInverseTemp(rilInverse_.size()); List<DynamicList<label> > rilInverseTemp(rilInverse_.size());
@ -663,14 +667,14 @@ Foam::InteractionLists<ParticleType>::InteractionLists
indexedOctree<treeDataCell> allCellsTree indexedOctree<treeDataCell> allCellsTree
( (
treeDataCell(true, mesh), treeDataCell(true, mesh_),
procBbRndExt, procBbRndExt,
8, // maxLevel, 8, // maxLevel,
10, // leafSize, 10, // leafSize,
100.0 100.0
); );
dil_.setSize(mesh.nCells()); dil_.setSize(mesh_.nCells());
forAll(cellBbs, cellI) forAll(cellBbs, cellI)
{ {
@ -711,6 +715,95 @@ Foam::InteractionLists<ParticleType>::InteractionLists
dil_[cellI].transfer(cellDIL); 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]);
}
} }

View File

@ -99,6 +99,12 @@ class InteractionLists
//- Direct interaction list //- Direct interaction list
labelListList dil_; 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 //- Referred interaction list - which real cells are to be
// supplied with particles from the referred particle // supplied with particles from the referred particle
// container with the same index. // container with the same index.
@ -201,6 +207,9 @@ public:
//- Return access to the direct interaction list //- Return access to the direct interaction list
inline const labelListList& dil() const; inline const labelListList& dil() const;
//- Return access to the direct wall faces
inline const labelListList& directWallFaces() const;
//- Return access to the referred interaction list //- Return access to the referred interaction list
inline const labelListList& ril() const; inline const labelListList& ril() const;

View File

@ -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> template<class ParticleType>
const Foam::labelListList& Foam::InteractionLists<ParticleType>::ril() const const Foam::labelListList& Foam::InteractionLists<ParticleType>::ril() const
{ {

View File

@ -169,224 +169,225 @@ void Foam::PairCollision<CloudType>::realReferredInteraction()
template<class CloudType> template<class CloudType>
void Foam::PairCollision<CloudType>::wallInteraction() void Foam::PairCollision<CloudType>::wallInteraction()
{ {
// const polyMesh& mesh = this->owner().mesh(); const polyMesh& mesh = this->owner().mesh();
// const DirectInteractionList<typename CloudType::parcelType>& dil = const labelListList& dil = il_.dil();
// il_.dil();
const labelListList directWallFaces = il_.directWallFaces();
// const ReferredCellList<typename CloudType::parcelType>& ril = il_.ril(); // const ReferredCellList<typename CloudType::parcelType>& ril = il_.ril();
// // Storage for the wall interaction sites // Storage for the wall interaction sites
// DynamicList<point> flatSites; DynamicList<point> flatSites;
// DynamicList<scalar> flatSiteExclusionDistancesSqr; DynamicList<scalar> flatSiteExclusionDistancesSqr;
// DynamicList<point> otherSites; DynamicList<point> otherSites;
// DynamicList<scalar> otherSiteDistances; DynamicList<scalar> otherSiteDistances;
// DynamicList<point> sharpSites; DynamicList<point> sharpSites;
// DynamicList<scalar> sharpSiteExclusionDistancesSqr; DynamicList<scalar> sharpSiteExclusionDistancesSqr;
// forAll(dil, realCellI) forAll(dil, realCellI)
// { {
// // The real wall faces in range of this real cell // The real wall faces in range of this real cell
// const labelList& realWallFaces = dil.wallFaces()[realCellI]; const labelList& realWallFaces = directWallFaces[realCellI];
// // The labels of referred cells in range of this real cell // Loop over all Parcels in cell
// const labelList& referredCellsInRange = forAll(cellOccupancy_[realCellI], cellParticleI)
// dil.referredCellsForInteraction()[realCellI]; {
flatSites.clear();
flatSiteExclusionDistancesSqr.clear();
otherSites.clear();
otherSiteDistances.clear();
sharpSites.clear();
sharpSiteExclusionDistancesSqr.clear();
// // Loop over all Parcels in cell typename CloudType::parcelType& p =
// forAll(cellOccupancy_[realCellI], cellParticleI) *cellOccupancy_[realCellI][cellParticleI];
// {
// flatSites.clear();
// flatSiteExclusionDistancesSqr.clear();
// otherSites.clear();
// otherSiteDistances.clear();
// sharpSites.clear();
// sharpSiteExclusionDistancesSqr.clear();
// typename CloudType::parcelType& p = const point& pos = p.position();
// *cellOccupancy_[realCellI][cellParticleI];
// const point& pos = p.position(); scalar r = p.d()/2;
// scalar r = p.d()/2; // real wallFace interactions
// // real wallFace interactions forAll(realWallFaces, realWallFaceI)
{
label realFaceI = realWallFaces[realWallFaceI];
// forAll(realWallFaces, realWallFaceI) pointHit nearest = mesh.faces()[realFaceI].nearestPoint
// { (
// label realFaceI = realWallFaces[realWallFaceI]; pos,
mesh.points()
);
// pointHit nearest = mesh.faces()[realFaceI].nearestPoint if (nearest.distance() < r)
// ( {
// pos, vector normal = mesh.faceAreas()[realFaceI];
// mesh.points()
// );
// if (nearest.distance() < r) normal /= mag(normal);
// {
// vector normal = mesh.faceAreas()[realFaceI];
// normal /= mag(normal); const vector& nearPt = nearest.rawPoint();
// const vector& nearPt = nearest.rawPoint(); vector pW = nearPt - pos;
// vector pW = nearPt - pos; scalar normalAlignment = normal & pW/mag(pW);
// 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);
// if (normalAlignment > cosPhiMinFlatWall) flatSiteExclusionDistancesSqr.append
// { (
// // Guard against a flat interaction being sqr(r) - sqr(nearest.distance())
// // present on the boundary of two or more );
// // faces, which would create duplicate contact }
// // points. Duplicates are discarded. }
// if else
// ( {
// !duplicatePointInList otherSites.append(nearPt);
// (
// flatSites,
// nearPt,
// sqr(r*flatWallDuplicateExclusion)
// )
// )
// {
// flatSites.append(nearPt);
// flatSiteExclusionDistancesSqr.append otherSiteDistances.append(nearest.distance());
// ( }
// sqr(r) - sqr(nearest.distance()) }
// ); }
// }
// }
// else
// {
// otherSites.append(nearPt);
// otherSiteDistances.append(nearest.distance()); // // referred wallFace interactions
// }
// }
// }
// // referred wallFace interactions // // The labels of referred cells in range of this real cell
// const labelList& referredCellsInRange =
// dil.referredCellsForInteraction()[realCellI];
// forAll(referredCellsInRange, refCellInRangeI) // forAll(referredCellsInRange, refCellInRangeI)
// { // {
// const ReferredCell<typename CloudType::parcelType>& refCell = // const ReferredCell<typename CloudType::parcelType>& refCell =
// ril[referredCellsInRange[refCellInRangeI]]; // ril[referredCellsInRange[refCellInRangeI]];
// const labelList& refWallFaces = refCell.wallFaces(); // const labelList& refWallFaces = refCell.wallFaces();
// forAll(refWallFaces, refWallFaceI) // forAll(refWallFaces, refWallFaceI)
// { // {
// label refFaceI = refWallFaces[refWallFaceI]; // label refFaceI = refWallFaces[refWallFaceI];
// pointHit nearest = refCell.faces()[refFaceI].nearestPoint // pointHit nearest = refCell.faces()[refFaceI].nearestPoint
// ( // (
// pos, // pos,
// refCell.points() // refCell.points()
// ); // );
// if (nearest.distance() < r) // if (nearest.distance() < r)
// { // {
// vector normal = refCell.faceAreas()[refFaceI]; // vector normal = refCell.faceAreas()[refFaceI];
// normal /= mag(normal); // normal /= mag(normal);
// const vector& nearPt = nearest.rawPoint(); // const vector& nearPt = nearest.rawPoint();
// vector pW = nearPt - pos; // vector pW = nearPt - pos;
// scalar normalAlignment = normal & pW/mag(pW); // scalar normalAlignment = normal & pW/mag(pW);
// if (normalAlignment > cosPhiMinFlatWall) // if (normalAlignment > cosPhiMinFlatWall)
// { // {
// // Guard against a flat interaction being // // Guard against a flat interaction being
// // present on the boundary of two or more // // present on the boundary of two or more
// // faces, which would create duplicate contact // // faces, which would create duplicate contact
// // points. Duplicates are discarded. // // points. Duplicates are discarded.
// if // if
// ( // (
// !duplicatePointInList // !duplicatePointInList
// ( // (
// flatSites, // flatSites,
// nearPt, // nearPt,
// sqr(r*flatWallDuplicateExclusion) // sqr(r*flatWallDuplicateExclusion)
// ) // )
// ) // )
// { // {
// flatSites.append(nearPt); // flatSites.append(nearPt);
// flatSiteExclusionDistancesSqr.append // flatSiteExclusionDistancesSqr.append
// ( // (
// sqr(r) - sqr(nearest.distance()) // sqr(r) - sqr(nearest.distance())
// ); // );
// } // }
// } // }
// else // else
// { // {
// otherSites.append(nearPt); // otherSites.append(nearPt);
// otherSiteDistances.append(nearest.distance()); // otherSiteDistances.append(nearest.distance());
// } // }
// } // }
// } // }
// } // }
// // All flat interaction sites found, now classify the // All flat interaction sites found, now classify the
// // other sites as being in range of a flat interaction, or // other sites as being in range of a flat interaction, or
// // a sharp interaction, being aware of not duplicating the // a sharp interaction, being aware of not duplicating the
// // sharp interaction sites. // sharp interaction sites.
// // The "other" sites need to evaluated in order of // The "other" sites need to evaluated in order of
// // ascending distance to their nearest point so that // ascending distance to their nearest point so that
// // grouping occurs around the closest in any group // grouping occurs around the closest in any group
// labelList sortedOtherSiteIndices; labelList sortedOtherSiteIndices;
// sortedOrder(otherSiteDistances, sortedOtherSiteIndices); sortedOrder(otherSiteDistances, sortedOtherSiteIndices);
// forAll(sortedOtherSiteIndices, siteI) forAll(sortedOtherSiteIndices, siteI)
// { {
// label orderedIndex = sortedOtherSiteIndices[siteI]; label orderedIndex = sortedOtherSiteIndices[siteI];
// const point& otherPt = otherSites[orderedIndex]; const point& otherPt = otherSites[orderedIndex];
// if if
// ( (
// !duplicatePointInList !duplicatePointInList
// ( (
// flatSites, flatSites,
// otherPt, otherPt,
// flatSiteExclusionDistancesSqr flatSiteExclusionDistancesSqr
// ) )
// ) )
// { {
// // Not in range of a flat interaction, must be a // Not in range of a flat interaction, must be a
// // sharp interaction. // sharp interaction.
// if if
// ( (
// !duplicatePointInList !duplicatePointInList
// ( (
// sharpSites, sharpSites,
// otherPt, otherPt,
// sharpSiteExclusionDistancesSqr sharpSiteExclusionDistancesSqr
// ) )
// ) )
// { {
// sharpSites.append(otherPt); sharpSites.append(otherPt);
// sharpSiteExclusionDistancesSqr.append sharpSiteExclusionDistancesSqr.append
// ( (
// sqr(r) - sqr(otherSiteDistances[orderedIndex]) sqr(r) - sqr(otherSiteDistances[orderedIndex])
// ); );
// } }
// } }
// } }
// evaluateWall(p, flatSites, sharpSites); evaluateWall(p, flatSites, sharpSites);
// } }
// } }
} }