44template<
class Type,
class TrackingData>
47template<
class Type,
class TrackingData>
50template<
class Type,
class TrackingData>
56 template<
class Type,
class TrackingData>
86 if (
y.valid(solver_.
data()))
91 meshFacei = patch_.
start() + facei;
113template<
class Type,
class TrackingData>
117 const label neighbourFacei,
118 const Type& neighbourInfo,
133 const bool propagate =
146 if (changedCell_.set(celli))
148 changedCells_.append(celli);
152 if (!wasValid && cellInfo.valid(td_))
161template<
class Type,
class TrackingData>
165 const label neighbourCelli,
166 const Type& neighbourInfo,
179 const bool wasValid = faceInfo.valid(td_);
181 const bool propagate =
194 if (changedFace_.set(facei))
196 changedFaces_.append(facei);
200 if (!wasValid && faceInfo.valid(td_))
209template<
class Type,
class TrackingData>
213 const Type& neighbourInfo,
226 const bool wasValid = faceInfo.valid(td_);
228 const bool propagate =
240 if (changedFace_.set(facei))
242 changedFaces_.append(facei);
246 if (!wasValid && faceInfo.valid(td_))
255template<
class Type,
class TrackingData>
264 refCast<const cyclicPolyPatch>(patch).
neighbPatch();
268 const label i1 = patch.start() + patchFacei;
269 const label i2 = nbrPatch.
start() + patchFacei;
273 !allFaceInfo_[i1].sameGeometry
283 <<
" faceInfo:" << allFaceInfo_[i1]
284 <<
" otherfaceInfo:" << allFaceInfo_[i2]
288 if (changedFace_.test(i1) != changedFace_.test(i2))
291 <<
" faceInfo:" << allFaceInfo_[i1]
292 <<
" otherfaceInfo:" << allFaceInfo_[i2]
293 <<
" changedFace:" << changedFace_.test(i1)
294 <<
" otherchangedFace:" << changedFace_.test(i2)
301template<
class Type,
class TrackingData>
302template<
class PatchType>
305 for (
const polyPatch&
p : mesh_.boundaryMesh())
307 if (isA<PatchType>(
p))
316template<
class Type,
class TrackingData>
323 const bool wasValid = allFaceInfo_[facei].valid(td_);
326 allFaceInfo_[facei] = faceInfo;
329 if (!wasValid && allFaceInfo_[facei].valid(td_))
335 changedFace_.set(facei);
336 changedFaces_.append(facei);
340template<
class Type,
class TrackingData>
347 forAll(changedFaces, changedFacei)
349 const label facei = changedFaces[changedFacei];
351 const bool wasValid = allFaceInfo_[facei].valid(td_);
354 allFaceInfo_[facei] = changedFacesInfo[changedFacei];
357 if (!wasValid && allFaceInfo_[facei].valid(td_))
363 changedFace_.
set(facei);
364 changedFaces_.append(facei);
369template<
class Type,
class TrackingData>
380 for (label changedFacei = 0; changedFacei <
nFaces; ++changedFacei)
382 const Type& newInfo = changedFacesInfo[changedFacei];
383 const label patchFacei = changedFaces[changedFacei];
385 const label meshFacei = patch.start() + patchFacei;
387 Type& currInfo = allFaceInfo_[meshFacei];
389 if (!currInfo.equal(newInfo, td_))
403template<
class Type,
class TrackingData>
407 const label startFacei,
418 for (label i = 0; i <
nFaces; ++i)
420 const label patchFacei = i + startFacei;
421 const label meshFacei = patch.start() + patchFacei;
423 if (changedFace_.test(meshFacei))
425 changedPatchFaces[nChanged] = patchFacei;
426 changedPatchFacesInfo[nChanged] = allFaceInfo_[meshFacei];
435template<
class Type,
class TrackingData>
448 for (label i = 0; i <
nFaces; ++i)
450 const label patchFacei = faceLabels[i];
451 const label meshFacei = patch.start() + patchFacei;
453 faceInfo[i].leaveDomain(mesh_, patch, patchFacei, fc[meshFacei], td_);
458template<
class Type,
class TrackingData>
471 for (label i = 0; i <
nFaces; ++i)
473 const label patchFacei = faceLabels[i];
474 const label meshFacei = patch.start() + patchFacei;
476 faceInfo[i].enterDomain(mesh_, patch, patchFacei, fc[meshFacei], td_);
481template<
class Type,
class TrackingData>
491 if (rotTensor.
size() == 1)
493 const tensor&
T = rotTensor[0];
495 for (label facei = 0; facei <
nFaces; ++facei)
497 faceInfo[facei].transform(mesh_,
T, td_);
502 for (label facei = 0; facei <
nFaces; ++facei)
504 faceInfo[facei].transform(mesh_, rotTensor[facei], td_);
510template<
class Type,
class TrackingData>
514 const label cycOffset,
522 for (label facei = 0; facei <
nFaces; ++facei)
524 faces[facei] += cycOffset;
529template<
class Type,
class TrackingData>
543 for (
const label patchi : procPatches)
546 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
554 nSendFaces = getChangedPatchFaces
574 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
576 <<
" Sending:" << nSendFaces
591 for (
const label patchi : procPatches)
594 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
602 fromNeighbour >> receiveFaces >> receiveFacesInfo;
607 Pout<<
" Processor patch " << patchi <<
' ' << procPatch.
name()
609 <<
" Receiving:" << receiveFaces.
size()
645template<
class Type,
class TrackingData>
650 for (
const polyPatch& patch : mesh_.boundaryMesh())
656 const auto& cycPatch = *cpp;
665 nReceiveFaces = getChangedPatchFaces
683 if (!cycPatch.parallel())
696 Pout<<
" Cyclic patch "
697 << cycPatch.index() <<
' ' << cycPatch.
name()
698 <<
" Changed : " << nReceiveFaces
722 checkCyclic(cycPatch);
729template<
class Type,
class TrackingData>
734 for (
const polyPatch& patch : mesh_.boundaryMesh())
740 const auto& cycPatch = *cpp;
761 sendInfo[i].leaveDomain(mesh_, nbrPatch, i, fc[i], td_);
768 if (cycPatch.applyLowWeightCorrection())
772 cycPatch.patchInternalList(allCellInfo_)
775 cycPatch.interpolate(sendInfo, cmb, receiveInfo, defVals);
779 cycPatch.interpolate(sendInfo, cmb, receiveInfo);
784 if (!cycPatch.parallel())
794 if (!cycPatch.parallel() || cycPatch.separated())
800 receiveInfo[i].enterDomain(mesh_, cycPatch, i, fc[i], td_);
807 const label meshFacei = cycPatch.start()+i;
809 const Type& newInfo = receiveInfo[i];
811 Type& currInfo = allFaceInfo_[meshFacei];
813 if (newInfo.valid(td_) && !currInfo.equal(newInfo, td_))
829template<
class Type,
class TrackingData>
832 changedBaffles_.clear();
835 for (
const labelPair& baffle : explicitConnections_)
837 const label f0 = baffle.first();
838 const label f1 = baffle.second();
840 if (changedFace_.test(f0))
846 if (changedFace_.test(f1))
858 const label tgtFace = updated.first;
859 const Type& newInfo = updated.second;
861 Type& currInfo = allFaceInfo_[tgtFace];
863 if (!currInfo.equal(newInfo, td_))
875 changedBaffles_.clear();
881template<
class Type,
class TrackingData>
891 explicitConnections_(),
892 allFaceInfo_(allFaceInfo),
893 allCellInfo_(allCellInfo),
895 changedFace_(mesh_.
nFaces(), false),
896 changedCell_(mesh_.nCells(), false),
897 changedFaces_(mesh_.
nFaces()),
898 changedCells_(mesh_.nCells()),
899 changedBaffles_(2*explicitConnections_.size()),
906 nUnvisitedCells_(mesh_.nCells()),
907 nUnvisitedFaces_(mesh_.
nFaces())
916 <<
"face and cell storage not the size of mesh faces, cells:" <<
nl
926template<
class Type,
class TrackingData>
939 explicitConnections_(),
940 allFaceInfo_(allFaceInfo),
941 allCellInfo_(allCellInfo),
943 changedFace_(mesh_.
nFaces(), false),
944 changedCell_(mesh_.nCells(), false),
945 changedFaces_(mesh_.
nFaces()),
946 changedCells_(mesh_.nCells()),
947 changedBaffles_(2*explicitConnections_.size()),
954 nUnvisitedCells_(mesh_.nCells()),
955 nUnvisitedFaces_(mesh_.
nFaces())
964 <<
"face and cell storage not the size of mesh faces, cells:" <<
nl
976 const label iter =
iterate(maxIter);
978 if ((maxIter > 0) && (iter >= maxIter))
981 <<
"Maximum number of iterations reached. Increase maxIter." <<
nl
982 <<
" maxIter:" << maxIter <<
nl
990template<
class Type,
class TrackingData>
995 const bool handleCyclicAMI,
1000 const label maxIter,
1005 explicitConnections_(explicitConnections),
1006 allFaceInfo_(allFaceInfo),
1007 allCellInfo_(allCellInfo),
1009 changedFace_(mesh_.
nFaces(), false),
1010 changedCell_(mesh_.nCells(), false),
1011 changedFaces_(mesh_.
nFaces()),
1012 changedCells_(mesh_.nCells()),
1013 changedBaffles_(2*explicitConnections_.size()),
1015 hasCyclicAMIPatches_
1021 nUnvisitedCells_(mesh_.nCells()),
1022 nUnvisitedFaces_(mesh_.
nFaces())
1031 <<
"face and cell storage not the size of mesh faces, cells:" <<
nl
1043 const label iter =
iterate(maxIter);
1045 if ((maxIter > 0) && (iter >= maxIter))
1048 <<
"Maximum number of iterations reached. Increase maxIter." <<
nl
1049 <<
" maxIter:" << maxIter <<
nl
1059template<
class Type,
class TrackingData>
1062 return nUnvisitedCells_;
1066template<
class Type,
class TrackingData>
1069 return nUnvisitedFaces_;
1073template<
class Type,
class TrackingData>
1078 const labelList& owner = mesh_.faceOwner();
1079 const labelList& neighbour = mesh_.faceNeighbour();
1080 const label nInternalFaces = mesh_.nInternalFaces();
1082 for (
const label facei : changedFaces_)
1084 if (!changedFace_.test(facei))
1088 <<
" not marked as having been changed"
1092 const Type& newInfo = allFaceInfo_[facei];
1098 const label celli = owner[facei];
1099 Type& currInfo = allCellInfo_[celli];
1101 if (!currInfo.equal(newInfo, td_))
1115 if (facei < nInternalFaces)
1117 const label celli = neighbour[facei];
1118 Type& currInfo = allCellInfo_[celli];
1120 if (!currInfo.equal(newInfo, td_))
1134 changedFace_.unset(facei);
1138 changedFaces_.clear();
1142 Pout<<
" Changed cells : " << changedCells_.size() <<
endl;
1150template<
class Type,
class TrackingData>
1157 for (
const label celli : changedCells_)
1159 if (!changedCell_.test(celli))
1162 <<
"Cell " << celli <<
" not marked as having been changed"
1166 const Type& newInfo = allCellInfo_[celli];
1171 for (
const label facei : faceLabels)
1173 Type& currInfo = allFaceInfo_[facei];
1175 if (!currInfo.equal(newInfo, td_))
1189 changedCell_.unset(celli);
1193 changedCells_.clear();
1197 handleExplicitConnections();
1199 if (hasCyclicPatches_)
1201 handleCyclicPatches();
1204 if (hasCyclicAMIPatches_)
1206 handleAMICyclicPatches();
1211 handleProcPatches();
1216 Pout<<
" Changed faces : " << changedFaces_.size() <<
endl;
1226template<
class Type,
class TrackingData>
1234 if (hasCyclicPatches_)
1236 handleCyclicPatches();
1239 if (hasCyclicAMIPatches_)
1241 handleAMICyclicPatches();
1246 handleProcPatches();
1251 for (; iter < maxIter; ++iter)
1255 Info<<
" Iteration " << iter <<
endl;
1264 Info<<
" Total evaluations : "
1266 <<
" Changed cells / faces : "
1268 <<
" Pending cells / faces : "
1269 << nUnvisitedCells_ <<
" / " << nUnvisitedFaces_ <<
nl;
Inter-processor communication reduction functions.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
DynamicList< label > changedCells_
void handleExplicitConnections()
Merge data across explicitly provided local connections.
DynamicList< label > changedFaces_
List of changed faces.
void handleProcPatches()
Merge data from across processor boundaries.
void leaveDomain(const polyPatch &patch, const label nFaces, const labelUList &faceLabels, List< Type > &faceInfo) const
Handle leaving domain. Implementation referred to Type.
const polyMesh & mesh() const
Access mesh.
static scalar propagationTol()
Access to tolerance.
label nUnvisitedCells() const
void mergeFaceInfo(const polyPatch &patch, const label nFaces, const labelUList &changedFaces, const List< Type > &changedFacesInfo)
Merge received patch data into global data.
bool hasPatch() const
Has cyclic patch?
void handleAMICyclicPatches()
Merge data from across AMI cyclics.
void checkCyclic(const polyPatch &pPatch) const
Debugging: check info on both sides of cyclic.
void enterDomain(const polyPatch &patch, const label nFaces, const labelUList &faceLabels, List< Type > &faceInfo) const
Handle leaving domain. Implementation referred to Type.
virtual label iterate(const label maxIter)
Iterate until no changes or maxIter reached.
void handleCyclicPatches()
Merge data from across cyclics.
void setFaceInfo(const label facei, const Type &faceInfo)
Set single initial changed face.
bool updateCell(const label celli, const label neighbourFacei, const Type &neighbourInfo, const scalar tol, Type &cellInfo)
Updates cellInfo with information from neighbour.
label getChangedPatchFaces(const polyPatch &patch, const label startFacei, const label nFaces, labelList &changedPatchFaces, List< Type > &changedPatchFacesInfo) const
Extract info for single patch only.
virtual label faceToCell()
Propagate from face to cell.
UList< Type > & allCellInfo()
Access allCellInfo.
const polyMesh & mesh_
Reference to mesh.
bool updateFace(const label facei, const label neighbourCelli, const Type &neighbourInfo, const scalar tol, Type &faceInfo)
Updates faceInfo with information from neighbour.
std::pair< label, Type > taggedInfoType
Information tagged with a source or destination id.
virtual label cellToFace()
Propagate from cell to face.
UList< Type > & allFaceInfo()
Access allFaceInfo.
label nUnvisitedFaces() const
Get number of unvisited faces.
const TrackingData & data() const
Additional data to be passed into container.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
virtual const fileName & name() const
Get the name of the stream.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void finishedSends(const bool wait=true)
Mark sends as done.
SubField is a Field obtained as a section of another Field, without its own allocation....
A List obtained as a section of another List.
void size(const label n)
Older name for setAddressableSize.
static bool & parRun() noexcept
Test if this a parallel run.
Holds information regarding type of cell. Used in inside/outside determination in cellClassification.
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const cellInfo &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
bool valid(TrackingData &td) const
Changed or contains original (invalid) value.
A topoSetFaceSource to select all the faces from given cellSet(s).
combine(FaceCellWave< Type, TrackingData > &solver, const cyclicAMIPolyPatch &patch)
virtual bool separated() const
Are the planes separated.
virtual bool parallel() const
Are the cyclic planes parallel.
virtual const tensorField & forwardT() const
Return face transformation tensor.
Cyclic patch for Arbitrary Mesh Interface (AMI)
virtual bool owner() const
Does this side own the patch?
virtual const cyclicAMIPolyPatch & neighbPatch() const
Return a reference to the neighbour patch.
const cyclicPolyPatch & neighbPatch() const
A topoSetCellSource to select all cells based on usage in given faceSet(s), e.g. select cells that ar...
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
const labelList & processorPatches() const noexcept
Return list of processor patch labels.
const vector & offset() const noexcept
Offset vector (from patch faces to destination mesh objects)
const word & name() const noexcept
The patch name.
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
const List< T >::subList patchSlice(const UList< T > &l) const
Slice list to patch.
label start() const
Return start label of this patch in the polyMesh face list.
const vectorField::subField faceCentres() const
Return face centres.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
Neighbour processor patch.
int neighbProcNo() const
Return neighbour processor number.
Base class for solution control classes.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.