51 void Foam::globalMeshData::initProcAddr()
54 processorPatchIndices_ = -1;
57 processorPatchNeighbours_ = -1;
63 label nNeighbours = 0;
69 processorPatches_[nNeighbours] =
patchi;
70 processorPatchIndices_[
patchi] = nNeighbours++;
73 processorPatches_.
setSize(nNeighbours);
79 forAll (processorPatches_, i)
81 label
patchi = processorPatches_[i];
86 refCast<const processorPolyPatch>
92 toNeighbour << processorPatchIndices_[
patchi];
95 forAll(processorPatches_, i)
97 label patchi = processorPatches_[i];
99 IPstream fromNeighbour
102 refCast<const processorPolyPatch>
108 fromNeighbour >> processorPatchNeighbours_[
patchi];
115 void Foam::globalMeshData::countSharedEdges
117 const HashTable<
labelList, edge, Hash<edge> >& procSharedEdges,
118 HashTable<label, edge, Hash<edge> >& globalShared,
125 HashTable<
labelList, edge, Hash<edge> >::const_iterator iter =
126 procSharedEdges.
begin();
127 iter != procSharedEdges.end();
131 const edge&
e = iter.key();
133 HashTable<label, edge, Hash<edge> >::iterator globalFnd =
134 globalShared.find(e);
136 if (globalFnd == globalShared.end())
139 if (iter().size() == 1)
142 globalShared.insert(e, -1);
148 globalShared.insert(e, sharedEdgeI++);
153 if (globalFnd() == -1)
157 globalFnd() = sharedEdgeI++;
168 void Foam::globalMeshData::calcSharedEdges()
const
170 if (nGlobalEdges_ != -1 || sharedEdgeLabelsPtr_ || sharedEdgeAddrPtr_)
177 const labelList& sharedPtAddr = sharedPointAddr();
178 const labelList& sharedPtLabels = sharedPointLabels();
182 Map<label> meshToShared(2*sharedPtLabels.size());
185 meshToShared.insert(sharedPtLabels[i], i);
191 HashTable<labelList, edge, Hash<edge> > localShared
193 2*sharedPtAddr.size()
196 const edgeList& edges = mesh_.edges();
200 const edge& e = edges[edgeI];
204 if (e0Fnd != meshToShared.end())
208 if (e1Fnd != meshToShared.end())
216 sharedPtAddr[e0Fnd()],
217 sharedPtAddr[e1Fnd()]
220 HashTable<labelList, edge, Hash<edge> >::iterator iter =
221 localShared.find(sharedEdge);
223 if (iter == localShared.end())
226 localShared.insert(sharedEdge,
labelList(1, edgeI));
233 label sz = edgeLabels.size();
234 edgeLabels.setSize(sz+1);
235 edgeLabels[sz] = edgeI;
251 HashTable<label, edge, Hash<edge> > globalShared(nGlobalPoints());
255 label sharedEdgeI = 0;
260 Pout<<
"globalMeshData::calcSharedEdges : Merging in from proc0 : "
261 << localShared.size() <<
endl;
263 countSharedEdges(localShared, globalShared, sharedEdgeI);
277 HashTable<labelList, edge, Hash<edge> > procSharedEdges
284 Pout<<
"globalMeshData::calcSharedEdges : "
285 <<
"Merging in from proc"
286 <<
Foam::name(slave) <<
" : " << procSharedEdges.size()
289 countSharedEdges(procSharedEdges, globalShared, sharedEdgeI);
297 HashTable<label, edge, Hash<edge> > oldSharedEdges(globalShared);
299 globalShared.clear();
303 HashTable<label, edge, Hash<edge> >::const_iterator iter =
304 oldSharedEdges.begin();
305 iter != oldSharedEdges.end();
311 globalShared.insert(iter.key(), iter());
316 Pout<<
"globalMeshData::calcSharedEdges : Filtered "
317 << oldSharedEdges.size()
318 <<
" down to " << globalShared.size() <<
endl;
335 toSlave << globalShared;
345 toMaster << localShared;
351 fromMaster >> globalShared;
358 nGlobalEdges_ = globalShared.size();
360 DynamicList<label> dynSharedEdgeLabels(globalShared.size());
361 DynamicList<label> dynSharedEdgeAddr(globalShared.size());
365 HashTable<
labelList, edge, Hash<edge> >::const_iterator iter =
367 iter != localShared.end();
371 const edge& e = iter.key();
373 HashTable<label, edge, Hash<edge> >::const_iterator edgeFnd =
374 globalShared.find(e);
376 if (edgeFnd != globalShared.end())
385 dynSharedEdgeLabels.append(edgeLabels[i]);
388 dynSharedEdgeAddr.append(edgeFnd());
394 labelList& sharedEdgeLabels = *sharedEdgeLabelsPtr_;
395 sharedEdgeLabels.
transfer(dynSharedEdgeLabels);
398 labelList& sharedEdgeAddr = *sharedEdgeAddrPtr_;
399 sharedEdgeAddr.
transfer(dynSharedEdgeAddr);
403 Pout<<
"globalMeshData : nGlobalEdges_:" << nGlobalEdges_ <<
nl
404 <<
"globalMeshData : sharedEdgeLabels:" << sharedEdgeLabels.size()
406 <<
"globalMeshData : sharedEdgeAddr:" << sharedEdgeAddr.size()
416 Foam::label Foam::globalMeshData::countCoincidentFaces
422 label nCoincident = 0;
424 forAll(separationDist, faceI)
426 if (
mag(separationDist[faceI]) < tolDim)
447 processorPatches_(0),
448 processorPatchIndices_(0),
449 processorPatchNeighbours_(0),
451 sharedPointLabels_(0),
453 sharedPointGlobalLabelsPtr_(NULL),
455 sharedEdgeLabelsPtr_(NULL),
456 sharedEdgeAddrPtr_(NULL)
471 processorPatches_(0),
472 processorPatchIndices_(0),
473 processorPatchNeighbours_(0),
475 sharedPointLabels_(0),
477 sharedPointGlobalLabelsPtr_(NULL),
479 sharedEdgeLabelsPtr_(NULL),
480 sharedEdgeAddrPtr_(NULL)
486 dict.
lookup(
"nTotalPoints") >> nTotalPoints_;
487 dict.
lookup(
"nTotalFaces") >> nTotalFaces_;
488 dict.
lookup(
"nTotalCells") >> nTotalCells_;
489 dict.
lookup(
"nGlobalPoints") >> nGlobalPoints_;
490 dict.
lookup(
"sharedPointLabels") >> sharedPointLabels_;
491 dict.
lookup(
"sharedPointAddr") >> sharedPointAddr_;
521 if (!sharedPointGlobalLabelsPtr_)
523 sharedPointGlobalLabelsPtr_ =
new labelList(sharedPointLabels_.size());
524 labelList& sharedPointGlobalLabels = *sharedPointGlobalLabelsPtr_;
528 "pointProcAddressing",
529 mesh_.facesInstance()/mesh_.meshSubDir,
534 if (addrHeader.headerOk())
538 Pout<<
"globalMeshData::sharedPointGlobalLabels : "
539 <<
"Reading pointProcAddressing" <<
endl;
543 forAll(sharedPointLabels_, i)
546 label pointI = sharedPointLabels_[i];
549 sharedPointGlobalLabels[i] = pointProcAddressing[pointI];
554 Pout<<
"globalMeshData::sharedPointGlobalLabels :"
555 <<
" Setting pointProcAddressing to -1" <<
endl;
557 sharedPointGlobalLabels = -1;
560 return *sharedPointGlobalLabelsPtr_;
576 forAll(sharedPointLabels_, i)
578 label sharedPointI = sharedPointAddr_[i];
580 sharedPoints[sharedPointI] = mesh_.points()[sharedPointLabels_[i]];
595 fromSlave >> nbrSharedPointAddr >> nbrSharedPoints;
597 forAll(nbrSharedPointAddr, i)
599 label sharedPointI = nbrSharedPointAddr[i];
601 sharedPoints[sharedPointI] = nbrSharedPoints[i];
619 toSlave << sharedPoints;
637 fromMaster >> sharedPoints;
649 pointField sharedPoints(sharedPointLabels_.size());
651 forAll(sharedPointLabels_, i)
653 label meshPointI = sharedPointLabels_[i];
655 sharedPoints[i] = mesh_.points()[meshPointI];
662 scalar tolDim = matchTol_ * bb_.mag();
683 if (nGlobalEdges_ == -1)
687 return nGlobalEdges_;
693 if (!sharedEdgeLabelsPtr_)
697 return *sharedEdgeLabelsPtr_;
703 if (!sharedEdgeAddrPtr_)
707 return *sharedEdgeAddrPtr_;
730 scalar tolDim = matchTol_ * bb_.
mag();
734 Pout<<
"globalMeshData : bb_:" << bb_
735 <<
" merge dist:" << tolDim <<
endl;
766 nTotalFaces_ = mesh_.nFaces();
769 forAll(processorPatches_, i)
771 label patchI = processorPatches_[i];
774 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchI]);
784 nTotalFaces_ -= countCoincidentFaces(tolDim, separationDist);
789 nTotalFaces_ -= procPatch.size();
797 Pout<<
"globalMeshData : nTotalFaces_:" << nTotalFaces_ <<
endl;
801 nTotalCells_ = mesh_.nCells();
806 Pout<<
"globalMeshData : nTotalCells_:" << nTotalCells_ <<
endl;
809 nTotalPoints_ = mesh_.nPoints();
819 const label UNSET = 0;
820 const label SHARED = 1;
821 const label VISITED = 2;
826 forAll(sharedPointLabels_, i)
828 label meshPointI = sharedPointLabels_[i];
830 pointStatus.set(meshPointI, SHARED);
834 forAll(processorPatches_, i)
836 label patchI = processorPatches_[i];
839 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchI]);
847 forAll(processorPatches_, i)
849 label patchI = processorPatches_[i];
852 refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchI]);
872 label meshPointI = procPatch.
meshPoints()[patchPointI];
874 label stat = pointStatus.get(meshPointI);
880 pointStatus.set(meshPointI, VISITED);
882 if (pMap[patchPointI] != -1)
898 label mySharedPoints = sharedPointLabels_.size();
902 pointField geomSharedPoints(geometricSharedPoints());
903 label nGeomSharedPoints = geomSharedPoints.
size();
906 nTotalPoints_ -= mySharedPoints - nGeomSharedPoints;
910 Pout<<
"globalMeshData : nTotalPoints_:" << nTotalPoints_ <<
endl;
925 Pout<<
"globalMeshData : writing geometrically separated shared"
926 <<
" points to geomSharedPoints.obj" <<
endl;
928 OFstream str(
"geomSharedPoints.obj");
930 forAll(geomSharedPoints, i)
932 const point& pt = geomSharedPoints[i];
934 str <<
"v " << pt.
x() <<
' ' << pt.
y() <<
' ' << pt.
z()
950 mesh_.facesInstance(),
956 dict.
add(
"nTotalPoints", nTotalPoints());
957 dict.
add(
"nTotalFaces", nTotalFaces());
958 dict.
add(
"nTotalCells", nTotalCells());
960 dict.
add(
"nGlobalPoints", nGlobalPoints());
961 dict.
add(
"sharedPointLabels", sharedPointLabels());
962 dict.
add(
"sharedPointAddr", sharedPointAddr());
963 dict.
add(
"sharedPointGlobalLabels", sharedPointGlobalLabels());