GAMGAgglomeration.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-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2020 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 "lduMesh.H"
31 #include "lduMatrix.H"
32 #include "Time.H"
33 #include "GAMGInterface.H"
34 #include "GAMGProcAgglomeration.H"
35 #include "pairGAMGAgglomeration.H"
36 #include "IOmanip.H"
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42  defineTypeNameAndDebug(GAMGAgglomeration, 0);
43  defineRunTimeSelectionTable(GAMGAgglomeration, lduMesh);
44  defineRunTimeSelectionTable(GAMGAgglomeration, lduMatrix);
45  defineRunTimeSelectionTable(GAMGAgglomeration, geometry);
46 }
47 
48 
49 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
50 
51 void Foam::GAMGAgglomeration::compactLevels(const label nCreatedLevels)
52 {
53  nCells_.setSize(nCreatedLevels);
54  restrictAddressing_.setSize(nCreatedLevels);
55  nFaces_.setSize(nCreatedLevels);
56  faceRestrictAddressing_.setSize(nCreatedLevels);
57  faceFlipMap_.setSize(nCreatedLevels);
58  nPatchFaces_.setSize(nCreatedLevels);
59  patchFaceRestrictAddressing_.setSize(nCreatedLevels);
60  meshLevels_.setSize(nCreatedLevels);
61 
62  // Have procCommunicator_ always, even if not procAgglomerating
63  procCommunicator_.setSize(nCreatedLevels + 1);
65  {
66  procAgglomMap_.setSize(nCreatedLevels);
67  agglomProcIDs_.setSize(nCreatedLevels);
68  procCellOffsets_.setSize(nCreatedLevels);
69  procFaceMap_.setSize(nCreatedLevels);
70  procBoundaryMap_.setSize(nCreatedLevels);
71  procBoundaryFaceMap_.setSize(nCreatedLevels);
72 
73  procAgglomeratorPtr_().agglomerate();
74 
75 
76  }
77 
78  // Print a bit
79  if (debug)
80  {
81  Info<< "GAMGAgglomeration:" << nl
82  << " local agglomerator : " << type() << nl;
84  {
85  Info<< " processor agglomerator : "
86  << procAgglomeratorPtr_().type() << nl
87  << nl;
88  }
89 
90  Info<< setw(36) << "nCells"
91  << setw(20) << "nFaces/nCells"
92  << setw(20) << "nInterfaces"
93  << setw(20) << "nIntFaces/nCells"
94  << setw(12) << "profile"
95  << nl
96  << setw(8) << "Level"
97  << setw(8) << "nProcs"
98  << " "
99  << setw(8) << "avg"
100  << setw(8) << "max"
101  << " "
102  << setw(8) << "avg"
103  << setw(8) << "max"
104  << " "
105  << setw(8) << "avg"
106  << setw(8) << "max"
107  << " "
108  << setw(8) << "avg"
109  << setw(8) << "max"
110  //<< " "
111  << setw(12) << "avg"
112  << nl
113  << setw(8) << "-----"
114  << setw(8) << "------"
115  << " "
116  << setw(8) << "---"
117  << setw(8) << "---"
118  << " "
119  << setw(8) << "---"
120  << setw(8) << "---"
121  << " "
122  << setw(8) << "---"
123  << setw(8) << "---"
124  << " "
125  << setw(8) << "---"
126  << setw(8) << "---"
127  //<< " "
128  << setw(12) << "---"
129  //<< " "
130  << nl;
131 
132  for (label levelI = 0; levelI <= size(); levelI++)
133  {
134  label nProcs = 0;
135  label nCells = 0;
136  scalar faceCellRatio = 0;
137  label nInterfaces = 0;
138  label nIntFaces = 0;
139  scalar ratio = 0.0;
140  scalar profile = 0.0;
141 
142  if (hasMeshLevel(levelI))
143  {
144  nProcs = 1;
145 
146  const lduMesh& fineMesh = meshLevel(levelI);
147  nCells = fineMesh.lduAddr().size();
148  faceCellRatio =
149  scalar(fineMesh.lduAddr().lowerAddr().size())/nCells;
150 
151  const lduInterfacePtrsList interfaces =
152  fineMesh.interfaces();
153  forAll(interfaces, i)
154  {
155  if (interfaces.set(i))
156  {
157  nInterfaces++;
158  nIntFaces += interfaces[i].faceCells().size();
159  }
160  }
161  ratio = scalar(nIntFaces)/nCells;
162 
163  profile = fineMesh.lduAddr().band().second();
164  }
165 
166  label totNprocs = returnReduce(nProcs, sumOp<label>());
167 
168  label maxNCells = returnReduce(nCells, maxOp<label>());
169  label totNCells = returnReduce(nCells, sumOp<label>());
170 
171  scalar maxFaceCellRatio =
172  returnReduce(faceCellRatio, maxOp<scalar>());
173  scalar totFaceCellRatio =
174  returnReduce(faceCellRatio, sumOp<scalar>());
175 
176  label maxNInt = returnReduce(nInterfaces, maxOp<label>());
177  label totNInt = returnReduce(nInterfaces, sumOp<label>());
178 
179  scalar maxRatio = returnReduce(ratio, maxOp<scalar>());
180  scalar totRatio = returnReduce(ratio, sumOp<scalar>());
181 
182  scalar totProfile = returnReduce(profile, sumOp<scalar>());
183 
184  int oldPrecision = Info().precision(4);
185 
186  Info<< setw(8) << levelI
187  << setw(8) << totNprocs
188  << " "
189  << setw(8) << totNCells/totNprocs
190  << setw(8) << maxNCells
191  << " "
192  << setw(8) << totFaceCellRatio/totNprocs
193  << setw(8) << maxFaceCellRatio
194  << " "
195  << setw(8) << scalar(totNInt)/totNprocs
196  << setw(8) << maxNInt
197  << " "
198  << setw(8) << totRatio/totNprocs
199  << setw(8) << maxRatio
200  << setw(12) << totProfile/totNprocs
201  << nl;
202 
203  Info().precision(oldPrecision);
204  }
205  Info<< endl;
206  }
207 }
208 
209 
211 (
212  const label nFineCells,
213  const label nCoarseCells
214 ) const
215 {
216  const label nTotalCoarseCells = returnReduce(nCoarseCells, sumOp<label>());
217  if (nTotalCoarseCells < Pstream::nProcs()*nCellsInCoarsestLevel_)
218  {
219  return false;
220  }
221  else
222  {
223  const label nTotalFineCells = returnReduce(nFineCells, sumOp<label>());
224  return nTotalCoarseCells < nTotalFineCells;
225  }
226 }
227 
228 
229 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
230 
232 (
233  const lduMesh& mesh,
234  const dictionary& controlDict
235 )
236 :
238 
239  maxLevels_(50),
240 
241  nCellsInCoarsestLevel_
242  (
243  controlDict.getOrDefault<label>("nCellsInCoarsestLevel", 10)
244  ),
245  meshInterfaces_(mesh.interfaces()),
246  procAgglomeratorPtr_
247  (
248  (
249  (UPstream::nProcs(mesh.comm()) > 1)
250  && controlDict.found("processorAgglomerator")
251  )
253  (
254  controlDict.get<word>("processorAgglomerator"),
255  *this,
257  )
259  ),
260 
261  nCells_(maxLevels_),
262  restrictAddressing_(maxLevels_),
263  nFaces_(maxLevels_),
264  faceRestrictAddressing_(maxLevels_),
265  faceFlipMap_(maxLevels_),
266  nPatchFaces_(maxLevels_),
267  patchFaceRestrictAddressing_(maxLevels_),
268 
269  meshLevels_(maxLevels_)
270 {
271  // Limit the cells in the coarsest level based on the local number of
272  // cells. Note: 2 for pair-wise
273  nCellsInCoarsestLevel_ =
274  max(1, min(mesh.lduAddr().size()/2, nCellsInCoarsestLevel_));
275 
276  // Ensure all procs see the same nCellsInCoarsestLevel_
277  reduce(nCellsInCoarsestLevel_, minOp<label>());
278 
279  procCommunicator_.setSize(maxLevels_ + 1, -1);
280  if (processorAgglomerate())
281  {
282  procAgglomMap_.setSize(maxLevels_);
283  agglomProcIDs_.setSize(maxLevels_);
284  procCellOffsets_.setSize(maxLevels_);
285  procFaceMap_.setSize(maxLevels_);
286  procBoundaryMap_.setSize(maxLevels_);
287  procBoundaryFaceMap_.setSize(maxLevels_);
288  }
289 }
290 
291 
293 (
294  const lduMesh& mesh,
295  const dictionary& controlDict
296 )
297 {
298  if
299  (
301  (
302  GAMGAgglomeration::typeName
303  )
304  )
305  {
306  const word agglomeratorType
307  (
308  controlDict.getOrDefault<word>("agglomerator", "faceAreaPair")
309  );
310 
311  mesh.thisDb().time().libs().open
312  (
313  controlDict,
314  "geometricGAMGAgglomerationLibs",
315  lduMeshConstructorTablePtr_
316  );
317 
318  auto cstrIter = lduMeshConstructorTablePtr_->cfind(agglomeratorType);
319 
320  if (!cstrIter.found())
321  {
323  << "Unknown GAMGAgglomeration type "
324  << agglomeratorType << ".\n"
325  << "Valid matrix GAMGAgglomeration types :"
326  << lduMatrixConstructorTablePtr_->sortedToc() << endl
327  << "Valid geometric GAMGAgglomeration types :"
328  << lduMeshConstructorTablePtr_->sortedToc()
329  << exit(FatalError);
330  }
331 
332  return store(cstrIter()(mesh, controlDict).ptr());
333  }
334  else
335  {
337  (
338  GAMGAgglomeration::typeName
339  );
340  }
341 }
342 
343 
345 (
346  const lduMatrix& matrix,
347  const dictionary& controlDict
348 )
349 {
350  const lduMesh& mesh = matrix.mesh();
351 
352  if
353  (
355  (
356  GAMGAgglomeration::typeName
357  )
358  )
359  {
360  const word agglomeratorType
361  (
362  controlDict.getOrDefault<word>("agglomerator", "faceAreaPair")
363  );
364 
365  mesh.thisDb().time().libs().open
366  (
367  controlDict,
368  "algebraicGAMGAgglomerationLibs",
369  lduMatrixConstructorTablePtr_
370  );
371 
372  if
373  (
374  !lduMatrixConstructorTablePtr_
375  || !lduMatrixConstructorTablePtr_->found(agglomeratorType)
376  )
377  {
378  return New(mesh, controlDict);
379  }
380  else
381  {
382  auto cstrIter =
383  lduMatrixConstructorTablePtr_->cfind(agglomeratorType);
384 
385  return store(cstrIter()(matrix, controlDict).ptr());
386  }
387  }
388  else
389  {
391  (
392  GAMGAgglomeration::typeName
393  );
394  }
395 }
396 
397 
399 (
400  const lduMesh& mesh,
401  const scalarField& cellVolumes,
402  const vectorField& faceAreas,
403  const dictionary& controlDict
404 )
405 {
406  const word agglomeratorType
407  (
408  controlDict.getOrDefault<word>("agglomerator", "faceAreaPair")
409  );
410 
411  mesh.thisDb().time().libs().open
412  (
413  controlDict,
414  "geometricGAMGAgglomerationLibs",
415  geometryConstructorTablePtr_
416  );
417 
418  auto cstrIter = geometryConstructorTablePtr_->cfind(agglomeratorType);
419 
420  if (!cstrIter.found())
421  {
423  << "Unknown GAMGAgglomeration type "
424  << agglomeratorType << ".\n"
425  << "Valid geometric GAMGAgglomeration types :"
426  << geometryConstructorTablePtr_->sortedToc()
427  << exit(FatalError);
428  }
429 
431  (
432  cstrIter()
433  (
434  mesh,
435  cellVolumes,
436  faceAreas,
438  )
439  );
440 }
441 
442 
443 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
444 
446 {}
447 
448 
449 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
450 
452 (
453  const label i
454 ) const
455 {
456  if (i == 0)
457  {
458  return mesh_;
459  }
460  else
461  {
462  return meshLevels_[i - 1];
463  }
464 }
465 
466 
467 bool Foam::GAMGAgglomeration::hasMeshLevel(const label i) const
468 {
469  if (i == 0)
470  {
471  return true;
472  }
473  else
474  {
475  return meshLevels_.set(i - 1);
476  }
477 }
478 
479 
481 (
482  const label i
483 ) const
484 {
485  if (i == 0)
486  {
487  return meshInterfaces_;
488  }
489  else
490  {
491  return meshLevels_[i - 1].rawInterfaces();
492  }
493 }
494 
495 
497 {
498  if (hasMeshLevel(i))
499  {
500  meshLevels_.set(i - 1, nullptr);
501 
502  if (i < nCells_.size())
503  {
504  nCells_[i] = -555;
505  restrictAddressing_.set(i, nullptr);
506  nFaces_[i] = -666;
507  faceRestrictAddressing_.set(i, nullptr);
508  faceFlipMap_.set(i, nullptr);
509  nPatchFaces_.set(i, nullptr);
510  patchFaceRestrictAddressing_.set(i, nullptr);
511  }
512  }
513 }
514 
515 
517 (
518  const label leveli
519 ) const
520 {
521  return procAgglomMap_[leveli];
522 }
523 
524 
526 (
527  const label leveli
528 ) const
529 {
530  return agglomProcIDs_[leveli];
531 }
532 
533 
534 bool Foam::GAMGAgglomeration::hasProcMesh(const label leveli) const
535 {
536  return procCommunicator_[leveli] != -1;
537 }
538 
539 
540 Foam::label Foam::GAMGAgglomeration::procCommunicator(const label leveli) const
541 {
542  return procCommunicator_[leveli];
543 }
544 
545 
547 (
548  const label leveli
549 ) const
550 {
551  return procCellOffsets_[leveli];
552 }
553 
554 
556 (
557  const label leveli
558 ) const
559 {
560  return procFaceMap_[leveli];
561 }
562 
563 
565 (
566  const label leveli
567 ) const
568 {
569  return procBoundaryMap_[leveli];
570 }
571 
572 
574 (
575  const label leveli
576 ) const
577 {
578  return procBoundaryFaceMap_[leveli];
579 }
580 
581 
583 (
584  labelList& newRestrict,
585  label& nNewCoarse,
586  const lduAddressing& fineAddressing,
587  const labelUList& restriction,
588  const label nCoarse
589 )
590 {
591  if (fineAddressing.size() != restriction.size())
592  {
594  << "nCells:" << fineAddressing.size()
595  << " agglom:" << restriction.size()
596  << abort(FatalError);
597  }
598 
599  // Seed (master) for every region
600  labelList master(identity(fineAddressing.size()));
601 
602  // Now loop and transport master through region
603  const labelUList& lower = fineAddressing.lowerAddr();
604  const labelUList& upper = fineAddressing.upperAddr();
605 
606  while (true)
607  {
608  label nChanged = 0;
609 
610  forAll(lower, facei)
611  {
612  label own = lower[facei];
613  label nei = upper[facei];
614 
615  if (restriction[own] == restriction[nei])
616  {
617  // coarse-mesh-internal face
618 
619  if (master[own] < master[nei])
620  {
621  master[nei] = master[own];
622  nChanged++;
623  }
624  else if (master[own] > master[nei])
625  {
626  master[own] = master[nei];
627  nChanged++;
628  }
629  }
630  }
631 
632  reduce(nChanged, sumOp<label>());
633 
634  if (nChanged == 0)
635  {
636  break;
637  }
638  }
639 
640 
641  // Count number of regions/masters per coarse cell
642  labelListList coarseToMasters(nCoarse);
643  nNewCoarse = 0;
644  forAll(restriction, celli)
645  {
646  labelList& masters = coarseToMasters[restriction[celli]];
647 
648  if (!masters.found(master[celli]))
649  {
650  masters.append(master[celli]);
651  nNewCoarse++;
652  }
653  }
654 
655  if (nNewCoarse > nCoarse)
656  {
657  //WarningInFunction
658  // << "Have " << nCoarse
659  // << " agglomerated cells but " << nNewCoarse
660  // << " disconnected regions" << endl;
661 
662  // Keep coarseToMasters[0] the original coarse, allocate new ones
663  // for the others
664  labelListList coarseToNewCoarse(coarseToMasters.size());
665 
666  nNewCoarse = nCoarse;
667 
668  forAll(coarseToMasters, coarseI)
669  {
670  const labelList& masters = coarseToMasters[coarseI];
671 
672  labelList& newCoarse = coarseToNewCoarse[coarseI];
673  newCoarse.setSize(masters.size());
674  newCoarse[0] = coarseI;
675  for (label i=1; i<newCoarse.size(); i++)
676  {
677  newCoarse[i] = nNewCoarse++;
678  }
679  }
680 
681  newRestrict.setSize(fineAddressing.size());
682  forAll(restriction, celli)
683  {
684  const label coarseI = restriction[celli];
685 
686  label index = coarseToMasters[coarseI].find(master[celli]);
687  newRestrict[celli] = coarseToNewCoarse[coarseI][index];
688  }
689 
690  return false;
691  }
692 
693  return true;
694 }
695 
696 
697 // ************************************************************************* //
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
GAMGProcAgglomeration.H
Foam::maxOp
Definition: ops.H:223
Foam::GAMGAgglomeration::procFaceMap_
PtrList< labelListList > procFaceMap_
Mapping from processor to procMeshLevel face.
Definition: GAMGAgglomeration.H:136
Foam::GAMGAgglomeration::procAgglomeratorPtr_
autoPtr< GAMGProcAgglomeration > procAgglomeratorPtr_
Definition: GAMGAgglomeration.H:81
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::GAMGAgglomeration
Geometric agglomerated algebraic multigrid agglomeration class.
Definition: GAMGAgglomeration.H:64
Foam::fvMesh::thisDb
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
Definition: fvMesh.H:287
Foam::minOp
Definition: ops.H:224
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::GAMGAgglomeration::nCells_
labelList nCells_
The number of cells in each level.
Definition: GAMGAgglomeration.H:84
Foam::lduMatrix
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition: lduMatrix.H:83
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:186
Foam::GAMGAgglomeration::meshLevel
const lduMesh & meshLevel(const label leveli) const
Return LDU mesh of given level.
Definition: GAMGAgglomeration.C:452
Foam::GAMGAgglomeration::faceMap
const labelListList & faceMap(const label fineLeveli) const
Mapping from processor to procMesh face.
Definition: GAMGAgglomeration.C:556
Foam::List::append
void append(const T &val)
Append an element at the end of the list.
Definition: ListI.H:182
GAMGAgglomeration.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
lduMatrix.H
Foam::GAMGAgglomeration::faceRestrictAddressing_
PtrList< labelList > faceRestrictAddressing_
Face restriction addressing array.
Definition: GAMGAgglomeration.H:100
Foam::GAMGAgglomeration::hasMeshLevel
bool hasMeshLevel(const label leveli) const
Do we have mesh for given level?
Definition: GAMGAgglomeration.C:467
Foam::GAMGAgglomeration::meshLevels_
PtrList< lduPrimitiveMesh > meshLevels_
Hierarchy of mesh addressing.
Definition: GAMGAgglomeration.H:117
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
Foam::objectRegistry::foundObject
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
Definition: objectRegistryTemplates.C:379
Foam::GAMGAgglomeration::size
label size() const
Definition: GAMGAgglomeration.H:325
Foam::sumOp
Definition: ops.H:213
Foam::GAMGAgglomeration::cellOffsets
const labelList & cellOffsets(const label fineLeveli) const
Mapping from processor to procMesh cells.
Definition: GAMGAgglomeration.C:547
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::lduMesh::interfaces
virtual lduInterfacePtrsList interfaces() const =0
Return a list of pointers for each patch.
Foam::GAMGAgglomeration::agglomProcIDs
const labelList & agglomProcIDs(const label fineLeveli) const
Definition: GAMGAgglomeration.C:526
Foam::fvMesh::comm
virtual label comm() const
Return communicator used for parallel communication.
Definition: fvMesh.H:314
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:51
Foam::GAMGAgglomeration::boundaryMap
const labelListList & boundaryMap(const label fineLeveli) const
Mapping from processor to procMesh boundary.
Definition: GAMGAgglomeration.C:565
GAMGInterface.H
Foam::stringOps::lower
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
Definition: stringOps.C:1186
Foam::Field< scalar >
Foam::GAMGAgglomeration::GAMGAgglomeration
GAMGAgglomeration(const GAMGAgglomeration &)=delete
No copy construct.
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::fvMesh::lduAddr
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
Definition: fvMesh.C:685
controlDict
runTime controlDict().readEntry("adjustTimeStep"
Definition: debug.C:143
Foam::GAMGAgglomeration::clearLevel
void clearLevel(const label leveli)
Definition: GAMGAgglomeration.C:496
IOmanip.H
Istream and Ostream manipulators taking arguments.
Foam::UPtrList< const lduInterface >
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:434
Foam::GAMGProcAgglomeration::New
static autoPtr< GAMGProcAgglomeration > New(const word &type, GAMGAgglomeration &agglom, const dictionary &controlDict)
Return the selected agglomerator.
Definition: GAMGProcAgglomeration.C:359
Foam::GAMGAgglomeration::checkRestriction
static bool checkRestriction(labelList &newRestrict, label &nNewCoarse, const lduAddressing &fineAddressing, const labelUList &restriction, const label nCoarse)
Given restriction determines if coarse cells are connected.
Definition: GAMGAgglomeration.C:583
Foam::GAMGAgglomeration::nPatchFaces_
PtrList< labelList > nPatchFaces_
The number of (coarse) patch faces in each level.
Definition: GAMGAgglomeration.H:109
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
pairGAMGAgglomeration.H
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::Time::libs
dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
Definition: Time.H:505
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::GAMGAgglomeration::procAgglomMap_
PtrList< labelList > procAgglomMap_
Per level, per processor the processor it agglomerates into.
Definition: GAMGAgglomeration.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::setw
Omanip< int > setw(const int i)
Definition: IOmanip.H:199
Foam::GAMGAgglomeration::New
static const GAMGAgglomeration & New(const lduMesh &mesh, const dictionary &controlDict)
Return the selected geometric agglomerator.
Definition: GAMGAgglomeration.C:293
Foam::dlLibraryTable::open
bool open(bool verbose=true)
Definition: dlLibraryTable.C:409
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
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
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::GAMGAgglomeration::procAgglomMap
const labelList & procAgglomMap(const label fineLeveli) const
Definition: GAMGAgglomeration.C:517
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::GAMGAgglomeration::nFaces_
labelList nFaces_
The number of (coarse) faces in each level.
Definition: GAMGAgglomeration.H:92
Foam::GAMGAgglomeration::interfaceLevel
const lduInterfacePtrsList & interfaceLevel(const label leveli) const
Return LDU interface addressing of given level.
Definition: GAMGAgglomeration.C:481
Foam::lduAddressing::lowerAddr
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
Foam::GAMGAgglomeration::procBoundaryMap_
PtrList< labelListList > procBoundaryMap_
Mapping from processor to procMeshLevel boundary.
Definition: GAMGAgglomeration.H:139
Foam::List< label >
Foam::GAMGAgglomeration::compactLevels
void compactLevels(const label nCreatedLevels)
Shrink the number of levels to that specified.
Definition: GAMGAgglomeration.C:51
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::fvMesh::interfaces
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
Definition: fvMesh.H:308
Foam::UList< label >
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38
Foam::lduMatrix::mesh
const lduMesh & mesh() const
Return the LDU mesh from which the addressing is obtained.
Definition: lduMatrix.H:566
Foam::GAMGAgglomeration::boundaryFaceMap
const labelListListList & boundaryFaceMap(const label fineLeveli) const
Mapping from processor to procMesh boundary face.
Definition: GAMGAgglomeration.C:574
Foam::UList::size
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
Definition: UListI.H:360
Foam::MeshObject
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:88
Foam::GAMGAgglomeration::hasProcMesh
bool hasProcMesh(const label fineLeveli) const
Check that level has combined mesh.
Definition: GAMGAgglomeration.C:534
Foam::GAMGAgglomeration::procCommunicator
label procCommunicator(const label fineLeveli) const
Communicator for current level or -1.
Definition: GAMGAgglomeration.C:540
Foam::stringOps::upper
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
Definition: stringOps.C:1202
Foam::List::setSize
void setSize(const label newSize)
Alias for resize(const label)
Definition: ListI.H:146
Foam::GAMGAgglomeration::nCells
label nCells(const label leveli) const
Return number of coarse cells (before processor agglomeration)
Definition: GAMGAgglomeration.H:367
Foam::GAMGAgglomeration::faceFlipMap_
PtrList< boolList > faceFlipMap_
Face flip: for faces mapped to internal faces stores whether.
Definition: GAMGAgglomeration.H:105
lduMesh.H
Foam::GAMGAgglomeration::procBoundaryFaceMap_
PtrList< labelListListList > procBoundaryFaceMap_
Mapping from processor to procMeshLevel boundary face.
Definition: GAMGAgglomeration.H:142
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::GAMGAgglomeration::patchFaceRestrictAddressing_
PtrList< labelListList > patchFaceRestrictAddressing_
Patch-local face restriction addressing array.
Definition: GAMGAgglomeration.H:114
Foam::GAMGAgglomeration::procCellOffsets_
PtrList< labelList > procCellOffsets_
Mapping from processor to procMeshLevel cells.
Definition: GAMGAgglomeration.H:133
Foam::lduMesh::lduAddr
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
Foam::GAMGAgglomeration::processorAgglomerate
bool processorAgglomerate() const
Whether to agglomerate across processors.
Definition: GAMGAgglomeration.H:447
Foam::GAMGAgglomeration::agglomProcIDs_
PtrList< labelList > agglomProcIDs_
Per level the set of processors to agglomerate. Element 0 is.
Definition: GAMGAgglomeration.H:127
Foam::UPstream::nProcs
static label nProcs(const label communicator=worldComm)
Number of processes in parallel run, and 1 for serial run.
Definition: UPstream.H:446
Foam::lduMesh
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:62
Foam::lduAddressing::band
Tuple2< label, scalar > band() const
Calculate bandwidth and profile of addressing.
Definition: lduAddressing.C:260
Foam::GAMGAgglomeration::~GAMGAgglomeration
~GAMGAgglomeration()
Destructor.
Definition: GAMGAgglomeration.C:445
Foam::GAMGAgglomeration::continueAgglomerating
bool continueAgglomerating(const label nCells, const label nCoarseCells) const
Check the need for further agglomeration.
Definition: GAMGAgglomeration.C:211
Foam::GAMGAgglomeration::procCommunicator_
labelList procCommunicator_
Communicator for given level.
Definition: GAMGAgglomeration.H:130