46 template<
class Type,
class TrackingData>
76 if (
y.valid(solver_.
data()))
81 meshFacei = patch_.
start() + facei;
103 template<
class Type,
class TrackingData>
107 const label neighbourFacei,
108 const Type& neighbourInfo,
123 const bool propagate =
136 if (changedCell_.set(celli))
138 changedCells_.push_back(celli);
151 template<
class Type,
class TrackingData>
155 const label neighbourCelli,
156 const Type& neighbourInfo,
169 const bool wasValid = faceInfo.valid(td_);
171 const bool propagate =
184 if (changedFace_.set(facei))
186 changedFaces_.push_back(facei);
190 if (!wasValid && faceInfo.valid(td_))
199 template<
class Type,
class TrackingData>
203 const Type& neighbourInfo,
216 const bool wasValid = faceInfo.valid(td_);
218 const bool propagate =
230 if (changedFace_.set(facei))
232 changedFaces_.push_back(facei);
236 if (!wasValid && faceInfo.valid(td_))
245 template<
class Type,
class TrackingData>
254 refCast<const cyclicPolyPatch>(
patch).neighbPatch();
258 const label i1 =
patch.start() + patchFacei;
259 const label i2 = nbrPatch.
start() + patchFacei;
263 !allFaceInfo_[i1].sameGeometry
273 <<
" faceInfo:" << allFaceInfo_[i1]
274 <<
" otherfaceInfo:" << allFaceInfo_[i2]
278 if (changedFace_.test(i1) != changedFace_.test(i2))
281 <<
" faceInfo:" << allFaceInfo_[i1]
282 <<
" otherfaceInfo:" << allFaceInfo_[i2]
283 <<
" changedFace:" << changedFace_.test(i1)
284 <<
" otherchangedFace:" << changedFace_.test(i2)
291 template<
class Type,
class TrackingData>
292 template<
class PatchType>
295 for (
const polyPatch&
p : mesh_.boundaryMesh())
297 if (isA<PatchType>(
p))
306 template<
class Type,
class TrackingData>
313 const bool wasValid = allFaceInfo_[facei].valid(td_);
316 allFaceInfo_[facei] = faceInfo;
319 if (!wasValid && allFaceInfo_[facei].valid(td_))
325 changedFace_.set(facei);
326 changedFaces_.push_back(facei);
330 template<
class Type,
class TrackingData>
337 forAll(changedFaces, changedFacei)
339 const label facei = changedFaces[changedFacei];
341 const bool wasValid = allFaceInfo_[facei].valid(td_);
344 allFaceInfo_[facei] = changedFacesInfo[changedFacei];
347 if (!wasValid && allFaceInfo_[facei].valid(td_))
353 changedFace_.
set(facei);
354 changedFaces_.push_back(facei);
359 template<
class Type,
class TrackingData>
370 for (label changedFacei = 0; changedFacei < nFaces; ++changedFacei)
372 const Type& newInfo = changedFacesInfo[changedFacei];
373 const label patchFacei = changedFaces[changedFacei];
375 const label meshFacei =
patch.start() + patchFacei;
377 Type& currInfo = allFaceInfo_[meshFacei];
379 if (!currInfo.equal(newInfo, td_))
393 template<
class Type,
class TrackingData>
397 const label startFacei,
408 for (label i = 0; i < nFaces; ++i)
410 const label patchFacei = i + startFacei;
411 const label meshFacei =
patch.start() + patchFacei;
413 if (changedFace_.test(meshFacei))
415 changedPatchFaces[nChanged] = patchFacei;
416 changedPatchFacesInfo[nChanged] = allFaceInfo_[meshFacei];
425 template<
class Type,
class TrackingData>
438 for (label i = 0; i < nFaces; ++i)
440 const label patchFacei = faceLabels[i];
441 const label meshFacei =
patch.start() + patchFacei;
443 faceInfo[i].leaveDomain(mesh_,
patch, patchFacei, fc[meshFacei], td_);
448 template<
class Type,
class TrackingData>
461 for (label i = 0; i < nFaces; ++i)
463 const label patchFacei = faceLabels[i];
464 const label meshFacei =
patch.start() + patchFacei;
466 faceInfo[i].enterDomain(mesh_,
patch, patchFacei, fc[meshFacei], td_);
471 template<
class Type,
class TrackingData>
481 if (rotTensor.
size() == 1)
483 const tensor&
T = rotTensor[0];
485 for (label facei = 0; facei < nFaces; ++facei)
487 faceInfo[facei].transform(mesh_,
T, td_);
492 for (label facei = 0; facei < nFaces; ++facei)
494 faceInfo[facei].transform(mesh_, rotTensor[facei], td_);
500 template<
class Type,
class TrackingData>
504 const label cycOffset,
512 for (label facei = 0; facei < nFaces; ++facei)
514 faces[facei] += cycOffset;
519 template<
class Type,
class TrackingData>
524 const globalMeshData& pData = mesh_.globalData();
527 const labelList& procPatches = pData.processorPatches();
531 PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
533 for (
const label patchi : procPatches)
535 const processorPolyPatch& procPatch =
536 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
541 List<Type> sendFacesInfo(procPatch.size());
544 nSendFaces = getChangedPatchFaces
564 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
565 <<
" communicating with " << procPatch.neighbProcNo()
566 <<
" Sending:" << nSendFaces
570 UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs);
573 << SubList<label>(sendFaces, nSendFaces)
574 << SubList<Type>(sendFacesInfo, nSendFaces);
577 pBufs.finishedSends();
581 for (
const label patchi : procPatches)
583 const processorPolyPatch& procPatch =
584 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
588 List<Type> receiveFacesInfo;
591 UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs);
592 fromNeighbour >> receiveFaces >> receiveFacesInfo;
597 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
598 <<
" communicating with " << procPatch.neighbProcNo()
599 <<
" Receiving:" << receiveFaces.size()
604 if (!procPatch.parallel())
608 procPatch.forwardT(),
635 template<
class Type,
class TrackingData>
640 for (
const polyPatch&
patch : mesh_.boundaryMesh())
642 const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(
patch);
646 const auto& cycPatch = *cpp;
647 const auto& nbrPatch = cycPatch.neighbPatch();
652 List<Type> receiveFacesInfo(
patch.size());
655 nReceiveFaces = getChangedPatchFaces
673 if (!cycPatch.parallel())
686 Pout<<
" Cyclic patch " 687 << cycPatch.index() <<
' ' << cycPatch.
name()
688 <<
" Changed : " << nReceiveFaces
712 checkCyclic(cycPatch);
719 template<
class Type,
class TrackingData>
724 for (
const polyPatch&
patch : mesh_.boundaryMesh())
726 const cyclicAMIPolyPatch* cpp = isA<cyclicAMIPolyPatch>(
patch);
730 const auto& cycPatch = *cpp;
731 const auto& nbrPatch = cycPatch.neighbPatch();
733 List<Type> receiveInfo;
745 if (!nbrPatch.parallel() || nbrPatch.separated())
748 const vectorField::subField fc = nbrPatch.faceCentres();
751 sendInfo[i].leaveDomain(mesh_, nbrPatch, i, fc[i], td_);
756 combine<Type, TrackingData> cmb(*
this, cycPatch);
758 if (cycPatch.applyLowWeightCorrection())
762 cycPatch.patchInternalList(allCellInfo_)
765 cycPatch.interpolate(sendInfo, cmb, receiveInfo, defVals);
769 cycPatch.interpolate(sendInfo, cmb, receiveInfo);
774 if (!cycPatch.parallel())
784 if (!cycPatch.parallel() || cycPatch.separated())
787 const vectorField::subField fc = cycPatch.faceCentres();
790 receiveInfo[i].enterDomain(mesh_, cycPatch, i, fc[i], td_);
797 const label meshFacei = cycPatch.start()+i;
799 const Type& newInfo = receiveInfo[i];
801 Type& currInfo = allFaceInfo_[meshFacei];
803 if (newInfo.valid(td_) && !currInfo.equal(newInfo, td_))
819 template<
class Type,
class TrackingData>
822 changedBaffles_.clear();
825 for (
const labelPair& baffle : explicitConnections_)
827 const label f0 = baffle.first();
828 const label f1 = baffle.second();
830 if (changedFace_.test(f0))
833 changedBaffles_.push_back(taggedInfoType(f1, allFaceInfo_[f0]));
836 if (changedFace_.test(f1))
839 changedBaffles_.push_back(taggedInfoType(f0, allFaceInfo_[f1]));
846 for (
const taggedInfoType& updated : changedBaffles_)
848 const label tgtFace = updated.first;
849 const Type& newInfo = updated.second;
851 Type& currInfo = allFaceInfo_[tgtFace];
853 if (!currInfo.equal(newInfo, td_))
865 changedBaffles_.clear();
871 template<
class Type,
class TrackingData>
882 explicitConnections_(),
883 allFaceInfo_(allFaceInfo),
884 allCellInfo_(allCellInfo),
886 changedBaffles_(2*explicitConnections_.size()),
901 <<
"face and cell storage not the size of mesh faces, cells:" <<
nl 911 template<
class Type,
class TrackingData>
925 explicitConnections_(),
926 allFaceInfo_(allFaceInfo),
927 allCellInfo_(allCellInfo),
929 changedBaffles_(2*explicitConnections_.size()),
944 <<
"face and cell storage not the size of mesh faces, cells:" <<
nl 956 const label iter =
iterate(maxIter);
958 if ((maxIter > 0) && (iter >= maxIter))
961 <<
"Maximum number of iterations reached. Increase maxIter." <<
nl 962 <<
" maxIter:" << maxIter <<
nl 970 template<
class Type,
class TrackingData>
975 const bool handleCyclicAMI,
986 explicitConnections_(explicitConnections),
987 allFaceInfo_(allFaceInfo),
988 allCellInfo_(allCellInfo),
990 changedBaffles_(2*explicitConnections_.size()),
1006 <<
"face and cell storage not the size of mesh faces, cells:" <<
nl 1018 const label iter =
iterate(maxIter);
1020 if ((maxIter > 0) && (iter >= maxIter))
1023 <<
"Maximum number of iterations reached. Increase maxIter." <<
nl 1024 <<
" maxIter:" << maxIter <<
nl 1034 template<
class Type,
class TrackingData>
1039 const labelList& owner = mesh_.faceOwner();
1040 const labelList& neighbour = mesh_.faceNeighbour();
1041 const label nInternalFaces = mesh_.nInternalFaces();
1043 for (
const label facei : changedFaces_)
1045 if (!changedFace_.test(facei))
1049 <<
" not marked as having been changed" 1053 const Type& newInfo = allFaceInfo_[facei];
1059 const label celli = owner[facei];
1060 Type& currInfo = allCellInfo_[celli];
1062 if (!currInfo.equal(newInfo, td_))
1076 if (facei < nInternalFaces)
1078 const label celli = neighbour[facei];
1079 Type& currInfo = allCellInfo_[celli];
1081 if (!currInfo.equal(newInfo, td_))
1095 changedFace_.unset(facei);
1099 changedFaces_.clear();
1103 Pout<<
" Changed cells : " << nChangedCells() <<
endl;
1111 template<
class Type,
class TrackingData>
1118 for (
const label celli : changedCells_)
1120 if (!changedCell_.test(celli))
1123 <<
"Cell " << celli <<
" not marked as having been changed" 1127 const Type& newInfo = allCellInfo_[celli];
1132 for (
const label facei : faceLabels)
1134 Type& currInfo = allFaceInfo_[facei];
1136 if (!currInfo.equal(newInfo, td_))
1150 changedCell_.unset(celli);
1154 changedCells_.clear();
1158 handleExplicitConnections();
1160 if (hasCyclicPatches_)
1162 handleCyclicPatches();
1165 if (hasCyclicAMIPatches_)
1167 handleAMICyclicPatches();
1172 handleProcPatches();
1177 Pout<<
" Changed faces : " << nChangedFaces() <<
endl;
1187 template<
class Type,
class TrackingData>
1195 if (hasCyclicPatches_)
1197 handleCyclicPatches();
1200 if (hasCyclicAMIPatches_)
1202 handleAMICyclicPatches();
1207 handleProcPatches();
1212 for (; iter < maxIter; ++iter)
1216 Info<<
" Iteration " << iter <<
endl;
1220 const label nCells = faceToCell();
1221 const label nFaces = nCells ? cellToFace() : 0;
1225 Info<<
" Total evaluations : " 1227 <<
" Changed cells / faces : " 1228 << nCells <<
" / " << nFaces <<
nl 1229 <<
" Pending cells / faces : " 1230 << nUnvisitedCells_ <<
" / " << nUnvisitedFaces_ <<
nl;
1233 if (!nCells || !nFaces)
void handleAMICyclicPatches()
Merge data from across AMI cyclics.
virtual const fileName & name() const
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
void handleExplicitConnections()
Merge data across explicitly provided local connections.
void size(const label n)
Older name for setAddressableSize.
Inter-processor communication reduction functions.
virtual label iterate(const label maxIter)
Iterate until no changes or maxIter reached.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Base class for solution control classes.
virtual label cellToFace()
Propagate from cell to face.
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.
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
static bool & parRun() noexcept
Test if this a parallel run.
const TrackingData & data() const noexcept
Additional data to be passed into container.
SubList< Type > subList
Declare type of subList.
Holds information regarding type of cell. Used in inside/outside determination in cellClassification...
label nFaces() const noexcept
Number of mesh faces.
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.
void handleProcPatches()
Merge data from across processor boundaries.
static scalar propagationTol() noexcept
Access to propagation tolerance.
#define forAll(list, i)
Loop across all elements in list.
void leaveDomain(const polyPatch &patch, const label nFaces, const labelUList &faceLabels, List< Type > &faceInfo) const
Handle leaving domain. Implementation referred to Type.
bool hasPatch() const
Has cyclic patch?
void transform(const tensorField &rotTensor, const label nFaces, List< Type > &faceInfo)
Apply transformation to Type.
bool valid(TrackingData &td) const
Changed or contains original (invalid) value.
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const cellInfo &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
const polyMesh & mesh() const noexcept
Return access to the mesh.
Cyclic patch for Arbitrary Mesh Interface (AMI)
void mergeFaceInfo(const polyPatch &patch, const label nFaces, const labelUList &changedFaces, const List< Type > &changedFacesInfo)
Merge received patch data into global data.
errorManip< error > abort(error &err)
bool updateFace(const label facei, const label neighbourCelli, const Type &neighbourInfo, const scalar tol, Type &faceInfo)
Updates faceInfo with information from neighbour.
bool updateCell(const label celli, const label neighbourFacei, const Type &neighbourInfo, const scalar tol, Type &cellInfo)
Updates cellInfo with information from neighbour.
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
void enterDomain(const polyPatch &patch, const label nFaces, const labelUList &faceLabels, List< Type > &faceInfo) const
Handle leaving domain. Implementation referred to Type.
label getChangedPatchFaces(const polyPatch &patch, const label startFacei, const label nFaces, labelList &changedPatchFaces, List< Type > &changedPatchFacesInfo) const
Extract info for single patch only.
combine(FaceCellWave< Type, TrackingData > &solver, const cyclicAMIPolyPatch &patch)
label nCells() const noexcept
Number of mesh cells.
virtual const cyclicAMIPolyPatch & neighbPatch() const
Return a reference to the neighbour patch.
virtual bool owner() const
Does this side own the patch?
label start() const
Return start label of this patch in the polyMesh face list.
const std::string patch
OpenFOAM patch number as a std::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
void checkCyclic(const polyPatch &pPatch) const
Debugging: check info on both sides of cyclic.
void handleCyclicPatches()
Merge data from across cyclics.
Mesh consisting of general polyhedral cells.
FaceCellWave(const FaceCellWave &)=delete
No copy construct.
List< label > labelList
A List of labels.
A patch is a list of labels that address the faces in the global face list.
const polyMesh & mesh_
Reference to mesh.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
Tensor of scalars, i.e. Tensor<scalar>.
static void offset(const polyPatch &patch, const label off, const label nFaces, labelList &faces)
Offset face labels by constant value.
label nChangedFaces() const noexcept
Current number of changed faces.
UList< Type > & allCellInfo() noexcept
Access allCellInfo.
UList< Type > & allFaceInfo() noexcept
Access allFaceInfo.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void setFaceInfo(const label facei, const Type &faceInfo)
Set single initial changed face.
virtual label faceToCell()
Propagate from face to cell.
label nChangedCells() const noexcept
Current number of changed cells.