Go to the documentation of this file.
68 Foam::label Foam::snappySnapDriver::getCollocatedPoints
72 bitSet& isCollocatedPoint
83 bool hasMerged = (nUnique <
points.size());
91 label nCollocated = 0;
96 forAll(pointMap, oldPointi)
108 isCollocatedPoint.set(oldPointi);
114 isCollocatedPoint.set(firstOldPoint[
newPointi]);
117 isCollocatedPoint.set(oldPointi);
130 const meshRefinement& meshRefiner,
131 const motionSmoother& meshMover
135 const polyMesh&
mesh = meshMover.mesh();
138 const hexRef8& cutter = meshRefiner.meshCutter();
139 const labelList& cellLevel = cutter.cellLevel();
143 bitSet isFront(
mesh.
nFaces(), pp.addressing());
183 label nInterface = 0;
190 if (!isFront.test(facei) && ownLevel != neiLevel)
193 isMovingPoint.
set(
f);
207 if (!isFront.test(facei) && ownLevel != neiLevel)
210 isMovingPoint.
set(
f);
218 reduce(nInterface, sumOp<label>());
219 Info<<
"Found " << nInterface <<
" faces out of "
221 <<
" inbetween refinement regions." <<
endl;
230 isMovingPoint.unset(pp.meshPoints());
238 Field<weightedPosition> sumLocation
244 forAll(isMovingPoint, pointi)
246 if (isMovingPoint.test(pointi))
250 sumLocation[pointi].first() = pCells.size();
251 for (
const label celli : pCells)
262 pointField& displacement = tdisplacement.ref();
266 forAll(displacement, pointi)
268 const weightedPosition& wp = sumLocation[pointi];
269 if (
mag(wp.first()) > VSMALL)
271 displacement[pointi] =
272 wp.second()/wp.first()
278 reduce(nAdapted, sumOp<label>());
279 Info<<
"Smoothing " << nAdapted <<
" points inbetween refinement regions."
282 return tdisplacement;
289 const motionSmoother& meshMover,
290 const List<labelPair>& baffles
296 bitSet nonManifoldPoint(pp.nPoints());
297 label nNonManifoldPoints = getCollocatedPoints
303 Info<<
"Found " << nNonManifoldPoints <<
" non-manifold point(s)."
321 const labelList& meshPoints = pp.meshPoints();
323 const polyMesh&
mesh = meshMover.mesh();
331 label f0 = baffles[i].first();
332 label f1 = baffles[i].second();
334 if (isMasterFace.test(f0))
337 isMasterFace.unset(f1);
339 else if (isMasterFace.test(f1))
341 isMasterFace.unset(f0);
346 <<
"Both sides of baffle consisting of faces " << f0
347 <<
" and " << f1 <<
" are already slave faces."
357 Field<weightedPosition> avgBoundary
363 forAll(pointFaces, patchPointi)
369 label facei =
pFaces[pfi];
371 if (isMasterFace.test(pp.addressing()[facei]))
373 avgBoundary[patchPointi].first() += 1.0;
374 avgBoundary[patchPointi].second() +=
387 if (
mag(avgBoundary[i].first()) > VSMALL)
389 avgBoundary[i].second() /= avgBoundary[i].first();
398 Field<weightedPosition> avgInternal;
400 Field<weightedPosition> globalSum
411 const face&
f = faces[facei];
416 weightedPosition& wp = globalSum[
f[fp]];
430 && refCast<const coupledPolyPatch>(
patches[patchi]).owner()
433 const coupledPolyPatch& pp =
434 refCast<const coupledPolyPatch>(
patches[patchi]);
440 const face&
f = pp[i];
441 const point& fc = faceCentres[i];
445 weightedPosition& wp = globalSum[
f[fp]];
456 avgInternal.setSize(meshPoints.size());
458 forAll(avgInternal, patchPointi)
460 label meshPointi = meshPoints[patchPointi];
461 const weightedPosition& wp = globalSum[meshPointi];
463 avgInternal[patchPointi].first() = wp.first();
464 if (
mag(wp.first()) < VSMALL)
467 avgInternal[patchPointi].second() = wp.second();
471 avgInternal[patchPointi].second() = wp.second()/wp.first();
488 anyCell[
f[fp]] = own;
494 tmp<pointField> tpatchDisp(
new pointField(meshPoints.size(),
Zero));
499 label meshPointi = meshPoints[i];
500 const point& currentPos = pp.points()[meshPointi];
508 const weightedPosition&
internal = avgInternal[i];
509 const weightedPosition&
boundary = avgBoundary[i];
513 if (!nonManifoldPoint.test(i))
517 scalar internalBlend = 0.1;
522 internalBlend*
internal.first()*
internal.second()
526 internalBlend*
internal.first()
530 newPos = (1-blend)*avgPos + blend*currentPos;
532 else if (
internal.first() == 0)
540 scalar cellCBlend = 0.8;
543 point avgPos = (1-cellCBlend)*
boundary.second() + cellCBlend*cc;
545 newPos = (1-blend)*avgPos + blend*currentPos;
550 scalar internalBlend = 0.9;
554 internalBlend*
internal.second()
555 + (1-internalBlend)*
boundary.second();
557 newPos = (1-blend)*avgPos + blend*currentPos;
560 patchDisp[i] = newPos - currentPos;
630 const pointMesh& pMesh,
634 const polyMesh&
mesh = pMesh();
637 List<pointEdgePoint> wallInfo(pp.nPoints());
639 forAll(pp.localPoints(), ppi)
641 wallInfo[ppi] = pointEdgePoint(pp.localPoints()[ppi], 0.0);
648 List<pointEdgePoint> allEdgeInfo(
mesh.
nEdges());
650 PointEdgeWave<pointEdgePoint> wallCalc
665 forAll(allEdgeInfo, edgei)
667 edgeDist[edgei] =
Foam::sqrt(allEdgeInfo[edgei].distSqr());
674 void Foam::snappySnapDriver::dumpMove
676 const fileName& fName,
682 Info<<
"Dumping move direction to " << fName <<
endl;
684 OFstream nearestStream(fName);
696 nearestStream<<
"l " << verti-1 <<
' ' << verti <<
nl;
703 bool Foam::snappySnapDriver::outwardsDisplacement
712 forAll(pointFaces, pointi)
716 vector disp(patchDisp[pointi]);
718 scalar magDisp =
mag(disp);
728 Warning<<
"Displacement " << patchDisp[pointi]
729 <<
" at mesh point " << pp.meshPoints()[pointi]
730 <<
" coord " << pp.points()[pp.meshPoints()[pointi]]
731 <<
" points through the surrounding patch faces" <<
endl;
746 Foam::snappySnapDriver::snappySnapDriver
754 meshRefiner_(meshRefiner),
755 globalToMasterPatch_(globalToMasterPatch),
756 globalToSlavePatch_(globalToSlavePatch),
774 scalarField maxEdgeLen(localPoints.size(), -GREAT);
776 forAll(pointEdges, pointi)
778 const labelList& pEdges = pointEdges[pointi];
782 const edge&
e = edges[pEdges[pEdgei]];
784 scalar len =
e.mag(localPoints);
786 maxEdgeLen[pointi] =
max(maxEdgeLen[pointi], len);
807 const label nInitErrors,
819 Info<<
"Smoothing patch and internal points ..." <<
endl;
823 Info<<
"Smoothing patch points ..." <<
endl;
830 label smoothIter = 0;
835 Info<<
"Smoothing iteration " << smoothIter <<
endl;
839 checkFaces[facei] = facei;
846 pointDisp = smoothInternalDisplacement(meshRefiner, meshMover);
850 pointField patchDisp(smoothPatchDisplacement(meshMover, baffles));
863 scalar oldErrorReduction = -1;
865 for (label snapIter = 0; snapIter < 2*snapParams.
nSnap(); snapIter++)
867 Info<<
nl <<
"Scaling iteration " << snapIter <<
endl;
869 if (snapIter == snapParams.
nSnap())
871 Info<<
"Displacement scaling for error reduction set to 0."
878 if (meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors))
880 Info<<
"Successfully moved mesh" <<
endl;
885 if (oldErrorReduction >= 0)
899 Info<<
"Writing patch smoothed mesh to time "
911 Info<<
"Dumped mesh in = "
915 Info<<
"Patch points smoothed in = "
921 void Foam::snappySnapDriver::getZoneSurfacePoints
925 const word& zoneName,
935 <<
"Cannot find zone " << zoneName
951 label meshPointi =
f[fp];
957 const label pointi = iter.val();
958 pointOnZone[pointi] =
true;
979 forAll(pointFaces, pointi)
983 avgBoundary[pointi].first() =
pFaces.size();
986 label facei =
pFaces[pfi];
1052 const scalar planarCos,
1060 Info<<
"Detecting near surfaces ..." <<
endl;
1349 forAll(localPoints, pointi)
1351 const point& pt = localPoints[pointi];
1352 const vector d = 2*(avgCc[pointi]-pt);
1353 start[pointi] = pt - d;
1354 end[pointi] = pt + d;
1366 /
"detectNearSurfaces_" + meshRefiner_.timeName() +
".obj"
1372 const bitSet isPatchMasterPoint
1381 label nOverride = 0;
1389 meshRefiner_.surfaces().surfZones()
1420 forAll(localPoints, pointi)
1423 const point& pt = localPoints[pointi];
1425 bool override =
false;
1464 if (hit1[pointi].hit() && hit2[pointi].hit())
1471 hit1[pointi].hitPoint(),
1473 hit2[pointi].hitPoint(),
1483 const point& intPt = hit2[pointi].hitPoint();
1488 disp[pointi] = hit2[pointi].hitPoint()-pt;
1493 if (
override && isPatchMasterPoint[pointi])
1515 label zoneSurfi = zonedSurfaces[i];
1516 const labelList surfacesToTest(1, zoneSurfi);
1519 surfZones[zoneSurfi].faceZoneNames();
1520 forAll(faceZoneNames, namei)
1522 const word& faceZoneName = faceZoneNames[namei];
1526 getZoneSurfacePoints
1565 label pointi = zonePointIndices[i];
1568 const point& pt = localPoints[pointi];
1570 bool override =
false;
1609 if (hit1[i].hit() && hit2[i].hit())
1625 const point& intPt = hit2[i].hitPoint();
1629 disp[pointi] = hit2[i].hitPoint()-pt;
1634 if (
override && isPatchMasterPoint[pointi])
1643 Info<<
"Overriding nearest with intersection of close gaps at "
1646 <<
" points." <<
endl;
1650 void Foam::snappySnapDriver::calcNearestSurface
1673 if (nearestNormal.size() == localPoints.size())
1693 if (hitInfo[i].hit())
1695 label pointi = zonePointIndices[i];
1696 nearestPoint[pointi] = hitInfo[i].hitPoint();
1697 nearestNormal[pointi] = hitNormal[i];
1718 if (hitInfo[i].hit())
1720 label pointi = zonePointIndices[i];
1722 patchDisp[pointi] = hitInfo[i].hitPoint() - localPoints[pointi];
1723 minSnapDist[pointi] =
mag(patchDisp[pointi]);
1724 snapSurf[pointi] = hitSurface[i];
1732 const bool strictRegionSnap,
1742 Info<<
"Calculating patchDisplacement as distance to nearest surface"
1743 <<
" point ..." <<
endl;
1744 if (strictRegionSnap)
1746 Info<<
" non-zone points : attract to local region on surface only"
1748 <<
" zone points : attract to local region on surface only"
1754 Info<<
" non-zone points :"
1755 <<
" attract to nearest of all non-zone surfaces"
1757 <<
" zone points : attract to zone surface only" <<
nl
1773 labelList snapSurf(localPoints.size(), -1);
1780 if (strictRegionSnap)
1786 label geomi = surfaces.
surfaces()[surfi];
1787 label nRegions = surfaces.
geometry()[geomi].regions().size();
1789 const labelList surfacesToTest(1, surfi);
1791 for (label regioni = 0; regioni < nRegions; regioni++)
1794 label masterPatchi = globalToMasterPatch[globali];
1825 if (globalToSlavePatch[globali] != masterPatchi)
1827 label slavePatchi = globalToSlavePatch[globali];
1877 if (nearestNormal.size() == localPoints.size())
1894 if (hitInfo[pointi].hit())
1896 nearestPoint[pointi] = hitInfo[pointi].hitPoint();
1897 nearestNormal[pointi] = hitNormal[pointi];
1915 if (hitInfo[pointi].hit())
1918 hitInfo[pointi].hitPoint()
1919 - localPoints[pointi];
1921 snapSurf[pointi] = hitSurface[pointi];
1941 label surfi = zonedSurfaces[i];
1942 const labelList surfacesToTest(1, surfi);
1943 const label geomi = surfaces.
surfaces()[surfi];
1944 const label nRegions =
1945 surfaces.
geometry()[geomi].regions().size();
1948 surfZones[surfi].faceZoneNames();
1952 forAll(faceZoneNames, locali)
1954 getZoneSurfacePoints
1958 faceZoneNames[locali],
1989 if (snapSurf[pointi] == -1)
1991 static label nWarn = 0;
1996 <<
"For point:" << pointi
1997 <<
" coordinate:" << localPoints[pointi]
1998 <<
" did not find any surface within:"
1999 << minSnapDist[pointi] <<
" metre." <<
endl;
2004 <<
"Reached warning limit " << nWarn
2005 <<
". Suppressing further warnings." <<
endl;
2012 const bitSet isPatchMasterPoint
2023 Info<<
"Wanted displacement : average:"
2025 <<
" min:" <<
gMin(magDisp)
2026 <<
" max:" <<
gMax(magDisp) <<
endl;
2030 Info<<
"Calculated surface displacement in = "
2036 forAll(patchDisp, patchPointi)
2038 scalar magDisp =
mag(patchDisp[patchPointi]);
2040 if (magDisp > snapDist[patchPointi])
2042 patchDisp[patchPointi] *= snapDist[patchPointi] / magDisp;
2044 Pout<<
"Limiting displacement for " << patchPointi
2045 <<
" from " << magDisp <<
" to " << snapDist[patchPointi]
2058 vector(GREAT, GREAT, GREAT)
2079 Info<<
"Smoothing displacement ..." <<
endl;
2089 for (label iter = 0; iter < snapParams.
nSmoothDispl(); iter++)
2091 if ((iter % 10) == 0)
2093 Info<<
"Iteration " << iter <<
endl;
2096 meshMover.
smooth(oldDisp, edgeGamma, disp);
2098 Info<<
"Displacement smoothed in = "
2104 Info<<
"Writing smoothed mesh to time " << meshRefiner_.timeName()
2121 Info<<
"Writing displacement field ..." <<
endl;
2126 Info<<
"Writing actual patch displacement ..." <<
endl;
2131 /
"actualPatchDisplacement_" + meshRefiner_.timeName() +
".obj",
2142 const label nInitErrors,
2154 scalar oldErrorReduction = -1;
2156 bool meshOk =
false;
2159 for (label iter = 0; iter < 2*snapParams.
nSnap(); iter++)
2163 if (iter == snapParams.
nSnap())
2165 Info<<
"Displacement scaling for error reduction set to 0." <<
endl;
2169 meshOk = meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors);
2173 Info<<
"Successfully moved mesh" <<
endl;
2179 Info<<
"Writing scaled mesh to time " << meshRefiner_.timeName()
2183 Info<<
"Writing displacement field ..." <<
endl;
2190 if (oldErrorReduction >= 0)
2194 Info<<
"Moved mesh in = "
2216 Info<<
"Repatching faces according to nearest surface ..." <<
endl;
2240 forAll(preserveFaces, facei)
2242 if (preserveFaces[facei] != -1)
2244 isZonedFace.set(facei);
2254 const label zoneSurfi = zonedSurfaces[i];
2255 const wordList& fZoneNames = surfZones[zoneSurfi].faceZoneNames();
2258 const faceZone& fZone = fZones[fZoneNames[i]];
2259 isZonedFace.set(fZone);
2287 forAll(localFaces, facei)
2289 const face&
f = localFaces[facei];
2293 faceSnapDist[facei] =
max
2295 faceSnapDist[facei],
2319 label facei = pp.addressing()[i];
2321 if (hitSurface[i] != -1 && !isZonedFace.test(facei))
2323 closestPatch[i] = globalToMasterPatch_
2350 ownPatch[pp.
start()+i] = patchi;
2351 neiPatch[pp.
start()+i] = patchi;
2358 label facei = pp.addressing()[i];
2360 if (closestPatch[i] != -1 && closestPatch[i] != ownPatch[facei])
2362 ownPatch[facei] = closestPatch[i];
2363 neiPatch[facei] = closestPatch[i];
2372 return meshRefiner_.createBaffles(ownPatch, neiPatch);
2376 void Foam::snappySnapDriver::detectWarpedFaces
2378 const scalar featureCos,
2388 const labelList& bFaces = pp.addressing();
2401 forAll(localFaces, facei)
2403 const face&
f = localFaces[facei];
2411 scalar minCos(GREAT);
2413 for (label startFp = 0; startFp <
f.size()-2; startFp++)
2415 label minFp =
f.rcIndex(startFp);
2419 label endFp =
f.fcIndex(
f.fcIndex(startFp));
2420 endFp <
f.size() && endFp != minFp;
2427 for (label fp = startFp; fp <= endFp; fp++)
2433 for (label fp = endFp; fp != startFp; fp =
f.fcIndex(fp))
2437 f1[i1++] =
f[startFp];
2442 const vector n0 = f0.areaNormal(localPoints);
2443 const scalar n0Mag =
mag(n0);
2445 const vector n1 = f1.areaNormal(localPoints);
2446 const scalar n1Mag =
mag(n1);
2448 if (n0Mag > ROOTVSMALL && n1Mag > ROOTVSMALL)
2450 scalar cosAngle = (n0/n0Mag) & (n1/n1Mag);
2451 if (cosAngle < minCos)
2461 if (minCos < featureCos)
2463 splitFaces.
append(bFaces[facei]);
2471 Foam::labelList Foam::snappySnapDriver::getInternalOrBaffleDuplicateFace()
const
2473 const fvMesh&
mesh = meshRefiner_.mesh();
2477 List<surfaceZonesInfo::faceZoneType> fzTypes(2);
2480 internalOrBaffleFaceZones = meshRefiner_.getZones(fzTypes);
2483 List<labelPair> baffles
2485 meshRefiner_.subsetBaffles
2488 internalOrBaffleFaceZones,
2497 faceToDuplicate[
p[0]] =
p[1];
2498 faceToDuplicate[
p[1]] =
p[0];
2501 return faceToDuplicate;
2510 const scalar featureCos,
2511 const scalar planarAngle,
2519 <<
"Morphing phase" <<
nl
2520 <<
"--------------" <<
nl
2559 meshRefiner_.getZones
2575 meshRefiner_.createZoneBaffles
2584 meshRefiner_.dupNonManifoldBoundaryPoints();
2587 bool doFeatures =
false;
2588 label nFeatIter = 1;
2598 Info<<
"Snapping to features in " << nFeatIter
2599 <<
" iterations ..." <<
endl;
2603 bool meshOk =
false;
2607 labelList adaptPatchIDs(meshRefiner_.meshedPatches());
2627 Info<<
"Constructing mesh displacer ..." <<
endl;
2628 Info<<
"Using mesh parameters " << motionDict <<
nl <<
endl;
2649 Info<<
"Checking initial mesh ..." <<
endl;
2658 Info<<
"Detected " << nInitErrors <<
" illegal faces"
2659 <<
" (concave, zero area or negative cell pyramid volume)"
2663 Info<<
"Checked initial mesh in = "
2670 meshRefiner_.subsetBaffles
2706 for (label iter = 0; iter < nFeatIter; iter++)
2709 <<
"Morph iteration " << iter <<
nl
2710 <<
"-----------------" <<
endl;
2713 bool doSplit =
false;
2719 (iter == nFeatIter-1)
2749 globalToMasterPatch_,
2750 globalToSlavePatch_,
2778 disp = calcNearestSurfaceFeature
2784 scalar(iter+1)/nFeatIter,
2800 outwardsDisplacement(pp, disp);
2813 /
"patchDisplacement_" +
name(iter) +
".obj",
2815 pp.localPoints() + disp
2820 smoothDisplacement(snapParams, meshMover);
2834 <<
"Did not successfully snap mesh."
2835 <<
" Continuing to snap to resolve easy" <<
nl
2836 <<
" surfaces but the"
2837 <<
" resulting mesh will not satisfy your quality"
2838 <<
" constraints" <<
nl <<
endl;
2844 Info<<
"Writing scaled mesh to time "
2845 << meshRefiner_.timeName() <<
endl;
2856 Info<<
"Writing displacement field ..." <<
endl;
2872 if (nTotalSplit && doSplit)
2877 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
2880 labelList oldSplitFaces(std::move(splitFaces));
2884 if (duplicateFace[oldSplitFaces[i]] == -1)
2886 splitFaces.
append(oldSplitFaces[i]);
2887 splits.
append(oldSplits[i]);
2898 meshRefiner_.splitFacesUndo
2909 meshMoverPtr.
clear();
2932 snapDist = calcSnapDistance(
mesh, snapParams, ppPtr());
2938 Info<<
"Writing split-faces mesh to time "
2939 << meshRefiner_.timeName() <<
endl;
2956 forAll(internalBaffles, i)
2962 if (
mag(fc0-fc1) > meshRefiner_.mergeDistance())
2965 <<
"Separated baffles : f0:" <<
p[0]
2966 <<
" centre:" << fc0
2967 <<
" f1:" <<
p[1] <<
" centre:" << fc1
2968 <<
" distance:" <<
mag(fc0-fc1)
2990 Info<<
"Writing baffle-merged mesh to time "
2991 << meshRefiner_.timeName() <<
endl;
3000 meshRefiner_.timeName()
3008 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3010 repatchToSurface(snapParams, adaptPatchIDs, duplicateFace);
3015 mergeType == meshRefinement::FaceMergeType::GEOMETRIC
3016 || mergeType == meshRefinement::FaceMergeType::IGNOREPATCH
3019 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3024 label nChanged = meshRefiner_.mergePatchFacesUndo
3028 meshRefiner_.meshedPatches(),
3034 nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict);
3039 Info<<
"Writing patchFace merged mesh to time "
3040 << meshRefiner_.timeName() <<
endl;
3049 meshRefiner_.timeName()
int debug
Static debugging option.
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
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)
static void syncPoints(const polyMesh &mesh, List< weightedPosition > &)
Synchronisation for mesh point positions.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
void correct()
Take over existing mesh position.
const labelList & surfaces() const
const indirectPrimitivePatch & patch() const
Reference to patch.
static writeType writeLevel()
Get/set write level.
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)
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.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const fvMesh & mesh() const
Reference to mesh.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
const searchableSurfaces & geometry() const
label nPoints() const noexcept
Number of mesh points.
void setCapacity(const label len)
Alter the size of the underlying storage.
#define forAll(list, i)
Loop across all elements in list.
Field< vector > vectorField
Specialisation of Field<T> for vector.
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
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 (stdout output on master, null elsewhere)
A patch is a list of labels that address the faces in the global face list.
void setSize(const label n)
Alias for resize()
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
const labelListList & pointEdges() const
Return point-edge addressing.
virtual const labelList & faceOwner() const
Return face owner.
Switch strictRegionSnap() const
Attract point to corresponding surface region only.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
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
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.
label nTotalPoints() const noexcept
Return total number of points in decomposed mesh. Not.
static const weightedPosition zero
Mesh data needed to do the Finite Volume discretisation.
errorManip< error > abort(error &err)
label findZoneID(const word &zoneName) const
Find zone index by 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.
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,.
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
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
A 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)
static void getPoints(const UList< weightedPosition > &in, List< point > &out)
Get points.
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.
label nInternalFaces() const noexcept
Number of internal faces.
dimensionedScalar sqrt(const dimensionedScalar &ds)
A traits class, which is primarily used for primitives.
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.
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)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
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.
SubField< vector > subField
Declare type of subField.
label nFaces() const noexcept
Number of mesh faces.
A face is a list of labels corresponding to mesh vertices.
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
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.
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.
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];} 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]
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.
label nTotalFaces() const noexcept
Return total number of faces in decomposed mesh. Not.
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.