53 const label nCreatedLevels,
54 const bool doProcessorAgglomerate
84 Info<<
"GAMGAgglomeration:" <<
nl 85 <<
" local agglomerator : " <<
type() <<
nl;
86 if (processorAgglomerate())
88 Info<<
" processor agglomerator : " 89 << procAgglomeratorPtr_().type() <<
nl 94 <<
setw(20) <<
"nFaces/nCells" 95 <<
setw(20) <<
"nInterfaces" 96 <<
setw(20) <<
"nIntFaces/nCells" 97 <<
setw(12) <<
"profile" 100 <<
setw(8) <<
"nProcs" 116 <<
setw(8) <<
"-----" 117 <<
setw(8) <<
"------" 135 const label maxSize =
returnReduce(size(), maxOp<label>());
137 for (label levelI = 0; levelI <= maxSize; levelI++)
141 scalar faceCellRatio = 0;
142 label nInterfaces = 0;
145 scalar profile = 0.0;
147 if (hasMeshLevel(levelI))
151 const lduMesh& fineMesh = meshLevel(levelI);
152 nCells = fineMesh.lduAddr().size();
154 scalar(fineMesh.lduAddr().lowerAddr().size())/nCells;
157 fineMesh.interfaces();
160 if (interfaces.set(i))
163 nIntFaces += interfaces[i].faceCells().size();
166 ratio = scalar(nIntFaces)/nCells;
168 profile = fineMesh.lduAddr().band().second();
176 scalar maxFaceCellRatio =
178 scalar totFaceCellRatio =
181 label maxNInt =
returnReduce(nInterfaces, maxOp<label>());
182 label totNInt =
returnReduce(nInterfaces, sumOp<label>());
187 scalar totProfile =
returnReduce(profile, sumOp<scalar>());
192 <<
setw(8) << totNprocs
194 <<
setw(8) << totNCells/totNprocs
195 <<
setw(8) << maxNCells
197 <<
setw(8) << totFaceCellRatio/totNprocs
198 <<
setw(8) << maxFaceCellRatio
200 <<
setw(8) << scalar(totNInt)/totNprocs
201 <<
setw(8) << maxNInt
203 <<
setw(8) << totRatio/totNprocs
204 <<
setw(8) << maxRatio
205 <<
setw(12) << totProfile/totNprocs
216 const label nCellsInCoarsestLevel,
217 const label nFineCells,
218 const label nCoarseCells,
222 const label nTotalCoarseCells =
230 const label nTotalFineCells =
232 return nTotalCoarseCells < nTotalFineCells;
245 MeshObject<lduMesh,
Foam::GeometricMeshObject, GAMGAgglomeration>(
mesh),
249 nCellsInCoarsestLevel_
251 controlDict.getOrDefault<label>(
"nCellsInCoarsestLevel", 10)
253 meshInterfaces_(
mesh.interfaces()),
257 (UPstream::nProcs(
mesh.comm()) > 1)
260 ? GAMGProcAgglomeration::
New 266 : autoPtr<GAMGProcAgglomeration>()
270 restrictAddressing_(maxLevels_),
272 faceRestrictAddressing_(maxLevels_),
273 faceFlipMap_(maxLevels_),
274 nPatchFaces_(maxLevels_),
275 patchFaceRestrictAddressing_(maxLevels_),
277 meshLevels_(maxLevels_)
306 const GAMGAgglomeration* agglomPtr =
309 GAMGAgglomeration::typeName
318 const word agglomeratorType
320 controlDict.getOrDefault<word>(
"agglomerator",
"faceAreaPair")
326 "geometricGAMGAgglomerationLibs",
327 lduMeshConstructorTablePtr_
330 auto* ctorPtr = lduMeshConstructorTable(agglomeratorType);
335 <<
"Unknown GAMGAgglomeration type " 336 << agglomeratorType <<
".\n" 337 <<
"Valid matrix GAMGAgglomeration types :" 338 << lduMatrixConstructorTablePtr_->sortedToc() <<
endl 339 <<
"Valid geometric GAMGAgglomeration types :" 340 << lduMeshConstructorTablePtr_->sortedToc()
347 agglomPtr().printLevels();
349 return store(agglomPtr.ptr());
356 const lduMatrix& matrix,
360 const lduMesh&
mesh = matrix.mesh();
362 const GAMGAgglomeration* agglomPtr =
365 GAMGAgglomeration::typeName
374 const word agglomeratorType
376 controlDict.getOrDefault<word>(
"agglomerator",
"faceAreaPair")
382 "algebraicGAMGAgglomerationLibs",
383 lduMatrixConstructorTablePtr_
386 auto* ctorPtr = lduMatrixConstructorTable(agglomeratorType);
397 agglomPtr().printLevels();
399 return store(agglomPtr.ptr());
414 const GAMGAgglomeration* agglomPtr =
417 GAMGAgglomeration::typeName
426 const word agglomeratorType
428 controlDict.lookupOrDefault<word>(
"agglomerator",
"faceAreaPair")
434 "geometricGAMGAgglomerationLibs",
435 geometryConstructorTablePtr_
438 auto* ctorPtr = geometryConstructorTable(agglomeratorType);
443 <<
"Unknown GAMGAgglomeration type " 444 << agglomeratorType <<
".\n" 445 <<
"Valid geometric GAMGAgglomeration types :" 446 << geometryConstructorTablePtr_->sortedToc()
462 agglomPtr().printLevels();
464 return store(agglomPtr.ptr());
488 return meshLevels_[i - 1];
501 return meshLevels_.set(i - 1);
513 return meshInterfaces_;
517 return meshLevels_[i - 1].rawInterfaces();
526 meshLevels_.set(i - 1,
nullptr);
528 if (i < nCells_.size())
531 restrictAddressing_.set(i,
nullptr);
533 faceRestrictAddressing_.set(i,
nullptr);
534 faceFlipMap_.set(i,
nullptr);
535 nPatchFaces_.set(i,
nullptr);
536 patchFaceRestrictAddressing_.set(i,
nullptr);
547 return procAgglomMap_[leveli];
556 return agglomProcIDs_[leveli];
562 return procCommunicator_[leveli] != -1;
568 return procCommunicator_[leveli];
577 return procCellOffsets_[leveli];
586 return procFaceMap_[leveli];
595 return procBoundaryMap_[leveli];
604 return procBoundaryFaceMap_[leveli];
617 if (fineAddressing.
size() != restriction.
size())
620 <<
"nCells:" << fineAddressing.
size()
621 <<
" agglom:" << restriction.
size()
638 const label own =
lower[facei];
639 const label nei =
upper[facei];
641 if (restriction[own] == restriction[nei])
645 if (master[own] < master[nei])
647 master[nei] = master[own];
650 else if (master[own] > master[nei])
652 master[own] = master[nei];
658 reduce(nChanged, sumOp<label>());
670 forAll(restriction, celli)
672 labelList& masters = coarseToMasters[restriction[celli]];
674 if (!masters.found(master[celli]))
676 masters.
append(master[celli]);
681 if (nNewCoarse > nCoarse)
692 nNewCoarse = nCoarse;
694 forAll(coarseToMasters, coarseI)
696 const labelList& masters = coarseToMasters[coarseI];
698 labelList& newCoarse = coarseToNewCoarse[coarseI];
699 newCoarse.
setSize(masters.size());
700 newCoarse[0] = coarseI;
701 for (label i=1; i<newCoarse.size(); i++)
703 newCoarse[i] = nNewCoarse++;
708 forAll(restriction, celli)
710 const label coarseI = restriction[celli];
712 const label index = coarseToMasters[coarseI].find(master[celli]);
713 newRestrict[celli] = coarseToNewCoarse[coarseI][index];
autoPtr< GAMGProcAgglomeration > procAgglomeratorPtr_
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
PtrList< labelListList > procBoundaryMap_
Mapping from processor to procMeshLevel boundary.
bool hasProcMesh(const label fineLeveli) const
Check that level has combined mesh.
static bool checkRestriction(labelList &newRestrict, label &nNewCoarse, const lduAddressing &fineAddressing, const labelUList &restriction, const label nCoarse)
Given restriction determines if coarse cells are connected.
void size(const label n)
Older name for setAddressableSize.
bool continueAgglomerating(const label nCellsInCoarsestLevel, const label nCells, const label nCoarseCells, const label comm) const
Check the need for further agglomeration.
PtrList< labelListList > procFaceMap_
Mapping from processor to procMeshLevel face.
dlLibraryTable & libs() const noexcept
Mutable access to the loaded dynamic libraries.
PtrList< labelListList > patchFaceRestrictAddressing_
Patch-local face restriction addressing array.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual int precision() const
Get precision of output field.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
PtrList< labelListListList > procBoundaryFaceMap_
Mapping from processor to procMeshLevel boundary face.
GAMGAgglomeration(const GAMGAgglomeration &)=delete
No copy construct.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void append(const T &val)
Append an element at the end of the list.
const lduMesh & meshLevel(const label leveli) const
Return LDU mesh of given level.
PtrList< labelList > procCellOffsets_
Mapping from processor to procMeshLevel cells.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
const labelListList & boundaryMap(const label fineLeveli) const
Mapping from processor to procMesh boundary.
Ostream & endl(Ostream &os)
Add newline and flush stream.
~GAMGAgglomeration()
Destructor.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
static const GAMGAgglomeration & New(const lduMesh &mesh, const dictionary &controlDict)
Return the selected geometric agglomerator.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
static int & msgType() noexcept
Message tag of standard messages.
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
PtrList< labelList > faceRestrictAddressing_
Face restriction addressing array.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
List< labelList > labelListList
List of labelList.
PtrList< labelList > nPatchFaces_
The number of (coarse) patch faces in each level.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
void clearLevel(const label leveli)
UList< label > labelUList
A UList of labels.
PtrList< labelList > agglomProcIDs_
Per level the set of processors to agglomerate. Element 0 is.
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
#define forAll(list, i)
Loop across all elements in list.
label procCommunicator(const label fineLeveli) const
Communicator for current level or -1.
labelList procCommunicator_
Communicator for given level.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
void setSize(const label n)
Alias for resize()
bool processorAgglomerate() const
Whether to agglomerate across processors.
PtrList< lduPrimitiveMesh > meshLevels_
Hierarchy of mesh addressing.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
const lduMesh & mesh() const noexcept
Reference to the mesh.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const Time & time() const noexcept
Return time registry.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
const labelList & agglomProcIDs(const label fineLeveli) const
Set of processors to agglomerate. Element 0 is the master processor. (local, same only on those proce...
void printLevels() const
Print level overview.
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
labelList nCells_
The number of cells in each level.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
runTime controlDict().readEntry("adjustTimeStep"
The central control dictionary, the contents of which are either taken directly from the FOAM_CONTROL...
errorManip< error > abort(error &err)
labelList nFaces_
The number of (coarse) faces in each level.
PtrList< labelField > restrictAddressing_
Cell restriction addressing array.
OSstream & stream(OSstream *alternative=nullptr)
Return OSstream for output operations. Use the alternative stream for serial-only output if it is a v...
Istream and Ostream manipulators taking arguments.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
const label maxLevels_
Max number of levels.
const labelList & cellOffsets(const label fineLeveli) const
Mapping from processor to procMesh cells.
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
const labelListListList & boundaryFaceMap(const label fineLeveli) const
Mapping from processor to procMesh boundary face.
const labelList & procAgglomMap(const label fineLeveli) const
Mapping from processor to agglomerated processor (global, all processors have the same information)...
PtrList< labelList > procAgglomMap_
Per level, per processor the processor it agglomerates into.
const lduInterfacePtrsList & interfaceLevel(const label leveli) const
Return LDU interface addressing of given level.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Field< vector > vectorField
Specialisation of Field<T> for vector.
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.
Omanip< int > setw(const int i)
List< label > labelList
A List of labels.
bool open(bool verbose=true)
Open named, but unopened libraries. These names will normally have been added with the append() metho...
Geometric agglomerated algebraic multigrid agglomeration class.
bool hasMeshLevel(const label leveli) const
Do we have mesh for given level?
label nCellsInCoarsestLevel_
Number of cells in coarsest level.
void compactLevels(const label nCreatedLevels, const bool doProcessorAgglomerate)
Shrink the number of levels to that specified. Optionally do.
label size() const
Return number of equations.
const labelListList & faceMap(const label fineLeveli) const
Mapping from processor to procMesh face.