Newer
Older
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "InteractionLists.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class ParticleType>
void Foam::InteractionLists<ParticleType>::buildInteractionLists()
Info<< "Building InteractionLists with interaction distance "
<< maxDistance_ << endl;
const vector interactionVec = maxDistance_*vector::one;
treeBoundBox procBb(treeBoundBox(mesh_.points()));
treeBoundBox extendedProcBb
(
procBb.min() - interactionVec,
procBb.max() + interactionVec
);
treeBoundBoxList allExtendedProcBbs(Pstream::nProcs());
allExtendedProcBbs[Pstream::myProcNo()] = extendedProcBb;
Pstream::gatherList(allExtendedProcBbs);
Pstream::scatterList(allExtendedProcBbs);
List<treeBoundBox> extendedProcBbsInRange;
List<label> extendedProcBbsTransformIndex;
List<label> extendedProcBbsOrigProc;
findExtendedProcBbsInRange
(
procBb,
allExtendedProcBbs,
globalTransforms_,
extendedProcBbsInRange,
extendedProcBbsTransformIndex,
extendedProcBbsOrigProc
);
treeBoundBoxList cellBbs(mesh_.nCells());
forAll(cellBbs, cellI)
{
cellBbs[cellI] = treeBoundBox
(
mesh_.cells()[cellI].points
(
mesh_.faces(),
mesh_.points()
)
);
}
// 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);
// IAndT: index and transform
DynamicList<labelPair> cellIAndTToExchange;
DynamicList<treeBoundBox> cellBbsToExchange;
DynamicList<label> procToDistributeCellTo;
forAll(extendedProcBbsInRange, ePBIRI)
{
const treeBoundBox& otherExtendedProcBb =
extendedProcBbsInRange[ePBIRI];
label transformIndex = extendedProcBbsTransformIndex[ePBIRI];
label origProc = extendedProcBbsOrigProc[ePBIRI];
const treeBoundBox& cellBb = cellBbs[cellI];
if (cellBb.overlaps(otherExtendedProcBb))
// This cell is in range of the Bb of the other
// processor Bb, and so needs to be referred to it
cellInRangeOfCoupledPatch[cellI] = true;
cellIAndTToExchange.append
globalTransforms_.encode(cellI, transformIndex)
cellBbsToExchange.append(cellBb);
procToDistributeCellTo.append(origProc);
buildMap(cellMapPtr_, procToDistributeCellTo);
// Needed for reverseDistribute
label preDistributionCellMapSize = procToDistributeCellTo.size();
cellMap().distribute(cellBbsToExchange);
cellMap().distribute(cellIAndTToExchange);
// Determine labelList specifying only cells that are in range of
// a coupled boundary to build an octree limited to these cells.
DynamicList<label> coupledPatchRangeCells;
forAll(cellInRangeOfCoupledPatch, cellI)
{
if (cellInRangeOfCoupledPatch[cellI])
{
coupledPatchRangeCells.append(cellI);
}
treeBoundBox procBbRndExt
(
treeBoundBox(mesh_.points()).extend(rndGen, 1e-4)
);
indexedOctree<treeDataCell> coupledPatchRangeTree
(
treeDataCell(true, mesh_, coupledPatchRangeCells),
procBbRndExt,
8, // maxLevel,
10, // leafSize,
100.0
);
ril_.setSize(cellBbsToExchange.size());
// This needs to be a boolList, not PackedBoolList if
// reverseDistribute is called.
boolList cellBbRequiredByAnyCell(cellBbsToExchange.size(), false);
Info<< " Building referred interaction lists" << endl;
forAll(cellBbsToExchange, bbI)
const labelPair& ciat = cellIAndTToExchange[bbI];
const vectorTensorTransform& transform = globalTransforms_.transform
(
globalTransforms_.transformIndex(ciat)
);
treeBoundBox tempTransformedBb
(
transform.invTransform(cellBbsToExchange[bbI].corners())
);
treeBoundBox extendedBb
(
tempTransformedBb.min() - interactionVec,
tempTransformedBb.max() + interactionVec
);
// Find all elements intersecting box.
labelList interactingElems
(
coupledPatchRangeTree.findBox(extendedBb)
);
Loading
Loading full blame...