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];
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 "
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)
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)]);
1117 if (facei != nearFacei)
1121 int dir =
f.edgeDirection(
e);
1132 void Foam::distributedTriSurfaceMesh::calcFaceFaces
1134 const triSurface&
s,
1139 faceFaces.setSize(
s.size());
1141 DynamicList<label> nbrs;
1145 const labelledTri&
f =
s[facei];
1147 nbrs.reserve(
f.size());
1152 const edge
e(
f[fp],
f[
f.fcIndex(fp)]);
1157 if (otherFacei != facei)
1159 if (
s[otherFacei].edgeDirection(
e) != 0)
1161 if (!nbrs.find(otherFacei))
1163 nbrs.append(otherFacei);
1169 faceFaces[facei] = std::move(nbrs);
1174 void Foam::distributedTriSurfaceMesh::surfaceSide
1177 const List<pointIndexHit>& nearestInfo,
1178 List<volumeType>& volType
1183 Pout<<
"distributedTriSurfaceMesh::surfaceSide :"
1184 <<
" finding surface side given points on surface for "
1191 labelList triangleIndex(nearestInfo.size());
1192 autoPtr<mapDistribute> mapPtr
1200 const mapDistribute& map = mapPtr();
1204 map.distribute(localSamples);
1210 volType.setSize(triangleIndex.size());
1213 const triSurface& surf =
static_cast<const triSurface&
>(*this);
1222 EdgeMap<labelPair> edgeToFaces;
1226 label facei = triangleIndex[i];
1228 const point& sample = localSamples[i];
1231 label nearType, nearLabel;
1233 f.nearestPointClassify(sample,
points, nearType, nearLabel);
1235 const point& nearestPoint(pHit.rawPoint());
1239 const vector sampleNearestVec = (sample - nearestPoint);
1243 scalar
c = sampleNearestVec & surf[facei].areaNormal(
points);
1261 label otherFacei = findOtherFace(pointFaces, facei, nearLabel);
1262 if (otherFacei != -1)
1265 edgeSide(sample, nearestPoint, facei, otherFacei);
1279 const label pointi =
f[nearLabel];
1281 const vector sampleNearestVec = (sample - nearestPoint);
1285 edgeToFaces.clear();
1287 scalar maxCosAngle = -GREAT;
1295 label fp =
f.find(pointi);
1297 label pMin1 =
f[
f.rcIndex(fp)];
1307 for (
const edge&
e : edges)
1309 auto iter = edgeToFaces.find(
e);
1312 if (iter().second() == -1)
1315 iter().second() = facei;
1318 scalar magEVec =
mag(eVec);
1320 if (magEVec > VSMALL)
1326 scalar cosAngle(sampleNearestVec&eVec);
1327 if (cosAngle > maxCosAngle)
1329 maxCosAngle = cosAngle;
1330 maxEdgeFaces = iter();
1350 for (
auto iter : edgeToFaces)
1352 if (iter[0] == -1 || iter[1] == -1)
1360 volType[i] = edgeSide
1396 map.constructHasFlip(),
1407 Pout<<
"distributedTriSurfaceMesh::surfaceSide :"
1408 <<
" finished finding surface side given points on surface for "
1414 void Foam::distributedTriSurfaceMesh::collectLeafMids
1417 DynamicField<point>& midPoints
1420 const indexedOctree<treeDataTriSurface>::node& nod = tree().nodes()[nodeI];
1422 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
1424 const labelBits index = nod.subNodes_[octant];
1441 const treeBoundBox subBb = nod.bb_.subBbox(octant);
1442 midPoints.append(subBb.midpoint());
1450 const List<volumeType>& midPointTypes,
1452 PackedList<2>& nodeTypes,
1460 const indexedOctree<treeDataTriSurface>::node& nod = tree().nodes()[nodeI];
1464 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
1468 const labelBits index = nod.subNodes_[octant];
1473 subType = calcVolumeType
1495 subType = midPointTypes[midPointi++];
1499 nodeTypes.set((nodeI<<3)+octant, subType);
1507 else if (subType != myType)
1522 const indexedOctree<treeDataTriSurface>::node& nod = tree().nodes()[nodeI];
1524 direction octant = nod.bb_.subOctant(sample);
1528 tree().nodeTypes().get((nodeI<<3)+octant)
1546 labelBits index = nod.subNodes_[octant];
1551 volumeType subType = cachedVolumeType
1569 <<
"Sample:" << sample <<
" node:" << nodeI
1570 <<
" with bb:" << nod.bb_ <<
nl
1571 <<
"Empty subnode has invalid volume type MIXED."
1580 <<
"Sample:" << sample <<
" at node:" << nodeI
1581 <<
" octant:" << octant
1582 <<
" with bb:" << nod.bb_.subBbox(octant) <<
nl
1583 <<
"Node has invalid volume type " << octantType
1598 Foam::distributedTriSurfaceMesh::independentlyDistributedBbs
1606 "distributedTriSurfaceMesh::independentlyDistributedBbs"
1609 if (!decomposer_.valid())
1614 const auto* dictPtr =
1627 if (!decomposeParDict_.valid())
1629 decomposeParDict_.reset
1658 const globalIndex& triIndexer = globalTris();
1665 if (triIndexer.localSize(proci) != 0)
1677 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1678 <<
" determining master-only decomposition for " <<
s.size()
1686 triCentres[trii] =
s[trii].centre(
s.points());
1690 if (!isA<geomDecomp>(decomposer_()))
1696 calcFaceFaces(
s, pointFaces, faceFaces);
1701 distribution = decomposer_().decompose(faceFaces, triCentres);
1707 distribution = decomposer_().decompose(triCentres);
1712 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1713 <<
" determining processor bounding boxes" <<
endl;
1721 treeBoundBox& bb = bbs[distribution[trii]][0];
1722 bb.add(
s.points(),
f);
1732 else if (distType_ == DISTRIBUTED)
1736 if (!decomposer_().parallelAware())
1739 <<
"The decomposition method " << decomposer_().typeName
1740 <<
" does not decompose in parallel."
1746 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1747 <<
" determining decomposition for " <<
s.size()
1748 <<
" centroids" <<
endl;
1755 triCentres[trii] =
s[trii].centre(
s.points());
1758 labelList distribution = decomposer_().decompose(triCentres);
1762 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1763 <<
" determining processor bounding boxes for "
1772 treeBoundBox& bb = bbs[distribution[trii]][0];
1773 bb.add(
s.points(),
f);
1989 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
1990 <<
" collecting all centroids" <<
endl;
1998 allCentres[trii] =
s[trii].centre(
s.points());
2026 Pout<<
"distributedTriSurfaceMesh::"
2027 <<
"independentlyDistributedBbs :"
2028 <<
" merged " << allCentres.size()
2029 <<
" centroids down to " << nMerged <<
endl;
2034 UIndirectList<point>(mergedPoints, allToMerged) = allCentres;
2039 labelList mergedDist(decomposer_().decompose(mergedPoints));
2043 allDistribution = UIndirectList<label>
2051 globalTris().scatter
2060 Pout<<
"distributedTriSurfaceMesh::"
2061 <<
"independentlyDistributedBbs :"
2062 <<
" determined decomposition" <<
endl;
2069 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
2070 <<
" determining processor bounding boxes for "
2077 treeBoundBox& bb = bbs[distribution[trii]][0];
2078 bb.add(
s.points(),
f);
2093 bool Foam::distributedTriSurfaceMesh::overlaps
2095 const List<treeBoundBox>& bbs,
2101 treeBoundBox triBb(
p0);
2107 const treeBoundBox& bb = bbs[bbi];
2113 if (bb.overlaps(triBb))
2116 if (bb.contains(
p0) || bb.contains(p1) || bb.contains(p2))
2137 void Foam::distributedTriSurfaceMesh::subsetMeshMap
2139 const triSurface&
s,
2141 const label nIncluded,
2147 newToOldFaces.setSize(nIncluded);
2148 newToOldPoints.setSize(
s.points().size());
2149 oldToNewPoints.setSize(
s.points().size());
2150 oldToNewPoints = -1;
2155 forAll(include, oldFacei)
2157 if (include[oldFacei])
2160 newToOldFaces[facei++] = oldFacei;
2169 if (oldToNewPoints[oldPointi] == -1)
2171 oldToNewPoints[oldPointi] = pointi;
2172 newToOldPoints[pointi++] = oldPointi;
2177 newToOldPoints.
setSize(pointi);
2184 const triSurface&
s,
2192 forAll(newToOldPoints, i)
2194 newPoints[i] =
s.points()[newToOldPoints[i]];
2197 List<labelledTri> newTriangles(newToOldFaces.size());
2202 const labelledTri& tri =
s[newToOldFaces[i]];
2204 newTriangles[i][0] = oldToNewPoints[tri[0]];
2205 newTriangles[i][1] = oldToNewPoints[tri[1]];
2206 newTriangles[i][2] = oldToNewPoints[tri[2]];
2207 newTriangles[i].region() = tri.region();
2211 return triSurface(newTriangles,
s.patches(), newPoints,
true);
2217 const triSurface&
s,
2256 const triSurface&
s,
2263 ListOps::createWithValue<bool>(
s.size(), newToOldFaces,
true,
false)
2266 newToOldPoints.setSize(
s.points().size());
2267 labelList oldToNewPoints(
s.points().size(), -1);
2271 forAll(include, oldFacei)
2273 if (include[oldFacei])
2282 if (oldToNewPoints[oldPointi] == -1)
2284 oldToNewPoints[oldPointi] = pointi;
2285 newToOldPoints[pointi++] = oldPointi;
2290 newToOldPoints.
setSize(pointi);
2303 Foam::label Foam::distributedTriSurfaceMesh::findTriangle
2305 const List<labelledTri>& allFaces,
2307 const labelledTri& otherF
2315 const labelledTri&
f = allFaces[
pFaces[i]];
2317 if (
f.region() == otherF.region())
2320 label fp0 =
f.find(otherF[0]);
2322 label fp1 =
f.fcIndex(fp0);
2323 label fp2 =
f.fcIndex(fp1);
2325 if (
f[fp1] == otherF[1] &&
f[fp2] == otherF[2])
2336 void Foam::distributedTriSurfaceMesh::merge
2338 const scalar mergeDist,
2339 const List<labelledTri>& subTris,
2342 List<labelledTri>& allTris,
2365 label allPointi = nOldAllPoints;
2366 forAll(pointConstructMap, pointi)
2368 if (pointConstructMap[pointi] == -1)
2370 pointConstructMap[pointi] = allPointi++;
2374 if (allPointi > nOldAllPoints)
2378 forAll(pointConstructMap, pointi)
2380 if (pointConstructMap[pointi] >= nOldAllPoints)
2382 allPoints[pointConstructMap[pointi]] = subPoints[pointi];
2396 label allTrii = allTris.size();
2397 allTris.setSize(allTrii + subTris.size());
2399 faceConstructMap.setSize(subTris.size());
2403 const labelledTri& subTri = subTris[trii];
2406 labelledTri mappedTri
2408 pointConstructMap[subTri[0]],
2409 pointConstructMap[subTri[1]],
2410 pointConstructMap[subTri[2]],
2416 bool fullMatch =
true;
2420 if (mappedTri[fp] >= nOldAllPoints)
2431 label i = findTriangle
2441 faceConstructMap[trii] = allTrii;
2442 allTris[allTrii] = mappedTri;
2447 faceConstructMap[trii] = i;
2453 faceConstructMap[trii] = allTrii;
2454 allTris[allTrii] = mappedTri;
2458 allTris.setSize(allTrii);
2464 Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh
2486 currentDistType_(FROZEN)
2506 Info<<
'\t' << proci <<
'\t' << nTris[proci]
2507 <<
'\t' << procBb_[proci] <<
endl;
2514 Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh(
const IOobject& io)
2521 findLocalInstance(io),
2553 currentDistType_(FROZEN)
2571 <<
" from parent path " << actualFile <<
endl;
2595 <<
" from actual path " << actualFile <<
':' <<
endl;
2605 Info<<
'\t' << proci <<
'\t' << nTris[proci]
2606 <<
'\t' << procBb_[proci] <<
endl;
2620 Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh
2631 findLocalInstance(io),
2664 currentDistType_(FROZEN)
2672 distributionTypeNames_.readIfPresent
2680 dict_.readIfPresent(
"mergeDistance", mergeDist_);
2684 if (dict_.readIfPresent<
bool>(
"closed", closed))
2686 surfaceClosed_ = closed;
2691 "outsideVolumeType",
2705 && (distType_ == INDEPENDENT || distType_ == DISTRIBUTED)
2711 <<
" from parent path " << actualFile
2712 <<
" and dictionary" <<
endl;
2736 <<
" from actual path " << actualFile
2737 <<
" and dictionary:" <<
endl;
2747 Info<<
'\t' << proci <<
'\t' << nTris[proci]
2748 <<
'\t' << procBb_[proci] <<
endl;
2772 globalTris_.clear();
2781 if (!globalTris_.valid())
2785 return *globalTris_;
3033 "distributedTriSurfaceMesh::findNearest"
3038 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3039 <<
" trying to find nearest for " <<
samples.size()
3040 <<
" samples with max sphere "
3070 forAll(dynSendMap, proci)
3077 label minProci = -1;
3087 label nContains = 0;
3090 if (procContains[proci])
3093 dynSendMap[proci].
append(samplei);
3094 distSqr[samplei] = best.
second();
3114 dynSendMap[minProci].
append(samplei);
3115 distSqr[samplei] = best.
second();
3123 sendMap[proci].
transfer(dynSendMap[proci]);
3133 <<
" of " <<
samples.size() <<
" samples sending to" <<
endl;
3137 Pout<<
" " << proci <<
"\t" << map1.
subMap()[proci].size()
3139 nSend += map1.
subMap()[proci].size();
3142 <<
" outside\t" << nOutside <<
endl;
3155 convertTriIndices(localInfo);
3159 nearestInfo.
setSize(localInfo.size());
3163 label nIgnoredHit = 0;
3196 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3197 <<
" searched locally for " << localPoints.size()
3198 <<
" samples with max sphere "
3200 <<
" found hits:" << nHit
3201 <<
" of which outside local bb:" << nIgnoredHit
3242 forAll(nearestInfo, samplei)
3268 calcOverlappingProcs(sample, d2, procBbOverlaps);
3270 forAll(procBbOverlaps, proci)
3272 if (procBbOverlaps[proci])
3278 if (proci != hitProci)
3280 dynSendMap[proci].
append(samplei);
3289 sendMap[proci].
transfer(dynSendMap[proci]);
3299 <<
" of " <<
samples.size() <<
" samples sending to" <<
endl;
3303 Pout<<
" " << proci <<
"\t" << map2.
subMap()[proci].size()
3305 nSend += map2.
subMap()[proci].size();
3314 forAll(nearestInfo, samplei)
3317 if (ni.
first().hit())
3319 localDistSqr[samplei] = ni.
second();
3327 convertTriIndices(localInfo);
3332 label nIgnoredHit = 0;
3359 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3360 <<
" searched locally for " << localSamples.size()
3361 <<
" samples with max sphere "
3363 <<
" found hits:" << nHit
3364 <<
" of which outside local bb:" << nIgnoredHit
3390 info[samplei] = ni.
first();
3418 "distributedTriSurfaceMesh::findNearestRegion"
3423 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3424 <<
" trying to find nearest and region for " <<
samples.size()
3425 <<
" samples with max sphere "
3430 if (regionIndices.empty())
3432 findNearest(
samples, nearestDistSqr, info);
3476 convertTriIndices(allInfo);
3480 if (allInfo[i].hit())
3488 allInfo[i].hitPoint()
3497 allInfo[i].setMiss();
3498 allInfo[i].setIndex(-1);
3515 if (allInfo[i].hit())
3517 label pointi = allSegmentMap[i];
3519 if (!info[pointi].hit())
3522 info[pointi] = allInfo[i];
3533 info[pointi] = allInfo[i];
3542 void Foam::distributedTriSurfaceMesh::findLine
3605 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
3606 <<
" intersecting with "
3613 "distributedTriSurfaceMesh::findLineAll"
3643 +
vector(ROOTVSMALL,ROOTVSMALL,ROOTVSMALL)
3655 if (hitInfo[pointi].hit())
3658 info[pointi][0] = hitInfo[pointi];
3660 point pt = hitInfo[pointi].hitPoint() + smallVec[pointi];
3662 if (((pt-
start[pointi])&dirVec[pointi]) <= magSqrDirVec[pointi])
3665 e1[compacti] =
end[pointi];
3666 pointMap[compacti] = pointi;
3672 info[pointi].
clear();
3676 e0.setSize(compacti);
3677 e1.setSize(compacti);
3678 pointMap.setSize(compacti);
3697 if (hitInfo[i].hit())
3699 label pointi = pointMap[i];
3701 label sz = info[pointi].size();
3703 info[pointi][sz] = hitInfo[i];
3705 point pt = hitInfo[i].hitPoint() + smallVec[pointi];
3708 scalar d = ((pt-
start[pointi])&dirVec[pointi]);
3712 if (d > 0 && d <= magSqrDirVec[pointi])
3715 e1[compacti] =
end[pointi];
3716 pointMap[compacti] = pointi;
3723 e0.setSize(compacti);
3724 e1.setSize(compacti);
3725 pointMap.setSize(compacti);
3731 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
3732 <<
" Exiting loop due to excessive number of"
3733 <<
" intersections along ray"
3744 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
3745 <<
" finished intersecting with "
3759 Pout<<
"distributedTriSurfaceMesh::getRegion :"
3760 <<
" getting region for "
3761 << info.size() <<
" triangles" <<
endl;
3764 addProfiling(getRegion,
"distributedTriSurfaceMesh::getRegion");
3773 region[i] = triSurface::operator[](info[i].index()).region();
3783 Pout<<
"distributedTriSurfaceMesh::getRegion :"
3784 <<
" finished getting region for "
3785 << info.size() <<
" triangles" <<
endl;
3811 region.
setSize(triangleIndex.size());
3815 label trii = triangleIndex[i];
3816 region[i] =
s[trii].region();
3827 Pout<<
"distributedTriSurfaceMesh::getRegion :"
3828 <<
" finished getting region for "
3829 << info.size() <<
" triangles" <<
endl;
3848 Pout<<
"distributedTriSurfaceMesh::getNormal :"
3849 <<
" getting normal for "
3850 << info.size() <<
" triangles" <<
endl;
3853 addProfiling(getNormal,
"distributedTriSurfaceMesh::getNormal");
3876 normal.setSize(triangleIndex.size());
3880 label trii = triangleIndex[i];
3881 normal[i] =
s[trii].unitNormal(
s.points());
3892 Pout<<
"distributedTriSurfaceMesh::getNormal :"
3893 <<
" finished getting normal for "
3894 << info.size() <<
" triangles" <<
endl;
3981 if (!hasVolumeType())
3984 <<
"Volume type only supported for closed distributed surfaces."
3996 "distributedTriSurfaceMesh::getCachedVolumeType"
4000 const point outsidePt(bounds().
max() + 0.5*bounds().span());
4003 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4004 <<
" triggering outsidePoint" << outsidePt
4005 <<
" orientation" <<
endl;
4018 surfaceSide(outsidePts, nearestInfo, outsideVolTypes);
4019 outsideVolType_ = outsideVolTypes[0];
4023 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4024 <<
" determined outsidePoint" << outsidePt
4044 collectLeafMids(0, midPoints);
4048 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4049 <<
" triggering orientation caching for "
4050 << midPoints.size() <<
" leaf mids" <<
endl;
4055 getVolumeType(midPoints, midVolTypes);
4068 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4069 <<
" done orientation caching for "
4070 << midPoints.size() <<
" leaf mids" <<
endl;
4078 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4079 <<
" finding orientation for " <<
samples.size()
4080 <<
" samples" <<
endl;
4086 "distributedTriSurfaceMesh::getVolumeType"
4105 if (contains(procBb_[proci],
samples[samplei]))
4118 outsideSamples.
append(samplei);
4124 sendMap[proci].
setSize(nSend[proci]);
4134 if (contains(procBb_[proci],
samples[samplei]))
4137 procSend[nSend[proci]++] = samplei;
4151 volType.
setSize(localPoints.size());
4160 volType[i] = cachedVolumeType(0, localPoints[i]);
4163 fullSearchMap.append(i);
4164 fullSearchPoints.append(localPoints[i]);
4170 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4171 <<
" original samples:" <<
samples.size()
4172 <<
" resulting in local queries:"
4173 << localPoints.size()
4174 <<
" of which cached:" << localPoints.size()-fullSearchPoints.size()
4189 surfaceSide(fullSearchPoints, nearestInfo, fullSearchType);
4194 volType[fullSearchMap[i]] = fullSearchType[i];
4217 for (
label samplei : outsideSamples)
4219 volType[samplei] = outsideVolType_;
4224 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4225 <<
" finished finding orientation for " <<
samples.size()
4226 <<
" samples" <<
endl;
4245 Pout<<
"distributedTriSurfaceMesh::getField :"
4246 <<
" retrieving field for "
4247 << info.size() <<
" triangles" <<
endl;
4252 const auto* fldPtr = findObject<triSurfaceLabelField>(
"values");
4276 values.setSize(triangleIndex.size());
4280 label trii = triangleIndex[i];
4293 Pout<<
"distributedTriSurfaceMesh::getField :"
4294 <<
" finished retrieving field for "
4295 << info.size() <<
" triangles" <<
endl;
4309 includedFace =
false;
4313 const scalar eps = 1.0e-4;
4316 const point mid = bbs[i].centre();
4317 const vector halfSpan = (1.0+eps)*(bbs[i].
max() - mid);
4319 bbsX[i].
min() = mid - halfSpan;
4320 bbsX[i].
max() = mid + halfSpan;
4327 const point& p1 =
s.points()[
f[1]];
4328 const point& p2 =
s.points()[
f[2]];
4330 if (overlaps(bbsX,
p0, p1, p2))
4332 includedFace[trii] =
true;
4350 overlappingSurface(
s, bbs, includedFace);
4351 return subsetMesh(
s, includedFace, subPointMap, subFaceMap);
4365 triangleIndex.
setSize(info.size());
4392 sendMap[proci].
setSize(nSend[proci]);
4402 triangleIndex[i] = triIndexer.
toLocal(proci, info[i].index());
4403 sendMap[proci][nSend[proci]++] = i;
4407 triangleIndex[i] = -1;
4437 forAll(constructMap, proci)
4443 constructMap[proci].
setSize(nRecv);
4445 for (
label i = 0; i < nRecv; i++)
4447 constructMap[proci][i] = segmenti++;
4462 std::move(constructMap)
4480 const bool keepNonLocal,
4492 Pout<<
"distributedTriSurfaceMesh::distribute :"
4493 <<
" distributing surface according to method:"
4494 << distributionTypeNames_[distType_]
4498 addProfiling(distribute,
"distributedTriSurfaceMesh::distribute");
4521 if (currentDistType_ == distType_)
4525 newProcBb = independentlyDistributedBbs(*
this);
4538 if (newProcBb == procBb_)
4544 procBb_.transfer(newProcBb);
4559 <<
"before distribution:" <<
endl <<
"\tproc\ttris" <<
endl;
4563 Info<<
'\t' << proci <<
'\t' << nTris[proci] <<
endl;
4581 pointSendMap[proci],
4595 forAll(faceSendMap, proci)
4599 forAll(faceSendMap[proci], i)
4601 includedFace[faceSendMap[proci][i]] =
false;
4657 allTris = subSurface;
4677 forAll(faceSendMap, proci)
4681 if (faceSendMap[proci].size() > 0)
4706 forAll(faceRecvSizes, proci)
4710 if (faceRecvSizes[proci] > 0)
4726 faceConstructMap[proci],
4727 pointConstructMap[proci]
4739 std::move(faceSendMap),
4740 std::move(faceConstructMap)
4748 std::move(pointSendMap),
4749 std::move(pointConstructMap)
4762 currentDistType_ = distType_;
4767 distributeFields<label>(
faceMap());
4768 distributeFields<scalar>(
faceMap());
4769 distributeFields<vector>(
faceMap());
4770 distributeFields<sphericalTensor>(
faceMap());
4771 distributeFields<symmTensor>(
faceMap());
4772 distributeFields<tensor>(
faceMap());
4782 <<
"after distribution:" <<
endl <<
"\tproc\ttris" <<
endl;
4786 Info<<
'\t' << proci <<
'\t' << nTris[proci] <<
endl;
4793 Info<<
"Writing local bounding box to " << str.
name() <<
endl;
4801 const edge&
e = es[ei];
4809 Info<<
"Writing all bounding boxes to " << str.
name() <<
endl;
4810 for (
auto myBbs : procBb_)
4818 const edge&
e = es[ei];
4828 Pout<<
"distributedTriSurfaceMesh::distribute :"
4829 <<
" done distributing surface according to method:"
4830 << distributionTypeNames_[distType_]
4846 Pout<<
"distributedTriSurfaceMesh::writeObject :"
4847 <<
" writing surface valid:" << valid <<
endl;
4865 triSurface::write(fullPath,
true);
4878 Pout<<
"distributedTriSurfaceMesh::writeObject :"
4879 <<
" done writing surface" <<
endl;
4896 <<
"Bounding Box : " << bb <<
endl
4897 <<
"Closed : " << surfaceClosed_ <<
endl
4899 <<
"Distribution : " << distributionTypeNames_[distType_] <<
endl;