56 Foam::label Foam::snappySnapDriver::getCollocatedPoints
60 PackedBoolList& isCollocatedPoint
71 bool hasMerged = (nUnique <
points.size());
79 label nCollocated = 0;
84 forAll(pointMap, oldPointi)
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)
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();
264 const coupledPolyPatch& pp =
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());
462 void Foam::snappySnapDriver::dumpMove
464 const fileName& fName,
470 Info<<
"Dumping move direction to " << fName <<
endl;
472 OFstream nearestStream(fName);
484 nearestStream<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
489 bool Foam::snappySnapDriver::outwardsDisplacement
498 forAll(pointFaces, pointi)
502 vector disp(patchDisp[pointi]);
504 scalar magDisp =
mag(disp);
514 Warning<<
"Displacement " << patchDisp[pointi]
515 <<
" at mesh point " << pp.meshPoints()[pointi]
516 <<
" coord " << pp.points()[pp.meshPoints()[pointi]]
517 <<
" points through the surrounding patch faces" <<
endl;
539 meshRefiner_(meshRefiner),
540 globalToMasterPatch_(globalToMasterPatch),
541 globalToSlavePatch_(globalToSlavePatch)
559 if (zonedSurfaces.
size() && nBaffles > 0)
562 Info<<
"Converting " << nBaffles <<
" baffles back into zoned faces ..."
565 map = meshRefiner_.mergeBaffles(baffles);
567 Info<<
"Converted baffles in = "
568 << meshRefiner_.mesh().time().cpuTimeIncrement()
589 forAll(pointEdges, pointi)
591 const labelList& pEdges = pointEdges[pointi];
595 const edge&
e = edges[pEdges[pEdgei]];
597 scalar len =
e.mag(localPoints);
599 maxEdgeLen[pointi] =
max(maxEdgeLen[pointi], len);
620 const label nInitErrors,
629 Info<<
"Smoothing patch points ..." <<
endl;
632 label smoothIter = 0;
637 Info<<
"Smoothing iteration " << smoothIter <<
endl;
641 checkFaces[facei] = facei;
644 pointField patchDisp(smoothPatchDisplacement(meshMover, baffles));
655 scalar oldErrorReduction = -1;
657 for (
label snapIter = 0; snapIter < 2*snapParams.
nSnap(); snapIter++)
659 Info<<
nl <<
"Scaling iteration " << snapIter <<
endl;
661 if (snapIter == snapParams.
nSnap())
663 Info<<
"Displacement scaling for error reduction set to 0."
670 if (meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors))
672 Info<<
"Successfully moved mesh" <<
endl;
677 if (oldErrorReduction >= 0)
691 Info<<
"Writing patch smoothed mesh to time "
692 << meshRefiner.
name() <<
'.' <<
endl;
703 Info<<
"Dumped mesh in = "
707 Info<<
"Patch points smoothed in = "
724 <<
"Cannot find zone " << zoneName
749 label pointi = iter();
750 pointOnZone[pointi] =
true;
774 forAll(pointFaces, pointi)
784 avgBoundary[pointi] +=
807 forAll(pointFaces, pointi)
809 avgBoundary[pointi] =
810 avgBoundary[pointi]/nBoundary[pointi] + pp.
localPoints()[pointi];
819 const scalar planarCos,
827 Info<<
"Detecting near surfaces ..." <<
endl;
1113 const pointField avgCc(avgCellCentres(mesh, pp));
1118 forAll(localPoints, pointi)
1120 const point& pt = localPoints[pointi];
1121 const vector d = 2*(avgCc[pointi]-pt);
1122 start[pointi] = pt - d;
1123 end[pointi] = pt + d;
1135 /
"detectNearSurfaces_" + meshRefiner_.
name() +
".obj"
1150 label nOverride = 0;
1158 meshRefiner_.surfaces().surfZones()
1189 forAll(localPoints, pointi)
1192 const point& pt = localPoints[pointi];
1194 bool override =
false;
1233 if (hit1[pointi].hit() && hit2[pointi].hit())
1240 hit1[pointi].hitPoint(),
1242 hit2[pointi].hitPoint(),
1252 const point& intPt = hit2[pointi].hitPoint();
1257 disp[pointi] = hit2[pointi].hitPoint()-pt;
1262 if (
override && isPatchMasterPoint[pointi])
1284 label zoneSurfI = zonedSurfaces[i];
1286 const word& faceZoneName = surfZones[zoneSurfI].faceZoneName();
1288 const labelList surfacesToTest(1, zoneSurfI);
1293 getZoneSurfacePoints
1331 label pointi = zonePointIndices[i];
1334 const point& pt = localPoints[pointi];
1336 bool override =
false;
1375 if (hit1[i].hit() && hit2[i].hit())
1391 const point& intPt = hit2[i].hitPoint();
1395 disp[pointi] = hit2[i].hitPoint()-pt;
1400 if (
override && isPatchMasterPoint[pointi])
1408 Info<<
"Overriding nearest with intersection of close gaps at "
1411 <<
" points." <<
endl;
1424 Info<<
"Calculating patchDisplacement as distance to nearest surface"
1425 <<
" point ..." <<
endl;
1459 if (nearestNormal.
size() == localPoints.
size())
1476 if (hitinfo[pointi].hit())
1478 nearestPoint[pointi] = hitinfo[pointi].hitPoint();
1479 nearestNormal[pointi] = hitNormal[pointi];
1497 if (hitinfo[pointi].hit())
1500 hitinfo[pointi].hitPoint()
1501 - localPoints[pointi];
1503 snapSurf[pointi] = hitSurface[pointi];
1521 label zoneSurfI = zonedSurfaces[i];
1523 const word& faceZoneName = surfZones[zoneSurfI].faceZoneName();
1525 const labelList surfacesToTest(1, zoneSurfI);
1530 getZoneSurfacePoints
1542 if (nearestNormal.
size() == localPoints.
size())
1559 if (hitinfo[i].hit())
1561 label pointi = zonePointIndices[i];
1562 nearestPoint[pointi] = hitinfo[i].hitPoint();
1563 nearestNormal[pointi] = hitNormal[i];
1581 label pointi = zonePointIndices[i];
1583 if (hitinfo[i].hit())
1586 hitinfo[i].hitPoint()
1587 - localPoints[pointi];
1589 minSnapDist[pointi] =
min
1591 minSnapDist[pointi],
1592 mag(patchDisp[pointi])
1595 snapSurf[pointi] = zoneSurfI;
1603 if (snapSurf[pointi] == -1)
1606 <<
"For point:" << pointi
1607 <<
" coordinate:" << localPoints[pointi]
1608 <<
" did not find any surface within:"
1609 << minSnapDist[pointi]
1610 <<
" metre." <<
endl;
1626 Info<<
"Wanted displacement : average:"
1628 <<
" min:" <<
gMin(magDisp)
1629 <<
" max:" <<
gMax(magDisp) <<
endl;
1633 Info<<
"Calculated surface displacement in = "
1638 forAll(patchDisp, patchPointi)
1640 scalar magDisp =
mag(patchDisp[patchPointi]);
1642 if (magDisp > snapDist[patchPointi])
1644 patchDisp[patchPointi] *= snapDist[patchPointi] / magDisp;
1646 Pout<<
"Limiting displacement for " << patchPointi
1647 <<
" from " << magDisp <<
" to " << snapDist[patchPointi]
1660 vector(great, great, great)
1676 Info<<
"Smoothing displacement ..." <<
endl;
1688 if ((iter % 10) == 0)
1690 Info<<
"Iteration " << iter <<
endl;
1693 meshMover.
smooth(oldDisp, edgeGamma, disp);
1695 Info<<
"Displacement smoothed in = "
1701 Info<<
"Writing smoothed mesh to time " << meshRefiner_.name()
1718 Info<<
"Writing displacement field ..." <<
endl;
1723 Info<<
"Writing actual patch displacement ..." <<
endl;
1728 /
"actualPatchDisplacement_" + meshRefiner_.
name() +
".obj",
1739 const label nInitErrors,
1750 scalar oldErrorReduction = -1;
1752 bool meshOk =
false;
1755 for (
label iter = 0; iter < 2*snapParams.
nSnap(); iter++)
1759 if (iter == snapParams.
nSnap())
1761 Info<<
"Displacement scaling for error reduction set to 0." <<
endl;
1765 meshOk = meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors);
1769 Info<<
"Successfully moved mesh" <<
endl;
1775 Info<<
"Writing scaled mesh to time " << meshRefiner_.name()
1779 Info<<
"Writing displacement field ..." <<
endl;
1786 if (oldErrorReduction >= 0)
1790 Info<<
"Moved mesh in = "
1807 Info<<
"Repatching faces according to nearest surface ..." <<
endl;
1831 forAll(preserveFaces, facei)
1833 if (preserveFaces[facei] != -1)
1835 isZonedFace.
set(facei, 1);
1845 const label zoneSurfI = zonedSurfaces[i];
1846 const faceZone& fZone = fZones[surfZones[zoneSurfI].faceZoneName()];
1850 isZonedFace.
set(fZone[i], 1);
1878 forAll(localFaces, facei)
1880 const face&
f = localFaces[facei];
1884 faceSnapDist[facei] =
max
1886 faceSnapDist[facei],
1912 if (hitSurface[i] != -1 && !isZonedFace.
get(facei))
1914 closestPatch[i] = globalToMasterPatch_
1951 if (closestPatch[i] != -1 && closestPatch[i] != ownPatch[facei])
1953 ownPatch[facei] = closestPatch[i];
1954 nbrPatch[facei] = closestPatch[i];
1963 return meshRefiner_.createBaffles(ownPatch, nbrPatch);
1967 void Foam::snappySnapDriver::detectWarpedFaces
1969 const scalar featureCos,
1992 forAll(localFaces, facei)
1994 const face&
f = localFaces[facei];
2002 scalar minCos(great);
2004 for (
label startFp = 0; startFp <
f.
size()-2; startFp++)
2011 endFp <
f.
size() && endFp != minFp;
2016 f0.setSize(endFp-startFp+1);
2018 for (
label fp = startFp; fp <= endFp; fp++)
2028 f1[i1++] =
f[startFp];
2033 const vector n0 = f0.area(localPoints);
2034 const scalar n0Mag =
mag(n0);
2035 const vector n1 = f1.area(localPoints);
2036 const scalar n1Mag =
mag(n1);
2038 if (n0Mag > rootVSmall && n1Mag > rootVSmall)
2040 scalar cosAngle = (n0/n0Mag) & (n1/n1Mag);
2041 if (cosAngle < minCos)
2051 if (minCos < featureCos)
2053 splitFaces.
append(bFaces[facei]);
2065 const scalar featureCos,
2066 const scalar planarAngle,
2073 <<
"Morphing phase" <<
nl
2074 <<
"--------------" <<
nl
2078 labelList adaptPatchIDs(meshRefiner_.meshedPatches());
2119 meshRefiner_.createZoneBaffles
2121 globalToMasterPatch_,
2122 globalToSlavePatch_,
2150 label nFilterFaces = 0;
2153 label nDuplicatePoints = 0;
2156 const word& faceZoneName = surfZones[surfi].faceZoneName();
2158 if (faceZoneName.size())
2161 surfZones[surfi].faceType();
2171 const faceZone& fZone = fZones[zonei];
2174 label facei = fZone[i];
2175 filterFace[facei] = zonei;
2183 label facei = fZone[i];
2186 duplicateFace[facei] = -1;
2191 if (!duplicatePoint[
f[fp]])
2193 duplicatePoint[
f[fp]] = 1;
2200 Info<<
"Surface : " << surfaces.
names()[surfi] <<
nl
2201 <<
" faces to become baffle : "
2203 <<
" points to duplicate : "
2228 nDuplicatePoints = 0;
2229 forAll(duplicatePoint, pointi)
2231 if (duplicatePoint[pointi])
2236 labelList candidatePoints(nDuplicatePoints);
2237 nDuplicatePoints = 0;
2238 forAll(duplicatePoint, pointi)
2240 if (duplicatePoint[pointi])
2242 candidatePoints[nDuplicatePoints++] = pointi;
2249 meshRefiner_.dupNonManifoldPoints(regionSide);
2265 const labelList& reverseFaceMap = mapPtr().reverseFaceMap();
2270 baffle.
first() = reverseFaceMap[baffle.
first()];
2277 Pout<<
"Writing duplicatedPoints mesh to time "
2278 << meshRefiner_.
name()
2288 mesh.
time().
path()/
"duplicatedPoints"
2301 filterFace[baffle.
first()] == -1
2302 && filterFace[baffles[i].second()] == -1
2305 newBaffles.
append(baffle);
2309 if (newBaffles.
size() < baffles.
size())
2321 bool doFeatures =
false;
2322 label nFeatIter = 1;
2328 Info<<
"Snapping to features in " << nFeatIter
2329 <<
" iterations ..." <<
endl;
2333 bool meshOk =
false;
2347 const scalarField snapDist(calcSnapDistance(mesh, snapParams, ppPtr()));
2351 Info<<
"Constructing mesh displacer ..." <<
endl;
2352 Info<<
"Using mesh parameters " << motionDict <<
nl <<
endl;
2372 Info<<
"Checking initial mesh ..." <<
endl;
2381 Info<<
"Detected " << nInitErrors <<
" illegal faces"
2382 <<
" (concave, zero area or negative cell pyramid volume)"
2386 Info<<
"Checked initial mesh in = "
2408 for (
label iter = 0; iter < nFeatIter; iter++)
2634 <<
"Morph iteration " << iter <<
nl
2635 <<
"-----------------" <<
endl;
2680 disp = calcNearestSurfaceFeature
2686 scalar(iter+1)/nFeatIter,
2696 outwardsDisplacement(pp, disp);
2709 /
"patchDisplacement_" +
name(iter) +
".obj",
2716 smoothDisplacement(snapParams, meshMover);
2730 <<
"Did not successfully snap mesh."
2731 <<
" Continuing to snap to resolve easy" <<
nl
2732 <<
" surfaces but the"
2733 <<
" resulting mesh will not satisfy your quality"
2734 <<
" constraints" <<
nl <<
endl;
2740 Info<<
"Writing scaled mesh to time "
2741 << meshRefiner_.name() <<
endl;
2752 Info<<
"Writing displacement field ..." <<
endl;
2800 label nChanged = meshRefiner_.mergePatchFacesUndo
2804 meshRefiner_.meshedPatches(),
2809 nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict);
2814 Info<<
"Writing patchFace merged mesh to time "
2815 << meshRefiner_.name() <<
endl;
#define forAll(list, i)
Loop across all elements in list.
static pointMesh & New(const word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
void setCapacity(const label)
Alter the size of the underlying storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
void clear()
Clear the addressed list, i.e. set the size to zero.
SubField< vector > subField
Declare type of subField.
label size() const
Return number of elements in table.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
A HashTable to objects of type <T> with a label key.
OFstream which keeps track of vertices.
virtual const fileName & name() const
Return the name of the stream.
virtual Ostream & write(const char)=0
Write character.
void set(const PackedList< 1 > &)
Set specified bits.
unsigned int get(const label) const
Get value at index I.
const Type & second() const
Return second.
const Type & first() const
Return first.
label nPoints() const
Return 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. Given the global point index find its.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
const labelListList & pointFaces() const
Return point-face addressing.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
label findIndex(const word &key) const
Return the index of the given the key or -1 if not found.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
fileName path() const
Explicitly inherit path from TimePaths to disambiguate from.
label size() const
Return the number of elements in the list.
const List< label > & addressing() const
Return the list addressing.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
A list of keyword definitions, which are a keyword followed by any number of values (e....
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.
word name() const
Return file name (part beyond last /)
Mesh data needed to do the Finite Volume discretisation.
const Time & time() const
Return the top-level database.
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
const polyMesh & mesh() const
Return reference to polyMesh.
Takes mesh with 'baffles' (= boundary faces sharing points). Determines for selected points on bounda...
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
const refinementSurfaces & surfaces() const
Reference to surface search engines.
word name() const
Replacement for Time::name() : return oldInstance (if.
const fvMesh & mesh() const
Reference to mesh.
static T gAverage(const PackedBoolList &isMasterElem, const UList< T > &values)
Helper: calculate average.
static tmp< pointVectorField > makeDisplacementField(const pointMesh &pMesh, const labelList &adaptPatchIDs)
Helper function to make a pointVectorField with correct.
static PackedBoolList getMasterPoints(const polyMesh &mesh, const labelList &meshPoints)
Determine master point for subset of points. If coupled.
static autoPtr< indirectPrimitivePatch > makePatch(const polyMesh &, const labelList &)
Create patch from set of patches.
static void updateList(const labelList &newToOld, const T &nullValue, List< T > &elems)
Helper: reorder list according to map.
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.
void smooth(const PointField< Type > &fld, const scalarField &edgeWeight, PointField< Type > &newFld) const
Fully explicit smoothing of fields (not positions)
bool scaleMesh(const labelList &checkFaces, const bool smoothMesh=true, const label nAllow=0)
Move mesh with given scale. Return true if mesh ok or has.
const indirectPrimitivePatch & patch() const
Reference to patch.
const pointMesh & pMesh() const
Reference to pointMesh.
pointVectorField & displacement()
Reference to displacement field.
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh err...
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
const faceZoneList & faceZones() const
Return face zones.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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 vectorField & cellCentres() const
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
const wordList & names() const
Names of surfaces.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
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.
const PtrList< surfaceZonesInfo > & surfZones() const
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 labelList & surfaces() const
label globalRegion(const label surfi, const label regioni) const
From surface and region on surface to global region.
virtual bool write(const bool write=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.
label nSmoothPatch() const
Number of patch smoothing iterations before finding.
label nFeatureSnap() const
Switch detectNearSurfacesSnap() const
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.
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.
autoPtr< polyTopoChangeMap > repatchToSurface(const snapParameters &snapParams, const labelList &adaptPatchIDs, const labelList &preserveFaces)
Repatch faces according to surface nearest the face centre.
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.
snappySnapDriver(meshRefinement &meshRefiner, const labelList &globalToMasterPatch, const labelList &globalToSlavePatch)
Construct from components.
static tmp< pointField > avgCellCentres(const fvMesh &mesh, const indirectPrimitivePatch &)
Helper: calculate average cell centre per point.
static labelList getZoneSurfacePoints(const fvMesh &mesh, const indirectPrimitivePatch &, const word &zoneName)
Get points both on patch and facezone.
void smoothDisplacement(const snapParameters &snapParams, motionSmoother &) const
Smooth the displacement field to the internal.
autoPtr< polyTopoChangeMap > mergeZoneBaffles(const List< labelPair > &)
Merge baffles.
void doSnap(const dictionary &snapDict, const dictionary &motionDict, const scalar featureCos, const scalar planarAngle, const snapParameters &snapParams)
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)
faceZoneType
What to do with faceZone faces.
static labelList getNamedSurfaces(const PtrList< surfaceZonesInfo > &surfList)
Get indices of named surfaces (surfaces with faceZoneName)
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
Functions for checking mesh topology and geometry.
#define WarningInFunction
Report a warning using Foam::Warning.
bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet &wrongFaces)
Check (subset of mesh including baffles) with mesh settings in dict.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Pair< label > labelPair
Label pair.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
line< point, const point & > linePointRef
Line using referred points.
word name(const bool)
Return a word representation of a bool.
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurrences of given element. Linear search.
errorManip< error > abort(error &err)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Vector< scalar > vector
A scalar version of the templated Vector.
dimensionedScalar sqrt(const dimensionedScalar &ds)
List< labelList > labelListList
A List of labelList.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
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.
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
prefixOSstream Pout(cout, "Pout")
Type gMin(const FieldField< Field, Type > &f)
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
Type gMax(const FieldField< Field, Type > &f)
dimensionedScalar cos(const dimensionedScalar &ds)
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("hex"));labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells]=cellShape(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< small) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &mergedCyclicPolyPatch::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]
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable