34 Foam::domainDecomposition::determineCoupledFaces
36 const label masterMeshProcStart,
37 const label masterMeshProcEnd,
38 const polyMesh& masterMesh,
39 const label meshToAddProcStart,
40 const label meshToAddProcEnd,
41 const polyMesh& meshToAdd
44 const polyBoundaryMesh& masterPatches = masterMesh.boundaryMesh();
45 const polyBoundaryMesh& addPatches = meshToAdd.boundaryMesh();
47 DynamicList<label> masterFaces
49 masterMesh.nFaces() - masterMesh.nInternalFaces()
51 DynamicList<label> addFaces
53 meshToAdd.nFaces() - meshToAdd.nInternalFaces()
58 label masterProci = masterMeshProcStart;
59 masterProci < masterMeshProcEnd;
65 label addProci = meshToAddProcStart;
66 addProci < meshToAddProcEnd;
70 const word masterToAddName
72 "procBoundary" +
name(masterProci) +
"to" +
name(addProci)
74 const word addToMasterName
76 "procBoundary" +
name(addProci) +
"to" +
name(masterProci)
79 const label masterToAddID =
80 masterPatches.findIndex(masterToAddName);
81 const label addToMasterID =
82 addPatches.findIndex(addToMasterName);
84 if (masterToAddID != -1 && addToMasterID != -1)
86 const polyPatch& masterPp = masterPatches[masterToAddID];
90 masterFaces.append(masterPp.start() + i);
93 const polyPatch& addPp = addPatches[addToMasterID];
97 addFaces.append(addPp.start() + i);
101 if ((masterToAddID != -1) != (addToMasterID != -1))
103 const label foundProci =
104 masterToAddID != -1 ? masterProci : addProci;
105 const word& foundName =
106 masterToAddID != -1 ? masterToAddName : addToMasterName;
108 const label missingProci =
109 masterToAddID != -1 ? addProci : masterProci;
110 const word& missingName =
111 masterToAddID != -1 ? addToMasterName : masterToAddName;
114 <<
"Patch " << foundName <<
" found on processor "
115 << foundProci <<
" but corresponding patch "
116 << missingName <<
" missing on processor "
122 masterFaces.shrink();
125 return autoPtr<faceCoupleInfo>
138 void Foam::domainDecomposition::reconstruct()
143 PtrList<fvMesh> masterMeshes(nProcs());
146 for (
label proci=0; proci<nProcs(); proci++)
156 procMeshes()[0].facesInstance(),
157 runTimes_.completeTime()
164 fvMesh& masterMesh = masterMeshes[proci];
165 masterMesh.setPointsInstance(procMeshes()[0].pointsInstance());
168 procPointAddressing_[proci] =
170 procFaceAddressing_[proci] =
identityMap(procMeshes()[proci].nFaces());
171 procCellAddressing_[proci] =
identityMap(procMeshes()[proci].nCells());
174 autoPtr<faceCoupleInfo> couples = determineCoupledFaces
196 map().addedPointMap(),
197 procPointAddressing_[proci]
201 map().addedFaceMap(),
202 procFaceAddressing_[proci]
206 map().addedCellMap(),
207 procCellAddressing_[proci]
212 for (
label step=2; step<nProcs()*2; step*=2)
214 for (
label proci=0; proci<nProcs(); proci+=step)
216 label procj = proci + step/2;
218 if (procj >= nProcs())
continue;
221 <<
" with " << procj <<
endl;
224 autoPtr<faceCoupleInfo> couples = determineCoupledFaces
246 label mergedProci = proci;
254 procPointAddressing_[mergedProci]
259 procFaceAddressing_[mergedProci]
264 procCellAddressing_[mergedProci]
271 label addedProci = procj;
272 addedProci <
min(proci + step, nProcs());
278 map().addedPointMap(),
279 procPointAddressing_[addedProci]
283 map().addedFaceMap(),
284 procFaceAddressing_[addedProci]
288 map().addedCellMap(),
289 procCellAddressing_[addedProci]
293 masterMeshes.set(procj,
nullptr);
297 const polyBoundaryMesh&
patches = masterMeshes[0].boundaryMesh();
300 if (!
patches.findIndices<processorCyclicPolyPatch>().
empty())
303 List<DynamicList<label>> patchPatches
306 DynamicList<label>(1)
317 FixedList<label, 3>::Hash<>
318 > nbrProcessorCyclicIDs;
322 if (!isA<processorCyclicPolyPatch>(
patches[
patchi]))
continue;
324 const processorCyclicPolyPatch& pcpp =
327 const label proci = pcpp.myProcNo();
328 const label nbrProci = pcpp.neighbProcNo();
329 const label refPatchi = pcpp.referPatchIndex();
330 const label nbrRefPatchi = pcpp.referPatch().nbrPatchIndex();
332 FixedList<label, 3> key({proci, nbrProci, refPatchi});
333 FixedList<label, 3> nbrKey({nbrProci, proci, nbrRefPatchi});
335 if (nbrProcessorCyclicIDs.found(nbrKey))
337 const label nbrPatchi = nbrProcessorCyclicIDs[nbrKey];
339 patchPatches[refPatchi].append
341 patchPatches[
patchi].remove()
343 patchPatches[nbrRefPatchi].append
345 patchPatches[nbrPatchi].remove()
348 nbrProcessorCyclicIDs.erase(nbrKey);
352 nbrProcessorCyclicIDs.insert(key,
patchi);
359 labelList newToOldFace(masterMeshes[0].nFaces());
360 SubList<label>(newToOldFace, masterMeshes[0].nInternalFaces()) =
364 newPatchSizes[
patchi] = 0;
367 ? masterMeshes[0].nInternalFaces()
381 newPatchSizes[
patchi] += pp.size();
388 boolList newHasOldFace(newToOldFace.size(),
false);
389 forAll(newToOldFace, newFacei)
391 if (newHasOldFace[newToOldFace[newFacei]])
394 <<
"Face re-ordering is not valid"
397 newHasOldFace[newToOldFace[newFacei]] =
true;
402 const labelList oldToNewFace(
invert(newToOldFace.size(), newToOldFace));
403 masterMeshes[0].resetPrimitives
405 NullObjectMove<pointField>(),
406 reorder(oldToNewFace, masterMeshes[0].faces()),
407 reorder(oldToNewFace, masterMeshes[0].faceOwner()),
408 reorder(oldToNewFace, masterMeshes[0].faceNeighbour()),
415 forAll(procFaceAddressing_, proci)
420 procFaceAddressing_[proci]
427 label nNonProcPatches = 0;
437 <<
"Non-empty processor patch \""
439 <<
"\" found in reconstructed mesh"
445 nonProcPatchIds[nNonProcPatches++] =
patchi;
449 nonProcPatchIds.resize(nNonProcPatches);
451 masterMeshes[0].reorderPatches(nonProcPatchIds,
false);
455 for (
label proci=0; proci<nProcs(); proci++)
457 const fvMesh& procMesh = procMeshes_[proci];
459 forAll(procFaceAddressing_[proci], procFacei)
461 const label completeFacei = procFaceAddressing_[proci][procFacei];
465 !procMesh.isInternalFace(procFacei)
466 && masterMeshes[0].isInternalFace(completeFacei)
472 const label procOwnCelli =
473 procMesh.faceOwner()[procFacei];
474 const label completeOwnCelli =
475 masterMeshes[0].faceOwner()[completeFacei];
479 procCellAddressing_[proci][procOwnCelli]
483 procFaceAddressing_[proci][procFacei] ++;
487 procFaceAddressing_[proci][procFacei] =
488 -1 - procFaceAddressing_[proci][procFacei];
496 procFaceAddressing_[proci][procFacei] ++;
502 procFaceAddressingBf_.clear();
505 cellProc_.resize(masterMeshes[0].nCells());
506 forAll(procCellAddressing_, proci)
508 forAll(procCellAddressing_[proci], procCelli)
510 cellProc_[procCellAddressing_[proci][procCelli]] = proci;
515 completeMesh_.reset(masterMeshes.set(0,
nullptr).ptr());
516 completeMesh_->setInstance(procMeshes()[0].facesInstance());
517 completeMesh_->setPointsInstance(procMeshes()[0].pointsInstance());
526 void Foam::domainDecomposition::reconstructPoints()
528 const label pointsCompare =
531 completeMesh().pointsInstance(),
532 procMeshes_[0].pointsInstance()
535 if (pointsCompare == 1)
539 for (
label proci = 0; proci < nProcs(); proci++)
541 const fvMesh& procMesh = procMeshes_[proci];
543 completePoints.rmap(procMesh.points(), procPointAddressing_[proci]);
546 completeMesh_->setPoints(completePoints);
#define forAll(list, i)
Loop across all elements in list.
label size() const
Return the number of elements in the UPtrList.
bool empty() const
Return true if the UPtrList is empty (ie, size() is zero)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
static autoPtr< mapAddedPolyMesh > add(fvMesh &mesh0, const fvMesh &mesh1, const faceCoupleInfo &coupleInfo, const bool validBoundary=true)
Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
errorManipArg< error, int > exit(error &err, const int errNo=1)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
List< cell > cellList
list of cells
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
vectorField pointField
pointField is a vectorField.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
List< bool > boolList
Bool container classes.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
ListType reorder(const label size, const typename ListType::value_type &defaultValue, const labelUList &oldToNew, const ListType &lst)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
Ostream & indent(Ostream &os)
Indent stream.
faceListList boundary(nPatches)