41 template<
class Type,
class TrackingData>
44 template<
class Type,
class TrackingData>
47 template<
class Type,
class TrackingData>
53 template<
class Type,
class TrackingData>
81 if (y.valid(solver_.
data()))
86 meshFaceI = patch_.
start() + faceI;
114 template<
class Type,
class TrackingData>
118 const label neighbourFaceI,
119 const Type& neighbourInfo,
126 bool wasValid = cellInfo.valid(td_);
141 if (!changedCell_[cellI])
143 changedCell_[cellI] =
true;
144 changedCells_[nChangedCells_++] = cellI;
148 if (!wasValid && cellInfo.valid(td_))
162 template<
class Type,
class TrackingData>
166 const label neighbourCellI,
167 const Type& neighbourInfo,
174 bool wasValid = faceInfo.valid(td_);
189 if (!changedFace_[faceI])
191 changedFace_[faceI] =
true;
192 changedFaces_[nChangedFaces_++] = faceI;
196 if (!wasValid && faceInfo.valid(td_))
210 template<
class Type,
class TrackingData>
214 const Type& neighbourInfo,
221 bool wasValid = faceInfo.valid(td_);
235 if (!changedFace_[faceI])
237 changedFace_[faceI] =
true;
238 changedFaces_[nChangedFaces_++] = faceI;
242 if (!wasValid && faceInfo.valid(td_))
252 template<
class Type,
class TrackingData>
259 refCast<const cyclicPolyPatch>(patch).neighbPatch();
268 !allFaceInfo_[i1].sameGeometry
279 "FaceCellWave<Type, TrackingData>" 280 "::checkCyclic(const polyPatch&)" 281 ) <<
"problem: i:" << i1 <<
" otheri:" << i2
282 <<
" faceInfo:" << allFaceInfo_[i1]
283 <<
" otherfaceInfo:" << allFaceInfo_[i2]
287 if (changedFace_[i1] != changedFace_[i2])
291 "FaceCellWave<Type, TrackingData>" 292 "::checkCyclic(const polyPatch&)" 293 ) <<
" problem: i:" << i1 <<
" otheri:" << i2
294 <<
" faceInfo:" << allFaceInfo_[i1]
295 <<
" otherfaceInfo:" << allFaceInfo_[i2]
296 <<
" changedFace:" << changedFace_[i1]
297 <<
" otherchangedFace:" << changedFace_[i2]
305 template<
class Type,
class TrackingData>
306 template<
class PatchType>
309 forAll(mesh_.boundaryMesh(), patchI)
311 if (isA<PatchType>(mesh_.boundaryMesh()[patchI]))
321 template<
class Type,
class TrackingData>
328 forAll(changedFaces, changedFaceI)
330 label faceI = changedFaces[changedFaceI];
332 bool wasValid = allFaceInfo_[faceI].valid(td_);
335 allFaceInfo_[faceI] = changedFacesInfo[changedFaceI];
338 if (!wasValid && allFaceInfo_[faceI].valid(td_))
345 changedFace_[faceI] =
true;
346 changedFaces_[nChangedFaces_++] = faceI;
352 template<
class Type,
class TrackingData>
361 for (
label changedFaceI = 0; changedFaceI < nFaces; changedFaceI++)
363 const Type& neighbourWallInfo = changedFacesInfo[changedFaceI];
364 label patchFaceI = changedFaces[changedFaceI];
368 Type& currentWallInfo = allFaceInfo_[meshFaceI];
370 if (!currentWallInfo.equal(neighbourWallInfo, td_))
387 template<
class Type,
class TrackingData>
391 const label startFaceI,
397 label nChangedPatchFaces = 0;
399 for (
label i = 0; i < nFaces; i++)
401 label patchFaceI = i + startFaceI;
405 if (changedFace_[meshFaceI])
407 changedPatchFaces[nChangedPatchFaces] = patchFaceI;
408 changedPatchFacesInfo[nChangedPatchFaces] = allFaceInfo_[meshFaceI];
409 nChangedPatchFaces++;
412 return nChangedPatchFaces;
417 template<
class Type,
class TrackingData>
428 for (
label i = 0; i < nFaces; i++)
430 label patchFaceI = faceLabels[i];
433 faceInfo[i].leaveDomain(mesh_, patch, patchFaceI, fc[meshFaceI], td_);
439 template<
class Type,
class TrackingData>
450 for (
label i = 0; i < nFaces; i++)
452 label patchFaceI = faceLabels[i];
455 faceInfo[i].enterDomain(mesh_, patch, patchFaceI, fc[meshFaceI], td_);
461 template<
class Type,
class TrackingData>
469 if (rotTensor.
size() == 1)
471 const tensor&
T = rotTensor[0];
473 for (
label faceI = 0; faceI < nFaces; faceI++)
475 faceInfo[faceI].transform(mesh_, T, td_);
480 for (
label faceI = 0; faceI < nFaces; faceI++)
482 faceInfo[faceI].transform(mesh_, rotTensor[faceI], td_);
489 template<
class Type,
class TrackingData>
493 const label cycOffset,
498 for (
label faceI = 0; faceI < nFaces; faceI++)
500 faces[faceI] += cycOffset;
506 template<
class Type,
class TrackingData>
520 label patchI = procPatches[i];
523 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchI]);
531 nSendFaces = getChangedPatchFaces
551 Pout<<
" Processor patch " << patchI <<
' ' << procPatch.
name()
553 <<
" Sending:" << nSendFaces
570 label patchI = procPatches[i];
573 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchI]);
581 fromNeighbour >> receiveFaces >> receiveFacesInfo;
586 Pout<<
" Processor patch " << patchI <<
' ' << procPatch.
name()
588 <<
" Receiving:" << receiveFaces.size()
625 template<
class Type,
class TrackingData>
628 forAll(mesh_.boundaryMesh(), patchI)
632 if (isA<cyclicPolyPatch>(patch))
635 refCast<const cyclicPolyPatch>(patch).neighbPatch();
643 nReceiveFaces = getChangedPatchFaces
662 refCast<const cyclicPolyPatch>(patch);
677 Pout<<
" Cyclic patch " << patchI <<
' ' << cycPatch.
name()
678 <<
" Changed : " << nReceiveFaces
702 checkCyclic(cycPatch);
710 template<
class Type,
class TrackingData>
713 forAll(mesh_.boundaryMesh(), patchI)
717 if (isA<cyclicAMIPolyPatch>(patch))
720 refCast<const cyclicAMIPolyPatch>(patch);
726 refCast<const cyclicAMIPolyPatch>(patch).neighbPatch();
743 sendInfo[i].leaveDomain(mesh_, nbrPatch, i, fc[i], td_);
757 cycPatch.
interpolate(sendInfo, cmb, receiveInfo, defVals);
782 receiveInfo[i].enterDomain(mesh_, cycPatch, i, fc[i], td_);
791 Type& currentWallInfo = allFaceInfo_[meshFaceI];
795 receiveInfo[i].valid(td_)
796 && !currentWallInfo.equal(receiveInfo[i], td_)
816 template<
class Type,
class TrackingData>
826 allFaceInfo_(allFaceInfo),
827 allCellInfo_(allCellInfo),
829 changedFace_(mesh_.nFaces(),
false),
830 changedFaces_(mesh_.nFaces()),
832 changedCell_(mesh_.nCells(),
false),
833 changedCells_(mesh_.nCells()),
835 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
841 nUnvisitedCells_(mesh_.nCells()),
842 nUnvisitedFaces_(mesh_.nFaces())
846 allFaceInfo.
size() != mesh_.nFaces()
847 || allCellInfo.
size() != mesh_.nCells()
852 "FaceCellWave<Type, TrackingData>::FaceCellWave" 853 "(const polyMesh&, const labelList&, const List<Type>," 854 " UList<Type>&, UList<Type>&, const label maxIter)" 855 ) <<
"face and cell storage not the size of mesh faces, cells:" 857 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 858 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 859 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 860 <<
" mesh_.nCells():" << mesh_.nCells()
868 template<
class Type,
class TrackingData>
881 allFaceInfo_(allFaceInfo),
882 allCellInfo_(allCellInfo),
884 changedFace_(mesh_.nFaces(),
false),
885 changedFaces_(mesh_.nFaces()),
887 changedCell_(mesh_.nCells(),
false),
888 changedCells_(mesh_.nCells()),
890 hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
896 nUnvisitedCells_(mesh_.nCells()),
897 nUnvisitedFaces_(mesh_.nFaces())
901 allFaceInfo.
size() != mesh_.nFaces()
902 || allCellInfo.
size() != mesh_.nCells()
907 "FaceCellWave<Type, TrackingData>::FaceCellWave" 908 "(const polyMesh&, const labelList&, const List<Type>," 909 " UList<Type>&, UList<Type>&, const label maxIter)" 910 ) <<
"face and cell storage not the size of mesh faces, cells:" 912 <<
" allFaceInfo :" << allFaceInfo.
size() <<
endl 913 <<
" mesh_.nFaces():" << mesh_.nFaces() <<
endl 914 <<
" allCellInfo :" << allCellInfo.
size() <<
endl 915 <<
" mesh_.nCells():" << mesh_.nCells()
920 setFaceInfo(changedFaces, changedFacesInfo);
923 label iter = iterate(maxIter);
925 if ((maxIter > 0) && (iter >= maxIter))
929 "FaceCellWave<Type, TrackingData>::FaceCellWave" 930 "(const polyMesh&, const labelList&, const List<Type>," 931 " UList<Type>&, UList<Type>&, const label maxIter)" 933 <<
"Maximum number of iterations reached. Increase maxIter." <<
endl 934 <<
" maxIter:" << maxIter <<
endl 935 <<
" nChangedCells:" << nChangedCells_ <<
endl 936 <<
" nChangedFaces:" << nChangedFaces_ <<
endl 945 template<
class Type,
class TrackingData>
948 return nUnvisitedCells_;
952 template<
class Type,
class TrackingData>
955 return nUnvisitedFaces_;
961 template<
class Type,
class TrackingData>
964 const labelList& owner = mesh_.faceOwner();
965 const labelList& neighbour = mesh_.faceNeighbour();
966 label nInternalFaces = mesh_.nInternalFaces();
970 label changedFaceI = 0;
971 changedFaceI < nChangedFaces_;
975 label faceI = changedFaces_[changedFaceI];
976 if (!changedFace_[faceI])
978 FatalErrorIn(
"FaceCellWave<Type, TrackingData>::faceToCell()")
980 <<
" not marked as having been changed" 985 const Type& neighbourWallInfo = allFaceInfo_[faceI];
990 label cellI = owner[faceI];
991 Type& currentWallInfo = allCellInfo_[cellI];
993 if (!currentWallInfo.equal(neighbourWallInfo, td_))
1006 if (faceI < nInternalFaces)
1008 cellI = neighbour[faceI];
1009 Type& currentWallInfo2 = allCellInfo_[cellI];
1011 if (!currentWallInfo2.equal(neighbourWallInfo, td_))
1025 changedFace_[faceI] =
false;
1033 Pout<<
" Changed cells : " << nChangedCells_ <<
endl;
1037 label totNChanged = nChangedCells_;
1046 template<
class Type,
class TrackingData>
1053 label changedCellI = 0;
1054 changedCellI < nChangedCells_;
1058 label cellI = changedCells_[changedCellI];
1059 if (!changedCell_[cellI])
1061 FatalErrorIn(
"FaceCellWave<Type, TrackingData>::cellToFace()")
1062 <<
"Cell " << cellI <<
" not marked as having been changed" 1066 const Type& neighbourWallInfo = allCellInfo_[cellI];
1070 const labelList& faceLabels = cells[cellI];
1071 forAll(faceLabels, faceLabelI)
1073 label faceI = faceLabels[faceLabelI];
1074 Type& currentWallInfo = allFaceInfo_[faceI];
1076 if (!currentWallInfo.equal(neighbourWallInfo, td_))
1090 changedCell_[cellI] =
false;
1096 if (hasCyclicPatches_)
1099 handleCyclicPatches();
1102 if (hasCyclicAMIPatches_)
1104 handleAMICyclicPatches();
1110 handleProcPatches();
1115 Pout<<
" Changed faces : " << nChangedFaces_ <<
endl;
1119 label totNChanged = nChangedFaces_;
1128 template<
class Type,
class TrackingData>
1131 if (hasCyclicPatches_)
1134 handleCyclicPatches();
1137 if (hasCyclicAMIPatches_)
1139 handleAMICyclicPatches();
1145 handleProcPatches();
1150 while (iter < maxIter)
1154 Info<<
" Iteration " << iter <<
endl;
1163 Info<<
" Total changed cells : " << nCells <<
endl;
1175 Info<<
" Total changed faces : " << nFaces <<
nl 1176 <<
" Total evaluations : " << nEvals_ <<
nl 1177 <<
" Remaining unvisited cells: " << nUnvisitedCells_ <<
nl 1178 <<
" Remaining unvisited faces: " << nUnvisitedFaces_ <<
endl;
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
virtual bool owner() const
Does this side own the patch?
static bool & parRun()
Is this a parallel run?
combine(FaceCellWave< Type, TrackingData > &solver, const cyclicAMIPolyPatch &patch)
virtual const tensorField & forwardT() const
Return face transformation tensor.
Pre-declare related SubField type.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Cyclic patch for Arbitrary Mesh Interface (AMI)
virtual bool separated() const
Are the planes separated.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void setFaceInfo(const labelList &changedFaces, const List< Type > &changedFacesInfo)
Set initial changed faces.
const word & name() const
Return name.
Output inter-processor communications stream operating on external buffer.
Input inter-processor communications stream operating on external buffer.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
A topoSetSource to select cells based on usage in faces.
label getUnsetCells() const
Get number of unvisited cells, i.e. cells that were not (yet)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
A patch is a list of labels that address the faces in the global face list.
const vectorField::subField faceCentres() const
Return face centres.
A topoSetSource to select a faceSet from cells.
virtual const cyclicAMIPolyPatch & neighbPatch() const
Return a reference to the neighbour patch.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Combine operator for AMIInterpolation.
Neighbour processor patch.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
virtual bool parallel() const
Are the cyclic planes parallel.
dimensionSet transform(const dimensionSet &)
const dimensionedScalar e
Elementary charge.
label cellToFace()
Propagate from cell to face. Returns total number of faces.
tmp< Field< Type > > interpolate(const Field< Type > &fld, const UList< Type > &defaultValues=UList< Type >()) const
Interpolate field.
label size() const
Return the number of elements in the UList.
errorManip< error > abort(error &err)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
const List< T >::subList patchSlice(const UList< T > &l) const
Slice list to patch.
bool applyLowWeightCorrection() const
Return true if applying the low weight correction.
const cellShapeList & cells
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
label start() const
Return start label of this patch in the polyMesh face list.
Holds information regarding type of cell. Used in inside/outside determination in cellClassification...
Mesh consisting of general polyhedral cells.
label faceToCell()
Propagate from face to cell. Returns total number of cells.
const polyMesh & mesh() const
Access mesh.
label getUnsetFaces() const
Get number of unvisited faces.
int neighbProcNo() const
Return neigbour processor number.
const TrackingData & data() const
Additional data to be passed into container.
A List obtained as a section of another List.
static scalar propagationTol()
Access to tolerance.
label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
const UIndirectList< T > patchInternalList(const UList< T > &internalValues) const
Extract face cell data.
const labelList & processorPatches() const
Return list of processor patch labels.
prefixOSstream Pout(cout,"Pout")