72Foam::label Foam::snappySnapDriver::getCollocatedPoints
76 bitSet& isCollocatedPoint
87 bool hasMerged = (nUnique <
points.size());
95 label nCollocated = 0;
100 forAll(pointMap, oldPointi)
112 isCollocatedPoint.set(oldPointi);
118 isCollocatedPoint.set(firstOldPoint[
newPointi]);
121 isCollocatedPoint.set(oldPointi);
132Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothInternalDisplacement
142 const hexRef8& cutter = meshRefiner.meshCutter();
143 const labelList& cellLevel = cutter.cellLevel();
187 label nInterface = 0;
194 if (!isFront.test(facei) && ownLevel != neiLevel)
197 isMovingPoint.
set(
f);
211 if (!isFront.test(facei) && ownLevel != neiLevel)
214 isMovingPoint.
set(
f);
224 <<
" inbetween refinement regions." <<
endl;
247 forAll(isMovingPoint, pointi)
249 if (isMovingPoint.test(pointi))
253 sumLocation[pointi].
first() = pCells.size();
254 for (
const label celli : pCells)
265 auto& displacement = tdisplacement.ref();
269 forAll(displacement, pointi)
272 if (
mag(wp.first()) > VSMALL)
274 displacement[pointi] =
275 wp.second()/wp.first()
282 <<
" points inbetween refinement regions."
285 return tdisplacement;
290Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothPatchDisplacement
300 label nNonManifoldPoints = getCollocatedPoints
306 Info<<
"Found " << nNonManifoldPoints <<
" non-manifold point(s)."
334 label f0 = baffles[i].first();
335 label f1 = baffles[i].second();
337 if (isMasterFace.test(f0))
340 isMasterFace.unset(f1);
342 else if (isMasterFace.test(f1))
344 isMasterFace.unset(f0);
349 <<
"Both sides of baffle consisting of faces " << f0
350 <<
" and " << f1 <<
" are already slave faces."
366 forAll(pointFaces, patchPointi)
372 label facei =
pFaces[pfi];
376 avgBoundary[patchPointi].first() += 1.0;
377 avgBoundary[patchPointi].second() +=
390 if (
mag(avgBoundary[i].first()) > VSMALL)
392 avgBoundary[i].second() /= avgBoundary[i].first();
414 const face&
f = faces[facei];
444 const point& fc = faceCentres[i];
459 avgInternal.setSize(meshPoints.size());
461 forAll(avgInternal, patchPointi)
463 label meshPointi = meshPoints[patchPointi];
466 avgInternal[patchPointi].
first() = wp.first();
467 if (
mag(wp.first()) < VSMALL)
470 avgInternal[patchPointi].second() = wp.second();
474 avgInternal[patchPointi].second() = wp.second()/wp.first();
491 anyCell[
f[fp]] = own;
498 auto& patchDisp = tpatchDisp.ref();
502 label meshPointi = meshPoints[i];
516 if (!nonManifoldPoint.test(i))
520 scalar internalBlend = 0.1;
533 newPos = (1-blend)*avgPos + blend*currentPos;
543 scalar cellCBlend = 0.8;
546 point avgPos = (1-cellCBlend)*
boundary.second() + cellCBlend*cc;
548 newPos = (1-blend)*avgPos + blend*currentPos;
553 scalar internalBlend = 0.9;
558 + (1-internalBlend)*
boundary.second();
560 newPos = (1-blend)*avgPos + blend*currentPos;
563 patchDisp[i] = newPos - currentPos;
631Foam::tmp<Foam::scalarField> Foam::snappySnapDriver::edgePatchDist
666 auto& edgeDist = tedgeDist.ref();
668 forAll(allEdgeInfo, edgei)
670 edgeDist[edgei] =
Foam::sqrt(allEdgeInfo[edgei].distSqr());
677void Foam::snappySnapDriver::dumpMove
685 Info<<
"Dumping move direction to " << fName <<
endl;
699 nearestStream<<
"l " << verti-1 <<
' ' << verti <<
nl;
706bool Foam::snappySnapDriver::outwardsDisplacement
715 forAll(pointFaces, pointi)
719 vector disp(patchDisp[pointi]);
721 scalar magDisp =
mag(disp);
731 Warning<<
"Displacement " << patchDisp[pointi]
734 <<
" points through the surrounding patch faces" <<
endl;
747void Foam::snappySnapDriver::freezeExposedPoints
762 const label pointZonei = pointZones.findZoneID(pzName);
763 if (pointZonei != -1)
765 isFrozenPoint.set(pointZones[pointZonei]);
770 const label faceZonei = faceZones.
findZoneID(fzName);
780 const labelList nEdgeFaces(meshRefiner.countEdgeFaces(
pp));
785 if (nEdgeFaces[edgei] != 1)
802 for (
const label pointi : isFrozenPoint)
804 const auto iter = outside.meshPointMap().find(pointi);
807 outsideDisp[iter.val()] =
Zero;
815Foam::snappySnapDriver::snappySnapDriver
817 meshRefinement& meshRefiner,
823 meshRefiner_(meshRefiner),
824 globalToMasterPatch_(globalToMasterPatch),
825 globalToSlavePatch_(globalToSlavePatch),
845 forAll(pointEdges, pointi)
847 const labelList& pEdges = pointEdges[pointi];
851 const edge&
e = edges[pEdges[pEdgei]];
853 scalar len =
e.mag(localPoints);
855 maxEdgeLen[pointi] =
max(maxEdgeLen[pointi], len);
876 const label nInitErrors,
888 Info<<
"Smoothing patch and internal points ..." <<
endl;
892 Info<<
"Smoothing patch points ..." <<
endl;
899 label smoothIter = 0;
904 Info<<
"Smoothing iteration " << smoothIter <<
endl;
908 checkFaces[facei] = facei;
915 pointDisp = smoothInternalDisplacement(meshRefiner, meshMover);
919 pointField patchDisp(smoothPatchDisplacement(meshMover, baffles));
932 scalar oldErrorReduction = -1;
934 for (label snapIter = 0; snapIter < 2*snapParams.
nSnap(); snapIter++)
936 Info<<
nl <<
"Scaling iteration " << snapIter <<
endl;
938 if (snapIter == snapParams.
nSnap())
940 Info<<
"Displacement scaling for error reduction set to 0."
947 if (meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors))
949 Info<<
"Successfully moved mesh" <<
endl;
954 if (oldErrorReduction >= 0)
968 Info<<
"Writing patch smoothed mesh to time "
980 Info<<
"Dumped mesh in = "
984 Info<<
"Patch points smoothed in = "
990void Foam::snappySnapDriver::getZoneSurfacePoints
994 const word& zoneName,
1004 <<
"Cannot find zone " << zoneName
1020 label meshPointi =
f[fp];
1026 const label pointi = iter.val();
1027 pointOnZone[pointi] =
true;
1048 forAll(pointFaces, pointi)
1052 avgBoundary[pointi].first() =
pFaces.size();
1055 label facei =
pFaces[pfi];
1067 return tavgBoundary;
1121 const scalar planarCos,
1130 Info<<
"Detecting near surfaces ..." <<
endl;
1418 forAll(localPoints, pointi)
1420 const point& pt = localPoints[pointi];
1421 const vector d = 2*(avgCc[pointi]-pt);
1422 start[pointi] = pt - d;
1423 end[pointi] = pt + d;
1435 /
"detectNearSurfaces_" + meshRefiner_.timeName() +
".obj"
1441 const bitSet isPatchMasterPoint
1450 label nOverride = 0;
1458 meshRefiner_.surfaces().surfZones()
1489 forAll(localPoints, pointi)
1492 const point& pt = localPoints[pointi];
1494 bool override =
false;
1533 if (hit1[pointi].hit() && hit2[pointi].hit())
1540 hit1[pointi].point(),
1542 hit2[pointi].point(),
1552 gapStr().writeLine(pt, hit2[pointi].
point());
1556 disp[pointi] = hit2[pointi].point()-pt;
1561 if (
override && isPatchMasterPoint[pointi])
1583 label zoneSurfi = zonedSurfaces[i];
1584 const labelList surfacesToTest(1, zoneSurfi);
1587 surfZones[zoneSurfi].faceZoneNames();
1588 forAll(faceZoneNames, namei)
1590 const word& faceZoneName = faceZoneNames[namei];
1594 getZoneSurfacePoints
1633 label pointi = zonePointIndices[i];
1636 const point& pt = localPoints[pointi];
1638 bool override =
false;
1677 if (hit1[i].hit() && hit2[i].hit())
1693 gapStr().writeLine(pt, hit2[i].
point());
1696 disp[pointi] = hit2[i].point()-pt;
1701 if (
override && isPatchMasterPoint[pointi])
1710 Info<<
"Overriding nearest with intersection of close gaps at "
1713 <<
" points." <<
endl;
1717void Foam::snappySnapDriver::calcNearestSurface
1740 if (nearestNormal.
size() == localPoints.
size())
1760 if (hitInfo[i].hit())
1762 label pointi = zonePointIndices[i];
1763 nearestPoint[pointi] = hitInfo[i].point();
1764 nearestNormal[pointi] = hitNormal[i];
1785 if (hitInfo[i].hit())
1787 label pointi = zonePointIndices[i];
1789 patchDisp[pointi] = hitInfo[i].point() - localPoints[pointi];
1790 minSnapDist[pointi] =
mag(patchDisp[pointi]);
1791 snapSurf[pointi] = hitSurface[i];
1799 const bool strictRegionSnap,
1810 Info<<
"Calculating patchDisplacement as distance to nearest surface"
1811 <<
" point ..." <<
endl;
1812 if (strictRegionSnap)
1814 Info<<
" non-zone points : attract to local region on surface only"
1816 <<
" zone points : attract to local region on surface only"
1822 Info<<
" non-zone points :"
1823 <<
" attract to nearest of all non-zone surfaces"
1825 <<
" zone points : attract to zone surface only" <<
nl
1840 labelList snapSurf(localPoints.size(), -1);
1847 if (strictRegionSnap)
1851 forAll(surfaces.surfaces(), surfi)
1853 label geomi = surfaces.surfaces()[surfi];
1854 label nRegions = surfaces.geometry()[geomi].regions().size();
1856 const labelList surfacesToTest(1, surfi);
1858 for (label regioni = 0; regioni < nRegions; regioni++)
1860 label globali = surfaces.globalRegion(surfi, regioni);
1861 label masterPatchi = globalToMasterPatch[globali];
1892 if (globalToSlavePatch[globali] != masterPatchi)
1894 label slavePatchi = globalToSlavePatch[globali];
1934 meshRefiner.surfaces().surfZones()
1944 if (nearestNormal.size() == localPoints.size())
1948 surfaces.findNearestRegion
1961 if (hitInfo[pointi].hit())
1963 nearestPoint[pointi] = hitInfo[pointi].point();
1964 nearestNormal[pointi] = hitNormal[pointi];
1970 surfaces.findNearest
1982 if (hitInfo[pointi].hit())
1985 hitInfo[pointi].point()
1986 - localPoints[pointi];
1988 snapSurf[pointi] = hitSurface[pointi];
1995 meshRefiner.surfaces().surfZones()
2008 label surfi = zonedSurfaces[i];
2009 const labelList surfacesToTest(1, surfi);
2010 const label geomi = surfaces.surfaces()[surfi];
2011 const label nRegions =
2012 surfaces.geometry()[geomi].regions().size();
2015 surfZones[surfi].faceZoneNames();
2019 forAll(faceZoneNames, locali)
2021 getZoneSurfacePoints
2025 faceZoneNames[locali],
2029 const labelList zonePointIndices(pointOnZone.toc());
2056 if (snapSurf[pointi] == -1)
2058 static label nWarn = 0;
2063 <<
"For point:" << pointi
2064 <<
" coordinate:" << localPoints[pointi]
2065 <<
" did not find any surface within:"
2066 << minSnapDist[pointi] <<
" metre." <<
endl;
2071 <<
"Reached warning limit " << nWarn
2072 <<
". Suppressing further warnings." <<
endl;
2079 const bitSet isPatchMasterPoint
2092 Info<<
"Wanted displacement : average:"
2094 <<
" min:" <<
limits.min()
2099 Info<<
"Calculated surface displacement in = "
2105 forAll(patchDisp, patchPointi)
2107 scalar magDisp =
mag(patchDisp[patchPointi]);
2109 if (magDisp > snapDist[patchPointi])
2111 patchDisp[patchPointi] *= snapDist[patchPointi] / magDisp;
2113 Pout<<
"Limiting displacement for " << patchPointi
2114 <<
" from " << magDisp <<
" to " << snapDist[patchPointi]
2127 vector(GREAT, GREAT, GREAT)
2145 const fvMesh&
mesh = meshRefiner_.mesh();
2148 Info<<
"Smoothing displacement ..." <<
endl;
2158 for (label iter = 0; iter < snapParams.
nSmoothDispl(); iter++)
2160 if ((iter % 10) == 0)
2162 Info<<
"Iteration " << iter <<
endl;
2165 meshMover.
smooth(oldDisp, edgeGamma, disp);
2167 Info<<
"Displacement smoothed in = "
2173 Info<<
"Writing smoothed mesh to time " << meshRefiner_.timeName()
2190 Info<<
"Writing displacement field ..." <<
endl;
2195 Info<<
"Writing actual patch displacement ..." <<
endl;
2200 /
"actualPatchDisplacement_" + meshRefiner_.timeName() +
".obj",
2202 pp.localPoints() + actualPatchDisp
2210 const snapParameters& snapParams,
2211 const label nInitErrors,
2212 const List<labelPair>& baffles,
2213 motionSmoother& meshMover
2217 const fvMesh&
mesh = meshRefiner_.mesh();
2223 scalar oldErrorReduction = -1;
2225 bool meshOk =
false;
2228 for (label iter = 0; iter < 2*snapParams.nSnap(); iter++)
2232 if (iter == snapParams.nSnap())
2234 Info<<
"Displacement scaling for error reduction set to 0." <<
endl;
2235 oldErrorReduction = meshMover.setErrorReduction(0.0);
2238 meshOk = meshMover.scaleMesh(checkFaces, baffles,
true, nInitErrors);
2242 Info<<
"Successfully moved mesh" <<
endl;
2248 Info<<
"Writing scaled mesh to time " << meshRefiner_.timeName()
2252 Info<<
"Writing displacement field ..." <<
endl;
2253 meshMover.displacement().write();
2259 if (oldErrorReduction >= 0)
2261 meshMover.setErrorReduction(oldErrorReduction);
2263 Info<<
"Moved mesh in = "
2285 Info<<
"Repatching faces according to nearest surface ..." <<
endl;
2309 forAll(preserveFaces, facei)
2311 if (preserveFaces[facei] != -1)
2313 isZonedFace.
set(facei);
2323 const label zoneSurfi = zonedSurfaces[i];
2324 const wordList& fZoneNames = surfZones[zoneSurfi].faceZoneNames();
2327 const faceZone& fZone = fZones[fZoneNames[i]];
2328 isZonedFace.
set(fZone);
2354 const faceList& localFaces =
pp.localFaces();
2356 forAll(localFaces, facei)
2358 const face&
f = localFaces[facei];
2362 faceSnapDist[facei] =
max
2364 faceSnapDist[facei],
2388 label facei =
pp.addressing()[i];
2390 if (hitSurface[i] != -1 && !isZonedFace.
test(facei))
2392 closestPatch[i] = globalToMasterPatch_
2419 ownPatch[
pp.start()+i] = patchi;
2420 neiPatch[
pp.start()+i] = patchi;
2427 label facei =
pp.addressing()[i];
2429 if (closestPatch[i] != -1 && closestPatch[i] != ownPatch[facei])
2431 ownPatch[facei] = closestPatch[i];
2432 neiPatch[facei] = closestPatch[i];
2438 <<
" faces in = " <<
mesh.time().cpuTimeIncrement() <<
" s\n" <<
nl
2441 return meshRefiner_.createBaffles(ownPatch, neiPatch);
2445void Foam::snappySnapDriver::detectWarpedFaces
2447 const scalar featureCos,
2455 const faceList& localFaces =
pp.localFaces();
2470 forAll(localFaces, facei)
2472 const face&
f = localFaces[facei];
2480 scalar minCos(GREAT);
2482 for (label startFp = 0; startFp <
f.size()-2; startFp++)
2484 label minFp =
f.rcIndex(startFp);
2488 label endFp =
f.fcIndex(
f.fcIndex(startFp));
2489 endFp <
f.size() && endFp != minFp;
2494 f0.setSize(endFp-startFp+1);
2496 for (label fp = startFp; fp <= endFp; fp++)
2500 f1.setSize(
f.size()+2-f0.size());
2502 for (label fp = endFp; fp != startFp; fp =
f.fcIndex(fp))
2506 f1[i1++] =
f[startFp];
2511 const vector n0 = f0.areaNormal(localPoints);
2512 const scalar n0Mag =
mag(n0);
2514 const vector n1 = f1.areaNormal(localPoints);
2515 const scalar n1Mag =
mag(n1);
2517 if (n0Mag > ROOTVSMALL && n1Mag > ROOTVSMALL)
2519 scalar cosAngle = (n0/n0Mag) & (n1/n1Mag);
2520 if (cosAngle < minCos)
2530 if (minCos < featureCos)
2532 splitFaces.
append(bFaces[facei]);
2540Foam::labelList Foam::snappySnapDriver::getInternalOrBaffleDuplicateFace()
const
2549 internalOrBaffleFaceZones = meshRefiner_.getZones(fzTypes);
2554 meshRefiner_.subsetBaffles
2557 internalOrBaffleFaceZones,
2566 faceToDuplicate[
p[0]] =
p[1];
2567 faceToDuplicate[
p[1]] =
p[0];
2570 return faceToDuplicate;
2579 const scalar featureCos,
2580 const scalar planarAngle,
2581 const snapParameters& snapParams
2604 <<
"Morphing phase" <<
nl
2605 <<
"--------------" <<
nl
2645 bufPatchIDs.setCapacity(globalToMasterPatch_.size());
2647 const auto& addLayers =
2648 meshRefiner_.surfaces().addBufferLayers();
2651 forAll(globalToMasterPatch_, globalRegioni)
2653 if (addLayers[globalRegioni])
2655 bufPatchIDs.push_uniq(globalToMasterPatch_[globalRegioni]);
2656 bufPatchIDs.push_uniq(globalToSlavePatch_[globalRegioni]);
2665 if (meshRefiner_.getFaceZoneInfo(fz.name(), mpI, spI,
type))
2667 bufPatchIDs.push_uniq(mpI);
2668 bufPatchIDs.push_uniq(spI);
2678 meshRefiner_.getZones
2693 meshRefiner_.createZoneBaffles
2707 const labelList& reverseFaceMap = map->reverseFaceMap();
2710 label f0 = reverseFaceMap[baffles[i].first()];
2711 label f1 = reverseFaceMap[baffles[i].second()];
2718 bool doFeatures =
false;
2719 label nFeatIter = 1;
2720 if (snapParams.nFeatureSnap() > 0)
2726 nFeatIter = snapParams.nFeatureSnap();
2729 Info<<
"Snapping to features in " << nFeatIter
2730 <<
" iterations ..." <<
endl;
2734 bool meshOk =
false;
2738 const labelList adaptPatchIDs(meshRefiner_.meshedPatches());
2757 Info<<
"Constructing mesh displacer ..." <<
endl;
2758 Info<<
"Using mesh parameters " << motionDict <<
nl <<
endl;
2779 Info<<
"Checking initial mesh ..." <<
endl;
2788 Info<<
"Detected " << nInitErrors <<
" illegal faces"
2789 <<
" (concave, zero area or negative cell pyramid volume)"
2793 Info<<
"Checked initial mesh in = "
2800 meshRefiner_.subsetBaffles
2948 Info<<
"Adding buffer layers ..." <<
endl;
2951 meshMoverPtr.clear();
3071 wantedThickness(bufPatchPtr(), 1
e-1)
3094 for (
auto& ppf : tdisp.ref().boundaryFieldRef())
3096 ppf == ppf.patchInternalField();
3101 pcs.constrainDisplacement(tdisp.ref(),
false);
3113 for (
const label patchi : bufPatchIDs)
3115 maxLen =
max(maxLen, label(
pbm[patchi].
name().size()));
3118 const int oldPrecision =
Info.stream().precision();
3121 <<
setf(ios_base::left) <<
setw(maxLen) <<
"patch"
3122 <<
setw(0) <<
" faces layers thickness[m]" <<
nl
3123 <<
setf(ios_base::left) <<
setw(maxLen) <<
"-----"
3124 <<
setw(0) <<
" ----- ------ ------------" <<
endl;
3126 for (
const label patchi : bufPatchIDs)
3132 <<
" " <<
setw(6) << 1
3173 meshRefiner_.mergePoints(pointToMaster);
3197 Info<<
"Writing merged points buffer layer mesh"
3198 <<
" to time " << meshRefiner_.timeName() <<
endl;
3207 meshRefiner_.timeName()
3214 Info<<
"Inflating buffer layers ..." <<
endl;
3242 Info<<
"Writing smoothed buffer layer mesh to time "
3243 << meshRefiner_.timeName() <<
endl;
3252 meshRefiner_.timeName()
3261 snapDist = calcSnapDistance(
mesh, snapParams, ppPtr());
3297 for (label iter = 0; iter < nFeatIter; iter++)
3300 <<
"Morph iteration " << iter <<
nl
3301 <<
"-----------------" <<
endl;
3304 bool doSplit =
false;
3308 && snapParams.nFaceSplitInterval() > 0
3310 (iter == nFeatIter-1)
3311 || (iter > 0 && (iter%snapParams.nFaceSplitInterval()) == 0)
3330 if (snapParams.detectNearSurfacesSnap() || doSplit)
3338 snapParams.strictRegionSnap(),
3340 globalToMasterPatch_,
3341 globalToSlavePatch_,
3352 if (snapParams.detectNearSurfacesSnap())
3371 splitPatches.clear();
3372 disp = calcNearestSurfaceFeature
3379 scalar(iter+1)/nFeatIter,
3397 outwardsDisplacement(
pp, disp);
3412 meshMover.setDisplacement(disp);
3420 /
"patchDisplacement_" +
name(iter) +
".obj",
3427 smoothDisplacement(snapParams, meshMover);
3441 <<
"Did not successfully snap mesh."
3442 <<
" Continuing to snap to resolve easy" <<
nl
3443 <<
" surfaces but the"
3444 <<
" resulting mesh will not satisfy your quality"
3445 <<
" constraints" <<
nl <<
endl;
3451 Info<<
"Writing scaled mesh to time "
3452 << meshRefiner_.timeName() <<
endl;
3463 Info<<
"Writing displacement field ..." <<
endl;
3464 meshMover.displacement().write();
3467 mag(meshMover.displacement())
3473 meshMover.correct();
3479 if (nTotalSplit && doSplit)
3484 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3487 labelList oldSplitFaces(std::move(splitFaces));
3492 if (duplicateFace[oldSplitFaces[i]] == -1)
3494 splitFaces.append(oldSplitFaces[i]);
3495 splits.append(oldSplits[i]);
3496 splitPatches.append(oldSplitPatches[i]);
3511 meshRefiner_.splitFacesUndo
3523 meshMoverPtr.clear();
3546 snapDist = calcSnapDistance(
mesh, snapParams, ppPtr());
3552 Info<<
"Writing split-faces mesh to time "
3553 << meshRefiner_.timeName() <<
endl;
3570 forAll(internalBaffles, i)
3576 if (
mag(fc0-fc1) > meshRefiner_.mergeDistance())
3579 <<
"Separated baffles : f0:" <<
p[0]
3580 <<
" centre:" << fc0
3581 <<
" f1:" <<
p[1] <<
" centre:" << fc1
3582 <<
" distance:" <<
mag(fc0-fc1)
3608 Info<<
"Writing baffle-merged mesh to time "
3609 << meshRefiner_.timeName() <<
endl;
3618 meshRefiner_.timeName()
3626 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3628 repatchToSurface(snapParams, adaptPatchIDs, duplicateFace);
3637 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3642 label nChanged = meshRefiner_.mergePatchFacesUndo
3646 meshRefiner_.meshedPatches(),
3652 nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict);
3657 Info<<
"Writing patchFace merged mesh to time "
3658 << meshRefiner_.timeName() <<
endl;
3667 meshRefiner_.timeName()
Istream and Ostream manipulators taking arguments.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
const polyBoundaryMesh & pbm
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
label push_uniq(const T &val)
Append an element if not already in the list.
void setCapacity(const label len)
Alter the size of the underlying storage.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
SubField< vector > subField
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
label size() const noexcept
The number of elements in table.
const word & name() const noexcept
Return the object name.
const Addr & addressing() const noexcept
The addressing used for the list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
void setSize(label n)
Alias for resize().
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &mesh, Args &&... args)
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
Wave propagation of information through grid. Every iteration information goes through one layer of e...
label nPoints() const
Number of points supporting patch faces.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Map< label > & meshPointMap() const
Mesh point map.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
const Field< point_type > & points() const noexcept
Return reference to global points.
const Field< point_type > & faceCentres() const
Return face centres for patch.
const labelListList & pointFaces() const
Return point-face addressing.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
fileName path() const
The path for the case = rootPath/caseName.
const T1 & first() const noexcept
Access the first element.
A List with indirect addressing. Like IndirectList but does not store addressing.
T & first()
Access first element of the list, position [0].
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of entries in the list.
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
Adds layers of cells to outside (or inside) of polyMesh. Can optionally create stand-alone extruded m...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void clear() noexcept
Same as reset(nullptr).
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
labelList toc() const
The indices of the on bits as a sorted labelList.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
double cpuTimeIncrement() const
Return CPU time [seconds] since last call to cpuTimeIncrement(), resetCpuTimeIncrement().
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
A subset of mesh faces organised as a primitive patch.
A face is a list of labels corresponding to mesh vertices.
A class for handling file names.
Mesh data needed to do the Finite Volume discretisation.
const Time & time() const
Return the top-level database.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
label nTotalFaces() const noexcept
Total global number of mesh faces. Not compensated for duplicate faces!
label nTotalPoints() const noexcept
Total global number of mesh points. Not compensated for duplicate points!
Refinement of (split) hexes using polyTopoChange.
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
static T gAverage(const bitSet &isMasterElem, const UList< T > &values)
Helper: calculate average.
@ CASTELLATEDBUFFERLAYER2
static bitSet getMasterPoints(const polyMesh &mesh, const labelList &meshPoints)
Determine master point for subset of points. If coupled.
static void mapBaffles(const polyMesh &mesh, const labelList &faceMap, List< labelPair > &baffles)
Map baffles after layer addition. Gets new-to-old face map.
static List< labelPair > subsetBaffles(const polyMesh &mesh, const labelList &zoneIDs, const List< labelPair > &baffles)
Subset baffles according to zones.
writeType
Enumeration for what to write. Used as a bit-pattern.
const refinementSurfaces & surfaces() const
Reference to surface search engines.
word timeName() const
Replacement for Time::timeName() that returns oldInstance (if overwrite_).
debugType
Enumeration for what to debug. Used as a bit-pattern.
const fvMesh & mesh() const
Reference to mesh.
static tmp< pointVectorField > makeDisplacementField(const pointMesh &pMesh, const labelList &adaptPatchIDs)
Helper function to make a pointVectorField with correct.
FaceMergeType
Enumeration for what to do with co-planar patch faces on a single.
static autoPtr< indirectPrimitivePatch > makePatch(const polyMesh &, const labelList &)
Create patch from set of patches.
bool write() const
Write mesh and all data.
static writeType writeLevel()
Get/set write level.
scalar setErrorReduction(const scalar)
Set the errorReduction (by how much to scale the displacement.
static void setDisplacement(const labelList &patchIDs, const indirectPrimitivePatch &pp, pointField &patchDisp, pointVectorField &displacement)
Set displacement field from displacement on patch points.
void correct()
Take over existing mesh position.
const indirectPrimitivePatch & patch() const
Reference to patch.
void smooth(const GeometricField< Type, pointPatchField, pointMesh > &fld, const scalarField &edgeWeight, GeometricField< Type, pointPatchField, pointMesh > &newFld) const
Fully explicit smoothing of fields (not positions).
const pointMesh & pMesh() const
Reference to pointMesh.
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces, const bool dryRun=false)
Check mesh with mesh settings in dict. Collects incorrect faces.
pointVectorField & pointDisplacement()
Return reference to the point motion displacement field.
bool scaleMesh(labelList &checkFaces, const bool smoothMesh=true, const label nAllow=0)
Move mesh with given scale. Return true if mesh ok or has.
pointVectorField & displacement()
Reference to displacement field.
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh err...
A traits class, which is primarily used for primitives and vector-space.
Application of (multi-)patch point constraints.
void constrainDisplacement(pointVectorField &displacement, const bool overrideValue=false) const
Apply boundary conditions (single-patch constraints),.
Holds information regarding nearest wall point. Used in PointEdgeWave. (so not standard FaceCellWave)...
Mesh representing a set of points created from polyMesh.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
virtual const faceList & faces() const
Return raw faces.
bool moving() const noexcept
Is mesh moving.
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info (demand-driven).
virtual const labelList & faceNeighbour() const
Return face neighbour.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
const vectorField & faceCentres() const
const labelListList & pointCells() const
label nInternalFaces() const noexcept
Number of internal faces.
const vectorField & cellCentres() const
label nPoints() const noexcept
Number of mesh points.
label nFaces() const noexcept
Number of mesh faces.
label nEdges() const
Number of mesh edges.
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
const searchableSurfaces & geometry() const
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
const labelList & surfaces() const
void findNearestRegion(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &hitSurface, labelList &hitRegion) const
Find nearest point on surfaces. Return surface and region on.
void findNearestIntersection(const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList ®ion1, labelList &surface2, List< pointIndexHit > &hit2, labelList ®ion2) const
Find intersection nearest to the endpoints. surface1,2 are.
const PtrList< surfaceZonesInfo > & surfZones() const
virtual bool write(const bool writeOnProc=true) const
Write using setting from DB.
Simple container to keep together snap specific information.
label nSmoothDispl() const
Number of mesh displacement smoothing iterations.
scalar snapTol() const
Relative distance for points to be attracted by surface.
label nSnap() const
Maximum number of snapping relaxation iterations. Should stop.
Switch strictRegionSnap() const
Attract point to corresponding surface region only.
label nSmoothPatch() const
Number of patch smoothing iterations before finding.
label nFeatureSnap() const
label nSmoothInternal() const
Number of internal point smoothing iterations (combined with.
label nFaceSplitInterval() const
Switch detectNearSurfacesSnap() const
Override attraction to nearest with intersection location.
static autoPtr< mapPolyMesh > dupFaceZonePoints(meshRefinement &meshRefiner, const labelList &patchIDs, const labelList &numLayers, List< labelPair > baffles, labelList &pointToMaster)
Duplicate points on faceZones with layers. Re-used when adding buffer layers. Can be made private aga...
static void mapFaceZonePoints(meshRefinement &meshRefiner, const mapPolyMesh &map, labelPairList &baffles, labelList &pointToMaster)
Map numbering after adding cell layers.
All to do with snapping to surface.
void detectNearSurfaces(const scalar planarCos, const indirectPrimitivePatch &pp, const pointField &ppLocalPoints, const pointField &nearestPoint, const vectorField &nearestNormal, vectorField &disp) const
Per patch point override displacement if in gap situation.
bool scaleMesh(const snapParameters &snapParams, const label nInitErrors, const List< labelPair > &baffles, motionSmoother &)
Do the hard work: move the mesh according to displacement,.
static void preSmoothPatch(const meshRefinement &meshRefiner, const snapParameters &snapParams, const label nInitErrors, const List< labelPair > &baffles, motionSmoother &)
Smooth the mesh (patch and internal) to increase visibility.
static tmp< pointField > avgCellCentres(const fvMesh &mesh, const indirectPrimitivePatch &)
Helper: calculate average cell centre per point.
void doSnap(const dictionary &snapDict, const dictionary &motionDict, const meshRefinement::FaceMergeType mergeType, const scalar featureCos, const scalar planarAngle, const snapParameters &snapParams)
Snap onto surface & features.
void smoothDisplacement(const snapParameters &snapParams, motionSmoother &) const
Smooth the displacement field to the internal.
autoPtr< mapPolyMesh > repatchToSurface(const snapParameters &snapParams, const labelList &adaptPatchIDs, const labelList &preserveFaces)
Repatch faces according to surface nearest the face centre.
static scalarField calcSnapDistance(const fvMesh &mesh, const snapParameters &snapParams, const indirectPrimitivePatch &)
Calculate edge length per patch point.
static labelList getUnnamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of unnamed surfaces (surfaces without faceZoneName).
faceZoneType
What to do with faceZone faces.
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName).
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Wrapper for position + weight to be used in e.g. averaging.
static void getPoints(const UList< weightedPosition > &in, List< point > &out)
Get points.
static void syncPoints(const polyMesh &mesh, List< weightedPosition > &)
Synchronisation for mesh point positions.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Geometric merging of points. See below.
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar mp
Proton mass.
Namespace for handling debugging switches.
const wordList internal
Standard volume internal field types (scalar, vector, tensor, etc).
List< edge > edgeList
List of edge.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Pair< label > labelPair
A pair of labels.
List< word > wordList
List of word.
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.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with pointZone content on a polyMesh.
List< labelPair > labelPairList
List of labelPair.
List< labelList > labelListList
List of labelList.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Smanip< std::ios_base::fmtflags > setf(std::ios_base::fmtflags flags)
messageStream Info
Information stream (stdout output on master, null elsewhere).
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
List< face > faceList
List of faces.
GeometricField< vector, pointPatchField, pointMesh > pointVectorField
Omanip< int > setprecision(const int i)
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.
Omanip< int > setw(const int i)
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.
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
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.
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
static constexpr const zero Zero
Global zero (0).
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.
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensionedScalar cos(const dimensionedScalar &ds)
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional 'FOAM Warning' header text.
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]
#define forAll(list, i)
Loop across all elements in list.
Unit conversion functions.