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>
490 const label cycOffset,
498 for (
label facei = 0; facei < nFaces; facei++)
500 faces[facei] += cycOffset;
505 template<
class Type,
class TrackingData>
524 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[
patchi]);
532 nSendFaces = getChangedPatchFaces
552 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
554 <<
" Sending:" << nSendFaces
574 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[
patchi]);
582 fromNeighbour >> receiveFaces >> receiveFacesInfo;
587 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
589 <<
" Receiving:" << receiveFaces.size()
625 template<
class Type,
class TrackingData>
634 if (isA<cyclicPolyPatch>(patch))
637 refCast<const cyclicPolyPatch>(patch).neighbPatch();
645 nReceiveFaces = getChangedPatchFaces
664 refCast<const cyclicPolyPatch>(patch);
680 <<
" Changed : " << nReceiveFaces
704 checkCyclic(cycPatch);
711 template<
class Type,
class TrackingData>
720 if (isA<cyclicAMIPolyPatch>(patch))
723 refCast<const cyclicAMIPolyPatch>(patch);
729 refCast<const cyclicAMIPolyPatch>(patch).neighbPatch();
746 sendInfo[i].leaveDomain(mesh_, nbrPatch, i, fc[i], td_);
760 cycPatch.
interpolate(sendInfo, cmb, receiveInfo, defVals);
785 receiveInfo[i].enterDomain(mesh_, cycPatch, i, fc[i], td_);
794 Type& currentWallInfo = allFaceInfo_[meshFacei];
798 receiveInfo[i].valid(td_)
799 && !currentWallInfo.equal(receiveInfo[i], td_)
816 template<
class Type,
class TrackingData>
827 forAll(explicitConnections_, connI)
829 const labelPair& baffle = explicitConnections_[connI];
831 label f0 = baffle[0];
832 if (changedFace_[f0])
834 f0Baffle.append(connI);
835 f0Info.append(allFaceInfo_[f0]);
839 if (changedFace_[f1])
841 f1Baffle.append(connI);
842 f1Info.append(allFaceInfo_[f1]);
851 const labelPair& baffle = explicitConnections_[f1Baffle[index]];
853 label f0 = baffle[0];
854 Type& currentWallInfo = allFaceInfo_[f0];
856 if (!currentWallInfo.equal(f1Info[index], td_))
870 const labelPair& baffle = explicitConnections_[f0Baffle[index]];
873 Type& currentWallInfo = allFaceInfo_[
f1];
875 if (!currentWallInfo.equal(f0Info[index], td_))
891 template<
class Type,
class TrackingData>
901 explicitConnections_(0),
902 allFaceInfo_(allFaceInfo),
903 allCellInfo_(allCellInfo),
905 changedFace_(mesh_.nFaces(),
false),
906 changedFaces_(mesh_.nFaces()),
907 changedCell_(mesh_.nCells(),
false),
908 changedCells_(mesh_.nCells()),
909 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
915 nUnvisitedCells_(mesh_.nCells()),
916 nUnvisitedFaces_(mesh_.nFaces())
920 allFaceInfo.
size() != mesh_.nFaces()
921 || allCellInfo.
size() != mesh_.nCells()
925 <<
"face and cell storage not the size of mesh faces, cells:" 927 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 928 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 929 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 930 <<
" mesh_.nCells():" << mesh_.nCells()
936 template<
class Type,
class TrackingData>
949 explicitConnections_(0),
950 allFaceInfo_(allFaceInfo),
951 allCellInfo_(allCellInfo),
953 changedFace_(mesh_.nFaces(),
false),
954 changedFaces_(mesh_.nFaces()),
955 changedCell_(mesh_.nCells(),
false),
956 changedCells_(mesh_.nCells()),
957 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
963 nUnvisitedCells_(mesh_.nCells()),
964 nUnvisitedFaces_(mesh_.nFaces())
968 allFaceInfo.
size() != mesh_.nFaces()
969 || allCellInfo.
size() != mesh_.nCells()
973 <<
"face and cell storage not the size of mesh faces, cells:" 975 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 976 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 977 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 978 <<
" mesh_.nCells():" << mesh_.nCells()
983 setFaceInfo(changedFaces, changedFacesInfo);
986 label iter = iterate(maxIter);
988 if ((maxIter > 0) && (iter >= maxIter))
991 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl 992 <<
" maxIter:" << maxIter <<
endl 993 <<
" nChangedCells:" << changedCells_.size() <<
endl 994 <<
" nChangedFaces:" << changedFaces_.size() <<
endl 1000 template<
class Type,
class TrackingData>
1005 const bool handleCyclicAMI,
1010 const label maxIter,
1015 explicitConnections_(explicitConnections),
1016 allFaceInfo_(allFaceInfo),
1017 allCellInfo_(allCellInfo),
1019 changedFace_(mesh_.nFaces(),
false),
1020 changedFaces_(mesh_.nFaces()),
1021 changedCell_(mesh_.nCells(),
false),
1022 changedCells_(mesh_.nCells()),
1023 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
1024 hasCyclicAMIPatches_
1030 nUnvisitedCells_(mesh_.nCells()),
1031 nUnvisitedFaces_(mesh_.nFaces())
1035 allFaceInfo.
size() != mesh_.nFaces()
1036 || allCellInfo.
size() != mesh_.nCells()
1040 <<
"face and cell storage not the size of mesh faces, cells:" 1042 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 1043 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 1044 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 1045 <<
" mesh_.nCells():" << mesh_.nCells()
1050 setFaceInfo(changedFaces, changedFacesInfo);
1053 label iter = iterate(maxIter);
1055 if ((maxIter > 0) && (iter >= maxIter))
1058 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl 1059 <<
" maxIter:" << maxIter <<
endl 1060 <<
" nChangedCells:" << changedCells_.size() <<
endl 1061 <<
" nChangedFaces:" << changedFaces_.size() <<
endl 1069 template<
class Type,
class TrackingData>
1072 return nUnvisitedCells_;
1076 template<
class Type,
class TrackingData>
1079 return nUnvisitedFaces_;
1083 template<
class Type,
class TrackingData>
1088 const labelList& owner = mesh_.faceOwner();
1089 const labelList& neighbour = mesh_.faceNeighbour();
1090 label nInternalFaces = mesh_.nInternalFaces();
1092 forAll(changedFaces_, changedFacei)
1094 label facei = changedFaces_[changedFacei];
1095 if (!changedFace_[facei])
1099 <<
" not marked as having been changed" 1104 const Type& neighbourWallInfo = allFaceInfo_[facei];
1109 label celli = owner[facei];
1110 Type& currentWallInfo = allCellInfo_[celli];
1112 if (!currentWallInfo.equal(neighbourWallInfo, td_))
1125 if (facei < nInternalFaces)
1127 celli = neighbour[facei];
1128 Type& currentWallInfo2 = allCellInfo_[celli];
1130 if (!currentWallInfo2.equal(neighbourWallInfo, td_))
1144 changedFace_[facei] =
false;
1148 changedFaces_.clear();
1152 Pout<<
" Changed cells : " << changedCells_.size() <<
endl;
1156 label totNChanged = changedCells_.size();
1164 template<
class Type,
class TrackingData>
1171 forAll(changedCells_, changedCelli)
1173 label celli = changedCells_[changedCelli];
1174 if (!changedCell_[celli])
1177 <<
"Cell " << celli <<
" not marked as having been changed" 1181 const Type& neighbourWallInfo = allCellInfo_[celli];
1185 const labelList& faceLabels = cells[celli];
1186 forAll(faceLabels, faceLabelI)
1188 label facei = faceLabels[faceLabelI];
1189 Type& currentWallInfo = allFaceInfo_[facei];
1191 if (!currentWallInfo.equal(neighbourWallInfo, td_))
1205 changedCell_[celli] =
false;
1209 changedCells_.clear();
1213 handleExplicitConnections();
1215 if (hasCyclicPatches_)
1218 handleCyclicPatches();
1221 if (hasCyclicAMIPatches_)
1223 handleAMICyclicPatches();
1229 handleProcPatches();
1234 Pout<<
" Changed faces : " << changedFaces_.size() <<
endl;
1238 label totNChanged = changedFaces_.size();
1247 template<
class Type,
class TrackingData>
1250 if (hasCyclicPatches_)
1253 handleCyclicPatches();
1256 if (hasCyclicAMIPatches_)
1258 handleAMICyclicPatches();
1264 handleProcPatches();
1269 while (iter < maxIter)
1273 Info<<
" Iteration " << iter <<
endl;
1282 Info<<
" Total changed cells : " << nCells <<
endl;
1294 Info<<
" Total changed faces : " << nFaces <<
nl 1295 <<
" Total evaluations : " << nEvals_ <<
nl 1296 <<
" Remaining unvisited cells: " << nUnvisitedCells_ <<
nl 1297 <<
" 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.
tmp< Field< Type > > interpolate(const Field< Type > &fld, const UList< Type > &defaultValues=UList< Type >()) const
Interpolate field.
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.
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 neigbour 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)