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);
166 subFaces.
append(mesh.
faces()[facei].reverseFace());
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)
191 subFaces.
append(mesh.
faces()[facei].reverseFace());
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(),
625 localMeshPtr().boundaryMesh(),
628 localMeshPtr().addPatches(
patches);
631 (void) localMeshPtr().tetBasePtIs();
633 return localProcCells;
640 boolList oldLocalTgtCellIsUsed(localTgtProcCellsPtr_().size(),
false);
641 forAll(srcLocalTgtCells_, srcCelli)
643 forAll(srcLocalTgtCells_[srcCelli], i)
645 oldLocalTgtCellIsUsed[srcLocalTgtCells_[srcCelli][i]] =
true;
650 labelList oldToNewLocalTgtCell, newToOldLocalTgtCell;
653 oldLocalTgtCellIsUsed,
655 oldToNewLocalTgtCell,
661 Pout<<
"Trim from " << oldToNewLocalTgtCell.
size() <<
" to "
662 << newToOldLocalTgtCell.
size() <<
" cells" <<
endl;
666 forAll(srcLocalTgtCells_, srcCelli)
668 forAll(srcLocalTgtCells_[srcCelli], i)
670 srcLocalTgtCells_[srcCelli][i] =
671 oldToNewLocalTgtCell[srcLocalTgtCells_[srcCelli][i]];
678 localTgtProcCellsPtr_() =
679 List<remote>(localTgtProcCellsPtr_(), newToOldLocalTgtCell);
685 const polyMesh& oldLocalTgtMesh = localTgtMeshPtr_();
688 labelList oldLocalTgtFaceNeighbour(oldLocalTgtFaceOwner.
size(), -1);
698 label iEnd = newToOldLocalTgtFace.
size();
702 label& oldLocalTgtFacei0 = newToOldLocalTgtFace[i0];
703 label& oldLocalTgtFacei1 = newToOldLocalTgtFace[i1 - 1];
704 label& oldLocalTgtFaceiEnd = newToOldLocalTgtFace[iEnd - 1];
706 const label newLocalTgtOwni0 =
707 oldLocalTgtFaceOwner[oldLocalTgtFacei0] != -1
708 ? oldToNewLocalTgtCell
709 [oldLocalTgtFaceOwner[oldLocalTgtFacei0]]
711 const label newLocalTgtOwni1 =
712 oldLocalTgtFaceOwner[oldLocalTgtFacei1] != -1
713 ? oldToNewLocalTgtCell
714 [oldLocalTgtFaceOwner[oldLocalTgtFacei1]]
717 const label newLocalTgtNbri0 =
718 oldLocalTgtFaceNeighbour[oldLocalTgtFacei0] != -1
719 ? oldToNewLocalTgtCell
720 [oldLocalTgtFaceNeighbour[oldLocalTgtFacei0]]
722 const label newLocalTgtNbri1 =
723 oldLocalTgtFaceNeighbour[oldLocalTgtFacei1] != -1
724 ? oldToNewLocalTgtCell
725 [oldLocalTgtFaceNeighbour[oldLocalTgtFacei1]]
729 newLocalTgtOwni0 != -1 || newLocalTgtNbri0 != -1;
731 newLocalTgtOwni1 != -1 || newLocalTgtNbri1 != -1;
733 const bool internal0 =
734 newLocalTgtOwni0 != -1 && newLocalTgtNbri0 != -1;
735 const bool internal1 =
736 newLocalTgtOwni1 != -1 && newLocalTgtNbri1 != -1;
741 Swap(oldLocalTgtFacei0, oldLocalTgtFaceiEnd);
742 if (i1 == iEnd) i1 --;
749 Swap(oldLocalTgtFacei1, oldLocalTgtFaceiEnd);
750 if (i1 == iEnd) i1 --;
756 else if (internal0 && internal1)
763 else if (!internal0 && !internal1)
770 else if (internal0 && !internal1)
778 else if (!internal0 && internal1)
780 Swap(oldLocalTgtFacei0, oldLocalTgtFacei1);
786 newToOldLocalTgtFace.
resize(iEnd);
788 oldToNewLocalTgtFace =
794 Pout<<
"Trim from " << oldToNewLocalTgtFace.
size() <<
" to "
795 << newToOldLocalTgtFace.
size() <<
" faces" <<
endl;
800 faceList newLocalTgtFaces(oldLocalTgtMesh.
faces(), newToOldLocalTgtFace);
803 oldLocalTgtFaceOwner,
804 static_cast<const labelUList&
>(newToOldLocalTgtFace)
809 oldLocalTgtFaceNeighbour,
810 static_cast<const labelUList&
>(newToOldLocalTgtFace)
817 label newLocalTgtNInternalFaces = 0;
818 bool internal0 =
true;
820 forAll(newLocalTgtFaces, newLocalTgtFacei)
822 face& newLocalTgtF = newLocalTgtFaces[newLocalTgtFacei];
823 label& newLocalTgtOwni = newLocalTgtFaceOwner[newLocalTgtFacei];
824 label& newLocalTgtNbri = newLocalTgtFaceNeighbour[newLocalTgtFacei];
827 const bool internal =
828 newLocalTgtOwni != -1 && newLocalTgtNbri != -1;
829 if (internal0 && !
internal)
831 newLocalTgtNInternalFaces = newLocalTgtFacei;
834 if (!internal0 &&
internal)
837 <<
"Trimmed mesh has boundary faces before internal faces"
843 newLocalTgtOwni == -1 && newLocalTgtNbri != -1;
847 Swap(newLocalTgtOwni, newLocalTgtNbri);
851 newLocalTgtFaceNeighbour.
resize(newLocalTgtNInternalFaces);
855 localTgtMeshPtr_.reset
863 oldLocalTgtMesh.
time(),
866 move(newLocalTgtPoints),
867 move(newLocalTgtFaces),
868 move(newLocalTgtFaceOwner),
869 move(newLocalTgtFaceNeighbour),
879 localTgtMeshPtr_().nFaces() - localTgtMeshPtr_().nInternalFaces(),
880 localTgtMeshPtr_().nInternalFaces(),
882 localTgtMeshPtr_().boundaryMesh(),
885 localTgtMeshPtr_().addPatches(
patches);
888 (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 time.
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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.
static const word null
An empty word.
#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)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< labelList > labelListList
A List of labelList.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
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)