60 void Foam::lduPrimitiveMesh::checkUpperTriangular
69 if (u[facei] < l[facei])
72 <<
"Reversed face. Problem at face " << facei
73 <<
" l:" << l[facei] <<
" u:" << u[facei]
76 if (l[facei] < 0 || u[facei] < 0 || u[facei] >=
size)
79 <<
"Illegal cell label. Problem at face " << facei
80 <<
" l:" << l[facei] <<
" u:" << u[facei]
85 for (
label facei=1; facei < l.size(); facei++)
87 if (l[facei-1] > l[facei])
90 <<
"Lower not in incremental cell order."
91 <<
" Problem at face " << facei
92 <<
" l:" << l[facei] <<
" u:" << u[facei]
93 <<
" previous l:" << l[facei-1]
96 else if (l[facei-1] == l[facei])
99 if (u[facei-1] > u[facei])
102 <<
"Upper not in incremental cell order."
103 <<
" Problem at face " << facei
104 <<
" l:" << l[facei] <<
" u:" << u[facei]
105 <<
" previous u:" << u[facei-1]
115 const PtrList<lduPrimitiveMesh>& meshes
122 size += meshes[i].lduAddr().size();
140 if (upper[facei] < lower[facei])
143 <<
"Problem at face:" << facei
144 <<
" lower:" << lower[facei]
145 <<
" upper:" << upper[facei]
148 nNbrs[lower[facei]]++;
156 offsets[celli+1] = offsets[celli]+nNbrs[celli];
164 label celli = lower[facei];
165 cellToFaces[nNbrs[celli]++] = facei;
177 for (
label celli = 0; celli < nCells; celli++)
179 label startOfCell = offsets[celli];
180 label nNbr = offsets[celli+1] - startOfCell;
186 nbr[i] = upper[cellToFaces[offsets[celli]+i]];
193 oldToNew[cellToFaces[startOfCell + index]] = newFacei++;
213 lowerAddr_(l, reuse),
214 upperAddr_(u, reuse),
225 interfaces_ = interfaces;
229 primitiveInterfaces_.
setSize(interfaces_.size());
232 if (interfaces_.set(i))
234 primitiveInterfaces_.set(i, &interfaces_[i]);
253 primitiveInterfaces_(0),
257 primitiveInterfaces_.transfer(primitiveInterfaces);
260 interfaces_.
setSize(primitiveInterfaces_.size());
261 forAll(primitiveInterfaces_, i)
263 if (primitiveInterfaces_.set(i))
265 interfaces_.
set(i, &primitiveInterfaces_[i]);
287 lduAddressing(myMesh.lduAddr().size() + totalSize(otherMeshes)),
298 if (otherMeshes[i].
comm() != currentComm)
301 <<
"Communicator " << otherMeshes[i].comm()
303 <<
" differs from that of predecessor "
309 const label nMeshes = otherMeshes.
size()+1;
313 if (lduPrimitiveMesh::debug)
316 <<
" agglomerating into " << myAgglom
317 <<
" as are " <<
findIndices(procAgglomMap, myAgglom)
324 if (procAgglomMap[procIDs[i]] != procAgglomMap[procIDs[0]])
327 <<
"Processor " << procIDs[i]
328 <<
" agglomerates to " << procAgglomMap[procIDs[i]]
329 <<
" whereas other processors " << procIDs
330 <<
" agglomerate to "
338 cellOffsets.
setSize(nMeshes+1);
340 for (
label procMeshI = 0; procMeshI < nMeshes; procMeshI++)
342 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
344 cellOffsets[procMeshI+1] =
345 cellOffsets[procMeshI]
351 labelList internalFaceOffsets(nMeshes+1);
352 internalFaceOffsets[0] = 0;
353 for (
label procMeshI = 0; procMeshI < nMeshes; procMeshI++)
355 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
357 internalFaceOffsets[procMeshI+1] =
358 internalFaceOffsets[procMeshI]
376 boundaryFaceMap.
setSize(nMeshes);
379 label nOtherInterfaces = 0;
382 for (
label procMeshI = 0; procMeshI < nMeshes; procMeshI++)
398 if (isA<processorLduInterface>(ldui))
401 refCast<const processorLduInterface>(ldui);
406 const edge procEdge(agglom0, agglom1);
408 if (agglom0 != myAgglom && agglom1 != myAgglom)
411 <<
"At mesh from processor " << procIDs[procMeshI]
412 <<
" have interface " << intI
413 <<
" with myProcNo:" << pldui.
myProcNo()
417 else if (agglom0 == myAgglom && agglom1 == myAgglom)
422 Pout<<
"merged interface: myProcNo:"
435 if (procMeshI < nbrProcMeshI)
442 mergedMap.
find(procEdge);
444 if (iter != mergedMap.
end())
446 iter().append(
labelPair(procMeshI, intI));
461 Pout<<
"external interface: myProcNo:"
469 unmergedMap.
find(procEdge);
471 if (iter != unmergedMap.
end())
473 iter().append(
labelPair(procMeshI, intI));
489 <<
"At mesh from processor " << procIDs[procMeshI]
490 <<
" have interface " << intI
491 <<
" of unhandled type " <<
interfaces[intI].type()
504 Pout<<
"Remaining interfaces:" <<
endl;
507 Pout<<
" agglom procEdge:" << iter.key() <<
endl;
511 label procMeshI = elems[i][0];
512 label interfacei = elems[i][1];
517 refCast<const processorLduInterface>
522 Pout<<
" proc:" << procIDs[procMeshI]
523 <<
" interfacei:" << interfacei
533 Pout<<
"Merged interfaces:" <<
endl;
536 Pout<<
" agglom procEdge:" << iter.key() <<
endl;
541 label procMeshI = elems[i][0];
542 label interfacei = elems[i][1];
546 refCast<const processorLduInterface>
551 Pout<<
" proc:" << procIDs[procMeshI]
552 <<
" interfacei:" << interfacei
563 faceOffsets.
setSize(nMeshes+1);
566 for (
label procMeshI = 0; procMeshI < nMeshes; procMeshI++)
568 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
571 faceOffsets[procMeshI+1] =
572 faceOffsets[procMeshI]
574 + nCoupledFaces[procMeshI];
580 map[i] = faceOffsets[procMeshI] + i;
593 for (
label procMeshI = 0; procMeshI < nMeshes; procMeshI++)
595 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
601 label allFacei = faceOffsets[procMeshI];
605 lowerAddr_[allFacei] = cellOffsets[procMeshI]+l[facei];
606 upperAddr_[allFacei] = cellOffsets[procMeshI]+u[facei];
620 if (isA<processorLduInterface>(ldui))
623 refCast<const processorLduInterface>(ldui);
630 if (procMeshI < nbrProcMeshI)
635 label agglom0 = procAgglomMap[myP];
636 label agglom1 = procAgglomMap[nbrP];
639 mergedMap.
find(
edge(agglom0, agglom1));
641 if (fnd != mergedMap.
end())
649 label proci = elems[i][0];
650 label interfacei = elems[i][1];
659 refCast<const processorLduInterface>
666 elems[i][0] == nbrProcMeshI
670 nbrIntI = elems[i][1];
694 nbrInterfaces[nbrIntI].faceCells();
696 if (faceCells.
size() != nbrFaceCells.
size())
699 <<
"faceCells:" << faceCells
700 <<
" nbrFaceCells:" << nbrFaceCells
706 boundaryFaceMap[procMeshI][intI];
708 boundaryFaceMap[nbrProcMeshI][nbrIntI];
715 lowerAddr_[allFacei] =
716 cellOffsets[procMeshI]+faceCells[pfI];
717 bfMap[pfI] = allFacei;
718 upperAddr_[allFacei] =
719 cellOffsets[nbrProcMeshI]+nbrFaceCells[pfI];
720 nbrBfMap[pfI] = (-allFacei-1);
750 map[i] = oldToNew[map[i]];
754 label allFacei = -map[i]-1;
755 map[i] = -oldToNew[allFacei]-1;
764 forAll(boundaryFaceMap, proci)
766 const labelList& bMap = boundaryMap[proci];
769 if (bMap[intI] == -1)
772 labelList& bfMap = boundaryFaceMap[proci][intI];
778 bfMap[i] = oldToNew[bfMap[i]];
782 label allFacei = -bfMap[i]-1;
783 bfMap[i] = (-oldToNew[allFacei]-1);
795 interfaces_.
setSize(unmergedMap.
size() + nOtherInterfaces);
796 primitiveInterfaces_.setSize(interfaces_.
size());
798 label allInterfacei = 0;
810 label procMeshI = elem[0];
811 label interfacei = elem[1];
820 refCast<const processorLduInterface>
828 min(myProcNo, nbrProcNo),
829 max(myProcNo, nbrProcNo)
842 label procMeshI = elem[0];
843 label interfacei = elem[1];
863 label procMeshI = elem[0];
864 label interfacei = elem[1];
872 boundaryMap[procMeshI][interfacei] = allInterfacei;
873 labelList& bfMap = boundaryFaceMap[procMeshI][interfacei];
880 allFaceCells[
n] = cellOffsets[procMeshI]+l[facei];
881 allFaceRestrictAddressing[
n] =
n;
890 label neighbProcNo = -1;
894 if (iter.key()[0] == myAgglom)
896 if (iter.key()[1] == myAgglom)
899 <<
"problem procEdge:" << iter.key()
903 neighbProcNo = iter.key()[1];
907 if (iter.key()[1] != myAgglom)
910 <<
"problem procEdge:" << iter.key()
914 neighbProcNo = iter.key()[0];
917 primitiveInterfaces_.set
925 allFaceRestrictAddressing,
933 interfaces_.
set(allInterfacei, &primitiveInterfaces_[allInterfacei]);
937 Pout<<
"Created " << interfaces_[allInterfacei].type()
938 <<
" interface at " << allInterfacei
940 <<
" myProcNo:" << myAgglom
941 <<
" neighbProcNo:" << neighbProcNo
942 <<
" nFaces:" << allFaceCells.
size()
951 patchSchedule_ = nonBlockingSchedule<processorGAMGInterface>(interfaces_);
955 checkUpperTriangular(cellOffsets.
last(), lowerAddr_, upperAddr_);
969 return (meshI == 0 ? myMesh : otherMeshes[meshI-1]);
989 for (
label i = 1; i < procIDs.
size(); i++)
1006 boolList validInterface(fromSlave);
1025 forAll(validInterface, intI)
1027 if (validInterface[intI])
1029 word coupleType(fromSlave);
1038 otherMeshes[i-1].rawInterfaces(),
1045 otherMeshes[i-1].addInterfaces
1048 nonBlockingSchedule<processorGAMGInterface>
1064 validInterface[intI] = interfaces.
set(intI);
1077 << addressing.
size()
1084 if (interfaces.
set(intI))
1091 toMaster << interface.type();
1092 interface.
write(toMaster);
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Map from edge (expressed as its endpoints) to value.
Abstract base class for GAMG agglomerated interfaces.
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.
label size() const
Return number of elements in table.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Input inter-processor communications stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
Output inter-processor communications stream.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool set(const label) const
Is element set.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
A List with indirect addressing.
T & first()
Return the first element of the list.
label size() const
Return the number of elements in the UList.
T & last()
Return the last element of the list.
static bool write(const commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Write given buffer to given processor.
static int & msgType()
Message tag of standard messages.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
bool set(const label) const
Is element set.
label size() const
Return the number of elements in the UPtrList.
void setSize(const label)
Reset size of UPtrList. This can only be used to set the size.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
The class contains the addressing required by the lduMatrix: upper, lower and losort.
virtual const lduSchedule & patchSchedule() const =0
label size() const
Return number of equations.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
virtual const labelUList & faceCells() const =0
Return faceCell addressing.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
virtual label comm() const =0
Return communicator used for parallel communication.
virtual lduInterfacePtrsList interfaces() const =0
Return a list of pointers for each patch.
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
Simplest concrete lduMesh which stores the addressing needed by lduMatrix.
void addInterfaces(lduInterfacePtrsList &interfaces, const lduSchedule &ps)
Add interfaces to a mesh constructed without.
lduPrimitiveMesh(const label nCells, labelList &l, labelList &u, const label comm, bool reuse)
Construct from components but without interfaces. Add interfaces.
virtual label comm() const
Return communicator used for parallel communication.
static const lduMesh & mesh(const lduMesh &mesh0, const PtrList< lduPrimitiveMesh > &otherMeshes, const label meshI)
Select either mesh0 (meshI is 0) or otherMeshes[meshI-1].
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
static void gather(const label comm, const lduMesh &mesh, const labelList &procIDs, PtrList< lduPrimitiveMesh > &otherMeshes)
Gather meshes from other processors onto procIDs[0].
Less operator for pairs of <processor><index>
bool operator()(const label a, const label b)
procLess(const labelPairList &lst)
GAMG agglomerated processor interface.
An abstract base class for processor coupled interfaces.
virtual int neighbProcNo() const =0
Return neighbour processor number (rank in communicator)
virtual int myProcNo() const =0
Return processor number (rank in communicator)
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< labelPair > labelPairList
List of labelPairs.
Pair< label > labelPair
Label pair.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
To & refCast(From &r)
Reference type cast template function.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
int order(const scalar s)
errorManip< error > abort(error &err)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
label readLabel(Istream &is)
prefixOSstream Pout(cout, "Pout")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
UList< label > labelUList
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable