40 template<
class Type,
class TrackingData>
43 template<
class Type,
class TrackingData>
50 template<
class Type,
class TrackingData>
63 if (!
x.valid(td_) &&
y.valid(td_))
75 template<
class Type,
class TrackingData>
78 const polyPatch& patch,
86 pointInfo[i].transform(patch, patchPointLabels[i],
transform, td_);
96 template<
class Type,
class TrackingData>
100 const label neighbourEdgeI,
101 const Type& neighbourInfo,
107 bool wasValid = pointInfo.valid(td_);
110 pointInfo.updatePoint
122 if (!changedPoint_[pointi])
124 changedPoint_[pointi] =
true;
125 changedPoints_[nChangedPoints_++] = pointi;
129 if (!wasValid && pointInfo.valid(td_))
143 template<
class Type,
class TrackingData>
147 const Type& neighbourInfo,
153 bool wasValid = pointInfo.valid(td_);
156 pointInfo.updatePoint
167 if (!changedPoint_[pointi])
169 changedPoint_[pointi] =
true;
170 changedPoints_[nChangedPoints_++] = pointi;
174 if (!wasValid && pointInfo.valid(td_))
188 template<
class Type,
class TrackingData>
192 const label neighbourPointi,
193 const Type& neighbourInfo,
199 bool wasValid = edgeInfo.valid(td_);
214 if (!changedEdge_[edgeI])
216 changedEdge_[edgeI] =
true;
217 changedEdges_[nChangedEdges_++] = edgeI;
221 if (!wasValid && edgeInfo.valid(td_))
231 template<
class Type,
class TrackingData>
232 template<
class PatchType>
239 if (isA<PatchType>(mesh_.boundaryMesh()[
patchi]))
249 template<
class Type,
class TrackingData>
260 forAll(mesh_.globalData().processorPatches(), i)
262 label patchi = mesh_.globalData().processorPatches()[i];
264 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[
patchi]);
275 forAll(neighbPoints, thisPointi)
278 if (changedPoint_[meshPointi])
280 patchInfo.
append(allPointInfo_[meshPointi]);
281 thisPoints.
append(thisPointi);
282 nbrPoints.
append(neighbPoints[thisPointi]);
294 toNeighbour << nbrPoints << patchInfo;
298 pBufs.finishedSends();
304 forAll(mesh_.globalData().processorPatches(), i)
306 label patchi = mesh_.globalData().processorPatches()[i];
307 const processorPolyPatch& procPatch =
308 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[
patchi]);
310 List<Type> patchInfo;
314 UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs);
315 fromNeighbour >> patchPoints >> patchInfo;
326 transform(procPatch, patchPoints, procPatch.transform(), patchInfo);
329 const labelList& meshPoints = procPatch.meshPoints();
332 label meshPointi = meshPoints[patchPoints[i]];
334 if (!allPointInfo_[meshPointi].
equal(patchInfo[i], td_))
340 allPointInfo_[meshPointi]
353 template<
class Type,
class TrackingData>
358 DynamicList<Type> nbrInfo;
359 DynamicList<label> nbrPoints;
360 DynamicList<label> thisPoints;
364 const polyPatch& patch = mesh_.boundaryMesh()[
patchi];
366 if (isA<cyclicPolyPatch>(patch))
368 const cyclicPolyPatch& cycPatch =
369 refCast<const cyclicPolyPatch>(patch);
372 nbrInfo.reserve(cycPatch.nPoints());
374 nbrPoints.reserve(cycPatch.nPoints());
376 thisPoints.reserve(cycPatch.nPoints());
380 const cyclicPolyPatch& nbrPatch = cycPatch.nbrPatch();
381 const edgeList& pairs = cycPatch.coupledPoints();
382 const labelList& meshPoints = nbrPatch.meshPoints();
386 label thisPointi = pairs[pairI][0];
387 label nbrPointi = pairs[pairI][1];
388 label meshPointi = meshPoints[nbrPointi];
390 if (changedPoint_[meshPointi])
392 nbrInfo.append(allPointInfo_[meshPointi]);
393 nbrPoints.append(nbrPointi);
394 thisPoints.append(thisPointi);
407 transform(cycPatch, thisPoints, cycPatch.transform(), nbrInfo);
410 const labelList& meshPoints = cycPatch.meshPoints();
413 label meshPointi = meshPoints[thisPoints[i]];
415 if (!allPointInfo_[meshPointi].
equal(nbrInfo[i], td_))
421 allPointInfo_[meshPointi]
432 template<
class Type,
class TrackingData>
436 const globalMeshData& gmd = mesh_.globalData();
438 const labelList& meshPoints = cpp.meshPoints();
440 const distributionMap& slavesMap = gmd.globalPointSlavesMap();
443 List<Type> elems(slavesMap.constructSize());
444 forAll(meshPoints, pointi)
446 elems[pointi] = allPointInfo_[meshPoints[pointi]];
451 slavesMap.distribute(elems,
false);
454 combineEqOp<Type, TrackingData> cop(td_);
458 Type& elem = elems[pointi];
460 const labelList& slavePoints = slaves[pointi];
465 cop(elem, elems[slavePoints[j]]);
471 elems[slavePoints[j]] = elem;
476 slavesMap.reverseDistribute(elems.size(), elems,
false);
479 forAll(meshPoints, pointi)
481 if (elems[pointi].
valid(td_))
483 label meshPointi = meshPoints[pointi];
485 Type& elem = allPointInfo_[meshPointi];
487 bool wasValid = elem.valid(td_);
492 if (!elem.equal(elems[pointi], td_))
495 elem = elems[pointi];
498 if (!wasValid && elem.valid(td_))
504 if (!changedPoint_[meshPointi])
506 changedPoint_[meshPointi] =
true;
507 changedPoints_[nChangedPoints_++] = meshPointi;
514 label totNChanged = nChangedPoints_;
516 reduce(totNChanged, sumOp<label>());
526 template<
class Type,
class TrackingData>
541 allPointInfo_(allPointInfo),
542 allEdgeInfo_(allEdgeInfo),
544 changedPoint_(mesh_.
nPoints(), false),
545 changedPoints_(mesh_.
nPoints()),
547 changedEdge_(mesh_.nEdges(), false),
548 changedEdges_(mesh_.nEdges()),
552 nUnvisitedPoints_(mesh_.
nPoints()),
553 nUnvisitedEdges_(mesh_.nEdges())
558 <<
"size of pointInfo work array is not equal to the number"
559 <<
" of points in the mesh" <<
endl
560 <<
" pointInfo :" << allPointInfo_.
size() <<
endl
561 <<
" mesh.nPoints:" << mesh_.
nPoints()
567 <<
"size of edgeInfo work array is not equal to the number"
568 <<
" of edges in the mesh" <<
endl
569 <<
" edgeInfo :" << allEdgeInfo_.
size() <<
endl
570 <<
" mesh.nEdges:" << mesh_.
nEdges()
580 Info<< typeName <<
": Seed points : "
587 if ((maxIter > 0) && (iter >= maxIter))
590 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl
591 <<
" maxIter:" << maxIter <<
endl
592 <<
" nChangedPoints:" << nChangedPoints_ <<
endl
593 <<
" nChangedEdges:" << nChangedEdges_ <<
endl
599 template<
class Type,
class TrackingData>
609 allPointInfo_(allPointInfo),
610 allEdgeInfo_(allEdgeInfo),
612 changedPoint_(mesh_.
nPoints(), false),
613 changedPoints_(mesh_.
nPoints()),
615 changedEdge_(mesh_.nEdges(), false),
616 changedEdges_(mesh_.nEdges()),
620 nUnvisitedPoints_(mesh_.
nPoints()),
621 nUnvisitedEdges_(mesh_.nEdges())
627 template<
class Type,
class TrackingData>
635 template<
class Type,
class TrackingData>
638 return nUnvisitedPoints_;
642 template<
class Type,
class TrackingData>
645 return nUnvisitedEdges_;
650 template<
class Type,
class TrackingData>
657 forAll(changedPoints, changedPointi)
659 label pointi = changedPoints[changedPointi];
661 bool wasValid = allPointInfo_[pointi].valid(td_);
664 allPointInfo_[pointi] = changedPointsInfo[changedPointi];
667 if (!wasValid && allPointInfo_[pointi].
valid(td_))
674 if (!changedPoint_[pointi])
676 changedPoint_[pointi] =
true;
677 changedPoints_[nChangedPoints_++] = pointi;
682 handleCollocatedPoints();
687 template<
class Type,
class TrackingData>
692 label changedEdgeI = 0;
693 changedEdgeI < nChangedEdges_;
697 label edgeI = changedEdges_[changedEdgeI];
699 if (!changedEdge_[edgeI])
703 <<
" not marked as having been changed" <<
nl
704 <<
"This might be caused by multiple occurrences of the same"
709 const Type& neighbourWallInfo = allEdgeInfo_[edgeI];
712 const edge&
e = mesh_.edges()[edgeI];
716 Type& currentWallInfo = allPointInfo_[
e[eI]];
718 if (!currentWallInfo.equal(neighbourWallInfo, td_))
731 changedEdge_[edgeI] =
false;
737 if (nCyclicPatches_ > 0)
740 handleCyclicPatches();
754 label totNChanged = nChangedPoints_;
763 template<
class Type,
class TrackingData>
770 label changedPointi = 0;
771 changedPointi < nChangedPoints_;
775 label pointi = changedPoints_[changedPointi];
777 if (!changedPoint_[pointi])
780 <<
"Point " << pointi
781 <<
" not marked as having been changed" <<
nl
782 <<
"This might be caused by multiple occurrences of the same"
786 const Type& neighbourWallInfo = allPointInfo_[pointi];
790 const labelList& edgeLabels = pointEdges[pointi];
791 forAll(edgeLabels, edgeLabelI)
793 label edgeI = edgeLabels[edgeLabelI];
795 Type& currentWallInfo = allEdgeInfo_[edgeI];
797 if (!currentWallInfo.equal(neighbourWallInfo, td_))
810 changedPoint_[pointi] =
false;
822 label totNChanged = nChangedEdges_;
831 template<
class Type,
class TrackingData>
837 if (nCyclicPatches_ > 0)
840 handleCyclicPatches();
852 while (iter < maxIter)
854 while (iter < maxIter)
858 Info<< typeName <<
": Iteration " << iter <<
endl;
861 label nEdges = pointToEdge();
865 Info<< typeName <<
": Total changed edges : "
878 Info<< typeName <<
": Total changed points : "
880 << typeName <<
": Total evaluations : "
882 << typeName <<
": Remaining unvisited points: "
884 << typeName <<
": Remaining unvisited edges : "
903 Info<< typeName <<
": Collocated point sync : "
Combination-Reduction operation for a parallel run. The information from all nodes is collected on th...
#define forAll(list, i)
Loop across all elements in list.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void reserve(const label)
Reserve allocation space for at least this size.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
void clear()
Clear the addressed list, i.e. set the size to zero.
Wave propagation of information through grid. Every iteration information goes through one layer of e...
label getUnsetPoints() const
void setPointInfo(const labelList &changedPoints, const List< Type > &changedPointsInfo)
Copy initial data into allPointInfo_.
PointEdgeWave(const polyMesh &mesh, const labelList &initialPoints, const List< Type > &initialPointsInfo, UList< Type > &allPointInfo, UList< Type > &allEdgeInfo, const label maxIter, TrackingData &td=defaultTrackingData_)
Construct from mesh, list of changed points with the Type.
label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
label pointToEdge()
Propagate from point to edge. Returns total number of edges.
label edgeToPoint()
Propagate from edge to point. Returns total number of points.
label getUnsetEdges() const
Get number of unvisited edges, i.e. edges that were not (yet)
~PointEdgeWave()
Destructor.
label nPoints() const
Return number of points supporting patch faces.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
label size() const
Return the number of elements in the UList.
static bool & parRun()
Is this a parallel run?
Reduction class. If x and y are not equal assign value.
combineEqOp(TrackingData &td)
void operator()(Type &x, const Type &y) const
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Mesh consisting of general polyhedral cells.
Neighbour processor patch.
int neighbProcNo() const
Return neighbour processor number.
const labelList & nbrPoints() const
Return neighbour point labels. WIP.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool valid(const PtrList< ModelType > &l)
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool equal(const T &s1, const T &s2)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
List< labelList > labelListList
A List of labelList.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensionSet transform(const dimensionSet &)
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...