56 Foam::label Foam::snappySnapDriver::getCollocatedPoints
60 PackedBoolList& isCollocatedPoint
71 bool hasMerged = (nUnique < points.size());
79 label nCollocated = 0;
84 forAll(pointMap, oldPointi)
86 label newPointi = pointMap[oldPointi];
88 if (firstOldPoint[newPointi] == -1)
93 else if (firstOldPoint[newPointi] == -2)
96 isCollocatedPoint.set(oldPointi, 1u);
102 isCollocatedPoint.set(firstOldPoint[newPointi], 1u);
105 isCollocatedPoint.set(oldPointi, 1u);
118 const motionSmoother& meshMover,
119 const List<labelPair>& baffles
125 PackedBoolList nonManifoldPoint(pp.nPoints());
126 label nNonManifoldPoints = getCollocatedPoints
132 Info<<
"Found " << nNonManifoldPoints <<
" non-manifold point(s)." 150 const labelList& meshPoints = pp.meshPoints();
152 const polyMesh& mesh = meshMover.mesh();
160 label f0 = baffles[i].first();
161 label f1 = baffles[i].second();
163 if (isMasterFace.get(f0))
166 isMasterFace.unset(f1);
168 else if (isMasterFace.get(f1))
170 isMasterFace.unset(f0);
175 <<
"Both sides of baffle consisting of faces " << f0
176 <<
" and " << f1 <<
" are already slave faces." 187 labelList nBoundary(pointFaces.size(), 0);
189 forAll(pointFaces, patchPointi)
191 const labelList& pFaces = pointFaces[patchPointi];
195 label facei = pFaces[pfi];
197 if (isMasterFace.get(pp.addressing()[facei]))
199 avgBoundary[patchPointi] +=
200 pp[facei].centre(points) - pp.localPoints()[patchPointi];
201 nBoundary[patchPointi]++;
225 avgBoundary[i] = avgBoundary[i]/nBoundary[i] + pp.localPoints()[i];
239 const faceList& faces = mesh.faces();
241 for (
label facei = 0; facei < mesh.nInternalFaces(); facei++)
243 const face& f = faces[facei];
244 const point& fc = mesh.faceCentres()[facei];
248 globalSum[f[fp]] += fc - mesh.points()[f[fp]];
254 const polyBoundaryMesh& patches = mesh.boundaryMesh();
260 patches[patchi].coupled()
261 && refCast<const coupledPolyPatch>(patches[patchi]).owner()
264 const coupledPolyPatch& pp =
265 refCast<const coupledPolyPatch>(patches[
patchi]);
271 const face& f = pp[i];
272 const point& fc = faceCentres[i];
276 globalSum[f[fp]] += fc - mesh.points()[f[fp]];
298 avgInternal.setSize(meshPoints.size());
299 nInternal.setSize(meshPoints.size());
301 forAll(avgInternal, patchPointi)
303 label meshPointi = meshPoints[patchPointi];
305 nInternal[patchPointi] = globalNum[meshPointi];
307 if (nInternal[patchPointi] == 0)
309 avgInternal[patchPointi] = globalSum[meshPointi];
313 avgInternal[patchPointi] =
314 globalSum[meshPointi]/nInternal[patchPointi]
315 + mesh.points()[meshPointi];
325 forAll(mesh.faceNeighbour(), facei)
327 label own = mesh.faceOwner()[facei];
328 const face& f = mesh.faces()[facei];
332 anyCell[f[fp]] = own;
335 for (
label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
337 label own = mesh.faceOwner()[facei];
339 const face& f = mesh.faces()[facei];
343 anyCell[f[fp]] = own;
353 label meshPointi = meshPoints[i];
354 const point& currentPos = pp.points()[meshPointi];
365 if (!nonManifoldPoint.get(i))
369 scalar internalBlend = 0.1;
374 internalBlend*nInternal[i]*avgInternal[i]
375 +(1-internalBlend)*nBoundary[i]*avgBoundary[i]
377 / (internalBlend*nInternal[i]+(1-internalBlend)*nBoundary[i]);
379 newPos = (1-blend)*avgPos + blend*currentPos;
381 else if (nInternal[i] == 0)
387 const point& cc = mesh.cellCentres()[anyCell[meshPointi]];
389 scalar cellCBlend = 0.8;
392 point avgPos = (1-cellCBlend)*avgBoundary[i] + cellCBlend*cc;
394 newPos = (1-blend)*avgPos + blend*currentPos;
399 scalar internalBlend = 0.9;
403 internalBlend*avgInternal[i]
404 + (1-internalBlend)*avgBoundary[i];
406 newPos = (1-blend)*avgPos + blend*currentPos;
409 patchDisp[i] = newPos - currentPos;
418 const pointMesh& pMesh,
422 const polyMesh& mesh = pMesh();
425 List<pointEdgePoint> wallInfo(pp.nPoints());
427 forAll(pp.localPoints(), ppi)
429 wallInfo[ppi] = pointEdgePoint(pp.localPoints()[ppi], 0.0);
433 List<pointEdgePoint> allPointInfo(mesh.nPoints());
436 List<pointEdgePoint> allEdgeInfo(mesh.nEdges());
438 PointEdgeWave<pointEdgePoint> wallCalc
446 mesh.globalData().nTotalPoints()
450 tmp<scalarField> tedgeDist(
new scalarField(mesh.nEdges()));
453 forAll(allEdgeInfo, edgei)
455 edgeDist[edgei] =
Foam::sqrt(allEdgeInfo[edgei].distSqr());
498 void Foam::snappySnapDriver::dumpMove
500 const fileName& fName,
506 Info<<
"Dumping move direction to " << fName <<
endl;
508 OFstream nearestStream(fName);
520 nearestStream<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
525 bool Foam::snappySnapDriver::outwardsDisplacement
534 forAll(pointFaces, pointi)
536 const labelList& pFaces = pointFaces[pointi];
538 vector disp(patchDisp[pointi]);
540 scalar magDisp =
mag(disp);
550 Warning<<
"Displacement " << patchDisp[pointi]
551 <<
" at mesh point " << pp.meshPoints()[pointi]
552 <<
" coord " << pp.points()[pp.meshPoints()[pointi]]
553 <<
" points through the surrounding patch faces" <<
endl;
575 meshRefiner_(meshRefiner),
576 globalToMasterPatch_(globalToMasterPatch),
577 globalToSlavePatch_(globalToSlavePatch)
595 if (zonedSurfaces.
size() && nBaffles > 0)
598 Info<<
"Converting " << nBaffles <<
" baffles back into zoned faces ..." 601 map = meshRefiner_.mergeBaffles(baffles);
603 Info<<
"Converted baffles in = " 604 << meshRefiner_.mesh().time().cpuTimeIncrement()
625 forAll(pointEdges, pointi)
627 const labelList& pEdges = pointEdges[pointi];
631 const edge&
e = edges[pEdges[pEdgei]];
633 scalar len = e.
mag(localPoints);
635 maxEdgeLen[pointi] =
max(maxEdgeLen[pointi], len);
656 const label nInitErrors,
665 Info<<
"Smoothing patch points ..." <<
endl;
668 label smoothIter = 0;
673 Info<<
"Smoothing iteration " << smoothIter <<
endl;
677 checkFaces[facei] = facei;
680 pointField patchDisp(smoothPatchDisplacement(meshMover, baffles));
691 scalar oldErrorReduction = -1;
693 for (
label snapIter = 0; snapIter < 2*snapParams.
nSnap(); snapIter++)
695 Info<<
nl <<
"Scaling iteration " << snapIter <<
endl;
697 if (snapIter == snapParams.
nSnap())
699 Info<<
"Displacement scaling for error reduction set to 0." 706 if (meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors))
708 Info<<
"Successfully moved mesh" <<
endl;
713 if (oldErrorReduction >= 0)
727 Info<<
"Writing patch smoothed mesh to time " 739 Info<<
"Dumped mesh in = " 743 Info<<
"Patch points smoothed in = " 760 <<
"Cannot find zone " << zoneName
778 label meshPointi = f[fp];
785 label pointi = iter();
786 pointOnZone[pointi] =
true;
810 forAll(pointFaces, pointi)
812 const labelList& pFaces = pointFaces[pointi];
816 label facei = pFaces[pfi];
817 label meshFacei = pp.addressing()[facei];
820 avgBoundary[pointi] +=
843 forAll(pointFaces, pointi)
845 avgBoundary[pointi] =
846 avgBoundary[pointi]/nBoundary[pointi] + pp.
localPoints()[pointi];
855 const scalar planarCos,
863 Info<<
"Detecting near surfaces ..." <<
endl;
868 const fvMesh& mesh = meshRefiner_.mesh();
1149 const pointField avgCc(avgCellCentres(mesh, pp));
1154 forAll(localPoints, pointi)
1156 const point& pt = localPoints[pointi];
1157 const vector d = 2*(avgCc[pointi]-pt);
1158 start[pointi] = pt - d;
1159 end[pointi] = pt + d;
1171 /
"detectNearSurfaces_" + meshRefiner_.timeName() +
".obj" 1186 label nOverride = 0;
1194 meshRefiner_.surfaces().surfZones()
1225 forAll(localPoints, pointi)
1228 const point& pt = localPoints[pointi];
1230 bool override =
false;
1269 if (hit1[pointi].hit() && hit2[pointi].hit())
1276 hit1[pointi].hitPoint(),
1278 hit2[pointi].hitPoint(),
1288 const point& intPt = hit2[pointi].hitPoint();
1293 disp[pointi] = hit2[pointi].hitPoint()-pt;
1298 if (
override && isPatchMasterPoint[pointi])
1320 label zoneSurfI = zonedSurfaces[i];
1322 const word& faceZoneName = surfZones[zoneSurfI].faceZoneName();
1324 const labelList surfacesToTest(1, zoneSurfI);
1329 getZoneSurfacePoints
1367 label pointi = zonePointIndices[i];
1370 const point& pt = localPoints[pointi];
1372 bool override =
false;
1411 if (hit1[i].hit() && hit2[i].hit())
1427 const point& intPt = hit2[i].hitPoint();
1431 disp[pointi] = hit2[i].hitPoint()-pt;
1436 if (
override && isPatchMasterPoint[pointi])
1444 Info<<
"Overriding nearest with intersection of close gaps at " 1447 <<
" points." <<
endl;
1460 Info<<
"Calculating patchDisplacement as distance to nearest surface" 1461 <<
" point ..." <<
endl;
1495 if (nearestNormal.
size() == localPoints.
size())
1512 if (hitinfo[pointi].hit())
1514 nearestPoint[pointi] = hitinfo[pointi].hitPoint();
1515 nearestNormal[pointi] = hitNormal[pointi];
1533 if (hitinfo[pointi].hit())
1536 hitinfo[pointi].hitPoint()
1537 - localPoints[pointi];
1539 snapSurf[pointi] = hitSurface[pointi];
1557 label zoneSurfI = zonedSurfaces[i];
1559 const word& faceZoneName = surfZones[zoneSurfI].faceZoneName();
1561 const labelList surfacesToTest(1, zoneSurfI);
1566 getZoneSurfacePoints
1578 if (nearestNormal.
size() == localPoints.
size())
1595 if (hitinfo[i].hit())
1597 label pointi = zonePointIndices[i];
1598 nearestPoint[pointi] = hitinfo[i].hitPoint();
1599 nearestNormal[pointi] = hitNormal[i];
1617 label pointi = zonePointIndices[i];
1619 if (hitinfo[i].hit())
1622 hitinfo[i].hitPoint()
1623 - localPoints[pointi];
1625 minSnapDist[pointi] =
min 1627 minSnapDist[pointi],
1628 mag(patchDisp[pointi])
1631 snapSurf[pointi] = zoneSurfI;
1639 if (snapSurf[pointi] == -1)
1642 <<
"For point:" << pointi
1643 <<
" coordinate:" << localPoints[pointi]
1644 <<
" did not find any surface within:" 1645 << minSnapDist[pointi]
1646 <<
" metre." <<
endl;
1662 Info<<
"Wanted displacement : average:" 1664 <<
" min:" <<
gMin(magDisp)
1665 <<
" max:" <<
gMax(magDisp) <<
endl;
1669 Info<<
"Calculated surface displacement in = " 1674 forAll(patchDisp, patchPointi)
1676 scalar magDisp =
mag(patchDisp[patchPointi]);
1678 if (magDisp > snapDist[patchPointi])
1680 patchDisp[patchPointi] *= snapDist[patchPointi] / magDisp;
1682 Pout<<
"Limiting displacement for " << patchPointi
1683 <<
" from " << magDisp <<
" to " << snapDist[patchPointi]
1696 vector(great, great, great)
1709 const fvMesh& mesh = meshRefiner_.mesh();
1712 Info<<
"Smoothing displacement ..." <<
endl;
1724 if ((iter % 10) == 0)
1726 Info<<
"Iteration " << iter <<
endl;
1729 meshMover.
smooth(oldDisp, edgeGamma, disp);
1731 Info<<
"Displacement smoothed in = " 1737 Info<<
"Writing smoothed mesh to time " << meshRefiner_.timeName()
1752 mesh.
time().
path()/meshRefiner_.timeName()
1754 Info<<
"Writing displacement field ..." <<
endl;
1759 Info<<
"Writing actual patch displacement ..." <<
endl;
1764 /
"actualPatchDisplacement_" + meshRefiner_.timeName() +
".obj",
1775 const label nInitErrors,
1780 const fvMesh& mesh = meshRefiner_.mesh();
1786 scalar oldErrorReduction = -1;
1788 bool meshOk =
false;
1791 for (
label iter = 0; iter < 2*snapParams.
nSnap(); iter++)
1795 if (iter == snapParams.
nSnap())
1797 Info<<
"Displacement scaling for error reduction set to 0." <<
endl;
1801 meshOk = meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors);
1805 Info<<
"Successfully moved mesh" <<
endl;
1811 Info<<
"Writing scaled mesh to time " << meshRefiner_.timeName()
1815 Info<<
"Writing displacement field ..." <<
endl;
1822 if (oldErrorReduction >= 0)
1826 Info<<
"Moved mesh in = " 1840 const fvMesh& mesh = meshRefiner_.mesh();
1843 Info<<
"Repatching faces according to nearest surface ..." <<
endl;
1867 forAll(preserveFaces, facei)
1869 if (preserveFaces[facei] != -1)
1871 isZonedFace.set(facei, 1);
1881 const label zoneSurfI = zonedSurfaces[i];
1882 const faceZone& fZone = fZones[surfZones[zoneSurfI].faceZoneName()];
1886 isZonedFace.set(fZone[i], 1);
1914 forAll(localFaces, facei)
1916 const face& f = localFaces[facei];
1920 faceSnapDist[facei] =
max 1922 faceSnapDist[facei],
1946 label facei = pp.addressing()[i];
1948 if (hitSurface[i] != -1 && !isZonedFace.get(facei))
1950 closestPatch[i] = globalToMasterPatch_
1985 label facei = pp.addressing()[i];
1987 if (closestPatch[i] != -1 && closestPatch[i] != ownPatch[facei])
1989 ownPatch[facei] = closestPatch[i];
1990 nbrPatch[facei] = closestPatch[i];
1999 return meshRefiner_.createBaffles(ownPatch, nbrPatch);
2003 void Foam::snappySnapDriver::detectWarpedFaces
2005 const scalar featureCos,
2012 const fvMesh& mesh = meshRefiner_.mesh();
2015 const labelList& bFaces = pp.addressing();
2028 forAll(localFaces, facei)
2030 const face& f = localFaces[facei];
2038 scalar minCos(great);
2040 for (
label startFp = 0; startFp < f.
size()-2; startFp++)
2047 endFp < f.
size() && endFp != minFp;
2054 for (
label fp = startFp; fp <= endFp; fp++)
2060 for (
label fp = endFp; fp != startFp; fp = f.
fcIndex(fp))
2064 f1[i1++] = f[startFp];
2070 const scalar n0Mag =
mag(n0);
2072 const scalar n1Mag =
mag(n1);
2074 if (n0Mag > rootVSmall && n1Mag > rootVSmall)
2076 scalar cosAngle = (n0/n0Mag) & (n1/n1Mag);
2077 if (cosAngle < minCos)
2087 if (minCos < featureCos)
2089 splitFaces.
append(bFaces[facei]);
2101 const scalar featureCos,
2102 const scalar planarAngle,
2106 fvMesh& mesh = meshRefiner_.mesh();
2109 <<
"Morphing phase" <<
nl 2110 <<
"--------------" <<
nl 2114 labelList adaptPatchIDs(meshRefiner_.meshedPatches());
2155 meshRefiner_.createZoneBaffles
2157 globalToMasterPatch_,
2158 globalToSlavePatch_,
2186 label nFilterFaces = 0;
2189 label nDuplicatePoints = 0;
2192 const word& faceZoneName = surfZones[surfi].faceZoneName();
2194 if (faceZoneName.size())
2197 surfZones[surfi].faceType();
2207 const faceZone& fZone = fZones[zonei];
2210 label facei = fZone[i];
2211 filterFace[facei] = zonei;
2219 label facei = fZone[i];
2222 duplicateFace[facei] = -1;
2227 if (!duplicatePoint[f[fp]])
2229 duplicatePoint[f[fp]] = 1;
2236 Info<<
"Surface : " << surfaces.
names()[surfi] <<
nl 2237 <<
" faces to become baffle : " 2239 <<
" points to duplicate : " 2264 nDuplicatePoints = 0;
2265 forAll(duplicatePoint, pointi)
2267 if (duplicatePoint[pointi])
2272 labelList candidatePoints(nDuplicatePoints);
2273 nDuplicatePoints = 0;
2274 forAll(duplicatePoint, pointi)
2276 if (duplicatePoint[pointi])
2278 candidatePoints[nDuplicatePoints++] = pointi;
2285 meshRefiner_.dupNonManifoldPoints(regionSide);
2301 const labelList& reverseFaceMap = mapPtr().reverseFaceMap();
2306 baffle.
first() = reverseFaceMap[baffle.
first()];
2313 Pout<<
"Writing duplicatedPoints mesh to time " 2314 << meshRefiner_.timeName()
2324 mesh.
time().
path()/
"duplicatedPoints" 2337 filterFace[baffle.
first()] == -1
2338 && filterFace[baffles[i].second()] == -1
2341 newBaffles.append(baffle);
2345 if (newBaffles.size() < baffles.size())
2357 bool doFeatures =
false;
2358 label nFeatIter = 1;
2364 Info<<
"Snapping to features in " << nFeatIter
2365 <<
" iterations ..." <<
endl;
2369 bool meshOk =
false;
2383 const scalarField snapDist(calcSnapDistance(mesh, snapParams, ppPtr()));
2387 Info<<
"Constructing mesh displacer ..." <<
endl;
2388 Info<<
"Using mesh parameters " << motionDict <<
nl <<
endl;
2408 Info<<
"Checking initial mesh ..." <<
endl;
2417 Info<<
"Detected " << nInitErrors <<
" illegal faces" 2418 <<
" (concave, zero area or negative cell pyramid volume)" 2422 Info<<
"Checked initial mesh in = " 2444 for (
label iter = 0; iter < nFeatIter; iter++)
2670 <<
"Morph iteration " << iter <<
nl 2671 <<
"-----------------" <<
endl;
2716 disp = calcNearestSurfaceFeature
2722 scalar(iter+1)/nFeatIter,
2732 outwardsDisplacement(pp, disp);
2745 /
"patchDisplacement_" +
name(iter) +
".obj",
2752 smoothDisplacement(snapParams, meshMover);
2766 <<
"Did not successfully snap mesh." 2767 <<
" Continuing to snap to resolve easy" <<
nl 2768 <<
" surfaces but the" 2769 <<
" resulting mesh will not satisfy your quality" 2770 <<
" constraints" <<
nl <<
endl;
2776 Info<<
"Writing scaled mesh to time " 2777 << meshRefiner_.timeName() <<
endl;
2786 mesh.
time().
path()/meshRefiner_.timeName()
2788 Info<<
"Writing displacement field ..." <<
endl;
2836 label nChanged = meshRefiner_.mergePatchFacesUndo
2840 meshRefiner_.meshedPatches(),
2845 nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict);
2850 Info<<
"Writing patchFace merged mesh to time " 2851 << meshRefiner_.timeName() <<
endl;
2860 meshRefiner_.timeName()
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces)
Check mesh with mesh settings in dict. Collects incorrect faces.
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh err...
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const labelListList & pointEdges() const
Return point-edge addressing.
Switch detectNearSurfacesSnap() const
List< labelList > labelListList
A List of labelList.
label nPoints() const
Return number of points supporting patch faces.
label findZoneID(const word &zoneName) const
Find zone index given a name.
const refinementSurfaces & surfaces() const
Reference to surface search engines.
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
label nSmoothDispl() const
Number of mesh displacement smoothing iterations.
virtual Ostream & write(const char)=0
Write character.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const labelList & surfaces() const
bool scaleMesh(const snapParameters &snapParams, const label nInitErrors, const List< labelPair > &baffles, motionSmoother &)
Do the hard work: move the mesh according to displacement,.
snappySnapDriver(meshRefinement &meshRefiner, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch)
Construct from components.
static const Vector< scalar > max
errorManipArg< error, int > exit(error &err, const int errNo=1)
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
A face is a list of labels corresponding to mesh vertices.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type gMin(const FieldField< Field, Type > &f)
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
T & ref() const
Return non-const reference or generate a fatal error.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Unit conversion functions.
bool scaleMesh(labelList &checkFaces, const bool smoothMesh=true, const label nAllow=0)
Move mesh with given scale. Return true if mesh ok or has.
void doSnap(const dictionary &snapDict, const dictionary &motionDict, const scalar featureCos, const scalar planarAngle, const snapParameters &snapParams)
void size(const label)
Override size to be inconsistent with allocated storage.
const pointMesh & pMesh() const
Reference to pointMesh.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
label nSmoothPatch() const
Number of patch smoothing iterations before finding.
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.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
autoPtr< polyTopoChangeMap > mergeZoneBaffles(const List< labelPair > &)
Merge baffles.
static writeType writeLevel()
Get/set write level.
Holds information (coordinate and normal) regarding nearest wall point.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
static vector area(const PointField &ps)
Return vector area given face points.
Vector< scalar > vector
A scalar version of the templated Vector.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
const Time & time() const
Return the top-level database.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
label nFeatureSnap() const
autoPtr< polyTopoChangeMap > repatchToSurface(const snapParameters &snapParams, const labelList &adaptPatchIDs, const labelList &preserveFaces)
Repatch faces according to surface nearest the face centre.
static labelList getZoneSurfacePoints(const fvMesh &mesh, const indirectPrimitivePatch &, const word &zoneName)
Get points both on patch and facezone.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
const fvMesh & mesh() const
Reference to mesh.
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
void correct()
Take over existing mesh position.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
static void updateList(const labelList &newToOld, const T &nullValue, List< T > &elems)
Helper: reorder list according to map.
A list of faces which address into the list of points.
Determines the 'side' for every face and connected to a singly-connected (through edges) region of fa...
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
vectorField pointField
pointField is a vectorField.
scalar setErrorReduction(const scalar)
Set the errorReduction (by how much to scale the displacement.
An ordered pair of two objects of type <T> with first() and second() elements.
dimensionedScalar cos(const dimensionedScalar &ds)
line< point, const point & > linePointRef
Line using referred points.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
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.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A class for handling words, derived from string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Simple container to keep together snap specific information.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
void transfer(const FixedList< T, Size > &)
Copy (not transfer) the argument contents.
void setCapacity(const label)
Alter the size of the underlying storage.
virtual const labelList & faceOwner() const
Return face owner.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
static void setDisplacement(const labelList &patchIDs, const indirectPrimitivePatch &pp, pointField &patchDisp, pointVectorField &displacement)
Set displacement field from displacement on patch points.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void smoothDisplacement(const snapParameters &snapParams, motionSmoother &) const
Smooth the displacement field to the internal.
Pair< label > labelPair
Label pair.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
List< label > labelList
A List of labels.
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.
scalar mag(const pointField &) const
Return scalar magnitude.
virtual const faceList & faces() const
Return raw faces.
const PtrList< surfaceZonesInfo > & surfZones() const
const vectorField & cellCentres() const
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
static labelList getUnnamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of unnamed surfaces (surfaces without faceZoneName)
errorManip< error > abort(error &err)
void smooth(const GeometricField< Type, pointPatchField, pointMesh > &fld, const scalarField &edgeWeight, GeometricField< Type, pointPatchField, pointMesh > &newFld) const
Fully explicit smoothing of fields (not positions)
word timeName() const
Replacement for Time::timeName() : return oldInstance (if.
static scalarField calcSnapDistance(const fvMesh &mesh, const snapParameters &snapParams, const indirectPrimitivePatch &)
Calculate edge length per patch point.
const labelListList & pointFaces() const
Return point-face addressing.
OFstream which keeps track of vertices.
Type gMax(const FieldField< Field, Type > &f)
label globalRegion(const label surfi, const label regioni) const
From surface and region on surface to global region.
defineTypeNameAndDebug(combustionModel, 0)
const indirectPrimitivePatch & patch() const
Reference to patch.
static pointMesh & New(polyMesh &mesh)
static tmp< pointField > avgCellCentres(const fvMesh &mesh, const indirectPrimitivePatch &)
Helper: calculate average cell centre per point.
static autoPtr< indirectPrimitivePatch > makePatch(const polyMesh &, const labelList &)
Create patch from set of patches.
word name(const complex &)
Return a string representation of a complex.
const Type & second() const
Return second.
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
const vectorField & faceCentres() const
label nSnap() const
Maximum number of snapping relaxation iterations. Should stop.
void setSize(const label)
Reset size of List.
const wordList & names() const
Names of surfaces.
scalar snapTol() const
Relative distance for points to be attracted by surface.
static T gAverage(const PackedBoolList &isMasterElem, const UList< T > &values)
Helper: calculate average.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
prefixOSstream Pout(cout, "Pout")
const meshFaceZones & faceZones() const
Return face zones.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
Mesh data needed to do the Finite Volume discretisation.
label start() const
Return start label of this patch in the polyMesh face list.
label mergePoints(const UList< Type > &points, const scalar mergeTol, const bool verbose, labelList &pointMap, const Type &origin=Type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
SubField< vector > subField
Declare type of subField.
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
faceZoneType
What to do with faceZone faces.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
const doubleScalar e
Elementary charge.
A subset of mesh faces organised as a primitive patch.
bool write() const
Write mesh and all data.
virtual bool write(const bool write=true) const
Write using setting from DB.
static tmp< pointVectorField > makeDisplacementField(const pointMesh &pMesh, const labelList &adaptPatchIDs)
Helper function to make a pointVectorField with correct.
A class for managing temporary objects.
A patch is a list of labels that address the faces in the global face list.
static PackedBoolList getMasterPoints(const polyMesh &mesh, const labelList &meshPoints)
Determine master point for subset of points. If coupled.
void clear()
Clear the addressed list, i.e. set the size to zero.
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.
fileName path() const
Return path.
const Type & first() const
Return first.
static const Vector< scalar > zero
A HashTable to objects of type <T> with a label key.
pointVectorField & displacement()
Reference to displacement field.
static vectorField calcNearestSurface(const meshRefinement &meshRefiner, const scalarField &snapDist, const indirectPrimitivePatch &, pointField &nearestPoint, vectorField &nearestNormal)
Per patch point calculate point on nearest surface. Set as.