68Foam::label Foam::snappySnapDriver::getCollocatedPoints
72 bitSet& isCollocatedPoint
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
241 pTraits<weightedPosition>::zero
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
360 pTraits<weightedPosition>::zero
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
403 pTraits<weightedPosition>::zero
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;
530 newPos = (1-blend)*avgPos + blend*currentPos;
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;
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());
674void 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;
703bool 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;
744void Foam::snappySnapDriver::freezeExposedPoints
746 const meshRefinement& meshRefiner,
753 const fvMesh&
mesh = meshRefiner.mesh();
759 const label pointZonei = pointZones.findZoneID(pzName);
760 if (pointZonei != -1)
762 isFrozenPoint.set(pointZones[pointZonei]);
767 const label faceZonei = faceZones.
findZoneID(fzName);
772 UIndirectList<face>(
mesh.
faces(), faceZones[faceZonei]),
777 const labelList nEdgeFaces(meshRefiner.countEdgeFaces(pp));
782 if (nEdgeFaces[edgei] != 1)
784 const edge&
e = pp.edges()[edgei];
785 isFrozenPoint.
set(pp.meshPoints()[
e[0]]);
786 isFrozenPoint.set(pp.meshPoints()[
e[1]]);
795 orEqOp<unsigned int>(),
799 if (
returnReduce(isFrozenPoint.count(), sumOp<label>()))
801 for (
const label pointi : isFrozenPoint)
803 const auto& iter = outside.meshPointMap().find(pointi);
806 outsideDisp[iter()] =
Zero;
823 meshRefiner_(meshRefiner),
824 globalToMasterPatch_(globalToMasterPatch),
825 globalToSlavePatch_(globalToSlavePatch),
845 forAll(pointEdges, pointi)
847 const labelList& pEdges = pointEdges[pointi];
851 const edge&
e = edges[pEdges[pEdgei]];
853 scalar len =
e.mag(localPoints);
855 maxEdgeLen[pointi] =
max(maxEdgeLen[pointi], len);
876 const label nInitErrors,
888 Info<<
"Smoothing patch and internal points ..." <<
endl;
892 Info<<
"Smoothing patch points ..." <<
endl;
899 label smoothIter = 0;
904 Info<<
"Smoothing iteration " << smoothIter <<
endl;
908 checkFaces[facei] = facei;
915 pointDisp = smoothInternalDisplacement(meshRefiner, meshMover);
919 pointField patchDisp(smoothPatchDisplacement(meshMover, baffles));
932 scalar oldErrorReduction = -1;
934 for (label snapIter = 0; snapIter < 2*snapParams.
nSnap(); snapIter++)
936 Info<<
nl <<
"Scaling iteration " << snapIter <<
endl;
938 if (snapIter == snapParams.
nSnap())
940 Info<<
"Displacement scaling for error reduction set to 0."
947 if (meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors))
949 Info<<
"Successfully moved mesh" <<
endl;
954 if (oldErrorReduction >= 0)
968 Info<<
"Writing patch smoothed mesh to time "
980 Info<<
"Dumped mesh in = "
984 Info<<
"Patch points smoothed in = "
990void Foam::snappySnapDriver::getZoneSurfacePoints
994 const word& zoneName,
1004 <<
"Cannot find zone " << zoneName
1020 label meshPointi =
f[fp];
1026 const label pointi = iter.
val();
1027 pointOnZone[pointi] =
true;
1048 forAll(pointFaces, pointi)
1055 label facei =
pFaces[pfi];
1067 return tavgBoundary;
1121 const scalar planarCos,
1129 Info<<
"Detecting near surfaces ..." <<
endl;
1418 forAll(localPoints, pointi)
1420 const point& pt = localPoints[pointi];
1421 const vector d = 2*(avgCc[pointi]-pt);
1422 start[pointi] = pt - d;
1423 end[pointi] = pt + d;
1435 /
"detectNearSurfaces_" + meshRefiner_.timeName() +
".obj"
1441 const bitSet isPatchMasterPoint
1450 label nOverride = 0;
1458 meshRefiner_.surfaces().surfZones()
1489 forAll(localPoints, pointi)
1492 const point& pt = localPoints[pointi];
1494 bool override =
false;
1533 if (hit1[pointi].hit() && hit2[pointi].hit())
1540 hit1[pointi].hitPoint(),
1542 hit2[pointi].hitPoint(),
1552 const point& intPt = hit2[pointi].hitPoint();
1557 disp[pointi] = hit2[pointi].hitPoint()-pt;
1562 if (
override && isPatchMasterPoint[pointi])
1584 label zoneSurfi = zonedSurfaces[i];
1585 const labelList surfacesToTest(1, zoneSurfi);
1588 surfZones[zoneSurfi].faceZoneNames();
1589 forAll(faceZoneNames, namei)
1591 const word& faceZoneName = faceZoneNames[namei];
1595 getZoneSurfacePoints
1634 label pointi = zonePointIndices[i];
1637 const point& pt = localPoints[pointi];
1639 bool override =
false;
1678 if (hit1[i].hit() && hit2[i].hit())
1694 const point& intPt = hit2[i].hitPoint();
1698 disp[pointi] = hit2[i].hitPoint()-pt;
1703 if (
override && isPatchMasterPoint[pointi])
1712 Info<<
"Overriding nearest with intersection of close gaps at "
1715 <<
" points." <<
endl;
1719void Foam::snappySnapDriver::calcNearestSurface
1742 if (nearestNormal.
size() == localPoints.
size())
1762 if (hitInfo[i].hit())
1764 label pointi = zonePointIndices[i];
1765 nearestPoint[pointi] = hitInfo[i].hitPoint();
1766 nearestNormal[pointi] = hitNormal[i];
1787 if (hitInfo[i].hit())
1789 label pointi = zonePointIndices[i];
1791 patchDisp[pointi] = hitInfo[i].hitPoint() - localPoints[pointi];
1792 minSnapDist[pointi] =
mag(patchDisp[pointi]);
1793 snapSurf[pointi] = hitSurface[i];
1801 const bool strictRegionSnap,
1811 Info<<
"Calculating patchDisplacement as distance to nearest surface"
1812 <<
" point ..." <<
endl;
1813 if (strictRegionSnap)
1815 Info<<
" non-zone points : attract to local region on surface only"
1817 <<
" zone points : attract to local region on surface only"
1823 Info<<
" non-zone points :"
1824 <<
" attract to nearest of all non-zone surfaces"
1826 <<
" zone points : attract to zone surface only" <<
nl
1849 if (strictRegionSnap)
1855 label geomi = surfaces.
surfaces()[surfi];
1856 label nRegions = surfaces.
geometry()[geomi].regions().
size();
1858 const labelList surfacesToTest(1, surfi);
1860 for (label regioni = 0; regioni < nRegions; regioni++)
1863 label masterPatchi = globalToMasterPatch[globali];
1894 if (globalToSlavePatch[globali] != masterPatchi)
1896 label slavePatchi = globalToSlavePatch[globali];
1946 if (nearestNormal.
size() == localPoints.
size())
1963 if (hitInfo[pointi].hit())
1965 nearestPoint[pointi] = hitInfo[pointi].hitPoint();
1966 nearestNormal[pointi] = hitNormal[pointi];
1984 if (hitInfo[pointi].hit())
1987 hitInfo[pointi].hitPoint()
1988 - localPoints[pointi];
1990 snapSurf[pointi] = hitSurface[pointi];
2010 label surfi = zonedSurfaces[i];
2011 const labelList surfacesToTest(1, surfi);
2012 const label geomi = surfaces.
surfaces()[surfi];
2013 const label nRegions =
2017 surfZones[surfi].faceZoneNames();
2021 forAll(faceZoneNames, locali)
2023 getZoneSurfacePoints
2027 faceZoneNames[locali],
2058 if (snapSurf[pointi] == -1)
2060 static label nWarn = 0;
2065 <<
"For point:" << pointi
2066 <<
" coordinate:" << localPoints[pointi]
2067 <<
" did not find any surface within:"
2068 << minSnapDist[pointi] <<
" metre." <<
endl;
2073 <<
"Reached warning limit " << nWarn
2074 <<
". Suppressing further warnings." <<
endl;
2081 const bitSet isPatchMasterPoint
2092 Info<<
"Wanted displacement : average:"
2094 <<
" min:" <<
gMin(magDisp)
2095 <<
" max:" <<
gMax(magDisp) <<
endl;
2099 Info<<
"Calculated surface displacement in = "
2105 forAll(patchDisp, patchPointi)
2107 scalar magDisp =
mag(patchDisp[patchPointi]);
2109 if (magDisp > snapDist[patchPointi])
2111 patchDisp[patchPointi] *= snapDist[patchPointi] / magDisp;
2113 Pout<<
"Limiting displacement for " << patchPointi
2114 <<
" from " << magDisp <<
" to " << snapDist[patchPointi]
2127 vector(GREAT, GREAT, GREAT)
2148 Info<<
"Smoothing displacement ..." <<
endl;
2158 for (label iter = 0; iter < snapParams.
nSmoothDispl(); iter++)
2160 if ((iter % 10) == 0)
2162 Info<<
"Iteration " << iter <<
endl;
2165 meshMover.
smooth(oldDisp, edgeGamma, disp);
2167 Info<<
"Displacement smoothed in = "
2173 Info<<
"Writing smoothed mesh to time " << meshRefiner_.timeName()
2190 Info<<
"Writing displacement field ..." <<
endl;
2195 Info<<
"Writing actual patch displacement ..." <<
endl;
2200 /
"actualPatchDisplacement_" + meshRefiner_.timeName() +
".obj",
2211 const label nInitErrors,
2223 scalar oldErrorReduction = -1;
2225 bool meshOk =
false;
2228 for (label iter = 0; iter < 2*snapParams.
nSnap(); iter++)
2232 if (iter == snapParams.
nSnap())
2234 Info<<
"Displacement scaling for error reduction set to 0." <<
endl;
2238 meshOk = meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors);
2242 Info<<
"Successfully moved mesh" <<
endl;
2248 Info<<
"Writing scaled mesh to time " << meshRefiner_.timeName()
2252 Info<<
"Writing displacement field ..." <<
endl;
2259 if (oldErrorReduction >= 0)
2263 Info<<
"Moved mesh in = "
2285 Info<<
"Repatching faces according to nearest surface ..." <<
endl;
2309 forAll(preserveFaces, facei)
2311 if (preserveFaces[facei] != -1)
2313 isZonedFace.
set(facei);
2323 const label zoneSurfi = zonedSurfaces[i];
2324 const wordList& fZoneNames = surfZones[zoneSurfi].faceZoneNames();
2327 const faceZone& fZone = fZones[fZoneNames[i]];
2328 isZonedFace.
set(fZone);
2356 forAll(localFaces, facei)
2358 const face&
f = localFaces[facei];
2362 faceSnapDist[facei] =
max
2364 faceSnapDist[facei],
2388 label facei = pp.addressing()[i];
2390 if (hitSurface[i] != -1 && !isZonedFace.
test(facei))
2392 closestPatch[i] = globalToMasterPatch_
2419 ownPatch[pp.
start()+i] = patchi;
2420 neiPatch[pp.
start()+i] = patchi;
2427 label facei = pp.addressing()[i];
2429 if (closestPatch[i] != -1 && closestPatch[i] != ownPatch[facei])
2431 ownPatch[facei] = closestPatch[i];
2432 neiPatch[facei] = closestPatch[i];
2441 return meshRefiner_.createBaffles(ownPatch, neiPatch);
2445void Foam::snappySnapDriver::detectWarpedFaces
2447 const scalar featureCos,
2457 const labelList& bFaces = pp.addressing();
2470 forAll(localFaces, facei)
2472 const face&
f = localFaces[facei];
2480 scalar minCos(GREAT);
2482 for (label startFp = 0; startFp <
f.
size()-2; startFp++)
2489 endFp <
f.
size() && endFp != minFp;
2494 f0.setSize(endFp-startFp+1);
2496 for (label fp = startFp; fp <= endFp; fp++)
2502 for (label fp = endFp; fp != startFp; fp =
f.
fcIndex(fp))
2506 f1[i1++] =
f[startFp];
2511 const vector n0 = f0.areaNormal(localPoints);
2512 const scalar n0Mag =
mag(n0);
2514 const vector n1 = f1.areaNormal(localPoints);
2515 const scalar n1Mag =
mag(n1);
2517 if (n0Mag > ROOTVSMALL && n1Mag > ROOTVSMALL)
2519 scalar cosAngle = (n0/n0Mag) & (n1/n1Mag);
2520 if (cosAngle < minCos)
2530 if (minCos < featureCos)
2532 splitFaces.
append(bFaces[facei]);
2540Foam::labelList Foam::snappySnapDriver::getInternalOrBaffleDuplicateFace()
const
2542 const fvMesh&
mesh = meshRefiner_.mesh();
2546 List<surfaceZonesInfo::faceZoneType> fzTypes(2);
2549 internalOrBaffleFaceZones = meshRefiner_.getZones(fzTypes);
2552 List<labelPair> baffles
2554 meshRefiner_.subsetBaffles
2557 internalOrBaffleFaceZones,
2566 faceToDuplicate[
p[0]] =
p[1];
2567 faceToDuplicate[
p[1]] =
p[0];
2570 return faceToDuplicate;
2579 const scalar featureCos,
2580 const scalar planarAngle,
2588 <<
"Morphing phase" <<
nl
2589 <<
"--------------" <<
nl
2628 meshRefiner_.getZones
2644 meshRefiner_.createZoneBaffles
2653 meshRefiner_.dupNonManifoldBoundaryPoints();
2656 bool doFeatures =
false;
2657 label nFeatIter = 1;
2667 Info<<
"Snapping to features in " << nFeatIter
2668 <<
" iterations ..." <<
endl;
2672 bool meshOk =
false;
2676 labelList adaptPatchIDs(meshRefiner_.meshedPatches());
2696 Info<<
"Constructing mesh displacer ..." <<
endl;
2697 Info<<
"Using mesh parameters " << motionDict <<
nl <<
endl;
2718 Info<<
"Checking initial mesh ..." <<
endl;
2727 Info<<
"Detected " << nInitErrors <<
" illegal faces"
2728 <<
" (concave, zero area or negative cell pyramid volume)"
2732 Info<<
"Checked initial mesh in = "
2739 meshRefiner_.subsetBaffles
2775 for (label iter = 0; iter < nFeatIter; iter++)
2778 <<
"Morph iteration " << iter <<
nl
2779 <<
"-----------------" <<
endl;
2782 bool doSplit =
false;
2788 (iter == nFeatIter-1)
2818 globalToMasterPatch_,
2819 globalToSlavePatch_,
2847 disp = calcNearestSurfaceFeature
2853 scalar(iter+1)/nFeatIter,
2869 outwardsDisplacement(pp, disp);
2892 /
"patchDisplacement_" +
name(iter) +
".obj",
2899 smoothDisplacement(snapParams, meshMover);
2913 <<
"Did not successfully snap mesh."
2914 <<
" Continuing to snap to resolve easy" <<
nl
2915 <<
" surfaces but the"
2916 <<
" resulting mesh will not satisfy your quality"
2917 <<
" constraints" <<
nl <<
endl;
2923 Info<<
"Writing scaled mesh to time "
2924 << meshRefiner_.timeName() <<
endl;
2935 Info<<
"Writing displacement field ..." <<
endl;
2951 if (nTotalSplit && doSplit)
2956 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
2959 labelList oldSplitFaces(std::move(splitFaces));
2963 if (duplicateFace[oldSplitFaces[i]] == -1)
2965 splitFaces.
append(oldSplitFaces[i]);
2966 splits.
append(oldSplits[i]);
2977 meshRefiner_.splitFacesUndo
2988 meshMoverPtr.
clear();
3011 snapDist = calcSnapDistance(
mesh, snapParams, ppPtr());
3017 Info<<
"Writing split-faces mesh to time "
3018 << meshRefiner_.timeName() <<
endl;
3035 forAll(internalBaffles, i)
3041 if (
mag(fc0-fc1) > meshRefiner_.mergeDistance())
3044 <<
"Separated baffles : f0:" <<
p[0]
3045 <<
" centre:" << fc0
3046 <<
" f1:" <<
p[1] <<
" centre:" << fc1
3047 <<
" distance:" <<
mag(fc0-fc1)
3069 Info<<
"Writing baffle-merged mesh to time "
3070 << meshRefiner_.timeName() <<
endl;
3079 meshRefiner_.timeName()
3087 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3089 repatchToSurface(snapParams, adaptPatchIDs, duplicateFace);
3098 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3103 label nChanged = meshRefiner_.mergePatchFacesUndo
3107 meshRefiner_.meshedPatches(),
3113 nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict);
3118 Info<<
"Writing patchFace merged mesh to time "
3119 << meshRefiner_.timeName() <<
endl;
3128 meshRefiner_.timeName()
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
void setCapacity(const label len)
Alter the size of the underlying storage.
SubField< vector > subField
Declare type of subField.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
reference val() const
Const access to referenced object (value)
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
label size() const noexcept
The number of elements in table.
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 setSize(const label n)
Alias for resize()
OFstream that keeps track of vertices.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A list of faces which address into the list of points.
label nPoints() const
Number of points supporting patch faces.
const labelListList & pointEdges() const
Return point-edge addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Map< label > & meshPointMap() const
Mesh point map.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const labelListList & pointFaces() const
Return point-face addressing.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
fileName path() const
Return path.
T & first()
Return the first element of the list.
label rcIndex(const label i) const noexcept
void size(const label n)
Older name for setAddressableSize.
label fcIndex(const label i) const noexcept
label size() const noexcept
The number of elements in the list.
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
void clear() noexcept
Same as reset(nullptr)
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool test(const label pos) const
Test value at specified position, never auto-vivify entries.
labelList toc() const
The indices of the on bits as a sorted labelList.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
virtual const vectorField & pointNormals() const
Return point unit normals.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A subset of mesh faces organised as a primitive patch.
A face is a list of labels corresponding to mesh vertices.
Mesh data needed to do the Finite Volume discretisation.
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
const Time & time() const
Return the top-level database.
label nTotalFaces() const noexcept
Return total number of faces in decomposed mesh. Not.
label nTotalPoints() const noexcept
Return total number of points in decomposed mesh. Not.
void checkMesh() const
Debug: Check coupled mesh for correctness.
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
static T gAverage(const bitSet &isMasterElem, const UList< T > &values)
Helper: calculate average.
static bitSet getMasterPoints(const polyMesh &mesh, const labelList &meshPoints)
Determine master point for subset of points. If coupled.
writeType
Enumeration for what to write. Used as a bit-pattern.
const refinementSurfaces & surfaces() const
Reference to surface search engines.
debugType
Enumeration for what to debug. Used as a bit-pattern.
const fvMesh & mesh() const
Reference to mesh.
static tmp< pointVectorField > makeDisplacementField(const pointMesh &pMesh, const labelList &adaptPatchIDs)
Helper function to make a pointVectorField with correct.
FaceMergeType
Enumeration for what to do with co-planar patch faces on a single.
static autoPtr< indirectPrimitivePatch > makePatch(const polyMesh &, const labelList &)
Create patch from set of patches.
bool write() const
Write mesh and all data.
static writeType writeLevel()
Get/set write level.
scalar setErrorReduction(const scalar)
Set the errorReduction (by how much to scale the displacement.
static void setDisplacement(const labelList &patchIDs, const indirectPrimitivePatch &pp, pointField &patchDisp, pointVectorField &displacement)
Set displacement field from displacement on patch points.
void correct()
Take over existing mesh position.
const indirectPrimitivePatch & patch() const
Reference to patch.
void smooth(const GeometricField< Type, pointPatchField, pointMesh > &fld, const scalarField &edgeWeight, GeometricField< Type, pointPatchField, pointMesh > &newFld) const
Fully explicit smoothing of fields (not positions)
const pointMesh & pMesh() const
Reference to pointMesh.
pointVectorField & pointDisplacement()
Return reference to the point motion displacement field.
bool scaleMesh(labelList &checkFaces, const bool smoothMesh=true, const label nAllow=0)
Move mesh with given scale. Return true if mesh ok or has.
pointVectorField & displacement()
Reference to displacement field.
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh err...
static const complex max
complex (VGREAT,VGREAT)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
label start() const
Return start label of this patch in the polyMesh face list.
const vectorField & faceCentres() const
const labelListList & pointCells() const
label nInternalFaces() const noexcept
Number of internal faces.
const vectorField & cellCentres() const
label nPoints() const noexcept
Number of mesh points.
label nFaces() const noexcept
Number of mesh faces.
label nEdges() const
Number of mesh edges.
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
const searchableSurfaces & geometry() const
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
const labelList & surfaces() const
void findNearestRegion(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &hitSurface, labelList &hitRegion) const
Find nearest point on surfaces. Return surface and region on.
void findNearestIntersection(const labelList &surfacesToTest, const pointField &start, const pointField &end, labelList &surface1, List< pointIndexHit > &hit1, labelList ®ion1, labelList &surface2, List< pointIndexHit > &hit2, labelList ®ion2) const
Find intersection nearest to the endpoints. surface1,2 are.
const PtrList< surfaceZonesInfo > & surfZones() const
virtual bool write(const bool valid=true) const
Write using setting from DB.
Simple container to keep together snap specific information.
label nSmoothDispl() const
Number of mesh displacement smoothing iterations.
scalar snapTol() const
Relative distance for points to be attracted by surface.
label nSnap() const
Maximum number of snapping relaxation iterations. Should stop.
Switch strictRegionSnap() const
Attract point to corresponding surface region only.
label nSmoothPatch() const
Number of patch smoothing iterations before finding.
label nFeatureSnap() const
label nSmoothInternal() const
Number of internal point smoothing iterations (combined with.
label nFaceSplitInterval() const
Switch detectNearSurfacesSnap() const
Override attraction to nearest with intersection location.
All to do with snapping to surface.
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.
bool scaleMesh(const snapParameters &snapParams, const label nInitErrors, const List< labelPair > &baffles, motionSmoother &)
Do the hard work: move the mesh according to displacement,.
static void preSmoothPatch(const meshRefinement &meshRefiner, const snapParameters &snapParams, const label nInitErrors, const List< labelPair > &baffles, motionSmoother &)
Smooth the mesh (patch and internal) to increase visibility.
static tmp< pointField > avgCellCentres(const fvMesh &mesh, const indirectPrimitivePatch &)
Helper: calculate average cell centre per point.
void doSnap(const dictionary &snapDict, const dictionary &motionDict, const meshRefinement::FaceMergeType mergeType, const scalar featureCos, const scalar planarAngle, const snapParameters &snapParams)
void smoothDisplacement(const snapParameters &snapParams, motionSmoother &) const
Smooth the displacement field to the internal.
autoPtr< mapPolyMesh > repatchToSurface(const snapParameters &snapParams, const labelList &adaptPatchIDs, const labelList &preserveFaces)
Repatch faces according to surface nearest the face centre.
static scalarField calcSnapDistance(const fvMesh &mesh, const snapParameters &snapParams, const indirectPrimitivePatch &)
Calculate edge length per patch point.
static labelList getUnnamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of unnamed surfaces (surfaces without faceZoneName)
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
A class for managing temporary objects.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static void getPoints(const UList< weightedPosition > &in, List< point > &out)
Get points.
static void syncPoints(const polyMesh &mesh, List< weightedPosition > &)
Synchronisation for mesh point positions.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf())
Geometric merging of points. See below.
#define WarningInFunction
Report a warning using Foam::Warning.
const wordList internal
Standard dimensioned field types (scalar, vector, tensor, etc)
Pair< label > labelPair
A pair of labels.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
line< point, const point & > linePointRef
A line using referred points.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label mergePoints(const PointList &points, labelList &pointToUnique, labelList &uniquePoints, const scalar mergeTol=SMALL, const bool verbose=false)
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
dimensionedScalar sqrt(const dimensionedScalar &ds)
PrimitivePatch< UIndirectList< face >, const pointField & > uindirectPrimitivePatch
A PrimitivePatch with UIndirectList for the faces, const reference for the point field.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
List< labelList > labelListList
A List of labelList.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0)
Type gMin(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< face > faceList
A List of faces.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
A PrimitivePatch with an IndirectList for the faces, const reference for the point field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gMax(const FieldField< Field, Type > &f)
dimensionedScalar cos(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a)
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
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]
#define forAll(list, i)
Loop across all elements in list.
A non-counting (dummy) refCount.
Unit conversion functions.