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());
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)
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 "
728 << meshRefiner.
name() <<
'.' <<
endl;
739 Info<<
"Dumped mesh in = "
743 Info<<
"Patch points smoothed in = "
760 <<
"Cannot find zone " << zoneName
785 label pointi = iter();
786 pointOnZone[pointi] =
true;
810 forAll(pointFaces, pointi)
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_.
name() +
".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_.name()
1754 Info<<
"Writing displacement field ..." <<
endl;
1759 Info<<
"Writing actual patch displacement ..." <<
endl;
1764 /
"actualPatchDisplacement_" + meshRefiner_.
name() +
".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_.name()
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],
1948 if (hitSurface[i] != -1 && !isZonedFace.
get(facei))
1950 closestPatch[i] = globalToMasterPatch_
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();
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;
2052 f0.setSize(endFp-startFp+1);
2054 for (
label fp = startFp; fp <= endFp; fp++)
2064 f1[i1++] =
f[startFp];
2069 const vector n0 = f0.area(localPoints);
2070 const scalar n0Mag =
mag(n0);
2071 const vector n1 = f1.area(localPoints);
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_.
name()
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_.name() <<
endl;
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_.name() <<
endl;
#define forAll(list, i)
Loop across all elements in list.
static pointMesh & New(const polyMesh &mesh)
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.
label findZoneID(const word &zoneName) const
Find zone index given a name.
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.
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.
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.
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces)
Check mesh with mesh settings in dict. Collects incorrect faces.
pointVectorField & displacement()
Reference to displacement field.
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh err...
const meshFaceZones & faceZones() const
Return face zones.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
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.
Determines the 'side' for every face and connected to a singly-connected (through edges) region of fa...
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
#define WarningInFunction
Report a warning using Foam::Warning.
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.
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.
word name(const complex &)
Return a string representation of a complex.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
Type gMax(const FieldField< Field, Type > &f)
dimensionedScalar cos(const dimensionedScalar &ds)
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
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
Unit conversion functions.