47 newMeshPtr.
reset(
nullptr);
52 const label nOldPoints = oldAreaPatch.
nPoints();
53 const label nOldEdges = oldAreaPatch.
nEdges();
54 const label nOldFaces = oldAreaPatch.
nFaces();
75 faFaceMap.compactLocalData
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];
228 dstEdges.
last() = uniqFaceIndex.toGlobal(facei);
232 faFaceMap.reverseDistribute(nOldFaces, dstFaceEdgeIds);
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));
272 label nNonProcessor(0);
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();
347 for (
const faPatch& fap : oldBndMesh)
349 const auto* fapp = isA<processorFaPatch>(fap);
364 label edgeTuplei = 0;
366 for (
const label srcEdgei : fap.edgeLabels())
368 halfEdgeLookup[srcEdgei].add(edgeTuples[edgeTuplei]);
376 for (
auto& tuple : halfEdgeLookup)
400 forAll(halfEdgeLookup, srcEdgei)
402 const faceEdgeTuple& facePairings = halfEdgeLookup[srcEdgei];
406 for (
int sidei = 0; sidei < 2; ++sidei)
408 const label dstFacei = facePairings.getFace(sidei);
416 label proci = uniqFaceIndex.whichProcID(dstFacei);
417 dstProcs[sidei] = proci;
419 if (proci != -1 && dstProcs[0] != dstProcs[1])
426 auto& edgeSubMap = faEdgeMap.subMap();
427 auto& edgeCnstrMap = faEdgeMap.constructMap();
430 edgeCnstrMap.resize(nProcEdges.
size());
436 edgeSubMap[proci].resize(nProcEdges[proci], -1);
437 remoteEdges[proci].resize(nProcEdges[proci], -1);
446 forAll(halfEdgeLookup, srcEdgei)
448 const faceEdgeTuple& facePairings = halfEdgeLookup[srcEdgei];
452 for (
int sidei = 0; sidei < 2; ++sidei)
454 const label dstFacei = facePairings.getFace(sidei);
455 const label dstEdgei = facePairings.getEdge(sidei);
462 label proci = uniqFaceIndex.whichProcID(dstFacei);
463 dstProcs[sidei] = proci;
465 if (proci != -1 && dstProcs[0] != dstProcs[1])
467 edgeSubMap[proci][nProcEdges[proci]] = srcEdgei;
468 remoteEdges[proci][nProcEdges[proci]] = dstEdgei;
478 Pstream::exchange<labelList, label>
498 <<
"Originating faMesh has gaps in the edge addressing" 499 <<
" this is currently unsupported" 513 mapDistributeBase::distribute<faceEdgeTuple, faceEdgeTuple, identityOp>
517 faEdgeMap.constructSize(),
520 faEdgeMap.subHasFlip(),
522 faEdgeMap.constructMap(),
523 faEdgeMap.constructHasFlip(),
540 forAll(halfEdgeLookup, edgei)
542 const auto& tuple = halfEdgeLookup[edgei];
549 label patchi =
mag(target[1])-2;
550 ++nNonProcEdges(patchi);
552 else if (target[0] >= 0 && target[1] >= 0)
555 target[0] = uniqFaceIndex.whichProcID(target[0]);
556 target[1] = uniqFaceIndex.whichProcID(target[1]);
562 target[0] != target[1]
570 ++nProcEdges(target);
590 procPairToPatchId.set(twoProcs,
nPatches);
599 for (label patchi = 0; patchi < nNonProcessor; ++patchi)
613 label nLabels = nProcEdges.
lookup(twoProcs, 0);
631 for (
const label edgei : order)
633 const auto& tuple = halfEdgeLookup[edgei];
642 patchi =
mag(target[1])-2;
644 else if (target[0] >= 0 && target[1] >= 0)
647 target[0] = uniqFaceIndex.whichProcID(target[0]);
648 target[1] = uniqFaceIndex.whichProcID(target[1]);
654 target[0] != target[1]
662 patchi = procPairToPatchId.lookup(target, -1);
668 const label idx = nEdgeLabels[patchi]++;
669 newEdgeLabels[patchi][idx] = edgei;
677 for (label patchi = 0; patchi < nNonProcessor; ++patchi)
687 oldMesh.
boundary()[patchi].ngbPolyPatchIndex()
699 ? twoProcs[0] : twoProcs[1]
720 newMesh.addFaPatches(newFaPatches);
747 oldToNewSub[edgei] = nEdges++;
753 for (
const label edgei : fap.edgeLabels())
755 oldToNewSub[edgei] = nEdges++;
770 oldToNewConstruct[edgei] = nEdges++;
774 for (
const faPatch& fap : newMesh.boundary())
776 for (
const label edgei : fap.edgeLabels())
778 oldToNewConstruct[edgei] = nEdges++;
786 faEdgeMap.subHasFlip()
791 faEdgeMap.constructMap(),
793 faEdgeMap.constructHasFlip()
804 newMesh.boundary().size(),
820 faPatchMap.subMap().resize(nProcs,
identity(nNonProcessor));
821 faPatchMap.constructMap().resize(nProcs,
identity(nNonProcessor));
869 faPointMap.compactData
SubList< label > labelSubList
A SubList of labels.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
const T & first() const noexcept
Access the first element.
label nPoints() const
Number of points supporting patch faces.
void size(const label n)
Older name for setAddressableSize.
labelList findIndices(const ListType &input, const UnaryPredicate &pred, label start=0)
Linear search to find all occurences of given element.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A 1D vector of objects of type <T> with a fixed length <N>.
void resize(const label len)
Adjust allocated size of list.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
static label nRequests() noexcept
Number of outstanding requests (on the internal list of requests)
PtrList< T > clone(Args &&... args) const
Make a copy by cloning each of the list elements.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
label nInternalEdges() const
Number of internal edges.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
static int & msgType() noexcept
Message tag of standard messages.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
static const List< T > & null()
Return a null List.
List< labelList > labelListList
List of labelList.
const labelList & edgeLabels() const noexcept
Return the list of edges.
static void waitRequests()
Wait for all requests to finish.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
const uindirectPrimitivePatch & patch() const
Return constant reference to primitive patch.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
bool insert(const label &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
static label getEdge(List< DynamicList< label >> &pe, DynamicList< edge > &es, const label pointi, const label nextPointi)
A list of faces which address into the list of points.
label nOldPoints() const noexcept
Number of points in mesh before distribution.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
const mapDistribute & pointMap() const noexcept
Point distribute map.
AccessType combine(const UList< T > &lists, AccessOp aop=accessOp< T >())
Combines sub-lists into a single list.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
const labelList & faceLabels() const noexcept
Return the underlying polyMesh face labels.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
label nOldFaces() const noexcept
Number of faces in mesh before distribution.
bool hasInternalEdgeLabels() const noexcept
True if the internalEdges use an ordering that does not correspond 1-to-1 with the patch internalEdge...
Reading is optional [identical to LAZY_READ].
A HashTable similar to std::unordered_map.
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
A HashTable to objects of type <T> with a labelPair key. The hashing is based on labelPair (FixedList...
Class containing processor-to-processor mapping information.
label nEdges() const
Number of edges in patch.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
A functor that returns its argument unchanged (cf. C++20 std::identity) Should never be specialized...
Pair< label > labelPair
A pair of labels.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
const polyMesh & mesh() const
Return access to polyMesh.
const faBoundaryMesh & boundary() const noexcept
Return constant reference to boundary mesh.
T & last()
Access last element of the list, position [size()-1].
void resize(const label newLen)
Adjust size of PtrList.
Class containing processor-to-processor mapping information.
const T & lookup(const Key &key, const T &deflt) const
Return hashed entry if it exists, or return the given default.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
Finite area boundary mesh.
"nonBlocking" : (MPI_Isend, MPI_Irecv)
const labelListList & faceEdges() const
Return face-edge addressing.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
const T & second() const noexcept
Access the second element.
label nFaces() const noexcept
Number of faces in the patch.
Defines the attributes of an object for which implicit objectRegistry management is supported...
labelList patchStarts() const
Return a list of patch start indices.
const mapDistribute & faceMap() const noexcept
Face distribute map.
static mapDistributePolyMesh distribute(const faMesh &oldMesh, const mapDistributePolyMesh &distMap, const polyMesh &tgtPolyMesh, autoPtr< faMesh > &newMeshPtr)
Distribute mesh according to the given (volume) mesh distribution.
static label renumberMap(labelListList &mapElements, const labelUList &oldToNew, const bool hasFlip)
Helper for renumbering the (compacted) map elements using the supplied old-to-new mapping...
A HashTable to objects of type <T> with a label key.
static constexpr const zero Zero
Global zero (0)