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 nCoarseCells
213 bool contAgg = nCoarseCells >= nCellsInCoarsestLevel_;
221 Foam::GAMGAgglomeration::GAMGAgglomeration
231 nCellsInCoarsestLevel_
240 && controlDict.
found(
"processorAgglomerator")
244 controlDict.
lookup(
"processorAgglomerator"),
252 restrictAddressing_(maxLevels_),
254 faceRestrictAddressing_(maxLevels_),
255 faceFlipMap_(maxLevels_),
256 nPatchFaces_(maxLevels_),
257 patchFaceRestrictAddressing_(maxLevels_),
259 meshLevels_(maxLevels_)
261 procCommunicator_.setSize(maxLevels_ + 1, -1);
262 if (processorAgglomerate())
264 procAgglomMap_.setSize(maxLevels_);
265 agglomProcIDs_.setSize(maxLevels_);
266 procCellOffsets_.setSize(maxLevels_);
267 procFaceMap_.setSize(maxLevels_);
268 procBoundaryMap_.setSize(maxLevels_);
269 procBoundaryFaceMap_.setSize(maxLevels_);
284 GAMGAgglomeration::typeName
288 const word agglomeratorType
296 "geometricGAMGAgglomerationLibs",
297 lduMeshConstructorTablePtr_
300 lduMeshConstructorTable::iterator cstrIter =
301 lduMeshConstructorTablePtr_->
find(agglomeratorType);
303 if (cstrIter == lduMeshConstructorTablePtr_->end())
306 <<
"Unknown GAMGAgglomeration type " 307 << agglomeratorType <<
".\n" 308 <<
"Valid matrix GAMGAgglomeration types are :" 309 << lduMatrixConstructorTablePtr_->sortedToc() <<
endl 310 <<
"Valid geometric GAMGAgglomeration types are :" 311 << lduMeshConstructorTablePtr_->sortedToc()
315 return store(cstrIter()(mesh, controlDict).ptr());
321 GAMGAgglomeration::typeName
339 GAMGAgglomeration::typeName
343 const word agglomeratorType
351 "algebraicGAMGAgglomerationLibs",
352 lduMatrixConstructorTablePtr_
357 !lduMatrixConstructorTablePtr_
358 || !lduMatrixConstructorTablePtr_->found(agglomeratorType)
361 return New(mesh, controlDict);
365 lduMatrixConstructorTable::iterator cstrIter =
366 lduMatrixConstructorTablePtr_->find(agglomeratorType);
368 return store(cstrIter()(matrix, controlDict).ptr());
375 GAMGAgglomeration::typeName
389 const word agglomeratorType
397 "geometricGAMGAgglomerationLibs",
398 geometryConstructorTablePtr_
401 geometryConstructorTable::iterator cstrIter =
402 geometryConstructorTablePtr_->
find(agglomeratorType);
404 if (cstrIter == geometryConstructorTablePtr_->end())
407 <<
"Unknown GAMGAgglomeration type " 408 << agglomeratorType <<
".\n" 409 <<
"Valid geometric GAMGAgglomeration types are :" 410 << geometryConstructorTablePtr_->sortedToc()
446 return meshLevels_[i - 1];
459 return meshLevels_.set(i - 1);
471 return meshInterfaces_;
475 return meshLevels_[i - 1].rawInterfaces();
484 meshLevels_.set(i - 1, NULL);
486 if (i < nCells_.size())
489 restrictAddressing_.set(i, NULL);
491 faceRestrictAddressing_.set(i, NULL);
492 faceFlipMap_.set(i, NULL);
493 nPatchFaces_.set(i, NULL);
494 patchFaceRestrictAddressing_.set(i, NULL);
505 return procAgglomMap_[leveli];
514 return agglomProcIDs_[leveli];
520 return procCommunicator_[leveli] != -1;
526 return procCommunicator_[leveli];
535 return procCellOffsets_[leveli];
544 return procFaceMap_[leveli];
553 return procBoundaryMap_[leveli];
562 return procBoundaryFaceMap_[leveli];
575 if (fineAddressing.
size() != restrict.
size())
578 <<
"nCells:" << fineAddressing.
size()
579 <<
" agglom:" << restrict.
size()
596 label own = lower[facei];
597 label nei = upper[facei];
599 if (restrict[own] == restrict[nei])
603 if (master[own] < master[nei])
605 master[nei] = master[own];
608 else if (master[own] > master[nei])
610 master[own] = master[nei];
630 labelList& masters = coarseToMasters[restrict[celli]];
632 if (
findIndex(masters, master[celli]) == -1)
634 masters.
append(master[celli]);
639 if (nNewCoarse > nCoarse)
650 nNewCoarse = nCoarse;
652 forAll(coarseToMasters, coarseI)
654 const labelList& masters = coarseToMasters[coarseI];
656 labelList& newCoarse = coarseToNewCoarse[coarseI];
658 newCoarse[0] = coarseI;
661 newCoarse[i] = nNewCoarse++;
668 label coarseI = restrict[celli];
671 newRestrict[celli] = coarseToNewCoarse[coarseI][index];
virtual lduInterfacePtrsList interfaces() const =0
Return a list of pointers for each patch.
const Time & time() const
Return time.
#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.
const labelList & procAgglomMap(const label fineLeveli) const
Mapping from processor to agglomerated processor (global, all.
errorManipArg< error, int > exit(error &err, const int errNo=1)
runTime controlDict().lookup("adjustTimeStep") >> adjustTimeStep
bool hasProcMesh(const label fineLeveli) const
Check that level has combined mesh.
A list of keyword definitions, which are a keyword followed by any number of values (e...
bool foundObject(const word &name) const
Is the named Type found?
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Tuple2< label, scalar > band() const
Calculate bandwidth and profile of addressing.
void size(const label)
Override size to be inconsistent with allocated storage.
virtual const objectRegistry & thisDb() const
Return the object registry.
bool hasMeshLevel(const label leveli) const
Do we have mesh for given level?
Ostream & endl(Ostream &os)
Add newline and flush stream.
~GAMGAgglomeration()
Destructor.
const lduMesh & mesh() const
Return the LDU mesh from which the addressing is obtained.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
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.
const lduMesh & meshLevel(const label leveli) const
Return LDU mesh of given level.
const labelList & cellOffsets(const label fineLeveli) const
Mapping from processor to procMesh cells.
virtual label comm() const =0
Return communicator used for parallel communication.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
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)
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.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
const labelListList & faceMap(const label fineLeveli) const
Mapping from processor to procMesh face.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
label size() const
Return number of equations.
A class for handling words, derived from string.
void reduce(T &Value, const BinaryOp &bop) const
Helper: reduce with current communicator.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
void append(const T &)
Append an element at the end of the list.
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
errorManip< error > abort(error &err)
const labelListListList & boundaryFaceMap(const label fineLeveli) const
Mapping from processor to procMesh boundary face.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
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 occurence of given element and return index,.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const lduInterfacePtrsList & interfaceLevel(const label leveli) const
Return LDU interface addressing of given level.
label size() const
Return the number of elements in the UList.
void setSize(const label)
Reset size of List.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
static label nProcs(const label communicator=0)
Number of processes in parallel run.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
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.
bool continueAgglomerating(const label nCoarseCells) const
Check the need for further agglomeration.
Omanip< int > setw(const int i)
label procCommunicator(const label fineLeveli) const
Communicator for current level or -1.
const labelListList & boundaryMap(const label fineLeveli) const
Mapping from processor to procMesh boundary.
Geometric agglomerated algebraic multigrid agglomeration class.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
const labelList & agglomProcIDs(const label fineLeveli) const
Set of processors to agglomerate. Element 0 is the.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
void compactLevels(const label nCreatedLevels)
Shrink the number of levels to that specified.