34 const label fineLevelIndex
37 const lduMesh& fineMesh = meshLevel(fineLevelIndex);
46 const labelField& restrictMap = restrictAddressing(fineLevelIndex);
48 if (
min(restrictMap) == -1)
54 if (restrictMap.
size() != fineMeshAddr.
size())
57 <<
"restrict map does not correspond to fine level. " <<
endl 58 <<
" Sizes: restrictMap: " << restrictMap.
size()
59 <<
" nEqns: " << fineMeshAddr.
size()
65 const label nCoarseCells = nCells_[fineLevelIndex];
76 labelList cCellFaces(maxNnbrs*nCoarseCells);
79 faceRestrictAddressing_.set(fineLevelIndex,
new labelList(nFineFaces));
80 labelList& faceRestrictAddr = faceRestrictAddressing_[fineLevelIndex];
86 label& nCoarseFaces = nFaces_[fineLevelIndex];
90 forAll(upperAddr, fineFacei)
92 label rmUpperAddr = restrictMap[upperAddr[fineFacei]];
93 label rmLowerAddr = restrictMap[lowerAddr[fineFacei]];
95 if (rmUpperAddr == rmLowerAddr)
100 faceRestrictAddr[fineFacei] = -(rmUpperAddr + 1);
106 label cOwn = rmUpperAddr;
107 label cNei = rmLowerAddr;
110 if (rmUpperAddr > rmLowerAddr)
117 label* ccFaces = &cCellFaces[maxNnbrs*cOwn];
119 bool nbrFound =
false;
120 label& ccnFaces = cCellnFaces[cOwn];
122 for (
int i=0; i<ccnFaces; i++)
124 if (initCoarseNeighb[ccFaces[i]] == cNei)
127 faceRestrictAddr[fineFacei] = ccFaces[i];
134 if (ccnFaces >= maxNnbrs)
136 label oldMaxNnbrs = maxNnbrs;
139 cCellFaces.
setSize(maxNnbrs*nCoarseCells);
143 label* oldCcNbrs = &cCellFaces[oldMaxNnbrs*i];
144 label* newCcNbrs = &cCellFaces[maxNnbrs*i];
146 for (
int j=0; j<cCellnFaces[i]; j++)
148 newCcNbrs[j] = oldCcNbrs[j];
152 ccFaces = &cCellFaces[maxNnbrs*cOwn];
155 ccFaces[ccnFaces] = nCoarseFaces;
156 initCoarseNeighb[nCoarseFaces] = cNei;
157 faceRestrictAddr[fineFacei] = nCoarseFaces;
174 label coarseFacei = 0;
178 label* cFaces = &cCellFaces[maxNnbrs*cci];
179 label ccnFaces = cCellnFaces[cci];
181 for (
int i=0; i<ccnFaces; i++)
183 coarseOwner[coarseFacei] = cci;
184 coarseNeighbour[coarseFacei] = initCoarseNeighb[cFaces[i]];
185 coarseFaceMap[cFaces[i]] = coarseFacei;
190 forAll(faceRestrictAddr, fineFacei)
192 if (faceRestrictAddr[fineFacei] >= 0)
194 faceRestrictAddr[fineFacei] =
195 coarseFaceMap[faceRestrictAddr[fineFacei]];
201 faceFlipMap_.set(fineLevelIndex,
new boolList(nFineFaces,
false));
202 boolList& faceFlipMap = faceFlipMap_[fineLevelIndex];
206 label nDissapear = 0;
208 forAll(faceRestrictAddr, fineFacei)
210 label coarseFacei = faceRestrictAddr[fineFacei];
212 if (coarseFacei >= 0)
215 label cOwn = coarseOwner[coarseFacei];
216 label cNei = coarseNeighbour[coarseFacei];
218 label rmUpperAddr = restrictMap[upperAddr[fineFacei]];
219 label rmLowerAddr = restrictMap[lowerAddr[fineFacei]];
221 if (cOwn == rmUpperAddr && cNei == rmLowerAddr)
223 faceFlipMap[fineFacei] =
true;
226 else if (cOwn == rmLowerAddr && cNei == rmUpperAddr)
234 <<
" fineFacei:" << fineFacei
235 <<
" rmUpperAddr:" << rmUpperAddr
236 <<
" rmLowerAddr:" << rmLowerAddr
237 <<
" coarseFacei:" << coarseFacei
263 nPatchFaces_.set(fineLevelIndex,
new labelList(fineInterfaces.
size(), 0));
264 labelList& nPatchFaces = nPatchFaces_[fineLevelIndex];
266 patchFaceRestrictAddressing_.set
272 patchFaceRestrictAddressing_[fineLevelIndex];
276 forAll(fineInterfaces, inti)
278 if (fineInterfaces.
set(inti))
280 fineInterfaces[inti].initInternalFieldTransfer
282 Pstream::nonBlocking,
288 if (Pstream::parRun())
290 Pstream::waitRequests();
310 forAll(fineInterfaces, inti)
312 if (fineInterfaces.
set(inti))
320 meshLevels_[fineLevelIndex].rawInterfaces(),
321 fineInterfaces[inti],
322 fineInterfaces[inti].interfaceInternalField(restrictMap),
323 fineInterfaces[inti].internalFieldTransfer
325 Pstream::nonBlocking,
333 nPatchFaces[inti] = coarseInterfaces[inti].faceCells().
size();
334 patchFineToCoarse[inti] = refCast<const GAMGInterface>
336 coarseInterfaces[inti]
337 ).faceRestrictAddressing();
341 meshLevels_[fineLevelIndex].addInterfaces
344 lduPrimitiveMesh::nonBlockingSchedule<processorGAMGInterface>
353 Pout<<
"GAMGAgglomeration :" 354 <<
" agglomerated level " << fineLevelIndex
355 <<
" from nCells:" << fineMeshAddr.
size()
356 <<
" nFaces:" << upperAddr.
size()
357 <<
" to nCells:" << nCoarseCells
358 <<
" nFaces:" << nCoarseFaces
366 const label meshComm,
369 const label allMeshComm,
371 const label levelIndex
374 const lduMesh& myMesh = meshLevels_[levelIndex-1];
377 label oldWarn = UPstream::warnComm;
378 UPstream::warnComm = meshComm;
381 procAgglomMap_.set(levelIndex,
new labelList(procAgglomMap));
382 agglomProcIDs_.set(levelIndex,
new labelList(procIDs));
383 procCommunicator_[levelIndex] = allMeshComm;
387 procCellOffsets_.set(levelIndex,
new labelList(0));
395 lduPrimitiveMesh::gather(meshComm, myMesh, procIDs, otherMeshes);
397 if (Pstream::myProcNo(meshComm) == procIDs[0])
414 procCellOffsets_[levelIndex],
416 procFaceMap_[levelIndex],
417 procBoundaryMap_[levelIndex],
418 procBoundaryFaceMap_[levelIndex]
427 procAgglomerateRestrictAddressing
434 if (Pstream::myProcNo(meshComm) != procIDs[0])
436 clearLevel(levelIndex);
439 UPstream::warnComm = oldWarn;
447 const label levelIndex
456 restrictAddressing_[levelIndex].size(),
465 offsets[i+1] = offsets[i] + nFineCells[i];
487 restrictAddressing_[levelIndex],
488 procRestrictAddressing,
495 if (Pstream::myProcNo(comm) == procIDs[0])
499 coarseCellOffsets[0] = 0;
502 coarseCellOffsets[i+1] = coarseCellOffsets[i]+nCoarseCells[i];
506 nCells_[levelIndex] = coarseCellOffsets.
last();
509 for (
label proci = 1; proci < procIDs.
size(); proci++)
513 procRestrictAddressing,
514 offsets[proci+1]-offsets[proci],
519 procSlot[i] += coarseCellOffsets[proci];
523 restrictAddressing_[levelIndex].transfer(procRestrictAddressing);
530 label prevLevel = curLevel - 1;
547 forAll(prevFaceResAddr, i)
549 if (prevFaceResAddr[i] >= 0)
551 label fineFacei = prevFaceResAddr[i];
552 prevFaceResAddr[i] = curFaceResAddr[fineFacei];
553 prevFaceFlipMap[i] = curFaceFlipMap[fineFacei];
557 label fineFacei = -prevFaceResAddr[i] - 1;
558 prevFaceResAddr[i] = -curResAddr[fineFacei] - 1;
559 prevFaceFlipMap[i] = curFaceFlipMap[fineFacei];
569 prevResAddr[i] = curResAddr[prevResAddr[i]];
577 forAll(prevPatchFaceResAddr, inti)
579 const labelList& curResAddr = curPatchFaceResAddr[inti];
580 labelList& prevResAddr = prevPatchFaceResAddr[inti];
583 label fineFacei = prevResAddr[i];
584 prevResAddr[i] = curResAddr[fineFacei];
602 forAll(prevInterLevel, inti)
604 if (prevInterLevel.
set(inti))
683 forAll(procAgglomMap, proci)
685 label coarseI = procAgglomMap[proci];
688 if (fnd == agglomToMaster.
end())
690 agglomToMaster.insert(coarseI, proci);
694 fnd() =
min(fnd(), proci);
698 masterProcs.
setSize(agglomToMaster.size());
701 masterProcs[iter.key()] = iter();
707 label myAgglom = procAgglomMap[myProcID];
711 agglomProcIDs =
findIndices(procAgglomMap, myAgglom);
716 agglomToMaster[myAgglom]
718 Swap(agglomProcIDs[0], agglomProcIDs[index]);
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
PtrList< labelListList > patchFaceRestrictAddressing_
Patch-local face restriction addressing array.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void gather(const labelUList &offsets, const label comm, const labelList &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const Pstream::commsTypes commsType=Pstream::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
void size(const label)
Override size to be inconsistent with allocated storage.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
#define forAllReverse(list, i)
Reverse loop across all elements in list.
virtual label comm() const =0
Return communicator used for parallel communication.
void procAgglomerateLduAddressing(const label comm, const labelList &procAgglomMap, const labelList &procIDs, const label allMeshComm, const label levelIndex)
Collect and combine processor meshes into allMesh:
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurences of given element. Linear search.
PtrList< labelList > faceRestrictAddressing_
Face restriction addressing array.
PtrList< labelList > nPatchFaces_
The number of (coarse) patch faces in each level.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
List< bool > boolList
Bool container classes.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
bool set(const label) const
Is element set.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
A List obtained as a section of another List.
label size() const
Return number of equations.
PtrList< lduPrimitiveMesh > meshLevels_
Hierarchy of mesh addressing.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
Simplest contrete lduMesh which stores the addressing needed by lduMatrix.
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
List< label > labelList
A List of labels.
labelList nCells_
The number of cells in each level.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
labelList nFaces_
The number of (coarse) faces in each level.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
PtrList< labelField > restrictAddressing_
Cell restriction addressing array.
void agglomerateLduAddressing(const label fineLevelIndex)
Assemble coarse mesh addressing.
prefixOSstream Pout(cout,"Pout")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Abstract base class for GAMG agglomerated interfaces.
void combine(const GAMGInterface &)
Merge the next level with this level.
label size() const
Return the number of elements in the UList.
void setSize(const label)
Reset size of List.
void procAgglomerateRestrictAddressing(const label comm, const labelList &procIDs, const label levelIndex)
Collect and combine basic restriction addressing:
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
List< labelListList > labelListListList
A List of labelListList.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
The class contains the addressing required by the lduMatrix: upper, lower and losort.
PtrList< boolList > faceFlipMap_
Face flip: for faces mapped to internal faces stores whether.
T & last()
Return the last element of the list.
static void calculateRegionMaster(const label comm, const labelList &procAgglomMap, labelList &masterProcs, List< label > &agglomProcIDs)
Given fine to coarse processor map determine:
void combineLevels(const label curLevel)
Combine a level with the previous one.
label size() const
Return the number of elements in the UPtrList.