42template<
class Type,
class TrackingData>
45template<
class Type,
class TrackingData>
51 template<
class Type,
class TrackingData>
65 if (!
x.valid(td_) &&
y.valid(td_))
77template<
class Type,
class TrackingData>
80 const polyPatch& patch,
81 const labelList& patchPointLabels,
87 forAll(patchPointLabels, i)
89 label patchPointi = patchPointLabels[i];
91 const point& pt =
patch.points()[meshPoints[patchPointi]];
93 pointInfo[i].leaveDomain(patch, patchPointi, pt, td_);
99template<
class Type,
class TrackingData>
102 const polyPatch& patch,
103 const labelList& patchPointLabels,
104 List<Type>& pointInfo
109 forAll(patchPointLabels, i)
111 label patchPointi = patchPointLabels[i];
113 const point& pt =
patch.points()[meshPoints[patchPointi]];
115 pointInfo[i].enterDomain(patch, patchPointi, pt, td_);
121template<
class Type,
class TrackingData>
124 const polyPatch& patch,
125 const tensorField& rotTensor,
126 List<Type>& pointInfo
129 if (rotTensor.size() == 1)
131 const tensor&
T = rotTensor[0];
135 pointInfo[i].transform(
T, td_);
141 <<
"Non-uniform transformation on patch " <<
patch.name()
142 <<
" of type " <<
patch.type()
143 <<
" not supported for point fields"
144 <<
abort(FatalError);
148 pointInfo[i].transform(rotTensor[i], td_);
159template<
class Type,
class TrackingData>
163 const label neighbourEdgeI,
164 const Type& neighbourInfo,
170 bool wasValid = pointInfo.valid(td_);
173 pointInfo.updatePoint
185 if (!changedPoint_[pointi])
187 changedPoint_[pointi] =
true;
188 changedPoints_[nChangedPoints_++] = pointi;
192 if (!wasValid && pointInfo.valid(td_))
206template<
class Type,
class TrackingData>
210 const Type& neighbourInfo,
216 bool wasValid = pointInfo.valid(td_);
219 pointInfo.updatePoint
230 if (!changedPoint_[pointi])
232 changedPoint_[pointi] =
true;
233 changedPoints_[nChangedPoints_++] = pointi;
237 if (!wasValid && pointInfo.valid(td_))
251template<
class Type,
class TrackingData>
255 const label neighbourPointi,
256 const Type& neighbourInfo,
262 bool wasValid = edgeInfo.valid(td_);
277 if (!changedEdge_[edgeI])
279 changedEdge_[edgeI] =
true;
280 changedEdges_[nChangedEdges_++] = edgeI;
284 if (!wasValid && edgeInfo.valid(td_))
294template<
class Type,
class TrackingData>
295template<
class PatchType>
300 forAll(mesh_.boundaryMesh(), patchi)
302 if (isA<PatchType>(mesh_.boundaryMesh()[patchi]))
312template<
class Type,
class TrackingData>
323 forAll(mesh_.globalData().processorPatches(), i)
325 label patchi = mesh_.globalData().processorPatches()[i];
327 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
338 forAll(neighbPoints, thisPointi)
340 label meshPointi = procPatch.
meshPoints()[thisPointi];
341 if (changedPoint_[meshPointi])
343 patchInfo.
append(allPointInfo_[meshPointi]);
344 thisPoints.
append(thisPointi);
345 nbrPoints.
append(neighbPoints[thisPointi]);
350 leaveDomain(procPatch, thisPoints, patchInfo);
360 toNeighbour << nbrPoints << patchInfo;
364 pBufs.finishedSends();
370 forAll(mesh_.globalData().processorPatches(), i)
372 label patchi = mesh_.globalData().processorPatches()[i];
373 const processorPolyPatch& procPatch =
374 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
376 List<Type> patchInfo;
380 UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs);
381 fromNeighbour >> patchPoints >> patchInfo;
392 if (!procPatch.parallel())
394 transform(procPatch, procPatch.forwardT(), patchInfo);
398 enterDomain(procPatch, patchPoints, patchInfo);
401 const labelList& meshPoints = procPatch.meshPoints();
404 label meshPointi = meshPoints[patchPoints[i]];
406 if (!allPointInfo_[meshPointi].
equal(patchInfo[i], td_))
412 allPointInfo_[meshPointi]
425template<
class Type,
class TrackingData>
430 DynamicList<Type> nbrInfo;
431 DynamicList<label> nbrPoints;
432 DynamicList<label> thisPoints;
434 forAll(mesh_.boundaryMesh(), patchi)
436 const polyPatch&
patch = mesh_.boundaryMesh()[patchi];
438 const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(patch);
442 const auto& cycPatch = *cpp;
443 const auto& nbrPatch = cycPatch.neighbPatch();
446 nbrInfo.reserve(cycPatch.nPoints());
448 nbrPoints.reserve(cycPatch.nPoints());
450 thisPoints.reserve(cycPatch.nPoints());
454 const edgeList& pairs = cycPatch.coupledPoints();
455 const labelList& meshPoints = nbrPatch.meshPoints();
459 label thisPointi = pairs[pairI][0];
460 label nbrPointi = pairs[pairI][1];
461 label meshPointi = meshPoints[nbrPointi];
463 if (changedPoint_[meshPointi])
465 nbrInfo.append(allPointInfo_[meshPointi]);
466 nbrPoints.append(nbrPointi);
467 thisPoints.append(thisPointi);
472 leaveDomain(nbrPatch, nbrPoints, nbrInfo);
478 if (!cycPatch.parallel())
481 transform(cycPatch, cycPatch.forwardT(), nbrInfo);
492 enterDomain(cycPatch, thisPoints, nbrInfo);
495 const labelList& meshPoints = cycPatch.meshPoints();
498 label meshPointi = meshPoints[thisPoints[i]];
500 if (!allPointInfo_[meshPointi].
equal(nbrInfo[i], td_))
506 allPointInfo_[meshPointi]
517template<
class Type,
class TrackingData>
521 const globalMeshData& gmd = mesh_.globalData();
523 const labelList& meshPoints = cpp.meshPoints();
525 const mapDistribute& slavesMap = gmd.globalPointSlavesMap();
528 List<Type> elems(slavesMap.constructSize());
529 forAll(meshPoints, pointi)
531 elems[pointi] = allPointInfo_[meshPoints[pointi]];
536 slavesMap.distribute(elems,
false);
539 combineEqOp<Type, TrackingData> cop(td_);
543 Type& elem = elems[pointi];
545 const labelList& slavePoints = slaves[pointi];
550 cop(elem, elems[slavePoints[j]]);
556 elems[slavePoints[j]] = elem;
561 slavesMap.reverseDistribute(elems.size(), elems,
false);
564 forAll(meshPoints, pointi)
566 if (elems[pointi].valid(td_))
568 label meshPointi = meshPoints[pointi];
570 Type& elem = allPointInfo_[meshPointi];
572 bool wasValid = elem.valid(td_);
577 if (!elem.equal(elems[pointi], td_))
580 elem = elems[pointi];
583 if (!wasValid && elem.valid(td_))
589 if (!changedPoint_[meshPointi])
591 changedPoint_[meshPointi] =
true;
592 changedPoints_[nChangedPoints_++] = meshPointi;
599 label totNChanged = nChangedPoints_;
601 reduce(totNChanged, sumOp<label>());
611template<
class Type,
class TrackingData>
626 allPointInfo_(allPointInfo),
627 allEdgeInfo_(allEdgeInfo),
629 changedPoint_(mesh_.
nPoints(), false),
630 changedPoints_(mesh_.
nPoints()),
632 changedEdge_(mesh_.
nEdges(), false),
633 changedEdges_(mesh_.
nEdges()),
637 nUnvisitedPoints_(mesh_.
nPoints()),
638 nUnvisitedEdges_(mesh_.
nEdges())
643 <<
"size of pointInfo work array is not equal to the number"
644 <<
" of points in the mesh" <<
endl
645 <<
" pointInfo :" << allPointInfo_.
size() <<
endl
646 <<
" mesh.nPoints:" << mesh_.
nPoints()
652 <<
"size of edgeInfo work array is not equal to the number"
653 <<
" of edges in the mesh" <<
endl
654 <<
" edgeInfo :" << allEdgeInfo_.
size() <<
endl
655 <<
" mesh.nEdges:" << mesh_.
nEdges()
665 Info<< typeName <<
": Seed points : "
672 if ((maxIter > 0) && (iter >= maxIter))
675 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl
676 <<
" maxIter:" << maxIter <<
endl
677 <<
" nChangedPoints:" << nChangedPoints_ <<
endl
678 <<
" nChangedEdges:" << nChangedEdges_ <<
endl
684template<
class Type,
class TrackingData>
694 allPointInfo_(allPointInfo),
695 allEdgeInfo_(allEdgeInfo),
697 changedPoint_(mesh_.
nPoints(), false),
698 changedPoints_(mesh_.
nPoints()),
700 changedEdge_(mesh_.
nEdges(), false),
701 changedEdges_(mesh_.
nEdges()),
705 nUnvisitedPoints_(mesh_.
nPoints()),
706 nUnvisitedEdges_(mesh_.
nEdges())
712template<
class Type,
class TrackingData>
715 return nUnvisitedPoints_;
719template<
class Type,
class TrackingData>
722 return nUnvisitedEdges_;
727template<
class Type,
class TrackingData>
734 forAll(changedPoints, changedPointi)
736 const label pointi = changedPoints[changedPointi];
738 const bool wasValid = allPointInfo_[pointi].valid(td_);
741 allPointInfo_[pointi] = changedPointsInfo[changedPointi];
744 if (!wasValid && allPointInfo_[pointi].valid(td_))
751 if (!changedPoint_[pointi])
753 changedPoint_[pointi] =
true;
754 changedPoints_[nChangedPoints_++] = pointi;
759 handleCollocatedPoints();
764template<
class Type,
class TrackingData>
769 label changedEdgeI = 0;
770 changedEdgeI < nChangedEdges_;
774 label edgeI = changedEdges_[changedEdgeI];
776 if (!changedEdge_[edgeI])
780 <<
" not marked as having been changed" <<
nl
781 <<
"This might be caused by multiple occurrences of the same"
786 const Type& neighbourWallInfo = allEdgeInfo_[edgeI];
789 const edge&
e = mesh_.edges()[edgeI];
793 Type& currentWallInfo = allPointInfo_[
e[eI]];
795 if (!currentWallInfo.equal(neighbourWallInfo, td_))
808 changedEdge_[edgeI] =
false;
814 if (nCyclicPatches_ > 0)
817 handleCyclicPatches();
831 label totNChanged = nChangedPoints_;
840template<
class Type,
class TrackingData>
847 label changedPointi = 0;
848 changedPointi < nChangedPoints_;
852 label pointi = changedPoints_[changedPointi];
854 if (!changedPoint_[pointi])
857 <<
"Point " << pointi
858 <<
" not marked as having been changed" <<
nl
859 <<
"This might be caused by multiple occurrences of the same"
863 const Type& neighbourWallInfo = allPointInfo_[pointi];
867 const labelList& edgeLabels = pointEdges[pointi];
868 forAll(edgeLabels, edgeLabelI)
870 label edgeI = edgeLabels[edgeLabelI];
872 Type& currentWallInfo = allEdgeInfo_[edgeI];
874 if (!currentWallInfo.equal(neighbourWallInfo, td_))
887 changedPoint_[pointi] =
false;
899 label totNChanged = nChangedEdges_;
908template<
class Type,
class TrackingData>
914 if (nCyclicPatches_ > 0)
917 handleCyclicPatches();
929 while (iter < maxIter)
931 while (iter < maxIter)
935 Info<< typeName <<
": Iteration " << iter <<
endl;
938 label
nEdges = pointToEdge();
942 Info<< typeName <<
": Total changed edges : "
955 Info<< typeName <<
": Total changed points : "
957 << typeName <<
": Total evaluations : "
959 << typeName <<
": Remaining unvisited points: "
961 << typeName <<
": Remaining unvisited edges : "
977 label
nPoints = handleCollocatedPoints();
980 Info<< typeName <<
": Collocated point sync : "
reduce(hasMovingMesh, orOp< bool >())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
void reserve(const label len)
Wave propagation of information through grid. Every iteration information goes through one layer of e...
label nUnvisitedEdges() const
Number of unvisited edges, i.e. edges that were not (yet)
void setPointInfo(const labelList &changedPoints, const List< Type > &changedPointsInfo)
Copy initial data into allPointInfo_.
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 nUnvisitedPoints() const
label nPoints() const
Number of points supporting patch faces.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
static bool & parRun() noexcept
Test if 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.
label nPoints() const noexcept
Number of mesh points.
label nEdges() const
Number of mesh edges.
Neighbour processor patch.
int neighbProcNo() const
Return neighbour processor number.
const labelList & neighbPoints() const
Return neighbour point labels. WIP.
Tensor of scalars, i.e. Tensor<scalar>.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelList nEdges(UPstream::listGatherValues< label >(aMesh.nEdges()))
const std::string patch
OpenFOAM patch number as a std::string.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere)
vector point
Point is a vector.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< labelList > labelListList
A List of labelList.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
errorManip< error > abort(error &err)
List< edge > edgeList
A List of edges.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.