73 if (u[facei] < l[facei])
76 <<
"Reversed face. Problem at face " << facei
77 <<
" l:" << l[facei] <<
" u:" << u[facei]
80 if (l[facei] < 0 || u[facei] < 0 || u[facei] >=
size)
83 <<
"Illegal cell label. Problem at face " << facei
84 <<
" l:" << l[facei] <<
" u:" << u[facei]
89 for (label facei=1; facei < l.
size(); ++facei)
91 if (l[facei-1] > l[facei])
94 <<
"Lower not in incremental cell order."
95 <<
" Problem at face " << facei
96 <<
" l:" << l[facei] <<
" u:" << u[facei]
97 <<
" previous l:" << l[facei-1]
100 else if (l[facei-1] == l[facei])
103 if (u[facei-1] > u[facei])
106 <<
"Upper not in incremental cell order."
107 <<
" Problem at face " << facei
108 <<
" l:" << l[facei] <<
" u:" << u[facei]
109 <<
" previous u:" << u[facei-1]
141 if (interfaces.
set(inti))
143 interfaces[inti].initInternalFieldTransfer
158 if (interfaces.
set(inti))
165 interfaces[inti].internalFieldTransfer
194 if (interfaces.
set(inti))
196 for (
const label celli : interfaces[inti].
faceCells())
210 cellCells[celli].
setSize(nNbrs[celli], -1);
219 const label c0 = own[facei];
220 const label c1 = nbr[facei];
222 cellCells[c0][nNbrs[c0]++] = globalIndices[c1];
223 cellCells[c1][nNbrs[c1]++] = globalIndices[c0];
227 if (interfaces.
set(inti))
234 cellCells[c0][nNbrs[c0]++] = nbrGlobalCells[inti][facei];
252 size += msh.lduAddr().size();
270 if (upper[facei] < lower[facei])
273 <<
"Problem at face:" << facei
274 <<
" lower:" << lower[facei]
275 <<
" upper:" << upper[facei]
278 nNbrs[lower[facei]]++;
286 offsets[celli+1] = offsets[celli]+nNbrs[celli];
294 const label celli = lower[facei];
295 cellToFaces[nNbrs[celli]++] = facei;
307 for (label celli = 0; celli < nCells; ++celli)
309 const label startOfCell = offsets[celli];
310 const label nNbr = offsets[celli+1] - startOfCell;
317 nbr[i] = upper[cellToFaces[offsets[celli]+i]];
321 for (
const label index : order)
323 oldToNew[cellToFaces[startOfCell + index]] = newFacei++;
343 lowerAddr_(l, reuse),
344 upperAddr_(u, reuse),
354 interfaces_ = interfaces;
358 primitiveInterfaces_.
setSize(interfaces_.size());
361 if (interfaces_.set(i))
363 primitiveInterfaces_.set(i, &interfaces_[i]);
392 primitiveInterfaces_(),
399 interfaces_.
setSize(primitiveInterfaces_.size());
400 forAll(primitiveInterfaces_, i)
402 if (primitiveInterfaces_.set(i))
404 interfaces_.
set(i, &primitiveInterfaces_[i]);
426 lduAddressing(myMesh.lduAddr().size() + totalSize(otherMeshes)),
429 const label currentComm = myMesh.
comm();
433 if (otherMeshes[i].
comm() != currentComm)
436 <<
"Communicator " << otherMeshes[i].comm()
438 <<
" differs from that of predecessor "
444 const label nMeshes = otherMeshes.
size()+1;
448 if (lduPrimitiveMesh::debug)
451 <<
" agglomerating into " << myAgglom
452 <<
" as are " <<
findIndices(procAgglomMap, myAgglom)
459 if (procAgglomMap[procIDs[i]] != procAgglomMap[procIDs[0]])
462 <<
"Processor " << procIDs[i]
463 <<
" agglomerates to " << procAgglomMap[procIDs[i]]
464 <<
" whereas other processors " << procIDs
465 <<
" agglomerate to "
473 cellOffsets.
setSize(nMeshes+1);
475 for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
477 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
479 cellOffsets[procMeshI+1] =
480 cellOffsets[procMeshI]
486 labelList internalFaceOffsets(nMeshes+1);
487 internalFaceOffsets[0] = 0;
488 for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
490 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
492 internalFaceOffsets[procMeshI+1] =
493 internalFaceOffsets[procMeshI]
511 boundaryFaceMap.
setSize(nMeshes);
514 label nOtherInterfaces = 0;
517 for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
533 if (isA<processorLduInterface>(ldui))
536 refCast<const processorLduInterface>(ldui);
538 label agglom0 = procAgglomMap[pldui.
myProcNo()];
541 const edge procEdge(agglom0, agglom1);
543 if (agglom0 != myAgglom && agglom1 != myAgglom)
546 <<
"At mesh from processor " << procIDs[procMeshI]
547 <<
" have interface " << intI
548 <<
" with myProcNo:" << pldui.
myProcNo()
552 else if (agglom0 == myAgglom && agglom1 == myAgglom)
557 Pout<<
"merged interface: myProcNo:"
564 const label nbrProcMeshI =
567 if (procMeshI < nbrProcMeshI)
573 mergedMap(procEdge).append
582 Pout<<
"external interface: myProcNo:"
589 unmergedMap(procEdge).append
599 <<
"At mesh from processor " << procIDs[procMeshI]
600 <<
" have interface " << intI
601 <<
" of unhandled type " <<
interfaces[intI].type()
614 Pout<<
"Remaining interfaces:" <<
endl;
617 Pout<<
" agglom procEdge:" << iter.key() <<
endl;
621 label procMeshI = elems[i][0];
622 label interfacei = elems[i][1];
627 refCast<const processorLduInterface>
632 Pout<<
" proc:" << procIDs[procMeshI]
633 <<
" interfacei:" << interfacei
643 Pout<<
"Merged interfaces:" <<
endl;
646 Pout<<
" agglom procEdge:" << iter.key() <<
endl;
651 label procMeshI = elems[i][0];
652 label interfacei = elems[i][1];
656 refCast<const processorLduInterface>
661 Pout<<
" proc:" << procIDs[procMeshI]
662 <<
" interfacei:" << interfacei
673 faceOffsets.
setSize(nMeshes+1);
676 for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
678 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
681 faceOffsets[procMeshI+1] =
682 faceOffsets[procMeshI]
684 + nCoupledFaces[procMeshI];
690 map[i] = faceOffsets[procMeshI] + i;
703 for (label procMeshI = 0; procMeshI < nMeshes; ++procMeshI)
705 const lduMesh& procMesh =
mesh(myMesh, otherMeshes, procMeshI);
711 label allFacei = faceOffsets[procMeshI];
715 lowerAddr_[allFacei] = cellOffsets[procMeshI]+l[facei];
716 upperAddr_[allFacei] = cellOffsets[procMeshI]+u[facei];
730 if (isA<processorLduInterface>(ldui))
733 refCast<const processorLduInterface>(ldui);
738 label nbrProcMeshI = procIDs.
find(nbrP);
740 if (procMeshI < nbrProcMeshI)
745 const label agglom0 = procAgglomMap[myP];
746 const label agglom1 = procAgglomMap[nbrP];
759 label proci = elems[i][0];
760 label interfacei = elems[i][1];
769 refCast<const processorLduInterface>
776 elems[i][0] == nbrProcMeshI
780 nbrIntI = elems[i][1];
804 nbrInterfaces[nbrIntI].faceCells();
810 <<
" nbrFaceCells:" << nbrFaceCells
816 boundaryFaceMap[procMeshI][intI];
818 boundaryFaceMap[nbrProcMeshI][nbrIntI];
825 lowerAddr_[allFacei] =
827 bfMap[pfI] = allFacei;
828 upperAddr_[allFacei] =
829 cellOffsets[nbrProcMeshI]+nbrFaceCells[pfI];
830 nbrBfMap[pfI] = (-allFacei-1);
860 map[i] = oldToNew[map[i]];
864 label allFacei = -map[i]-1;
865 map[i] = -oldToNew[allFacei]-1;
874 forAll(boundaryFaceMap, proci)
876 const labelList& bMap = boundaryMap[proci];
879 if (bMap[intI] == -1)
882 labelList& bfMap = boundaryFaceMap[proci][intI];
888 bfMap[i] = oldToNew[bfMap[i]];
892 label allFacei = -bfMap[i]-1;
893 bfMap[i] = (-oldToNew[allFacei]-1);
905 interfaces_.
setSize(unmergedMap.
size() + nOtherInterfaces);
906 primitiveInterfaces_.setSize(interfaces_.
size());
908 label allInterfacei = 0;
920 label procMeshI = elem[0];
921 label interfacei = elem[1];
930 refCast<const processorLduInterface>
938 min(myProcNo, nbrProcNo),
939 max(myProcNo, nbrProcNo)
951 label procMeshI = elem[0];
952 label interfacei = elem[1];
972 label procMeshI = elem[0];
973 label interfacei = elem[1];
981 boundaryMap[procMeshI][interfacei] = allInterfacei;
982 labelList& bfMap = boundaryFaceMap[procMeshI][interfacei];
989 allFaceCells[
n] = cellOffsets[procMeshI]+l[facei];
990 allFaceRestrictAddressing[
n] =
n;
999 label neighbProcNo = -1;
1003 if (iter.key()[0] == myAgglom)
1005 if (iter.key()[1] == myAgglom)
1008 <<
"problem procEdge:" << iter.key()
1012 neighbProcNo = iter.key()[1];
1016 if (iter.key()[1] != myAgglom)
1019 <<
"problem procEdge:" << iter.key()
1023 neighbProcNo = iter.key()[0];
1026 primitiveInterfaces_.set
1034 allFaceRestrictAddressing,
1042 interfaces_.
set(allInterfacei, &primitiveInterfaces_[allInterfacei]);
1046 Pout<<
"Created " << interfaces_[allInterfacei].type()
1047 <<
" interface at " << allInterfacei
1048 <<
" comm:" << comm_
1049 <<
" myProcNo:" << myAgglom
1050 <<
" neighbProcNo:" << neighbProcNo
1051 <<
" nFaces:" << allFaceCells.
size()
1060 patchSchedule_ = nonBlockingSchedule<processorGAMGInterface>(interfaces_);
1078 return (meshI == 0 ? myMesh : otherMeshes[meshI-1]);
1098 for (label i = 1; i < procIDs.
size(); ++i)
1115 boolList validInterface(fromSlave);
1134 forAll(validInterface, intI)
1136 if (validInterface[intI])
1138 word coupleType(fromSlave);
1147 otherMeshes[i-1].rawInterfaces(),
1154 otherMeshes[i-1].addInterfaces
1157 nonBlockingSchedule<processorGAMGInterface>
1173 validInterface[intI] = interfaces.
set(intI);
1186 << addressing.
size()
1193 if (interfaces.
set(intI))
label totalSize() const
The total addressed size.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void resize(const label len)
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
Abstract base class for GAMG agglomerated interfaces.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
label size() const noexcept
The number of elements in table.
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 setSize(const label n)
Alias for resize()
Output inter-processor communications stream.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
void setSize(const label newLen)
Same as resize()
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
T & first()
Return the first element of the list.
bool found(const T &val, label pos=0) const
True if the value if found in the list.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
T & last()
Return the last element of the list.
@ nonBlocking
"nonBlocking"
static int & msgType() noexcept
Message tag of standard messages.
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
static bool & parRun() noexcept
Test if this a parallel run.
const T * set(const label i) const
void setSize(const label n)
Alias for resize()
label size() const noexcept
The number of elements in the list.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Smooth ATC in cells next to a set of patches supplied by type.
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
virtual label comm() const
Return communicator used for parallel communication.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label localStart() const
My local start.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
virtual const lduSchedule & patchSchedule() const =0
Return patch field evaluation schedule.
virtual const labelUList & upperAddr() const =0
Return upper addressing.
label size() const
Return number of equations.
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 const lduAddressing & lduAddr() const =0
Return ldu addressing.
virtual lduInterfacePtrsList interfaces() const =0
Simplest concrete lduMesh that stores the addressing needed by lduMatrix.
static void checkUpperTriangular(const label size, const labelUList &l, const labelUList &u)
Check if in upper-triangular ordering.
static labelListList globalCellCells(const lduMesh &mesh, const globalIndex &globalNumbering)
Calculate global cell-cells.
void addInterfaces(lduInterfacePtrsList &interfaces, const lduSchedule &ps)
Add interfaces to a mesh constructed without.
PtrList< const lduInterface > & primitiveInterfaces()
Return a non-const list of primitive interfaces.
static labelList upperTriOrder(const label nCells, const labelUList &lower, const labelUList &upper)
Calculate upper-triangular order.
virtual label comm() const
Return communicator used for parallel communication.
virtual lduInterfacePtrsList interfaces() const
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>
procLess(const labelPairList &list)
bool operator()(const label a, const label b)
int myProcNo() const noexcept
Return processor number.
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 Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Pair< label > labelPair
A pair of labels.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
To & refCast(From &r)
Reference type cast template function.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
labelList findIndices(const ListType &input, typename ListType::const_reference val, label start=0)
Linear search to find all occurrences of given element.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UIndirectList< label > labelUIndList
UIndirectList of labels.
interfaceProperties interface(alpha1, U, thermo->transportPropertiesDict())
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.