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)
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 = "
943 <<
"Cannot find zone " << zoneName
967 const label pointi = iter.val();
968 pointOnZone[pointi] =
true;
973 return findIndices(pointOnZone,
true);
993 forAll(pointFaces, pointi)
1000 label meshFacei = pp.addressing()[facei];
1004 nBoundary[pointi]++;
1027 avgBoundary[i] /= nBoundary[i];
1029 return tavgBoundary;
1083 const scalar planarCos,
1091 Info<<
"Detecting near surfaces ..." <<
endl;
1380 forAll(localPoints, pointi)
1382 const point& pt = localPoints[pointi];
1383 const vector d = 2*(avgCc[pointi]-pt);
1384 start[pointi] = pt - d;
1385 end[pointi] = pt + d;
1397 /
"detectNearSurfaces_" + meshRefiner_.timeName() +
".obj"
1403 const bitSet isPatchMasterPoint
1412 label nOverride = 0;
1420 meshRefiner_.surfaces().surfZones()
1451 forAll(localPoints, pointi)
1454 const point& pt = localPoints[pointi];
1456 bool override =
false;
1495 if (hit1[pointi].hit() && hit2[pointi].hit())
1502 hit1[pointi].hitPoint(),
1504 hit2[pointi].hitPoint(),
1514 const point& intPt = hit2[pointi].hitPoint();
1519 disp[pointi] = hit2[pointi].hitPoint()-pt;
1524 if (
override && isPatchMasterPoint[pointi])
1546 label zoneSurfi = zonedSurfaces[i];
1548 const word& faceZoneName = surfZones[zoneSurfi].faceZoneName();
1550 const labelList surfacesToTest(1, zoneSurfi);
1555 getZoneSurfacePoints
1593 label pointi = zonePointIndices[i];
1596 const point& pt = localPoints[pointi];
1598 bool override =
false;
1637 if (hit1[i].hit() && hit2[i].hit())
1653 const point& intPt = hit2[i].hitPoint();
1657 disp[pointi] = hit2[i].hitPoint()-pt;
1662 if (
override && isPatchMasterPoint[pointi])
1670 Info<<
"Overriding nearest with intersection of close gaps at "
1673 <<
" points." <<
endl;
1677 void Foam::snappySnapDriver::calcNearestSurface
1700 if (nearestNormal.size() == localPoints.size())
1720 if (hitInfo[i].hit())
1722 label pointi = zonePointIndices[i];
1723 nearestPoint[pointi] = hitInfo[i].hitPoint();
1724 nearestNormal[pointi] = hitNormal[i];
1745 if (hitInfo[i].hit())
1747 label pointi = zonePointIndices[i];
1749 patchDisp[pointi] = hitInfo[i].hitPoint() - localPoints[pointi];
1750 minSnapDist[pointi] =
mag(patchDisp[pointi]);
1751 snapSurf[pointi] = hitSurface[i];
1759 const bool strictRegionSnap,
1769 Info<<
"Calculating patchDisplacement as distance to nearest surface"
1770 <<
" point ..." <<
endl;
1771 if (strictRegionSnap)
1773 Info<<
" non-zone points : attract to local region on surface only"
1775 <<
" zone points : attract to local region on surface only"
1781 Info<<
" non-zone points :"
1782 <<
" attract to nearest of all non-zone surfaces"
1784 <<
" zone points : attract to zone surface only" <<
nl
1800 labelList snapSurf(localPoints.size(), -1);
1807 if (strictRegionSnap)
1814 label nRegions = surfaces.
geometry()[geomi].regions().size();
1816 const labelList surfacesToTest(1, surfi);
1818 for (
label regioni = 0; regioni < nRegions; regioni++)
1821 label masterPatchi = globalToMasterPatch[globali];
1852 if (globalToSlavePatch[globali] != masterPatchi)
1854 label slavePatchi = globalToSlavePatch[globali];
1904 if (nearestNormal.size() == localPoints.size())
1921 if (hitInfo[pointi].hit())
1923 nearestPoint[pointi] = hitInfo[pointi].hitPoint();
1924 nearestNormal[pointi] = hitNormal[pointi];
1942 if (hitInfo[pointi].hit())
1945 hitInfo[pointi].hitPoint()
1946 - localPoints[pointi];
1948 snapSurf[pointi] = hitSurface[pointi];
1968 label surfi = zonedSurfaces[i];
1970 const word& faceZoneName = surfZones[surfi].faceZoneName();
1972 const labelList surfacesToTest(1, surfi);
1975 label nRegions = surfaces.
geometry()[geomi].regions().size();
1981 getZoneSurfacePoints
2015 if (snapSurf[pointi] == -1)
2017 static label nWarn = 0;
2022 <<
"For point:" << pointi
2023 <<
" coordinate:" << localPoints[pointi]
2024 <<
" did not find any surface within:"
2025 << minSnapDist[pointi] <<
" metre." <<
endl;
2030 <<
"Reached warning limit " << nWarn
2031 <<
". Suppressing further warnings." <<
endl;
2038 const bitSet isPatchMasterPoint
2049 Info<<
"Wanted displacement : average:"
2051 <<
" min:" <<
gMin(magDisp)
2052 <<
" max:" <<
gMax(magDisp) <<
endl;
2056 Info<<
"Calculated surface displacement in = "
2062 forAll(patchDisp, patchPointi)
2064 scalar magDisp =
mag(patchDisp[patchPointi]);
2066 if (magDisp > snapDist[patchPointi])
2068 patchDisp[patchPointi] *= snapDist[patchPointi] / magDisp;
2070 Pout<<
"Limiting displacement for " << patchPointi
2071 <<
" from " << magDisp <<
" to " << snapDist[patchPointi]
2084 vector(GREAT, GREAT, GREAT)
2105 Info<<
"Smoothing displacement ..." <<
endl;
2117 if ((iter % 10) == 0)
2119 Info<<
"Iteration " << iter <<
endl;
2122 meshMover.
smooth(oldDisp, edgeGamma, disp);
2124 Info<<
"Displacement smoothed in = "
2130 Info<<
"Writing smoothed mesh to time " << meshRefiner_.timeName()
2147 Info<<
"Writing displacement field ..." <<
endl;
2152 Info<<
"Writing actual patch displacement ..." <<
endl;
2157 /
"actualPatchDisplacement_" + meshRefiner_.timeName() +
".obj",
2168 const label nInitErrors,
2180 scalar oldErrorReduction = -1;
2182 bool meshOk =
false;
2185 for (
label iter = 0; iter < 2*snapParams.
nSnap(); iter++)
2189 if (iter == snapParams.
nSnap())
2191 Info<<
"Displacement scaling for error reduction set to 0." <<
endl;
2195 meshOk = meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors);
2199 Info<<
"Successfully moved mesh" <<
endl;
2205 Info<<
"Writing scaled mesh to time " << meshRefiner_.timeName()
2209 Info<<
"Writing displacement field ..." <<
endl;
2216 if (oldErrorReduction >= 0)
2220 Info<<
"Moved mesh in = "
2242 Info<<
"Repatching faces according to nearest surface ..." <<
endl;
2266 forAll(preserveFaces, facei)
2268 if (preserveFaces[facei] != -1)
2270 isZonedFace.set(facei);
2280 const label zoneSurfi = zonedSurfaces[i];
2281 const faceZone& fZone = fZones[surfZones[zoneSurfi].faceZoneName()];
2283 isZonedFace.set(fZone);
2310 forAll(localFaces, facei)
2312 const face&
f = localFaces[facei];
2316 faceSnapDist[facei] =
max
2318 faceSnapDist[facei],
2342 label facei = pp.addressing()[i];
2344 if (hitSurface[i] != -1 && !isZonedFace.test(facei))
2346 closestPatch[i] = globalToMasterPatch_
2373 ownPatch[pp.
start()+i] = patchi;
2374 neiPatch[pp.
start()+i] = patchi;
2381 label facei = pp.addressing()[i];
2383 if (closestPatch[i] != -1 && closestPatch[i] != ownPatch[facei])
2385 ownPatch[facei] = closestPatch[i];
2386 neiPatch[facei] = closestPatch[i];
2395 return meshRefiner_.createBaffles(ownPatch, neiPatch);
2399 void Foam::snappySnapDriver::detectWarpedFaces
2401 const scalar featureCos,
2411 const labelList& bFaces = pp.addressing();
2424 forAll(localFaces, facei)
2426 const face&
f = localFaces[facei];
2434 scalar minCos(GREAT);
2436 for (
label startFp = 0; startFp <
f.size()-2; startFp++)
2438 label minFp =
f.rcIndex(startFp);
2442 label endFp =
f.fcIndex(
f.fcIndex(startFp));
2443 endFp <
f.size() && endFp != minFp;
2450 for (
label fp = startFp; fp <= endFp; fp++)
2456 for (
label fp = endFp; fp != startFp; fp =
f.fcIndex(fp))
2460 f1[i1++] =
f[startFp];
2465 const vector n0 = f0.areaNormal(localPoints);
2466 const scalar n0Mag =
mag(n0);
2468 const vector n1 = f1.areaNormal(localPoints);
2469 const scalar n1Mag =
mag(n1);
2471 if (n0Mag > ROOTVSMALL && n1Mag > ROOTVSMALL)
2473 scalar cosAngle = (n0/n0Mag) & (n1/n1Mag);
2474 if (cosAngle < minCos)
2484 if (minCos < featureCos)
2486 splitFaces.
append(bFaces[facei]);
2494 Foam::labelList Foam::snappySnapDriver::getInternalOrBaffleDuplicateFace()
const
2496 const fvMesh&
mesh = meshRefiner_.mesh();
2500 List<surfaceZonesInfo::faceZoneType> fzTypes(2);
2503 internalOrBaffleFaceZones = meshRefiner_.getZones(fzTypes);
2506 List<labelPair> baffles
2508 meshRefiner_.subsetBaffles
2511 internalOrBaffleFaceZones,
2520 faceToDuplicate[
p[0]] =
p[1];
2521 faceToDuplicate[
p[1]] =
p[0];
2524 return faceToDuplicate;
2533 const scalar featureCos,
2534 const scalar planarAngle,
2542 <<
"Morphing phase" <<
nl
2543 <<
"--------------" <<
nl
2582 meshRefiner_.getZones
2598 meshRefiner_.createZoneBaffles
2607 meshRefiner_.dupNonManifoldBoundaryPoints();
2610 bool doFeatures =
false;
2611 label nFeatIter = 1;
2621 Info<<
"Snapping to features in " << nFeatIter
2622 <<
" iterations ..." <<
endl;
2626 bool meshOk =
false;
2630 labelList adaptPatchIDs(meshRefiner_.meshedPatches());
2650 Info<<
"Constructing mesh displacer ..." <<
endl;
2651 Info<<
"Using mesh parameters " << motionDict <<
nl <<
endl;
2672 Info<<
"Checking initial mesh ..." <<
endl;
2681 Info<<
"Detected " << nInitErrors <<
" illegal faces"
2682 <<
" (concave, zero area or negative cell pyramid volume)"
2686 Info<<
"Checked initial mesh in = "
2693 meshRefiner_.subsetBaffles
2729 for (
label iter = 0; iter < nFeatIter; iter++)
2732 <<
"Morph iteration " << iter <<
nl
2733 <<
"-----------------" <<
endl;
2736 bool doSplit =
false;
2742 (iter == nFeatIter-1)
2772 globalToMasterPatch_,
2773 globalToSlavePatch_,
2801 disp = calcNearestSurfaceFeature
2807 scalar(iter+1)/nFeatIter,
2823 outwardsDisplacement(pp, disp);
2836 /
"patchDisplacement_" +
name(iter) +
".obj",
2838 pp.localPoints() + disp
2843 smoothDisplacement(snapParams, meshMover);
2857 <<
"Did not successfully snap mesh."
2858 <<
" Continuing to snap to resolve easy" <<
nl
2859 <<
" surfaces but the"
2860 <<
" resulting mesh will not satisfy your quality"
2861 <<
" constraints" <<
nl <<
endl;
2867 Info<<
"Writing scaled mesh to time "
2868 << meshRefiner_.timeName() <<
endl;
2879 Info<<
"Writing displacement field ..." <<
endl;
2895 if (nTotalSplit && doSplit)
2900 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
2903 labelList oldSplitFaces(std::move(splitFaces));
2907 if (duplicateFace[oldSplitFaces[i]] == -1)
2909 splitFaces.
append(oldSplitFaces[i]);
2910 splits.
append(oldSplits[i]);
2921 meshRefiner_.splitFacesUndo
2932 meshMoverPtr.
clear();
2955 snapDist = calcSnapDistance(
mesh, snapParams, ppPtr());
2961 Info<<
"Writing split-faces mesh to time "
2962 << meshRefiner_.timeName() <<
endl;
2979 forAll(internalBaffles, i)
2985 if (
mag(fc0-fc1) > meshRefiner_.mergeDistance())
2988 <<
"Separated baffles : f0:" <<
p[0]
2989 <<
" centre:" << fc0
2990 <<
" f1:" <<
p[1] <<
" centre:" << fc1
2991 <<
" distance:" <<
mag(fc0-fc1)
3013 Info<<
"Writing baffle-merged mesh to time "
3014 << meshRefiner_.timeName() <<
endl;
3023 meshRefiner_.timeName()
3031 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3033 repatchToSurface(snapParams, adaptPatchIDs, duplicateFace);
3038 mergeType == meshRefinement::FaceMergeType::GEOMETRIC
3039 || mergeType == meshRefinement::FaceMergeType::IGNOREPATCH
3042 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3047 label nChanged = meshRefiner_.mergePatchFacesUndo
3051 meshRefiner_.meshedPatches(),
3057 nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict);
3062 Info<<
"Writing patchFace merged mesh to time "
3063 << meshRefiner_.timeName() <<
endl;
3072 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.
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 Field< PointType > & localPoints() const
Return pointField of points in patch.
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.
List< bool > boolList
A List of bools.
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)
label nFeatureSnap() const
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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.
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)
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< face, IndirectList, const pointField & > indirectPrimitivePatch
A PrimitivePatch using an IndirectList for the faces.
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)
An ordered pair of two objects of type <T> with first() and second() elements.
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)
label ListType::const_reference const label start
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
Delete managed object and set pointer to 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
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
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.