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]
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]];
192 label index = order[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]);
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++)
385 mesh(myMesh, otherMeshes, procMeshI).interfaces();
388 boundaryMap[procMeshI].
setSize(interfaces.
size(), -1);
389 boundaryFaceMap[procMeshI].
setSize(interfaces.
size());
394 if (interfaces.
set(intI))
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];
514 mesh(myMesh, otherMeshes, procMeshI).interfaces();
517 refCast<const processorLduInterface>
519 interfaces[interfacei]
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];
544 mesh(myMesh, otherMeshes, procMeshI).interfaces();
546 refCast<const processorLduInterface>
548 interfaces[interfacei]
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;
587 upperAddr_.setSize(lowerAddr_.size(), -1);
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];
616 if (interfaces.
set(intI))
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>
661 interfaces[interfacei]
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);
743 forAll(faceMap, procMeshI)
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>
822 interfaces[interfacei]
828 min(myProcNo, nbrProcNo),
829 max(myProcNo, nbrProcNo)
842 label procMeshI = elem[0];
843 label interfacei = elem[1];
851 n += interfaces[interfacei].faceCells().
size();
863 label procMeshI = elem[0];
864 label interfacei = elem[1];
872 boundaryMap[procMeshI][interfacei] = allInterfacei;
873 labelList& bfMap = boundaryFaceMap[procMeshI][interfacei];
875 const labelUList& l = interfaces[interfacei].faceCells();
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);
virtual lduInterfacePtrsList interfaces() const =0
Return a list of pointers for each patch.
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.
#define forAll(list, i)
Loop across all elements in list.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
bool set(const label) const
Is element set.
virtual const labelUList & faceCells() const =0
Return faceCell addressing.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
void addInterfaces(lduInterfacePtrsList &interfaces, const lduSchedule &ps)
Add interfaces to a mesh constructed without.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
To & refCast(From &r)
Reference type cast template function.
void size(const label)
Override size to be inconsistent with allocated storage.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
Ostream & endl(Ostream &os)
Add newline and flush stream.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
static int & msgType()
Message tag of standard messages.
virtual label comm() const =0
Return communicator used for parallel communication.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
T & first()
Return the first element of the list.
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
Less operator for pairs of <processor><index>
Input inter-processor communications stream.
bool insert(const edge &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
lduPrimitiveMesh(const label nCells, labelList &l, labelList &u, const label comm, bool reuse)
Construct from components but without interfaces. Add interfaces.
An ordered pair of two objects of type <T> with first() and second() elements.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A class for handling words, derived from string.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
Simplest contrete lduMesh which stores the addressing needed by lduMatrix.
virtual const lduAddressing & lduAddr() const =0
Return ldu addressing.
Pair< label > labelPair
Label pair.
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].
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
label readLabel(Istream &is)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
bool set(const label) const
Is element set.
An abstract base class for processor coupled interfaces.
Map from edge (expressed as its endpoints) to value.
defineTypeNameAndDebug(combustionModel, 0)
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.
GAMG agglomerated processor interface.
Output inter-processor communications stream.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Abstract base class for GAMG agglomerated interfaces.
label size() const
Return the number of elements in the UPtrList.
void setSize(const label)
Reset size of List.
#define WarningInFunction
Report a warning using Foam::Warning.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
prefixOSstream Pout(cout, "Pout")
A List with indirect addressing.
virtual int neighbProcNo() const =0
Return neighbour processor number (rank in communicator)
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
bool operator()(const label a, const label b)
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.
virtual int myProcNo() const =0
Return processor number (rank in communicator)
T & last()
Return the last element of the list.
label size() const
Return the number of elements in the UList.
procLess(const labelPairList &lst)
label size() const
Return number of equations.
virtual const lduSchedule & patchSchedule() const =0