50 nCells_.setSize(nCreatedLevels);
51 restrictAddressing_.setSize(nCreatedLevels);
52 nFaces_.setSize(nCreatedLevels);
53 faceRestrictAddressing_.setSize(nCreatedLevels);
54 faceFlipMap_.setSize(nCreatedLevels);
55 nPatchFaces_.setSize(nCreatedLevels);
56 patchFaceRestrictAddressing_.setSize(nCreatedLevels);
57 meshLevels_.setSize(nCreatedLevels);
60 procCommunicator_.setSize(nCreatedLevels + 1);
61 if (processorAgglomerate())
63 procAgglomMap_.setSize(nCreatedLevels);
64 agglomProcIDs_.setSize(nCreatedLevels);
65 procCellOffsets_.setSize(nCreatedLevels);
66 procFaceMap_.setSize(nCreatedLevels);
67 procBoundaryMap_.setSize(nCreatedLevels);
68 procBoundaryFaceMap_.setSize(nCreatedLevels);
70 procAgglomeratorPtr_().agglomerate();
76 if (processorAgglomerate() && debug)
78 Info<<
"GAMGAgglomeration:" <<
nl 79 <<
" local agglomerator : " <<
type() <<
nl;
80 if (processorAgglomerate())
82 Info<<
" processor agglomerator : " 83 << procAgglomeratorPtr_().type() << nl
88 <<
setw(20) <<
"nFaces/nCells" 89 <<
setw(20) <<
"nInterfaces" 90 <<
setw(20) <<
"nIntFaces/nCells" 91 <<
setw(12) <<
"profile" 94 <<
setw(8) <<
"nProcs" 110 <<
setw(8) <<
"-----" 111 <<
setw(8) <<
"------" 129 for (
label levelI = 0; levelI <= size(); levelI++)
133 scalar faceCellRatio = 0;
134 label nInterfaces = 0;
137 scalar profile = 0.0;
139 if (hasMeshLevel(levelI))
143 const lduMesh& fineMesh = meshLevel(levelI);
152 if (interfaces.set(i))
155 nIntFaces += interfaces[i].faceCells().size();
158 ratio = scalar(nIntFaces)/nCells;
168 scalar maxFaceCellRatio =
170 scalar totFaceCellRatio =
181 int oldPrecision =
Info().precision(4);
184 <<
setw(8) << totNprocs
186 <<
setw(8) << totNCells/totNprocs
187 <<
setw(8) << maxNCells
189 <<
setw(8) << totFaceCellRatio/totNprocs
190 <<
setw(8) << maxFaceCellRatio
192 <<
setw(8) << scalar(totNInt)/totNprocs
193 <<
setw(8) << maxNInt
195 <<
setw(8) << totRatio/totNprocs
196 <<
setw(8) << maxRatio
197 <<
setw(12) << totProfile/totNprocs
200 Info().precision(oldPrecision);
209 const label nFineCells,
210 const label nCoarseCells
221 return nTotalCoarseCells < nTotalFineCells;
238 nCellsInCoarsestLevel_
247 && controlDict.
found(
"processorAgglomerator")
251 controlDict.
lookup(
"processorAgglomerator"),
259 restrictAddressing_(maxLevels_),
261 faceRestrictAddressing_(maxLevels_),
262 faceFlipMap_(maxLevels_),
263 nPatchFaces_(maxLevels_),
264 patchFaceRestrictAddressing_(maxLevels_),
266 meshLevels_(maxLevels_)
268 procCommunicator_.setSize(maxLevels_ + 1, -1);
269 if (processorAgglomerate())
271 procAgglomMap_.setSize(maxLevels_);
272 agglomProcIDs_.setSize(maxLevels_);
273 procCellOffsets_.setSize(maxLevels_);
274 procFaceMap_.setSize(maxLevels_);
275 procBoundaryMap_.setSize(maxLevels_);
276 procBoundaryFaceMap_.setSize(maxLevels_);
291 GAMGAgglomeration::typeName
295 const word agglomeratorType
303 "geometricGAMGAgglomerationLibs",
304 lduMeshConstructorTablePtr_
307 lduMeshConstructorTable::iterator cstrIter =
308 lduMeshConstructorTablePtr_->find(agglomeratorType);
310 if (cstrIter == lduMeshConstructorTablePtr_->end())
313 <<
"Unknown GAMGAgglomeration type " 314 << agglomeratorType <<
".\n" 315 <<
"Valid matrix GAMGAgglomeration types are :" 316 << lduMatrixConstructorTablePtr_->sortedToc() <<
endl 317 <<
"Valid geometric GAMGAgglomeration types are :" 318 << lduMeshConstructorTablePtr_->sortedToc()
322 return store(cstrIter()(mesh, controlDict).ptr());
328 GAMGAgglomeration::typeName
346 GAMGAgglomeration::typeName
350 const word agglomeratorType
358 "algebraicGAMGAgglomerationLibs",
359 lduMatrixConstructorTablePtr_
364 !lduMatrixConstructorTablePtr_
365 || !lduMatrixConstructorTablePtr_->found(agglomeratorType)
368 return New(mesh, controlDict);
372 lduMatrixConstructorTable::iterator cstrIter =
373 lduMatrixConstructorTablePtr_->find(agglomeratorType);
375 return store(cstrIter()(matrix, controlDict).ptr());
382 GAMGAgglomeration::typeName
396 const word agglomeratorType
404 "geometricGAMGAgglomerationLibs",
405 geometryConstructorTablePtr_
408 geometryConstructorTable::iterator cstrIter =
409 geometryConstructorTablePtr_->find(agglomeratorType);
411 if (cstrIter == geometryConstructorTablePtr_->end())
414 <<
"Unknown GAMGAgglomeration type " 415 << agglomeratorType <<
".\n" 416 <<
"Valid geometric GAMGAgglomeration types are :" 417 << geometryConstructorTablePtr_->sortedToc()
453 return meshLevels_[i - 1];
466 return meshLevels_.set(i - 1);
478 return meshInterfaces_;
482 return meshLevels_[i - 1].rawInterfaces();
491 meshLevels_.set(i - 1,
nullptr);
493 if (i < nCells_.size())
496 restrictAddressing_.set(i,
nullptr);
498 faceRestrictAddressing_.set(i,
nullptr);
499 faceFlipMap_.set(i,
nullptr);
500 nPatchFaces_.set(i,
nullptr);
501 patchFaceRestrictAddressing_.set(i,
nullptr);
512 return procAgglomMap_[leveli];
521 return agglomProcIDs_[leveli];
527 return procCommunicator_[leveli] != -1;
533 return procCommunicator_[leveli];
542 return procCellOffsets_[leveli];
551 return procFaceMap_[leveli];
560 return procBoundaryMap_[leveli];
569 return procBoundaryFaceMap_[leveli];
582 if (fineAddressing.
size() != restrict.
size())
585 <<
"nCells:" << fineAddressing.
size()
586 <<
" agglom:" << restrict.
size()
603 label own = lower[facei];
604 label nei = upper[facei];
606 if (restrict[own] == restrict[nei])
610 if (master[own] < master[nei])
612 master[nei] = master[own];
615 else if (master[own] > master[nei])
617 master[own] = master[nei];
637 labelList& masters = coarseToMasters[restrict[celli]];
639 if (
findIndex(masters, master[celli]) == -1)
641 masters.
append(master[celli]);
646 if (nNewCoarse > nCoarse)
657 nNewCoarse = nCoarse;
659 forAll(coarseToMasters, coarseI)
661 const labelList& masters = coarseToMasters[coarseI];
663 labelList& newCoarse = coarseToNewCoarse[coarseI];
665 newCoarse[0] = coarseI;
668 newCoarse[i] = nNewCoarse++;
675 label coarseI = restrict[celli];
678 newRestrict[celli] = coarseToNewCoarse[coarseI][index];
virtual lduInterfacePtrsList interfaces() const =0
Return a list of pointers for each patch.
bool hasProcMesh(const label fineLeveli) const
Check that level has combined mesh.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#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.
GAMGAgglomeration(const lduMesh &mesh, const dictionary &controlDict)
Construct given mesh and controls.
errorManipArg< error, int > exit(error &err, const int errNo=1)
runTime controlDict().lookup("adjustTimeStep") >> adjustTimeStep
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const lduMesh & meshLevel(const label leveli) const
Return LDU mesh of given level.
void size(const label)
Override size to be inconsistent with allocated storage.
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...
bool foundObject(const word &name) const
Is the named Type found?
static const GAMGAgglomeration & New(const lduMesh &mesh, const dictionary &controlDict)
Return the selected geometric agglomerator.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
virtual label comm() const =0
Return communicator used for parallel communication.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
static bool checkRestriction(labelList &newRestrict, label &nNewCoarse, const lduAddressing &fineAddressing, const labelUList &restrict, const label nCoarse)
Given restriction determines if coarse cells are connected.
void clearLevel(const label leveli)
dlLibraryTable libs
Table of loaded dynamic libraries.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
static autoPtr< GAMGProcAgglomeration > New(const word &type, GAMGAgglomeration &agglom, const dictionary &controlDict)
Return the selected agglomerator.
label procCommunicator(const label fineLeveli) const
Communicator for current level or -1.
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
bool continueAgglomerating(const label nCells, const label nCoarseCells) const
Check the need for further agglomeration.
A class for handling words, derived from string.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
void append(const T &)
Append an element at the end of the list.
const labelList & agglomProcIDs(const label fineLeveli) const
Set of processors to agglomerate. Element 0 is the.
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Tuple2< label, scalar > band() const
Calculate bandwidth and profile of addressing.
Istream and Ostream manipulators taking arguments.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void setSize(const label)
Reset size of List.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
const labelList & cellOffsets(const label fineLeveli) const
Mapping from processor to procMesh cells.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
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.
virtual const objectRegistry & thisDb() const
Return the object registry.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
const lduInterfacePtrsList & interfaceLevel(const label leveli) const
Return LDU interface addressing of given level.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Omanip< int > setw(const int i)
label size() const
Return the number of elements in the UList.
Geometric agglomerated algebraic multigrid agglomeration class.
bool hasMeshLevel(const label leveli) const
Do we have mesh for given level?
const lduMesh & mesh() const
Return the LDU mesh from which the addressing is obtained.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
label size() const
Return number of equations.
void compactLevels(const label nCreatedLevels)
Shrink the number of levels to that specified.
const labelListList & faceMap(const label fineLeveli) const
Mapping from processor to procMesh face.