mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Adding a simple surface smoothing function. Needs functionality added to properly collapse small boundary normal faces.
Also adding a function to determine if a Delaunay edge corresponds to a boundary dual face.
This commit is contained in:
@ -2079,6 +2079,25 @@ void Foam::conformalVoronoiMesh::calcDualMesh
|
||||
|
||||
} while (nPtsMerged > 0);
|
||||
|
||||
// Smooth the surface of the mesh
|
||||
|
||||
Info<< nl << " Smoothing surface" << endl;
|
||||
|
||||
label nSmoothedVertices = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Map<label> dualPtIndexMap;
|
||||
|
||||
nSmoothedVertices = smoothSurfaceDualFaces(points, dualPtIndexMap);
|
||||
|
||||
Info<< " Smoothed " << nPtsMerged << " points (0 HARD CODED)"
|
||||
<< endl;
|
||||
|
||||
reindexDualVertices(dualPtIndexMap);
|
||||
|
||||
} while (nSmoothedVertices > 0);
|
||||
|
||||
// Assess faces for collapse
|
||||
|
||||
Info<< nl << " Collapsing unnecessary faces" << endl;
|
||||
@ -2415,6 +2434,79 @@ Foam::label Foam::conformalVoronoiMesh::mergeCloseDualVertices
|
||||
return nPtsMerged;
|
||||
}
|
||||
|
||||
Foam::label Foam::conformalVoronoiMesh::smoothSurfaceDualFaces
|
||||
(
|
||||
pointField& pts,
|
||||
Map<label>& dualPtIndexMap
|
||||
)
|
||||
{
|
||||
label nSmoothedVertices = 0;
|
||||
|
||||
for
|
||||
(
|
||||
Triangulation::Finite_edges_iterator eit = finite_edges_begin();
|
||||
eit != finite_edges_end();
|
||||
++eit
|
||||
)
|
||||
{
|
||||
Cell_circulator ccStart = incident_cells(*eit);
|
||||
Cell_circulator cc = ccStart;
|
||||
|
||||
do
|
||||
{
|
||||
if (dualPtIndexMap.found(cc->cellIndex()))
|
||||
{
|
||||
// One of the points of this face has already been
|
||||
// collapsed this sweep, leave for next sweep
|
||||
continue;
|
||||
}
|
||||
|
||||
} while (++cc != ccStart);
|
||||
|
||||
// Cell_handle c = eit->first;
|
||||
// Vertex_handle vA = c->vertex(eit->second);
|
||||
// Vertex_handle vB = c->vertex(eit->third);
|
||||
|
||||
if (isBoundaryDualFace(eit))
|
||||
{
|
||||
face dualFace = buildDualFace(eit);
|
||||
|
||||
if (dualFace.size() < 3)
|
||||
{
|
||||
// This face has been collapsed already
|
||||
continue;
|
||||
}
|
||||
|
||||
forAll(dualFace, fPtI)
|
||||
{
|
||||
label ptI = dualFace[fPtI];
|
||||
|
||||
point& pt = pts[ptI];
|
||||
|
||||
pointIndexHit surfHit;
|
||||
label hitSurface;
|
||||
|
||||
geometryToConformTo_.findSurfaceNearest
|
||||
(
|
||||
pt,
|
||||
cvMeshControls().spanSqr(),
|
||||
surfHit,
|
||||
hitSurface
|
||||
);
|
||||
|
||||
if (surfHit.hit())
|
||||
{
|
||||
pt = surfHit.hitPoint();
|
||||
|
||||
// dualPtIndexMap.insert(ptI, ptI);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nSmoothedVertices;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::conformalVoronoiMesh::collapseFaces
|
||||
(
|
||||
@ -2724,7 +2816,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
|
||||
if
|
||||
(
|
||||
vA->internalOrBoundaryPoint()
|
||||
|| vB->internalOrBoundaryPoint()
|
||||
|| vB->internalOrBoundaryPoint()
|
||||
)
|
||||
{
|
||||
face newDualFace = buildDualFace(eit);
|
||||
|
||||
@ -456,6 +456,13 @@ private:
|
||||
const Triangulation::Finite_edges_iterator& eit
|
||||
) const;
|
||||
|
||||
//- Determines if the dual face constructed by the Delaunay
|
||||
// edge is a boundary face
|
||||
inline bool isBoundaryDualFace
|
||||
(
|
||||
const Triangulation::Finite_edges_iterator& eit
|
||||
) const;
|
||||
|
||||
//- Merge vertices that are very close together
|
||||
label mergeCloseDualVertices
|
||||
(
|
||||
@ -463,6 +470,15 @@ private:
|
||||
Map<label>& dualPtIndexMap
|
||||
);
|
||||
|
||||
//- Smooth the dual vertices of the dual faces on the boundary
|
||||
// so that they conform to the surface and remove any
|
||||
// small, normal oriented faces
|
||||
label smoothSurfaceDualFaces
|
||||
(
|
||||
pointField& pts,
|
||||
Map<label>& dualPtIndexMap
|
||||
);
|
||||
|
||||
//- Collapse a face to a point or an edge, modifying and
|
||||
// mapping the points, returns the true if the face was
|
||||
// collapsed in this operation
|
||||
|
||||
@ -337,6 +337,31 @@ inline void Foam::conformalVoronoiMesh::insertVb(const Vb& v, label offset)
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::conformalVoronoiMesh::isBoundaryDualFace
|
||||
(
|
||||
const Triangulation::Finite_edges_iterator& eit
|
||||
) const
|
||||
{
|
||||
Cell_handle c = eit->first;
|
||||
Vertex_handle vA = c->vertex(eit->second);
|
||||
Vertex_handle vB = c->vertex(eit->third);
|
||||
|
||||
// A dual face on the boundary will result from one Dv inside and
|
||||
// one outside
|
||||
return
|
||||
(
|
||||
(
|
||||
vA->internalOrBoundaryPoint()
|
||||
|| vB->internalOrBoundaryPoint()
|
||||
)
|
||||
&& (
|
||||
!vA->internalOrBoundaryPoint()
|
||||
|| !vB->internalOrBoundaryPoint()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef CGAL_INEXACT
|
||||
|
||||
Reference in New Issue
Block a user