41 template<
class ListType>
90 if (procBb[proci].overlaps(cellBb))
92 resultDyn[proci].
append(tgtCelli);
101 result[proci].
transfer(resultDyn[proci]);
129 if (sendElems.
size())
133 forAll(sendElems, subCelli)
135 reverseCellMap[sendElems[subCelli]] = subCelli;
150 const label subOwn = reverseCellMap[own];
151 const label subNbr = reverseCellMap[nbr];
153 if (subOwn != -1 && subNbr != -1)
160 subFaceOwner.
append(subOwn);
161 subFaceNeighbour.
append(subNbr);
167 subFaceOwner.
append(subNbr);
168 subFaceNeighbour.
append(subOwn);
179 const label subOwn = reverseCellMap[own];
180 const label subNbr = reverseCellMap[nbr];
182 if (subOwn != -1 && subNbr == -1)
185 subFaceOwner.
append(subOwn);
186 subFaceNeighbour.
append(subNbr);
189 else if (subOwn == -1 && subNbr != -1)
192 subFaceOwner.
append(subNbr);
193 subFaceNeighbour.
append(subOwn);
203 const label nbrProci =
204 isType<processorPolyPatch>(pp)
205 ? refCast<const processorPolyPatch>(pp).neighbProcNo()
213 if (reverseCellMap[own] != -1)
216 subFaceOwner.
append(reverseCellMap[own]);
217 subFaceNeighbour.
append(-1);
218 subProcProcessorPatchFaces.
append
229 forAll(subFaces, subFacei)
231 face&
f = subFaces[subFacei];
235 if (reversePointMap[pointi] == -1)
237 reversePointMap[pointi] = subPoints.
size();
241 f[fp] = reversePointMap[pointi];
263 subProcProcessorPatchFaces;
277 << subProcProcessorPatchFaces;
294 str >> allPoints[domain]
295 >> allNInternalFaces[domain]
297 >> allFaceOwners[domain]
298 >> allFaceNeighbours[domain]
299 >> allProcCells[domain]
300 >> allProcProcessorPatchFaces[domain];
325 labelList allNIntCoupledFaces(allNInternalFaces);
339 procCoupleInfo procFaceToGlobalCell;
340 forAll(allProcProcessorPatchFaces, proci)
343 allProcProcessorPatchFaces[proci];
345 forAll(procProcessorPatchFaces, i)
347 if (procProcessorPatchFaces[i] !=
remote())
351 min(proci, procProcessorPatchFaces[i].proci),
352 max(proci, procProcessorPatchFaces[i].proci),
353 procProcessorPatchFaces[i].elementi
356 procCoupleInfo::const_iterator fnd =
357 procFaceToGlobalCell.find(key);
359 if (fnd == procFaceToGlobalCell.end())
361 procFaceToGlobalCell.insert(key, -1);
367 Pout<<
"Additional internal face between procs:"
368 << key[0] <<
" and " << key[1]
369 <<
" across local face " << key[2] <<
endl;
372 allNIntCoupledFaces[proci]++;
380 label nFacesTotal = 0;
382 forAll(allNIntCoupledFaces, proci)
384 label nCoupledFaces =
385 allNIntCoupledFaces[proci] - allNInternalFaces[proci];
387 internalFaceOffset[proci] = nIntFaces;
388 nIntFaces += allNIntCoupledFaces[proci];
389 nFacesTotal += allFaceOwners[proci].
size() - nCoupledFaces;
395 forAll(allProcCells, proci)
397 cellOffset[proci] = nCells;
398 nCells += allProcCells[proci].
size();
406 labelList localFaceNeighbours(nFacesTotal);
409 forAll(allProcCells, proci)
426 const faceList& fcs = allFaces[proci];
427 const labelList& faceOs = allFaceOwners[proci];
428 const labelList& faceNs = allFaceNeighbours[proci];
433 allNInternalFaces[proci],
434 internalFaceOffset[proci]
437 offset(slice, pointOffset[proci]);
442 allNInternalFaces[proci],
443 internalFaceOffset[proci]
446 offset(ownSlice, cellOffset[proci]);
451 allNInternalFaces[proci],
452 internalFaceOffset[proci]
455 offset(nbrSlice, cellOffset[proci]);
457 internalFaceOffset[proci] += allNInternalFaces[proci];
461 forAll(allProcProcessorPatchFaces, proci)
464 allProcProcessorPatchFaces[proci];
465 const labelList& faceOs = allFaceOwners[proci];
466 const faceList& fcs = allFaces[proci];
468 forAll(procProcessorPatchFaces, i)
470 if (procProcessorPatchFaces[i] !=
remote())
474 min(proci, procProcessorPatchFaces[i].proci),
475 max(proci, procProcessorPatchFaces[i].proci),
476 procProcessorPatchFaces[i].elementi
479 procCoupleInfo::iterator fnd = procFaceToGlobalCell.find(key);
481 if (fnd != procFaceToGlobalCell.end())
486 fnd() = cellOffset[proci] + faceOs[i];
491 const label newOwn = cellOffset[proci] + faceOs[i];
492 const label newNbr = fnd();
493 const label localFacei = internalFaceOffset[proci]++;
497 Pout<<
" proc " << proci
498 <<
"\tinserting face:" << localFacei
499 <<
" connection between owner " << newOwn
500 <<
" and neighbour " << newNbr
507 localFaces[localFacei] = fcs[i];
508 localFaceOwners[localFacei] = newOwn;
509 localFaceNeighbours[localFacei] = newNbr;
514 localFaces[localFacei] = fcs[i].reverseFace();
515 localFaceOwners[localFacei] = newNbr;
516 localFaceNeighbours[localFacei] = newOwn;
519 offset(localFaces[localFacei], pointOffset[proci]);
529 forAll(allProcProcessorPatchFaces, proci)
532 allProcProcessorPatchFaces[proci];
533 const labelList& faceOs = allFaceOwners[proci];
534 const labelList& faceNs = allFaceNeighbours[proci];
535 const faceList& fcs = allFaces[proci];
537 forAll(procProcessorPatchFaces, i)
540 if (procProcessorPatchFaces[i] !=
remote())
544 min(proci, procProcessorPatchFaces[i].proci),
545 max(proci, procProcessorPatchFaces[i].proci),
546 procProcessorPatchFaces[i].elementi
549 if (procFaceToGlobalCell[key] == -1)
552 <<
"Unvisited " << key
555 else if (procFaceToGlobalCell[key] != -2)
557 const label newOwn = cellOffset[proci] + faceOs[i];
558 const label localFacei = nIntFaces++;
562 Pout<<
" proc " << proci
563 <<
"\tinserting boundary face:" << localFacei
564 <<
" from coupled face " << key
568 localFaces[localFacei] = fcs[i];
569 offset(localFaces[localFacei], pointOffset[proci]);
571 localFaceOwners[localFacei] = newOwn;
572 localFaceNeighbours[localFacei] = -1;
579 const label own = faceOs[i];
580 const label nbr = faceNs[i];
582 if ((own != -1) && (nbr == -1))
584 const label newOwn = cellOffset[proci] + faceOs[i];
585 const label localFacei = nIntFaces++;
587 localFaces[localFacei] = fcs[i];
588 offset(localFaces[localFacei], pointOffset[proci]);
590 localFaceOwners[localFacei] = newOwn;
591 localFaceNeighbours[localFacei] = -1;
611 move(localFaceOwners),
612 move(localFaceNeighbours),
622 localMeshPtr().nFaces() - localMeshPtr().nInternalFaces(),
623 localMeshPtr().nInternalFaces(),
627 localMeshPtr().addPatches(
patches);
630 (void) localMeshPtr().tetBasePtIs();
632 return localProcCells;
639 boolList oldLocalTgtCellIsUsed(localTgtProcCellsPtr_().size(),
false);
640 forAll(srcLocalTgtCells_, srcCelli)
642 forAll(srcLocalTgtCells_[srcCelli], i)
644 oldLocalTgtCellIsUsed[srcLocalTgtCells_[srcCelli][i]] =
true;
649 labelList oldToNewLocalTgtCell, newToOldLocalTgtCell;
652 oldLocalTgtCellIsUsed,
654 oldToNewLocalTgtCell,
660 Pout<<
"Trim from " << oldToNewLocalTgtCell.
size() <<
" to "
661 << newToOldLocalTgtCell.
size() <<
" cells" <<
endl;
665 forAll(srcLocalTgtCells_, srcCelli)
667 forAll(srcLocalTgtCells_[srcCelli], i)
669 srcLocalTgtCells_[srcCelli][i] =
670 oldToNewLocalTgtCell[srcLocalTgtCells_[srcCelli][i]];
677 localTgtProcCellsPtr_() =
678 List<remote>(localTgtProcCellsPtr_(), newToOldLocalTgtCell);
684 const polyMesh& oldLocalTgtMesh = localTgtMeshPtr_();
687 labelList oldLocalTgtFaceNeighbour(oldLocalTgtFaceOwner.
size(), -1);
697 label iEnd = newToOldLocalTgtFace.
size();
701 label& oldLocalTgtFacei0 = newToOldLocalTgtFace[i0];
702 label& oldLocalTgtFacei1 = newToOldLocalTgtFace[i1 - 1];
703 label& oldLocalTgtFaceiEnd = newToOldLocalTgtFace[iEnd - 1];
705 const label newLocalTgtOwni0 =
706 oldLocalTgtFaceOwner[oldLocalTgtFacei0] != -1
707 ? oldToNewLocalTgtCell
708 [oldLocalTgtFaceOwner[oldLocalTgtFacei0]]
710 const label newLocalTgtOwni1 =
711 oldLocalTgtFaceOwner[oldLocalTgtFacei1] != -1
712 ? oldToNewLocalTgtCell
713 [oldLocalTgtFaceOwner[oldLocalTgtFacei1]]
716 const label newLocalTgtNbri0 =
717 oldLocalTgtFaceNeighbour[oldLocalTgtFacei0] != -1
718 ? oldToNewLocalTgtCell
719 [oldLocalTgtFaceNeighbour[oldLocalTgtFacei0]]
721 const label newLocalTgtNbri1 =
722 oldLocalTgtFaceNeighbour[oldLocalTgtFacei1] != -1
723 ? oldToNewLocalTgtCell
724 [oldLocalTgtFaceNeighbour[oldLocalTgtFacei1]]
728 newLocalTgtOwni0 != -1 || newLocalTgtNbri0 != -1;
730 newLocalTgtOwni1 != -1 || newLocalTgtNbri1 != -1;
732 const bool internal0 =
733 newLocalTgtOwni0 != -1 && newLocalTgtNbri0 != -1;
734 const bool internal1 =
735 newLocalTgtOwni1 != -1 && newLocalTgtNbri1 != -1;
740 Swap(oldLocalTgtFacei0, oldLocalTgtFaceiEnd);
741 if (i1 == iEnd) i1 --;
748 Swap(oldLocalTgtFacei1, oldLocalTgtFaceiEnd);
749 if (i1 == iEnd) i1 --;
755 else if (internal0 && internal1)
762 else if (!internal0 && !internal1)
769 else if (internal0 && !internal1)
777 else if (!internal0 && internal1)
779 Swap(oldLocalTgtFacei0, oldLocalTgtFacei1);
785 newToOldLocalTgtFace.
resize(iEnd);
787 oldToNewLocalTgtFace =
793 Pout<<
"Trim from " << oldToNewLocalTgtFace.
size() <<
" to "
794 << newToOldLocalTgtFace.
size() <<
" faces" <<
endl;
799 faceList newLocalTgtFaces(oldLocalTgtMesh.
faces(), newToOldLocalTgtFace);
802 oldLocalTgtFaceOwner,
803 static_cast<const labelUList&
>(newToOldLocalTgtFace)
808 oldLocalTgtFaceNeighbour,
809 static_cast<const labelUList&
>(newToOldLocalTgtFace)
816 label newLocalTgtNInternalFaces = 0;
817 bool internal0 =
true;
819 forAll(newLocalTgtFaces, newLocalTgtFacei)
821 face& newLocalTgtF = newLocalTgtFaces[newLocalTgtFacei];
822 label& newLocalTgtOwni = newLocalTgtFaceOwner[newLocalTgtFacei];
823 label& newLocalTgtNbri = newLocalTgtFaceNeighbour[newLocalTgtFacei];
826 const bool internal =
827 newLocalTgtOwni != -1 && newLocalTgtNbri != -1;
828 if (internal0 && !
internal)
830 newLocalTgtNInternalFaces = newLocalTgtFacei;
833 if (!internal0 &&
internal)
836 <<
"Trimmed mesh has boundary faces before internal faces"
842 newLocalTgtOwni == -1 && newLocalTgtNbri != -1;
846 Swap(newLocalTgtOwni, newLocalTgtNbri);
850 newLocalTgtFaceNeighbour.
resize(newLocalTgtNInternalFaces);
854 localTgtMeshPtr_.reset
862 oldLocalTgtMesh.
time(),
865 move(newLocalTgtPoints),
866 move(newLocalTgtFaces),
867 move(newLocalTgtFaceOwner),
868 move(newLocalTgtFaceNeighbour),
878 localTgtMeshPtr_().nFaces() - localTgtMeshPtr_().nInternalFaces(),
879 localTgtMeshPtr_().nInternalFaces(),
883 localTgtMeshPtr_().addPatches(
patches);
886 (void) localTgtMeshPtr_().tetBasePtIs();
#define forAll(list, i)
Loop across all elements in list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
An STL-conforming hash table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const word & name() const
Return name.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void append(const T &)
Append an element at the end of the list.
void resize(const label)
Alias for setSize(const label)
void size(const label)
Override size to be inconsistent with allocated storage.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
static void scatterList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Scatter data. Reverse of gatherList.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
Pre-declare related SubField type.
A List obtained as a section of another List.
Input inter-processor communications stream operating on external buffer.
Output inter-processor communications stream operating on external buffer.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
A bounding box defined in terms of the points at its extremities.
labelListList tgtMeshSendCells(const polyMesh &srcMesh, const polyMesh &tgtMesh) const
Determine which target cells need to be sent to the source.
void trimLocalTgt()
Trim the local target addressing and mesh so that communication.
static List< remote > distributeMesh(const distributionMap &map, const polyMesh &mesh, autoPtr< polyMesh > &localMeshPtr)
Distribute a mesh given its distribution map.
const word & name() const
Return const reference to name.
const labelListList & constructMap() const
From subsetted data to new reconstructed data.
const labelListList & subMap() const
From subsetted data back to original data.
Class containing processor-to-processor mapping information.
A face is a list of labels corresponding to mesh vertices.
face reverseFace() const
Return face with reverse direction.
const Time & time() const
Return the top-level database.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
const word & name() const
Return reference to name.
const Time & time() const
Return time.
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
label nInternalFaces() const
const cellList & cells() const
Struct for keeping processor, element (cell, face, point) index.
word capitalise() const
Return the word with the first letter capitalised.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
List< scalarList > scalarListList
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
errorManip< error > abort(error &err)
List< labelList > labelListList
A List of labelList.
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
prefixOSstream Pout(cout, "Pout")
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void offset(label &lst, const label o)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
faceListList boundary(nPatches)