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).neighbPatch();
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>
467 if (rotTensor.
size() == 1)
469 const tensor&
T = rotTensor[0];
471 for (
label facei = 0; facei < nFaces; facei++)
473 faceInfo[facei].transform(mesh_, T, td_);
478 for (
label facei = 0; facei < nFaces; facei++)
480 faceInfo[facei].transform(mesh_, rotTensor[facei], td_);
486 template<
class Type,
class TrackingData>
498 for (
label facei = 0; facei < nFaces; facei++)
500 faceInfo[facei].transform(mesh_, trans.
R(), td_);
506 template<
class Type,
class TrackingData>
510 const label cycOffset,
518 for (
label facei = 0; facei < nFaces; facei++)
520 faces[facei] += cycOffset;
525 template<
class Type,
class TrackingData>
544 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[
patchi]);
552 nSendFaces = getChangedPatchFaces
572 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
574 <<
" Sending:" << nSendFaces
594 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[
patchi]);
602 fromNeighbour >> receiveFaces >> receiveFacesInfo;
607 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
609 <<
" Receiving:" << receiveFaces.size()
645 template<
class Type,
class TrackingData>
654 if (isA<cyclicPolyPatch>(patch))
657 refCast<const cyclicPolyPatch>(patch).neighbPatch();
665 nReceiveFaces = getChangedPatchFaces
684 refCast<const cyclicPolyPatch>(patch);
700 <<
" Changed : " << nReceiveFaces
724 checkCyclic(cycPatch);
731 template<
class Type,
class TrackingData>
740 if (isA<cyclicAMIPolyPatch>(patch))
743 refCast<const cyclicAMIPolyPatch>(patch);
749 refCast<const cyclicAMIPolyPatch>(patch).neighbPatch();
766 sendInfo[i].leaveDomain(mesh_, nbrPatch, i, fc[i], td_);
779 if (cycPatch.
owner())
790 cycPatch.
AMIs()[i].interpolateToSource
838 receiveInfo[i].enterDomain(mesh_, cycPatch, i, fc[i], td_);
847 Type& currentWallInfo = allFaceInfo_[meshFacei];
851 receiveInfo[i].valid(td_)
852 && !currentWallInfo.equal(receiveInfo[i], td_)
869 template<
class Type,
class TrackingData>
880 forAll(explicitConnections_, connI)
882 const labelPair& baffle = explicitConnections_[connI];
884 label f0 = baffle[0];
885 if (changedFace_[f0])
887 f0Baffle.append(connI);
888 f0Info.append(allFaceInfo_[f0]);
892 if (changedFace_[f1])
894 f1Baffle.append(connI);
895 f1Info.append(allFaceInfo_[f1]);
904 const labelPair& baffle = explicitConnections_[f1Baffle[index]];
906 label f0 = baffle[0];
907 Type& currentWallInfo = allFaceInfo_[f0];
909 if (!currentWallInfo.equal(f1Info[index], td_))
923 const labelPair& baffle = explicitConnections_[f0Baffle[index]];
926 Type& currentWallInfo = allFaceInfo_[
f1];
928 if (!currentWallInfo.equal(f0Info[index], td_))
944 template<
class Type,
class TrackingData>
954 explicitConnections_(0),
955 allFaceInfo_(allFaceInfo),
956 allCellInfo_(allCellInfo),
958 changedFace_(mesh_.nFaces(),
false),
959 changedFaces_(mesh_.nFaces()),
960 changedCell_(mesh_.nCells(),
false),
961 changedCells_(mesh_.nCells()),
962 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
968 nUnvisitedCells_(mesh_.nCells()),
969 nUnvisitedFaces_(mesh_.nFaces())
973 allFaceInfo.
size() != mesh_.nFaces()
974 || allCellInfo.
size() != mesh_.nCells()
978 <<
"face and cell storage not the size of mesh faces, cells:" 980 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 981 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 982 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 983 <<
" mesh_.nCells():" << mesh_.nCells()
989 template<
class Type,
class TrackingData>
1002 explicitConnections_(0),
1003 allFaceInfo_(allFaceInfo),
1004 allCellInfo_(allCellInfo),
1006 changedFace_(mesh_.nFaces(),
false),
1007 changedFaces_(mesh_.nFaces()),
1008 changedCell_(mesh_.nCells(),
false),
1009 changedCells_(mesh_.nCells()),
1010 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
1011 hasCyclicAMIPatches_
1016 nUnvisitedCells_(mesh_.nCells()),
1017 nUnvisitedFaces_(mesh_.nFaces())
1021 allFaceInfo.
size() != mesh_.nFaces()
1022 || allCellInfo.
size() != mesh_.nCells()
1026 <<
"face and cell storage not the size of mesh faces, cells:" 1028 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 1029 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 1030 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 1031 <<
" mesh_.nCells():" << mesh_.nCells()
1036 setFaceInfo(changedFaces, changedFacesInfo);
1039 label iter = iterate(maxIter);
1041 if ((maxIter > 0) && (iter >= maxIter))
1044 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl 1045 <<
" maxIter:" << maxIter <<
endl 1046 <<
" nChangedCells:" << changedCells_.size() <<
endl 1047 <<
" nChangedFaces:" << changedFaces_.size() <<
endl 1053 template<
class Type,
class TrackingData>
1058 const bool handleCyclicAMI,
1063 const label maxIter,
1068 explicitConnections_(explicitConnections),
1069 allFaceInfo_(allFaceInfo),
1070 allCellInfo_(allCellInfo),
1072 changedFace_(mesh_.nFaces(),
false),
1073 changedFaces_(mesh_.nFaces()),
1074 changedCell_(mesh_.nCells(),
false),
1075 changedCells_(mesh_.nCells()),
1076 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
1077 hasCyclicAMIPatches_
1083 nUnvisitedCells_(mesh_.nCells()),
1084 nUnvisitedFaces_(mesh_.nFaces())
1088 allFaceInfo.
size() != mesh_.nFaces()
1089 || allCellInfo.
size() != mesh_.nCells()
1093 <<
"face and cell storage not the size of mesh faces, cells:" 1095 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 1096 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 1097 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 1098 <<
" mesh_.nCells():" << mesh_.nCells()
1103 setFaceInfo(changedFaces, changedFacesInfo);
1106 label iter = iterate(maxIter);
1108 if ((maxIter > 0) && (iter >= maxIter))
1111 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl 1112 <<
" maxIter:" << maxIter <<
endl 1113 <<
" nChangedCells:" << changedCells_.size() <<
endl 1114 <<
" nChangedFaces:" << changedFaces_.size() <<
endl 1122 template<
class Type,
class TrackingData>
1125 return nUnvisitedCells_;
1129 template<
class Type,
class TrackingData>
1132 return nUnvisitedFaces_;
1136 template<
class Type,
class TrackingData>
1141 const labelList& owner = mesh_.faceOwner();
1142 const labelList& neighbour = mesh_.faceNeighbour();
1143 label nInternalFaces = mesh_.nInternalFaces();
1145 forAll(changedFaces_, changedFacei)
1147 label facei = changedFaces_[changedFacei];
1148 if (!changedFace_[facei])
1152 <<
" not marked as having been changed" 1157 const Type& neighbourWallInfo = allFaceInfo_[facei];
1162 label celli = owner[facei];
1163 Type& currentWallInfo = allCellInfo_[celli];
1165 if (!currentWallInfo.equal(neighbourWallInfo, td_))
1178 if (facei < nInternalFaces)
1180 celli = neighbour[facei];
1181 Type& currentWallInfo2 = allCellInfo_[celli];
1183 if (!currentWallInfo2.equal(neighbourWallInfo, td_))
1197 changedFace_[facei] =
false;
1201 changedFaces_.clear();
1205 Pout<<
" Changed cells : " << changedCells_.size() <<
endl;
1209 label totNChanged = changedCells_.size();
1217 template<
class Type,
class TrackingData>
1224 forAll(changedCells_, changedCelli)
1226 label celli = changedCells_[changedCelli];
1227 if (!changedCell_[celli])
1230 <<
"Cell " << celli <<
" not marked as having been changed" 1234 const Type& neighbourWallInfo = allCellInfo_[celli];
1238 const labelList& faceLabels = cells[celli];
1239 forAll(faceLabels, faceLabelI)
1241 label facei = faceLabels[faceLabelI];
1242 Type& currentWallInfo = allFaceInfo_[facei];
1244 if (!currentWallInfo.equal(neighbourWallInfo, td_))
1258 changedCell_[celli] =
false;
1262 changedCells_.clear();
1266 handleExplicitConnections();
1268 if (hasCyclicPatches_)
1271 handleCyclicPatches();
1274 if (hasCyclicAMIPatches_)
1276 handleAMICyclicPatches();
1282 handleProcPatches();
1287 Pout<<
" Changed faces : " << changedFaces_.size() <<
endl;
1291 label totNChanged = changedFaces_.size();
1300 template<
class Type,
class TrackingData>
1303 if (hasCyclicPatches_)
1306 handleCyclicPatches();
1309 if (hasCyclicAMIPatches_)
1311 handleAMICyclicPatches();
1317 handleProcPatches();
1322 while (iter < maxIter)
1326 Info<<
" Iteration " << iter <<
endl;
1335 Info<<
" Total changed cells : " << nCells <<
endl;
1347 Info<<
" Total changed faces : " << nFaces <<
nl 1348 <<
" Total evaluations : " << nEvals_ <<
nl 1349 <<
" Remaining unvisited cells: " << nUnvisitedCells_ <<
nl 1350 <<
" 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.
virtual bool separated() const
Are the planes separated.
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...
bool applyLowWeightCorrection() const
Return true if applying the low weight correction.
const PtrList< AMIPatchToPatchInterpolation > & AMIs() const
Return a reference to the AMI interpolators.
const polyMesh & mesh() const
Access mesh.
Pre-declare related SubField type.
void handleProcPatches()
Merge data from across processor boundaries.
virtual const tensorField & forwardT() const
Return face transformation tensor.
Neighbour processor patch.
const List< vectorTensorTransform > & AMITransforms() const
Return a reference to the AMI transforms.
A topoSetSource to select a faceSet from cells.
Input inter-processor communications stream operating on external buffer.
virtual bool parallel() const
Are the cyclic planes parallel.
label getUnsetFaces() const
Get number of unvisited faces.
A List obtained as a section of another List.
const dimensionedScalar e
Elementary charge.
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?
A topoSetSource to select cells based on usage in faces.
void append(const T &)
Append an element at the end of the list.
void transform(const tensorField &rotTensor, const label nFaces, List< Type > &faceInfo)
Apply transformation to Type.
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.
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 T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
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.
virtual const cyclicAMIPolyPatch & neighbPatch() const
Return a reference to the neighbour patch.
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 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)