39 template<
class Type,
class TrackingData>
42 template<
class Type,
class TrackingData>
49 template<
class Type,
class TrackingData>
62 if (!
x.valid(td_) &&
y.valid(td_))
73 template<
class Type,
class TrackingData>
76 const polyPatch& patch,
84 pointInfo[i].transform(patch, patchPointLabels[i],
transform, td_);
89 template<
class Type,
class TrackingData>
93 const label neighbourEdgeI,
94 const Type& neighbourInfo,
106 bool wasValid = pointInfo.valid(td_);
109 pointInfo.updatePoint
121 if (!changedPoint_[pointi])
123 changedPoint_[pointi] =
true;
124 changedPoints_[nChangedPoints_++] = pointi;
128 if (!wasValid && pointInfo.valid(td_))
137 template<
class Type,
class TrackingData>
141 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_))
183 template<
class Type,
class TrackingData>
187 const label neighbourPointi,
188 const Type& neighbourInfo,
200 bool wasValid = edgeInfo.valid(td_);
215 if (!changedEdge_[edgeI])
217 changedEdge_[edgeI] =
true;
218 changedEdges_[nChangedEdges_++] = edgeI;
222 if (!wasValid && edgeInfo.valid(td_))
231 template<
class Type,
class TrackingData>
232 template<
class PatchType>
239 if (isA<PatchType>(mesh_.boundary()[
patchi]))
248 template<
class Type,
class TrackingData>
259 forAll(mesh_.globalData().processorPatches(), i)
261 label patchi = mesh_.globalData().processorPatches()[i];
263 refCast<const processorPolyPatch>(mesh_.boundary()[
patchi]);
274 forAll(neighbPoints, thisPointi)
277 if (changedPoint_[meshPointi])
279 patchInfo.
append(allPointInfo_[meshPointi]);
280 thisPoints.
append(thisPointi);
281 nbrPoints.
append(neighbPoints[thisPointi]);
293 toNeighbour << nbrPoints << patchInfo;
297 pBufs.finishedSends();
303 forAll(mesh_.globalData().processorPatches(), i)
305 label patchi = mesh_.globalData().processorPatches()[i];
306 const processorPolyPatch& procPatch =
307 refCast<const processorPolyPatch>(mesh_.boundary()[
patchi]);
313 UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs);
314 fromNeighbour >> patchPoints >> patchInfo;
325 transform(procPatch, patchPoints, procPatch.transform(), patchInfo);
328 const labelList& meshPoints = procPatch.meshPoints();
331 label meshPointi = meshPoints[patchPoints[i]];
333 if (!allPointInfo_[meshPointi].
equal(patchInfo[i], td_))
339 allPointInfo_[meshPointi]
352 template<
class Type,
class TrackingData>
357 DynamicList<Type> nbrInfo;
358 DynamicList<label> nbrPoints;
359 DynamicList<label> thisPoints;
363 const polyPatch& patch = mesh_.boundary()[
patchi];
365 if (isA<cyclicPolyPatch>(patch))
367 const cyclicPolyPatch& cycPatch =
368 refCast<const cyclicPolyPatch>(patch);
371 nbrInfo.reserve(cycPatch.nPoints());
373 nbrPoints.reserve(cycPatch.nPoints());
375 thisPoints.reserve(cycPatch.nPoints());
379 const cyclicPolyPatch& nbrPatch = cycPatch.nbrPatch();
380 const edgeList& pairs = cycPatch.coupledPoints();
381 const labelList& meshPoints = nbrPatch.meshPoints();
385 label thisPointi = pairs[pairI][0];
386 label nbrPointi = pairs[pairI][1];
387 label meshPointi = meshPoints[nbrPointi];
389 if (changedPoint_[meshPointi])
391 nbrInfo.append(allPointInfo_[meshPointi]);
392 nbrPoints.append(nbrPointi);
393 thisPoints.append(thisPointi);
406 transform(cycPatch, thisPoints, cycPatch.transform(), nbrInfo);
409 const labelList& meshPoints = cycPatch.meshPoints();
412 label meshPointi = meshPoints[thisPoints[i]];
414 if (!allPointInfo_[meshPointi].
equal(nbrInfo[i], td_))
420 allPointInfo_[meshPointi]
429 template<
class Type,
class TrackingData>
433 const globalMeshData& gmd = mesh_.globalData();
435 const labelList& meshPoints = cpp.meshPoints();
437 const distributionMap& slavesMap = gmd.globalPointSlavesMap();
441 forAll(meshPoints, pointi)
443 elems[pointi] = allPointInfo_[meshPoints[pointi]];
448 slavesMap.distribute(elems,
false);
451 combineEqOp<Type, TrackingData> cop(td_);
455 Type& elem = elems[pointi];
457 const labelList& slavePoints = slaves[pointi];
462 cop(elem, elems[slavePoints[j]]);
468 elems[slavePoints[j]] = elem;
473 slavesMap.reverseDistribute(elems.size(), elems,
false);
476 forAll(meshPoints, pointi)
478 if (elems[pointi].
valid(td_))
480 label meshPointi = meshPoints[pointi];
482 Type& elem = allPointInfo_[meshPointi];
484 bool wasValid = elem.valid(td_);
489 if (!elem.equal(elems[pointi], td_))
492 elem = elems[pointi];
495 if (!wasValid && elem.valid(td_))
501 if (!changedPoint_[meshPointi])
503 changedPoint_[meshPointi] =
true;
504 changedPoints_[nChangedPoints_++] = meshPointi;
511 label totNChanged = nChangedPoints_;
513 reduce(totNChanged, sumOp<label>());
521 template<
class Type,
class TrackingData>
536 allPointInfo_(allPointInfo),
537 allEdgeInfo_(allEdgeInfo),
539 changedPoint_(mesh_.
nPoints(), false),
540 changedPoints_(mesh_.
nPoints()),
542 changedEdge_(mesh_.nEdges(), false),
543 changedEdges_(mesh_.nEdges()),
547 nUnvisitedPoints_(mesh_.
nPoints()),
548 nUnvisitedEdges_(mesh_.nEdges())
553 <<
"size of pointInfo work array is not equal to the number"
554 <<
" of points in the mesh" <<
endl
555 <<
" pointInfo :" << allPointInfo_.
size() <<
endl
556 <<
" mesh.nPoints:" << mesh_.
nPoints()
562 <<
"size of edgeInfo work array is not equal to the number"
563 <<
" of edges in the mesh" <<
endl
564 <<
" edgeInfo :" << allEdgeInfo_.
size() <<
endl
565 <<
" mesh.nEdges:" << mesh_.
nEdges()
582 if ((maxIter > 0) && (iter >= maxIter))
585 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl
586 <<
" maxIter:" << maxIter <<
endl
587 <<
" nChangedPoints:" << nChangedPoints_ <<
endl
588 <<
" nChangedEdges:" << nChangedEdges_ <<
endl
594 template<
class Type,
class TrackingData>
604 allPointInfo_(allPointInfo),
605 allEdgeInfo_(allEdgeInfo),
607 changedPoint_(mesh_.
nPoints(), false),
608 changedPoints_(mesh_.
nPoints()),
610 changedEdge_(mesh_.nEdges(), false),
611 changedEdges_(mesh_.nEdges()),
615 nUnvisitedPoints_(mesh_.
nPoints()),
616 nUnvisitedEdges_(mesh_.nEdges())
622 template<
class Type,
class TrackingData>
630 template<
class Type,
class TrackingData>
633 return nUnvisitedPoints_;
637 template<
class Type,
class TrackingData>
640 return nUnvisitedEdges_;
645 template<
class Type,
class TrackingData>
652 forAll(startPoints, startPointi)
654 label pointi = startPoints[startPointi];
656 bool wasValid = allPointInfo_[pointi].valid(td_);
659 allPointInfo_[pointi] = startPointsInfo[startPointi];
662 if (!wasValid && allPointInfo_[pointi].
valid(td_))
669 if (!changedPoint_[pointi])
671 changedPoint_[pointi] =
true;
672 changedPoints_[nChangedPoints_++] = pointi;
677 handleCollocatedPoints();
681 template<
class Type,
class TrackingData>
686 label changedEdgeI = 0;
687 changedEdgeI < nChangedEdges_;
691 label edgeI = changedEdges_[changedEdgeI];
693 if (!changedEdge_[edgeI])
697 <<
" not marked as having been changed" <<
nl
698 <<
"This might be caused by multiple occurrences of the same"
703 const Type& neighbourWallInfo = allEdgeInfo_[edgeI];
706 const edge&
e = mesh_.edges()[edgeI];
710 Type& currentWallInfo = allPointInfo_[
e[eI]];
712 if (!currentWallInfo.equal(neighbourWallInfo, td_))
725 changedEdge_[edgeI] =
false;
731 if (nCyclicPatches_ > 0)
734 handleCyclicPatches();
743 label totNChanged = nChangedPoints_;
751 template<
class Type,
class TrackingData>
758 label changedPointi = 0;
759 changedPointi < nChangedPoints_;
763 label pointi = changedPoints_[changedPointi];
765 if (!changedPoint_[pointi])
768 <<
"Point " << pointi
769 <<
" not marked as having been changed" <<
nl
770 <<
"This might be caused by multiple occurrences of the same"
774 const Type& neighbourWallInfo = allPointInfo_[pointi];
778 const labelList& edgeLabels = pointEdges[pointi];
779 forAll(edgeLabels, edgeLabelI)
781 label edgeI = edgeLabels[edgeLabelI];
783 Type& currentWallInfo = allEdgeInfo_[edgeI];
785 if (!currentWallInfo.equal(neighbourWallInfo, td_))
798 changedPoint_[pointi] =
false;
810 label totNChanged = nChangedEdges_;
818 template<
class Type,
class TrackingData>
824 if (nCyclicPatches_ > 0)
827 handleCyclicPatches();
839 while (iter < maxIter)
841 while (iter < maxIter)
848 label nEdges = pointToEdge();
867 <<
typeName <<
": Total evaluations : "
869 <<
typeName <<
": Remaining unvisited points: "
871 <<
typeName <<
": Remaining unvisited edges : "
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.
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 &startPoints, const List< Type > &startPointsInfo)
Copy start data into allPointInfo_.
PointEdgeWave(const polyMesh &mesh, const labelList &startPoints, const List< Type > &startPointsInfo, 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...
Motion of the mesh specified as a list of pointMeshMovers.
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.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#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.
void transform(GeometricField< Type, GeoMesh > &rtf, const GeometricField< tensor, GeoMesh > &trf, const GeometricField< Type, GeoMesh > &tf)
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)
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...