Go to the documentation of this file.
46 #include "PatchTools.H"
78 bool hasMerged = (nUnique <
points.size());
86 label nCollocated = 0;
91 forAll(pointMap, oldPointI)
93 label newPointI = pointMap[oldPointI];
95 if (firstOldPoint[newPointI] == -1)
98 firstOldPoint[newPointI] = oldPointI;
100 else if (firstOldPoint[newPointI] == -2)
103 isCollocatedPoint.
set(oldPointI, 1u);
109 isCollocatedPoint.
set(firstOldPoint[newPointI], 1u);
112 isCollocatedPoint.
set(oldPointI, 1u);
116 firstOldPoint[newPointI] = -2;
139 forAll(pp.addressing(), i)
141 isFront[pp.addressing()[i]] =
true;
188 label nInterface = 0;
190 for (
label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
192 label ownLevel = cellLevel[
mesh.faceOwner()[faceI]];
193 label neiLevel = cellLevel[
mesh.faceNeighbour()[faceI]];
195 if (!isFront[faceI] && ownLevel != neiLevel)
200 isMovingPoint[
f[fp]] =
true;
208 syncTools::swapBoundaryCellList(
mesh, cellLevel, neiCellLevel);
210 for (
label faceI =
mesh.nInternalFaces(); faceI <
mesh.nFaces(); faceI++)
212 label ownLevel = cellLevel[
mesh.faceOwner()[faceI]];
213 label neiLevel = neiCellLevel[faceI-
mesh.nInternalFaces()];
215 if (!isFront[faceI] && ownLevel != neiLevel)
220 isMovingPoint[
f[fp]] =
true;
230 Info<<
"Found " << nInterface <<
" faces out of "
231 <<
mesh.globalData().nTotalFaces()
232 <<
" inbetween refinement regions." <<
endl;
243 isMovingPoint[pp.
meshPoints()[pointI]] =
false;
255 forAll(isMovingPoint, pointI)
257 if (isMovingPoint[pointI])
263 sumLocation[pointI] +=
mesh.cellCentres()[pCells[i]];
271 syncTools::syncPointList
284 forAll(displacement, pointI)
286 if (nCells[pointI] > 0)
288 displacement[pointI] =
289 sumLocation[pointI]/nCells[pointI]-
mesh.points()[pointI];
295 Info<<
"Smoothing " << nAdapted <<
" points inbetween refinement regions."
298 return tdisplacement;
313 label nNonManifoldPoints = getCollocatedPoints
319 Info<<
"Found " << nNonManifoldPoints <<
" non-manifold point(s)."
347 label f0 = baffles[i].first();
348 label f1 = baffles[i].second();
350 if (isMasterFace.
get(f0))
355 else if (isMasterFace.
get(
f1))
357 isMasterFace.
unset(f0);
362 <<
"Both sides of baffle consisting of faces " << f0
363 <<
" and " <<
f1 <<
" are already slave faces."
376 forAll(pointFaces, patchPointI)
384 if (isMasterFace.
get(pp.addressing()[faceI]))
386 avgBoundary[patchPointI] += pp[faceI].centre(
points);
387 nBoundary[patchPointI]++;
392 syncTools::syncPointList
400 syncTools::syncPointList
411 avgBoundary[i] /= nBoundary[i];
427 for (
label faceI = 0; faceI <
mesh.nInternalFaces(); faceI++)
429 const face&
f = faces[faceI];
430 const point& fc =
mesh.faceCentres()[faceI];
434 globalSum[
f[fp]] += fc;
447 && refCast<const coupledPolyPatch>(
patches[patchI]).owner()
451 refCast<const coupledPolyPatch>(
patches[patchI]);
457 const face&
f = pp[i];
458 const point& fc = faceCentres[i];
462 globalSum[
f[fp]] += fc;
469 syncTools::syncPointList
476 syncTools::syncPointList
484 avgInternal.setSize(meshPoints.
size());
487 forAll(avgInternal, patchPointI)
489 label meshPointI = meshPoints[patchPointI];
491 nInternal[patchPointI] = globalNum[meshPointI];
493 if (nInternal[patchPointI] == 0)
495 avgInternal[patchPointI] = globalSum[meshPointI];
499 avgInternal[patchPointI] =
500 globalSum[meshPointI]
501 / nInternal[patchPointI];
518 anyCell[
f[fp]] = own;
529 label meshPointI = meshPoints[i];
541 if (!nonManifoldPoint.
get(i))
545 scalar internalBlend = 0.1;
550 internalBlend*nInternal[i]*avgInternal[i]
551 +(1-internalBlend)*nBoundary[i]*avgBoundary[i]
553 / (internalBlend*nInternal[i]+(1-internalBlend)*nBoundary[i]);
555 newPos = (1-blend)*avgPos + blend*currentPos;
557 else if (nInternal[i] == 0)
563 const point& cc =
mesh.cellCentres()[anyCell[meshPointI]];
565 scalar cellCBlend = 0.8;
568 point avgPos = (1-cellCBlend)*avgBoundary[i] + cellCBlend*cc;
570 newPos = (1-blend)*avgPos + blend*currentPos;
575 scalar internalBlend = 0.9;
579 internalBlend*avgInternal[i]
580 + (1-internalBlend)*avgBoundary[i];
582 newPos = (1-blend)*avgPos + blend*currentPos;
585 patchDisp[i] = newPos - currentPos;
683 mesh.globalData().nTotalPoints()
690 forAll(allEdgeInfo, edgeI)
692 edgeDist[edgeI] =
Foam::sqrt(allEdgeInfo[edgeI].distSqr());
707 Info<<
"Dumping move direction to " << fName <<
endl;
721 nearestStream<<
"l " << vertI-1 <<
' ' << vertI <<
nl;
737 forAll(pointFaces, pointI)
741 vector disp(patchDisp[pointI]);
743 scalar magDisp =
mag(disp);
753 Warning<<
"Displacement " << patchDisp[pointI]
754 <<
" at mesh point " << pp.
meshPoints()[pointI]
756 <<
" points through the surrounding patch faces" <<
endl;
778 meshRefiner_(meshRefiner),
779 globalToMasterPatch_(globalToMasterPatch),
780 globalToSlavePatch_(globalToSlavePatch)
797 scalarField maxEdgeLen(localPoints.size(), -GREAT);
799 forAll(pointEdges, pointI)
801 const labelList& pEdges = pointEdges[pointI];
805 const edge&
e = edges[pEdges[pEdgeI]];
807 scalar len =
e.mag(localPoints);
809 maxEdgeLen[pointI] =
max(maxEdgeLen[pointI], len);
813 syncTools::syncPointList
830 const label nInitErrors,
841 Info<<
"Smoothing patch and internal points ..." <<
endl;
845 Info<<
"Smoothing patch points ..." <<
endl;
850 label smoothIter = 0;
855 Info<<
"Smoothing iteration " << smoothIter <<
endl;
859 checkFaces[faceI] = faceI;
867 smoothInternalDisplacement(meshRefiner, meshMover);
871 pointField patchDisp(smoothPatchDisplacement(meshMover, baffles));
884 scalar oldErrorReduction = -1;
886 for (
label snapIter = 0; snapIter < 2*snapParams.
nSnap(); snapIter++)
888 Info<<
nl <<
"Scaling iteration " << snapIter <<
endl;
890 if (snapIter == snapParams.
nSnap())
892 Info<<
"Displacement scaling for error reduction set to 0."
899 if (meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors))
901 Info<<
"Successfully moved mesh" <<
endl;
906 if (oldErrorReduction >= 0)
920 Info<<
"Writing patch smoothed mesh to time "
927 meshRefinement::writeLevel()
928 | meshRefinement::WRITEMESH
932 Info<<
"Dumped mesh in = "
933 <<
mesh.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
936 Info<<
"Patch points smoothed in = "
937 <<
mesh.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
949 label zoneI =
mesh.faceZones().findZoneID(zoneName);
954 <<
"Cannot find zone " << zoneName
979 label pointI = iter();
980 pointOnZone[pointI] =
true;
1005 forAll(pointFaces, pointI)
1012 label meshFaceI = pp.addressing()[faceI];
1014 label own =
mesh.faceOwner()[meshFaceI];
1015 avgBoundary[pointI] +=
mesh.cellCentres()[own];
1016 nBoundary[pointI]++;
1020 syncTools::syncPointList
1028 syncTools::syncPointList
1039 avgBoundary[i] /= nBoundary[i];
1041 return tavgBoundary;
1095 const scalar planarCos,
1103 Info<<
"Detecting near surfaces ..." <<
endl;
1394 forAll(localPoints, pointI)
1396 const point& pt = localPoints[pointI];
1397 const vector d = 2*(avgCc[pointI]-pt);
1398 start[pointI] = pt - d;
1399 end[pointI] = pt + d;
1404 if (debug&meshRefinement::ATTRACTION)
1411 /
"detectNearSurfaces_" + meshRefiner_.timeName() +
".obj"
1419 meshRefinement::getMasterPoints
1426 label nOverride = 0;
1432 surfaceZonesInfo::getUnnamedSurfaces
1434 meshRefiner_.surfaces().surfZones()
1465 forAll(localPoints, pointI)
1468 const point& pt = localPoints[pointI];
1470 bool override =
false;
1509 if (hit1[pointI].hit() && hit2[pointI].hit())
1516 hit1[pointI].hitPoint(),
1518 hit2[pointI].hitPoint(),
1528 const point& intPt = hit2[pointI].hitPoint();
1533 disp[pointI] = hit2[pointI].hitPoint()-pt;
1538 if (
override && isPatchMasterPoint[pointI])
1553 const labelList zonedSurfaces = surfaceZonesInfo::getNamedSurfaces
1560 label zoneSurfI = zonedSurfaces[i];
1562 const word& faceZoneName = surfZones[zoneSurfI].faceZoneName();
1564 const labelList surfacesToTest(1, zoneSurfI);
1569 getZoneSurfacePoints
1607 label pointI = zonePointIndices[i];
1610 const point& pt = localPoints[pointI];
1612 bool override =
false;
1651 if (hit1[i].hit() && hit2[i].hit())
1667 const point& intPt = hit2[i].hitPoint();
1671 disp[pointI] = hit2[i].hitPoint()-pt;
1676 if (
override && isPatchMasterPoint[pointI])
1684 Info<<
"Overriding nearest with intersection of close gaps at "
1687 <<
" points." <<
endl;
1714 if (nearestNormal.size() == localPoints.size())
1734 if (hitInfo[i].hit())
1736 label pointI = zonePointIndices[i];
1737 nearestPoint[pointI] = hitInfo[i].hitPoint();
1738 nearestNormal[pointI] = hitNormal[i];
1759 if (hitInfo[i].hit())
1761 label pointI = zonePointIndices[i];
1763 patchDisp[pointI] = hitInfo[i].hitPoint() - localPoints[pointI];
1764 minSnapDist[pointI] =
mag(patchDisp[pointI]);
1765 snapSurf[pointI] = hitSurface[i];
1773 const bool strictRegionSnap,
1783 Info<<
"Calculating patchDisplacement as distance to nearest surface"
1784 <<
" point ..." <<
endl;
1785 if (strictRegionSnap)
1787 Info<<
" non-zone points : attract to local region on surface only"
1789 <<
" zone points : attract to local region on surface only"
1795 Info<<
" non-zone points :"
1796 <<
" attract to nearest of all non-zone surfaces"
1798 <<
" zone points : attract to zone surface only" <<
nl
1808 vectorField patchDisp(localPoints.size(), vector::zero);
1814 labelList snapSurf(localPoints.size(), -1);
1821 if (strictRegionSnap)
1830 const labelList surfacesToTest(1, surfI);
1832 for (
label regionI = 0; regionI < nRegions; regionI++)
1835 label masterPatchI = globalToMasterPatch[globalI];
1843 mesh.boundaryMesh()[masterPatchI]
1866 if (globalToSlavePatch[globalI] != masterPatchI)
1868 label slavePatchI = globalToSlavePatch[globalI];
1876 mesh.boundaryMesh()[slavePatchI]
1906 surfaceZonesInfo::getUnnamedSurfaces
1918 if (nearestNormal.size() == localPoints.size())
1935 if (hitInfo[pointI].hit())
1937 nearestPoint[pointI] = hitInfo[pointI].hitPoint();
1938 nearestNormal[pointI] = hitNormal[pointI];
1956 if (hitInfo[pointI].hit())
1959 hitInfo[pointI].hitPoint()
1960 - localPoints[pointI];
1962 snapSurf[pointI] = hitSurface[pointI];
1968 surfaceZonesInfo::getNamedSurfaces
1982 label surfI = zonedSurfaces[i];
1984 const word& faceZoneName = surfZones[surfI].faceZoneName();
1986 const labelList surfacesToTest(1, surfI);
1995 getZoneSurfacePoints
2029 if (snapSurf[pointI] == -1)
2032 <<
"For point:" << pointI
2033 <<
" coordinate:" << localPoints[pointI]
2034 <<
" did not find any surface within:"
2035 << minSnapDist[pointI]
2036 <<
" metre." <<
endl;
2043 meshRefinement::getMasterPoints
2052 Info<<
"Wanted displacement : average:"
2054 <<
" min:" <<
gMin(magDisp)
2055 <<
" max:" <<
gMax(magDisp) <<
endl;
2059 Info<<
"Calculated surface displacement in = "
2060 <<
mesh.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
2065 forAll(patchDisp, patchPointI)
2067 scalar magDisp =
mag(patchDisp[patchPointI]);
2069 if (magDisp > snapDist[patchPointI])
2071 patchDisp[patchPointI] *= snapDist[patchPointI] / magDisp;
2073 Pout<<
"Limiting displacement for " << patchPointI
2074 <<
" from " << magDisp <<
" to " << snapDist[patchPointI]
2081 syncTools::syncPointList
2087 vector(GREAT, GREAT, GREAT)
2103 Info<<
"Smoothing displacement ..." <<
endl;
2115 if ((iter % 10) == 0)
2117 Info<<
"Iteration " << iter <<
endl;
2120 meshMover.
smooth(oldDisp, edgeGamma, disp);
2122 Info<<
"Displacement smoothed in = "
2123 <<
mesh.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
2128 Info<<
"Writing smoothed mesh to time " << meshRefiner_.timeName()
2140 meshRefinement::writeLevel()
2141 | meshRefinement::WRITEMESH
2143 mesh.time().path()/meshRefiner_.timeName()
2145 Info<<
"Writing displacement field ..." <<
endl;
2150 Info<<
"Writing actual patch displacement ..." <<
endl;
2155 /
"actualPatchDisplacement_" + meshRefiner_.timeName() +
".obj",
2166 const label nInitErrors,
2177 scalar oldErrorReduction = -1;
2179 bool meshOk =
false;
2182 for (
label iter = 0; iter < 2*snapParams.
nSnap(); iter++)
2186 if (iter == snapParams.
nSnap())
2188 Info<<
"Displacement scaling for error reduction set to 0." <<
endl;
2192 meshOk = meshMover.
scaleMesh(checkFaces, baffles,
true, nInitErrors);
2196 Info<<
"Successfully moved mesh" <<
endl;
2202 Info<<
"Writing scaled mesh to time " << meshRefiner_.timeName()
2206 Info<<
"Writing displacement field ..." <<
endl;
2213 if (oldErrorReduction >= 0)
2217 Info<<
"Moved mesh in = "
2218 <<
mesh.time().cpuTimeIncrement() <<
" s\n" <<
nl <<
endl;
2239 Info<<
"Repatching faces according to nearest surface ..." <<
endl;
2244 meshRefinement::makePatch
2254 surfaceZonesInfo::getNamedSurfaces(surfaces.
surfZones());
2256 surfaceZonesInfo::getUnnamedSurfaces(surfaces.
surfZones());
2263 forAll(preserveFaces, faceI)
2265 if (preserveFaces[faceI] != -1)
2267 isZonedFace.
set(faceI, 1);
2277 const label zoneSurfI = zonedSurfaces[i];
2278 const faceZone& fZone = fZones[surfZones[zoneSurfI].faceZoneName()];
2282 isZonedFace.
set(fZone[i], 1);
2310 forAll(localFaces, faceI)
2312 const face&
f = localFaces[faceI];
2316 faceSnapDist[faceI] =
max
2318 faceSnapDist[faceI],
2325 pointField localFaceCentres(
mesh.faceCentres(), pp.addressing());
2342 label faceI = pp.addressing()[i];
2344 if (hitSurface[i] != -1 && !isZonedFace.
get(faceI))
2346 closestPatch[i] = globalToMasterPatch_
2373 ownPatch[pp.
start()+i] = patchI;
2374 neiPatch[pp.
start()+i] = patchI;
2381 label faceI = pp.addressing()[i];
2383 if (closestPatch[i] != -1 && closestPatch[i] != ownPatch[faceI])
2385 ownPatch[faceI] = closestPatch[i];
2386 neiPatch[faceI] = closestPatch[i];
2392 <<
" faces in = " <<
mesh.time().cpuTimeIncrement() <<
" s\n" <<
nl
2395 return meshRefiner_.createBaffles(ownPatch, neiPatch);
2401 const scalar featureCos,
2411 const labelList& bFaces = pp.addressing();
2424 forAll(localFaces, faceI)
2426 const face&
f = localFaces[faceI];
2434 scalar minCos(GREAT);
2436 for (
label startFp = 0; startFp <
f.size()-2; startFp++)
2438 label minFp =
f.rcIndex(startFp);
2442 label endFp =
f.fcIndex(
f.fcIndex(startFp));
2443 endFp <
f.size() && endFp != minFp;
2450 for (
label fp = startFp; fp <= endFp; fp++)
2454 f1.setSize(
f.size()+2-f0.
size());
2456 for (
label fp = endFp; fp != startFp; fp =
f.fcIndex(fp))
2460 f1[i1++] =
f[startFp];
2466 scalar n0Mag =
mag(n0);
2467 vector n1 =
f1.normal(localPoints);
2468 scalar n1Mag =
mag(n1);
2470 if (n0Mag > ROOTVSMALL && n1Mag > ROOTVSMALL)
2472 scalar cosAngle = (n0/n0Mag) & (n1/n1Mag);
2473 if (cosAngle < minCos)
2483 if (minCos < featureCos)
2485 splitFaces.
append(bFaces[faceI]);
2510 internalOrBaffleFaceZones,
2519 faceToDuplicate[
p[0]] =
p[1];
2520 faceToDuplicate[
p[1]] =
p[0];
2523 return faceToDuplicate;
2532 const scalar featureCos,
2533 const scalar planarAngle,
2540 <<
"Morphing phase" <<
nl
2541 <<
"--------------" <<
nl
2580 meshRefiner_.getZones
2596 meshRefiner_.createZoneBaffles
2605 meshRefiner_.dupNonManifoldBoundaryPoints();
2608 bool doFeatures =
false;
2609 label nFeatIter = 1;
2615 Info<<
"Snapping to features in " << nFeatIter
2616 <<
" iterations ..." <<
endl;
2620 bool meshOk =
false;
2624 labelList adaptPatchIDs(meshRefiner_.meshedPatches());
2644 Info<<
"Constructing mesh displacer ..." <<
endl;
2645 Info<<
"Using mesh parameters " << motionDict <<
nl <<
endl;
2665 Info<<
"Checking initial mesh ..." <<
endl;
2674 Info<<
"Detected " << nInitErrors <<
" illegal faces"
2675 <<
" (concave, zero area or negative cell pyramid volume)"
2679 Info<<
"Checked initial mesh in = "
2686 meshRefiner_.subsetBaffles
2721 for (
label iter = 0; iter < nFeatIter; iter++)
2724 <<
"Morph iteration " << iter <<
nl
2725 <<
"-----------------" <<
endl;
2728 bool doSplit =
false;
2734 (iter == nFeatIter-1)
2764 globalToMasterPatch_,
2765 globalToSlavePatch_,
2793 disp = calcNearestSurfaceFeature
2799 scalar(iter+1)/nFeatIter,
2815 outwardsDisplacement(pp, disp);
2828 /
"patchDisplacement_" +
name(iter) +
".obj",
2835 smoothDisplacement(snapParams, meshMover);
2849 <<
"Did not succesfully snap mesh."
2850 <<
" Continuing to snap to resolve easy" <<
nl
2851 <<
" surfaces but the"
2852 <<
" resulting mesh will not satisfy your quality"
2853 <<
" constraints" <<
nl <<
endl;
2859 Info<<
"Writing scaled mesh to time "
2860 << meshRefiner_.timeName() <<
endl;
2871 Info<<
"Writing displacement field ..." <<
endl;
2887 if (nTotalSplit && doSplit)
2892 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
2899 if (duplicateFace[oldSplitFaces[i]] == -1)
2901 splitFaces.
append(oldSplitFaces[i]);
2902 splits.
append(oldSplits[i]);
2913 meshRefiner_.splitFacesUndo
2924 meshMoverPtr.
clear();
2946 snapDist = calcSnapDistance(
mesh, snapParams, ppPtr());
2952 Info<<
"Writing split-faces mesh to time "
2953 << meshRefiner_.timeName() <<
endl;
2970 forAll(internalBaffles, i)
2976 if (
mag(fc0-fc1) > meshRefiner_.mergeDistance())
2979 <<
"Separated baffles : f0:" <<
p[0]
2980 <<
" centre:" << fc0
2981 <<
" f1:" <<
p[1] <<
" centre:" << fc1
2982 <<
" distance:" <<
mag(fc0-fc1)
3004 Info<<
"Writing baffle-merged mesh to time "
3005 << meshRefiner_.timeName() <<
endl;
3014 meshRefiner_.timeName()
3022 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3024 repatchToSurface(snapParams, adaptPatchIDs, duplicateFace);
3029 labelList duplicateFace(getInternalOrBaffleDuplicateFace());
3034 label nChanged = meshRefiner_.mergePatchFacesUndo
3038 meshRefiner_.meshedPatches(),
3043 nChanged += meshRefiner_.mergeEdgesUndo(featureCos, motionDict);
3048 Info<<
"Writing patchFace merged mesh to time "
3049 << meshRefiner_.timeName() <<
endl;
3058 meshRefiner_.timeName()
vector normal(const pointField &) const
Vector normal; magnitude is equal to area of face.
vectorField pointField
pointField is a vectorField.
static void preSmoothPatch(const meshRefinement &meshRefiner, const snapParameters &snapParams, const label nInitErrors, const List< labelPair > &baffles, motionSmoother &)
Smooth the mesh (patch and internal) to increase visibility.
static labelList getZoneSurfacePoints(const fvMesh &mesh, const indirectPrimitivePatch &, const word &zoneName)
Get points both on patch and facezone.
const labelListList & pointFaces() const
Return point-face addressing.
Xfer< List< T > > xfer()
Transfer contents to the Xfer container as a plain List.
scalar setErrorReduction(const scalar)
Set the errorReduction (by how much to scale the displacement.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void unset(const PackedList< 1 > &)
Unset specified bits.
const Field< PointType > & points() const
Return reference to global points.
A class for handling words, derived from string.
const labelIOList & cellLevel() const
A class for handling file names.
List< label > labelList
A List of labels.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
OFstream which keeps track of vertices.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
#define forAll(list, i)
Loop across all elements in list.
void writeOBJ(Ostream &os, label &vertI, const tetPoints &tet)
A class for managing temporary objects.
void findNearest(const labelList &surfacesToTest, const pointField &samples, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest point on surfaces.
Type gAverage(const FieldField< Field, Type > &f)
void correct()
Take over existing mesh position.
const labelList & surfaces() const
Wave propagation of information through grid. Every iteration information goes through one layer of e...
const Field< PointType > & localPoints() const
Return pointField of points in patch.
const indirectPrimitivePatch & patch() const
Reference to patch.
void set(const PackedList< 1 > &)
Set specified bits.
static writeType writeLevel()
Get/set write level.
meshRefinement & meshRefiner_
Mesh+surface.
labelList getZones(const List< surfaceZonesInfo::faceZoneType > &fzTypes) const
Get zones of given type.
bool scaleMesh(const snapParameters &snapParams, const label nInitErrors, const List< labelPair > &baffles, motionSmoother &)
Do the hard work: move the mesh according to displacement,.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
autoSnapDriver(const autoSnapDriver &)
Disallow default bitwise copy construct.
bool scaleMesh(labelList &checkFaces, const bool smoothMesh=true, const label nAllow=0)
Move mesh with given scale. Return true if mesh ok or has.
A HashTable to objects of type <T> with a label key.
Unit conversion functions.
Ostream & endl(Ostream &os)
Add newline and flush stream.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
labelList getInternalOrBaffleDuplicateFace() const
Get per face -1 or label of opposite face if on internal/baffle.
dimensioned< scalar > mag(const dimensioned< Type > &)
const fvMesh & mesh() const
Reference to mesh.
const searchableSurfaces & geometry() const
faceList mergePatchFaces(const List< DynList< label > > &pfcs, const pointField &polyPoints)
static void dumpMove(const fileName &, const pointField &, const pointField &)
Write displacement as .obj file.
Mesh consisting of general polyhedral cells.
static const pointMesh & New(const polyMesh &mesh)
static List< labelPair > subsetBaffles(const polyMesh &mesh, const labelList &zoneIDs, const List< labelPair > &baffles)
Subset baffles according to zones.
const faceZoneMesh & faceZones() const
Return face zone mesh.
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, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
Pre-declare related SubField type.
Simple container to keep together snap specific information.
const PtrList< surfaceZonesInfo > & surfZones() const
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
label nFeatureSnap() const
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
A subset of mesh faces organised as a primitive patch.
virtual Ostream & write(const token &)=0
Write next token to stream.
A patch is a list of labels that address the faces in the global face list.
const labelListList & pointEdges() const
Return point-edge addressing.
void clear()
Clear the addressed list, i.e. set the size to zero.
Switch strictRegionSnap() const
Attract point to corresponding surface region only.
void setCapacity(const label)
Alter the size of the underlying storage.
InternalField & internalField()
Return internal field.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh err...
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
label nPoints() const
Return number of points supporting patch faces.
label nSnap() const
Maximum number of snapping relaxation iterations. Should stop.
A list of keyword definitions, which are a keyword followed by any number of values (e....
label size() const
Return number of elements in table.
static autoPtr< indirectPrimitivePatch > makePatch(const polyMesh &, const labelList &)
Create patch from set of patches.
label globalRegion(const label surfI, const label regionI) const
From surface and region on surface to global region.
static bool outwardsDisplacement(const indirectPrimitivePatch &, const vectorField &)
Check displacement is outwards pointing.
Mesh data needed to do the Finite Volume discretisation.
Mesh representing a set of points created from polyMesh.
errorManip< error > abort(error &err)
unsigned int get(const label) const
Get value at index I.
void smoothDisplacement(const snapParameters &snapParams, motionSmoother &) const
Smooth the displacement field to the internal.
label start() const
Return start label of this patch in the polyMesh face list.
Holds information regarding nearest wall point. Used in PointEdgeWave. (so not standard FaceCellWave)...
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)
static tmp< pointField > avgCellCentres(const fvMesh &mesh, const indirectPrimitivePatch &)
Helper: calculate average cell centre per point.
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.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const hexRef8 & meshCutter() const
Reference to meshcutting engine.
void setSize(const label)
Reset size of List.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
List< labelList > labelListList
A List of labelList.
line< point, const point & > linePointRef
Line using referred points.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.
void detectWarpedFaces(const scalar featureCos, const indirectPrimitivePatch &pp, DynamicList< label > &splitFaces, DynamicList< labelPair > &splits) const
Detect warpage.
scalar snapTol() const
Relative distance for points to be attracted by surface.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
static tmp< pointField > smoothInternalDisplacement(const meshRefinement &meshRefiner, const motionSmoother &)
Calculate displacement (over all mesh points) to move points.
An ordered pair of two objects of type <T> with first() and second() elements.
fileName path() const
Return path.
label nFaceSplitInterval() const
label nSmoothInternal() const
Number of internal point smoothing iterations (combined with.
Refinement of (split) hexes using polyTopoChange.
prefixOSstream Pout(cout, "Pout")
const vectorField::subField faceCentres() const
Return face centres.
static tmp< pointField > smoothPatchDisplacement(const motionSmoother &, const List< labelPair > &)
Calculate displacement per patch point to smooth out patch.
const Field< PointType > & faceNormals() const
Return face normals for patch.
static bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces)
Check mesh with mesh settings in dict. Collects incorrect faces.
static void calcNearestSurface(const refinementSurfaces &surfaces, const labelList &surfacesToTest, const labelListList ®ionsToTest, const pointField &localPoints, const labelList &zonePointIndices, scalarField &minSnapDist, labelList &snapSurf, vectorField &patchDisp, pointField &nearestPoint, vectorField &nearestNormal)
Per patch point calculate point on nearest surface.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensionedScalar sqrt(const dimensionedScalar &ds)
volScalarField scalarField(fieldObject, mesh)
Switch detectNearSurfacesSnap() const
Override attraction to nearest with intersection location.
const polyMesh & mesh() const
Reference to mesh.
pointVectorField & pointDisplacement()
Return reference to the point motion displacement field.
const vectorField & faceCentres() const
Helper class which maintains intersections of (changing) mesh with (static) surfaces.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
static void setDisplacement(const labelList &patchIDs, const indirectPrimitivePatch &pp, pointField &patchDisp, pointVectorField &displacement)
Set displacement field from displacement on patch points.
const dimensionedScalar e
Elementary charge.
bool write() const
Write mesh and all data.
void smooth(const GeometricField< Type, pointPatchField, pointMesh > &fld, const scalarField &edgeWeight, GeometricField< Type, pointPatchField, pointMesh > &newFld) const
Fully explicit smoothing of fields (not positions)
label size() const
Return the number of elements in the PtrList.
static label getCollocatedPoints(const scalar tol, const pointField &, PackedBoolList &)
Calculates (geometric) shared points.
autoPtr< mapPolyMesh > repatchToSurface(const snapParameters &snapParams, const labelList &adaptPatchIDs, const labelList &preserveFaces)
Repatch faces according to surface nearest the face centre.
static tmp< scalarField > edgePatchDist(const pointMesh &, const indirectPrimitivePatch &)
Per edge distance to patch.
void clear()
Delete object (if the pointer is valid) and set pointer to NULL.
void reset(T *=0)
If object pointer already set, delete object and set to given.
const pointMesh & pMesh() const
Reference to pointMesh.
const Time & time() const
Return the top-level database.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
pointVectorField & displacement()
Reference to displacement field.
A face is a list of labels corresponding to mesh vertices.
void size(const label)
Override size to be inconsistent with allocated storage.
Type gMin(const FieldField< Field, Type > &f)
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
void doSnap(const dictionary &snapDict, const dictionary &motionDict, const bool mergePatchFaces, const scalar featureCos, const scalar planarAngle, const snapParameters &snapParams)
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Generic GeometricField class.
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.
Container for data on surfaces used for surface-driven refinement. Contains all the data about the le...
label nSmoothDispl() const
Number of mesh displacement smoothing iterations.
defineTypeNameAndDebug(combustionModel, 0)
labelList findIndices(const ListType &, typename ListType::const_reference, const label start=0)
Find all occurences of given element. Linear search.
static tmp< pointVectorField > makeDisplacementField(const pointMesh &pMesh, const labelList &adaptPatchIDs)
Helper function to make a pointVectorField with correct.
#define WarningInFunction
Report a warning using Foam::Warning.
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.
Pair< label > labelPair
Label pair.
Type gMax(const FieldField< Field, Type > &f)
word name(const complex &)
Return a string representation of a complex.
label nSmoothPatch() const
Number of patch smoothing iterations before finding.
static labelPairList findDuplicateFacePairs(const polyMesh &)
Helper routine to find all baffles (two boundary faces.
A list of faces which address into the list of points.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
dimensionedScalar cos(const dimensionedScalar &ds)
const refinementSurfaces & surfaces() const
Reference to surface search engines.