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::commsTypes::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::commsTypes::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 procAgglomMap_.set(levelIndex,
new labelList(procAgglomMap));
378 agglomProcIDs_.set(levelIndex,
new labelList(procIDs));
379 procCommunicator_[levelIndex] = allMeshComm;
383 procCellOffsets_.set(levelIndex,
new labelList(0));
391 lduPrimitiveMesh::gather(meshComm, myMesh, procIDs, otherMeshes);
393 if (Pstream::myProcNo(meshComm) == procIDs[0])
410 procCellOffsets_[levelIndex],
412 procFaceMap_[levelIndex],
413 procBoundaryMap_[levelIndex],
414 procBoundaryFaceMap_[levelIndex]
423 procAgglomerateRestrictAddressing
430 if (Pstream::myProcNo(meshComm) != procIDs[0])
432 clearLevel(levelIndex);
441 const label levelIndex
450 restrictAddressing_[levelIndex].size(),
459 offsets[i+1] = offsets[i] + nFineCells[i];
481 restrictAddressing_[levelIndex],
482 procRestrictAddressing,
485 Pstream::commsTypes::nonBlocking
489 if (Pstream::myProcNo(comm) == procIDs[0])
493 coarseCellOffsets[0] = 0;
496 coarseCellOffsets[i+1] = coarseCellOffsets[i]+nCoarseCells[i];
500 nCells_[levelIndex] = coarseCellOffsets.
last();
503 for (
label proci = 1; proci < procIDs.
size(); proci++)
507 procRestrictAddressing,
508 offsets[proci+1]-offsets[proci],
513 procSlot[i] += coarseCellOffsets[proci];
517 restrictAddressing_[levelIndex].transfer(procRestrictAddressing);
524 label prevLevel = curLevel - 1;
541 forAll(prevFaceResAddr, i)
543 if (prevFaceResAddr[i] >= 0)
545 label fineFacei = prevFaceResAddr[i];
546 prevFaceResAddr[i] = curFaceResAddr[fineFacei];
547 prevFaceFlipMap[i] = curFaceFlipMap[fineFacei];
551 label fineFacei = -prevFaceResAddr[i] - 1;
552 prevFaceResAddr[i] = -curResAddr[fineFacei] - 1;
553 prevFaceFlipMap[i] = curFaceFlipMap[fineFacei];
563 prevResAddr[i] = curResAddr[prevResAddr[i]];
571 forAll(prevPatchFaceResAddr, inti)
573 const labelList& curResAddr = curPatchFaceResAddr[inti];
574 labelList& prevResAddr = prevPatchFaceResAddr[inti];
577 label fineFacei = prevResAddr[i];
578 prevResAddr[i] = curResAddr[fineFacei];
596 forAll(prevInterLevel, inti)
598 if (prevInterLevel.
set(inti))
677 forAll(procAgglomMap, proci)
679 label coarseI = procAgglomMap[proci];
682 if (fnd == agglomToMaster.
end())
684 agglomToMaster.insert(coarseI, proci);
688 fnd() =
min(fnd(), proci);
692 masterProcs.
setSize(agglomToMaster.size());
695 masterProcs[iter.key()] = iter();
701 label myAgglom = procAgglomMap[myProcID];
705 agglomProcIDs =
findIndices(procAgglomMap, myAgglom);
710 agglomToMaster[myAgglom]
712 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
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::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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 occurrences 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.
List< bool > boolList
Bool container classes.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
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.
PtrList< lduPrimitiveMesh > meshLevels_
Hierarchy of mesh addressing.
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
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.
bool set(const label) const
Is element set.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Abstract base class for GAMG agglomerated interfaces.
label size() const
Return the number of elements in the UPtrList.
void combine(const GAMGInterface &)
Merge the next level with this level.
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.
prefixOSstream Pout(cout, "Pout")
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.
label size() const
Return the number of elements in the UList.
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 number of equations.