GAMGAgglomerateLduAddressing.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "GAMGAgglomeration.H"
30 #include "GAMGInterface.H"
31 #include "processorGAMGInterface.H"
32 
33 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34 
36 (
37  const label fineLevelIndex
38 )
39 {
40  const lduMesh& fineMesh = meshLevel(fineLevelIndex);
41  const lduAddressing& fineMeshAddr = fineMesh.lduAddr();
42 
43  const labelUList& upperAddr = fineMeshAddr.upperAddr();
44  const labelUList& lowerAddr = fineMeshAddr.lowerAddr();
45 
46  label nFineFaces = upperAddr.size();
47 
48  // Get restriction map for current level
49  const labelField& restrictMap = restrictAddressing(fineLevelIndex);
50 
51  if (min(restrictMap) == -1)
52  {
54  << "min(restrictMap) == -1" << exit(FatalError);
55  }
56 
57  if (restrictMap.size() != fineMeshAddr.size())
58  {
60  << "restrict map does not correspond to fine level. " << endl
61  << " Sizes: restrictMap: " << restrictMap.size()
62  << " nEqns: " << fineMeshAddr.size()
63  << abort(FatalError);
64  }
65 
66 
67  // Get the number of coarse cells
68  const label nCoarseCells = nCells_[fineLevelIndex];
69 
70  // Storage for coarse cell neighbours and coefficients
71 
72  // Guess initial maximum number of neighbours in coarse cell
73  label maxNnbrs = 10;
74 
75  // Number of faces for each coarse-cell
76  labelList cCellnFaces(nCoarseCells, Zero);
77 
78  // Setup initial packed storage for coarse-cell faces
79  labelList cCellFaces(maxNnbrs*nCoarseCells);
80 
81  // Create face-restriction addressing
82  faceRestrictAddressing_.set(fineLevelIndex, new labelList(nFineFaces));
83  labelList& faceRestrictAddr = faceRestrictAddressing_[fineLevelIndex];
84 
85  // Initial neighbour array (not in upper-triangle order)
86  labelList initCoarseNeighb(nFineFaces);
87 
88  // Counter for coarse faces
89  label& nCoarseFaces = nFaces_[fineLevelIndex];
90  nCoarseFaces = 0;
91 
92  // Loop through all fine faces
93  forAll(upperAddr, fineFacei)
94  {
95  label rmUpperAddr = restrictMap[upperAddr[fineFacei]];
96  label rmLowerAddr = restrictMap[lowerAddr[fineFacei]];
97 
98  if (rmUpperAddr == rmLowerAddr)
99  {
100  // For each fine face inside of a coarse cell keep the address
101  // of the cell corresponding to the face in the faceRestrictAddr
102  // as a negative index
103  faceRestrictAddr[fineFacei] = -(rmUpperAddr + 1);
104  }
105  else
106  {
107  // this face is a part of a coarse face
108 
109  label cOwn = rmUpperAddr;
110  label cNei = rmLowerAddr;
111 
112  // get coarse owner and neighbour
113  if (rmUpperAddr > rmLowerAddr)
114  {
115  cOwn = rmLowerAddr;
116  cNei = rmUpperAddr;
117  }
118 
119  // check the neighbour to see if this face has already been found
120  label* ccFaces = &cCellFaces[maxNnbrs*cOwn];
121 
122  bool nbrFound = false;
123  label& ccnFaces = cCellnFaces[cOwn];
124 
125  for (int i=0; i<ccnFaces; i++)
126  {
127  if (initCoarseNeighb[ccFaces[i]] == cNei)
128  {
129  nbrFound = true;
130  faceRestrictAddr[fineFacei] = ccFaces[i];
131  break;
132  }
133  }
134 
135  if (!nbrFound)
136  {
137  if (ccnFaces >= maxNnbrs)
138  {
139  label oldMaxNnbrs = maxNnbrs;
140  maxNnbrs *= 2;
141 
142  cCellFaces.setSize(maxNnbrs*nCoarseCells);
143 
144  forAllReverse(cCellnFaces, i)
145  {
146  label* oldCcNbrs = &cCellFaces[oldMaxNnbrs*i];
147  label* newCcNbrs = &cCellFaces[maxNnbrs*i];
148 
149  for (int j=0; j<cCellnFaces[i]; j++)
150  {
151  newCcNbrs[j] = oldCcNbrs[j];
152  }
153  }
154 
155  ccFaces = &cCellFaces[maxNnbrs*cOwn];
156  }
157 
158  ccFaces[ccnFaces] = nCoarseFaces;
159  initCoarseNeighb[nCoarseFaces] = cNei;
160  faceRestrictAddr[fineFacei] = nCoarseFaces;
161  ccnFaces++;
162 
163  // new coarse face created
164  nCoarseFaces++;
165  }
166  }
167  } // end for all fine faces
168 
169 
170  // Renumber into upper-triangular order
171 
172  // All coarse owner-neighbour storage
173  labelList coarseOwner(nCoarseFaces);
174  labelList coarseNeighbour(nCoarseFaces);
175  labelList coarseFaceMap(nCoarseFaces);
176 
177  label coarseFacei = 0;
178 
179  forAll(cCellnFaces, cci)
180  {
181  label* cFaces = &cCellFaces[maxNnbrs*cci];
182  label ccnFaces = cCellnFaces[cci];
183 
184  for (int i=0; i<ccnFaces; i++)
185  {
186  coarseOwner[coarseFacei] = cci;
187  coarseNeighbour[coarseFacei] = initCoarseNeighb[cFaces[i]];
188  coarseFaceMap[cFaces[i]] = coarseFacei;
189  coarseFacei++;
190  }
191  }
192 
193  forAll(faceRestrictAddr, fineFacei)
194  {
195  if (faceRestrictAddr[fineFacei] >= 0)
196  {
197  faceRestrictAddr[fineFacei] =
198  coarseFaceMap[faceRestrictAddr[fineFacei]];
199  }
200  }
201 
202 
203  // Create face-flip status
204  faceFlipMap_.set(fineLevelIndex, new boolList(nFineFaces, false));
205  boolList& faceFlipMap = faceFlipMap_[fineLevelIndex];
206 
207 
208  label nFlipped = 0;
209  label nDissapear = 0;
210 
211  forAll(faceRestrictAddr, fineFacei)
212  {
213  label coarseFacei = faceRestrictAddr[fineFacei];
214 
215  if (coarseFacei >= 0)
216  {
217  // Maps to coarse face
218  label cOwn = coarseOwner[coarseFacei];
219  label cNei = coarseNeighbour[coarseFacei];
220 
221  label rmUpperAddr = restrictMap[upperAddr[fineFacei]];
222  label rmLowerAddr = restrictMap[lowerAddr[fineFacei]];
223 
224  if (cOwn == rmUpperAddr && cNei == rmLowerAddr)
225  {
226  faceFlipMap[fineFacei] = true;
227  nFlipped++;
228  }
229  else if (cOwn == rmLowerAddr && cNei == rmUpperAddr)
230  {
231  //faceFlipMap[fineFacei] = false;
232  }
233  else
234  {
236  << "problem."
237  << " fineFacei:" << fineFacei
238  << " rmUpperAddr:" << rmUpperAddr
239  << " rmLowerAddr:" << rmLowerAddr
240  << " coarseFacei:" << coarseFacei
241  << " cOwn:" << cOwn
242  << " cNei:" << cNei
243  << exit(FatalError);
244  }
245  }
246  else
247  {
248  nDissapear++;
249  }
250  }
251 
252 
253 
254  // Clear the temporary storage for the coarse cell data
255  cCellnFaces.setSize(0);
256  cCellFaces.setSize(0);
257  initCoarseNeighb.setSize(0);
258  coarseFaceMap.setSize(0);
259 
260 
261  // Create coarse-level interfaces
262 
263  // Get reference to fine-level interfaces
264  const lduInterfacePtrsList& fineInterfaces = interfaceLevel(fineLevelIndex);
265 
266  nPatchFaces_.set
267  (
268  fineLevelIndex,
269  new labelList(fineInterfaces.size(), Zero)
270  );
271  labelList& nPatchFaces = nPatchFaces_[fineLevelIndex];
272 
273  patchFaceRestrictAddressing_.set
274  (
275  fineLevelIndex,
276  new labelListList(fineInterfaces.size())
277  );
278  labelListList& patchFineToCoarse =
279  patchFaceRestrictAddressing_[fineLevelIndex];
280 
281 
282  const label nReq = Pstream::nRequests();
283 
284  // Initialise transfer of restrict addressing on the interface
285  forAll(fineInterfaces, inti)
286  {
287  if (fineInterfaces.set(inti))
288  {
289  fineInterfaces[inti].initInternalFieldTransfer
290  (
291  Pstream::commsTypes::nonBlocking,
292  restrictMap
293  );
294  }
295  }
296 
297  if (Pstream::parRun())
298  {
299  Pstream::waitRequests(nReq);
300  }
301 
302 
303  // Add the coarse level
304  meshLevels_.set
305  (
306  fineLevelIndex,
307  new lduPrimitiveMesh
308  (
309  nCoarseCells,
310  coarseOwner,
311  coarseNeighbour,
312  fineMesh.comm(),
313  true
314  )
315  );
316 
317  lduInterfacePtrsList coarseInterfaces(fineInterfaces.size());
318 
319  forAll(fineInterfaces, inti)
320  {
321  if (fineInterfaces.set(inti))
322  {
323  coarseInterfaces.set
324  (
325  inti,
327  (
328  inti,
329  meshLevels_[fineLevelIndex].rawInterfaces(),
330  fineInterfaces[inti],
331  fineInterfaces[inti].interfaceInternalField(restrictMap),
332  fineInterfaces[inti].internalFieldTransfer
333  (
334  Pstream::commsTypes::nonBlocking,
335  restrictMap
336  ),
337  fineLevelIndex,
338  fineMesh.comm()
339  ).ptr()
340  );
341 
342  nPatchFaces[inti] = coarseInterfaces[inti].faceCells().size();
343  patchFineToCoarse[inti] = refCast<const GAMGInterface>
344  (
345  coarseInterfaces[inti]
346  ).faceRestrictAddressing();
347  }
348  }
349 
350  meshLevels_[fineLevelIndex].addInterfaces
351  (
352  coarseInterfaces,
353  lduPrimitiveMesh::nonBlockingSchedule<processorGAMGInterface>
354  (
355  coarseInterfaces
356  )
357  );
358 
359 
360  if (debug & 2)
361  {
362  Pout<< "GAMGAgglomeration :"
363  << " agglomerated level " << fineLevelIndex
364  << " from nCells:" << fineMeshAddr.size()
365  << " nFaces:" << upperAddr.size()
366  << " to nCells:" << nCoarseCells
367  << " nFaces:" << nCoarseFaces
368  << endl;
369  }
370 }
371 
372 
374 (
375  const label meshComm,
376  const labelList& procAgglomMap,
377  const labelList& procIDs,
378  const label allMeshComm,
379 
380  const label levelIndex
381 )
382 {
383  const lduMesh& myMesh = meshLevels_[levelIndex-1];
384 
385 
386  procAgglomMap_.set(levelIndex, new labelList(procAgglomMap));
387  agglomProcIDs_.set(levelIndex, new labelList(procIDs));
388  procCommunicator_[levelIndex] = allMeshComm;
389 
390  // These could only be set on the master procs but it is
391  // quite convenient to also have them on the slaves
392  procCellOffsets_.set(levelIndex, new labelList(0));
393  procFaceMap_.set(levelIndex, new labelListList(0));
394  procBoundaryMap_.set(levelIndex, new labelListList(0));
395  procBoundaryFaceMap_.set(levelIndex, new labelListListList(0));
396 
397 
398  // Collect meshes
399  PtrList<lduPrimitiveMesh> otherMeshes;
400  lduPrimitiveMesh::gather(meshComm, myMesh, procIDs, otherMeshes);
401 
402  if (Pstream::myProcNo(meshComm) == procIDs[0])
403  {
404  // Combine all addressing
405 
406  labelList procFaceOffsets;
407  meshLevels_.set
408  (
409  levelIndex-1,
410  new lduPrimitiveMesh
411  (
412  allMeshComm,
413  procAgglomMap,
414 
415  procIDs,
416  myMesh,
417  otherMeshes,
418 
419  procCellOffsets_[levelIndex],
420  procFaceOffsets,
421  procFaceMap_[levelIndex],
422  procBoundaryMap_[levelIndex],
423  procBoundaryFaceMap_[levelIndex]
424  )
425  );
426  }
427 
428 
429  // Combine restrict addressing
430  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
431 
432  procAgglomerateRestrictAddressing
433  (
434  meshComm,
435  procIDs,
436  levelIndex
437  );
438 
439  if (Pstream::myProcNo(meshComm) != procIDs[0])
440  {
441  clearLevel(levelIndex);
442  }
443 }
444 
445 
447 (
448  const label comm,
449  const labelList& procIDs,
450  const label levelIndex
451 )
452 {
453  // Collect number of cells
454  labelList nFineCells;
455  gatherList
456  (
457  comm,
458  procIDs,
459  restrictAddressing_[levelIndex].size(),
460  nFineCells
461  );
462 
463  labelList offsets(nFineCells.size()+1);
464  {
465  offsets[0] = 0;
466  forAll(nFineCells, i)
467  {
468  offsets[i+1] = offsets[i] + nFineCells[i];
469  }
470  }
471 
472  // Combine and renumber nCoarseCells
473  labelList nCoarseCells;
474  gatherList
475  (
476  comm,
477  procIDs,
478  nCells_[levelIndex],
479  nCoarseCells
480  );
481 
482  // (cell)restrictAddressing
483  const globalIndex cellOffsetter(offsets);
484 
485  labelList procRestrictAddressing;
486  cellOffsetter.gather
487  (
488  comm,
489  procIDs,
490  restrictAddressing_[levelIndex],
491  procRestrictAddressing,
492 
493  UPstream::msgType(),
494  Pstream::commsTypes::nonBlocking //Pstream::commsTypes::scheduled
495  );
496 
497 
498  if (Pstream::myProcNo(comm) == procIDs[0])
499  {
500  labelList coarseCellOffsets(procIDs.size()+1);
501  {
502  coarseCellOffsets[0] = 0;
503  forAll(procIDs, i)
504  {
505  coarseCellOffsets[i+1] = coarseCellOffsets[i]+nCoarseCells[i];
506  }
507  }
508 
509  nCells_[levelIndex] = coarseCellOffsets.last();
510 
511  // Renumber consecutively
512  for (label proci = 1; proci < procIDs.size(); proci++)
513  {
514  SubList<label> procSlot
515  (
516  procRestrictAddressing,
517  offsets[proci+1]-offsets[proci],
518  offsets[proci]
519  );
520  forAll(procSlot, i)
521  {
522  procSlot[i] += coarseCellOffsets[proci];
523  }
524  }
525 
526  restrictAddressing_[levelIndex].transfer(procRestrictAddressing);
527  }
528 }
529 
530 
531 void Foam::GAMGAgglomeration::combineLevels(const label curLevel)
532 {
533  label prevLevel = curLevel - 1;
534 
535  // Set the previous level nCells to the current
536  nCells_[prevLevel] = nCells_[curLevel];
537  nFaces_[prevLevel] = nFaces_[curLevel];
538 
539  // Map the restrictAddressing from the coarser level into the previous
540  // finer level
541 
542  const labelList& curResAddr = restrictAddressing_[curLevel];
543  labelList& prevResAddr = restrictAddressing_[prevLevel];
544 
545  const labelList& curFaceResAddr = faceRestrictAddressing_[curLevel];
546  labelList& prevFaceResAddr = faceRestrictAddressing_[prevLevel];
547  const boolList& curFaceFlipMap = faceFlipMap_[curLevel];
548  boolList& prevFaceFlipMap = faceFlipMap_[prevLevel];
549 
550  forAll(prevFaceResAddr, i)
551  {
552  if (prevFaceResAddr[i] >= 0)
553  {
554  label fineFacei = prevFaceResAddr[i];
555  prevFaceResAddr[i] = curFaceResAddr[fineFacei];
556  prevFaceFlipMap[i] = curFaceFlipMap[fineFacei];
557  }
558  else
559  {
560  label fineFacei = -prevFaceResAddr[i] - 1;
561  prevFaceResAddr[i] = -curResAddr[fineFacei] - 1;
562  prevFaceFlipMap[i] = curFaceFlipMap[fineFacei];
563  }
564  }
565 
566  // Delete the restrictAddressing for the coarser level
567  faceRestrictAddressing_.set(curLevel, nullptr);
568  faceFlipMap_.set(curLevel, nullptr);
569 
570  forAll(prevResAddr, i)
571  {
572  prevResAddr[i] = curResAddr[prevResAddr[i]];
573  }
574 
575  const labelListList& curPatchFaceResAddr =
577  labelListList& prevPatchFaceResAddr =
578  patchFaceRestrictAddressing_[prevLevel];
579 
580  forAll(prevPatchFaceResAddr, inti)
581  {
582  const labelList& curResAddr = curPatchFaceResAddr[inti];
583  labelList& prevResAddr = prevPatchFaceResAddr[inti];
584  forAll(prevResAddr, i)
585  {
586  label fineFacei = prevResAddr[i];
587  prevResAddr[i] = curResAddr[fineFacei];
588  }
589  }
590 
591  // Delete the restrictAddressing for the coarser level
592  restrictAddressing_.set(curLevel, nullptr);
593 
594  // Patch faces
595  nPatchFaces_[prevLevel] = nPatchFaces_[curLevel];
596 
597 
598 
599  // Adapt the restrict addressing for the patches
600  const lduInterfacePtrsList& curInterLevel =
601  meshLevels_[curLevel].rawInterfaces();
602  const lduInterfacePtrsList& prevInterLevel =
603  meshLevels_[prevLevel].rawInterfaces();
604 
605  forAll(prevInterLevel, inti)
606  {
607  if (prevInterLevel.set(inti))
608  {
609  GAMGInterface& prevInt = refCast<GAMGInterface>
610  (
611  const_cast<lduInterface&>
612  (
613  prevInterLevel[inti]
614  )
615  );
616  const GAMGInterface& curInt = refCast<const GAMGInterface>
617  (
618  curInterLevel[inti]
619  );
620  prevInt.combine(curInt);
621  }
622  }
623 
624  // Delete the matrix addressing and coefficients from the previous level
625  // and replace with the corresponding entry from the coarser level
626  meshLevels_.set(prevLevel, meshLevels_.set(curLevel, nullptr));
627 }
628 
629 
630 //void Foam::GAMGAgglomeration::gatherList
631 //(
632 // const label comm,
633 // const labelList& procIDs,
634 //
635 // const label myVal,
636 // labelList& vals,
637 // const int tag
638 //)
639 //{
640 // vals.setSize(procIDs.size());
641 //
642 // if (Pstream::myProcNo(comm) == procIDs[0])
643 // {
644 // vals[0] = myVal;
645 //
646 // for (label i=1; i<procIDs.size(); i++)
647 // {
648 // label& slaveVal = vals[i];
649 // IPstream::read
650 // (
651 // Pstream::commsTypes::scheduled,
652 // procIDs[i],
653 // reinterpret_cast<char*>(&slaveVal),
654 // sizeof(slaveVal),
655 // tag,
656 // comm
657 // );
658 // }
659 // }
660 // else
661 // {
662 // OPstream::write
663 // (
664 // Pstream::commsTypes::scheduled,
665 // procIDs[0],
666 // reinterpret_cast<const char*>(&myVal),
667 // sizeof(myVal),
668 // tag,
669 // comm
670 // );
671 // }
672 //}
673 
674 
676 (
677  const label comm,
678  const labelList& procAgglomMap,
679  labelList& masterProcs,
680  List<label>& agglomProcIDs
681 )
682 {
683  // Determine the master processors
684  Map<label> agglomToMaster(procAgglomMap.size());
685 
686  forAll(procAgglomMap, proci)
687  {
688  const label coarsei = procAgglomMap[proci];
689 
690  auto iter = agglomToMaster.find(coarsei);
691  if (iter.found())
692  {
693  iter.val() = min(iter.val(), proci);
694  }
695  else
696  {
697  agglomToMaster.insert(coarsei, proci);
698  }
699  }
700 
701  masterProcs.setSize(agglomToMaster.size());
702  forAllConstIters(agglomToMaster, iter)
703  {
704  masterProcs[iter.key()] = iter.val();
705  }
706 
707 
708  // Collect all the processors in my agglomeration
709  label myProcID = Pstream::myProcNo(comm);
710  label myAgglom = procAgglomMap[myProcID];
711 
712  // Get all processors agglomerating to the same coarse
713  // processor
714  agglomProcIDs = findIndices(procAgglomMap, myAgglom);
715 
716  // Make sure the master is the first element.
717  const label index =
718  agglomProcIDs.find(agglomToMaster[myAgglom]);
719 
720  Swap(agglomProcIDs[0], agglomProcIDs[index]);
721 }
722 
723 
724 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::UPtrList::size
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:97
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::lduInterface
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Definition: lduInterface.H:54
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
Foam::GAMGAgglomeration::procAgglomerateRestrictAddressing
void procAgglomerateRestrictAddressing(const label comm, const labelList &procIDs, const label levelIndex)
Collect and combine basic restriction addressing:
Definition: GAMGAgglomerateLduAddressing.C:447
Foam::GAMGAgglomeration::nCells_
labelList nCells_
The number of cells in each level.
Definition: GAMGAgglomeration.H:84
Foam::Map< label >
Foam::boolList
List< bool > boolList
A List of bools.
Definition: List.H:69
GAMGAgglomeration.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::GAMGAgglomeration::faceRestrictAddressing_
PtrList< labelList > faceRestrictAddressing_
Face restriction addressing array.
Definition: GAMGAgglomeration.H:100
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Foam::GAMGAgglomeration::meshLevels_
PtrList< lduPrimitiveMesh > meshLevels_
Hierarchy of mesh addressing.
Definition: GAMGAgglomeration.H:117
Foam::Swap
void Swap(DynamicList< T, SizeMin1 > &a, DynamicList< T, SizeMin2 > &b)
Definition: DynamicListI.H:913
Foam::lduAddressing::size
label size() const
Return number of equations.
Definition: lduAddressing.H:171
Foam::lduAddressing::upperAddr
virtual const labelUList & upperAddr() const =0
Return upper addressing.
Foam::GAMGAgglomeration::restrictAddressing_
PtrList< labelField > restrictAddressing_
Cell restriction addressing array.
Definition: GAMGAgglomeration.H:88
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::GAMGAgglomeration::agglomerateLduAddressing
void agglomerateLduAddressing(const label fineLevelIndex)
Assemble coarse mesh addressing.
Definition: GAMGAgglomerateLduAddressing.C:36
Foam::GAMGAgglomeration::calculateRegionMaster
static void calculateRegionMaster(const label comm, const labelList &procAgglomMap, labelList &masterProcs, List< label > &agglomProcIDs)
Given fine to coarse processor map determine:
Definition: GAMGAgglomerateLduAddressing.C:676
GAMGInterface.H
Foam::Field< label >
Foam::GAMGInterface
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:53
Foam::UPtrList< const lduInterface >
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:62
Foam::GAMGAgglomeration::nPatchFaces_
PtrList< labelList > nPatchFaces_
The number of (coarse) patch faces in each level.
Definition: GAMGAgglomeration.H:109
Foam::GAMGAgglomeration::combineLevels
void combineLevels(const label curLevel)
Combine a level with the previous one.
Definition: GAMGAgglomerateLduAddressing.C:531
Foam::FatalError
error FatalError
processorGAMGInterface.H
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:68
Foam::labelListListList
List< labelListList > labelListListList
A List of labelListList.
Definition: labelList.H:57
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::lduPrimitiveMesh
Simplest contrete lduMesh which stores the addressing needed by lduMatrix.
Definition: lduPrimitiveMesh.H:52
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::UPtrList::set
const T * set(const label i) const
Return const pointer to element (can be nullptr),.
Definition: UPtrList.H:170
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:464
Foam::GAMGAgglomeration::nFaces_
labelList nFaces_
The number of (coarse) faces in each level.
Definition: GAMGAgglomeration.H:92
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::lduAddressing::lowerAddr
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
Foam::List< label >
Foam::UList< label >
Foam::List::set
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.
Definition: List.H:325
Foam::lduMesh::comm
virtual label comm() const =0
Return communicator used for parallel communication.
Foam::UList::size
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
Definition: UListI.H:360
forAllReverse
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Definition: stdFoam.H:309
Foam::findIndices
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
Foam::GAMGAgglomeration::procAgglomerateLduAddressing
void procAgglomerateLduAddressing(const label comm, const labelList &procAgglomMap, const labelList &procIDs, const label allMeshComm, const label levelIndex)
Collect and combine processor meshes into allMesh:
Definition: GAMGAgglomerateLduAddressing.C:374
Foam::List::setSize
void setSize(const label newSize)
Alias for resize(const label)
Definition: ListI.H:146
Foam::GAMGAgglomeration::faceFlipMap_
PtrList< boolList > faceFlipMap_
Face flip: for faces mapped to internal faces stores whether.
Definition: GAMGAgglomeration.H:105
Foam::GAMGAgglomeration::patchFaceRestrictAddressing_
PtrList< labelListList > patchFaceRestrictAddressing_
Patch-local face restriction addressing array.
Definition: GAMGAgglomeration.H:114
Foam::lduMesh::lduAddr
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
Foam::lduMesh
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:62
Foam::GAMGInterface::combine
void combine(const GAMGInterface &)
Merge the next level with this level.
Definition: GAMGInterface.C:58
Foam::globalIndex::gather
static void gather(const labelUList &offsets, const label comm, const Container &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]).
Definition: globalIndexTemplates.C:35