From 732fa271ba5ce88ebc6517f898fed978a935047e Mon Sep 17 00:00:00 2001 From: graham Date: Fri, 18 Sep 2009 19:34:49 +0100 Subject: [PATCH] Adding inverse addressing to record which referred cells are in range of the referred cells. To be used by wall interactions. --- .../DirectInteractionList.C | 114 +++++++++++++++++- .../DirectInteractionList.H | 25 +++- .../DirectInteractionListI.H | 8 ++ .../basic/InteractionLists/InteractionLists.C | 4 +- 4 files changed, 146 insertions(+), 5 deletions(-) diff --git a/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionList.C b/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionList.C index 83a4ac4c8e..1d3d2eaaf2 100644 --- a/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionList.C +++ b/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionList.C @@ -26,6 +26,7 @@ License #include "DirectInteractionList.H" #include "InteractionLists.H" +#include "ReferredCellList.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -397,7 +398,8 @@ Foam::DirectInteractionList::DirectInteractionList : labelListList(il.mesh().nCells()), il_(il), - wallFaces_(il.mesh().nCells()) + wallFaces_(il.mesh().nCells()), + referredCellsForInteraction_(il.mesh().nCells()) { if ((*this).size() > 1) { @@ -423,7 +425,8 @@ Foam::DirectInteractionList::DirectInteractionList : labelListList(il.mesh().nCells()), il_(il), - wallFaces_(il.mesh().nCells()) + wallFaces_(il.mesh().nCells()), + referredCellsForInteraction_(il.mesh().nCells()) { Info<< " Read DirectInteractionList from disk not implemented" << endl; } @@ -436,4 +439,111 @@ Foam::DirectInteractionList::~DirectInteractionList() {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::DirectInteractionList::buildInverseAddressing() +{ + const ReferredCellList& ril(il_.ril()); + + // Temporary Dynamic lists for accumulation + List > referredCellsForInteraction + ( + referredCellsForInteraction_.size() + ); + + // Loop over all referred cells + forAll(ril, refCellI) + { + const ReferredCell& refCell = ril[refCellI]; + + const labelList& realCells = refCell.realCellsForInteraction(); + + // Loop over all real cells in that the referred cell is to + // supply interactions to and record the index of this + // referred cell in the cells entry in + // referredCellsForInteraction_ + + forAll(realCells, realCellI) + { + referredCellsForInteraction[realCells[realCellI]].append(refCellI); + } + } + + forAll(referredCellsForInteraction_, cellI) + { + referredCellsForInteraction_[cellI].transfer + ( + referredCellsForInteraction[cellI] + ); + } +} + + +template +void Foam::DirectInteractionList:: +writeReferredCellsForInteraction() const +{ + const ReferredCellList& ril(il_.ril()); + + forAll(*this, cellI) + { + const labelList& refCells = referredCellsForInteraction_[cellI]; + + if (!refCells.size()) + { + continue; + } + + fileName fName = + il_.mesh().time().path() + /"referredCellsForInteraction_" + name(cellI) + ".obj"; + + Info<< " Writing " << fName.name() << endl; + + OFstream referredCellsFile(fName); + + label vertexOffset = 1; + + forAll(refCells, refCellForInteractionI) + { + const ReferredCell& refCell = + ril[refCells[refCellForInteractionI]]; + + const vectorList& refCellPts = refCell.vertexPositions(); + + const faceList& refCellFaces = refCell.faces(); + + forAll(refCellPts, ptI) + { + referredCellsFile + << "v " + << refCellPts[ptI].x() << " " + << refCellPts[ptI].y() << " " + << refCellPts[ptI].z() + << nl; + } + + forAll(refCellFaces, faceI) + { + referredCellsFile<< "f"; + + forAll(refCellFaces[faceI], fPtI) + { + referredCellsFile + << " " + << refCellFaces[faceI][fPtI] + vertexOffset; + } + + referredCellsFile<< nl; + } + + vertexOffset += refCellPts.size(); + } + + referredCellsFile.flush(); + } +} + + // ************************************************************************* // diff --git a/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionList.H b/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionList.H index f3acc18bfb..9403016262 100644 --- a/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionList.H +++ b/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionList.H @@ -26,6 +26,8 @@ Class Foam::DirectInteractionList Description + Data stored that specifies what a "real" cell (one on the current + processor) interacts with. SourceFiles DirectInteractionListI.H @@ -66,6 +68,10 @@ class DirectInteractionList // of each cell labelListList wallFaces_; + //- Data specifying which referred cells are in range of each + // cell, Inverse data of ReferredCell's realCellsForInteraction + labelListList referredCellsForInteraction_; + // Private Member Functions @@ -108,11 +114,26 @@ public: // Member Functions + //- Build referredCellsForInteraction by interrogating the + //- ReferredCellList of the InteractionLists object that owns + //- this object. + void buildInverseAddressing(); + + // Access - inline const labelListList& wallFaces() const; + inline const labelListList& wallFaces() const; + + inline const labelListList& referredCellsForInteraction() const; + + inline const InteractionLists& il() const; + + + // Write + + //- Write the referred cells in range of each real cell + void writeReferredCellsForInteraction() const; - inline const InteractionLists& il() const; }; diff --git a/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionListI.H b/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionListI.H index 9611a033d6..5b195cc295 100644 --- a/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionListI.H +++ b/src/lagrangian/basic/InteractionLists/DirectInteractionList/DirectInteractionListI.H @@ -34,6 +34,14 @@ Foam::DirectInteractionList::wallFaces() const } +template +inline const Foam::labelListList& +Foam::DirectInteractionList::referredCellsForInteraction() const +{ + return referredCellsForInteraction_; +} + + template inline const Foam::InteractionLists& Foam::DirectInteractionList::il() const diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.C b/src/lagrangian/basic/InteractionLists/InteractionLists.C index cf6f802951..87866788d6 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionLists.C +++ b/src/lagrangian/basic/InteractionLists/InteractionLists.C @@ -46,7 +46,9 @@ Foam::InteractionLists::InteractionLists maxDistanceSqr_(maxDistanceSqr), dil_(*this, pointPointListBuild), ril_(*this, pointPointListBuild) -{} +{ + dil_.buildInverseAddressing(); +} template