47 newMeshPtr.
reset(
nullptr);
52 const label nOldPoints = oldAreaPatch.
nPoints();
53 const label nOldEdges = oldAreaPatch.
nEdges();
54 const label nOldFaces = oldAreaPatch.
nFaces();
102 new faMesh(tgtPolyMesh, std::move(newFaceLabels),
io)
109 auto& newMesh = newMeshPtr();
121 struct faceEdgeTuple :
public FixedList<label, 4>
132 return (face0() < 0 && face1() < 0);
136 label face0()
const {
return (*
this)[0]; }
137 label face1()
const {
return (*
this)[1]; }
140 label edge0()
const {
return (*
this)[2]; }
141 label edge1()
const {
return (*
this)[3]; }
143 label getFace(
int i)
const {
return (*
this)[(i ? 1 : 0)]; }
144 label getEdge(
int i)
const {
return (*
this)[(i ? 3 : 2)]; }
153 if (face1() >= 0 && face0() >= face1())
155 std::swap((*
this)[0], (*
this)[1]);
156 std::swap((*
this)[2], (*
this)[3]);
165 (*this)[0] = faceEdge.
first();
166 (*this)[2] = faceEdge.
second();
168 else if ((*
this)[1] < 0)
170 (*this)[1] = faceEdge.
first();
171 (*this)[3] = faceEdge.
second();
176 void combine(
const faceEdgeTuple&
y)
180 if (
y.empty() ||
x ==
y)
191 <<
"Unexpected edge matching: "
192 <<
x <<
" vs. " <<
y <<
endl
198 void operator()(faceEdgeTuple&
x,
const faceEdgeTuple&
y)
const
220 labelList& dstEdges = dstFaceEdgeIds[facei];
250 const labelList& dstFaceEdges = dstFaceEdgeIds[facei];
253 const label uniqFacei = dstFaceEdges.
last();
257 const label srcEdgei = fEdges[faceEdgei];
258 const label dstEdgei = dstFaceEdges[faceEdgei];
260 halfEdgeLookup[srcEdgei].add(
labelPair(uniqFacei, dstEdgei));
276 forAll(oldBndMesh, patchi)
278 const faPatch& fap = oldBndMesh[patchi];
279 if (isA<processorFaPatch>(fap))
286 const labelPair encodedPatchId(-(patchi+2), -(patchi+2));
290 faceEdgeTuple& facePairings = halfEdgeLookup[srcEdgei];
292 facePairings.add(encodedPatchId);
294 label dstFacei = facePairings.face0();
296 label proci = uniqFaceIndex.whichProcID(dstFacei);
298 patchMapInfo(proci).
insert(patchi);
313 for (
const faPatch& fap : oldBndMesh)
315 const auto* fapp = isA<processorFaPatch>(fap);
326 label edgeTuplei = 0;
328 for (
const label edgei : fap.edgeLabels())
330 edgeTuples[edgeTuplei] = halfEdgeLookup[edgei].getPair0();
346 for (
const faPatch& fap : oldBndMesh)
348 const auto* fapp = isA<processorFaPatch>(fap);
363 label edgeTuplei = 0;
365 for (
const label srcEdgei : fap.edgeLabels())
367 halfEdgeLookup[srcEdgei].add(edgeTuples[edgeTuplei]);
375 for (
auto& tuple : halfEdgeLookup)
399 forAll(halfEdgeLookup, srcEdgei)
401 const faceEdgeTuple& facePairings = halfEdgeLookup[srcEdgei];
405 for (
int sidei = 0; sidei < 2; ++sidei)
407 const label dstFacei = facePairings.getFace(sidei);
415 label proci = uniqFaceIndex.whichProcID(dstFacei);
416 dstProcs[sidei] = proci;
418 if (proci != -1 && dstProcs[0] != dstProcs[1])
425 auto& edgeSubMap = faEdgeMap.
subMap();
435 edgeSubMap[proci].resize(
nProcEdges[proci], -1);
445 forAll(halfEdgeLookup, srcEdgei)
447 const faceEdgeTuple& facePairings = halfEdgeLookup[srcEdgei];
451 for (
int sidei = 0; sidei < 2; ++sidei)
453 const label dstFacei = facePairings.getFace(sidei);
454 const label dstEdgei = facePairings.getEdge(sidei);
461 label proci = uniqFaceIndex.whichProcID(dstFacei);
462 dstProcs[sidei] = proci;
464 if (proci != -1 && dstProcs[0] != dstProcs[1])
466 edgeSubMap[proci][
nProcEdges[proci]] = srcEdgei;
467 remoteEdges[proci][
nProcEdges[proci]] = dstEdgei;
477 Pstream::exchange<labelList, label>
497 <<
"Originating faMesh has gaps in the edge addressing"
498 <<
" this is currently unsupported"
512 mapDistributeBase::distribute<faceEdgeTuple, faceEdgeTuple, identityOp>
539 forAll(halfEdgeLookup, edgei)
541 const auto& tuple = halfEdgeLookup[edgei];
548 label patchi =
mag(target[1])-2;
549 ++nNonProcEdges(patchi);
551 else if (target[0] >= 0 && target[1] >= 0)
554 target[0] = uniqFaceIndex.whichProcID(target[0]);
555 target[1] = uniqFaceIndex.whichProcID(target[1]);
561 target[0] != target[1]
612 label nLabels =
nProcEdges.lookup(twoProcs, 0);
630 for (
const label edgei : order)
632 const auto& tuple = halfEdgeLookup[edgei];
641 patchi =
mag(target[1])-2;
643 else if (target[0] >= 0 && target[1] >= 0)
646 target[0] = uniqFaceIndex.whichProcID(target[0]);
647 target[1] = uniqFaceIndex.whichProcID(target[1]);
653 target[0] != target[1]
661 patchi = procPairToPatchId.
lookup(target, -1);
667 const label idx = nEdgeLabels[patchi]++;
668 newEdgeLabels[patchi][idx] = edgei;
686 oldMesh.
boundary()[patchi].ngbPolyPatchIndex()
698 ? twoProcs[0] : twoProcs[1]
719 newMesh.addFaPatches(newFaPatches);
746 oldToNewSub[edgei] =
nEdges++;
752 for (
const label edgei : fap.edgeLabels())
754 oldToNewSub[edgei] =
nEdges++;
769 oldToNewConstruct[edgei] =
nEdges++;
773 for (
const faPatch& fap : newMesh.boundary())
775 for (
const label edgei : fap.edgeLabels())
777 oldToNewConstruct[edgei] =
nEdges++;
803 newMesh.boundary().size(),
868 faPointMap.compactData
906 return faMeshDistributor::distribute
Various functions to operate on Lists.
A 1D vector of objects of type <T> with a fixed length <N>.
T & first() noexcept
The first element of the list, position [0].
A HashTable similar to std::unordered_map.
bool set(const Key &key, const T &obj)
Copy assign a new entry, overwriting existing entries.
const T & lookup(const Key &key, const T &deflt) const
Return hashed entry if it exists, or return the given default.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
readOption readOpt() const noexcept
The read option.
void resize(const label len)
Adjust allocated size of list.
A HashTable to objects of type <T> with a label key.
const T & second() const noexcept
Return second element, which is also the last element.
A list of faces which address into the list of points.
label nEdges() const
Number of edges in patch.
label nPoints() const
Number of points supporting patch faces.
label nFaces() const noexcept
Number of faces in the patch.
label nInternalEdges() const
Number of internal edges.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const labelListList & faceEdges() const
Return face-edge addressing.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
void resize(const label newLen)
Adjust size of PtrList.
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 label nRequests()
Get number of outstanding requests.
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.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Finite area boundary mesh.
labelList patchStarts() const
Return a list of patch start indices.
static mapDistributePolyMesh distribute(const faMesh &oldMesh, const mapDistributePolyMesh &distMap, const polyMesh &tgtPolyMesh, autoPtr< faMesh > &newMeshPtr)
Distribute mesh according to the given (volume) mesh distribution.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
bool hasInternalEdgeLabels() const noexcept
const faBoundaryMesh & boundary() const noexcept
Return constant reference to boundary mesh.
const polyMesh & mesh() const
Return access to polyMesh.
const uindirectPrimitivePatch & patch() const
Return constant reference to primitive patch.
const labelList & faceLabels() const noexcept
Return the underlying polyMesh face labels.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
const labelList & edgeLabels() const noexcept
Return the list of edges.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label toGlobal(const label i) const
From local to global index.
Class containing processor-to-processor mapping information.
static label renumberMap(labelListList &mapElements, const labelUList &oldToNew, const bool hasFlip)
const labelListList & constructMap() const noexcept
From subsetted data to new reconstructed data.
void reverseDistribute(const label constructSize, List< T > &values, const int tag=UPstream::msgType()) const
bool constructHasFlip() const noexcept
Does constructMap include a sign.
const labelListList & subMap() const noexcept
From subsetted data back to original data.
bool subHasFlip() const noexcept
Does subMap include a sign.
label comm() const noexcept
The communicator used.
label constructSize() const noexcept
Constructed data size.
void compactLocalData(const bitSet &allowedLocalElems, const int tag=UPstream::msgType(), const bool doRenumber=false)
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
label nOldFaces() const noexcept
Number of faces in mesh before distribution.
const mapDistribute & pointMap() const noexcept
Point distribute map.
const mapDistribute & faceMap() const noexcept
Face distribute map.
label nOldPoints() const noexcept
Number of points in mesh before distribution.
Class containing processor-to-processor mapping information.
Mesh consisting of general polyhedral cells.
int myProcNo() const noexcept
Return processor number.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const label nNonProcessor
const labelList nProcEdges(UPstream::listGatherValues< label >(nLocalProcEdges))
const labelList nEdges(UPstream::listGatherValues< label >(aMesh.nEdges()))
A HashTable to objects of type <T> with a labelPair key. The hashing is based on labelPair (FixedList...
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
labelList findIndices(const ListType &input, const UnaryPredicate &pred, label start=0)
Linear search to find all occurences of given element.
Pair< label > labelPair
A pair of labels.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< labelList > labelListList
A List of labelList.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
SubList< label > labelSubList
A SubList of labels.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dict add("bounds", meshBb)
#define forAll(list, i)
Loop across all elements in list.
Unary predicate for greater-equal 0 (int values)