45 template<
class Type,
class TrackingData>
59 if (!
x.valid(td_) &&
y.valid(td_))
71template<
class Type,
class TrackingData>
72void Foam::PointEdgeWave<Type, TrackingData>::leaveDomain
74 const polyPatch& patch,
75 const labelUList& patchPointLabels,
76 UList<Type>& pointInfo
81 forAll(patchPointLabels, i)
83 label patchPointi = patchPointLabels[i];
85 const point& pt =
patch.points()[meshPoints[patchPointi]];
87 pointInfo[i].leaveDomain(patch, patchPointi, pt, td_);
93template<
class Type,
class TrackingData>
94void Foam::PointEdgeWave<Type, TrackingData>::enterDomain
96 const polyPatch& patch,
97 const labelUList& patchPointLabels,
98 UList<Type>& pointInfo
103 forAll(patchPointLabels, i)
105 label patchPointi = patchPointLabels[i];
107 const point& pt =
patch.points()[meshPoints[patchPointi]];
109 pointInfo[i].enterDomain(patch, patchPointi, pt, td_);
115template<
class Type,
class TrackingData>
116void Foam::PointEdgeWave<Type, TrackingData>::transform
118 const polyPatch& patch,
119 const tensorField& rotTensor,
120 UList<Type>& pointInfo
123 if (rotTensor.size() == 1)
125 const tensor&
T = rotTensor[0];
129 pointInfo[i].transform(
T, td_);
135 <<
"Non-uniform transformation on patch " <<
patch.name()
136 <<
" of type " <<
patch.type()
137 <<
" not supported for point fields"
138 <<
abort(FatalError);
142 pointInfo[i].transform(rotTensor[i], td_);
153template<
class Type,
class TrackingData>
154bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
157 const label neighbourEdgeI,
158 const Type& neighbourInfo,
164 bool wasValid = pointInfo.valid(td_);
167 pointInfo.updatePoint
179 if (changedPoint_.set(pointi))
181 changedPoints_.push_back(pointi);
185 if (!wasValid && pointInfo.valid(td_))
199template<
class Type,
class TrackingData>
200bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
203 const Type& neighbourInfo,
209 bool wasValid = pointInfo.valid(td_);
212 pointInfo.updatePoint
223 if (changedPoint_.set(pointi))
225 changedPoints_.push_back(pointi);
229 if (!wasValid && pointInfo.valid(td_))
243template<
class Type,
class TrackingData>
244bool Foam::PointEdgeWave<Type, TrackingData>::updateEdge
247 const label neighbourPointi,
248 const Type& neighbourInfo,
254 bool wasValid = edgeInfo.valid(td_);
269 if (changedEdge_.set(edgei))
271 changedEdges_.push_back(edgei);
275 if (!wasValid && edgeInfo.valid(td_))
285template<
class Type,
class TrackingData>
286template<
class PatchType>
303template<
class Type,
class TrackingData>
304void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches()
323 pBufs_.initRegisterSend();
331 for (
const label patchi : procPatches)
333 const auto& procPatch =
336 const label nbrProci = procPatch.neighbProcNo();
339 patchInfo.
reserve(procPatch.nPoints());
342 thisPoints.
reserve(procPatch.nPoints());
345 nbrPoints.
reserve(procPatch.nPoints());
348 const labelList& neighbPoints = procPatch.neighbPoints();
349 forAll(neighbPoints, thisPointi)
351 label meshPointi = procPatch.meshPoints()[thisPointi];
352 if (changedPoint_.test(meshPointi))
354 patchInfo.
append(allPointInfo_[meshPointi]);
355 thisPoints.
append(thisPointi);
356 nbrPoints.
append(neighbPoints[thisPointi]);
361 leaveDomain(procPatch, thisPoints, patchInfo);
365 UOPstream toNbr(nbrProci, pBufs_);
366 toNbr << nbrPoints << patchInfo;
369 pBufs_.registerSend(nbrProci, !patchInfo.empty());
382 pBufs_.finishedNeighbourSends(neighbourProcs);
389 for (
const label patchi : procPatches)
391 const auto& procPatch =
392 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
394 const label nbrProci = procPatch.neighbProcNo();
396 if (!pBufs_.recvDataCount(nbrProci))
403 List<Type> patchInfo;
405 UIPstream is(nbrProci, pBufs_);
406 is >> patchPoints >> patchInfo;
417 if (!procPatch.parallel())
419 transform(procPatch, procPatch.forwardT(), patchInfo);
423 enterDomain(procPatch, patchPoints, patchInfo);
426 const labelList& meshPoints = procPatch.meshPoints();
429 label meshPointi = meshPoints[patchPoints[i]];
431 if (!allPointInfo_[meshPointi].
equal(patchInfo[i], td_))
437 allPointInfo_[meshPointi]
450template<
class Type,
class TrackingData>
451void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
455 DynamicList<Type> nbrInfo;
456 DynamicList<label> nbrPoints;
457 DynamicList<label> thisPoints;
459 for (
const polyPatch& patch : mesh_.boundaryMesh())
461 const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(patch);
465 const auto& cycPatch = *cpp;
466 const auto& nbrPatch = cycPatch.neighbPatch();
469 nbrInfo.reserve(cycPatch.nPoints());
471 nbrPoints.reserve(cycPatch.nPoints());
473 thisPoints.reserve(cycPatch.nPoints());
477 const edgeList& pairs = cycPatch.coupledPoints();
478 const labelList& meshPoints = nbrPatch.meshPoints();
482 label thisPointi = pairs[pairI][0];
483 label nbrPointi = pairs[pairI][1];
484 label meshPointi = meshPoints[nbrPointi];
486 if (changedPoint_.test(meshPointi))
488 nbrInfo.append(allPointInfo_[meshPointi]);
489 nbrPoints.append(nbrPointi);
490 thisPoints.append(thisPointi);
495 leaveDomain(nbrPatch, nbrPoints, nbrInfo);
501 if (!cycPatch.parallel())
504 transform(cycPatch, cycPatch.forwardT(), nbrInfo);
515 enterDomain(cycPatch, thisPoints, nbrInfo);
518 const labelList& meshPoints = cycPatch.meshPoints();
521 label meshPointi = meshPoints[thisPoints[i]];
523 if (!allPointInfo_[meshPointi].
equal(nbrInfo[i], td_))
529 allPointInfo_[meshPointi]
540template<
class Type,
class TrackingData>
541Foam::label Foam::PointEdgeWave<Type, TrackingData>::handleCollocatedPoints()
544 const globalMeshData& gmd = mesh_.globalData();
546 const labelList& meshPoints = cpp.meshPoints();
548 const mapDistribute& slavesMap = gmd.globalPointSlavesMap();
551 List<Type> elems(slavesMap.constructSize());
552 forAll(meshPoints, pointi)
554 elems[pointi] = allPointInfo_[meshPoints[pointi]];
559 slavesMap.distribute(elems,
false);
562 combineEqOp<Type, TrackingData> cop(td_);
566 Type& elem = elems[pointi];
568 const labelList& slavePoints = slaves[pointi];
573 cop(elem, elems[slavePoints[j]]);
579 elems[slavePoints[j]] = elem;
584 slavesMap.reverseDistribute(elems.size(), elems,
false);
587 forAll(meshPoints, pointi)
589 if (elems[pointi].valid(td_))
591 label meshPointi = meshPoints[pointi];
593 Type& elem = allPointInfo_[meshPointi];
595 bool wasValid = elem.valid(td_);
600 if (!elem.equal(elems[pointi], td_))
603 elem = elems[pointi];
606 if (!wasValid && elem.valid(td_))
612 if (changedPoint_.set(meshPointi))
614 changedPoints_.push_back(meshPointi);
629template<
class Type,
class TrackingData>
630Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
651 if (allPointInfo_.size() !=
mesh_.nPoints())
654 <<
"size of pointInfo work array is not equal to the number"
655 <<
" of points in the mesh" << endl
656 <<
" pointInfo :" << allPointInfo_.size() << endl
657 <<
" mesh.nPoints:" << mesh_.nPoints()
660 if (allEdgeInfo_.size() !=
mesh_.nEdges())
663 <<
"size of edgeInfo work array is not equal to the number"
664 <<
" of edges in the mesh" << endl
665 <<
" edgeInfo :" << allEdgeInfo_.size() << endl
666 <<
" mesh.nEdges:" << mesh_.nEdges()
683 if ((maxIter > 0) && (iter >= maxIter))
686 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl
687 <<
" maxIter:" << maxIter <<
nl
695template<
class Type,
class TrackingData>
696Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
698 const polyMesh&
mesh,
699 UList<Type>& allPointInfo,
700 UList<Type>& allEdgeInfo,
704 PointEdgeWaveBase(
mesh),
706 allPointInfo_(allPointInfo),
707 allEdgeInfo_(allEdgeInfo),
709 nCyclicPatches_(countPatchType<cyclicPolyPatch>()),
717template<
class Type,
class TrackingData>
724 forAll(changedPoints, changedPointi)
726 const label pointi = changedPoints[changedPointi];
728 const bool wasValid = allPointInfo_[pointi].valid(td_);
731 allPointInfo_[pointi] = changedPointsInfo[changedPointi];
734 if (!wasValid && allPointInfo_[pointi].valid(td_))
748 handleCollocatedPoints();
753template<
class Type,
class TrackingData>
756 for (
const label edgei : changedEdges_)
758 if (!changedEdge_.test(edgei))
762 <<
" not marked as having been changed" <<
nl
763 <<
"This might be caused by multiple occurrences of the same"
768 const Type& neighbourWallInfo = allEdgeInfo_[edgei];
771 const edge&
e = mesh_.edges()[edgei];
775 Type& currentWallInfo = allPointInfo_[
e[eI]];
777 if (!currentWallInfo.equal(neighbourWallInfo, td_))
790 changedEdge_.unset(edgei);
794 changedEdges_.clear();
796 if (nCyclicPatches_ > 0)
799 handleCyclicPatches();
818template<
class Type,
class TrackingData>
823 for (
const label pointi : changedPoints_)
825 if (!changedPoint_.test(pointi))
828 <<
"Point " << pointi
829 <<
" not marked as having been changed" <<
nl
830 <<
"This might be caused by multiple occurrences of the same"
834 const Type& neighbourWallInfo = allPointInfo_[pointi];
838 for (
const label edgei : pointEdges[pointi])
840 Type& currentWallInfo = allEdgeInfo_[edgei];
842 if (!currentWallInfo.equal(neighbourWallInfo, td_))
855 changedPoint_.unset(pointi);
859 changedPoints_.clear();
872template<
class Type,
class TrackingData>
878 if (nCyclicPatches_ > 0)
881 handleCyclicPatches();
893 while (iter < maxIter)
895 while (iter < maxIter)
902 label nEdges = pointToEdge();
921 <<
typeName <<
": Total evaluations : "
923 <<
typeName <<
": Remaining unvisited points: "
925 <<
typeName <<
": Remaining unvisited edges : "
941 label
nPoints = handleCollocatedPoints();
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)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
void clear()
Clear the list, i.e. set size to zero.
PointEdgeWaveBase(const polyMesh &mesh)
Construct with mesh reference and set initial sizes.
bitSet changedPoint_
Track if point has changed.
DynamicList< label > changedPoints_
List of changed points.
DynamicList< label > changedEdges_
List of changed edges.
label nChangedEdges() const noexcept
Current number of changed edges.
label nChangedPoints() const noexcept
Current number of changed points.
label nUnvisitedEdges_
Number of unvisited edges.
bitSet changedEdge_
Track if edge has changed.
const polyMesh & mesh() const noexcept
Return access to the mesh.
label nUnvisitedPoints_
Number of unvisited points.
const polyMesh & mesh_
Reference to mesh.
UList< Type > & allEdgeInfo() const noexcept
Access allEdgeInfo.
UList< Type > & allPointInfo() const noexcept
Access allPointInfo.
Foam::label countPatchType() const
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.
void setPointInfo(const labelList &changedPoints, const UList< Type > &changedPointsInfo)
Copy initial data into allPointInfo_.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static bool & parRun() noexcept
Test if this a parallel run.
combineEqOp(TrackingData &td)
void operator()(Type &x, const Type &y) const
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const labelList & processorPatches() const noexcept
Return list of processor patch labels.
const processorTopology & topology() const noexcept
The processor to processor topology.
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
const labelList & procNeighbours() const
The neighbour processor connections (ascending order) associated with the local rank.
Tensor of scalars, i.e. Tensor<scalar>.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
return returnReduce(nRefine-oldNRefine, sumOp< label >())
bool equal(const UList< Type1 > &a, const UList< Type2 > &b)
Test for list equality with different but compatible data types. Eg, int32 and int64.
Namespace for handling debugging switches.
const std::string patch
OpenFOAM patch number as a std::string.
List< edge > edgeList
List of edge.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
messageStream Info
Information stream (stdout output on master, null elsewhere).
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
errorManip< error > abort(error &err)
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...