41 template<
class Type,
class TrackingData>
44 template<
class Type,
class TrackingData>
47 template<
class Type,
class TrackingData>
52 template<
class Type,
class TrackingData>
82 if (y.valid(solver_.
data()))
87 meshFacei = patch_.
start() + facei;
109 template<
class Type,
class TrackingData>
113 const label neighbourFacei,
114 const Type& neighbourInfo,
127 bool wasValid = cellInfo.valid(td_);
142 if (!changedCell_[celli])
144 changedCell_[celli] =
true;
145 changedCells_.append(celli);
149 if (!wasValid && cellInfo.valid(td_))
158 template<
class Type,
class TrackingData>
162 const label neighbourCelli,
163 const Type& neighbourInfo,
176 bool wasValid = faceInfo.valid(td_);
191 if (!changedFace_[facei])
193 changedFace_[facei] =
true;
194 changedFaces_.append(facei);
198 if (!wasValid && faceInfo.valid(td_))
207 template<
class Type,
class TrackingData>
211 const Type& neighbourInfo,
224 bool wasValid = faceInfo.valid(td_);
238 if (!changedFace_[facei])
240 changedFace_[facei] =
true;
241 changedFaces_.append(facei);
245 if (!wasValid && faceInfo.valid(td_))
254 template<
class Type,
class TrackingData>
263 refCast<const cyclicPolyPatch>(patch).nbrPatch();
272 !allFaceInfo_[i1].sameGeometry
282 <<
" faceInfo:" << allFaceInfo_[i1]
283 <<
" otherfaceInfo:" << allFaceInfo_[i2]
287 if (changedFace_[i1] != changedFace_[i2])
290 <<
" faceInfo:" << allFaceInfo_[i1]
291 <<
" otherfaceInfo:" << allFaceInfo_[i2]
292 <<
" changedFace:" << changedFace_[i1]
293 <<
" otherchangedFace:" << changedFace_[i2]
300 template<
class Type,
class TrackingData>
301 template<
class PatchType>
306 if (isA<PatchType>(mesh_.boundaryMesh()[
patchi]))
315 template<
class Type,
class TrackingData>
322 forAll(changedFaces, changedFacei)
324 label facei = changedFaces[changedFacei];
326 bool wasValid = allFaceInfo_[facei].valid(td_);
329 allFaceInfo_[facei] = changedFacesInfo[changedFacei];
332 if (!wasValid && allFaceInfo_[facei].valid(td_))
339 changedFace_[facei] =
true;
340 changedFaces_.
append(facei);
345 template<
class Type,
class TrackingData>
356 for (
label changedFacei = 0; changedFacei < nFaces; changedFacei++)
358 const Type& neighbourWallInfo = changedFacesInfo[changedFacei];
359 label patchFacei = changedFaces[changedFacei];
363 Type& currentWallInfo = allFaceInfo_[meshFacei];
365 if (!currentWallInfo.equal(neighbourWallInfo, td_))
379 template<
class Type,
class TrackingData>
383 const label startFacei,
392 label nChangedPatchFaces = 0;
394 for (
label i = 0; i < nFaces; i++)
396 label patchFacei = i + startFacei;
400 if (changedFace_[meshFacei])
402 changedPatchFaces[nChangedPatchFaces] = patchFacei;
403 changedPatchFacesInfo[nChangedPatchFaces] = allFaceInfo_[meshFacei];
404 nChangedPatchFaces++;
407 return nChangedPatchFaces;
411 template<
class Type,
class TrackingData>
424 for (
label i = 0; i < nFaces; i++)
426 label patchFacei = faceLabels[i];
429 faceInfo[i].leaveDomain(mesh_, patch, patchFacei, fc[meshFacei], td_);
434 template<
class Type,
class TrackingData>
447 for (
label i = 0; i < nFaces; i++)
449 label patchFacei = faceLabels[i];
452 faceInfo[i].enterDomain(mesh_, patch, patchFacei, fc[meshFacei], td_);
457 template<
class Type,
class TrackingData>
465 for (
label facei = 0; facei < nFaces; facei++)
467 faceInfo[facei].transform(mesh_, rotTensor, td_);
472 template<
class Type,
class TrackingData>
484 for (
label facei = 0; facei < nFaces; facei++)
486 faceInfo[facei].transform(mesh_, trans.
T(), td_);
492 template<
class Type,
class TrackingData>
496 const label cycOffset,
504 for (
label facei = 0; facei < nFaces; facei++)
506 faces[facei] += cycOffset;
511 template<
class Type,
class TrackingData>
530 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[
patchi]);
538 nSendFaces = getChangedPatchFaces
558 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
560 <<
" Sending:" << nSendFaces
580 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[
patchi]);
588 fromNeighbour >> receiveFaces >> receiveFacesInfo;
593 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
595 <<
" Receiving:" << receiveFaces.size()
631 template<
class Type,
class TrackingData>
640 if (isA<cyclicPolyPatch>(patch))
643 refCast<const cyclicPolyPatch>(patch).nbrPatch();
651 nReceiveFaces = getChangedPatchFaces
670 refCast<const cyclicPolyPatch>(patch);
686 <<
" Changed : " << nReceiveFaces
710 checkCyclic(cycPatch);
717 template<
class Type,
class TrackingData>
726 if (isA<cyclicAMIPolyPatch>(patch))
729 refCast<const cyclicAMIPolyPatch>(patch);
735 refCast<const cyclicAMIPolyPatch>(patch).nbrPatch();
752 sendInfo[i].leaveDomain(mesh_, nbrPatch, i, fc[i], td_);
765 if (cycPatch.
owner())
776 cycPatch.
AMIs()[i].interpolateToSource
824 receiveInfo[i].enterDomain(mesh_, cycPatch, i, fc[i], td_);
833 Type& currentWallInfo = allFaceInfo_[meshFacei];
837 receiveInfo[i].valid(td_)
838 && !currentWallInfo.equal(receiveInfo[i], td_)
855 template<
class Type,
class TrackingData>
866 forAll(explicitConnections_, connI)
868 const labelPair& baffle = explicitConnections_[connI];
870 label f0 = baffle[0];
871 if (changedFace_[f0])
873 f0Baffle.append(connI);
874 f0Info.append(allFaceInfo_[f0]);
878 if (changedFace_[f1])
880 f1Baffle.append(connI);
881 f1Info.append(allFaceInfo_[f1]);
890 const labelPair& baffle = explicitConnections_[f1Baffle[index]];
892 label f0 = baffle[0];
893 Type& currentWallInfo = allFaceInfo_[f0];
895 if (!currentWallInfo.equal(f1Info[index], td_))
909 const labelPair& baffle = explicitConnections_[f0Baffle[index]];
912 Type& currentWallInfo = allFaceInfo_[
f1];
914 if (!currentWallInfo.equal(f0Info[index], td_))
930 template<
class Type,
class TrackingData>
940 explicitConnections_(0),
941 allFaceInfo_(allFaceInfo),
942 allCellInfo_(allCellInfo),
944 changedFace_(mesh_.nFaces(),
false),
945 changedFaces_(mesh_.nFaces()),
946 changedCell_(mesh_.nCells(),
false),
947 changedCells_(mesh_.nCells()),
948 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
954 nUnvisitedCells_(mesh_.nCells()),
955 nUnvisitedFaces_(mesh_.nFaces())
959 allFaceInfo.
size() != mesh_.nFaces()
960 || allCellInfo.
size() != mesh_.nCells()
964 <<
"face and cell storage not the size of mesh faces, cells:" 966 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 967 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 968 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 969 <<
" mesh_.nCells():" << mesh_.nCells()
975 template<
class Type,
class TrackingData>
988 explicitConnections_(0),
989 allFaceInfo_(allFaceInfo),
990 allCellInfo_(allCellInfo),
992 changedFace_(mesh_.nFaces(),
false),
993 changedFaces_(mesh_.nFaces()),
994 changedCell_(mesh_.nCells(),
false),
995 changedCells_(mesh_.nCells()),
996 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
1002 nUnvisitedCells_(mesh_.nCells()),
1003 nUnvisitedFaces_(mesh_.nFaces())
1007 allFaceInfo.
size() != mesh_.nFaces()
1008 || allCellInfo.
size() != mesh_.nCells()
1012 <<
"face and cell storage not the size of mesh faces, cells:" 1014 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 1015 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 1016 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 1017 <<
" mesh_.nCells():" << mesh_.nCells()
1022 setFaceInfo(changedFaces, changedFacesInfo);
1025 label iter = iterate(maxIter);
1027 if ((maxIter > 0) && (iter >= maxIter))
1030 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl 1031 <<
" maxIter:" << maxIter <<
endl 1032 <<
" nChangedCells:" << changedCells_.size() <<
endl 1033 <<
" nChangedFaces:" << changedFaces_.size() <<
endl 1039 template<
class Type,
class TrackingData>
1044 const bool handleCyclicAMI,
1049 const label maxIter,
1054 explicitConnections_(explicitConnections),
1055 allFaceInfo_(allFaceInfo),
1056 allCellInfo_(allCellInfo),
1058 changedFace_(mesh_.nFaces(),
false),
1059 changedFaces_(mesh_.nFaces()),
1060 changedCell_(mesh_.nCells(),
false),
1061 changedCells_(mesh_.nCells()),
1062 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
1063 hasCyclicAMIPatches_
1069 nUnvisitedCells_(mesh_.nCells()),
1070 nUnvisitedFaces_(mesh_.nFaces())
1074 allFaceInfo.
size() != mesh_.nFaces()
1075 || allCellInfo.
size() != mesh_.nCells()
1079 <<
"face and cell storage not the size of mesh faces, cells:" 1081 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 1082 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 1083 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 1084 <<
" mesh_.nCells():" << mesh_.nCells()
1089 setFaceInfo(changedFaces, changedFacesInfo);
1092 label iter = iterate(maxIter);
1094 if ((maxIter > 0) && (iter >= maxIter))
1097 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl 1098 <<
" maxIter:" << maxIter <<
endl 1099 <<
" nChangedCells:" << changedCells_.size() <<
endl 1100 <<
" nChangedFaces:" << changedFaces_.size() <<
endl 1108 template<
class Type,
class TrackingData>
1111 return nUnvisitedCells_;
1115 template<
class Type,
class TrackingData>
1118 return nUnvisitedFaces_;
1122 template<
class Type,
class TrackingData>
1127 const labelList& owner = mesh_.faceOwner();
1128 const labelList& neighbour = mesh_.faceNeighbour();
1129 label nInternalFaces = mesh_.nInternalFaces();
1131 forAll(changedFaces_, changedFacei)
1133 label facei = changedFaces_[changedFacei];
1134 if (!changedFace_[facei])
1138 <<
" not marked as having been changed" 1143 const Type& neighbourWallInfo = allFaceInfo_[facei];
1148 label celli = owner[facei];
1149 Type& currentWallInfo = allCellInfo_[celli];
1151 if (!currentWallInfo.equal(neighbourWallInfo, td_))
1164 if (facei < nInternalFaces)
1166 celli = neighbour[facei];
1167 Type& currentWallInfo2 = allCellInfo_[celli];
1169 if (!currentWallInfo2.equal(neighbourWallInfo, td_))
1183 changedFace_[facei] =
false;
1187 changedFaces_.clear();
1191 Pout<<
" Changed cells : " << changedCells_.size() <<
endl;
1195 label totNChanged = changedCells_.size();
1203 template<
class Type,
class TrackingData>
1210 forAll(changedCells_, changedCelli)
1212 label celli = changedCells_[changedCelli];
1213 if (!changedCell_[celli])
1216 <<
"Cell " << celli <<
" not marked as having been changed" 1220 const Type& neighbourWallInfo = allCellInfo_[celli];
1224 const labelList& faceLabels = cells[celli];
1225 forAll(faceLabels, faceLabelI)
1227 label facei = faceLabels[faceLabelI];
1228 Type& currentWallInfo = allFaceInfo_[facei];
1230 if (!currentWallInfo.equal(neighbourWallInfo, td_))
1244 changedCell_[celli] =
false;
1248 changedCells_.clear();
1252 handleExplicitConnections();
1254 if (hasCyclicPatches_)
1257 handleCyclicPatches();
1260 if (hasCyclicAMIPatches_)
1262 handleAMICyclicPatches();
1268 handleProcPatches();
1273 Pout<<
" Changed faces : " << changedFaces_.size() <<
endl;
1277 label totNChanged = changedFaces_.size();
1286 template<
class Type,
class TrackingData>
1289 if (hasCyclicPatches_)
1292 handleCyclicPatches();
1295 if (hasCyclicAMIPatches_)
1297 handleAMICyclicPatches();
1303 handleProcPatches();
1308 while (iter < maxIter)
1312 Info<<
" Iteration " << iter <<
endl;
1321 Info<<
" Total changed cells : " << nCells <<
endl;
1333 Info<<
" Total changed faces : " << nFaces <<
nl 1334 <<
" Total evaluations : " << nEvals_ <<
nl 1335 <<
" Remaining unvisited cells: " << nUnvisitedCells_ <<
nl 1336 <<
" Remaining unvisited faces: " << nUnvisitedFaces_ <<
endl;
void handleAMICyclicPatches()
Merge data from across AMI cyclics.
void mergeFaceInfo(const polyPatch &patch, const label nFaces, const labelList &, const List< Type > &)
Merge received patch data into global data.
void handleExplicitConnections()
Merge data across explicitly provided local connections (usually.
#define forAll(list, i)
Loop across all elements in list.
const labelList & processorPatches() const
Return list of processor patch 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.
const word & name() const
Return name.
Inter-processor communication reduction functions.
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
virtual label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
const UIndirectList< T > patchInternalList(const UList< T > &internalValues) const
Extract face cell data.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void setFaceInfo(const labelList &changedFaces, const List< Type > &changedFacesInfo)
Set initial changed faces.
virtual label cellToFace()
Propagate from cell to face. Returns total number of faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
void size(const label)
Override size to be inconsistent with allocated storage.
static scalar propagationTol()
Access to tolerance.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
FaceCellWave(const polyMesh &, UList< Type > &allFaceInfo, UList< Type > &allCellInfo, TrackingData &td=dummyTrackData_)
bool applyLowWeightCorrection() const
Return true if applying the low weight correction.
virtual const transformer & transform() const
Return transformation between the coupled patches.
const polyMesh & mesh() const
Access mesh.
Pre-declare related SubField type.
void handleProcPatches()
Merge data from across processor boundaries.
Neighbour processor patch.
const List< transformer > & AMITransforms() const
Return a reference to the AMI transforms.
virtual const cyclicAMIPolyPatch & nbrPatch() const
Return a reference to the neighbour patch.
A topoSetSource to select a faceSet from cells.
Input inter-processor communications stream operating on external buffer.
label getUnsetFaces() const
Get number of unvisited faces.
A List obtained as a section of another List.
An ordered pair of two objects of type <T> with first() and second() elements.
void enterDomain(const polyPatch &patch, const label nFaces, const labelList &faceLabels, List< Type > &faceInfo) const
Handle leaving domain. Implementation referred to Type.
bool hasPatch() const
Has cyclic patch?
const PtrList< AMIInterpolation > & AMIs() const
Return a reference to the AMI interpolators.
void transform(const tensor &rotTensor, const label nFaces, List< Type > &faceInfo)
Apply transformation to Type.
A topoSetSource to select cells based on usage in faces.
void append(const T &)
Append an element at the end of the list.
virtual const transformer & transform() const
Return transformation between the coupled patches.
Cyclic patch for Arbitrary Mesh Interface (AMI)
int neighbProcNo() const
Return neighbour processor number.
errorManip< error > abort(error &err)
Output inter-processor communications stream operating on external buffer.
static direction size()
Return the number of elements in the VectorSpace = Ncmpts.
bool updateFace(const label facei, const label neighbourCelli, const Type &neighbourInfo, const scalar tol, Type &faceInfo)
Updates faceInfo with information from neighbour. Updates all.
bool updateCell(const label celli, const label neighbourFacei, const Type &neighbourInfo, const scalar tol, Type &cellInfo)
Updates cellInfo with information from neighbour. Updates all.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
virtual const transformer & transform() const
Return null transform between processor patches.
static bool & parRun()
Is this a parallel run?
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)
const TrackingData & data() const
Additional data to be passed into container.
prefixOSstream Pout(cout, "Pout")
virtual bool owner() const
Does this side own the patch?
label start() const
Return start label of this patch in the polyMesh face list.
void checkCyclic(const polyPatch &pPatch) const
Debugging: check info on both sides of cyclic.
void handleCyclicPatches()
Merge data from across cyclics.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Mesh consisting of general polyhedral cells.
void leaveDomain(const polyPatch &patch, const label nFaces, const labelList &faceLabels, List< Type > &faceInfo) const
Handle leaving domain. Implementation referred to Type.
A patch is a list of labels that address the faces in the global face list.
label size() const
Return the number of elements in the UList.
static void offset(const polyPatch &patch, const label off, const label nFaces, labelList &faces)
Offset face labels by constant value.
const dimensionedScalar e
Elementary charge.
const List< T >::subList patchSlice(const UList< T > &l) const
Slice list to patch.
dimensionSet transform(const dimensionSet &)
virtual label faceToCell()
Propagate from face to cell. Returns total number of cells.
const vectorField::subField faceCentres() const
Return face centres.
label getUnsetCells() const
Get number of unvisited cells, i.e. cells that were not (yet)