54 if (u[facei] < l[facei])
57 <<
"Reversed face. Problem at face " << facei
58 <<
" l:" << l[facei] <<
" u:" << u[facei]
61 if (l[facei] < 0 || u[facei] < 0 || u[facei] >=
size)
64 <<
"Illegal cell label. Problem at face " << facei
65 <<
" l:" << l[facei] <<
" u:" << u[facei]
70 for (label facei=1; facei < l.
size(); ++facei)
72 if (l[facei-1] > l[facei])
75 <<
"Lower not in incremental cell order." 76 <<
" Problem at face " << facei
77 <<
" l:" << l[facei] <<
" u:" << u[facei]
78 <<
" previous l:" << l[facei-1]
81 else if (l[facei-1] == l[facei])
84 if (u[facei-1] > u[facei])
87 <<
"Upper not in incremental cell order." 88 <<
" Problem at face " << facei
89 <<
" l:" << l[facei] <<
" u:" << u[facei]
90 <<
" previous u:" << u[facei-1]
101 const globalIndex& globalNumbering
117 PtrList<labelList> nbrGlobalCells(interfaces.size());
122 if (interfaces.set(inti))
124 interfaces[inti].initInternalFieldTransfer
137 if (interfaces.set(inti))
144 interfaces[inti].internalFieldTransfer
173 if (interfaces.set(inti))
175 for (
const label celli : interfaces[inti].faceCells())
189 cellCells[celli].setSize(nNbrs[celli], -1);
198 const label c0 = own[facei];
199 const label
c1 = nbr[facei];
201 cellCells[c0][nNbrs[c0]++] = globalIndices[
c1];
202 cellCells[
c1][nNbrs[
c1]++] = globalIndices[c0];
206 if (interfaces.set(inti))
208 const labelUList& faceCells = interfaces[inti].faceCells();
212 const label c0 = faceCells[facei];
213 cellCells[c0][nNbrs[c0]++] = nbrGlobalCells[inti][facei];
222 Foam::label Foam::lduPrimitiveMesh::totalSize
224 const PtrList<lduPrimitiveMesh>&
meshes 229 for (
const lduPrimitiveMesh& msh :
meshes)
231 size += msh.lduAddr().size();
252 <<
"Problem at face:" << facei
253 <<
" lower:" <<
lower[facei]
254 <<
" upper:" <<
upper[facei]
257 nNbrs[
lower[facei]]++;
265 offsets[celli+1] = offsets[celli]+nNbrs[celli];
273 const label celli =
lower[facei];
274 cellToFaces[nNbrs[celli]++] = facei;
281 DynamicList<label> order;
282 DynamicList<label> nbr;
286 for (label celli = 0; celli < nCells; ++celli)
288 const label startOfCell = offsets[celli];
289 const label nNbr = offsets[celli+1] - startOfCell;
296 nbr[i] =
upper[cellToFaces[offsets[celli]+i]];
300 for (
const label index : order)
302 oldToNew[cellToFaces[startOfCell + index]] = newFacei++;
312 Foam::lduPrimitiveMesh::lduPrimitiveMesh
322 lowerAddr_(l, reuse),
323 upperAddr_(u, reuse),
328 if (
max(lowerAddr_) >= nCells ||
min(lowerAddr_) < 0)
331 <<
" nCells:" << nCells
332 <<
" max(lower):" <<
max(lowerAddr_)
333 <<
" min(lower):" <<
min(lowerAddr_)
339 if (
max(upperAddr_) >= nCells ||
min(upperAddr_) < 0)
342 <<
" nCells:" << nCells
343 <<
" max(upper):" <<
max(upperAddr_)
344 <<
" min(upper):" <<
min(upperAddr_)
357 interfaces_ = interfaces;
361 primitiveInterfaces_.setSize(interfaces_.size());
364 if (interfaces_.set(i))
366 primitiveInterfaces_.set(i, &interfaces_[i]);
372 Foam::lduPrimitiveMesh::lduPrimitiveMesh
382 Foam::lduPrimitiveMesh::lduPrimitiveMesh
395 primitiveInterfaces_(),
401 if (
max(lowerAddr_) >= nCells ||
min(lowerAddr_) < 0)
404 <<
" nCells:" << nCells
405 <<
" max(lower):" <<
max(lowerAddr_)
406 <<
" min(lower):" <<
min(lowerAddr_)
412 if (
max(upperAddr_) >= nCells ||
min(upperAddr_) < 0)
415 <<
" nCells:" << nCells
416 <<
" max(upper):" <<
max(upperAddr_)
417 <<
" min(upper):" <<
min(upperAddr_)
426 interfaces_.
setSize(primitiveInterfaces_.size());
427 forAll(primitiveInterfaces_, i)
429 if (primitiveInterfaces_.set(i))
431 interfaces_.
set(i, &primitiveInterfaces_[i]);
437 Foam::lduPrimitiveMesh::lduPrimitiveMesh
443 const lduMesh& myMesh,
444 const PtrList<lduPrimitiveMesh>& otherMeshes,
453 lduAddressing(myMesh.lduAddr().size() + totalSize(otherMeshes)),
456 const label currentComm = myMesh.comm();
460 if (otherMeshes[i].
comm() != currentComm)
463 <<
"Communicator " << otherMeshes[i].comm()
465 <<
" differs from that of predecessor " 471 const label nMeshes = otherMeshes.size()+1;
478 <<
" agglomerating into " << myAgglom
479 <<
" as are " <<
findIndices(procAgglomMap, myAgglom)
486 if (procAgglomMap[procIDs[i]] != procAgglomMap[procIDs[0]])
489 <<
"Processor " << procIDs[i]
490 <<
" agglomerates to " << procAgglomMap[procIDs[i]]
491 <<
" whereas other processors " << procIDs
492 <<
" agglomerate to " 500 cellOffsets.setSize(nMeshes+1);
502 for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
504 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
506 cellOffsets[procMeshI+1] =
507 cellOffsets[procMeshI]
508 + procMesh.lduAddr().size();
513 labelList internalFaceOffsets(nMeshes+1);
514 internalFaceOffsets[0] = 0;
515 for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
517 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
519 internalFaceOffsets[procMeshI+1] =
520 internalFaceOffsets[procMeshI]
521 + procMesh.lduAddr().lowerAddr().size();
530 EdgeMap<labelPairList> mergedMap(2*myMesh.interfaces().size());
535 EdgeMap<labelPairList> unmergedMap(mergedMap.size());
537 boundaryMap.setSize(nMeshes);
538 boundaryFaceMap.setSize(nMeshes);
541 label nOtherInterfaces = 0;
544 for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
560 if (isA<processorLduInterface>(ldui))
562 const processorLduInterface& pldui =
563 refCast<const processorLduInterface>(ldui);
565 label agglom0 = procAgglomMap[pldui.myProcNo()];
566 label agglom1 = procAgglomMap[pldui.neighbProcNo()];
568 const edge procEdge(agglom0, agglom1);
570 if (agglom0 != myAgglom && agglom1 != myAgglom)
573 <<
"At mesh from processor " << procIDs[procMeshI]
574 <<
" have interface " << intI
575 <<
" with myProcNo:" << pldui.myProcNo()
576 <<
" with neighbProcNo:" << pldui.neighbProcNo()
579 else if (agglom0 == myAgglom && agglom1 == myAgglom)
584 Pout<<
"merged interface: myProcNo:" 586 <<
" nbr:" << pldui.neighbProcNo()
587 <<
" size:" << ldui.faceCells().size()
591 const label nbrProcMeshI =
592 procIDs.find(pldui.neighbProcNo());
594 if (procMeshI < nbrProcMeshI)
597 nCoupledFaces[procMeshI] += ldui.faceCells().size();
600 mergedMap(procEdge).append
609 Pout<<
"external interface: myProcNo:" 611 <<
" nbr:" << pldui.neighbProcNo()
612 <<
" size:" << ldui.faceCells().size()
616 unmergedMap(procEdge).append
626 <<
"At mesh from processor " << procIDs[procMeshI]
627 <<
" have interface " << intI
628 <<
" of unhandled type " <<
interfaces[intI].type()
641 Pout<<
"Remaining interfaces:" <<
endl;
644 Pout<<
" agglom procEdge:" << iter.key() <<
endl;
648 label procMeshI = elems[i][0];
649 label interfacei = elems[i][1];
653 const processorLduInterface& pldui =
654 refCast<const processorLduInterface>
659 Pout<<
" proc:" << procIDs[procMeshI]
660 <<
" interfacei:" << interfacei
661 <<
" between:" << pldui.myProcNo()
662 <<
" and:" << pldui.neighbProcNo()
670 Pout<<
"Merged interfaces:" <<
endl;
673 Pout<<
" agglom procEdge:" << iter.key() <<
endl;
678 label procMeshI = elems[i][0];
679 label interfacei = elems[i][1];
682 const processorLduInterface& pldui =
683 refCast<const processorLduInterface>
688 Pout<<
" proc:" << procIDs[procMeshI]
689 <<
" interfacei:" << interfacei
690 <<
" between:" << pldui.myProcNo()
691 <<
" and:" << pldui.neighbProcNo()
700 faceOffsets.setSize(nMeshes+1);
703 for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
705 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
706 label nInternal = procMesh.lduAddr().lowerAddr().size();
708 faceOffsets[procMeshI+1] =
709 faceOffsets[procMeshI]
711 + nCoupledFaces[procMeshI];
714 map.setSize(nInternal);
717 map[i] = faceOffsets[procMeshI] + i;
723 lowerAddr_.
setSize(faceOffsets.last(), -1);
730 for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
732 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
734 const labelUList& l = procMesh.lduAddr().lowerAddr();
735 const labelUList& u = procMesh.lduAddr().upperAddr();
738 label allFacei = faceOffsets[procMeshI];
742 lowerAddr_[allFacei] = cellOffsets[procMeshI]+l[facei];
743 upperAddr_[allFacei] = cellOffsets[procMeshI]+u[facei];
757 if (isA<processorLduInterface>(ldui))
759 const processorLduInterface& pldui =
760 refCast<const processorLduInterface>(ldui);
763 label myP = pldui.myProcNo();
764 label nbrP = pldui.neighbProcNo();
765 label nbrProcMeshI = procIDs.find(nbrP);
767 if (procMeshI < nbrProcMeshI)
772 const label agglom0 = procAgglomMap[myP];
773 const label agglom1 = procAgglomMap[nbrP];
776 mergedMap.cfind(edge(agglom0, agglom1));
786 label proci = elems[i][0];
787 label interfacei = elems[i][1];
795 const processorLduInterface& pldui =
796 refCast<const processorLduInterface>
803 elems[i][0] == nbrProcMeshI
804 && pldui.neighbProcNo() == procIDs[procMeshI]
807 nbrIntI = elems[i][1];
831 nbrInterfaces[nbrIntI].faceCells();
833 if (faceCells.size() != nbrFaceCells.size())
836 <<
"faceCells:" << faceCells
837 <<
" nbrFaceCells:" << nbrFaceCells
843 boundaryFaceMap[procMeshI][intI];
845 boundaryFaceMap[nbrProcMeshI][nbrIntI];
847 bfMap.
setSize(faceCells.size());
848 nbrBfMap.setSize(faceCells.size());
852 lowerAddr_[allFacei] =
853 cellOffsets[procMeshI]+faceCells[pfI];
854 bfMap[pfI] = allFacei;
855 upperAddr_[allFacei] =
856 cellOffsets[nbrProcMeshI]+nbrFaceCells[pfI];
857 nbrBfMap[pfI] = (-allFacei-1);
887 map[i] = oldToNew[map[i]];
891 label allFacei = -map[i]-1;
892 map[i] = -oldToNew[allFacei]-1;
901 forAll(boundaryFaceMap, proci)
903 const labelList& bMap = boundaryMap[proci];
906 if (bMap[intI] == -1)
909 labelList& bfMap = boundaryFaceMap[proci][intI];
915 bfMap[i] = oldToNew[bfMap[i]];
919 label allFacei = -bfMap[i]-1;
920 bfMap[i] = (-oldToNew[allFacei]-1);
932 interfaces_.
setSize(unmergedMap.size() + nOtherInterfaces);
933 primitiveInterfaces_.setSize(interfaces_.
size());
935 label allInterfacei = 0;
947 label procMeshI = elem[0];
948 label interfacei = elem[1];
956 const processorLduInterface& pldui =
957 refCast<const processorLduInterface>
961 label myProcNo = pldui.myProcNo();
962 label nbrProcNo = pldui.neighbProcNo();
965 min(myProcNo, nbrProcNo),
966 max(myProcNo, nbrProcNo)
978 label procMeshI = elem[0];
979 label interfacei = elem[1];
999 label procMeshI = elem[0];
1000 label interfacei = elem[1];
1008 boundaryMap[procMeshI][interfacei] = allInterfacei;
1009 labelList& bfMap = boundaryFaceMap[procMeshI][interfacei];
1016 allFaceCells[
n] = cellOffsets[procMeshI]+l[facei];
1017 allFaceRestrictAddressing[
n] =
n;
1026 label neighbProcNo = -1;
1030 if (iter.key()[0] == myAgglom)
1032 if (iter.key()[1] == myAgglom)
1035 <<
"problem procEdge:" << iter.key()
1039 neighbProcNo = iter.key()[1];
1043 if (iter.key()[1] != myAgglom)
1046 <<
"problem procEdge:" << iter.key()
1050 neighbProcNo = iter.key()[0];
1053 primitiveInterfaces_.set
1056 new processorGAMGInterface
1061 allFaceRestrictAddressing,
1069 interfaces_.
set(allInterfacei, &primitiveInterfaces_[allInterfacei]);
1073 Pout<<
"Created " << interfaces_[allInterfacei].type()
1074 <<
" interface at " << allInterfacei
1075 <<
" comm:" << comm_
1076 <<
" myProcNo:" << myAgglom
1077 <<
" neighbProcNo:" << neighbProcNo
1078 <<
" nFaces:" << allFaceCells.size()
1087 patchSchedule_ = nonBlockingSchedule<processorGAMGInterface>(interfaces_);
1100 const lduMesh& myMesh,
1101 const PtrList<lduPrimitiveMesh>& otherMeshes,
1105 return (meshI == 0 ? myMesh : otherMeshes[meshI-1]);
1125 for (label i = 1; i < procIDs.
size(); ++i)
1161 forAll(validInterface, intI)
1163 if (validInterface[intI])
1165 word coupleType(fromProc);
1174 otherMeshes[i-1].rawInterfaces(),
1181 otherMeshes[i-1].addInterfaces
1184 nonBlockingSchedule<processorGAMGInterface>
1197 boolList validInterface(interfaces.size());
1200 validInterface[intI] = interfaces.set(intI);
1213 << addressing.size()
1214 << addressing.lowerAddr()
1215 << addressing.upperAddr()
1220 if (interfaces.set(intI))
1222 const GAMGInterface&
interface =
refCast<const GAMGInterface>
virtual lduInterfacePtrsList interfaces() const =0
Return a list of pointers for each patch with only those pointing to interfaces being set...
List< labelList > labelListList
A List of labelList.
Field< label > labelField
Specialisation of Field<T> for label.
void size(const label n)
Older name for setAddressableSize.
static autoPtr< GAMGInterface > New(const label index, const lduInterfacePtrsList &coarseInterfaces, const lduInterface &fineInterface, const labelField &localRestrictAddressing, const labelField &neighbourRestrictAddressing, const label fineLevelIndex, const label coarseComm)
Return a pointer to a new interface created on freestore given.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void addInterfaces(lduInterfacePtrsList &interfaces, const lduSchedule &ps)
Add interfaces to a mesh constructed without.
void resize(const label len)
Adjust allocated size of list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Type & refCast(U &obj)
A dynamic_cast (for references) that generates FatalError on failed casts, uses the virtual type() me...
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
PtrList< const lduInterface > & primitiveInterfaces()
Return a non-const list of primitive interfaces.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
static int & msgType() noexcept
Message tag of standard messages.
interfaceProperties interface(alpha1, U, thermo->transportPropertiesDict())
List< lduScheduleEntry > lduSchedule
A List of lduSchedule entries.
static int myProcNo(const label communicator=worldComm)
Number of this process (starting from masterNo() = 0)
UList< label > labelUList
A UList of labels.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
#define forAll(list, i)
Loop across all elements in list.
Input inter-processor communications stream.
virtual label comm() const
Return communicator used for parallel communication.
void setSize(const label n)
Alias for resize()
"scheduled" : (MPI_Send, MPI_Recv)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
A class for handling words, derived from Foam::string.
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
label size() const noexcept
The number of elements in the list.
virtual label comm() const
Return communicator used for parallel communication.
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
List< labelPair > labelPairList
List of labelPairs.
static const lduMesh & mesh(const lduMesh &mesh0, const PtrList< lduPrimitiveMesh > &otherMeshes, const label meshI)
Select either mesh0 (meshI is 0) or otherMeshes[meshI-1].
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
defineTypeNameAndDebug(combustionModel, 0)
void setSize(const label newLen)
Same as resize()
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
UIndirectList< label > labelUIndList
UIndirectList of labels.
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
static void checkUpperTriangular(const label size, const labelUList &l, const labelUList &u)
Check if in upper-triangular ordering.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
List< labelListList > labelListListList
A List of labelListList.
static labelListList globalCellCells(const lduMesh &mesh, const globalIndex &globalNumbering)
Calculate global cell-cells.
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
"nonBlocking" : (MPI_Isend, MPI_Irecv)
static void gather(const label comm, const lduMesh &mesh, const labelList &procIDs, PtrList< lduPrimitiveMesh > &otherMeshes)
Gather meshes from other processors onto procIDs[0].
The class contains the addressing required by the lduMatrix: upper, lower and losort.
List< label > labelList
A List of labels.
void setSize(const label n)
Alias for resize()
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch with only those pointing to interfaces being set...
List< bool > boolList
A List of bools.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
static labelList upperTriOrder(const label nCells, const labelUList &lower, const labelUList &upper)
Calculate upper-triangular order.
forAllConstIters(mixture.phases(), phase)
label size() const
Return number of equations.
virtual const lduSchedule & patchSchedule() const =0
Return patch field evaluation schedule.
static constexpr const zero Zero
Global zero (0)