35 void Foam::interactionLists::buildCellReferralLists()
37 Info<<
nl <<
"Determining molecule referring schedule" <<
endl;
39 const referredCellList& refIntL(
ril());
41 DynamicList<label> referralProcs;
47 const referredCell& rC(refIntL[rIL]);
49 if (
findIndex(referralProcs, rC.sourceProc()) == -1)
51 referralProcs.append(rC.sourceProc());
55 referralProcs.shrink();
64 List<DynamicList<autoPtr<DynamicList<label> > > >
71 const referredCell& rC(refIntL[rIL]);
73 label rPI =
findIndex(referralProcs, rC.sourceProc());
79 label existingSource =
findIndex(sRL, rC.sourceCell());
89 if (existingSource == -1)
91 sRL.append(rC.sourceCell());
95 autoPtr<DynamicList<label> >(
new DynamicList<label> (
labelList(1,rIL)))
100 rRL[existingSource]->append(rIL);
102 rRL[existingSource]->shrink();
106 forAll(referralProcs, rPI)
120 cellReceivingReferralLists_.
setSize(referralProcs.size());
122 cellSendingReferralLists_.
setSize(referralProcs.size());
124 forAll(referralProcs, rPI)
132 translLL[rRLI] = rRL[rRLI]();
135 cellReceivingReferralLists_[rPI] = receivingReferralList
144 forAll(referralProcs, rPI)
153 OPstream toInteractingProc
159 toInteractingProc << sendingReferralList
170 forAll(referralProcs, rPI)
176 IPstream fromInteractingProc
182 fromInteractingProc >> cellSendingReferralLists_[rPI];
187 cellSendingReferralLists_[rPI] = sendingReferralList
200 Foam::interactionLists::interactionLists
204 bool pointPointListBuild
208 rCutMaxSqr_(rCutMaxSqr),
209 dil_(*
this, pointPointListBuild),
210 ril_(*
this, pointPointListBuild),
211 cellSendingReferralLists_(),
212 cellReceivingReferralLists_()
214 buildCellReferralLists();
218 Foam::interactionLists::interactionLists(
const polyMesh& mesh)
240 return (
magSqr(mesh_.points()[ptI] - mesh_.points()[ptJ]) <= rCutMaxSqr_);
251 const vector& eJe(mesh_.points()[eJ.
end()]);
253 return testEdgeEdgeDistance(eI, eJs, eJe);
263 const vector& pointPosition(mesh_.points()[
p]);
265 return testPointFaceDistance(pointPosition, faceNo);
275 const vector& pointPosition(mesh_.points()[
p]);
281 testPointFaceDistance
284 refCell.
faces()[rCF],
307 const vector&
p(pointsToTest[pTT]);
313 if (testPointFaceDistance(p, faceNo))
329 const face& faceToTest(mesh_.faces()[faceNo]);
331 const vector& faceC(mesh_.faceCentres()[faceNo]);
333 const vector& faceA(mesh_.faceAreas()[faceNo]);
337 return testPointFaceDistance
359 scalar perpDist((p - faceC) & faceN);
361 if (
magSqr(perpDist) > rCutMaxSqr_)
366 vector pointOnPlane = (p - faceN * perpDist);
368 if (
magSqr(faceC - pointOnPlane) < rCutMaxSqr_*1
e-8)
376 return (
magSqr(pointOnPlane - p) <= rCutMaxSqr_);
379 vector xAxis = (faceC - pointOnPlane)/
mag(faceC - pointOnPlane);
382 ((faceC - pointOnPlane) ^ faceN)
383 /
mag((faceC - pointOnPlane) ^ faceN);
389 const vector& V(points[faceToTest[fTT]]);
391 if (
magSqr(V-p) <= rCutMaxSqr_)
398 ((V - pointOnPlane) & xAxis),
399 ((V - pointOnPlane) & yAxis)
403 scalar localFaceCx((faceC - pointOnPlane) & xAxis);
405 scalar la_valid = -1;
407 forAll(local2DVertices, fV)
409 const vector2D& va(local2DVertices[fV]);
413 local2DVertices[(fV + 1) % local2DVertices.size()]
416 if (
mag(vb.y()-va.
y()) > SMALL)
420 va.
x() - va.
y()*((vb.x() - va.
x())/(vb.y() - va.
y()))
424 scalar lv = -va.
y()/(vb.y() - va.
y());
427 if (la >= 0 && la <= 1 && lv >= 0 && lv <= 1)
439 return (
magSqr(pointOnPlane-p) <= rCutMaxSqr_);
447 magSqr(pointOnPlane + la_valid*(faceC - pointOnPlane) - p)
456 <<
"point " << p <<
" to face " << faceToTest
457 <<
" comparison did not find a nearest point"
458 <<
" to be inside or outside face."
480 scalar magCrossSqr =
magSqr(crossab);
482 if (magCrossSqr > VSMALL)
487 scalar s = ((c ^
b) & crossab)/magCrossSqr;
488 scalar t = ((c ^ a) & crossab)/magCrossSqr;
500 &&
magSqr(eIs + a*s - eJs - b*t) <= rCutMaxSqr_
519 const label
f = segmentFaces[sF];
523 if (testPointFaceDistance(p, f))
525 const labelList& pCells(mesh_.pointCells()[
p]);
529 const label cellI(pCells[pC]);
531 if (
findIndex(realCellsFoundInRange, cellI) == -1)
533 realCellsFoundInRange.
append(cellI);
542 const label p = segmentPoints[sP];
546 if (testPointFaceDistance(p,
f))
548 const label cellO(mesh_.faceOwner()[
f]);
550 if (
findIndex(realCellsFoundInRange, cellO) == -1)
552 realCellsFoundInRange.
append(cellO);
555 if (mesh_.isInternalFace(
f))
559 const label cellN(mesh_.faceNeighbour()[
f]);
561 if (
findIndex(realCellsFoundInRange, cellN) == -1)
563 realCellsFoundInRange.
append(cellN);
572 const edge& eJ(mesh_.edges()[segmentEdges[sE]]);
574 forAll (mesh_.edges(), edgeIIndex)
576 const edge& eI(mesh_.edges()[edgeIIndex]);
578 if (testEdgeEdgeDistance(eI, eJ))
580 const labelList& eICells(mesh_.edgeCells()[edgeIIndex]);
584 const label cellI(eICells[eIC]);
586 if (
findIndex(realCellsFoundInRange, cellI) == -1)
588 realCellsFoundInRange.
append(cellI);
595 return realCellsFoundInRange.
shrink();
611 const label
f = segmentFaces[sF];
613 forAll(referredInteractionList, rIL)
616 = referredInteractionList[rIL].vertexPositions();
618 if (testPointFaceDistance(refCellPoints, f))
620 if (
findIndex(referredCellsFoundInRange, rIL) == -1)
622 referredCellsFoundInRange.
append(rIL);
630 const label p = segmentPoints[sP];
632 forAll(referredInteractionList, rIL)
634 const referredCell& refCell(referredInteractionList[rIL]);
636 if (testPointFaceDistance(p, refCell))
638 if (
findIndex(referredCellsFoundInRange, rIL) == -1)
640 referredCellsFoundInRange.
append(rIL);
648 const edge& eI(mesh_.edges()[segmentEdges[sE]]);
650 forAll(referredInteractionList, rIL)
653 = referredInteractionList[rIL].vertexPositions();
656 = referredInteractionList[rIL].edges();
660 const edge& eJ(refCellEdges[rCE]);
667 refCellPoints[eJ.
start()],
668 refCellPoints[eJ.
end()]
672 if(
findIndex(referredCellsFoundInRange, rIL) == -1)
674 referredCellsFoundInRange.
append(rIL);
681 return referredCellsFoundInRange.
shrink();