41 template<
class Type,
class TrackingData>
44 template<
class Type,
class TrackingData>
47 template<
class Type,
class TrackingData>
53 template<
class Type,
class TrackingData>
57 const label neighbourFacei,
58 const Type& neighbourInfo,
71 bool wasValid = cellInfo.valid(td_);
86 if (!changedCell_[celli])
88 changedCell_[celli] =
true;
89 changedCells_.append(celli);
93 if (!wasValid && cellInfo.valid(td_))
102 template<
class Type,
class TrackingData>
106 const label neighbourCelli,
107 const Type& neighbourInfo,
120 bool wasValid = faceInfo.valid(td_);
135 if (!changedFace_[facei])
137 changedFace_[facei] =
true;
138 changedFaces_.append(facei);
142 if (!wasValid && faceInfo.valid(td_))
151 template<
class Type,
class TrackingData>
155 const Type& neighbourInfo,
168 bool wasValid = faceInfo.valid(td_);
182 if (!changedFace_[facei])
184 changedFace_[facei] =
true;
185 changedFaces_.append(facei);
189 if (!wasValid && faceInfo.valid(td_))
198 template<
class Type,
class TrackingData>
207 refCast<const cyclicPolyPatch>(patch).nbrPatch();
216 !allFaceInfo_[i1].sameGeometry
226 <<
" faceInfo:" << allFaceInfo_[i1]
227 <<
" otherfaceInfo:" << allFaceInfo_[i2]
231 if (changedFace_[i1] != changedFace_[i2])
234 <<
" faceInfo:" << allFaceInfo_[i1]
235 <<
" otherfaceInfo:" << allFaceInfo_[i2]
236 <<
" changedFace:" << changedFace_[i1]
237 <<
" otherchangedFace:" << changedFace_[i2]
244 template<
class Type,
class TrackingData>
245 template<
class PatchType>
250 if (isA<PatchType>(mesh_.boundaryMesh()[
patchi]))
259 template<
class Type,
class TrackingData>
266 forAll(changedFaces, changedFacei)
268 label facei = changedFaces[changedFacei];
270 bool wasValid = allFaceInfo_[facei].valid(td_);
273 allFaceInfo_[facei] = changedFacesInfo[changedFacei];
276 if (!wasValid && allFaceInfo_[facei].valid(td_))
283 changedFace_[facei] =
true;
284 changedFaces_.
append(facei);
289 template<
class Type,
class TrackingData>
300 for (
label changedFacei = 0; changedFacei < nFaces; changedFacei++)
302 const Type& neighbourWallInfo = changedFacesInfo[changedFacei];
303 label patchFacei = changedFaces[changedFacei];
307 Type& currentWallInfo = allFaceInfo_[meshFacei];
309 if (!currentWallInfo.equal(neighbourWallInfo, td_))
323 template<
class Type,
class TrackingData>
327 const label startFacei,
336 label nChangedPatchFaces = 0;
338 for (
label i = 0; i < nFaces; i++)
340 label patchFacei = i + startFacei;
344 if (changedFace_[meshFacei])
346 changedPatchFaces[nChangedPatchFaces] = patchFacei;
347 changedPatchFacesInfo[nChangedPatchFaces] = allFaceInfo_[meshFacei];
348 nChangedPatchFaces++;
351 return nChangedPatchFaces;
355 template<
class Type,
class TrackingData>
365 for (
label i = 0; i < nFaces; i++)
367 faceInfo[i].transform(patch, faceLabels[i], transform, td_);
372 template<
class Type,
class TrackingData>
391 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[
patchi]);
399 nSendFaces = getChangedPatchFaces
410 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
412 <<
" Sending:" << nSendFaces
432 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[
patchi]);
441 fromNeighbour >> receiveFaces >> receiveFacesInfo;
446 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
448 <<
" Receiving:" << receiveFaces.size()
474 template<
class Type,
class TrackingData>
483 if (isA<cyclicPolyPatch>(patch))
486 refCast<const cyclicPolyPatch>(patch);
495 nReceiveFaces = getChangedPatchFaces
507 <<
" Changed : " << nReceiveFaces
532 checkCyclic(cycPatch);
539 template<
class Type,
class TrackingData>
570 if (y.valid(solver_.
data()))
572 label meshFacei = -1;
576 meshFacei = patch_.
start() + facei;
601 if (isA<cyclicAMIPolyPatch>(patch))
604 refCast<const cyclicAMIPolyPatch>(patch);
612 List<Type> sendInfo(nbrPatch.patchSlice(allFaceInfo_));
624 if (cycPatch.
owner())
639 cycPatch.
AMIs()[i].interpolateToSource
649 cycPatch.
AMIs()[i].interpolateToSource
661 forAll(nbrPatch.AMIs(), i)
663 if (nbrPatch.AMITransforms()[i].transformsPosition())
671 nbrPatch.AMITransforms()[i],
697 forAll(receiveInfo, patchFacei)
699 if (receiveInfo[patchFacei].valid(td_))
701 if (receiveFaces.size() != patchFacei)
703 receiveInfo[receiveFaces.size()] =
704 receiveInfo[patchFacei];
706 receiveFaces.
append(patchFacei);
736 template<
class Type,
class TrackingData>
747 forAll(explicitConnections_, connI)
749 const labelPair& baffle = explicitConnections_[connI];
751 label f0 = baffle[0];
752 if (changedFace_[f0])
754 f0Baffle.append(connI);
755 f0Info.append(allFaceInfo_[f0]);
759 if (changedFace_[f1])
761 f1Baffle.append(connI);
762 f1Info.append(allFaceInfo_[f1]);
771 const labelPair& baffle = explicitConnections_[f1Baffle[index]];
773 label f0 = baffle[0];
774 Type& currentWallInfo = allFaceInfo_[f0];
776 if (!currentWallInfo.equal(f1Info[index], td_))
790 const labelPair& baffle = explicitConnections_[f0Baffle[index]];
793 Type& currentWallInfo = allFaceInfo_[
f1];
795 if (!currentWallInfo.equal(f0Info[index], td_))
811 template<
class Type,
class TrackingData>
821 explicitConnections_(0),
822 allFaceInfo_(allFaceInfo),
823 allCellInfo_(allCellInfo),
825 changedFace_(mesh_.nFaces(),
false),
826 changedFaces_(mesh_.nFaces()),
827 changedCell_(mesh_.nCells(),
false),
828 changedCells_(mesh_.nCells()),
829 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
835 nUnvisitedCells_(mesh_.nCells()),
836 nUnvisitedFaces_(mesh_.nFaces())
840 allFaceInfo.
size() != mesh_.nFaces()
841 || allCellInfo.
size() != mesh_.nCells()
845 <<
"face and cell storage not the size of mesh faces, cells:" 847 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 848 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 849 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 850 <<
" mesh_.nCells():" << mesh_.nCells()
856 template<
class Type,
class TrackingData>
869 explicitConnections_(0),
870 allFaceInfo_(allFaceInfo),
871 allCellInfo_(allCellInfo),
873 changedFace_(mesh_.nFaces(),
false),
874 changedFaces_(mesh_.nFaces()),
875 changedCell_(mesh_.nCells(),
false),
876 changedCells_(mesh_.nCells()),
877 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
883 nUnvisitedCells_(mesh_.nCells()),
884 nUnvisitedFaces_(mesh_.nFaces())
888 allFaceInfo.
size() != mesh_.nFaces()
889 || allCellInfo.
size() != mesh_.nCells()
893 <<
"face and cell storage not the size of mesh faces, cells:" 895 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 896 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 897 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 898 <<
" mesh_.nCells():" << mesh_.nCells()
903 setFaceInfo(changedFaces, changedFacesInfo);
906 label iter = iterate(maxIter);
908 if ((maxIter > 0) && (iter >= maxIter))
911 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl 912 <<
" maxIter:" << maxIter <<
endl 913 <<
" nChangedCells:" << changedCells_.size() <<
endl 914 <<
" nChangedFaces:" << changedFaces_.size() <<
endl 920 template<
class Type,
class TrackingData>
925 const bool handleCyclicAMI,
935 explicitConnections_(explicitConnections),
936 allFaceInfo_(allFaceInfo),
937 allCellInfo_(allCellInfo),
939 changedFace_(mesh_.nFaces(),
false),
940 changedFaces_(mesh_.nFaces()),
941 changedCell_(mesh_.nCells(),
false),
942 changedCells_(mesh_.nCells()),
943 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
950 nUnvisitedCells_(mesh_.nCells()),
951 nUnvisitedFaces_(mesh_.nFaces())
955 allFaceInfo.
size() != mesh_.nFaces()
956 || allCellInfo.
size() != mesh_.nCells()
960 <<
"face and cell storage not the size of mesh faces, cells:" 962 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 963 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 964 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 965 <<
" mesh_.nCells():" << mesh_.nCells()
970 setFaceInfo(changedFaces, changedFacesInfo);
973 label iter = iterate(maxIter);
975 if ((maxIter > 0) && (iter >= maxIter))
978 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl 979 <<
" maxIter:" << maxIter <<
endl 980 <<
" nChangedCells:" << changedCells_.size() <<
endl 981 <<
" nChangedFaces:" << changedFaces_.size() <<
endl 989 template<
class Type,
class TrackingData>
992 return nUnvisitedCells_;
996 template<
class Type,
class TrackingData>
999 return nUnvisitedFaces_;
1003 template<
class Type,
class TrackingData>
1008 const labelList& owner = mesh_.faceOwner();
1009 const labelList& neighbour = mesh_.faceNeighbour();
1010 label nInternalFaces = mesh_.nInternalFaces();
1012 forAll(changedFaces_, changedFacei)
1014 label facei = changedFaces_[changedFacei];
1015 if (!changedFace_[facei])
1019 <<
" not marked as having been changed" 1024 const Type& neighbourWallInfo = allFaceInfo_[facei];
1029 label celli = owner[facei];
1030 Type& currentWallInfo = allCellInfo_[celli];
1032 if (!currentWallInfo.equal(neighbourWallInfo, td_))
1045 if (facei < nInternalFaces)
1047 celli = neighbour[facei];
1048 Type& currentWallInfo2 = allCellInfo_[celli];
1050 if (!currentWallInfo2.equal(neighbourWallInfo, td_))
1064 changedFace_[facei] =
false;
1068 changedFaces_.clear();
1072 Pout<<
" Changed cells : " << changedCells_.size() <<
endl;
1076 label totNChanged = changedCells_.size();
1084 template<
class Type,
class TrackingData>
1091 forAll(changedCells_, changedCelli)
1093 label celli = changedCells_[changedCelli];
1094 if (!changedCell_[celli])
1097 <<
"Cell " << celli <<
" not marked as having been changed" 1101 const Type& neighbourWallInfo = allCellInfo_[celli];
1105 const labelList& faceLabels = cells[celli];
1106 forAll(faceLabels, faceLabelI)
1108 label facei = faceLabels[faceLabelI];
1109 Type& currentWallInfo = allFaceInfo_[facei];
1111 if (!currentWallInfo.equal(neighbourWallInfo, td_))
1125 changedCell_[celli] =
false;
1129 changedCells_.clear();
1133 handleExplicitConnections();
1135 if (hasCyclicPatches_)
1138 handleCyclicPatches();
1141 if (hasCyclicAMIPatches_)
1143 handleAMICyclicPatches();
1146 if (Pstream::parRun())
1149 handleProcPatches();
1154 Pout<<
" Changed faces : " << changedFaces_.size() <<
endl;
1158 label totNChanged = changedFaces_.size();
1167 template<
class Type,
class TrackingData>
1170 if (hasCyclicPatches_)
1173 handleCyclicPatches();
1176 if (hasCyclicAMIPatches_)
1178 handleAMICyclicPatches();
1181 if (Pstream::parRun())
1184 handleProcPatches();
1189 while (iter < maxIter)
1193 Info<<
" Iteration " << iter <<
endl;
1202 Info<<
" Total changed cells : " << nCells <<
endl;
1214 Info<<
" Total changed faces : " << nFaces <<
nl 1215 <<
" Total evaluations : " << nEvals_ <<
nl 1216 <<
" Remaining unvisited cells: " << nUnvisitedCells_ <<
nl 1217 <<
" 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.
const word & name() const
Return name.
Inter-processor communication reduction functions.
bool updateCell(const fvMesh &, const label thisCelli, const labelPair &neighbourPatchAndFacei, const FvWallInfoBase< WallInfo, Derived > &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
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.
void transform(const polyPatch &patch, const label nFaces, const labelList &faceLabels, const transformer &transform, List< Type > &faceInfo)
Transform across an interface. Implementation referred to Type.
#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.
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.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
virtual const transformer & transform() const
Return transformation between the coupled patches.
const cyclicPolyPatch & nbrPatch() const
const polyMesh & mesh() const
Access mesh.
void handleProcPatches()
Merge data from across processor boundaries.
Neighbour processor patch.
bool updateFace(const fvMesh &, const labelPair &thisPatchAndFacei, const label neighbourCelli, const FvWallInfoBase< WallInfo, Derived > &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
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.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
bool hasPatch() const
Has cyclic patch?
const PtrList< AMIInterpolation > & AMIs() const
Return a reference to the AMI interpolators.
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.
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)
FaceCellWave(const polyMesh &, UList< Type > &allFaceInfo, UList< Type > &allCellInfo, TrackingData &td=defaultTrackingData_)
virtual const transformer & transform() const
Return null transform between processor patches.
label getChangedPatchFaces(const polyPatch &patch, const label startFacei, const label nFaces, labelList &changedPatchFaces, List< Type > &changedPatchFacesInfo) const
Extract info for single patch only.
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.
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.
const dimensionedScalar e
Elementary charge.
dimensionSet transform(const dimensionSet &)
treeBoundBox combine(const treeBoundBox &a, const treeBoundBox &b)
virtual label faceToCell()
Propagate from face to cell. Returns total number of cells.
label getUnsetCells() const
Get number of unvisited cells, i.e. cells that were not (yet)