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);
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];
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(),
1404 Pout<<
"distributedTriSurfaceMesh::surfaceSide :"
1405 <<
" finished finding surface side given points on surface for "
1411 void Foam::distributedTriSurfaceMesh::collectLeafMids
1414 DynamicField<point>& midPoints
1417 const indexedOctree<treeDataTriSurface>::node& nod = tree().nodes()[nodeI];
1419 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
1421 const labelBits index = nod.subNodes_[octant];
1438 const treeBoundBox subBb = nod.bb_.subBbox(octant);
1439 midPoints.append(subBb.midpoint());
1447 const List<volumeType>& midPointTypes,
1449 PackedList<2>& nodeTypes,
1457 const indexedOctree<treeDataTriSurface>::node& nod = tree().nodes()[nodeI];
1461 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
1465 const labelBits index = nod.subNodes_[octant];
1470 subType = calcVolumeType
1492 subType = midPointTypes[midPointi++];
1496 nodeTypes.set((nodeI<<3)+octant, subType);
1504 else if (subType != myType)
1519 const indexedOctree<treeDataTriSurface>::node& nod = tree().nodes()[nodeI];
1525 tree().nodeTypes().
get((nodeI<<3)+octant)
1543 labelBits index = nod.subNodes_[octant];
1548 volumeType subType = cachedVolumeType
1566 <<
"Sample:" <<
sample <<
" node:" << nodeI
1567 <<
" with bb:" << nod.bb_ <<
nl
1568 <<
"Empty subnode has invalid volume type MIXED."
1577 <<
"Sample:" <<
sample <<
" at node:" << nodeI
1578 <<
" octant:" << octant
1579 <<
" with bb:" << nod.bb_.subBbox(octant) <<
nl
1580 <<
"Node has invalid volume type " << octantType
1595 Foam::distributedTriSurfaceMesh::independentlyDistributedBbs
1603 "distributedTriSurfaceMesh::independentlyDistributedBbs"
1611 const auto* dictPtr =
1624 if (!decomposeParDict_)
1626 decomposeParDict_.reset
1655 const globalIndex& triIndexer = globalTris();
1662 if (triIndexer.localSize(proci) != 0)
1674 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1675 <<
" determining master-only decomposition for " <<
s.size()
1683 triCentres[trii] =
s[trii].centre(
s.points());
1687 if (!isA<geomDecomp>(decomposer_()))
1693 calcFaceFaces(
s, pointFaces, faceFaces);
1697 distribution = decomposer_().decompose(faceFaces, triCentres);
1703 distribution = decomposer_().decompose(triCentres);
1708 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1709 <<
" determining processor bounding boxes" <<
endl;
1715 treeBoundBox& bb = bbs[distribution[trii]][0];
1716 bb.add(
s.points(),
s[trii]);
1726 else if (distType_ == DISTRIBUTED)
1730 if (!decomposer_().parallelAware())
1733 <<
"The decomposition method " << decomposer_().typeName
1734 <<
" does not decompose in parallel."
1740 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1741 <<
" determining decomposition for " <<
s.size()
1742 <<
" centroids" <<
endl;
1749 triCentres[trii] =
s[trii].centre(
s.points());
1752 labelList distribution = decomposer_().decompose(triCentres);
1756 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1757 <<
" determining processor bounding boxes for "
1764 treeBoundBox& bb = bbs[distribution[trii]][0];
1765 bb.add(
s.points(),
s[trii]);
1979 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1980 <<
" collecting all centroids" <<
endl;
1988 allCentres[trii] =
s[trii].centre(
s.points());
2016 Pout<<
"distributedTriSurfaceMesh::"
2017 <<
"independentlyDistributedBbs :"
2018 <<
" merged " << allCentres.size()
2019 <<
" centroids down to " << nMerged <<
endl;
2024 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();
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
3222 forAll(nearestInfo, samplei)
3248 calcOverlappingProcs(
sample, d2, procBbOverlaps);
3250 forAll(procBbOverlaps, proci)
3252 if (procBbOverlaps[proci])
3258 if (proci != hitProci)
3260 dynSendMap[proci].
append(samplei);
3269 sendMap[proci].
transfer(dynSendMap[proci]);
3279 <<
" of " <<
samples.size() <<
" samples sending to" <<
endl;
3283 Pout<<
" " << proci <<
"\t" << map2.
subMap()[proci].size()
3285 nSend += map2.
subMap()[proci].size();
3294 forAll(nearestInfo, samplei)
3297 if (ni.
first().hit())
3299 localDistSqr[samplei] = ni.
second();
3307 convertTriIndices(localInfo);
3312 label nIgnoredHit = 0;
3339 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3340 <<
" searched locally for " << localSamples.size()
3341 <<
" samples with max sphere "
3343 <<
" found hits:" << nHit
3344 <<
" of which outside local bb:" << nIgnoredHit
3372 info[samplei] = ni.
first();
3400 "distributedTriSurfaceMesh::findNearestRegion"
3405 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3406 <<
" trying to find nearest and region for " <<
samples.size()
3407 <<
" samples with max sphere "
3412 if (regionIndices.empty())
3414 findNearest(
samples, nearestDistSqr, info);
3458 convertTriIndices(allInfo);
3462 if (allInfo[i].hit())
3470 allInfo[i].hitPoint()
3479 allInfo[i].setMiss();
3480 allInfo[i].setIndex(-1);
3497 if (allInfo[i].hit())
3499 label pointi = allSegmentMap[i];
3501 if (!info[pointi].hit())
3504 info[pointi] = allInfo[i];
3515 info[pointi] = allInfo[i];
3524 void Foam::distributedTriSurfaceMesh::findLine
3587 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
3588 <<
" intersecting with "
3589 << start.size() <<
" rays" <<
endl;
3595 "distributedTriSurfaceMesh::findLineAll"
3625 +
vector(ROOTVSMALL,ROOTVSMALL,ROOTVSMALL)
3637 if (hitInfo[pointi].hit())
3640 info[pointi][0] = hitInfo[pointi];
3642 point pt = hitInfo[pointi].hitPoint() + smallVec[pointi];
3644 if (((pt-start[pointi])&dirVec[pointi]) <= magSqrDirVec[pointi])
3647 e1[compacti] =
end[pointi];
3648 pointMap[compacti] = pointi;
3654 info[pointi].
clear();
3658 e0.setSize(compacti);
3659 e1.setSize(compacti);
3660 pointMap.setSize(compacti);
3679 if (hitInfo[i].hit())
3681 label pointi = pointMap[i];
3683 label sz = info[pointi].size();
3685 info[pointi][sz] = hitInfo[i];
3687 point pt = hitInfo[i].hitPoint() + smallVec[pointi];
3690 scalar d = ((pt-start[pointi])&dirVec[pointi]);
3694 if (d > 0 && d <= magSqrDirVec[pointi])
3697 e1[compacti] =
end[pointi];
3698 pointMap[compacti] = pointi;
3705 e0.setSize(compacti);
3706 e1.setSize(compacti);
3707 pointMap.setSize(compacti);
3713 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
3714 <<
" Exiting loop due to excessive number of"
3715 <<
" intersections along ray"
3726 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
3727 <<
" finished intersecting with "
3728 << start.size() <<
" rays" <<
endl;
3741 Pout<<
"distributedTriSurfaceMesh::getRegion :"
3742 <<
" getting region for "
3743 << info.size() <<
" triangles" <<
endl;
3746 addProfiling(getRegion,
"distributedTriSurfaceMesh::getRegion");
3755 region[i] = triSurface::operator[](info[i].index()).region();
3765 Pout<<
"distributedTriSurfaceMesh::getRegion :"
3766 <<
" finished getting region for "
3767 << info.size() <<
" triangles" <<
endl;
3793 region.
setSize(triangleIndex.size());
3797 label trii = triangleIndex[i];
3798 region[i] =
s[trii].region();
3809 Pout<<
"distributedTriSurfaceMesh::getRegion :"
3810 <<
" finished getting region for "
3811 << info.size() <<
" triangles" <<
endl;
3830 Pout<<
"distributedTriSurfaceMesh::getNormal :"
3831 <<
" getting normal for "
3832 << info.size() <<
" triangles" <<
endl;
3835 addProfiling(getNormal,
"distributedTriSurfaceMesh::getNormal");
3858 normal.setSize(triangleIndex.size());
3862 label trii = triangleIndex[i];
3863 normal[i] =
s[trii].unitNormal(
s.points());
3874 Pout<<
"distributedTriSurfaceMesh::getNormal :"
3875 <<
" finished getting normal for "
3876 << info.size() <<
" triangles" <<
endl;
3963 if (!hasVolumeType())
3966 <<
"Volume type only supported for closed distributed surfaces."
3978 "distributedTriSurfaceMesh::getCachedVolumeType"
3982 const point outsidePt(bounds().
max() + 0.5*bounds().span());
3985 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
3986 <<
" triggering outsidePoint" << outsidePt
3987 <<
" orientation" <<
endl;
4000 surfaceSide(outsidePts, nearestInfo, outsideVolTypes);
4001 outsideVolType_ = outsideVolTypes[0];
4005 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4006 <<
" determined outsidePoint" << outsidePt
4026 collectLeafMids(0, midPoints);
4030 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4031 <<
" triggering orientation caching for "
4032 << midPoints.size() <<
" leaf mids" <<
endl;
4037 getVolumeType(midPoints, midVolTypes);
4050 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4051 <<
" done orientation caching for "
4052 << midPoints.size() <<
" leaf mids" <<
endl;
4060 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4061 <<
" finding orientation for " <<
samples.size()
4062 <<
" samples" <<
endl;
4068 "distributedTriSurfaceMesh::getVolumeType"
4087 if (contains(procBb_[proci],
samples[samplei]))
4100 outsideSamples.
append(samplei);
4106 sendMap[proci].
setSize(nSend[proci]);
4116 if (contains(procBb_[proci],
samples[samplei]))
4119 procSend[nSend[proci]++] = samplei;
4133 volType.
setSize(localPoints.size());
4142 volType[i] = cachedVolumeType(0, localPoints[i]);
4145 fullSearchMap.append(i);
4146 fullSearchPoints.append(localPoints[i]);
4152 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4153 <<
" original samples:" <<
samples.size()
4154 <<
" resulting in local queries:"
4155 << localPoints.size()
4156 <<
" of which cached:" << localPoints.size()-fullSearchPoints.size()
4171 surfaceSide(fullSearchPoints, nearestInfo, fullSearchType);
4176 volType[fullSearchMap[i]] = fullSearchType[i];
4201 for (label samplei : outsideSamples)
4203 volType[samplei] = outsideVolType_;
4208 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4209 <<
" finished finding orientation for " <<
samples.size()
4210 <<
" samples" <<
endl;
4229 Pout<<
"distributedTriSurfaceMesh::getField :"
4230 <<
" retrieving field for "
4231 << info.size() <<
" triangles" <<
endl;
4236 const auto* fldPtr = findObject<triSurfaceLabelField>(
"values");
4260 values.setSize(triangleIndex.size());
4264 label trii = triangleIndex[i];
4277 Pout<<
"distributedTriSurfaceMesh::getField :"
4278 <<
" finished retrieving field for "
4279 << info.size() <<
" triangles" <<
endl;
4293 includedFace =
false;
4297 const scalar eps = 1.0e-4;
4300 const point mid = bbs[i].centre();
4301 const vector halfSpan = (1.0+eps)*(bbs[i].
max() - mid);
4303 bbsX[i].
min() = mid - halfSpan;
4304 bbsX[i].
max() = mid + halfSpan;
4311 const point& p1 =
s.points()[
f[1]];
4312 const point& p2 =
s.points()[
f[2]];
4314 if (overlaps(bbsX,
p0, p1, p2))
4316 includedFace[trii] =
true;
4334 overlappingSurface(
s, bbs, includedFace);
4335 return subsetMesh(
s, includedFace, subPointMap, subFaceMap);
4349 triangleIndex.
setSize(info.size());
4367 label proci = triIndexer.
whichProcID(info[i].index());
4376 sendMap[proci].
setSize(nSend[proci]);
4385 label proci = triIndexer.
whichProcID(info[i].index());
4386 triangleIndex[i] = triIndexer.
toLocal(proci, info[i].index());
4387 sendMap[proci][nSend[proci]++] = i;
4391 triangleIndex[i] = -1;
4421 forAll(constructMap, proci)
4427 constructMap[proci].
setSize(nRecv);
4429 for (label i = 0; i < nRecv; i++)
4431 constructMap[proci][i] = segmenti++;
4446 std::move(constructMap)
4464 const bool keepNonLocal,
4476 Pout<<
"distributedTriSurfaceMesh::distribute :"
4477 <<
" distributing surface according to method:"
4478 << distributionTypeNames_[distType_]
4482 addProfiling(distribute,
"distributedTriSurfaceMesh::distribute");
4505 if (currentDistType_ == distType_)
4509 newProcBb = independentlyDistributedBbs(*
this);
4522 if (newProcBb == procBb_)
4528 procBb_.transfer(newProcBb);
4543 <<
"before distribution:" <<
endl <<
"\tproc\ttris" <<
endl;
4547 Info<<
'\t' << proci <<
'\t' << nTris[proci] <<
endl;
4565 pointSendMap[proci],
4579 forAll(faceSendMap, proci)
4583 forAll(faceSendMap[proci], i)
4585 includedFace[faceSendMap[proci][i]] =
false;
4641 allTris = subSurface;
4661 forAll(faceSendMap, proci)
4665 if (faceSendMap[proci].size() > 0)
4690 forAll(faceRecvSizes, proci)
4694 if (faceRecvSizes[proci] > 0)
4710 faceConstructMap[proci],
4711 pointConstructMap[proci]
4723 std::move(faceSendMap),
4724 std::move(faceConstructMap)
4732 std::move(pointSendMap),
4733 std::move(pointConstructMap)
4746 currentDistType_ = distType_;
4751 distributeFields<label>(
faceMap());
4752 distributeFields<scalar>(
faceMap());
4753 distributeFields<vector>(
faceMap());
4754 distributeFields<sphericalTensor>(
faceMap());
4755 distributeFields<symmTensor>(
faceMap());
4756 distributeFields<tensor>(
faceMap());
4766 <<
"after distribution:" <<
endl <<
"\tproc\ttris" <<
endl;
4770 Info<<
'\t' << proci <<
'\t' << nTris[proci] <<
endl;
4777 Info<<
"Writing local bounding box to " << str.
name() <<
endl;
4785 const edge&
e = es[ei];
4793 Info<<
"Writing all bounding boxes to " << str.
name() <<
endl;
4794 for (
auto myBbs : procBb_)
4802 const edge&
e = es[ei];
4812 Pout<<
"distributedTriSurfaceMesh::distribute :"
4813 <<
" done distributing surface according to method:"
4814 << distributionTypeNames_[distType_]
4828 Pout<<
"distributedTriSurfaceMesh::writeObject :"
4829 <<
" writing surface valid:" << valid <<
endl;
4857 bool ok = dict_.writeObject(streamOpt,
true);
4861 Pout<<
"distributedTriSurfaceMesh::writeObject :"
4862 <<
" done writing surface" <<
endl;
4879 <<
"Bounding Box : " << bb <<
endl
4880 <<
"Closed : " << surfaceClosed_ <<
endl
4882 <<
"Distribution : " << distributionTypeNames_[distType_] <<
endl;