42 void Foam::faMeshReconstructor::calcAddressing
47 const globalIndex globalFaceNum(procMesh_.
nFaces());
66 faBoundaryProcAddr_[patchi] = -1;
78 for (label& facei : faFaceProcAddr_)
81 facei =
mag(fvFaceProcAddr[facei] - 1);
89 globalFaceNum.gather(faFaceProcAddr_, singlePatchFaceLabels_);
93 singlePatchFaceLabels_ =
94 labelList(singlePatchFaceLabels_, globalOrder);
99 label patchFirstMeshfacei
101 singlePatchFaceLabels_.empty()
103 : singlePatchFaceLabels_.first()
107 for (label& facei : faFaceProcAddr_)
109 facei -= patchFirstMeshfacei;
119 labelList procTargets(globalFaceNum.size());
125 globalFaceNum.range(proci),
130 labelList procStarts(globalFaceNum.offsets());
131 labelList procOrders(globalFaceNum.size());
133 for (
const label globali : globalOrder)
135 const label proci = procTargets[globali];
137 procOrders[procStarts[proci]++] =
138 (globali - globalFaceNum.localStart(proci));
144 SubList<label> localOrder
147 globalFaceNum.range(proci)
150 UOPstream toProc(proci, pBufs);
151 toProc << localOrder;
154 SubList<label> localOrder(procOrders, globalFaceNum.range(0));
156 faFaceProcAddr_ =
labelList(faFaceProcAddr_, localOrder);
159 pBufs.finishedSends();
166 fromProc >> localOrder;
168 faFaceProcAddr_ =
labelList(faFaceProcAddr_, localOrder);
188 faPointProcAddr_.
clear();
215 autoPtr<globalIndex> globalPointsPtr =
218 procPatch.meshPoints(),
219 procPatch.meshPointMap(),
221 uniqueMeshPointLabels
225 faceList tmpFaces(globalFaceNum.localSize());
230 face(pointToGlobal, procPatch.localFaces()[facei]);
236 singlePatchProcFaces,
241 globalPointsPtr().gather
246 uniqueMeshPointLabels
252 singlePatchFaces_.
resize(singlePatchProcFaces.size());
256 globalFaceNum.gather(faFaceProcAddr_, singlePatchProcAddr);
258 forAll(singlePatchProcAddr, facei)
260 const label targetFacei = singlePatchProcAddr[facei];
261 singlePatchFaces_[targetFacei] = singlePatchProcFaces[facei];
270 SubList<face>(singlePatchFaces_),
275 tmpFaces = initialPatch.localFaces();
276 pointField tmpPoints(initialPatch.localPoints());
279 labelList mpm(initialPatch.points().size(), -1);
290 for (label& pointi : pointToGlobal)
292 pointi = mpm[pointi];
296 faPointProcAddr_ = std::move(pointToGlobal);
298 singlePatchFaces_ = std::move(tmpFaces);
299 singlePatchPoints_ = std::move(tmpPoints);
311 SubList<face>(singlePatchFaces_),
315 faEdgeProcAddr_.
clear();
319 EdgeMap<label> globalEdgeMapping(2*onePatch.nEdges());
327 for (
const edge&
e : onePatch.edges())
329 globalEdgeMapping.insert(
e, globalEdgeMapping.size());
333 for (label edgei = 0; edgei < procPatch.nEdges(); ++edgei)
335 const edge globalEdge(faPointProcAddr_, procPatch.edges()[edgei]);
337 const auto fnd = globalEdgeMapping.cfind(globalEdge);
341 faEdgeProcAddr_[edgei] = fnd.val();
346 <<
"Failed to find edge " << globalEdge
347 <<
" this indicates a programming error" <<
nl
361 Map<label> remapGlobal(2*onePatch.nEdges());
362 for (label edgei = 0; edgei < onePatch.nInternalEdges(); ++edgei)
364 remapGlobal.insert(edgei, remapGlobal.size());
368 singlePatchEdgeLabels_.
clear();
371 forAll(singlePatchEdgeLabels_, patchi)
373 const faPatch& fap = procMesh_.
boundary()[patchi];
375 labelList& patchEdgeLabels = singlePatchEdgeLabels_[patchi];
376 patchEdgeLabels = fap.edgeLabels();
379 for (label& edgeId : patchEdgeLabels)
381 edgeId = faEdgeProcAddr_[edgeId];
392 ListOps::appendEqOp<label>()
398 for (
const label sortedEdgei : patchEdgeLabels)
400 remapGlobal.insert(sortedEdgei, remapGlobal.size());
407 labelList newEdgeProcAddr(faEdgeProcAddr_);
411 for (
const faPatch& fap : procMesh_.
boundary())
413 for (
const label patchEdgei : fap.edgeLabels())
415 const label globalEdgei = faEdgeProcAddr_[patchEdgei];
417 const auto fnd = remapGlobal.cfind(globalEdgei);
420 newEdgeProcAddr[edgei] = fnd.val();
426 <<
"Failed to find edge " << globalEdgei
427 <<
" this indicates a programming error" <<
nl
433 faEdgeProcAddr_ = std::move(newEdgeProcAddr);
438 void Foam::faMeshReconstructor::initPatch()
const
440 serialPatchPtr_.reset
444 SubList<face>(singlePatchFaces_),
451 void Foam::faMeshReconstructor::createMesh()
468 procMesh_.mesh().name(),
469 procMesh_.mesh().facesInstance(),
486 serialAreaMesh_.reset
495 auto& completeMesh = *serialAreaMesh_;
498 PtrList<faPatch> completePatches(singlePatchEdgeLabels_.size());
499 forAll(completePatches, patchi)
501 const labelList& patchEdgeLabels = singlePatchEdgeLabels_[patchi];
503 const faPatch& fap = procMesh_.boundary()[patchi];
505 const label neiPolyPatchId = fap.ngbPolyPatchIndex();
512 completeMesh.boundary(),
524 completeMesh.addFaPatches(completePatches);
532 Foam::faMeshReconstructor::faMeshReconstructor
542 <<
"Can only be called in parallel!!" <<
nl
551 "faceProcAddressing",
552 procMesh_.mesh().facesInstance(),
571 calcAddressing(fvFaceProcAddressing);
575 Foam::faMeshReconstructor::faMeshReconstructor
586 <<
"Can only be called in parallel!!" <<
nl
590 calcAddressing(fvFaceProcAddressing);
604 serialAreaMesh_.reset(
nullptr);
605 serialVolMesh_.reset(
nullptr);
606 serialRunTime_.reset(
nullptr);
612 if (!serialPatchPtr_)
617 return *serialPatchPtr_;
623 if (!serialPatchPtr_)
628 return *serialPatchPtr_;
634 if (!serialAreaMesh_)
639 return *serialAreaMesh_;
645 writeAddressing(procMesh_.mesh().facesInstance());
665 ioAddr.
rename(
"boundaryProcAddressing");
669 ioAddr.rename(
"faceProcAddressing");
673 ioAddr.rename(
"pointProcAddressing");
677 ioAddr.rename(
"edgeProcAddressing");
684 writeMesh(procMesh_.mesh().facesInstance());