Go to the documentation of this file.
67 Foam::label Foam::snappySnapDriver::getCollocatedPoints
71 bitSet& isCollocatedPoint
82 bool hasMerged = (nUnique <
points.size());
90 label nCollocated = 0;
95 forAll(pointMap, oldPointi)
107 isCollocatedPoint.set(oldPointi);
113 isCollocatedPoint.set(firstOldPoint[
newPointi]);
116 isCollocatedPoint.set(oldPointi);
129 const meshRefinement& meshRefiner,
130 const motionSmoother& meshMover
134 const polyMesh&
mesh = meshMover.mesh();
137 const hexRef8& cutter = meshRefiner.meshCutter();
138 const labelList& cellLevel = cutter.cellLevel();
142 bitSet isFront(
mesh.
nFaces(), pp.addressing());
182 label nInterface = 0;
189 if (!isFront.test(facei) && ownLevel != neiLevel)
192 isMovingPoint.
set(
f);
206 if (!isFront.test(facei) && ownLevel != neiLevel)
209 isMovingPoint.
set(
f);
217 reduce(nInterface, sumOp<label>());
218 Info<<
"Found " << nInterface <<
" faces out of "
220 <<
" inbetween refinement regions." <<
endl;
229 isMovingPoint.unset(pp.meshPoints());
240 forAll(isMovingPoint, pointi)
242 if (isMovingPoint.test(pointi))
265 pointField& displacement = tdisplacement.ref();
269 forAll(displacement, pointi)
271 if (nCells[pointi] > 0)
273 displacement[pointi] =
274 sumLocation[pointi]/nCells[pointi]-
mesh.
points()[pointi];
279 reduce(nAdapted, sumOp<label>());
280 Info<<
"Smoothing " << nAdapted <<
" points inbetween refinement regions."
283 return tdisplacement;
290 const motionSmoother& meshMover,
291 const List<labelPair>& baffles
297 bitSet nonManifoldPoint(pp.nPoints());
298 label nNonManifoldPoints = getCollocatedPoints
304 Info<<
"Found " << nNonManifoldPoints <<
" non-manifold point(s)."
322 const labelList& meshPoints = pp.meshPoints();
324 const polyMesh&
mesh = meshMover.mesh();
332 label f0 = baffles[i].first();
333 label f1 = baffles[i].second();
335 if (isMasterFace.test(f0))
338 isMasterFace.unset(f1);
340 else if (isMasterFace.test(f1))
342 isMasterFace.unset(f0);
347 <<
"Both sides of baffle consisting of faces " << f0
348 <<
" and " << f1 <<
" are already slave faces."
361 forAll(pointFaces, patchPointi)
367 label facei =
pFaces[pfi];
369 if (isMasterFace.test(pp.addressing()[facei]))
371 avgBoundary[patchPointi] += pp[facei].centre(
points);
372 nBoundary[patchPointi]++;
396 avgBoundary[i] /= nBoundary[i];
414 const face&
f = faces[facei];
419 globalSum[
f[fp]] += fc;
432 && refCast<const coupledPolyPatch>(
patches[patchi]).owner()
435 const coupledPolyPatch& pp =
436 refCast<const coupledPolyPatch>(
patches[patchi]);
442 const face&
f = pp[i];
443 const point& fc = faceCentres[i];
447 globalSum[
f[fp]] += fc;
469 avgInternal.setSize(meshPoints.size());
470 nInternal.setSize(meshPoints.size());
472 forAll(avgInternal, patchPointi)
474 label meshPointi = meshPoints[patchPointi];
476 nInternal[patchPointi] = globalNum[meshPointi];
478 if (nInternal[patchPointi] == 0)
480 avgInternal[patchPointi] = globalSum[meshPointi];
484 avgInternal[patchPointi] =
485 globalSum[meshPointi]
486 / nInternal[patchPointi];
503 anyCell[
f[fp]] = own;
509 tmp<pointField> tpatchDisp(
new pointField(meshPoints.size(),
Zero));
514 label meshPointi = meshPoints[i];
515 const point& currentPos = pp.points()[meshPointi];
526 if (!nonManifoldPoint.test(i))
530 scalar internalBlend = 0.1;
535 internalBlend*nInternal[i]*avgInternal[i]
536 +(1-internalBlend)*nBoundary[i]*avgBoundary[i]
538 / (internalBlend*nInternal[i]+(1-internalBlend)*nBoundary[i]);
540 newPos = (1-blend)*avgPos + blend*currentPos;
542 else if (nInternal[i] == 0)
550 scalar cellCBlend = 0.8;
553 point avgPos = (1-cellCBlend)*avgBoundary[i] + cellCBlend*cc;
555 newPos = (1-blend)*avgPos + blend*currentPos;
560 scalar internalBlend = 0.9;
564 internalBlend*avgInternal[i]
565 + (1-internalBlend)*avgBoundary[i];
567 newPos = (1-blend)*avgPos + blend*currentPos;
570 patchDisp[i] = newPos - currentPos;
640 const pointMesh& pMesh,
644 const polyMesh&
mesh = pMesh();
647 List<pointEdgePoint> wallInfo(pp.nPoints());
649 forAll(pp.localPoints(), ppi)
651 wallInfo[ppi] = pointEdgePoint(pp.localPoints()[ppi], 0.0);
658 List<pointEdgePoint> allEdgeInfo(
mesh.
nEdges());
660 PointEdgeWave<pointEdgePoint> wallCalc
675 forAll(allEdgeInfo, edgei)
677 edgeDist[edgei] =
Foam::sqrt(allEdgeInfo[edgei].distSqr());
684 void Foam::snappySnapDriver::dumpMove
686 const fileName& fName,
692 Info<<
"Dumping move direction to " << fName <<
endl;
694 OFstream nearestStream(fName);
706 nearestStream<<
"l " << verti-1 <<
' ' << verti <<
nl;
713 bool Foam::snappySnapDriver::outwardsDisplacement
722 forAll(pointFaces, pointi)
726 vector disp(patchDisp[pointi]);
728 scalar magDisp =
mag(disp);
738 Warning<<
"Displacement " << patchDisp[pointi]
739 <<
" at mesh point " << pp.meshPoints()[pointi]
740 <<
" coord " << pp.points()[pp.meshPoints()[pointi]]
741 <<
" points through the surrounding patch faces" <<
endl;
756 Foam::snappySnapDriver::snappySnapDriver
764 meshRefiner_(meshRefiner),
765 globalToMasterPatch_(globalToMasterPatch),
766 globalToSlavePatch_(globalToSlavePatch),
784 scalarField maxEdgeLen(localPoints.size(), -GREAT);
786 forAll(pointEdges, pointi)
788 const labelList& pEdges = pointEdges[pointi];
792 const edge&
e = edges[pEdges[pEdgei]];
794 scalar len =
e.mag(localPoints);
796 maxEdgeLen[pointi] =
max(maxEdgeLen[pointi], len);
817 const label nInitErrors,
829 Info<<
"Smoothing patch and internal points ..." <<
endl;
833 Info<<
"Smoothing patch points ..." <<
endl;
840 label smoothIter = 0;
845 Info<<
"Smoothing iteration " << smoothIter <<
endl;
849 checkFaces[facei] = facei;
856 pointDisp = smoothInternalDisplacement(meshRefiner, meshMover);
860 pointField patchDisp(smoothPatchDisplacement(meshMover, baffles));
873 scalar oldErrorReduction = -1;
875 for (label snapIter = 0; snapIter < 2*snapParams.
nSnap(); snapIter++)
877 Info<<
nl <<
"Scaling iteration " << snapIter <<
endl;
879 if (snapIter == snapParams.
nSnap())
881 Info<<
"Displacement scaling for error reduction set to 0."
888 if (meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors))
890 Info<<
"Successfully moved mesh" <<
endl;
895 if (oldErrorReduction >= 0)
909 Info<<
"Writing patch smoothed mesh to time "
921 Info<<
"Dumped mesh in = "
925 Info<<
"Patch points smoothed in = "
931 void Foam::snappySnapDriver::getZoneSurfacePoints
935 const word& zoneName,
945 <<
"Cannot find zone " << zoneName
961 label meshPointi =
f[fp];
967 const label pointi = iter.val();
968 pointOnZone[pointi] =
true;
991 forAll(pointFaces, pointi)
997 label facei =
pFaces[pfi];
998 label meshFacei = pp.addressing()[facei];
1002 nBoundary[pointi]++;
1025 avgBoundary[i] /= nBoundary[i];
1027 return tavgBoundary;
1081 const scalar planarCos,
1089 Info<<
"Detecting near surfaces ..." <<
endl;
1378 forAll(localPoints, pointi)
1380 const point& pt = localPoints[pointi];
1381 const vector d = 2*(avgCc[pointi]-pt);
1382 start[pointi] = pt - d;
1383 end[pointi] = pt + d;
1395 /
"detectNearSurfaces_" + meshRefiner_.timeName() +
".obj"
1401 const bitSet isPatchMasterPoint
1410 label nOverride = 0;
1418 meshRefiner_.surfaces().surfZones()
1449 forAll(localPoints, pointi)
1452 const point& pt = localPoints[pointi];
1454 bool override =
false;
1493 if (hit1[pointi].hit() && hit2[pointi].hit())
1500 hit1[pointi].hitPoint(),
1502 hit2[pointi].hitPoint(),
1512 const point& intPt = hit2[pointi].hitPoint();
1517 disp[pointi] = hit2[pointi].hitPoint()-pt;
1522 if (
override && isPatchMasterPoint[pointi])
1544 label zoneSurfi = zonedSurfaces[i];
1545 const labelList surfacesToTest(1, zoneSurfi);
1548 surfZones[zoneSurfi].faceZoneNames();
1549 forAll(faceZoneNames, namei)
1551 const word& faceZoneName = faceZoneNames[namei];
1555 getZoneSurfacePoints
1594 label pointi = zonePointIndices[i];
1597 const point& pt = localPoints[pointi];
1599 bool override =
false;
1638 if (hit1[i].hit() && hit2[i].hit())
1654 const point& intPt = hit2[i].hitPoint();
1658 disp[pointi] = hit2[i].hitPoint()-pt;
1663 if (
override && isPatchMasterPoint[pointi])
1672 Info<<
"Overriding nearest with intersection of close gaps at "
1675 <<
" points." <<
endl;
1679 void Foam::snappySnapDriver::calcNearestSurface
1702 if (nearestNormal.size() == localPoints.size())
1722 if (hitInfo[i].hit())
1724 label pointi = zonePointIndices[i];
1725 nearestPoint[pointi] = hitInfo[i].hitPoint();
1726 nearestNormal[pointi] = hitNormal[i];
1747 if (hitInfo[i].hit())
1749 label pointi = zonePointIndices[i];
1751 patchDisp[pointi] = hitInfo[i].hitPoint() - localPoints[pointi];
1752 minSnapDist[pointi] =
mag(patchDisp[pointi]);
1753 snapSurf[pointi] = hitSurface[i];
1761 const bool strictRegionSnap,
1771 Info<<
"Calculating patchDisplacement as distance to nearest surface"
1772 <<
" point ..." <<
endl;
1773 if (strictRegionSnap)
1775 Info<<
" non-zone points : attract to local region on surface only"
1777 <<
" zone points : attract to local region on surface only"
1783 Info<<
" non-zone points :"
1784 <<
" attract to nearest of all non-zone surfaces"
1786 <<
" zone points : attract to zone surface only" <<
nl
1802 labelList snapSurf(localPoints.size(), -1);
1809 if (strictRegionSnap)
1815 label geomi = surfaces.
surfaces()[surfi];
1816 label nRegions = surfaces.
geometry()[geomi].regions().size();
1818 const labelList surfacesToTest(1, surfi);
1820 for (label regioni = 0; regioni < nRegions; regioni++)
1823 label masterPatchi = globalToMasterPatch[globali];
1854 if (globalToSlavePatch[globali] != masterPatchi)
1856 label slavePatchi = globalToSlavePatch[globali];
1906 if (nearestNormal.size() == localPoints.size())
1923 if (hitInfo[pointi].hit())
1925 nearestPoint[pointi] = hitInfo[pointi].hitPoint();
1926 nearestNormal[pointi] = hitNormal[pointi];
1944 if (hitInfo[pointi].hit())
1947 hitInfo[pointi].hitPoint()
1948 - localPoints[pointi];
1950 snapSurf[pointi] = hitSurface[pointi];
1970 label surfi = zonedSurfaces[i];
1971 const labelList surfacesToTest(1, surfi);
1972 const label geomi = surfaces.
surfaces()[surfi];
1973 const label nRegions =
1974 surfaces.
geometry()[geomi].regions().size();
1977 surfZones[surfi].faceZoneNames();
1981 forAll(faceZoneNames, locali)
1983 getZoneSurfacePoints
1987 faceZoneNames[locali],
2018 if (snapSurf[pointi] == -1)
2020 static label nWarn = 0;
2025 <<
"For point:" << pointi
2026 <<
" coordinate:" << localPoints[pointi]
2027 <<
" did not find any surface within:"
2028 << minSnapDist[pointi] <<
" metre." <<
endl;
2033 <<
"Reached warning limit " << nWarn
2034 <<
". Suppressing further warnings." <<
endl;
2041 const bitSet isPatchMasterPoint
2052 Info<<
"Wanted displacement : average:"
2054 <<
" min:" <<
gMin(magDisp)
2055 <<
" max:" <<
gMax(magDisp) <<
endl;
2059 Info<<
"Calculated surface displacement in = "
2065 forAll(patchDisp, patchPointi)
2067 scalar magDisp =
mag(patchDisp[patchPointi]);
2069 if (magDisp > snapDist[patchPointi])
2071 patchDisp[patchPointi] *= snapDist[patchPointi] / magDisp;
2073 Pout<<
"Limiting displacement for " << patchPointi
2074 <<
" from " << magDisp <<
" to " << snapDist[patchPointi]
2087 vector(GREAT, GREAT, GREAT)
2108 Info<<
"Smoothing displacement ..." <<
endl;
2118 for (label iter = 0; iter < snapParams.
nSmoothDispl(); iter++)
2120 if ((iter % 10) == 0)
2122 Info<<
"Iteration " << iter <<
endl;
2125 meshMover.
smooth(oldDisp, edgeGamma, disp);
2127 Info<<
"Displacement smoothed in = "
2133 Info<<
"Writing smoothed mesh to time " << meshRefiner_.timeName()
2150 Info<<
"Writing displacement field ..." <<
endl;
2155 Info<<
"Writing actual patch displacement ..." <<
endl;
2160 /
"actualPatchDisplacement_" + meshRefiner_.timeName() +
".obj",
2171 const label nInitErrors,
2183 scalar oldErrorReduction = -1;
2185 bool meshOk =
false;
2188 for (label iter = 0; iter < 2*snapParams.
nSnap(); iter++)
2192 if (iter == snapParams.
nSnap())
2194 Info<<
"Displacement scaling for error reduction set to 0." <<
endl;
2198 meshOk = meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors);
2202 Info<<
"Successfully moved mesh" <<
endl;
2208 Info<<
"Writing scaled mesh to time " << meshRefiner_.timeName()
2212 Info<<
"Writing displacement field ..." <<
endl;
2219 if (oldErrorReduction >= 0)
2223 Info<<
"Moved mesh in = "
2245 Info<<
"Repatching faces according to nearest surface ..." <<
endl;
2269 forAll(preserveFaces, facei)
2271 if (preserveFaces[facei] != -1)
2273 isZonedFace.set(facei);
2283 const label zoneSurfi = zonedSurfaces[i];
2284 const wordList& fZoneNames = surfZones[zoneSurfi].faceZoneNames();
2287 const faceZone& fZone = fZones[fZoneNames[i]];
2288 isZonedFace.set(fZone);
2316 forAll(localFaces, facei)
2318 const face&
f = localFaces[facei];
2322 faceSnapDist[facei] =
max
2324 faceSnapDist[facei],
2348 label facei = pp.addressing()[i];
2350 if (hitSurface[i] != -1 && !isZonedFace.test(facei))
2352 closestPatch[i] = globalToMasterPatch_
2379 ownPatch[pp.
start()+i] = patchi;
2380 neiPatch[pp.
start()+i] = patchi;
2387 label facei = pp.addressing()[i];
2389 if (closestPatch[i] != -1 && closestPatch[i] != ownPatch[facei])
2391 ownPatch[facei] = closestPatch[i];
2392 neiPatch[facei] = closestPatch[i];
2401 return meshRefiner_.createBaffles(ownPatch, neiPatch);
2405 void Foam::snappySnapDriver::detectWarpedFaces
2407 const scalar featureCos,
2417 const labelList& bFaces = pp.addressing();
2430 forAll(localFaces, facei)
2432 const face&
f = localFaces[facei];
2440 scalar minCos(GREAT);
2442 for (label startFp = 0; startFp <
f.size()-2; startFp++)
2444 label minFp =
f.rcIndex(startFp);
2448 label endFp =
f.fcIndex(
f.fcIndex(startFp));
2449 endFp <
f.size() && endFp != minFp;
2456 for (label fp = startFp; fp <= endFp; fp++)
2462 for (label fp = endFp; fp != startFp; fp =
f.fcIndex(fp))
2466 f1[i1++] =
f[startFp];
2471 const vector n0 = f0.areaNormal(localPoints);
2472 const scalar n0Mag =
mag(n0);
2474 const vector n1 = f1.areaNormal(localPoints);
2475 const scalar n1Mag =
mag(n1);
2477 if (n0Mag > ROOTVSMALL && n1Mag > ROOTVSMALL)
2479 scalar cosAngle = (n0/n0Mag) & (n1/n1Mag);
2480 if (cosAngle < minCos)
2490 if (minCos < featureCos)
2492 splitFaces.
append(bFaces[facei]);
2500 Foam::labelList Foam::snappySnapDriver::getInternalOrBaffleDuplicateFace()
const
2502 const fvMesh&
mesh = meshRefiner_.mesh();
2506 List<surfaceZonesInfo::faceZoneType> fzTypes(2);
2509 internalOrBaffleFaceZones = meshRefiner_.getZones(fzTypes);
2512 List<labelPair> baffles
2514 meshRefiner_.subsetBaffles
2517 internalOrBaffleFaceZones,
2526 faceToDuplicate[
p[0]] =
p[1];
2527 faceToDuplicate[
p[1]] =
p[0];
2530 return faceToDuplicate;
2539 const scalar featureCos,
2540 const scalar planarAngle,
2548 <<
"Morphing phase" <<
nl
2549 <<
"--------------" <<
nl
2588 meshRefiner_.getZones
2604 meshRefiner_.createZoneBaffles
2613 meshRefiner_.dupNonManifoldBoundaryPoints();
2616 bool doFeatures =
false;
2617 label nFeatIter = 1;
2627 Info<<
"Snapping to features in " << nFeatIter
2628 <<
" iterations ..." <<
endl;
2632 bool meshOk =
false;
2636 labelList adaptPatchIDs(meshRefiner_.meshedPatches());
2656 Info<<
"Constructing mesh displacer ..." <<
endl;
2657 Info<<
"Using mesh parameters " << motionDict <<
nl <<
endl;
2678 Info<<
"Checking initial mesh ..." <<
endl;
2687 Info<<
"Detected " << nInitErrors <<
" illegal faces"
2688 <<
" (concave, zero area or negative cell pyramid volume)"
2692 Info<<
"Checked initial mesh in = "
2699 meshRefiner_.subsetBaffles
2735 for (label iter = 0; iter < nFeatIter; iter++)
2738 <<
"Morph iteration " << iter <<
nl
2739 <<
"-----------------" <<
endl;
2742 bool doSplit =
false;
2748 (iter == nFeatIter-1)
2778 globalToMasterPatch_,
2779 globalToSlavePatch_,
2807 disp = calcNearestSurfaceFeature
2813 scalar(iter+1)/nFeatIter,
2829 outwardsDisplacement(pp, disp);
2842 /
"patchDisplacement_" +
name(iter) +
".obj",
2844 pp.localPoints() + disp
2849 smoothDisplacement(snapParams, meshMover);
2863 <<
"Did not successfully snap mesh."
2864 <<
" Continuing to snap to resolve easy" <<
nl
2865 <<
" surfaces but the"
2866 <<
" resulting mesh will not satisfy your quality"
2867 <<
" constraints" <<
nl <<
endl;
2873 Info<<
"Writing scaled mesh to time "
2874 << meshRefiner_.timeName() <<
endl;
2885 Info<<
"Writing displacement field ..." <<
endl;
2901 if (nTotalSplit && doSplit)
2906 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
2909 labelList oldSplitFaces(std::move(splitFaces));
2913 if (duplicateFace[oldSplitFaces[i]] == -1)
2915 splitFaces.
append(oldSplitFaces[i]);
2916 splits.
append(oldSplits[i]);
2927 meshRefiner_.splitFacesUndo
2938 meshMoverPtr.
clear();
2961 snapDist = calcSnapDistance(
mesh, snapParams, ppPtr());
2967 Info<<
"Writing split-faces mesh to time "
2968 << meshRefiner_.timeName() <<
endl;
2985 forAll(internalBaffles, i)
2991 if (
mag(fc0-fc1) > meshRefiner_.mergeDistance())
2994 <<
"Separated baffles : f0:" <<
p[0]
2995 <<
" centre:" << fc0
2996 <<
" f1:" <<
p[1] <<
" centre:" << fc1
2997 <<
" distance:" <<
mag(fc0-fc1)
3019 Info<<
"Writing baffle-merged mesh to time "
3020 << meshRefiner_.timeName() <<
endl;
3029 meshRefiner_.timeName()
3037 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3039 repatchToSurface(snapParams, adaptPatchIDs, duplicateFace);
3044 mergeType == meshRefinement::FaceMergeType::GEOMETRIC
3045 || mergeType == meshRefinement::FaceMergeType::IGNOREPATCH
3048 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3053 label nChanged = meshRefiner_.mergePatchFacesUndo
3057 meshRefiner_.meshedPatches(),
3063 nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict);
3068 Info<<
"Writing patchFace merged mesh to time "
3069 << meshRefiner_.timeName() <<
endl;
3078 meshRefiner_.timeName()
int debug
Static debugging option.
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
void smoothDisplacement(const snapParameters &snapParams, motionSmoother &) const
Smooth the displacement field to the internal.
virtual const pointField & points() const
Return raw points.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const labelListList & pointFaces() const
Return point-face addressing.
scalar setErrorReduction(const scalar)
Set the errorReduction (by how much to scale the displacement.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static T gAverage(const bitSet &isMasterElem, const UList< T > &values)
Helper: calculate average.
static scalarField calcSnapDistance(const fvMesh &mesh, const snapParameters &snapParams, const indirectPrimitivePatch &)
Calculate edge length per patch point.
A class for handling words, derived from Foam::string.
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
OFstream that keeps track of vertices.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
label nInternalFaces() const
Number of internal faces.
void correct()
Take over existing mesh position.
const labelList & surfaces() const
const indirectPrimitivePatch & patch() const
Reference to patch.
label nFaces() const
Number of mesh faces.
static writeType writeLevel()
Get/set write level.
label nTotalPoints() const
Return total number of points in decomposed mesh. Not.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label nEdges() const
Number of mesh edges.
bool scaleMesh(labelList &checkFaces, const bool smoothMesh=true, const label nAllow=0)
Move mesh with given scale. Return true if mesh ok or has.
Unit conversion functions.
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
bool valid() const noexcept
True if the managed pointer is non-null.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label nTotalFaces() const
Return total number of faces in decomposed mesh. Not.
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
const fvMesh & mesh() const
Reference to mesh.
const searchableSurfaces & geometry() const
#define forAll(list, i)
Loop across all elements in list.
Field< vector > vectorField
Specialisation of Field<T> for vector.
const faceZoneMesh & faceZones() const
Return face zone mesh.
FaceMergeType
Enumeration for what to do with co-planar patch faces on a single.
Pair< label > labelPair
A pair of labels.
Simple container to keep together snap specific information.
const PtrList< surfaceZonesInfo > & surfZones() const
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
labelList toc() const
The indices of the on bits as a sorted labelList.
label nFeatureSnap() const
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]=cellShape(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];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } 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};const 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< SLList< face > > pFaces[nBCs]
surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf())
void detectNearSurfaces(const scalar planarCos, const indirectPrimitivePatch &, const pointField &nearestPoint, const vectorField &nearestNormal, vectorField &disp) const
Per patch point override displacement if in gap situation.
A subset of mesh faces organised as a primitive patch.
messageStream Info
Information stream (uses stdout - output is on the master only)
A patch is a list of labels that address the faces in the global face list.
word name(const complex &c)
Return string representation of complex.
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
const labelListList & pointEdges() const
Return point-edge addressing.
void clear()
Clear the addressed list, i.e. set the size to zero.
virtual const labelList & faceOwner() const
Return face owner.
Switch strictRegionSnap() const
Attract point to corresponding surface region only.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh err...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
label nPoints() const
Return number of points supporting patch faces.
label nSnap() const
Maximum number of snapping relaxation iterations. Should stop.
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
static autoPtr< indirectPrimitivePatch > makePatch(const polyMesh &, const labelList &)
Create patch from set of patches.
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Mesh data needed to do the Finite Volume discretisation.
errorManip< error > abort(error &err)
label findZoneID(const word &zoneName) const
Find zone index given a name, return -1 if not found.
Vector< scalar > vector
A scalar version of the templated Vector.
label start() const
Return start label of this patch in the polyMesh face list.
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
label mergePoints(const PointList &points, const scalar mergeTol, const bool verbose, labelList &pointMap, typename PointList::const_reference origin=PointList::value_type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const Field< point_type > & localPoints() const
Return pointField of points in patch.
void setCapacity(const label nElem)
Alter the size of the underlying storage.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
autoPtr< mapPolyMesh > repatchToSurface(const snapParameters &snapParams, const labelList &adaptPatchIDs, const labelList &preserveFaces)
Repatch faces according to surface nearest the face centre.
static labelList getUnnamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of unnamed surfaces (surfaces without faceZoneName)
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.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
bool scaleMesh(const snapParameters &snapParams, const label nInitErrors, const List< labelPair > &baffles, motionSmoother &)
Do the hard work: move the mesh according to displacement,.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
List< labelList > labelListList
A List of labelList.
const vectorField & cellCentres() const
line< point, const point & > linePointRef
Line using referred points.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.
scalar snapTol() const
Relative distance for points to be attracted by surface.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
fileName path() const
Return path.
label nFaceSplitInterval() const
label nSmoothInternal() const
Number of internal point smoothing iterations (combined with.
static const Vector< scalar > max
void doSnap(const dictionary &snapDict, const dictionary &motionDict, const meshRefinement::FaceMergeType mergeType, const scalar featureCos, const scalar planarAngle, const snapParameters &snapParams)
List< face > faceList
A List of faces.
writeType
Enumeration for what to write. Used as a bit-pattern.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Switch detectNearSurfacesSnap() const
Override attraction to nearest with intersection location.
pointVectorField & pointDisplacement()
Return reference to the point motion displacement field.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const vectorField & faceCentres() const
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
static void setDisplacement(const labelList &patchIDs, const indirectPrimitivePatch &pp, pointField &patchDisp, pointVectorField &displacement)
Set displacement field from displacement on patch points.
const dimensionedScalar e
Elementary charge.
bool write() const
Write mesh and all data.
label nPoints() const
Number of mesh points.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
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 labelListList & pointCells() const
const polyBoundaryMesh & patches
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
void clear() noexcept
Same as reset(nullptr)
const pointMesh & pMesh() const
Reference to pointMesh.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
const Time & time() const
Return the top-level database.
static const Vector< scalar > zero
SubField< vector > subField
Declare type of subField.
A face is a list of labels corresponding to mesh vertices.
Type gMin(const FieldField< Field, Type > &f)
const globalMeshData & globalData() const
Return parallel info.
vector point
Point is a vector.
const Map< label > & meshPointMap() const
Mesh point map.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
void setSize(const label newSize)
Alias for resize(const label)
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
label nSmoothDispl() const
Number of mesh displacement smoothing iterations.
defineTypeNameAndDebug(combustionModel, 0)
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< pointVectorField > makeDisplacementField(const pointMesh &pMesh, const labelList &adaptPatchIDs)
Helper function to make a pointVectorField with correct.
#define WarningInFunction
Report a warning using Foam::Warning.
static tmp< pointField > avgCellCentres(const fvMesh &mesh, const indirectPrimitivePatch &)
Helper: calculate average cell centre per point.
Type gMax(const FieldField< Field, Type > &f)
virtual const labelList & faceNeighbour() const
Return face neighbour.
label nSmoothPatch() const
Number of patch smoothing iterations before finding.
static bitSet getMasterPoints(const polyMesh &mesh, const labelList &meshPoints)
Determine master point for subset of points. If coupled.
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
pointVectorField & displacement()
Reference to displacement field.
A list of faces which address into the list of points.
void smooth(volScalarField &field, const scalar coeff)
dimensionedScalar cos(const dimensionedScalar &ds)
const refinementSurfaces & surfaces() const
Reference to surface search engines.
debugType
Enumeration for what to debug. Used as a bit-pattern.