45 template<
class Type,
class TrackingData>
59 if (!
x.valid(td_) &&
y.valid(td_))
71 template<
class Type,
class TrackingData>
74 const polyPatch&
patch,
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_);
93 template<
class Type,
class TrackingData>
96 const polyPatch&
patch,
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_);
115 template<
class Type,
class TrackingData>
118 const polyPatch&
patch,
120 List<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" 142 pointInfo[i].transform(rotTensor[i], td_);
153 template<
class Type,
class TrackingData>
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_))
199 template<
class Type,
class TrackingData>
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_))
243 template<
class Type,
class TrackingData>
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_))
285 template<
class Type,
class TrackingData>
286 template<
class PatchType>
291 for (
const polyPatch&
p : mesh_.boundaryMesh())
293 if (isA<PatchType>(
p))
303 template<
class Type,
class TrackingData>
332 for (
const label patchi : procPatches)
334 const auto& procPatch =
335 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
337 const label nbrProci = procPatch.neighbProcNo();
340 patchInfo.
reserve(procPatch.nPoints());
343 thisPoints.
reserve(procPatch.nPoints());
346 nbrPoints.
reserve(procPatch.nPoints());
349 const labelList& neighbPoints = procPatch.neighbPoints();
350 forAll(neighbPoints, thisPointi)
352 label meshPointi = procPatch.meshPoints()[thisPointi];
353 if (changedPoint_.test(meshPointi))
355 patchInfo.
append(allPointInfo_[meshPointi]);
356 thisPoints.
append(thisPointi);
357 nbrPoints.
append(neighbPoints[thisPointi]);
362 leaveDomain(procPatch, thisPoints, patchInfo);
365 if (!patchInfo.
empty())
367 const label nbrIndex = neighbourProcs.
find(nbrProci);
370 isActiveSend[nbrIndex] =
true;
376 UOPstream toNbr(nbrProci, pBufs_);
377 toNbr << nbrPoints << patchInfo;
389 forAll(neighbourProcs, nbrIndex)
391 if (!isActiveSend[nbrIndex])
393 pBufs_.clearSend(neighbourProcs[nbrIndex]);
398 pBufs_.finishedNeighbourSends(neighbourProcs);
405 for (
const label patchi : procPatches)
407 const auto& procPatch =
408 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
410 const label nbrProci = procPatch.neighbProcNo();
412 if (!pBufs_.recvDataCount(nbrProci))
419 List<Type> patchInfo;
421 UIPstream is(nbrProci, pBufs_);
422 is >> patchPoints >> patchInfo;
433 if (!procPatch.parallel())
435 transform(procPatch, procPatch.forwardT(), patchInfo);
439 enterDomain(procPatch, patchPoints, patchInfo);
442 const labelList& meshPoints = procPatch.meshPoints();
445 label meshPointi = meshPoints[patchPoints[i]];
447 if (!allPointInfo_[meshPointi].
equal(patchInfo[i], td_))
453 allPointInfo_[meshPointi]
466 template<
class Type,
class TrackingData>
471 DynamicList<Type> nbrInfo;
472 DynamicList<label> nbrPoints;
473 DynamicList<label> thisPoints;
475 for (
const polyPatch&
patch : mesh_.boundaryMesh())
477 const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(
patch);
481 const auto& cycPatch = *cpp;
482 const auto& nbrPatch = cycPatch.neighbPatch();
485 nbrInfo.reserve(cycPatch.nPoints());
487 nbrPoints.reserve(cycPatch.nPoints());
489 thisPoints.reserve(cycPatch.nPoints());
493 const edgeList& pairs = cycPatch.coupledPoints();
494 const labelList& meshPoints = nbrPatch.meshPoints();
498 label thisPointi = pairs[pairI][0];
499 label nbrPointi = pairs[pairI][1];
500 label meshPointi = meshPoints[nbrPointi];
502 if (changedPoint_.test(meshPointi))
504 nbrInfo.append(allPointInfo_[meshPointi]);
505 nbrPoints.append(nbrPointi);
506 thisPoints.append(thisPointi);
511 leaveDomain(nbrPatch, nbrPoints, nbrInfo);
517 if (!cycPatch.parallel())
520 transform(cycPatch, cycPatch.forwardT(), nbrInfo);
531 enterDomain(cycPatch, thisPoints, nbrInfo);
534 const labelList& meshPoints = cycPatch.meshPoints();
537 label meshPointi = meshPoints[thisPoints[i]];
539 if (!allPointInfo_[meshPointi].
equal(nbrInfo[i], td_))
545 allPointInfo_[meshPointi]
556 template<
class Type,
class TrackingData>
560 const globalMeshData& gmd = mesh_.globalData();
562 const labelList& meshPoints = cpp.meshPoints();
564 const mapDistribute& slavesMap = gmd.globalPointSlavesMap();
567 List<Type> elems(slavesMap.constructSize());
568 forAll(meshPoints, pointi)
570 elems[pointi] = allPointInfo_[meshPoints[pointi]];
575 slavesMap.distribute(elems,
false);
578 combineEqOp<Type, TrackingData> cop(td_);
582 Type& elem = elems[pointi];
584 const labelList& slavePoints = slaves[pointi];
589 cop(elem, elems[slavePoints[j]]);
595 elems[slavePoints[j]] = elem;
600 slavesMap.reverseDistribute(elems.size(), elems,
false);
603 forAll(meshPoints, pointi)
605 if (elems[pointi].valid(td_))
607 label meshPointi = meshPoints[pointi];
609 Type& elem = allPointInfo_[meshPointi];
611 bool wasValid = elem.valid(td_);
616 if (!elem.equal(elems[pointi], td_))
619 elem = elems[pointi];
622 if (!wasValid && elem.valid(td_))
628 if (changedPoint_.set(meshPointi))
630 changedPoints_.push_back(meshPointi);
645 template<
class Type,
class TrackingData>
661 allPointInfo_(allPointInfo),
662 allEdgeInfo_(allEdgeInfo),
670 <<
"size of pointInfo work array is not equal to the number" 671 <<
" of points in the mesh" <<
endl 672 <<
" pointInfo :" << allPointInfo_.
size() <<
endl 679 <<
"size of edgeInfo work array is not equal to the number" 680 <<
" of edges in the mesh" <<
endl 681 <<
" edgeInfo :" << allEdgeInfo_.
size() <<
endl 692 Info<< typeName <<
": Seed points : " 699 if ((maxIter > 0) && (iter >= maxIter))
702 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl 703 <<
" maxIter:" << maxIter <<
nl 711 template<
class Type,
class TrackingData>
722 allPointInfo_(allPointInfo),
723 allEdgeInfo_(allEdgeInfo),
733 template<
class Type,
class TrackingData>
740 forAll(changedPoints, changedPointi)
742 const label pointi = changedPoints[changedPointi];
744 const bool wasValid = allPointInfo_[pointi].valid(td_);
747 allPointInfo_[pointi] = changedPointsInfo[changedPointi];
750 if (!wasValid && allPointInfo_[pointi].valid(td_))
757 if (changedPoint_.set(pointi))
764 handleCollocatedPoints();
769 template<
class Type,
class TrackingData>
772 for (
const label edgei : changedEdges_)
774 if (!changedEdge_.test(edgei))
778 <<
" not marked as having been changed" <<
nl 779 <<
"This might be caused by multiple occurrences of the same" 784 const Type& neighbourWallInfo = allEdgeInfo_[edgei];
787 const edge&
e = mesh_.edges()[edgei];
791 Type& currentWallInfo = allPointInfo_[
e[eI]];
793 if (!currentWallInfo.equal(neighbourWallInfo, td_))
806 changedEdge_.unset(edgei);
810 changedEdges_.clear();
812 if (nCyclicPatches_ > 0)
815 handleCyclicPatches();
834 template<
class Type,
class TrackingData>
839 for (
const label pointi : changedPoints_)
841 if (!changedPoint_.test(pointi))
844 <<
"Point " << pointi
845 <<
" not marked as having been changed" <<
nl 846 <<
"This might be caused by multiple occurrences of the same" 850 const Type& neighbourWallInfo = allPointInfo_[pointi];
854 for (
const label edgei : pointEdges[pointi])
856 Type& currentWallInfo = allEdgeInfo_[edgei];
858 if (!currentWallInfo.equal(neighbourWallInfo, td_))
871 changedPoint_.unset(pointi);
875 changedPoints_.clear();
888 template<
class Type,
class TrackingData>
894 if (nCyclicPatches_ > 0)
897 handleCyclicPatches();
909 while (iter < maxIter)
911 while (iter < maxIter)
915 Info<< typeName <<
": Iteration " << iter <<
endl;
918 label nEdges = pointToEdge();
922 Info<< typeName <<
": Total changed edges : " 935 Info<< typeName <<
": Total changed points : " 937 << typeName <<
": Total evaluations : " 939 << typeName <<
": Remaining unvisited points: " 941 << typeName <<
": Remaining unvisited edges : " 957 label
nPoints = handleCollocatedPoints();
960 Info<< typeName <<
": Collocated point sync : "
void size(const label n)
Older name for setAddressableSize.
Reduction class. If x and y are not equal assign value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
List< edge > edgeList
List of edge.
label pointToEdge()
Propagate from point to edge. Returns total number of edges.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const polyMesh & mesh_
Reference to mesh.
const labelList & processorPatches() const noexcept
Return list of processor patch labels.
label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
label edgeToPoint()
Propagate from edge to point. Returns total number of points.
void setPointInfo(const labelList &changedPoints, const List< Type > &changedPointsInfo)
Copy initial data into allPointInfo_.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field...
combineEqOp(TrackingData &td)
void push_back(const T &val)
Append an element at the end of the list.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
List< labelList > labelListList
List of labelList.
#define forAll(list, i)
Loop across all elements in list.
const dimensionedScalar e
Elementary charge.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
void clear()
Clear the list, i.e. set size to zero.
label nChangedEdges() const noexcept
Current number of changed edges.
void append(const T &val)
Copy append an element to the end of this list.
errorManip< error > abort(error &err)
label nEdges() const
Number of mesh edges.
void reserve(const label len)
Reserve allocation space for at least this size, allocating new space if required and retaining old c...
int debug
Static debugging option.
void operator()(Type &x, const Type &y) const
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
const labelList & procNeighbours() const
The neighbour processor connections (ascending order) associated with the local rank.
vector point
Point is a vector.
const processorTopology & topology() const noexcept
The processor to processor topology.
const std::string patch
OpenFOAM patch number as a std::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
A patch is a list of labels that address the faces in the global face list.
Wave propagation of information through grid. Every iteration information goes through one layer of e...
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
label nChangedPoints() const noexcept
Current number of changed points.