200 if (
y.first().hit() &&
y.second() <
x.second())
205 else if (
y.first().hit())
220 { distributionType::FOLLOW,
"follow" },
221 { distributionType::INDEPENDENT,
"independent" },
222 { distributionType::DISTRIBUTED,
"distributed" },
223 { distributionType::FROZEN,
"frozen" }
229Foam::word Foam::distributedTriSurfaceMesh::findLocalInstance
238 io.time().findInstance
261 io.rootPath()/
io.globalCaseName()
262 /
io.instance()/
io.db().dbDir()/
io.local()/
io.name()
267 return io.instance();
271 const scalar startValue =
io.time().timeOutputValue();
275 label instIndex = ts.
size()-1;
278 for (; instIndex >= 0; --instIndex)
280 if (ts[instIndex] <= startValue)
287 for (; instIndex >= 0; --instIndex)
290 if (ts[instIndex].
name() ==
io.instance())
297 io.rootPath()/
io.globalCaseName()
298 /ts[instIndex].name()/
io.db().dbDir()/
io.local()/
io.name()
303 return ts[instIndex].name();
312 if (!ts.size() || ts[0].name() !=
io.time().constant())
320 io.rootPath()/
io.globalCaseName()
321 /
io.time().constant()/
io.db().dbDir()/
io.local()/
io.name()
326 return io.time().constant();
338 return io.time().constant();
342bool Foam::distributedTriSurfaceMesh::readSettings(
const bool undecomposed)
359 decomposeUsingBbs_ = dict_.getOrDefault<
bool>(
"decomposeUsingBbs",
true);
364 !distributionTypeNames_.readIfPresent
373 distType_ = DISTRIBUTED;
374 dict_.add(
"distributionType", distributionTypeNames_[distType_]);
378 if (!dict_.readIfPresent(
"mergeDistance", mergeDist_))
381 dict_.add(
"mergeDistance", mergeDist_);
385 if (!dict_.readIfPresent<label>(
"closed", surfaceClosed_))
394 surfaceClosed_ =
false;
396 dict_.add(
"closed", surfaceClosed_);
411 outsideVolType_ = vt;
415 if (undecomposed && surfaceClosed_)
426 const point outsidePt(localBb.max()+localBb.centre());
434 if (info.distance() < nearInfo.distance())
470 label volType = outsideVolType_;
489void Foam::distributedTriSurfaceMesh::calcVertexNormals
500 const vector n =
f.unitNormal(surf.points());
503 const label pointi =
f[fp];
504 pointNormals[pointi] +=
n;
507 pointNormals.normalise();
518 vn[facei][fp] = pointNormals[
f[fp]];
525bool Foam::distributedTriSurfaceMesh::isLocal
534 if (myBbs[bbi].contains(start) && myBbs[bbi].contains(end))
605void Foam::distributedTriSurfaceMesh::distributeSegment
607 const label segmenti,
616 if (decomposeUsingBbs_)
634 if (isLocal(bbs, start, end))
636 sendMap[proci].append(allSegments.size());
637 allSegmentMap.append(segmenti);
638 allSegments.append(
segment(start, end));
662 if (bb.intersects(start, end, clipPt))
664 sendMap[proci].append(allSegments.size());
665 allSegmentMap.append(segmenti);
666 allSegments.append(
segment(start, end));
688Foam::autoPtr<Foam::mapDistribute>
689Foam::distributedTriSurfaceMesh::distributeSegments
718 dynSendMap[proci].reserve
744 sendMap[proci].transfer(dynSendMap[proci]);
747 allSegments.transfer(dynAllSegments);
748 allSegmentMap.transfer(dynAllSegmentMap);
755void Foam::distributedTriSurfaceMesh::findLine
757 const bool nearestIntersection,
765 Pout<<
"distributedTriSurfaceMesh::findLine :"
768 << start.size() <<
" rays" <<
endl;
770 addProfiling(findLine,
"distributedTriSurfaceMesh::findLine");
778 info.setSize(start.size());
797 if (nearestIntersection)
799 info[i] = octree.findLine(start[i], end[i]);
803 info[i] = octree.findLineAny(start[i], end[i]);
808 info[i].setIndex(triIndexer.toGlobal(info[i].index()));
810 end[i] = info[i].hitPoint();
856 label nOldAllSegments = allSegments.size();
862 map.distribute(allSegments);
873 if (nearestIntersection)
875 intersections[i] = octree.findLine
877 allSegments[i].first(),
878 allSegments[i].second()
883 intersections[i] = octree.findLineAny
885 allSegments[i].first(),
886 allSegments[i].second()
891 if (intersections[i].hit())
893 intersections[i].setIndex
895 triIndexer.toGlobal(intersections[i].index())
904 map.reverseDistribute(nOldAllSegments, intersections);
913 label segmenti = allSegmentMap[i];
923 else if (nearestIntersection)
928 start[segmenti].distSqr(allInfo.point())
929 < start[segmenti].distSqr(hitInfo.point())
940void Foam::distributedTriSurfaceMesh::convertTriIndices
952 pi.setIndex(triIndexer.toGlobal(
pi.index()));
961Foam::autoPtr<Foam::mapDistribute>
962Foam::distributedTriSurfaceMesh::calcLocalQueries
972 triangleIndex.setSize(info.size());
990 label proci = triIndexer.whichProcID(info[i].index());
999 sendMap[proci].setSize(nSend[proci]);
1008 label proci = triIndexer.whichProcID(info[i].index());
1009 triangleIndex[i] = triIndexer.toLocal(proci, info[i].index());
1010 sendMap[proci][nSend[proci]++] = i;
1014 triangleIndex[i] = -1;
1023 mapPtr().distribute(triangleIndex);
1029bool Foam::distributedTriSurfaceMesh::contains
1037 if (bbs[bbi].contains(sample))
1046Foam::Tuple2<Foam::label, Foam::scalar>
1047Foam::distributedTriSurfaceMesh::findBestProcs
1049 const point& centre,
1050 const scalar radiusSqr,
1061 procContains =
false;
1064 procOverlaps =
false;
1068 scalar minDistSqr = radiusSqr;
1077 if (bbs[bbi].contains(centre))
1082 if (!procContains[proci])
1084 procContains[proci] =
true;
1089 bbs[bbi].calcExtremities(centre, near, far);
1090 minDistSqr =
min(minDistSqr, centre.distSqr(far));
1101 scalar maxDistSqr = radiusSqr;
1112 if (bbs[bbi].overlaps(centre, radiusSqr))
1115 bbs[bbi].calcExtremities(centre, near, far);
1117 scalar d2 = centre.distSqr(near);
1118 if (d2 < minDistSqr)
1121 maxDistSqr =
min(radiusSqr, centre.distSqr(far));
1133 procOverlaps[minProci] =
true;
1138 if (proci != minProci)
1143 if (bbs[bbi].overlaps(centre, maxDistSqr))
1145 procOverlaps[proci] =
true;
1158Foam::label Foam::distributedTriSurfaceMesh::calcOverlappingProcs
1160 const point& centre,
1161 const scalar radiusSqr,
1166 label nOverlaps = 0;
1174 if (bbs[bbi].overlaps(centre, radiusSqr))
1176 overlaps[proci] =
true;
1189Foam::autoPtr<Foam::mapDistribute>
1190Foam::distributedTriSurfaceMesh::calcLocalQueries
1192 const bool includeLocalProcessor,
1216 forAll(dynSendMap, proci)
1218 dynSendMap[proci].reserve
1232 calcOverlappingProcs
1239 forAll(procBbOverlaps, proci)
1243 procBbOverlaps[proci]
1245 includeLocalProcessor
1250 dynSendMap[proci].append(dynAllCentres.size());
1251 dynAllSegmentMap.append(centrei);
1252 dynAllCentres.append(centres[centrei]);
1253 dynAllRadiusSqr.append(radiusSqr[centrei]);
1262 sendMap[proci].transfer(dynSendMap[proci]);
1265 allCentres.transfer(dynAllCentres);
1266 allRadiusSqr.transfer(dynAllRadiusSqr);
1267 allSegmentMap.transfer(dynAllSegmentMap);
1274Foam::volumeType Foam::distributedTriSurfaceMesh::edgeSide
1276 const point& sample,
1277 const point& nearestPoint,
1292 if (((sample - nearestPoint) &
n) > 0)
1303Foam::label Foam::distributedTriSurfaceMesh::findOtherFace
1306 const label nearFacei,
1307 const label nearLabel
1313 const edge e(nearF[nearLabel], nearF[nearF.fcIndex(nearLabel)]);
1316 for (
const label facei :
pFaces)
1318 if (facei != nearFacei)
1320 if (surf[facei].contains(
e))
1330void Foam::distributedTriSurfaceMesh::calcFaceFaces
1337 faceFaces.setSize(
s.size());
1345 nbrs.reserve(
f.
size());
1352 for (
const label otherFacei :
pFaces)
1354 if (otherFacei != facei)
1356 if (
s[otherFacei].contains(
e))
1358 if (!nbrs.find(otherFacei))
1360 nbrs.append(otherFacei);
1366 faceFaces[facei] = std::move(nbrs);
1371void Foam::distributedTriSurfaceMesh::surfaceSide
1380 Pout<<
"distributedTriSurfaceMesh::surfaceSide :"
1382 <<
" finding surface side given points on surface for "
1384 <<
" cached vertexnormals " << vertexNormals_.valid() <<
endl;
1390 labelList triangleIndex(nearestInfo.size());
1403 map.distribute(localSamples);
1407 map.distribute(localNearestInfo);
1413 volType.setSize(triangleIndex.size());
1426 const label facei = triangleIndex[i];
1428 const auto& vn = vertexNormals_()[facei];
1430 const point& sample = localSamples[i];
1432 const point& nearest = localNearestInfo[i].point();
1434 const vector sampleNearestVec(sample - nearest);
1438 const vector n = w[0]*vn[0]+w[1]*vn[1]+w[2]*vn[2];
1440 const scalar
c = (sampleNearestVec &
n);
1464 const label facei = triangleIndex[i];
1466 const point& sample = localSamples[i];
1469 label nearType, nearLabel;
1471 f.nearestPointClassify(sample,
points, nearType, nearLabel);
1473 const point& nearestPoint(pHit.point());
1477 const vector sampleNearestVec = (sample - nearestPoint);
1481 const scalar
c = (sampleNearestVec &
f.areaNormal(
points));
1499 label otherFacei = findOtherFace(pointFaces, facei, nearLabel);
1500 if (otherFacei != -1)
1503 edgeSide(sample, nearestPoint, facei, otherFacei);
1517 const label pointi =
f[nearLabel];
1519 const vector sampleNearestVec = (sample - nearestPoint);
1523 edgeToFaces.clear();
1525 scalar maxCosAngle = -GREAT;
1528 for (
const label facei :
pFaces)
1532 label fp =
f.
find(pointi);
1544 for (
const edge&
e : edges)
1546 auto iter = edgeToFaces.find(
e);
1549 if (iter().second() == -1)
1552 iter().second() = facei;
1555 scalar magEVec =
mag(eVec);
1557 if (magEVec > VSMALL)
1563 scalar cosAngle(sampleNearestVec&eVec);
1564 if (cosAngle > maxCosAngle)
1566 maxCosAngle = cosAngle;
1567 maxEdgeFaces = iter();
1587 for (
auto iter : edgeToFaces)
1589 if (iter[0] == -1 || iter[1] == -1)
1597 volType[i] = edgeSide
1665 map.constructHasFlip(),
1678 Pout<<
"distributedTriSurfaceMesh::surfaceSide :"
1680 <<
" given points on surface "
1687Foam::volumeType Foam::distributedTriSurfaceMesh::markMixed
1695 const auto& nod =
tree.nodes()[nodei];
1705 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
1707 const labelBits index = nod.subNodes_[octant];
1710 if (subBb.intersects(tri))
1767 else if (subType != myType)
1787void Foam::distributedTriSurfaceMesh::markMixedOverlap
1836 for (
const int proci : pBufs.allProcs())
1862 for (
const auto& tri : subSurface)
1868 tri.tri(subSurface.points()),
1877void Foam::distributedTriSurfaceMesh::collectLeafMids
1883 const auto& nod =
tree().nodes()[nodeI];
1885 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
1887 const labelBits index = nod.subNodes_[octant];
1905 midPoints.append(subBb.centre());
1911Foam::volumeType Foam::distributedTriSurfaceMesh::calcVolumeType
1923 const auto& nod =
tree().nodes()[nodeI];
1927 for (
direction octant = 0; octant < nod.subNodes_.size(); octant++)
1931 const labelBits index = nod.subNodes_[octant];
1936 subType = calcVolumeType
1958 subType = midPointTypes[midPointi++];
1970 else if (subType != myType)
1979void Foam::distributedTriSurfaceMesh::cacheVolumeType(
PackedList<2>& nt)
const
1983 const auto& nodes = t.nodes();
1989 collectLeafMids(0, midPoints);
1994 Pout<<
"distributedTriSurfaceMesh::cacheVolumeType :"
1996 <<
" triggering orientation caching for "
1997 << midPoints.size() <<
" leaf mids" <<
endl;
2014 surfaceSide(midPoints, nearestInfo, midVolTypes);
2033 insideStr.write(
ln);
2037 outsideStr.write(
ln);
2041 <<
" have inside:" << insideStr.nVertices()
2042 <<
" have outside:" << outsideStr.nVertices()
2061 Pout<<
"distributedTriSurfaceMesh::cacheVolumeType :"
2063 <<
" done orientation caching for "
2064 << midPoints.size() <<
" leaf mids" <<
endl;
2069Foam::volumeType Foam::distributedTriSurfaceMesh::cachedVolumeType
2075 const auto& nod =
tree().nodes()[nodeI];
2077 direction octant = nod.bb_.subOctant(sample);
2099 labelBits index = nod.subNodes_[octant];
2122 <<
"Sample:" << sample <<
" node:" << nodeI
2123 <<
" with bb:" << nod.bb_ <<
nl
2124 <<
"Empty subnode has invalid volume type MIXED."
2133 <<
"Sample:" << sample <<
" at node:" << nodeI
2134 <<
" octant:" << octant
2135 <<
" with bb:" << nod.bb_.subBbox(octant) <<
nl
2136 <<
"Node has invalid volume type " << octantType
2144const Foam::decompositionMethod&
2145Foam::distributedTriSurfaceMesh::decomposer()
const
2150 if (dict_.found(
"method"))
2154 Pout<<
"distributedTriSurfaceMesh::decomposer() :"
2155 <<
" constructing decomposer from provided dictionary "
2166 const auto* dictPtr =
2177 Pout<<
"distributedTriSurfaceMesh::decomposer() :"
2178 <<
" constructing decomposer from registered"
2179 <<
" dictionary " << *dictPtr <<
endl;
2186 if (!decomposeParDict_)
2188 decomposeParDict_.reset
2206 Pout<<
"distributedTriSurfaceMesh::decomposer() :"
2208 << decomposeParDict_().objectRelPath()
2217 return decomposer_();
2227void Foam::distributedTriSurfaceMesh::independentlyDistributedBbs
2237 "distributedTriSurfaceMesh::independentlyDistributedBbs"
2251 if (triIndexer.localSize(proci) != 0)
2263 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
2264 <<
" determining master-only decomposition for " <<
s.size()
2272 triCentres[trii] =
s[trii].centre(
s.points());
2281 calcFaceFaces(
s, pointFaces, faceFaces);
2285 distribution = decomposer().decompose(faceFaces, triCentres);
2296 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
2297 <<
" determining processor bounding boxes for surface "
2305 bb.
add(
s.points(),
s[trii]);
2312 for (
auto& bb : bbs[proci])
2314 bb.grow(mergeDist_);
2320 else if (distType_ == DISTRIBUTED)
2324 if (!decomposer().parallelAware())
2327 <<
"The decomposition method " << decomposer().typeName
2328 <<
" does not decompose in parallel."
2334 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
2335 <<
" determining decomposition for " <<
s.size()
2344 triCentres[trii] =
s[trii].centre(
s.points());
2351 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
2352 <<
" determining processor bounding boxes for "
2360 bb.
add(
s.points(),
s[trii]);
2367 for (
auto& bb : bbs[proci])
2369 bb.grow(mergeDist_);
2573 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
2574 <<
" collecting all centroids for surface "
2583 allCentres[trii] =
s[trii].centre(
s.points());
2585 globalTris().gatherInplace(allCentres);
2604 Pout<<
"distributedTriSurfaceMesh::"
2605 <<
"independentlyDistributedBbs :"
2607 <<
" merged " << allCentres.size()
2608 <<
" centroids down to " << nMerged <<
endl;
2617 labelList mergedDist(decomposer().decompose(mergedPoints));
2633 Pout<<
"distributedTriSurfaceMesh::"
2634 <<
"independentlyDistributedBbs :"
2635 <<
" determined decomposition" <<
endl;
2642 Pout<<
"distributedTriSurfaceMesh::independentlyDistributedBbs :"
2643 <<
" determining processor bounding boxes for "
2650 bb.
add(
s.points(),
s[trii]);
2657 for (
auto& bb : bbs[proci])
2659 bb.grow(mergeDist_);
2669bool Foam::distributedTriSurfaceMesh::overlaps
2686 if (bb.overlaps(triBb) && bb.intersects(tri))
2695void Foam::distributedTriSurfaceMesh::subsetMeshMap
2699 const label nIncluded,
2705 newToOldFaces.setSize(nIncluded);
2706 newToOldPoints.setSize(
s.points().size());
2707 oldToNewPoints.setSize(
s.points().size());
2708 oldToNewPoints = -1;
2713 forAll(include, oldFacei)
2715 if (include[oldFacei])
2718 newToOldFaces[facei++] = oldFacei;
2721 for (
const label oldPointi :
s[oldFacei])
2723 if (oldToNewPoints[oldPointi] == -1)
2725 oldToNewPoints[oldPointi] = pointi;
2726 newToOldPoints[pointi++] = oldPointi;
2731 newToOldPoints.setSize(pointi);
2736Foam::triSurface Foam::distributedTriSurfaceMesh::subsetMesh
2746 forAll(newToOldPoints, i)
2748 newPoints[i] =
s.points()[newToOldPoints[i]];
2758 newTriangles[i][0] = oldToNewPoints[tri[0]];
2759 newTriangles[i][1] = oldToNewPoints[tri[1]];
2760 newTriangles[i][2] = oldToNewPoints[tri[2]];
2761 newTriangles[i].
region() = tri.region();
2765 return triSurface(newTriangles,
s.patches(), newPoints,
true);
2769Foam::triSurface Foam::distributedTriSurfaceMesh::subsetMesh
2808Foam::triSurface Foam::distributedTriSurfaceMesh::subsetMesh
2820 newToOldPoints.setSize(
s.points().size());
2821 labelList oldToNewPoints(
s.points().size(), -1);
2825 forAll(include, oldFacei)
2827 if (include[oldFacei])
2830 for (
const label oldPointi :
s[oldFacei])
2832 if (oldToNewPoints[oldPointi] == -1)
2834 oldToNewPoints[oldPointi] = pointi;
2835 newToOldPoints[pointi++] = oldPointi;
2840 newToOldPoints.setSize(pointi);
2853Foam::label Foam::distributedTriSurfaceMesh::findTriangle
2867 if (
f.region() == otherF.region())
2870 label fp0 =
f.
find(otherF[0]);
2875 if (
f[fp1] == otherF[1] &&
f[fp2] == otherF[2])
2886void Foam::distributedTriSurfaceMesh::merge
2888 const scalar mergeDist,
2915 label allPointi = nOldAllPoints;
2916 forAll(pointConstructMap, pointi)
2918 if (pointConstructMap[pointi] == -1)
2920 pointConstructMap[pointi] = allPointi++;
2924 if (allPointi > nOldAllPoints)
2928 forAll(pointConstructMap, pointi)
2930 if (pointConstructMap[pointi] >= nOldAllPoints)
2932 allPoints[pointConstructMap[pointi]] = subPoints[pointi];
2946 label allTrii = allTris.size();
2947 allTris.setSize(allTrii + subTris.size());
2949 faceConstructMap.setSize(subTris.size());
2958 pointConstructMap[subTri[0]],
2959 pointConstructMap[subTri[1]],
2960 pointConstructMap[subTri[2]],
2966 bool fullMatch =
true;
2970 if (mappedTri[fp] >= nOldAllPoints)
2981 label i = findTriangle
2991 faceConstructMap[trii] = allTrii;
2992 allTris[allTrii] = mappedTri;
2997 faceConstructMap[trii] = i;
3003 faceConstructMap[trii] = allTrii;
3004 allTris[allTrii] = mappedTri;
3008 allTris.setSize(allTrii);
3014Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh
3041 readSettings(dict_.empty());
3062 Info<<
'\t' << proci <<
'\t' << nTris[proci]
3063 <<
'\t' << procBb_[proci] <<
endl;
3071Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh(
const IOobject&
io)
3078 findLocalInstance(
io),
3108 const bool readFromMaster =
3111 || actualFile !=
io.localFilePath(triSurfaceMesh::typeName)
3114 readSettings(readFromMaster);
3123 <<
"Forcing consistent normals since undecomposed" <<
endl;
3128 if (readFromMaster && !decomposeUsingBbs_)
3132 <<
"Determining vertex based normals since undecomposed" <<
endl;
3135 calcVertexNormals(surf, vertexNormals_());
3145 <<
"Read distributedTriSurface " <<
io.name()
3146 <<
" from parent path " << actualFile <<
endl;
3169 <<
"Read distributedTriSurface " <<
io.name()
3170 <<
" from actual path " << actualFile <<
':' <<
endl;
3182 Info<<
'\t' << proci <<
'\t' << nTris[proci]
3183 <<
'\t' << procBb_[proci] <<
endl;
3192 <<
"Read distributedTriSurface " <<
io.name() <<
':' <<
endl;
3198Foam::distributedTriSurfaceMesh::distributedTriSurfaceMesh
3209 findLocalInstance(
io),
3240 const bool readFromMaster =
3243 || actualFile !=
io.localFilePath(triSurfaceMesh::typeName)
3249 readSettings(readFromMaster);
3253 if (readFromMaster && !decomposeUsingBbs_)
3257 <<
"Determining vertex based normals since undecomposed" <<
endl;
3260 calcVertexNormals(surf, vertexNormals_());
3270 <<
"Read distributedTriSurface " <<
io.name()
3271 <<
" from parent path " << actualFile
3272 <<
" and dictionary" <<
endl;
3295 <<
"Read distributedTriSurface " <<
io.name()
3296 <<
" from actual path " << actualFile
3297 <<
" and dictionary:" <<
endl;
3309 Info<<
'\t' << proci <<
'\t' << nTris[proci]
3310 <<
'\t' << procBb_[proci] <<
endl;
3319 <<
"Read distributedTriSurface " <<
io.name() <<
':' <<
endl;
3335 globalTris_.clear();
3348 return *globalTris_;
3356 Pout<<
"distributedTriSurfaceMesh::flip :"
3358 <<
" with current orientation "
3360 <<
" vertexNormals_ " << vertexNormals_.good()
3370 for (
auto& normals : vn)
3372 for (
auto&
n : normals)
3621 "distributedTriSurfaceMesh::findNearest"
3626 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3628 <<
" trying to find nearest for " <<
samples.size()
3629 <<
" samples with max sphere "
3659 forAll(dynSendMap, proci)
3666 label minProci = -1;
3676 label nContains = 0;
3679 if (procContains[proci])
3682 dynSendMap[proci].
append(samplei);
3683 distSqr[samplei] = best.
second();
3703 dynSendMap[minProci].
append(samplei);
3704 distSqr[samplei] = best.
second();
3712 sendMap[proci].
transfer(dynSendMap[proci]);
3722 <<
" of " <<
samples.size() <<
" samples sending to" <<
endl;
3731 <<
" outside\t" << nOutside <<
endl;
3744 convertTriIndices(localInfo);
3752 label nIgnoredHit = 0;
3785 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3788 <<
" samples with max sphere "
3790 <<
" found hits:" << nHit
3791 <<
" of which outside local bb:" << nIgnoredHit
3834 forAll(nearestInfo, samplei)
3860 calcOverlappingProcs(
sample, d2, procBbOverlaps);
3862 forAll(procBbOverlaps, proci)
3864 if (procBbOverlaps[proci])
3870 if (proci != hitProci)
3872 dynSendMap[proci].
append(samplei);
3881 sendMap[proci].
transfer(dynSendMap[proci]);
3891 <<
" of " <<
samples.size() <<
" samples sending to" <<
endl;
3906 forAll(nearestInfo, samplei)
3911 localDistSqr[samplei] = ni.
second();
3919 convertTriIndices(localInfo);
3924 label nIgnoredHit = 0;
3944 ni.
second() =
info.point().distSqr(localSamples[i]);
3951 Pout<<
"distributedTriSurfaceMesh::findNearest :"
3953 <<
" searched locally for " << localSamples.
size()
3954 <<
" samples with max sphere "
3956 <<
" found hits:" << nHit
3957 <<
" of which outside local bb:" << nIgnoredHit
4013 "distributedTriSurfaceMesh::findNearestRegion"
4018 Pout<<
"distributedTriSurfaceMesh::findNearest :"
4020 <<
" trying to find nearest and region for " <<
samples.size()
4021 <<
" samples with max sphere "
4026 if (regionIndices.
empty())
4072 convertTriIndices(allInfo);
4076 if (allInfo[i].hit())
4089 allInfo[i].setMiss();
4090 allInfo[i].setIndex(-1);
4107 if (allInfo[i].hit())
4109 label pointi = allSegmentMap[i];
4111 if (!
info[pointi].hit())
4114 info[pointi] = allInfo[i];
4125 info[pointi] = allInfo[i];
4134void Foam::distributedTriSurfaceMesh::findLine
4197 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
4199 <<
" intersecting with "
4200 << start.
size() <<
" rays" <<
endl;
4206 "distributedTriSurfaceMesh::findLineAll"
4248 if (hitInfo[pointi].hit())
4250 info[pointi].setSize(1);
4251 info[pointi][0] = hitInfo[pointi];
4253 point pt = hitInfo[pointi].point() + smallVec[pointi];
4255 if (((pt-start[pointi])&dirVec[pointi]) <= magSqrDirVec[pointi])
4258 e1[compacti] =
end[pointi];
4259 pointMap[compacti] = pointi;
4265 info[pointi].clear();
4290 if (hitInfo[i].hit())
4292 label pointi = pointMap[i];
4294 label sz =
info[pointi].size();
4295 info[pointi].setSize(sz+1);
4296 info[pointi][sz] = hitInfo[i];
4298 point pt = hitInfo[i].point() + smallVec[pointi];
4301 scalar d = ((pt-start[pointi])&dirVec[pointi]);
4305 if (d > 0 && d <= magSqrDirVec[pointi])
4308 e1[compacti] =
end[pointi];
4309 pointMap[compacti] = pointi;
4324 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
4325 <<
" Exiting loop due to excessive number of"
4326 <<
" intersections along ray"
4337 Pout<<
"distributedTriSurfaceMesh::findLineAll :"
4339 <<
" finished intersecting with "
4340 << start.
size() <<
" rays" <<
endl;
4353 Pout<<
"distributedTriSurfaceMesh::getRegion :"
4355 <<
" getting region for "
4356 <<
info.size() <<
" triangles" <<
endl;
4378 Pout<<
"distributedTriSurfaceMesh::getRegion :"
4380 <<
" finished getting region for "
4381 <<
info.size() <<
" triangles" <<
endl;
4411 label trii = triangleIndex[i];
4412 region[i] =
s[trii].region();
4423 Pout<<
"distributedTriSurfaceMesh::getRegion :"
4425 <<
" finished getting region for "
4426 <<
info.size() <<
" triangles" <<
endl;
4445 Pout<<
"distributedTriSurfaceMesh::getNormal :"
4447 <<
" getting normal for "
4448 <<
info.size() <<
" triangles" <<
endl;
4488 const label trii = triangleIndex[i];
4490 const auto& vn = vertexNormals_()[trii];
4492 normal[i] = w[0]*vn[0]+w[1]*vn[1]+w[2]*vn[2];
4499 const label trii = triangleIndex[i];
4500 normal[i] =
s[trii].unitNormal(
s.points());
4512 Pout<<
"distributedTriSurfaceMesh::getNormal :"
4514 <<
" finished getting normal for "
4515 <<
info.size() <<
" triangles" <<
endl;
4605 <<
"Volume type only supported for closed distributed surfaces."
4617 "distributedTriSurfaceMesh::getCachedVolumeType"
4624 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4626 <<
" triggering outsidePoint" << outsidePt
4627 <<
" orientation" <<
endl;
4640 surfaceSide(outsidePts, nearestInfo, outsideVolTypes);
4651 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4653 <<
" determined outsidePoint" << outsidePt
4664 const auto& nodes = t.
nodes();
4669 if (!decomposeUsingBbs_)
4671 markMixedOverlap(t, nt);
4674 cacheVolumeType(nt);
4681 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4683 <<
" finding orientation for " <<
samples.size()
4684 <<
" samples" <<
endl;
4690 "distributedTriSurfaceMesh::getVolumeType"
4709 if (contains(procBb_[proci],
samples[samplei]))
4722 outsideSamples.
append(samplei);
4738 if (contains(procBb_[proci],
samples[samplei]))
4740 sendMap[proci][nSend[proci]++] = samplei;
4772 if (decomposeUsingBbs_ &&
tree().nodes().
size())
4785 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4787 <<
" original samples:" <<
samples.size()
4788 <<
" resulting in local queries:"
4805 surfaceSide(fullSearchPoints, nearestInfo, fullSearchType);
4813 vt = fullSearchType[i];
4815 else if (vt != fullSearchType[i])
4817 Pout<<
"At point:" << fullSearchPoints[i]
4819 <<
" have cached status:" << vt
4820 <<
" have full-search status:" << fullSearchType[i]
4893 for (label samplei : outsideSamples)
4900 Pout<<
"distributedTriSurfaceMesh::getVolumeType :"
4902 <<
" finished finding orientation for " <<
samples.size()
4903 <<
" samples" <<
endl;
4922 Pout<<
"distributedTriSurfaceMesh::getField :"
4924 <<
" retrieving field for "
4925 <<
info.size() <<
" triangles" <<
endl;
4954 values.setSize(triangleIndex.
size());
4958 label trii = triangleIndex[i];
4959 values[i] =
fld[trii];
4971 Pout<<
"distributedTriSurfaceMesh::getField :"
4973 <<
" finished retrieving field for "
4974 <<
info.size() <<
" triangles" <<
endl;
4988 includedFace =
false;
4992 const scalar eps = 1.0e-4;
4995 const point mid = bbs[i].centre();
4996 const vector halfSpan = (1.0+eps)*(bbs[i].
max() - mid);
4998 bbsX[i].min() = mid - halfSpan;
4999 bbsX[i].max() = mid + halfSpan;
5008 if (overlaps(bbsX, tri))
5010 includedFace[trii] =
true;
5029 return subsetMesh(
s, includedFace, subPointMap, subFaceMap);
5080 triangleIndex[i] = triIndexer.
toLocal(proci,
info[i].index());
5081 sendMap[proci][nSend[proci]++] = i;
5085 triangleIndex[i] = -1;
5094 mapPtr().distribute(triangleIndex);
5103 const bool keepNonLocal,
5115 Pout<<
"distributedTriSurfaceMesh::distribute :"
5117 <<
" distributing surface according to method:"
5119 <<
" fill-in:" << decomposeUsingBbs_
5144 if (currentDistType_ == distType_)
5148 independentlyDistributedBbs(*
this,
distribution, newProcBb);
5161 if (newProcBb == procBb_)
5167 procBb_.transfer(newProcBb);
5184 <<
"before distribution:" <<
endl <<
"\tproc\ttris" <<
endl;
5188 Info<<
'\t' << proci <<
'\t' << nTris[proci] <<
endl;
5201 if (decomposeUsingBbs_)
5209 pointSendMap[proci],
5228 pointSendMap[proci],
5243 forAll(faceSendMap, proci)
5247 forAll(faceSendMap[proci], i)
5249 includedFace[faceSendMap[proci][i]] =
false;
5298 allTris = subSurface;
5299 allPoints = subSurface.
points();
5318 forAll(faceSendMap, proci)
5344 for (
const int proci : pBufs.
allProcs())
5362 faceConstructMap[proci],
5363 pointConstructMap[proci]
5374 std::move(faceSendMap),
5375 std::move(faceConstructMap)
5383 std::move(pointSendMap),
5384 std::move(pointConstructMap)
5397 currentDistType_ = distType_;
5402 distributeFields<label>(
faceMap());
5403 distributeFields<scalar>(
faceMap());
5404 distributeFields<vector>(
faceMap());
5405 distributeFields<sphericalTensor>(
faceMap());
5406 distributeFields<symmTensor>(
faceMap());
5407 distributeFields<tensor>(
faceMap());
5423 const auto&
f =
s[trii];
5427 const point& pt =
s.points()[
f[fp]];
5428 const vector&
n = vn[trii][fp];
5432 Pout<<
"Dumped local vertex normals to " << str.
name() <<
endl;
5446 const auto& nodes = t.
nodes();
5452 if (!decomposeUsingBbs_)
5458 markMixedOverlap(t, nt);
5461 cacheVolumeType(nt);
5476 <<
"after distribution:" <<
endl <<
"\tproc\ttris" <<
endl;
5480 Info<<
'\t' << proci <<
'\t' << nTris[proci] <<
endl;
5492 Info<<
"Writing local bounding box to " << str.
name() <<
endl;
5496 str.
write(bb,
true);
5507 Info<<
"Writing all bounding boxes to " << str.
name() <<
endl;
5508 for (
const auto& myBbs : procBb_)
5512 str.
write(bb,
true);
5520 Pout<<
"distributedTriSurfaceMesh::distribute :"
5522 <<
" done distributing surface according to method:"
5532 const bool writeOnProc
5537 Pout<<
"distributedTriSurfaceMesh::writeObject :"
5539 <<
" writing surface:" << writeOnProc <<
endl;
5567 bool ok = dict_.writeObject(streamOpt,
true);
5571 Pout<<
"distributedTriSurfaceMesh::writeObject :"
5573 <<
" done writing surface" <<
endl;
5587 os <<
"Triangles : "
5590 <<
"Vertex normals : " << vertexNormals_.valid() <<
endl
5591 <<
"Bounding Box : " << bb <<
endl
constexpr scalar pi(M_PI)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
propsDict readIfPresent("fields", acceptFields)
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Dynamically sized Field. Similar to DynamicList, but inheriting from a Field instead of a List.
void append(const T &val)
Append an element at the end of the list.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
A 1D vector of objects of type <T> with a fixed length <N>.
Minimal example by using system/controlDict.functions:
bool empty() const noexcept
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
readOption readOpt() const noexcept
Get the read option.
writeOption writeOpt() const noexcept
Get the write option.
bool registerObject() const noexcept
Should objects created with this IOobject be registered?
static readOption lazierRead(readOption opt) noexcept
Downgrade readOption optional (LAZY_READ), leaves NO_READ intact.
@ NO_READ
Nothing to be read.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const Time & time() const noexcept
Return Time associated with the objectRegistry.
const word & name() const noexcept
Return the object name.
const objectRegistry & db() const noexcept
Return the local objectRegistry.
InfoProxy< IOobject > info() const noexcept
Return info proxy, for printing information to a stream.
const fileName & instance() const noexcept
Read access to instance path component.
fileName objectPath() const
The complete path + object name.
A simple container for options an IOstream can normally have.
streamFormat format() const noexcept
Get the current stream format.
@ ASCII
"ascii" (normal default)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void resize_nocopy(const label len)
Adjust allocated size of list without necessarily.
void append(const T &val)
Append an element at the end of the list.
void setSize(label n)
Alias for resize().
void clear()
Clear the list, i.e. set size to zero.
static const List< T > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files.
virtual Ostream & write(const char c) override
Write character.
virtual const fileName & name() const override
Read/write access to the name of the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
An ordered pair of two objects of type <T> with first() and second() elements.
bool hit() const noexcept
Is there a hit?
const Field< point_type > & localPoints() const
const Field< point_type > & points() const noexcept
Return reference to global points.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
UPstream::rangeType allProcs() const noexcept
Range of ranks indices associated with PstreamBuffers.
label recvDataCount(const label proci) const
Number of unconsumed receive bytes for the specified processor. Must call finishedSends() or other fi...
void finishedSends(const bool wait=true)
Mark the send phase as being finished.
static void listCombineGather(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::listGather with an in-place cop.
static void allGatherList(UList< T > &values, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather data, but keep individual values separate. Uses MPI_Allgather or manual communication.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
const T1 & first() const noexcept
Access the first element.
const T2 & second() const noexcept
Access the second element.
Input inter-processor communications stream using MPI send/recv etc. - operating on external buffer.
A List with indirect addressing. Like IndirectList but does not store addressing.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
label rcIndex(const label i) const noexcept
The reverse circular index. The previous index in the list which returns to the last at the beginning...
void size(const label n)
Older name for setAddressableSize.
T & operator[](const label i)
Return element of UList.
label find(const T &val) const
Find index of the first occurrence of the value.
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
Output inter-processor communications stream using MPI send/recv etc. - operating on external buffer.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Negative if the process is not a...
@ nonBlocking
"nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static int & msgType() noexcept
Message tag of standard messages.
static List< T > listGatherValues(const T &localValue, const int communicator=UPstream::worldComm)
Gather individual values into list locations.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run.
static rangeType subProcs(const label communicator=worldComm)
Range of process indices for sub-processes.
@ broadcast
broadcast [MPI]
static bool & parRun() noexcept
Test if this a parallel run.
static Form uniform(const Cmpt &s)
Return a VectorSpace with all elements = s.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A bounding box defined in terms of min/max extrema points.
void reduce()
Inplace parallel reduction of min/max values, using UPstream::worldComm.
void add(const boundBox &bb)
Extend to include the second box.
static autoPtr< decompositionMethod > New(const dictionary &decompDict, const word ®ionName="")
Return a reference to the selected decomposition method, optionally region-specific.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
IOoject and searching on distributed triSurface. All processor hold (possibly overlapping) part of th...
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
virtual void flip()
Flip triangles, outsideVolumeType and all cached inside/outside.
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
static const Enum< distributionType > distributionTypeNames_
virtual void distribute(const List< treeBoundBox > &, const bool keepNonLocal, autoPtr< mapDistribute > &faceMap, autoPtr< mapDistribute > &pointMap)
Set bounds of surface. Bounds currently set as list of.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
static void overlappingSurface(const triSurface &, const List< treeBoundBox > &, boolList &includedFace)
Calculate the triangles that are overlapping bounds.
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
virtual autoPtr< mapDistribute > localQueries(const List< pointIndexHit > &, labelList &triangleIndex) const
Obtains global indices from pointIndexHit and swaps them back.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual void getRegion(const List< pointIndexHit > &, labelList ®ion) const
From a set of points and indices get the region.
const globalIndex & globalTris() const
Triangle indexing (demand driven).
void writeStats(Ostream &os) const
Print some stats. Parallel aware version of.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
virtual ~distributedTriSurfaceMesh()
Destructor.
void clearOut()
Clear storage.
Accumulating histogram of values. Specified bin resolution automatic generation of bins.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
A class for handling file names.
static std::string path(const std::string &str)
Return directory path name (part before last /).
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
label toLocal(const label proci, const label i) const
From global to local on proci.
label whichProcID(const label proci, const label i) const
Which processor does global id come from? Checks proci first (assumed to occur reasonably frequently)...
static label getNode(const labelBits i)
Return real (dereferenced) index for a parent node.
static bool isNode(labelBits i) noexcept
A parent node.
static bool isContent(labelBits i) noexcept
Node with content (leaf).
Non-pointer based hierarchical recursive searching.
const List< node > & nodes() const noexcept
List of all nodes.
PackedList< 2 > & nodeTypes() const noexcept
Per node, per octant whether is fully inside/outside/mixed.
A 29bits (or 61bits) integer label with 3bits direction (eg, octant) packed into single label.
static constexpr label pack(const label val, const direction bits) noexcept
Pack integer value and bits (octant) into a label.
A triFace with additional (region) index.
label region() const noexcept
Return the region index.
const labelListList & constructMap() const noexcept
From subsetted data to new reconstructed data.
bool constructHasFlip() const noexcept
Does constructMap include a sign.
const labelListList & subMap() const noexcept
From subsetted data back to original data.
bool subHasFlip() const noexcept
Does subMap include a sign.
static void distribute(const UPstream::commsTypes commsType, const UList< labelPair > &schedule, const label constructSize, const labelListList &subMap, const bool subHasFlip, const labelListList &constructMap, const bool constructHasFlip, List< T > &field, const T &nullValue, const CombineOp &cop, const NegateOp &negOp, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Distribute combine data with specified combine operation and negate operator (for flips).
label comm() const noexcept
The communicator used.
Class containing processor-to-processor mapping information.
void reverseDistribute(const label constructSize, List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute List data using default commsType, default flip/negate operator.
void operator()(nearestAndDist &x, const nearestAndDist &y) const
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
static bool orientConsistent(triSurface &s)
Make sure surface has consistent orientation across connected.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
virtual const boundBox & bounds() const
Return const reference to boundBox.
Standard boundBox with extra functionality for use in octree.
treeBoundBox subBbox(const direction octant) const
Sub-box of given octant. Midpoint calculated.
static const treeBoundBox & null() noexcept
The null treeBoundBox is the same as an inverted box.
label surfaceClosed_
Is surface closed.
virtual label size() const
Range of local indices that can be returned.
virtual void flip()
Flip triangles, outsideVolumeType and all cached inside/outside.
volumeType outsideVolType_
If surface is closed, what is type of outside points.
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
virtual void getVolumeType(const pointField &points, List< volumeType > &volType) const
Determine type (inside/outside/mixed) for point.
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
triSurfaceMesh(const triSurfaceMesh &)=delete
No copy construct.
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
virtual bool hasVolumeType() const
Whether supports volume type (below) - i.e. whether is closed.
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
void clearOut()
Clear storage.
pointIndexHit nearest(const point &pt, const vector &span) const
Calculate nearest point on surface for single searchPoint. Returns.
Triangulated surface description with patch information.
static fileName findFile(const IOobject &io, const bool isGlobal=true)
Use IOobject information to resolve file to load from, or empty if the file does not exist.
labelledTri face_type
The face type (same as the underlying PrimitivePatch).
void write(Ostream &os) const
Write to Ostream in simple OpenFOAM format.
void operator=(const triSurface &surf)
Copy assignment.
barycentric2D pointToBarycentric(const point &pt) const
Calculate the barycentric coordinates from the given point.
Combine operator for volume types.
void operator()(volumeType &x, const volumeType &y) const
An enumeration wrapper for classification of a location as being inside/outside of a volume.
static const Enum< volumeType::type > names
Names for the classification enumeration.
type
Volume classification types.
@ OUTSIDE
A location outside the volume.
@ MIXED
A location that is partly inside and outside.
@ INSIDE
A location inside the volume.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Determine correspondence between points. See below.
#define DebugInFunction
Report an information message using Foam::Info.
#define InfoInFunction
Report an information message using Foam::Info.
List< T > createWithValue(const label len, const labelUList &locations, const T &val, const T &deflt=T())
Create a List filled with default values and various locations with another specified value.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Namespace for bounding specifications. At the moment, mostly for tables.
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for handling debugging switches.
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Pair< label > labelPair
A pair of labels.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
DimensionedField< label, triSurfaceGeoMesh > triSurfaceLabelField
List< labelList > labelListList
List of labelList.
PointHit< point > pointHit
A PointHit with a 3D point.
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
List< treeBoundBox > treeBoundBoxList
A List of treeBoundBox.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler().
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Tuple2< pointIndexHit, scalar > nearestAndDist
Combine operator for nearest.
List< instant > instantList
List of instants.
const nearestAndDist nearestZero(nearestAndDist(pointIndexHit(), -GREAT))
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
label mergePoints(const PointList &points, labelList &pointToUnique, labelList &uniquePoints, const scalar mergeTol=SMALL, const bool verbose=false)
Calculate merge mapping, preserving the original point order. All points closer/equal mergeTol are to...
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
line< point, const point & > linePointRef
A line using referred points.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
List< bool > boolList
A List of bools.
static constexpr const zero Zero
Global zero (0).
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
bool matchPoints(const UList< point > &pts0, const UList< point > &pts1, const UList< scalar > &matchDistance, const bool verbose, labelList &from0To1, const point &origin=point::zero)
Determine correspondence between pointFields. Gets passed.
triangle< point, const point & > triPointRef
A triangle using referred points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
constexpr char nl
The newline '\n' character (0x0a).
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} pointMap[start]=pointMap[end]=Foam::min(start, end);} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};constexpr label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< DynamicList< face > > pFaces[nBCs]
Tree tree(triangles.begin(), triangles.end())
#define forAll(list, i)
Loop across all elements in list.
A functor that returns its argument unchanged (cf. C++20 std::identity) Should never be specialized.
scalarField samples(nIntervals, Zero)