Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2012-03-28 18:59:46 +01:00
34 changed files with 2064 additions and 882 deletions

View File

@ -20,7 +20,8 @@ EXE_LIBS = \
$(CGAL_LIBS) \
-lconformalVoronoiMesh \
-lmeshTools \
-ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lscotchDecomp \
-ldecompositionMethods \
-L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \
-ledgeMesh \
-ltriSurface \
-ldynamicMesh

View File

@ -19,7 +19,6 @@ EXE_INC = \
EXE_LIBS = \
-lmeshTools \
-ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lscotchDecomp \
-ledgeMesh \
-ltriSurface \
-ldynamicMesh

View File

@ -63,7 +63,7 @@ Foam::fieldFromFile::fieldFromFile
Foam::triSurfaceScalarField Foam::fieldFromFile::load()
{
Info<< "Loading: " << fileName_ << endl;
Info<< indent << "Loading: " << fileName_ << endl;
triSurfaceScalarField surfaceCellSize
(

View File

@ -82,9 +82,9 @@ Foam::nonUniformField::nonUniformField
Info<< decrIndent;
Info<< indent << "Cell size field statistics:" << nl
<< indent << " Minimum: " << min(surfaceCellSize_).value() << nl
<< indent << " Average: " << average(surfaceCellSize_).value() << nl
<< indent << " Maximum: " << max(surfaceCellSize_).value() << endl;
<< indent << " Minimum: " << min(surfaceCellSize_).value() << nl
<< indent << " Average: " << average(surfaceCellSize_).value() << nl
<< indent << " Maximum: " << max(surfaceCellSize_).value() << endl;
Info<< decrIndent;
}

View File

@ -46,7 +46,10 @@ Foam::surfaceCellSizeFunction::surfaceCellSizeFunction
dictionary(surfaceCellSizeFunctionDict),
surface_(surface),
coeffsDict_(subDict(type + "Coeffs")),
refinementFactor_(readScalar(lookup("refinementFactor")))
refinementFactor_
(
lookupOrDefault<scalar>("refinementFactor", 1.0)
)
{}

View File

@ -44,6 +44,142 @@ const Foam::scalar Foam::conformalVoronoiMesh::tolParallel = 1e-3;
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::scalar Foam::conformalVoronoiMesh::requiredSize
(
const Foam::point& pt
) const
{
pointIndexHit surfHit;
label hitSurface;
DynamicList<scalar> cellSizeHits;
geometryToConformTo_.findSurfaceNearest
(
pt,
sqr(GREAT),
surfHit,
hitSurface
);
if (!surfHit.hit())
{
FatalErrorIn
(
"Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment"
)
<< "findSurfaceNearest did not find a hit across the surfaces."
<< exit(FatalError) << endl;
}
cellSizeHits.append(cellSizeControl().cellSize(pt));
// Primary alignment
vectorField norm(1);
allGeometry_[hitSurface].getNormal
(
List<pointIndexHit>(1, surfHit),
norm
);
const vector np = norm[0];
// Generate equally spaced 'spokes' in a circle normal to the
// direction from the vertex to the closest point on the surface
// and look for a secondary intersection.
const vector d = surfHit.hitPoint() - pt;
const tensor Rp = rotationTensor(vector(0,0,1), np);
const label s = cvMeshControls().alignmentSearchSpokes();
const scalar spanMag = geometryToConformTo_.globalBounds().mag();
scalar totalDist = 0;
for (label i = 0; i < s; i++)
{
vector spoke
(
Foam::cos(i*constant::mathematical::twoPi/s),
Foam::sin(i*constant::mathematical::twoPi/s),
0
);
spoke *= spanMag;
spoke = Rp & spoke;
pointIndexHit spokeHit;
label spokeSurface = -1;
// internal spoke
geometryToConformTo_.findSurfaceNearestIntersection
(
pt,
pt + spoke,
spokeHit,
spokeSurface
);
if (spokeHit.hit())
{
const Foam::point& hitPt = spokeHit.hitPoint();
scalar spokeHitDistance = mag(hitPt - pt);
cellSizeHits.append
(
cellSizeControl().cellSize(hitPt)
);
totalDist += spokeHitDistance;
}
//external spoke
Foam::point mirrorPt = pt + 2*d;
geometryToConformTo_.findSurfaceNearestIntersection
(
mirrorPt,
mirrorPt + spoke,
spokeHit,
spokeSurface
);
if (spokeHit.hit())
{
const Foam::point& hitPt = spokeHit.hitPoint();
scalar spokeHitDistance = mag(hitPt - mirrorPt);
cellSizeHits.append
(
cellSizeControl().cellSize(hitPt)
);
totalDist += spokeHitDistance;
}
}
scalar cellSize = 0;
forAll(cellSizeHits, hitI)
{
cellSize += cellSizeHits[hitI];
}
return cellSize/cellSizeHits.size();
//return cellSizeControl().cellSize(pt);
}
Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment
(
const Foam::point& pt
@ -828,10 +964,7 @@ void Foam::conformalVoronoiMesh::storeSizesAndAlignments
{
sizeAndAlignmentLocations_[i] = topoint(*pit);
storedSizes_[i] = cellSizeControl().cellSize
(
sizeAndAlignmentLocations_[i]
);
storedSizes_[i] = requiredSize(sizeAndAlignmentLocations_[i]);
storedAlignments_[i] = requiredAlignment(sizeAndAlignmentLocations_[i]);

View File

@ -268,6 +268,9 @@ private:
//- Return the local maximum surface protrusion distance
inline scalar maxSurfaceProtrusion(const Foam::point& pt) const;
//- Return the required cell size at the given location
scalar requiredSize(const Foam::point& pt) const;
//- Return the required alignment directions at the given location
tensor requiredAlignment(const Foam::point& pt) const;
@ -533,6 +536,11 @@ private:
const Delaunay::Finite_edges_iterator& eit
) const;
boolList dualFaceBoundaryPoints
(
const Delaunay::Finite_edges_iterator& eit
) const;
//- Finds the maximum filterCount of the dual vertices
// (Delaunay cells) that form the dual face produced by the
// supplied edge
@ -839,6 +847,13 @@ private:
const Delaunay::Finite_facets_iterator& fit
) const;
//- Merge adjacent edges that are not attached to other faces
label mergeNearlyParallelEdges
(
const pointField& pts,
const scalar maxCosAngle
);
//- Merge vertices that are very close together
void mergeCloseDualVertices
(

View File

@ -212,6 +212,20 @@ void Foam::conformalVoronoiMesh::calcDualMesh
Info<< nl << "Collapsing unnecessary faces" << endl;
collapseFaces(points, boundaryPts, deferredCollapseFaces);
const scalar maxCosAngle
= cos(degToRad(cvMeshControls().edgeMergeAngle()));
Info<< nl << "Merging adjacent edges which have an angle "
<< "of greater than "
<< cvMeshControls().edgeMergeAngle() << ": " << endl;
label nRemovedEdges =
mergeNearlyParallelEdges(points, maxCosAngle);
reduce(nRemovedEdges, sumOp<label>());
Info<< " Merged " << nRemovedEdges << " edges" << endl;
}
labelHashSet wrongFaces = checkPolyMeshQuality(points);
@ -652,6 +666,113 @@ Foam::label Foam::conformalVoronoiMesh::mergeCloseDualVertices
}
Foam::label Foam::conformalVoronoiMesh::mergeNearlyParallelEdges
(
const pointField& pts,
const scalar maxCosAngle
)
{
List<HashSet<label> > pointFaceCount(number_of_cells());
labelList pointNeighbour(number_of_cells(), -1);
Map<label> dualPtIndexMap;
for
(
Delaunay::Finite_edges_iterator eit = finite_edges_begin();
eit != finite_edges_end();
++eit
)
{
Cell_handle c = eit->first;
Vertex_handle vA = c->vertex(eit->second);
Vertex_handle vB = c->vertex(eit->third);
if (isBoundaryDualFace(eit))
{
const face f = buildDualFace(eit);
forAll(f, pI)
{
const label pIndex = f[pI];
const label prevPointI = f.prevLabel(pI);
const label nextPointI = f.nextLabel(pI);
pointFaceCount[pIndex].insert(prevPointI);
pointFaceCount[pIndex].insert(nextPointI);
pointNeighbour[pIndex] = nextPointI;
}
}
else if
(
vA->internalOrBoundaryPoint()
|| vB->internalOrBoundaryPoint()
)
{
const face f = buildDualFace(eit);
const boolList faceBoundaryPoints = dualFaceBoundaryPoints(eit);
forAll(f, pI)
{
const label pIndex = f[pI];
const label prevPointI = f.prevLabel(pI);
const label nextPointI = f.nextLabel(pI);
pointFaceCount[pIndex].insert(prevPointI);
pointFaceCount[pIndex].insert(nextPointI);
if (faceBoundaryPoints[pI] == false)
{
pointNeighbour[pIndex] = nextPointI;
}
else
{
if (faceBoundaryPoints[prevPointI] == true)
{
pointNeighbour[pIndex] = prevPointI;
}
else if (faceBoundaryPoints[nextPointI] == true)
{
pointNeighbour[pIndex] = nextPointI;
}
else
{
pointNeighbour[pIndex] = pIndex;
}
}
}
}
}
forAll(pointFaceCount, pI)
{
if (pointFaceCount[pI].size() == 2)
{
List<vector> edges(2, vector(0, 0, 0));
label count = 0;
forAllConstIter(HashSet<label>, pointFaceCount[pI], iter)
{
edges[count] = pts[pI] - pts[iter.key()];
edges[count] /= mag(edges[count]) + VSMALL;
count++;
}
if (mag(edges[0] & edges[1]) > maxCosAngle)
{
dualPtIndexMap.insert(pI, pointNeighbour[pI]);
}
}
}
reindexDualVertices(dualPtIndexMap);
return dualPtIndexMap.size();
}
void Foam::conformalVoronoiMesh::smoothSurface
(
pointField& pts,
@ -696,7 +817,6 @@ void Foam::conformalVoronoiMesh::smoothSurface
} while (nCollapsedFaces > 0);
// Force all points of boundary faces to be on the surface
for
(
Delaunay::Finite_cells_iterator cit = finite_cells_begin();
@ -917,6 +1037,7 @@ void Foam::conformalVoronoiMesh::collapseFaces
mergeCloseDualVertices(pts, boundaryPts);
if (nCollapsedFaces > 0)
{
Info<< " Collapsed " << nCollapsedFaces << " faces" << endl;
@ -932,6 +1053,7 @@ void Foam::conformalVoronoiMesh::collapseFaces
}
} while (nCollapsedFaces > 0);
}
@ -1064,6 +1186,25 @@ Foam::conformalVoronoiMesh::collapseFace
bool allowEarlyCollapseToPoint = true;
// // Quick exit
// label smallEdges = 0;
// const edgeList& fEdges = f.edges();
// forAll(fEdges, eI)
// {
// const edge& e = fEdges[eI];
//
// if (e.mag(pts) < 0.2*targetFaceSize)
// {
// smallEdges++;
// }
// }
// if (smallEdges == 0)
// {
// return fcmNone;
// }
// if (maxFC > cvMeshControls().filterCountSkipThreshold() - 3)
// {
// limitToQuadsOrTris = true;
@ -1071,6 +1212,7 @@ Foam::conformalVoronoiMesh::collapseFace
// allowEarlyCollapseToPoint = false;
// }
collapseSizeLimitCoeff *= pow
(
cvMeshControls().filterErrorReductionCoeff(),
@ -1158,6 +1300,91 @@ Foam::conformalVoronoiMesh::collapseFace
}
}
scalar maxDist = 0;
scalar minDist = GREAT;
//
// if (f.size() <= 3)
// {
// const edgeList& fEdges = f.edges();
//
// forAll(fEdges, eI)
// {
// const edge& e = fEdges[eI];
// const scalar d = e.mag(pts);
//
// if (d > maxDist)
// {
// maxDist = d;
// collapseAxis = e.vec(pts);
// }
// else if (d < minDist && d != 0)
// {
// minDist = d;
// }
// }
// }
// else
// {
// forAll(f, pI)
// {
// for (label i = pI + 1; i < f.size(); ++i)
// {
// if
// (
// f[i] != f.nextLabel(pI)
// && f[i] != f.prevLabel(pI)
// )
// {
// scalar d = mag(pts[f[pI]] - pts[f[i]]);
//
// if (d > maxDist)
// {
// maxDist = d;
// collapseAxis = pts[f[pI]] - pts[f[i]];
// }
// else if (d < minDist && d != 0)
// {
// minDist = d;
// }
// }
// }
// }
// }
//
// const edgeList& fEdges = f.edges();
//
// scalar perimeter = 0;
//
// forAll(fEdges, eI)
// {
// const edge& e = fEdges[eI];
// const scalar d = e.mag(pts);
//
// perimeter += d;
//
//// collapseAxis += e.vec(pts);
//
// if (d > maxDist)
// {
// collapseAxis = e.vec(pts);
// maxDist = d;
// }
// else if (d < minDist && d != 0)
// {
// minDist = d;
// }
// }
//
// collapseAxis /= mag(collapseAxis);
//
//// Info<< f.size() << " " << minDist << " " << maxDist << " | "
//// << collapseAxis << endl;
//
// aspectRatio = maxDist/minDist;
//
// aspectRatio = min(aspectRatio, sqr(perimeter)/(16.0*fA));
if (magSqr(collapseAxis) < VSMALL)
{
WarningIn
@ -1170,9 +1397,9 @@ Foam::conformalVoronoiMesh::collapseFace
// Output face and collapse axis for visualisation
Pout<< "# Aspect ratio = " << aspectRatio << nl
<< "# inertia = " << J << nl
<< "# determinant = " << detJ << nl
<< "# eigenvalues = " << eigenValues(J) << nl
// << "# inertia = " << J << nl
// << "# determinant = " << detJ << nl
// << "# eigenvalues = " << eigenValues(J) << nl
<< "# collapseAxis = " << collapseAxis << nl
<< "# facePts = " << facePts << nl
<< endl;
@ -1280,8 +1507,6 @@ Foam::conformalVoronoiMesh::collapseFace
{
scalar guardFraction = cvMeshControls().edgeCollapseGuardFraction();
cvMeshControls().maxCollapseFaceToPointSideLengthCoeff();
if
(
allowEarlyCollapseToPoint
@ -1337,6 +1562,8 @@ Foam::conformalVoronoiMesh::collapseFace
Foam::point collapseToPt =
collapseAxis*(sum(dNeg)/dNeg.size() - dShift) + fC;
// DynamicList<label> faceBoundaryPts(f.size());
forAll(facePtsNeg, fPtI)
{
if (boundaryPts[facePtsNeg[fPtI]] == true)
@ -1351,9 +1578,36 @@ Foam::conformalVoronoiMesh::collapseFace
collapseToPt = pts[collapseToPtI];
break;
// faceBoundaryPts.append(facePtsNeg[fPtI]);
}
}
// if (!faceBoundaryPts.empty())
// {
// if (faceBoundaryPts.size() == 2)
// {
// collapseToPtI = faceBoundaryPts[0];
//
// collapseToPt =
// 0.5
// *(
// pts[faceBoundaryPts[0]]
// + pts[faceBoundaryPts[1]]
// );
// }
// else if (faceBoundaryPts.size() < f.size())
// {
// face bFace(faceBoundaryPts);
//
// collapseToPtI = faceBoundaryPts.first();
//
// collapseToPt = bFace.centre(pts);
// }
// }
//
// faceBoundaryPts.clear();
// ...otherwise arbitrarily choosing the most distant
// point as the index to collapse to.
@ -1384,9 +1638,34 @@ Foam::conformalVoronoiMesh::collapseFace
collapseToPt = pts[collapseToPtI];
break;
// faceBoundaryPts.append(facePtsNeg[fPtI]);
}
}
// if (!faceBoundaryPts.empty())
// {
// if (faceBoundaryPts.size() == 2)
// {
// collapseToPtI = faceBoundaryPts[0];
//
// collapseToPt =
// 0.5
// *(
// pts[faceBoundaryPts[0]]
// + pts[faceBoundaryPts[1]]
// );
// }
// else if (faceBoundaryPts.size() < f.size())
// {
// face bFace(faceBoundaryPts);
//
// collapseToPtI = faceBoundaryPts.first();
//
// collapseToPt = bFace.centre(pts);
// }
// }
// ...otherwise arbitrarily choosing the most distant
// point as the index to collapse to.
@ -1406,6 +1685,8 @@ Foam::conformalVoronoiMesh::collapseFace
Foam::point collapseToPt = fC;
DynamicList<label> faceBoundaryPts(f.size());
forAll(facePts, fPtI)
{
if (boundaryPts[facePts[fPtI]] == true)
@ -1415,11 +1696,32 @@ Foam::conformalVoronoiMesh::collapseFace
// use the first boundary point encountered if
// there are multiple boundary points.
collapseToPtI = facePts[fPtI];
// collapseToPtI = facePts[fPtI];
//
// collapseToPt = pts[collapseToPtI];
//
// break;
collapseToPt = pts[collapseToPtI];
faceBoundaryPts.append(facePts[fPtI]);
}
}
break;
if (!faceBoundaryPts.empty())
{
if (faceBoundaryPts.size() == 2)
{
collapseToPtI = faceBoundaryPts[0];
collapseToPt =
0.5*(pts[faceBoundaryPts[0]] + pts[faceBoundaryPts[1]]);
}
else if (faceBoundaryPts.size() < f.size())
{
face bFace(faceBoundaryPts);
collapseToPtI = faceBoundaryPts.first();
collapseToPt = bFace.centre(pts);
}
}
@ -1791,9 +2093,9 @@ void Foam::conformalVoronoiMesh::checkCellSizing()
}
Info<< " Automatically re-sizing " << cellsToResize.size()
<< " cells that are attached to the bad faces: DISABLED" << endl;
<< " cells that are attached to the bad faces: " << endl;
//cellSizeControl_.setCellSizes(cellsToResize);
cellSizeControl_.setCellSizes(cellsToResize);
}
timeCheck("End of Cell Sizing");
@ -1858,7 +2160,10 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::findOffsetPatchFaces
}
}
offsetBoundaryCells.write();
if (cvMeshControls().objOutput())
{
offsetBoundaryCells.write();
}
return offsetBoundaryCells;
}
@ -2092,13 +2397,7 @@ void Foam::conformalVoronoiMesh::indexDualVertices
pts[dualVertI] = cit->dual();
if
(
!cit->vertex(0)->internalOrBoundaryPoint()
|| !cit->vertex(1)->internalOrBoundaryPoint()
|| !cit->vertex(2)->internalOrBoundaryPoint()
|| !cit->vertex(3)->internalOrBoundaryPoint()
)
if (cit->boundaryDualVertex())
{
// This is a boundary dual vertex
boundaryPts[dualVertI] = true;

View File

@ -719,12 +719,15 @@ bool Foam::conformalVoronoiMesh::dualCellSurfaceAllIntersections
const Foam::point& p = infoList[hitI].hitPoint();
const scalar separationDistance
= mag(p - info.hitPoint());
const scalar separationDistance =
mag(p - info.hitPoint());
const scalar minSepDist
= sqr(cvMeshControls().removalDistCoeff()
*targetCellSize(p));
const scalar minSepDist =
sqr
(
cvMeshControls().removalDistCoeff()
*targetCellSize(p)
);
// Reject the point if it is too close to another
// surface point.

View File

@ -366,6 +366,49 @@ inline bool Foam::conformalVoronoiMesh::isBoundaryDualFace
}
inline Foam::List<bool> Foam::conformalVoronoiMesh::dualFaceBoundaryPoints
(
const Delaunay::Finite_edges_iterator& eit
) const
{
Cell_circulator ccStart = incident_cells(*eit);
Cell_circulator cc1 = ccStart;
Cell_circulator cc2 = cc1;
// Advance the second circulator so that it always stays on the next
// cell around the edge;
cc2++;
DynamicList<bool> tmpFaceBoundaryPoints;
do
{
label cc1I = cc1->cellIndex();
label cc2I = cc2->cellIndex();
if (cc1I != cc2I)
{
if (cc1->boundaryDualVertex())
{
tmpFaceBoundaryPoints.append(true);
}
else
{
tmpFaceBoundaryPoints.append(false);
}
}
cc1++;
cc2++;
} while (cc1 != ccStart);
return tmpFaceBoundaryPoints;
}
inline Foam::List<Foam::label> Foam::conformalVoronoiMesh::processorsAttached
(
const Delaunay::Finite_facets_iterator& fit

View File

@ -291,6 +291,11 @@ Foam::cvControls::cvControls
filteringDict.lookup("mergeClosenessCoeff")
);
edgeMergeAngle_ = readScalar
(
filteringDict.lookup("edgeMergeAngle")
);
continueFilteringOnBadInitialPolyMesh_ = Switch
(
filteringDict.lookupOrDefault<Switch>

View File

@ -234,6 +234,11 @@ class cvControls
// being merged, fraction of the local target cell size
scalar mergeClosenessCoeff_;
//- If the angle between two dual edges that are connected by a single
// point is less than this angle, then the edges will be merged into a
// single edge.
scalar edgeMergeAngle_;
//- If the mesh quality criteria cannot be satisfied, continue
// with filtering anyway?
Switch continueFilteringOnBadInitialPolyMesh_;
@ -405,6 +410,9 @@ public:
//- Return the mergeClosenessCoeff
inline scalar mergeClosenessCoeff() const;
//- Return the edgeMergeAngle
inline scalar edgeMergeAngle() const;
//- Return the continueFilteringOnBadInitialPolyMesh Switch
inline Switch continueFilteringOnBadInitialPolyMesh() const;

View File

@ -166,6 +166,12 @@ inline Foam::scalar Foam::cvControls::mergeClosenessCoeff() const
}
inline Foam::scalar Foam::cvControls::edgeMergeAngle() const
{
return edgeMergeAngle_;
}
inline Foam::Switch
Foam::cvControls::continueFilteringOnBadInitialPolyMesh() const
{

View File

@ -3,30 +3,25 @@ cd ${0%/*} || exit 1 # run from this directory
set -x
if [ ! -e "Make/files" ] || [ ! -e "Make/options" ]
if [ -n "$CGAL_ARCH_PATH" ]
then
mkdir -p Make
echo
echo "Compiling surfaceFeatureExtract with CGAL curvature support"
echo
if [ -n "$CGAL_ARCH_PATH" ]
then
cp -r MakeWithCGAL/* Make
echo
echo Compiling surfaceFeatureExtract with CGAL support for curvature
echo
wmake
else
cp -r MakeWithoutCGAL/* Make
echo
echo Compiling surfaceFeatureExtract without CGAL support for curvature
echo
wmake
fi
wmake "ENABLE_CURVATURE=-DENABLE_CURVATURE \
EXE_FROUNDING_MATH=-frounding-math \
USE_F2C=-DCGAL_USE_F2C \
CGAL_LIBDIR=-L$CGAL_ARCH_PATH/lib \
LAPACK_LIB=-llapack \
BLAS_LIB=-lblas \
CGAL_LIB=-lCGAL"
else
echo surfaceFeatureExtract already has a Make folder
echo
echo "Compiling surfaceFeatureExtract without CGAL curvature support"
echo
wmake
fi

View File

@ -1,89 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "buildCGALPolyhedron.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::buildCGALPolyhedron::buildCGALPolyhedron
(
const Foam::triSurface& surf
)
:
CGAL::Modifier_base<HalfedgeDS>(),
surf_(surf)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::buildCGALPolyhedron::~buildCGALPolyhedron()
{}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
void Foam::buildCGALPolyhedron::operator()
(
HalfedgeDS& hds
)
{
typedef HalfedgeDS::Traits Traits;
typedef Traits::Point_3 Point;
// Postcondition: `hds' is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HalfedgeDS> B(hds, false);
B.begin_surface
(
surf_.points().size(), // n points
surf_.size(), // n facets
2*surf_.edges().size() // n halfedges
);
forAll(surf_.points(), pI)
{
const Foam::point& p = surf_.points()[pI];
B.add_vertex(Point(p.x(), p.y(), p.z()));
}
forAll(surf_, fI)
{
B.begin_facet();
B.add_vertex_to_facet(surf_[fI][0]);
B.add_vertex_to_facet(surf_[fI][1]);
B.add_vertex_to_facet(surf_[fI][2]);
B.end_facet();
}
B.end_surface();
}
// ************************************************************************* //

View File

@ -53,7 +53,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class buildCGALPolyhedron Declaration
Class buildCGALPolyhedron Declaration
\*---------------------------------------------------------------------------*/
class buildCGALPolyhedron
@ -80,18 +80,56 @@ public:
// Constructors
//- Construct with reference to triSurface
buildCGALPolyhedron(const triSurface& surf);
explicit buildCGALPolyhedron(const triSurface& surf)
:
CGAL::Modifier_base<HalfedgeDS>(),
surf_(surf)
{}
//- Destructor
~buildCGALPolyhedron();
~buildCGALPolyhedron(){}
// Member Operators
//- operator() of this `modifier' called by delegate function of
// Polyhedron
void operator()(HalfedgeDS& hds);
void operator()(HalfedgeDS& hds)
{
typedef HalfedgeDS::Traits Traits;
typedef Traits::Point_3 Point;
// Postcondition: `hds' is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HalfedgeDS> B(hds, false);
B.begin_surface
(
surf_.points().size(), // n points
surf_.size(), // n facets
2*surf_.edges().size() // n halfedges
);
forAll(surf_.points(), pI)
{
const Foam::point& p = surf_.points()[pI];
B.add_vertex(Point(p.x(), p.y(), p.z()));
}
forAll(surf_, fI)
{
B.begin_facet();
B.add_vertex_to_facet(surf_[fI][0]);
B.add_vertex_to_facet(surf_[fI][1]);
B.add_vertex_to_facet(surf_[fI][2]);
B.end_facet();
}
B.end_surface();
}
};

View File

@ -1,4 +1,11 @@
include $(GENERAL_RULES)/CGAL
EXE_INC = \
${ENABLE_CURVATURE}\
${EXE_FROUNDING_MATH} \
${USE_F2C} \
${CGAL_INC} \
-ICGALPolyhedron \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
@ -7,6 +14,11 @@ EXE_INC = \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
$(CGAL_LIBS) \
${CGAL_LIBDIR} \
${LAPACK_LIB} \
${BLAS_LIB} \
${CGAL_LIB} \
-lmeshTools \
-ledgeMesh \
-ltriSurface \

View File

@ -1,4 +0,0 @@
surfaceFeatureExtract.C
CGALPolyhedron/buildCGALPolyhedron.C
EXE = $(FOAM_APPBIN)/surfaceFeatureExtract

View File

@ -1,29 +0,0 @@
EXE_FROUNDING_MATH = -frounding-math
EXE_NDEBUG = -DNDEBUG
USE_F2C = -DCGAL_USE_F2C
include $(GENERAL_RULES)/CGAL
EXE_INC = \
-DENABLE_CURVATURE \
${EXE_FROUNDING_MATH} \
${EXE_NDEBUG} \
${USE_F2C} \
${CGAL_INC} \
-ICGALPolyhedron \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
$(CGAL_LIBS) \
-L$(CGAL_ARCH_PATH)/lib \
-llapack \
-lblas \
-lCGAL \
-lmeshTools \
-ledgeMesh \
-ltriSurface \
-lsampling

View File

@ -1,3 +0,0 @@
surfaceFeatureExtract.C
EXE = $(FOAM_APPBIN)/surfaceFeatureExtract

View File

@ -1,13 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-lmeshTools \
-ledgeMesh \
-ltriSurface \
-lsampling

View File

@ -0,0 +1,86 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object surfaceFeatureExtractDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
surface1.stl
{
// extractFromFile || extractFromSurface
extractionMethod extractFromFile;
extractFromFile
{
// Load from an existing feature edge file
featureEdgeFile "constant/triSurface/featureEdges.nas";
}
trimFeatures
{
// Remove features with fewer than the specified number of edges
minElem 0;
// Remove features shorter than the specified cumulative length
minLen 0.0;
}
subsetFeatures
{
// Use a plane to select feature edges
// (normal)(basePoint)
plane (1 0 0)(0 0 0);
// Select feature edges using a box
// (minPt)(maxPt)
insideBox (0 0 0)(1 1 1);
outsideBox (0 0 0)(1 1 1);
// Remove any non-manifold (open or > 2 connected faces) edges
manifoldEdges no;
}
// Output the curvature of the surface
curvature no;
// Output the proximity of feature points and edges to each other
featureProximity no;
// The maximum search distance to use when looking for other feature
// points and edges
maxFeatureProximity 1;
// Out put the closeness of surface elements to other surface elements.
closeness no;
// Write options
writeVTK no;
writeObj yes;
writeFeatureEdgeMesh no;
}
surface2.nas
{
extractionMethod extractFromSurface;
extractFromSurface
{
// Mark edges whose adjacent surface normals are at an angle less
// than includedAngle as features
// - 0 : selects no edges
// - 180: selects all edges
includedAngle 120;
}
}
// ************************************************************************* //