61 Foam::label Foam::autoSnapDriver::getCollocatedPoints
65 PackedBoolList& isCollocatedPoint
76 bool hasMerged = (nUnique < points.size());
84 label nCollocated = 0;
89 forAll(pointMap, oldPointI)
91 label newPointI = pointMap[oldPointI];
93 if (firstOldPoint[newPointI] == -1)
96 firstOldPoint[newPointI] = oldPointI;
98 else if (firstOldPoint[newPointI] == -2)
101 isCollocatedPoint.set(oldPointI, 1u);
107 isCollocatedPoint.set(firstOldPoint[newPointI], 1u);
110 isCollocatedPoint.set(oldPointI, 1u);
114 firstOldPoint[newPointI] = -2;
124 const motionSmoother& meshMover,
125 const List<labelPair>& baffles
131 PackedBoolList nonManifoldPoint(pp.nPoints());
132 label nNonManifoldPoints = getCollocatedPoints
138 Info<<
"Found " << nNonManifoldPoints <<
" non-manifold point(s)." 156 const labelList& meshPoints = pp.meshPoints();
158 const polyMesh& mesh = meshMover.mesh();
166 label f0 = baffles[i].first();
167 label f1 = baffles[i].second();
169 if (isMasterFace.get(f0))
172 isMasterFace.unset(f1);
174 else if (isMasterFace.get(f1))
176 isMasterFace.unset(f0);
180 FatalErrorIn(
"autoSnapDriver::smoothPatchDisplacement(..)")
181 <<
"Both sides of baffle consisting of faces " << f0
182 <<
" and " << f1 <<
" are already slave faces." 193 labelList nBoundary(pointFaces.size(), 0);
195 forAll(pointFaces, patchPointI)
197 const labelList& pFaces = pointFaces[patchPointI];
201 label faceI = pFaces[pfI];
203 if (isMasterFace.get(pp.addressing()[faceI]))
205 avgBoundary[patchPointI] += pp[faceI].centre(points);
206 nBoundary[patchPointI]++;
230 avgBoundary[i] /= nBoundary[i];
244 const faceList& faces = mesh.faces();
246 for (
label faceI = 0; faceI < mesh.nInternalFaces(); faceI++)
248 const face& f = faces[faceI];
249 const point& fc = mesh.faceCentres()[faceI];
253 globalSum[f[fp]] += fc;
259 const polyBoundaryMesh& patches = mesh.boundaryMesh();
265 patches[patchI].coupled()
266 && refCast<const coupledPolyPatch>(patches[patchI]).owner()
269 const coupledPolyPatch& pp =
270 refCast<const coupledPolyPatch>(patches[patchI]);
276 const face& f = pp[i];
277 const point& fc = faceCentres[i];
281 globalSum[f[fp]] += fc;
303 avgInternal.setSize(meshPoints.size());
304 nInternal.setSize(meshPoints.size());
306 forAll(avgInternal, patchPointI)
308 label meshPointI = meshPoints[patchPointI];
310 nInternal[patchPointI] = globalNum[meshPointI];
312 if (nInternal[patchPointI] == 0)
314 avgInternal[patchPointI] = globalSum[meshPointI];
318 avgInternal[patchPointI] =
319 globalSum[meshPointI]
320 / nInternal[patchPointI];
330 forAll(mesh.faceNeighbour(), faceI)
332 label own = mesh.faceOwner()[faceI];
333 const face& f = mesh.faces()[faceI];
337 anyCell[f[fp]] = own;
340 for (
label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
342 label own = mesh.faceOwner()[faceI];
344 const face& f = mesh.faces()[faceI];
348 anyCell[f[fp]] = own;
358 label meshPointI = meshPoints[i];
359 const point& currentPos = pp.points()[meshPointI];
370 if (!nonManifoldPoint.get(i))
374 scalar internalBlend = 0.1;
379 internalBlend*nInternal[i]*avgInternal[i]
380 +(1-internalBlend)*nBoundary[i]*avgBoundary[i]
382 / (internalBlend*nInternal[i]+(1-internalBlend)*nBoundary[i]);
384 newPos = (1-blend)*avgPos + blend*currentPos;
386 else if (nInternal[i] == 0)
392 const point& cc = mesh.cellCentres()[anyCell[meshPointI]];
394 scalar cellCBlend = 0.8;
397 point avgPos = (1-cellCBlend)*avgBoundary[i] + cellCBlend*cc;
399 newPos = (1-blend)*avgPos + blend*currentPos;
404 scalar internalBlend = 0.9;
408 internalBlend*avgInternal[i]
409 + (1-internalBlend)*avgBoundary[i];
411 newPos = (1-blend)*avgPos + blend*currentPos;
414 patchDisp[i] = newPos - currentPos;
484 const pointMesh& pMesh,
488 const polyMesh& mesh = pMesh();
491 List<pointEdgePoint> wallInfo(pp.nPoints());
493 forAll(pp.localPoints(), ppI)
495 wallInfo[ppI] = pointEdgePoint(pp.localPoints()[ppI], 0.0);
499 List<pointEdgePoint> allPointInfo(mesh.nPoints());
502 List<pointEdgePoint> allEdgeInfo(mesh.nEdges());
504 PointEdgeWave<pointEdgePoint> wallCalc
512 mesh.globalData().nTotalPoints()
516 tmp<scalarField> tedgeDist(
new scalarField(mesh.nEdges()));
519 forAll(allEdgeInfo, edgeI)
521 edgeDist[edgeI] =
Foam::sqrt(allEdgeInfo[edgeI].distSqr());
564 void Foam::autoSnapDriver::dumpMove
566 const fileName& fName,
572 Info<<
"Dumping move direction to " << fName <<
endl;
574 OFstream nearestStream(fName);
586 nearestStream<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
593 bool Foam::autoSnapDriver::outwardsDisplacement
602 forAll(pointFaces, pointI)
604 const labelList& pFaces = pointFaces[pointI];
606 vector disp(patchDisp[pointI]);
608 scalar magDisp =
mag(disp);
618 Warning<<
"Displacement " << patchDisp[pointI]
619 <<
" at mesh point " << pp.meshPoints()[pointI]
620 <<
" coord " << pp.points()[pp.meshPoints()[pointI]]
621 <<
" points through the surrounding patch faces" <<
endl;
636 Foam::autoSnapDriver::autoSnapDriver
643 meshRefiner_(meshRefiner),
644 globalToMasterPatch_(globalToMasterPatch),
645 globalToSlavePatch_(globalToSlavePatch)
663 if (zonedSurfaces.
size() && nBaffles > 0)
666 Info<<
"Converting " << nBaffles <<
" baffles back into zoned faces ..." 669 map = meshRefiner_.mergeBaffles(baffles);
671 Info<<
"Converted baffles in = " 672 << meshRefiner_.mesh().time().cpuTimeIncrement()
693 forAll(pointEdges, pointI)
695 const labelList& pEdges = pointEdges[pointI];
699 const edge&
e = edges[pEdges[pEdgeI]];
701 scalar len = e.
mag(localPoints);
703 maxEdgeLen[pointI] =
max(maxEdgeLen[pointI], len);
724 const label nInitErrors,
733 Info<<
"Smoothing patch points ..." <<
endl;
736 label smoothIter = 0;
741 Info<<
"Smoothing iteration " << smoothIter <<
endl;
745 checkFaces[faceI] = faceI;
748 pointField patchDisp(smoothPatchDisplacement(meshMover, baffles));
759 scalar oldErrorReduction = -1;
761 for (
label snapIter = 0; snapIter < 2*snapParams.
nSnap(); snapIter++)
763 Info<<
nl <<
"Scaling iteration " << snapIter <<
endl;
765 if (snapIter == snapParams.
nSnap())
767 Info<<
"Displacement scaling for error reduction set to 0." 774 if (meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors))
776 Info<<
"Successfully moved mesh" <<
endl;
781 if (oldErrorReduction >= 0)
795 Info<<
"Writing patch smoothed mesh to time " 807 Info<<
"Dumped mesh in = " 811 Info<<
"Patch points smoothed in = " 830 "autoSnapDriver::getZoneSurfacePoints" 831 "(const fvMesh&, const indirectPrimitivePatch&, const word&)" 832 ) <<
"Cannot find zone " << zoneName
850 label meshPointI = f[fp];
857 label pointI = iter();
858 pointOnZone[pointI] =
true;
883 forAll(pointFaces, pointI)
885 const labelList& pFaces = pointFaces[pointI];
889 label faceI = pFaces[pfI];
890 label meshFaceI = pp.addressing()[faceI];
917 avgBoundary[i] /= nBoundary[i];
973 const scalar planarCos,
981 Info<<
"Detecting near surfaces ..." <<
endl;
986 const fvMesh& mesh = meshRefiner_.mesh();
1267 const pointField avgCc(avgCellCentres(mesh, pp));
1272 forAll(localPoints, pointI)
1274 const point& pt = localPoints[pointI];
1275 const vector d = 2*(avgCc[pointI]-pt);
1276 start[pointI] = pt - d;
1277 end[pointI] = pt + d;
1289 /
"detectNearSurfaces_" + meshRefiner_.timeName() +
".obj" 1304 label nOverride = 0;
1312 meshRefiner_.surfaces().surfZones()
1343 forAll(localPoints, pointI)
1346 const point& pt = localPoints[pointI];
1348 bool override =
false;
1387 if (hit1[pointI].hit() && hit2[pointI].hit())
1394 hit1[pointI].hitPoint(),
1396 hit2[pointI].hitPoint(),
1406 const point& intPt = hit2[pointI].hitPoint();
1411 disp[pointI] = hit2[pointI].hitPoint()-pt;
1416 if (
override && isPatchMasterPoint[pointI])
1438 label zoneSurfI = zonedSurfaces[i];
1440 const word& faceZoneName = surfZones[zoneSurfI].faceZoneName();
1442 const labelList surfacesToTest(1, zoneSurfI);
1447 getZoneSurfacePoints
1485 label pointI = zonePointIndices[i];
1488 const point& pt = localPoints[pointI];
1490 bool override =
false;
1529 if (hit1[i].hit() && hit2[i].hit())
1545 const point& intPt = hit2[i].hitPoint();
1549 disp[pointI] = hit2[i].hitPoint()-pt;
1554 if (
override && isPatchMasterPoint[pointI])
1562 Info<<
"Overriding nearest with intersection of close gaps at " 1565 <<
" points." <<
endl;
1578 Info<<
"Calculating patchDisplacement as distance to nearest surface" 1579 <<
" point ..." <<
endl;
1613 if (nearestNormal.
size() == localPoints.
size())
1630 if (hitInfo[pointI].hit())
1632 nearestPoint[pointI] = hitInfo[pointI].hitPoint();
1633 nearestNormal[pointI] = hitNormal[pointI];
1651 if (hitInfo[pointI].hit())
1654 hitInfo[pointI].hitPoint()
1655 - localPoints[pointI];
1657 snapSurf[pointI] = hitSurface[pointI];
1675 label zoneSurfI = zonedSurfaces[i];
1677 const word& faceZoneName = surfZones[zoneSurfI].faceZoneName();
1679 const labelList surfacesToTest(1, zoneSurfI);
1684 getZoneSurfacePoints
1696 if (nearestNormal.
size() == localPoints.
size())
1713 if (hitInfo[i].hit())
1715 label pointI = zonePointIndices[i];
1716 nearestPoint[pointI] = hitInfo[i].hitPoint();
1717 nearestNormal[pointI] = hitNormal[i];
1735 label pointI = zonePointIndices[i];
1737 if (hitInfo[i].hit())
1740 hitInfo[i].hitPoint()
1741 - localPoints[pointI];
1743 minSnapDist[pointI] =
min 1745 minSnapDist[pointI],
1746 mag(patchDisp[pointI])
1749 snapSurf[pointI] = zoneSurfI;
1757 if (snapSurf[pointI] == -1)
1759 WarningIn(
"autoSnapDriver::calcNearestSurface(..)")
1760 <<
"For point:" << pointI
1761 <<
" coordinate:" << localPoints[pointI]
1762 <<
" did not find any surface within:" 1763 << minSnapDist[pointI]
1764 <<
" metre." <<
endl;
1780 Info<<
"Wanted displacement : average:" 1782 <<
" min:" <<
gMin(magDisp)
1783 <<
" max:" <<
gMax(magDisp) <<
endl;
1787 Info<<
"Calculated surface displacement in = " 1792 forAll(patchDisp, patchPointI)
1794 scalar magDisp =
mag(patchDisp[patchPointI]);
1796 if (magDisp > snapDist[patchPointI])
1798 patchDisp[patchPointI] *= snapDist[patchPointI] / magDisp;
1800 Pout<<
"Limiting displacement for " << patchPointI
1801 <<
" from " << magDisp <<
" to " << snapDist[patchPointI]
1814 vector(GREAT, GREAT, GREAT)
2075 const fvMesh& mesh = meshRefiner_.mesh();
2078 Info<<
"Smoothing displacement ..." <<
endl;
2090 if ((iter % 10) == 0)
2092 Info<<
"Iteration " << iter <<
endl;
2095 meshMover.
smooth(oldDisp, edgeGamma, disp);
2097 Info<<
"Displacement smoothed in = " 2103 Info<<
"Writing smoothed mesh to time " << meshRefiner_.timeName()
2118 mesh.
time().
path()/meshRefiner_.timeName()
2120 Info<<
"Writing displacement field ..." <<
endl;
2125 Info<<
"Writing actual patch displacement ..." <<
endl;
2130 /
"actualPatchDisplacement_" + meshRefiner_.timeName() +
".obj",
2141 const label nInitErrors,
2146 const fvMesh& mesh = meshRefiner_.mesh();
2152 scalar oldErrorReduction = -1;
2154 bool meshOk =
false;
2157 for (
label iter = 0; iter < 2*snapParams.
nSnap(); iter++)
2161 if (iter == snapParams.
nSnap())
2163 Info<<
"Displacement scaling for error reduction set to 0." <<
endl;
2167 meshOk = meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors);
2171 Info<<
"Successfully moved mesh" <<
endl;
2177 Info<<
"Writing scaled mesh to time " << meshRefiner_.timeName()
2181 Info<<
"Writing displacement field ..." <<
endl;
2188 if (oldErrorReduction >= 0)
2192 Info<<
"Moved mesh in = " 2211 const fvMesh& mesh = meshRefiner_.mesh();
2214 Info<<
"Repatching faces according to nearest surface ..." <<
endl;
2238 forAll(preserveFaces, faceI)
2240 if (preserveFaces[faceI] != -1)
2242 isZonedFace.set(faceI, 1);
2252 const label zoneSurfI = zonedSurfaces[i];
2253 const faceZone& fZone = fZones[surfZones[zoneSurfI].faceZoneName()];
2257 isZonedFace.set(fZone[i], 1);
2285 forAll(localFaces, faceI)
2287 const face& f = localFaces[faceI];
2291 faceSnapDist[faceI] =
max 2293 faceSnapDist[faceI],
2317 label faceI = pp.addressing()[i];
2319 if (hitSurface[i] != -1 && !isZonedFace.get(faceI))
2321 closestPatch[i] = globalToMasterPatch_
2348 ownPatch[pp.
start()+i] = patchI;
2349 neiPatch[pp.
start()+i] = patchI;
2356 label faceI = pp.addressing()[i];
2358 if (closestPatch[i] != -1 && closestPatch[i] != ownPatch[faceI])
2360 ownPatch[faceI] = closestPatch[i];
2361 neiPatch[faceI] = closestPatch[i];
2370 return meshRefiner_.createBaffles(ownPatch, neiPatch);
2374 void Foam::autoSnapDriver::detectWarpedFaces
2376 const scalar featureCos,
2383 const fvMesh& mesh = meshRefiner_.mesh();
2386 const labelList& bFaces = pp.addressing();
2399 forAll(localFaces, faceI)
2401 const face& f = localFaces[faceI];
2409 scalar minCos(GREAT);
2411 for (
label startFp = 0; startFp < f.
size()-2; startFp++)
2418 endFp < f.
size() && endFp != minFp;
2425 for (
label fp = startFp; fp <= endFp; fp++)
2431 for (
label fp = endFp; fp != startFp; fp = f.
fcIndex(fp))
2435 f1[i1++] = f[startFp];
2441 scalar n0Mag =
mag(n0);
2443 scalar n1Mag =
mag(n1);
2445 if (n0Mag > ROOTVSMALL && n1Mag > ROOTVSMALL)
2447 scalar cosAngle = (n0/n0Mag) & (n1/n1Mag);
2448 if (cosAngle < minCos)
2458 if (minCos < featureCos)
2460 splitFaces.
append(bFaces[faceI]);
2472 const scalar featureCos,
2473 const scalar planarAngle,
2477 fvMesh& mesh = meshRefiner_.mesh();
2480 <<
"Morphing phase" <<
nl 2481 <<
"--------------" <<
nl 2485 labelList adaptPatchIDs(meshRefiner_.meshedPatches());
2526 meshRefiner_.createZoneBaffles
2528 globalToMasterPatch_,
2529 globalToSlavePatch_,
2557 label nFilterFaces = 0;
2560 label nDuplicatePoints = 0;
2563 const word& faceZoneName = surfZones[surfI].faceZoneName();
2565 if (faceZoneName.size())
2568 surfZones[surfI].faceType();
2578 const faceZone& fZone = fZones[zoneI];
2581 label faceI = fZone[i];
2582 filterFace[faceI] = zoneI;
2590 label faceI = fZone[i];
2593 duplicateFace[faceI] = -1;
2598 if (!duplicatePoint[f[fp]])
2600 duplicatePoint[f[fp]] = 1;
2607 Info<<
"Surface : " << surfaces.
names()[surfI] <<
nl 2608 <<
" faces to become baffle : " 2610 <<
" points to duplicate : " 2635 nDuplicatePoints = 0;
2636 forAll(duplicatePoint, pointI)
2638 if (duplicatePoint[pointI])
2643 labelList candidatePoints(nDuplicatePoints);
2644 nDuplicatePoints = 0;
2645 forAll(duplicatePoint, pointI)
2647 if (duplicatePoint[pointI])
2649 candidatePoints[nDuplicatePoints++] = pointI;
2674 const labelList& reverseFaceMap = mapPtr().reverseFaceMap();
2679 baffle.
first() = reverseFaceMap[baffle.
first()];
2686 Pout<<
"Writing duplicatedPoints mesh to time " 2687 << meshRefiner_.timeName()
2697 mesh.
time().
path()/
"duplicatedPoints" 2710 filterFace[baffle.
first()] == -1
2711 && filterFace[baffles[i].second()] == -1
2714 newBaffles.append(baffle);
2718 if (newBaffles.size() < baffles.size())
2730 bool doFeatures =
false;
2731 label nFeatIter = 1;
2737 Info<<
"Snapping to features in " << nFeatIter
2738 <<
" iterations ..." <<
endl;
2742 bool meshOk =
false;
2756 const scalarField snapDist(calcSnapDistance(mesh, snapParams, ppPtr()));
2760 Info<<
"Constructing mesh displacer ..." <<
endl;
2761 Info<<
"Using mesh parameters " << motionDict <<
nl <<
endl;
2781 Info<<
"Checking initial mesh ..." <<
endl;
2790 Info<<
"Detected " << nInitErrors <<
" illegal faces" 2791 <<
" (concave, zero area or negative cell pyramid volume)" 2795 Info<<
"Checked initial mesh in = " 2817 for (
label iter = 0; iter < nFeatIter; iter++)
3043 <<
"Morph iteration " << iter <<
nl 3044 <<
"-----------------" <<
endl;
3089 disp = calcNearestSurfaceFeature
3095 scalar(iter+1)/nFeatIter,
3105 outwardsDisplacement(pp, disp);
3118 /
"patchDisplacement_" +
name(iter) +
".obj",
3125 smoothDisplacement(snapParams, meshMover);
3139 <<
"Did not succesfully snap mesh." 3140 <<
" Continuing to snap to resolve easy" <<
nl 3141 <<
" surfaces but the" 3142 <<
" resulting mesh will not satisfy your quality" 3143 <<
" constraints" <<
nl <<
endl;
3149 Info<<
"Writing scaled mesh to time " 3150 << meshRefiner_.timeName() <<
endl;
3159 mesh.
time().
path()/meshRefiner_.timeName()
3161 Info<<
"Writing displacement field ..." <<
endl;
3182 forAll(duplicateFace, faceI)
3184 if (duplicateFace[faceI] != -1)
3186 duplicateFace[faceI] = mapPtr().reverseFaceMap()[faceI];
3211 label nChanged = meshRefiner_.mergePatchFacesUndo
3215 meshRefiner_.meshedPatches(),
3220 nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict);
3225 Info<<
"Writing patchFace merged mesh to time " 3226 << meshRefiner_.timeName() <<
endl;
3235 meshRefiner_.timeName()
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
dimensionedScalar sqrt(const dimensionedScalar &ds)
virtual bool write() const
Write mesh using IO settings from time.
autoPtr< mapPolyMesh > mergeZoneBaffles(const List< labelPair > &)
Merge baffles.
static void updateList(const labelList &newToOld, const T &nullValue, List< T > &elems)
Helper: reorder list according to map.
OFstream which keeps track of vertices.
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 faceZoneMesh & faceZones() const
Return face zone mesh.
static PackedBoolList getMasterFaces(const polyMesh &)
Get per face whether it is uncoupled or a master of a.
bool write() const
Write mesh and all data.
void setCapacity(const label)
Alter the size of the underlying storage.
Mesh data needed to do the Finite Volume discretisation.
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
vector point
Point is a vector.
An ordered pair of two objects of type <T> with first() and second() elements.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
fileName path() const
Return path.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
dimensioned< scalar > mag(const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
faceZoneType
What to do with faceZone faces.
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces)
Check mesh with mesh settings in dict. Collects incorrect faces.
void reset(T *=0)
If object pointer already set, delete object and set to given.
static const pointMesh & New(const polyMesh &mesh)
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
static T gAverage(const PackedBoolList &isMasterElem, const UList< T > &values)
Helper: calculate average.
A HashTable to objects of type <T> with a label key.
const labelListList & pointFaces() const
Return point-face addressing.
A subset of mesh faces organised as a primitive patch.
const pointMesh & pMesh() const
Reference to pointMesh.
const Type & second() const
Return second.
static labelList getUnnamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of unnamed surfaces (surfaces without faceZoneName)
pointVectorField & displacement()
Reference to displacement field.
void clear()
Clear the addressed list, i.e. set the size to zero.
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
scalar snapTol() const
Relative distance for points to be attracted by surface.
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
static autoPtr< indirectPrimitivePatch > makePatch(const polyMesh &, const labelList &)
Create patch from set of patches.
PrimitivePatch< face, IndirectList, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
const vectorField & cellCentres() const
A list of keyword definitions, which are a keyword followed by any number of values (e...
Simple container to keep together snap specific information.
bool scaleMesh(labelList &checkFaces, const bool smoothMesh=true, const label nAllow=0)
Move mesh with given scale. Return true if mesh ok or has.
static void syncFaceList(const polyMesh &mesh, UList< T > &l, const CombineOp &cop)
Synchronize values on all mesh faces.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label nPoints() const
Return number of points supporting patch faces.
vectorField pointField
pointField is a vectorField.
A patch is a list of labels that address the faces in the global face list.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const wordList & names() const
Names of surfaces.
const Time & time() const
Return the top-level database.
static labelList getZoneSurfacePoints(const fvMesh &mesh, const indirectPrimitivePatch &, const word &zoneName)
Get points both on patch and facezone.
scalar mag(const pointField &) const
Return scalar magnitude.
virtual bool write() const
Write using setting from DB.
A face is a list of labels corresponding to mesh vertices.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
const double e
Elementary charge.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
label nSmoothPatch() const
Number of patch smoothing iterations before finding.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
static tmp< pointVectorField > makeDisplacementField(const pointMesh &pMesh, const labelList &adaptPatchIDs)
Helper function to make a pointVectorField with correct.
void doSnap(const dictionary &snapDict, const dictionary &motionDict, const scalar featureCos, const scalar planarAngle, const snapParameters &snapParams)
label nFeatureSnap() const
void smoothDisplacement(const snapParameters &snapParams, motionSmoother &) const
Smooth the displacement field to the internal.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
static scalarField calcSnapDistance(const fvMesh &mesh, const snapParameters &snapParams, const indirectPrimitivePatch &)
Calculate edge length per patch point.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
virtual Ostream & write(const token &)=0
Write next token to stream.
dimensionedScalar cos(const dimensionedScalar &ds)
static PackedBoolList getMasterPoints(const polyMesh &mesh, const labelList &meshPoints)
Determine master point for subset of points. If coupled.
Unit conversion functions.
void correct()
Take over existing mesh position.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
errorManip< error > abort(error &err)
virtual const labelList & faceOwner() const
Return face owner.
Type gMin(const FieldField< Field, Type > &f)
label nSnap() const
Maximum number of snapping relaxation iterations. Should stop.
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
static void syncPointList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const indirectPrimitivePatch & patch() const
Reference to patch.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A list of faces which address into the list of points.
static tmp< pointField > pointNormals(const polyMesh &, const PrimitivePatch< Face, FaceList, PointField, PointType > &)
Return parallel consistent point normals for patches using mesh points.
static writeType writeLevel()
Get/set write level.
label start() const
Return start label of this patch in the polyMesh face list.
Determines the 'side' for every face and connected to a singly-connected (through edges) region of fa...
label nSmoothDispl() const
Number of mesh displacement smoothing iterations.
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.
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.
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.
vector normal(const pointField &) const
Vector normal; magnitude is equal to area of face.
const labelListList & pointEdges() const
Return point-edge addressing.
const PtrList< surfaceZonesInfo > & surfZones() const
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh err...
SubField< vector > subField
Declare type of subField.
List< label > labelList
A List of labels.
const refinementSurfaces & surfaces() const
Reference to surface search engines.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
Pair< label > labelPair
Label pair.
const Type & first() const
Return first.
static tmp< pointField > avgCellCentres(const fvMesh &mesh, const indirectPrimitivePatch &)
Helper: calculate average cell centre per point.
label findZoneID(const word &zoneName) const
Find zone index given a name.
Vector< scalar > vector
A scalar version of the templated Vector.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
Switch detectNearSurfacesSnap() const
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
word timeName() const
Replacement for Time::timeName() : return oldInstance (if.
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
line< point, const point & > linePointRef
Line using referred points.
virtual const faceList & faces() const
Return raw faces.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
const labelList & surfaces() const
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
List< labelList > labelListList
A List of labelList.
void smooth(const GeometricField< Type, pointPatchField, pointMesh > &fld, const scalarField &edgeWeight, GeometricField< Type, pointPatchField, pointMesh > &newFld) const
Fully explicit smoothing of fields (not positions)
void writeOBJ(Ostream &os, const point &pt)
Write obj representation of point.
scalar setErrorReduction(const scalar)
Set the errorReduction (by how much to scale the displacement.
void transfer(const FixedList< T, Size > &)
Copy (not transfer) the argument contents.
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.
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
Type gMax(const FieldField< Field, Type > &f)
const fvMesh & mesh() const
Reference to mesh.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurences of given element. Linear search.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A class for managing temporary objects.
static void setDisplacement(const labelList &patchIDs, const indirectPrimitivePatch &pp, pointField &patchDisp, pointVectorField &displacement)
Set displacement field from displacement on patch points.
bool scaleMesh(const snapParameters &snapParams, const label nInitErrors, const List< labelPair > &baffles, motionSmoother &)
Do the hard work: move the mesh according to displacement,.
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.
autoPtr< mapPolyMesh > repatchToSurface(const snapParameters &snapParams, const labelList &adaptPatchIDs, const labelList &preserveFaces)
Repatch faces according to surface nearest the face centre.
defineTypeNameAndDebug(combustionModel, 0)
bool visNormal(const vector &n, const vectorField &faceNormals, const labelList &faceLabels)
Check if n is in same direction as normals of all faceLabels.
prefixOSstream Pout(cout,"Pout")
const vectorField & faceCentres() const