56 distributedTriSurfaceMesh,
131 if (
y.first().hit() &&
y.second() <
x.second())
136 else if (
y.first().hit())
151 { distributionType::FOLLOW,
"follow" },
152 { distributionType::INDEPENDENT,
"independent" },
153 { distributionType::DISTRIBUTED,
"distributed" },
154 { distributionType::FROZEN,
"frozen" }
160 Foam::word Foam::distributedTriSurfaceMesh::findLocalInstance
168 io.time().findInstance
186 io.rootPath()/io.time().globalCaseName()
187 /io.instance()/io.db().dbDir()/io.local()/io.
name();
191 return io.instance();
197 const scalar startValue = io.time().timeOutputValue();
199 for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
201 if (ts[instanceI].value() <= startValue)
208 for (; instanceI >= 0; --instanceI)
211 if (ts[instanceI].
name() == io.instance())
217 io.rootPath()/io.time().globalCaseName()
218 /ts[instanceI].name()/io.db().dbDir()/io.local()/io.name();
222 return ts[instanceI].name();
231 if (!ts.size() || ts[0].name() != io.time().constant())
238 io.rootPath()/io.time().globalCaseName()
239 /io.time().constant()/io.db().dbDir()/io.local()/io.name();
243 return io.time().constant();
248 <<
"Cannot find directory " << io.local() <<
" in times " << ts
256 bool Foam::distributedTriSurfaceMesh::read()
276 distType_ = DISTRIBUTED;
277 dict_.add(
"distributionType", distributionTypeNames_[distType_]);
281 dict_.add(
"mergeDistance", mergeDist_);
287 dict_.add(
"closed", surfaceClosed_);
312 distType_ = distributionTypeNames_.get(
"distributionType", dict_);
315 dict_.readEntry(
"mergeDistance", mergeDist_);
318 surfaceClosed_ = dict_.getOrDefault<
bool>(
"closed",
false);
333 bool Foam::distributedTriSurfaceMesh::isLocal
335 const List<treeBoundBox>& myBbs,
342 if (myBbs[bbi].contains(start) && myBbs[bbi].contains(
end))
413 void Foam::distributedTriSurfaceMesh::distributeSegment
415 const label segmenti,
419 DynamicList<segment>& allSegments,
420 DynamicList<label>& allSegmentMap,
421 List<DynamicList<label>>& sendMap
438 const List<treeBoundBox>& bbs = procBb_[proci];
440 if (isLocal(bbs, start,
end))
442 sendMap[proci].
append(allSegments.size());
443 allSegmentMap.append(segmenti);
455 const List<treeBoundBox>& bbs = procBb_[proci];
459 const treeBoundBox& bb = bbs[bbi];
467 if (bb.intersects(start,
end, clipPt))
469 sendMap[proci].append(allSegments.size());
470 allSegmentMap.append(segmenti);
494 Foam::distributedTriSurfaceMesh::distributeSegments
499 List<segment>& allSegments,
514 DynamicList<segment> dynAllSegments(start.size());
516 DynamicList<label> dynAllSegmentMap(start.size());
523 dynSendMap[proci].reserve
549 dynSendMap[proci].shrink();
550 sendMap[proci].transfer(dynSendMap[proci]);
553 allSegments.transfer(dynAllSegments);
554 allSegmentMap.transfer(dynAllSegmentMap);
561 void Foam::distributedTriSurfaceMesh::findLine
563 const bool nearestIntersection,
566 List<pointIndexHit>& info
571 Pout<<
"distributedTriSurfaceMesh::findLine :"
572 <<
" intersecting with "
573 << start.size() <<
" rays" <<
endl;
575 addProfiling(findLine,
"distributedTriSurfaceMesh::findLine");
577 const indexedOctree<treeDataTriSurface>& octree = tree();
580 info.setSize(start.size());
587 const globalIndex& triIndexer = globalTris();
599 if (nearestIntersection)
601 info[i] = octree.findLine(start[i],
end[i]);
605 info[i] = octree.findLineAny(start[i],
end[i]);
610 info[i].setIndex(triIndexer.toGlobal(info[i].index()));
631 List<segment> allSegments(start.size());
635 const autoPtr<mapDistribute> mapPtr
645 const mapDistribute& map = mapPtr();
647 label nOldAllSegments = allSegments.size();
653 map.distribute(allSegments);
660 List<pointIndexHit> intersections(allSegments.size());
664 if (nearestIntersection)
666 intersections[i] = octree.findLine
668 allSegments[i].first(),
669 allSegments[i].second()
674 intersections[i] = octree.findLineAny
676 allSegments[i].first(),
677 allSegments[i].second()
682 if (intersections[i].hit())
684 intersections[i].setIndex
686 triIndexer.toGlobal(intersections[i].index())
695 map.reverseDistribute(nOldAllSegments, intersections);
704 label segmenti = allSegmentMap[i];
714 else if (nearestIntersection)
719 magSqr(allInfo.hitPoint()-start[segmenti])
720 <
magSqr(hitInfo.hitPoint()-start[segmenti])
732 void Foam::distributedTriSurfaceMesh::convertTriIndices
734 List<pointIndexHit>& info
738 const globalIndex& triIndexer = globalTris();
744 pi.setIndex(triIndexer.toGlobal(
pi.index()));
754 Foam::distributedTriSurfaceMesh::calcLocalQueries
756 const List<pointIndexHit>& info,
764 triangleIndex.setSize(info.size());
766 const globalIndex& triIndexer = globalTris();
782 label proci = triIndexer.whichProcID(info[i].index());
791 sendMap[proci].setSize(nSend[proci]);
800 label proci = triIndexer.whichProcID(info[i].index());
801 triangleIndex[i] = triIndexer.toLocal(proci, info[i].index());
802 sendMap[proci][nSend[proci]++] = i;
806 triangleIndex[i] = -1;
814 autoPtr<mapDistribute> mapPtr(
new mapDistribute(std::move(sendMap)));
820 mapPtr().distribute(triangleIndex);
826 bool Foam::distributedTriSurfaceMesh::contains
828 const List<treeBoundBox>& bbs,
834 if (bbs[bbi].contains(sample))
844 Foam::distributedTriSurfaceMesh::findBestProcs
847 const scalar radiusSqr,
858 procContains =
false;
861 procOverlaps =
false;
865 scalar minDistSqr = radiusSqr;
870 const List<treeBoundBox>& bbs = procBb_[proci];
874 if (bbs[bbi].contains(centre))
879 if (!procContains[proci])
881 procContains[proci] =
true;
886 bbs[bbi].calcExtremities(centre, near, far);
887 minDistSqr =
min(minDistSqr,
magSqr(centre-far));
894 return Tuple2<label, scalar>(nContain, minDistSqr);
898 scalar maxDistSqr = radiusSqr;
905 const List<treeBoundBox>& bbs = procBb_[proci];
909 if (bbs[bbi].overlaps(centre, radiusSqr))
912 bbs[bbi].calcExtremities(centre, near, far);
914 scalar d2 =
magSqr(centre-near);
918 maxDistSqr =
min(radiusSqr,
magSqr(centre-far));
930 procOverlaps[minProci] =
true;
935 if (proci != minProci)
937 const List<treeBoundBox>& bbs = procBb_[proci];
940 if (bbs[bbi].overlaps(centre, maxDistSqr))
942 procOverlaps[proci] =
true;
950 return Tuple2<label, scalar>(nOverlap, maxDistSqr);
955 Foam::label Foam::distributedTriSurfaceMesh::calcOverlappingProcs
958 const scalar radiusSqr,
967 const List<treeBoundBox>& bbs = procBb_[proci];
971 if (bbs[bbi].overlaps(centre, radiusSqr))
973 overlaps[proci] =
true;
987 Foam::distributedTriSurfaceMesh::calcLocalQueries
989 const bool includeLocalProcessor,
1005 DynamicList<point> dynAllCentres(centres.size());
1006 DynamicList<scalar> dynAllRadiusSqr(centres.size());
1008 DynamicList<label> dynAllSegmentMap(centres.size());
1013 forAll(dynSendMap, proci)
1015 dynSendMap[proci].reserve
1029 calcOverlappingProcs
1036 forAll(procBbOverlaps, proci)
1040 procBbOverlaps[proci]
1042 includeLocalProcessor
1047 dynSendMap[proci].append(dynAllCentres.size());
1048 dynAllSegmentMap.append(centrei);
1049 dynAllCentres.append(centres[centrei]);
1050 dynAllRadiusSqr.append(radiusSqr[centrei]);
1059 dynSendMap[proci].shrink();
1060 sendMap[proci].transfer(dynSendMap[proci]);
1063 allCentres.transfer(dynAllCentres);
1064 allRadiusSqr.transfer(dynAllRadiusSqr);
1065 allSegmentMap.transfer(dynAllSegmentMap);
1074 const point& sample,
1075 const point& nearestPoint,
1080 const triSurface& surf =
static_cast<const triSurface&
>(*this);
1090 if (((sample - nearestPoint) &
n) > 0)
1101 Foam::label Foam::distributedTriSurfaceMesh::findOtherFace
1104 const label nearFacei,
1105 const label nearLabel
1108 const triSurface& surf =
static_cast<const triSurface&
>(*this);
1111 const edge
e(nearF[nearLabel], nearF[nearF.fcIndex(nearLabel)]);
1114 for (
const label facei :
pFaces)
1116 if (facei != nearFacei)
1118 int dir = surf[facei].edgeDirection(
e);
1129 void Foam::distributedTriSurfaceMesh::calcFaceFaces
1131 const triSurface&
s,
1136 faceFaces.setSize(
s.size());
1138 DynamicList<label> nbrs;
1142 const labelledTri&
f =
s[facei];
1144 nbrs.reserve(
f.size());
1149 const edge
e(
f[fp],
f[
f.fcIndex(fp)]);
1151 for (
const label otherFacei :
pFaces)
1153 if (otherFacei != facei)
1155 if (
s[otherFacei].edgeDirection(
e) != 0)
1157 if (!nbrs.find(otherFacei))
1159 nbrs.append(otherFacei);
1165 faceFaces[facei] = std::move(nbrs);
1170 void Foam::distributedTriSurfaceMesh::surfaceSide
1173 const List<pointIndexHit>& nearestInfo,
1174 List<volumeType>& volType
1179 Pout<<
"distributedTriSurfaceMesh::surfaceSide :"
1180 <<
" finding surface side given points on surface for "
1187 labelList triangleIndex(nearestInfo.size());
1188 autoPtr<mapDistribute> mapPtr
1196 const mapDistribute& map = mapPtr();
1200 map.distribute(localSamples);
1206 volType.setSize(triangleIndex.size());
1209 const triSurface& surf =
static_cast<const triSurface&
>(*this);
1218 EdgeMap<labelPair> edgeToFaces;
1222 const label facei = triangleIndex[i];
1224 const point& sample = localSamples[i];
1227 label nearType, nearLabel;
1229 f.nearestPointClassify(sample,
points, nearType, nearLabel);
1231 const point& nearestPoint(pHit.rawPoint());
1235 const vector sampleNearestVec = (sample - nearestPoint);
1239 scalar
c = sampleNearestVec & surf[facei].areaNormal(
points);
1257 label otherFacei = findOtherFace(pointFaces, facei, nearLabel);
1258 if (otherFacei != -1)
1261 edgeSide(sample, nearestPoint, facei, otherFacei);
1275 const label pointi =
f[nearLabel];
1277 const vector sampleNearestVec = (sample - nearestPoint);
1281 edgeToFaces.clear();
1283 scalar maxCosAngle = -GREAT;
1286 for (
const label facei :
pFaces)
1290 label fp =
f.find(pointi);
1291 label p1 =
f[
f.fcIndex(fp)];
1292 label pMin1 =
f[
f.rcIndex(fp)];
1302 for (
const edge&
e : edges)
1304 auto iter = edgeToFaces.find(
e);
1307 if (iter().second() == -1)
1310 iter().second() = facei;
1313 scalar magEVec =
mag(eVec);
1315 if (magEVec > VSMALL)
1321 scalar cosAngle(sampleNearestVec&eVec);
1322 if (cosAngle > maxCosAngle)
1324 maxCosAngle = cosAngle;
1325 maxEdgeFaces = iter();
1345 for (
auto iter : edgeToFaces)
1347 if (iter[0] == -1 || iter[1] == -1)
1355 volType[i] = edgeSide
1391 map.constructHasFlip(),
1402 Pout<<
"distributedTriSurfaceMesh::surfaceSide :"
1403 <<
" finished finding surface side given points on surface for "
1409 void Foam::distributedTriSurfaceMesh::collectLeafMids
1412 DynamicField<point>& midPoints
1415 const indexedOctree<treeDataTriSurface>::node& nod = tree().nodes()[nodeI];
1417 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
1419 const labelBits index = nod.subNodes_[octant];
1436 const treeBoundBox subBb = nod.bb_.subBbox(octant);
1437 midPoints.append(subBb.midpoint());
1445 const List<volumeType>& midPointTypes,
1447 PackedList<2>& nodeTypes,
1455 const indexedOctree<treeDataTriSurface>::node& nod = tree().nodes()[nodeI];
1459 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
1463 const labelBits index = nod.subNodes_[octant];
1468 subType = calcVolumeType
1490 subType = midPointTypes[midPointi++];
1494 nodeTypes.set((nodeI<<3)+octant, subType);
1502 else if (subType != myType)
1517 const indexedOctree<treeDataTriSurface>::node& nod = tree().nodes()[nodeI];
1519 direction octant = nod.bb_.subOctant(sample);
1523 tree().nodeTypes().get((nodeI<<3)+octant)
1541 labelBits index = nod.subNodes_[octant];
1546 volumeType subType = cachedVolumeType
1564 <<
"Sample:" << sample <<
" node:" << nodeI
1565 <<
" with bb:" << nod.bb_ <<
nl
1566 <<
"Empty subnode has invalid volume type MIXED."
1575 <<
"Sample:" << sample <<
" at node:" << nodeI
1576 <<
" octant:" << octant
1577 <<
" with bb:" << nod.bb_.subBbox(octant) <<
nl
1578 <<
"Node has invalid volume type " << octantType
1593 Foam::distributedTriSurfaceMesh::independentlyDistributedBbs
1601 "distributedTriSurfaceMesh::independentlyDistributedBbs"
1604 if (!decomposer_.valid())
1609 const auto* dictPtr =
1622 if (!decomposeParDict_.valid())
1624 decomposeParDict_.reset
1653 const globalIndex& triIndexer = globalTris();
1660 if (triIndexer.localSize(proci) != 0)
1672 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1673 <<
" determining master-only decomposition for " <<
s.size()
1681 triCentres[trii] =
s[trii].centre(
s.points());
1685 if (!isA<geomDecomp>(decomposer_()))
1691 calcFaceFaces(
s, pointFaces, faceFaces);
1696 distribution = decomposer_().decompose(faceFaces, triCentres);
1702 distribution = decomposer_().decompose(triCentres);
1707 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1708 <<
" determining processor bounding boxes" <<
endl;
1714 treeBoundBox& bb = bbs[distribution[trii]][0];
1715 bb.add(
s.points(),
s[trii]);
1725 else if (distType_ == DISTRIBUTED)
1729 if (!decomposer_().parallelAware())
1732 <<
"The decomposition method " << decomposer_().typeName
1733 <<
" does not decompose in parallel."
1739 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1740 <<
" determining decomposition for " <<
s.size()
1741 <<
" centroids" <<
endl;
1748 triCentres[trii] =
s[trii].centre(
s.points());
1751 labelList distribution = decomposer_().decompose(triCentres);
1755 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1756 <<
" determining processor bounding boxes for "
1763 treeBoundBox& bb = bbs[distribution[trii]][0];
1764 bb.add(
s.points(),
s[trii]);
1978 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1979 <<
" collecting all centroids" <<
endl;
1987 allCentres[trii] =
s[trii].centre(
s.points());
2015 Pout<<
"distributedTriSurfaceMesh::"
2016 <<
"independentlyDistributedBbs :"
2017 <<
" merged " << allCentres.size()
2018 <<
" centroids down to " << nMerged <<
endl;
2023 UIndirectList<point>(mergedPoints, allToMerged) = allCentres;
2028 labelList mergedDist(decomposer_().decompose(mergedPoints));
2032 allDistribution = UIndirectList<label>
2040 globalTris().scatter
2049 Pout<<
"distributedTriSurfaceMesh::"
2050 <<
"independentlyDistributedBbs :"
2051 <<
" determined decomposition" <<
endl;
2058 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
2059 <<
" determining processor bounding boxes for "
2065 treeBoundBox& bb = bbs[distribution[trii]][0];
2066 bb.add(
s.points(),
s[trii]);
2081 bool Foam::distributedTriSurfaceMesh::overlaps
2083 const List<treeBoundBox>& bbs,
2089 treeBoundBox triBb(
p0);
2095 const treeBoundBox& bb = bbs[bbi];
2101 if (bb.overlaps(triBb))
2104 if (bb.contains(
p0) || bb.contains(p1) || bb.contains(p2))
2125 void Foam::distributedTriSurfaceMesh::subsetMeshMap
2127 const triSurface&
s,
2129 const label nIncluded,
2135 newToOldFaces.setSize(nIncluded);
2136 newToOldPoints.setSize(
s.points().size());
2137 oldToNewPoints.setSize(
s.points().size());
2138 oldToNewPoints = -1;
2143 forAll(include, oldFacei)
2145 if (include[oldFacei])
2148 newToOldFaces[facei++] = oldFacei;
2151 for (
const label oldPointi :
s[oldFacei])
2153 if (oldToNewPoints[oldPointi] == -1)
2155 oldToNewPoints[oldPointi] = pointi;
2156 newToOldPoints[pointi++] = oldPointi;
2161 newToOldPoints.setSize(pointi);
2168 const triSurface&
s,
2176 forAll(newToOldPoints, i)
2178 newPoints[i] =
s.points()[newToOldPoints[i]];
2181 List<labelledTri> newTriangles(newToOldFaces.size());
2186 const labelledTri& tri =
s[newToOldFaces[i]];
2188 newTriangles[i][0] = oldToNewPoints[tri[0]];
2189 newTriangles[i][1] = oldToNewPoints[tri[1]];
2190 newTriangles[i][2] = oldToNewPoints[tri[2]];
2191 newTriangles[i].region() = tri.region();
2195 return triSurface(newTriangles,
s.patches(), newPoints,
true);
2201 const triSurface&
s,
2240 const triSurface&
s,
2247 ListOps::createWithValue<bool>(
s.size(), newToOldFaces,
true,
false)
2250 newToOldPoints.setSize(
s.points().size());
2251 labelList oldToNewPoints(
s.points().size(), -1);
2255 forAll(include, oldFacei)
2257 if (include[oldFacei])
2260 for (
const label oldPointi :
s[oldFacei])
2262 if (oldToNewPoints[oldPointi] == -1)
2264 oldToNewPoints[oldPointi] = pointi;
2265 newToOldPoints[pointi++] = oldPointi;
2270 newToOldPoints.setSize(pointi);
2283 Foam::label Foam::distributedTriSurfaceMesh::findTriangle
2285 const List<labelledTri>& allFaces,
2287 const labelledTri& otherF
2295 const labelledTri&
f = allFaces[
pFaces[i]];
2297 if (
f.region() == otherF.region())
2300 label fp0 =
f.find(otherF[0]);
2302 label fp1 =
f.fcIndex(fp0);
2303 label fp2 =
f.fcIndex(fp1);
2305 if (
f[fp1] == otherF[1] &&
f[fp2] == otherF[2])
2316 void Foam::distributedTriSurfaceMesh::merge
2318 const scalar mergeDist,
2319 const List<labelledTri>& subTris,
2322 List<labelledTri>& allTris,
2345 label allPointi = nOldAllPoints;
2346 forAll(pointConstructMap, pointi)
2348 if (pointConstructMap[pointi] == -1)
2350 pointConstructMap[pointi] = allPointi++;
2354 if (allPointi > nOldAllPoints)
2358 forAll(pointConstructMap, pointi)
2360 if (pointConstructMap[pointi] >= nOldAllPoints)
2362 allPoints[pointConstructMap[pointi]] = subPoints[pointi];
2376 label allTrii = allTris.size();
2377 allTris.setSize(allTrii + subTris.size());
2379 faceConstructMap.setSize(subTris.size());
2383 const labelledTri& subTri = subTris[trii];
2386 labelledTri mappedTri
2388 pointConstructMap[subTri[0]],
2389 pointConstructMap[subTri[1]],
2390 pointConstructMap[subTri[2]],
2396 bool fullMatch =
true;
2400 if (mappedTri[fp] >= nOldAllPoints)
2411 label i = findTriangle
2421 faceConstructMap[trii] = allTrii;
2422 allTris[allTrii] = mappedTri;
2427 faceConstructMap[trii] = i;
2433 faceConstructMap[trii] = allTrii;
2434 allTris[allTrii] = mappedTri;
2438 allTris.setSize(allTrii);
2444 Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh
2466 currentDistType_(FROZEN)
2486 Info<<
'\t' << proci <<
'\t' << nTris[proci]
2487 <<
'\t' << procBb_[proci] <<
endl;
2494 Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh(
const IOobject& io)
2501 findLocalInstance(io),
2533 currentDistType_(FROZEN)
2549 <<
"Read distributedTriSurface " << io.
name()
2550 <<
" from parent path " << actualFile <<
endl;
2573 <<
"Read distributedTriSurface " << io.
name()
2574 <<
" from actual path " << actualFile <<
':' <<
endl;
2584 Info<<
'\t' << proci <<
'\t' << nTris[proci]
2585 <<
'\t' << procBb_[proci] <<
endl;
2593 <<
"Read distributedTriSurface " << io.
name() <<
':' <<
endl;
2599 Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh
2610 findLocalInstance(io),
2643 currentDistType_(FROZEN)
2651 distributionTypeNames_.readIfPresent
2659 dict_.readIfPresent(
"mergeDistance", mergeDist_);
2663 if (dict_.readIfPresent<
bool>(
"closed", closed))
2665 surfaceClosed_ = closed;
2670 "outsideVolumeType",
2684 && (distType_ == INDEPENDENT || distType_ == DISTRIBUTED)
2688 <<
"Read distributedTriSurface " << io.
name()
2689 <<
" from parent path " << actualFile
2690 <<
" and dictionary" <<
endl;
2713 <<
"Read distributedTriSurface " << io.
name()
2714 <<
" from actual path " << actualFile
2715 <<
" and dictionary:" <<
endl;
2725 Info<<
'\t' << proci <<
'\t' << nTris[proci]
2726 <<
'\t' << procBb_[proci] <<
endl;
2734 <<
"Read distributedTriSurface " << io.
name() <<
':' <<
endl;
2750 globalTris_.clear();
2759 if (!globalTris_.valid())
2763 return *globalTris_;
3011 "distributedTriSurfaceMesh::findNearest"
3016 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3017 <<
" trying to find nearest for " <<
samples.size()
3018 <<
" samples with max sphere "
3048 forAll(dynSendMap, proci)
3055 label minProci = -1;
3065 label nContains = 0;
3068 if (procContains[proci])
3071 dynSendMap[proci].
append(samplei);
3072 distSqr[samplei] = best.
second();
3092 dynSendMap[minProci].
append(samplei);
3093 distSqr[samplei] = best.
second();
3101 sendMap[proci].
transfer(dynSendMap[proci]);
3111 <<
" of " <<
samples.size() <<
" samples sending to" <<
endl;
3115 Pout<<
" " << proci <<
"\t" << map1.
subMap()[proci].size()
3117 nSend += map1.
subMap()[proci].size();
3120 <<
" outside\t" << nOutside <<
endl;
3133 convertTriIndices(localInfo);
3137 nearestInfo.
setSize(localInfo.size());
3141 label nIgnoredHit = 0;
3174 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3175 <<
" searched locally for " << localPoints.size()
3176 <<
" samples with max sphere "
3178 <<
" found hits:" << nHit
3179 <<
" of which outside local bb:" << nIgnoredHit
3220 forAll(nearestInfo, samplei)
3246 calcOverlappingProcs(sample, d2, procBbOverlaps);
3248 forAll(procBbOverlaps, proci)
3250 if (procBbOverlaps[proci])
3256 if (proci != hitProci)
3258 dynSendMap[proci].
append(samplei);
3267 sendMap[proci].
transfer(dynSendMap[proci]);
3277 <<
" of " <<
samples.size() <<
" samples sending to" <<
endl;
3281 Pout<<
" " << proci <<
"\t" << map2.
subMap()[proci].size()
3283 nSend += map2.
subMap()[proci].size();
3292 forAll(nearestInfo, samplei)
3295 if (ni.
first().hit())
3297 localDistSqr[samplei] = ni.
second();
3305 convertTriIndices(localInfo);
3310 label nIgnoredHit = 0;
3337 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3338 <<
" searched locally for " << localSamples.size()
3339 <<
" samples with max sphere "
3341 <<
" found hits:" << nHit
3342 <<
" of which outside local bb:" << nIgnoredHit
3368 info[samplei] = ni.
first();
3396 "distributedTriSurfaceMesh::findNearestRegion"
3401 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3402 <<
" trying to find nearest and region for " <<
samples.size()
3403 <<
" samples with max sphere "
3408 if (regionIndices.empty())
3410 findNearest(
samples, nearestDistSqr, info);
3454 convertTriIndices(allInfo);
3458 if (allInfo[i].hit())
3466 allInfo[i].hitPoint()
3475 allInfo[i].setMiss();
3476 allInfo[i].setIndex(-1);
3493 if (allInfo[i].hit())
3495 label pointi = allSegmentMap[i];
3497 if (!info[pointi].hit())
3500 info[pointi] = allInfo[i];
3511 info[pointi] = allInfo[i];
3520 void Foam::distributedTriSurfaceMesh::findLine
3583 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
3584 <<
" intersecting with "
3585 << start.size() <<
" rays" <<
endl;
3591 "distributedTriSurfaceMesh::findLineAll"
3621 +
vector(ROOTVSMALL,ROOTVSMALL,ROOTVSMALL)
3633 if (hitInfo[pointi].hit())
3636 info[pointi][0] = hitInfo[pointi];
3638 point pt = hitInfo[pointi].hitPoint() + smallVec[pointi];
3640 if (((pt-start[pointi])&dirVec[pointi]) <= magSqrDirVec[pointi])
3643 e1[compacti] =
end[pointi];
3644 pointMap[compacti] = pointi;
3650 info[pointi].
clear();
3654 e0.setSize(compacti);
3655 e1.setSize(compacti);
3656 pointMap.setSize(compacti);
3675 if (hitInfo[i].hit())
3677 label pointi = pointMap[i];
3679 label sz = info[pointi].size();
3681 info[pointi][sz] = hitInfo[i];
3683 point pt = hitInfo[i].hitPoint() + smallVec[pointi];
3686 scalar d = ((pt-start[pointi])&dirVec[pointi]);
3690 if (d > 0 && d <= magSqrDirVec[pointi])
3693 e1[compacti] =
end[pointi];
3694 pointMap[compacti] = pointi;
3701 e0.setSize(compacti);
3702 e1.setSize(compacti);
3703 pointMap.setSize(compacti);
3709 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
3710 <<
" Exiting loop due to excessive number of"
3711 <<
" intersections along ray"
3722 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
3723 <<
" finished intersecting with "
3724 << start.size() <<
" rays" <<
endl;
3737 Pout<<
"distributedTriSurfaceMesh::getRegion :"
3738 <<
" getting region for "
3739 << info.size() <<
" triangles" <<
endl;
3742 addProfiling(getRegion,
"distributedTriSurfaceMesh::getRegion");
3751 region[i] = triSurface::operator[](info[i].index()).region();
3761 Pout<<
"distributedTriSurfaceMesh::getRegion :"
3762 <<
" finished getting region for "
3763 << info.size() <<
" triangles" <<
endl;
3789 region.
setSize(triangleIndex.size());
3793 label trii = triangleIndex[i];
3794 region[i] =
s[trii].region();
3805 Pout<<
"distributedTriSurfaceMesh::getRegion :"
3806 <<
" finished getting region for "
3807 << info.size() <<
" triangles" <<
endl;
3826 Pout<<
"distributedTriSurfaceMesh::getNormal :"
3827 <<
" getting normal for "
3828 << info.size() <<
" triangles" <<
endl;
3831 addProfiling(getNormal,
"distributedTriSurfaceMesh::getNormal");
3854 normal.setSize(triangleIndex.size());
3858 label trii = triangleIndex[i];
3859 normal[i] =
s[trii].unitNormal(
s.points());
3870 Pout<<
"distributedTriSurfaceMesh::getNormal :"
3871 <<
" finished getting normal for "
3872 << info.size() <<
" triangles" <<
endl;
3959 if (!hasVolumeType())
3962 <<
"Volume type only supported for closed distributed surfaces."
3974 "distributedTriSurfaceMesh::getCachedVolumeType"
3978 const point outsidePt(bounds().
max() + 0.5*bounds().span());
3981 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
3982 <<
" triggering outsidePoint" << outsidePt
3983 <<
" orientation" <<
endl;
3996 surfaceSide(outsidePts, nearestInfo, outsideVolTypes);
3997 outsideVolType_ = outsideVolTypes[0];
4001 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4002 <<
" determined outsidePoint" << outsidePt
4022 collectLeafMids(0, midPoints);
4026 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4027 <<
" triggering orientation caching for "
4028 << midPoints.size() <<
" leaf mids" <<
endl;
4033 getVolumeType(midPoints, midVolTypes);
4046 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4047 <<
" done orientation caching for "
4048 << midPoints.size() <<
" leaf mids" <<
endl;
4056 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4057 <<
" finding orientation for " <<
samples.size()
4058 <<
" samples" <<
endl;
4064 "distributedTriSurfaceMesh::getVolumeType"
4083 if (contains(procBb_[proci],
samples[samplei]))
4096 outsideSamples.
append(samplei);
4102 sendMap[proci].
setSize(nSend[proci]);
4112 if (contains(procBb_[proci],
samples[samplei]))
4115 procSend[nSend[proci]++] = samplei;
4129 volType.
setSize(localPoints.size());
4138 volType[i] = cachedVolumeType(0, localPoints[i]);
4141 fullSearchMap.append(i);
4142 fullSearchPoints.append(localPoints[i]);
4148 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4149 <<
" original samples:" <<
samples.size()
4150 <<
" resulting in local queries:"
4151 << localPoints.size()
4152 <<
" of which cached:" << localPoints.size()-fullSearchPoints.size()
4167 surfaceSide(fullSearchPoints, nearestInfo, fullSearchType);
4172 volType[fullSearchMap[i]] = fullSearchType[i];
4195 for (label samplei : outsideSamples)
4197 volType[samplei] = outsideVolType_;
4202 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4203 <<
" finished finding orientation for " <<
samples.size()
4204 <<
" samples" <<
endl;
4223 Pout<<
"distributedTriSurfaceMesh::getField :"
4224 <<
" retrieving field for "
4225 << info.size() <<
" triangles" <<
endl;
4230 const auto* fldPtr = findObject<triSurfaceLabelField>(
"values");
4254 values.setSize(triangleIndex.size());
4258 label trii = triangleIndex[i];
4271 Pout<<
"distributedTriSurfaceMesh::getField :"
4272 <<
" finished retrieving field for "
4273 << info.size() <<
" triangles" <<
endl;
4287 includedFace =
false;
4291 const scalar eps = 1.0e-4;
4294 const point mid = bbs[i].centre();
4295 const vector halfSpan = (1.0+eps)*(bbs[i].
max() - mid);
4297 bbsX[i].
min() = mid - halfSpan;
4298 bbsX[i].
max() = mid + halfSpan;
4305 const point& p1 =
s.points()[
f[1]];
4306 const point& p2 =
s.points()[
f[2]];
4308 if (overlaps(bbsX,
p0, p1, p2))
4310 includedFace[trii] =
true;
4328 overlappingSurface(
s, bbs, includedFace);
4329 return subsetMesh(
s, includedFace, subPointMap, subFaceMap);
4343 triangleIndex.
setSize(info.size());
4361 label proci = triIndexer.
whichProcID(info[i].index());
4370 sendMap[proci].
setSize(nSend[proci]);
4379 label proci = triIndexer.
whichProcID(info[i].index());
4380 triangleIndex[i] = triIndexer.
toLocal(proci, info[i].index());
4381 sendMap[proci][nSend[proci]++] = i;
4385 triangleIndex[i] = -1;
4415 forAll(constructMap, proci)
4421 constructMap[proci].
setSize(nRecv);
4423 for (label i = 0; i < nRecv; i++)
4425 constructMap[proci][i] = segmenti++;
4440 std::move(constructMap)
4458 const bool keepNonLocal,
4470 Pout<<
"distributedTriSurfaceMesh::distribute :"
4471 <<
" distributing surface according to method:"
4472 << distributionTypeNames_[distType_]
4476 addProfiling(distribute,
"distributedTriSurfaceMesh::distribute");
4499 if (currentDistType_ == distType_)
4503 newProcBb = independentlyDistributedBbs(*
this);
4516 if (newProcBb == procBb_)
4522 procBb_.transfer(newProcBb);
4537 <<
"before distribution:" <<
endl <<
"\tproc\ttris" <<
endl;
4541 Info<<
'\t' << proci <<
'\t' << nTris[proci] <<
endl;
4559 pointSendMap[proci],
4573 forAll(faceSendMap, proci)
4577 forAll(faceSendMap[proci], i)
4579 includedFace[faceSendMap[proci][i]] =
false;
4635 allTris = subSurface;
4655 forAll(faceSendMap, proci)
4659 if (faceSendMap[proci].size() > 0)
4684 forAll(faceRecvSizes, proci)
4688 if (faceRecvSizes[proci] > 0)
4704 faceConstructMap[proci],
4705 pointConstructMap[proci]
4717 std::move(faceSendMap),
4718 std::move(faceConstructMap)
4726 std::move(pointSendMap),
4727 std::move(pointConstructMap)
4740 currentDistType_ = distType_;
4745 distributeFields<label>(
faceMap());
4746 distributeFields<scalar>(
faceMap());
4747 distributeFields<vector>(
faceMap());
4748 distributeFields<sphericalTensor>(
faceMap());
4749 distributeFields<symmTensor>(
faceMap());
4750 distributeFields<tensor>(
faceMap());
4760 <<
"after distribution:" <<
endl <<
"\tproc\ttris" <<
endl;
4764 Info<<
'\t' << proci <<
'\t' << nTris[proci] <<
endl;
4771 Info<<
"Writing local bounding box to " << str.
name() <<
endl;
4779 const edge&
e = es[ei];
4787 Info<<
"Writing all bounding boxes to " << str.
name() <<
endl;
4788 for (
auto myBbs : procBb_)
4796 const edge&
e = es[ei];
4806 Pout<<
"distributedTriSurfaceMesh::distribute :"
4807 <<
" done distributing surface according to method:"
4808 << distributionTypeNames_[distType_]
4822 Pout<<
"distributedTriSurfaceMesh::writeObject :"
4823 <<
" writing surface valid:" << valid <<
endl;
4851 bool ok = dict_.writeObject(streamOpt,
true);
4855 Pout<<
"distributedTriSurfaceMesh::writeObject :"
4856 <<
" done writing surface" <<
endl;
4873 <<
"Bounding Box : " << bb <<
endl
4874 <<
"Closed : " << surfaceClosed_ <<
endl
4876 <<
"Distribution : " << distributionTypeNames_[distType_] <<
endl;