38 const label masterMeshProcStart,
39 const label masterMeshProcEnd,
41 const label meshToAddProcStart,
42 const label meshToAddProcEnd,
60 label masterProci = masterMeshProcStart;
61 masterProci < masterMeshProcEnd;
67 label addProci = meshToAddProcStart;
68 addProci < meshToAddProcEnd;
72 const word masterToAddName
74 "procBoundary" +
name(masterProci) +
"to" +
name(addProci)
76 const word addToMasterName
78 "procBoundary" +
name(addProci) +
"to" +
name(masterProci)
81 const label masterToAddID =
83 const label addToMasterID =
86 if (masterToAddID != -1 && addToMasterID != -1)
88 const polyPatch& masterPp = masterPatches[masterToAddID];
95 const polyPatch& addPp = addPatches[addToMasterID];
103 if ((masterToAddID != -1) != (addToMasterID != -1))
105 const label foundProci =
106 masterToAddID != -1 ? masterProci : addProci;
107 const word& foundName =
108 masterToAddID != -1 ? masterToAddName : addToMasterName;
110 const label missingProci =
111 masterToAddID != -1 ? addProci : masterProci;
112 const word& missingName =
113 masterToAddID != -1 ? addToMasterName : masterToAddName;
116 <<
"Patch " << foundName <<
" found on processor "
117 << foundProci <<
" but corresponding patch "
118 << missingName <<
" missing on processor "
143 void Foam::domainDecomposition::reconstruct()
148 PtrList<fvMesh> masterMeshes(
nProcs());
169 fvMesh& masterMesh = masterMeshes[proci];
170 masterMesh.setPointsInstance(
procMeshes()[0].pointsInstance());
173 procPointAddressing_[proci] =
201 map().addedPointMap(),
202 procPointAddressing_[proci]
206 map().addedFaceMap(),
207 procFaceAddressing_[proci]
211 map().addedCellMap(),
212 procCellAddressing_[proci]
221 label procj = proci + step/2;
223 if (procj >=
nProcs())
continue;
226 <<
" with " << procj <<
endl;
251 label mergedProci = proci;
259 procPointAddressing_[mergedProci]
264 procFaceAddressing_[mergedProci]
269 procCellAddressing_[mergedProci]
276 label addedProci = procj;
277 addedProci <
min(proci + step,
nProcs());
283 map().addedPointMap(),
284 procPointAddressing_[addedProci]
288 map().addedFaceMap(),
289 procFaceAddressing_[addedProci]
293 map().addedCellMap(),
294 procCellAddressing_[addedProci]
298 masterMeshes.set(procj,
nullptr);
302 const polyBoundaryMesh&
patches = masterMeshes[0].boundaryMesh();
305 if (!
patches.findPatchIDs<processorCyclicPolyPatch>().empty())
308 List<DynamicList<label>> patchPatches
311 DynamicList<label>(1)
322 FixedList<label, 3>::Hash<>
323 > nbrProcessorCyclicIDs;
327 if (!isA<processorCyclicPolyPatch>(
patches[
patchi]))
continue;
329 const processorCyclicPolyPatch& pcpp =
332 const label proci = pcpp.myProcNo();
333 const label nbrProci = pcpp.neighbProcNo();
334 const label refPatchi = pcpp.referPatchID();
335 const label nbrRefPatchi = pcpp.referPatch().nbrPatchID();
337 FixedList<label, 3> key({proci, nbrProci, refPatchi});
338 FixedList<label, 3> nbrKey({nbrProci, proci, nbrRefPatchi});
340 if (nbrProcessorCyclicIDs.found(nbrKey))
342 const label nbrPatchi = nbrProcessorCyclicIDs[nbrKey];
344 patchPatches[refPatchi].append
346 patchPatches[
patchi].remove()
348 patchPatches[nbrRefPatchi].append
350 patchPatches[nbrPatchi].remove()
353 nbrProcessorCyclicIDs.erase(nbrKey);
357 nbrProcessorCyclicIDs.insert(key,
patchi);
364 labelList newToOldFace(masterMeshes[0].nFaces());
365 SubList<label>(newToOldFace, masterMeshes[0].nInternalFaces()) =
369 newPatchSizes[
patchi] = 0;
372 ? masterMeshes[0].nInternalFaces()
386 newPatchSizes[
patchi] += pp.size();
393 boolList newHasOldFace(newToOldFace.size(),
false);
394 forAll(newToOldFace, newFacei)
396 if (newHasOldFace[newToOldFace[newFacei]])
399 <<
"Face re-ordering is not valid"
402 newHasOldFace[newToOldFace[newFacei]] =
true;
407 const labelList oldToNewFace(
invert(newToOldFace.size(), newToOldFace));
408 masterMeshes[0].resetPrimitives
410 NullObjectMove<pointField>(),
411 reorder(oldToNewFace, masterMeshes[0].faces()),
412 reorder(oldToNewFace, masterMeshes[0].faceOwner()),
413 reorder(oldToNewFace, masterMeshes[0].faceNeighbour()),
420 forAll(procFaceAddressing_, proci)
425 procFaceAddressing_[proci]
432 label nNonProcPatches = 0;
442 <<
"Non-empty processor patch \""
444 <<
"\" found in reconstructed mesh"
450 nonProcPatchIds[nNonProcPatches++] =
patchi;
454 nonProcPatchIds.resize(nNonProcPatches);
456 masterMeshes[0].reorderPatches(nonProcPatchIds,
false);
462 const fvMesh& procMesh = procMeshes_[proci];
464 forAll(procFaceAddressing_[proci], procFacei)
466 const label completeFacei = procFaceAddressing_[proci][procFacei];
470 !procMesh.isInternalFace(procFacei)
471 && masterMeshes[0].isInternalFace(completeFacei)
477 const label procOwnCelli =
478 procMesh.faceOwner()[procFacei];
479 const label completeOwnCelli =
480 masterMeshes[0].faceOwner()[completeFacei];
484 procCellAddressing_[proci][procOwnCelli]
488 procFaceAddressing_[proci][procFacei] ++;
492 procFaceAddressing_[proci][procFacei] =
493 -1 - procFaceAddressing_[proci][procFacei];
501 procFaceAddressing_[proci][procFacei] ++;
507 procFaceAddressingBf_.clear();
510 cellProc_.
resize(masterMeshes[0].nCells());
511 forAll(procCellAddressing_, proci)
513 forAll(procCellAddressing_[proci], procCelli)
515 cellProc_[procCellAddressing_[proci][procCelli]] = proci;
520 completeMesh_.reset(masterMeshes.set(0,
nullptr).ptr());
521 completeMesh_->setInstance(
procMeshes()[0].facesInstance());
522 completeMesh_->setPointsInstance(
procMeshes()[0].pointsInstance());
#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.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
void resize(const label)
Alias for setSize(const label)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
label nProcs() const
Return the number of processors in the decomposition.
const PtrList< fvMesh > & procMeshes() const
Access the processor meshes.
Container for information needed to couple to meshes. When constructed from two meshes and a list of ...
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.
label findPatchID(const word &patchName) const
Find patch index given a name.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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 Time & completeTime() const
Access the complete run time.
A class for handling words, derived from string.
#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.
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)
autoPtr< faceCoupleInfo > determineCoupledFaces(const label masterMeshProcStart, const label masterMeshProcEnd, const polyMesh &masterMesh, const label meshToAddProcStart, const label meshToAddProcEnd, const polyMesh &meshToAdd)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
ListType reorder(const labelUList &oldToNew, const ListType &)
Reorder the elements (indices, not values) of a list.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
word name(const complex &)
Return a string representation of a complex.
Ostream & indent(Ostream &os)
Indent stream.
faceListList boundary(nPatches)