36void Foam::GAMGSolver::agglomerateMatrix
38 const label fineLevelIndex,
39 const lduMesh& coarseMesh,
40 const lduInterfacePtrsList& coarseMeshInterfaces
44 const lduMatrix& fineMatrix = matrixLevel(fineLevelIndex);
48 const label nCoarseFaces = agglomeration_.nFaces(fineLevelIndex);
49 const label nCoarseCells = agglomeration_.nCells(fineLevelIndex);
55 new lduMatrix(coarseMesh)
57 lduMatrix& coarseMatrix = matrixLevels_[fineLevelIndex];
64 scalarField& coarseDiag = coarseMatrix.diag(nCoarseCells);
66 agglomeration_.restrictField
76 interfaceLevel(fineLevelIndex);
79 primitiveInterfaceLevels_.set
82 new PtrList<lduInterfaceField>(fineInterfaces.size())
85 PtrList<lduInterfaceField>& coarsePrimInterfaces =
86 primitiveInterfaceLevels_[fineLevelIndex];
95 interfaceLevels_[fineLevelIndex];
98 interfaceLevelsBouCoeffs_.
set
101 new FieldField<Field, scalar>(fineInterfaces.size())
103 FieldField<Field, scalar>& coarseInterfaceBouCoeffs =
104 interfaceLevelsBouCoeffs_[fineLevelIndex];
107 interfaceLevelsIntCoeffs_.set
110 new FieldField<Field, scalar>(fineInterfaces.size())
112 FieldField<Field, scalar>& coarseInterfaceIntCoeffs =
113 interfaceLevelsIntCoeffs_[fineLevelIndex];
116 agglomerateInterfaceCoefficients
119 coarseMeshInterfaces,
120 coarsePrimInterfaces,
122 coarseInterfaceBouCoeffs,
123 coarseInterfaceIntCoeffs
129 agglomeration_.faceRestrictAddressing(fineLevelIndex);
131 agglomeration_.faceFlipMap(fineLevelIndex);
135 if (fineMatrix.hasLower())
142 scalarField& coarseUpper = coarseMatrix.upper(nCoarseFaces);
143 scalarField& coarseLower = coarseMatrix.lower(nCoarseFaces);
145 forAll(faceRestrictAddr, fineFacei)
147 label cFace = faceRestrictAddr[fineFacei];
153 if (!faceFlipMap[fineFacei])
155 coarseUpper[cFace] += fineUpper[fineFacei];
156 coarseLower[cFace] += fineLower[fineFacei];
160 coarseUpper[cFace] += fineLower[fineFacei];
161 coarseLower[cFace] += fineUpper[fineFacei];
167 coarseDiag[-1 - cFace] +=
168 fineUpper[fineFacei] + fineLower[fineFacei];
178 scalarField& coarseUpper = coarseMatrix.upper(nCoarseFaces);
180 forAll(faceRestrictAddr, fineFacei)
182 label cFace = faceRestrictAddr[fineFacei];
186 coarseUpper[cFace] += fineUpper[fineFacei];
191 coarseDiag[-1 - cFace] += 2*fineUpper[fineFacei];
199void Foam::GAMGSolver::agglomerateInterfaceCoefficients
201 const label fineLevelIndex,
211 interfaceLevel(fineLevelIndex);
215 interfaceBouCoeffsLevel(fineLevelIndex);
219 interfaceIntCoeffsLevel(fineLevelIndex);
222 agglomeration_.patchFaceRestrictAddressing(fineLevelIndex);
225 agglomeration_.nPatchFaces(fineLevelIndex);
229 forAll(fineInterfaces, inti)
231 if (fineInterfaces.set(inti))
236 coarseMeshInterfaces[inti]
239 coarsePrimInterfaces.set
251 &coarsePrimInterfaces[inti]
254 const labelList& faceRestrictAddressing = patchFineToCoarse[inti];
256 coarseInterfaceBouCoeffs.set
261 agglomeration_.restrictField
263 coarseInterfaceBouCoeffs[inti],
264 fineInterfaceBouCoeffs[inti],
265 faceRestrictAddressing
268 coarseInterfaceIntCoeffs.set
273 agglomeration_.restrictField
275 coarseInterfaceIntCoeffs[inti],
276 fineInterfaceIntCoeffs[inti],
277 faceRestrictAddressing
284void Foam::GAMGSolver::gatherMatrices
286 const label destLevel,
306 Pout<<
"GAMGSolver::gatherMatrices :"
307 <<
" collecting matrices from procs:" << procIDs
308 <<
" using comm:" << comm <<
endl;
311 const auto& boundaryMap = agglomeration_.boundaryMap(destLevel);
330 bitSet validCoeffs(interfaces.size());
331 forAll(interfaceBouCoeffs, intI)
333 if (interfaceBouCoeffs.set(intI))
335 validCoeffs.set(intI);
340 bitSet validInterface(interfaces.size());
343 const label allIntI = boundaryMap[proci][intI];
344 if (interfaces.set(intI) && allIntI != -1)
346 validInterface.set(intI);
357 for (
const label intI : validCoeffs)
360 << interfaceBouCoeffs[intI]
361 << interfaceIntCoeffs[intI];
363 for (
const label intI : validInterface)
376 pBufs.finishedGathers();
383 const lduMesh& destMesh = agglomeration_.meshLevel(destLevel);
387 otherMats.resize(nProcs-1);
388 otherBouCoeffs.resize(nProcs-1);
389 otherIntCoeffs.resize(nProcs-1);
390 otherInterfaces.resize(nProcs-1);
394 const label otherI = proci-1;
398 otherMats.set(otherI,
new lduMatrix(destMesh, fromProc));
401 const bitSet validCoeffs(fromProc);
402 const bitSet validInterface(fromProc);
404 otherBouCoeffs.emplace_set(otherI, validCoeffs.size());
405 otherIntCoeffs.emplace_set(otherI, validCoeffs.size());
406 otherInterfaces.emplace_set(otherI, validInterface.size());
409 for (
const label intI : validCoeffs)
411 otherBouCoeffs[otherI].emplace_set(intI, fromProc);
412 otherIntCoeffs[otherI].emplace_set(intI, fromProc);
416 for (
const label intI : validInterface)
418 const word coupleType(fromProc);
420 const label allIntI = boundaryMap[proci][intI];
422 otherInterfaces[otherI].set
430 destInterfaces[allIntI]
441void Foam::GAMGSolver::procAgglomerateMatrix
457 const lduMatrix& coarsestMatrix = matrixLevels_[levelI];
459 interfaceLevels_[levelI];
461 interfaceLevelsBouCoeffs_[levelI];
463 interfaceLevelsIntCoeffs_[levelI];
467 const label agglomComm = agglomeration_.agglomCommunicator(levelI+1);
499 const lduMesh& allMesh = agglomeration_.meshLevel(levelI+1);
500 const labelList& cellOffsets = agglomeration_.cellOffsets(levelI+1);
502 const labelListList& boundaryMap = agglomeration_.boundaryMap(levelI+1);
504 agglomeration_.boundaryFaceMap(levelI+1);
506 allMatrixPtr.reset(
new lduMatrix(allMesh));
509 if (coarsestMatrix.hasDiag())
516 coarsestMatrix.diag().size()
517 ) = coarsestMatrix.diag();
524 otherMats[i].
diag().size(),
526 ) = otherMats[i].diag();
529 if (coarsestMatrix.hasLower())
536 ) = coarsestMatrix.lower();
543 ) = otherMats[i].lower();
546 if (coarsestMatrix.hasUpper())
553 ) = coarsestMatrix.upper();
560 ) = otherMats[i].upper();
570 allInterfaceBouCoeffs.setSize(allMeshInterfaces.size());
571 allInterfaceIntCoeffs.setSize(allMeshInterfaces.size());
572 allPrimitiveInterfaces.setSize(allMeshInterfaces.size());
573 allInterfaces.setSize(allMeshInterfaces.size());
575 forAll(allMeshInterfaces, intI)
578 label size =
patch.faceCells().size();
580 allInterfaceBouCoeffs.set(intI,
new scalarField(size));
581 allInterfaceIntCoeffs.set(intI,
new scalarField(size));
586 forAll(boundaryMap, proci)
592 : otherBouCoeffs[proci-1]
598 : otherIntCoeffs[proci-1]
602 const labelList& bMap = boundaryMap[proci];
605 label allIntI = bMap[procIntI];
612 if (!allInterfaces.set(allIntI))
616 allMeshInterfaces[allIntI]
628 coarsestInterfaces[procIntI]
631 allPrimitiveInterfaces.set
644 if (otherInterfaces[proci-1].
set(procIntI))
649 otherInterfaces[proci-1][procIntI]
652 allPrimitiveInterfaces.set
668 allPrimitiveInterfaces.set
683 allPrimitiveInterfaces.get(allIntI)
690 scalarField& allBou = allInterfaceBouCoeffs[allIntI];
691 scalarField& allInt = allInterfaceIntCoeffs[allIntI];
693 const labelList& map = boundaryFaceMap[proci][procIntI];
695 const scalarField& procBou = procBouCoeffs[procIntI];
696 const scalarField& procInt = procIntCoeffs[procIntI];
700 label allFacei = map[i];
706 allBou[allFacei] = procBou[i];
707 allInt[allFacei] = procInt[i];
710 else if (procBouCoeffs.set(procIntI))
714 const labelList& map = boundaryFaceMap[proci][procIntI];
715 const scalarField& procBou = procBouCoeffs[procIntI];
716 const scalarField& procInt = procIntCoeffs[procIntI];
722 label allFacei = map[i];
724 if (coarsestMatrix.hasUpper())
726 allMatrix.upper()[allFacei] = -procBou[i];
728 if (coarsestMatrix.hasLower())
730 allMatrix.lower()[allFacei] = -procInt[i];
735 label allFacei = -map[i]-1;
737 if (coarsestMatrix.hasUpper())
739 allMatrix.upper()[allFacei] = -procInt[i];
741 if (coarsestMatrix.hasLower())
743 allMatrix.lower()[allFacei] = -procBou[i];
779void Foam::GAMGSolver::procAgglomerateMatrix
805 procAgglomerateMatrix
815 allInterfaceBouCoeffs(),
816 allInterfaceIntCoeffs(),
817 allPrimitiveInterfaces(),
821 matrixLevels_.set(levelI, allMatrixPtr);
822 interfaceLevelsBouCoeffs_.set(levelI, allInterfaceBouCoeffs);
823 interfaceLevelsIntCoeffs_.set(levelI, allInterfaceIntCoeffs);
824 primitiveInterfaceLevels_.set(levelI, allPrimitiveInterfaces);
825 interfaceLevels_.set(levelI, allInterfaces);
A field of fields is a PtrList of fields with reference counting.
Abstract base class for GAMG agglomerated interface fields.
static autoPtr< GAMGInterfaceField > New(const GAMGInterface &GAMGCp, const lduInterfaceField &fineInterface)
Return a pointer to a new interface created on freestore given.
Abstract base class for GAMG agglomerated interfaces.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Buffers for inter-processor communications streams (UOPstream, UIPstream).
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
A non-owning sub-view of a List (allocated or unallocated storage).
Input inter-processor communications stream using MPI send/recv etc. - operating on external buffer.
A List with indirect addressing. Like IndirectList but does not store addressing.
Output inter-processor communications stream using MPI send/recv etc. - operating on external buffer.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
static List< int > & procID(int communicator)
The list of ranks within a given communicator.
static constexpr int masterNo() noexcept
Relative rank for the master process - is always 0.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
Namespace for handling debugging switches.
const std::string patch
OpenFOAM patch number as a std::string.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
List< labelListList > labelListListList
List of labelListList.
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
List< bool > boolList
A List of bools.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
interfaceProperties interface(alpha1, U, thermo->transportPropertiesDict())
#define forAll(list, i)
Loop across all elements in list.