mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Added feature edge guard distance to placement of edge control points, two new tolerance values and a featureEdges size == 0 check
This commit is contained in:
@ -140,6 +140,14 @@ public:
|
|||||||
//- Square of ppDist
|
//- Square of ppDist
|
||||||
scalar ppDist2;
|
scalar ppDist2;
|
||||||
|
|
||||||
|
//- Maximum distance between adjacent control points on a feature edge
|
||||||
|
//- before they are considered a group
|
||||||
|
scalar edgeGroupSpacing;
|
||||||
|
|
||||||
|
//- Guard distance from a feature point within which an edge control
|
||||||
|
//- point may not be placed
|
||||||
|
scalar featurePointGuard;
|
||||||
|
|
||||||
tolerances
|
tolerances
|
||||||
(
|
(
|
||||||
const dictionary& controlDict,
|
const dictionary& controlDict,
|
||||||
|
|||||||
@ -196,11 +196,14 @@ void Foam::CV3D::smoothEdgePositions
|
|||||||
|
|
||||||
// Process the points along each edge (in blocks of edgeLabel) performing 3
|
// Process the points along each edge (in blocks of edgeLabel) performing 3
|
||||||
// functions:
|
// functions:
|
||||||
// 1: move points away from feature edges
|
// 1: move points away from feature points
|
||||||
// 2: aggregate tight groups of points into one point
|
// 2: aggregate tight groups of points into one point
|
||||||
// 3: adjust the spacing of remaining points on a pair by pair basis to
|
// 3: adjust the spacing of remaining points on a pair by pair basis to
|
||||||
// remove excess points
|
// remove excess points
|
||||||
|
|
||||||
|
// part 1
|
||||||
|
|
||||||
|
{
|
||||||
DynamicList<point> tempEdgePoints(edgePoints.size());
|
DynamicList<point> tempEdgePoints(edgePoints.size());
|
||||||
|
|
||||||
DynamicList<label> tempEdgeLabels(edgeLabels.size());
|
DynamicList<label> tempEdgeLabels(edgeLabels.size());
|
||||||
@ -226,7 +229,134 @@ void Foam::CV3D::smoothEdgePositions
|
|||||||
|
|
||||||
List<scalar> edgeDistanceBlock(SubList<scalar>(edgeDistances, length, start));
|
List<scalar> edgeDistanceBlock(SubList<scalar>(edgeDistances, length, start));
|
||||||
|
|
||||||
scalar maxPointGroupSpacing = tols_.ppDist;
|
const edge& e(edges[edgeI]);
|
||||||
|
|
||||||
|
const point& eStart(localPts[e.start()]);
|
||||||
|
|
||||||
|
const point& eEnd(localPts[e.end()]);
|
||||||
|
|
||||||
|
scalar edgeLength = mag(eStart - eEnd);
|
||||||
|
|
||||||
|
if (edgeLength < 2*tols_.featurePointGuard)
|
||||||
|
{
|
||||||
|
Info<< "edge " << edgeI
|
||||||
|
<< " is too short with respect to the featurePointGuard distance "
|
||||||
|
<< "to allow edge control points to be placed."
|
||||||
|
<< nl << "Edge length = " << edgeLength
|
||||||
|
<< nl <<endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
forAll (edgeDistanceBlock, eDB)
|
||||||
|
{
|
||||||
|
bool startGuardPlaced = false;
|
||||||
|
|
||||||
|
bool endGuardPlaced = false;
|
||||||
|
|
||||||
|
const scalar& edgeDist = edgeDistanceBlock[eDB];
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
edgeDist < tols_.featurePointGuard
|
||||||
|
&& !startGuardPlaced
|
||||||
|
)
|
||||||
|
{
|
||||||
|
tempEdgePoints.append
|
||||||
|
(
|
||||||
|
eStart + (edgePointBlock[eDB] - eStart)
|
||||||
|
* tols_.featurePointGuard/edgeDist
|
||||||
|
);
|
||||||
|
|
||||||
|
tempEdgeLabels.append(edgeI);
|
||||||
|
|
||||||
|
startGuardPlaced = true;
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
edgeDist > (edgeLength - tols_.featurePointGuard)
|
||||||
|
&& !endGuardPlaced
|
||||||
|
)
|
||||||
|
{
|
||||||
|
tempEdgePoints.append
|
||||||
|
(
|
||||||
|
eEnd + (edgePointBlock[eDB] - eEnd)
|
||||||
|
* tols_.featurePointGuard/(edgeLength - edgeDist)
|
||||||
|
);
|
||||||
|
|
||||||
|
tempEdgeLabels.append(edgeI);
|
||||||
|
|
||||||
|
endGuardPlaced = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tempEdgePoints.append(edgePointBlock[eDB]);
|
||||||
|
|
||||||
|
tempEdgeLabels.append(edgeI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
edgePoints.transfer(tempEdgePoints.shrink());
|
||||||
|
|
||||||
|
edgeLabels.transfer(tempEdgeLabels.shrink());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Re-establish the correct distances and jumps
|
||||||
|
|
||||||
|
edgeDistances.clear();
|
||||||
|
|
||||||
|
edgeDistances.setSize(edgePoints.size());
|
||||||
|
|
||||||
|
forAll(edgeDistances, eD)
|
||||||
|
{
|
||||||
|
const point& edgeStart = localPts[edges[edgeLabels[eD]].start()];
|
||||||
|
|
||||||
|
edgeDistances[eD] = mag(edgeStart - edgePoints[eD]);
|
||||||
|
}
|
||||||
|
|
||||||
|
edgeLabelJumps.clear();
|
||||||
|
|
||||||
|
// Force first edgeLabel to be a jump
|
||||||
|
edgeLabelJumps.append(0);
|
||||||
|
|
||||||
|
for (label eL = 1; eL < edgeLabels.size(); eL++)
|
||||||
|
{
|
||||||
|
if (edgeLabels[eL] > edgeLabels[eL-1])
|
||||||
|
{
|
||||||
|
edgeLabelJumps.append(eL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
edgeLabelJumps.shrink();
|
||||||
|
|
||||||
|
// part 2
|
||||||
|
{
|
||||||
|
DynamicList<point> tempEdgePoints(edgePoints.size());
|
||||||
|
|
||||||
|
DynamicList<label> tempEdgeLabels(edgeLabels.size());
|
||||||
|
|
||||||
|
forAll(edgeLabelJumps, eLJ)
|
||||||
|
{
|
||||||
|
label start = edgeLabelJumps[eLJ];
|
||||||
|
|
||||||
|
label edgeI = edgeLabels[start];
|
||||||
|
|
||||||
|
label length;
|
||||||
|
|
||||||
|
if (eLJ == edgeLabelJumps.size() - 1)
|
||||||
|
{
|
||||||
|
length = edgeLabels.size() - start;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
length = edgeLabelJumps[eLJ + 1] - start;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<point> edgePointBlock(SubList<point>(edgePoints, length, start));
|
||||||
|
|
||||||
|
List<scalar> edgeDistanceBlock(SubList<scalar>(edgeDistances, length, start));
|
||||||
|
|
||||||
label groupSize = 0;
|
label groupSize = 0;
|
||||||
|
|
||||||
@ -238,7 +368,7 @@ void Foam::CV3D::smoothEdgePositions
|
|||||||
|
|
||||||
tempEdgeLabels.append(edgeI);
|
tempEdgeLabels.append(edgeI);
|
||||||
}
|
}
|
||||||
else if ((edgeDistanceBlock[1] - edgeDistanceBlock[0]) > maxPointGroupSpacing)
|
else if ((edgeDistanceBlock[1] - edgeDistanceBlock[0]) > tols_.edgeGroupSpacing)
|
||||||
{
|
{
|
||||||
tempEdgePoints.append(edgePointBlock[0]);
|
tempEdgePoints.append(edgePointBlock[0]);
|
||||||
|
|
||||||
@ -250,7 +380,7 @@ void Foam::CV3D::smoothEdgePositions
|
|||||||
const scalar& edgeDist = edgeDistanceBlock[eDB];
|
const scalar& edgeDist = edgeDistanceBlock[eDB];
|
||||||
const scalar& previousEdgeDist = edgeDistanceBlock[eDB - 1];
|
const scalar& previousEdgeDist = edgeDistanceBlock[eDB - 1];
|
||||||
|
|
||||||
if ((edgeDist - previousEdgeDist) < maxPointGroupSpacing)
|
if ((edgeDist - previousEdgeDist) < tols_.edgeGroupSpacing)
|
||||||
{
|
{
|
||||||
newEdgePoint += edgePointBlock[eDB];
|
newEdgePoint += edgePointBlock[eDB];
|
||||||
|
|
||||||
@ -282,6 +412,7 @@ void Foam::CV3D::smoothEdgePositions
|
|||||||
edgePoints.transfer(tempEdgePoints.shrink());
|
edgePoints.transfer(tempEdgePoints.shrink());
|
||||||
|
|
||||||
edgeLabels.transfer(tempEdgeLabels.shrink());
|
edgeLabels.transfer(tempEdgeLabels.shrink());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -483,8 +614,10 @@ void Foam::CV3D::insertSurfaceNearestPointPairs()
|
|||||||
label nSurfacePointsEst = number_of_vertices();
|
label nSurfacePointsEst = number_of_vertices();
|
||||||
|
|
||||||
scalar distanceFactor = 8.0;
|
scalar distanceFactor = 8.0;
|
||||||
scalar distanceFactor2 = distanceFactor*distanceFactor;
|
scalar distanceFactor2 = Foam::sqr(distanceFactor);
|
||||||
|
|
||||||
|
if (qSurf_.features().featureEdges().size())
|
||||||
|
{
|
||||||
DynamicList<point> nearSurfacePoints(nSurfacePointsEst);
|
DynamicList<point> nearSurfacePoints(nSurfacePointsEst);
|
||||||
|
|
||||||
for
|
for
|
||||||
@ -555,8 +688,10 @@ void Foam::CV3D::insertSurfaceNearestPointPairs()
|
|||||||
edgeLabels,
|
edgeLabels,
|
||||||
"surfaceNearestEdgePoints.obj"
|
"surfaceNearestEdgePoints.obj"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicList<point> nearSurfacePoints(nSurfacePointsEst);
|
||||||
|
|
||||||
nearSurfacePoints.clear();
|
|
||||||
DynamicList<point> surfacePoints(nSurfacePointsEst);
|
DynamicList<point> surfacePoints(nSurfacePointsEst);
|
||||||
DynamicList<label> surfaceTris(nSurfacePointsEst);
|
DynamicList<label> surfaceTris(nSurfacePointsEst);
|
||||||
|
|
||||||
|
|||||||
@ -47,8 +47,17 @@ Foam::CV3D::tolerances::tolerances
|
|||||||
minEdgeLen2(Foam::sqr(minEdgeLen)),
|
minEdgeLen2(Foam::sqr(minEdgeLen)),
|
||||||
|
|
||||||
ppDist(readScalar(controlDict.lookup("ppDistCoeff"))*minCellSize),
|
ppDist(readScalar(controlDict.lookup("ppDistCoeff"))*minCellSize),
|
||||||
ppDist2(Foam::sqr(ppDist))
|
ppDist2(Foam::sqr(ppDist)),
|
||||||
|
|
||||||
|
edgeGroupSpacing
|
||||||
|
(
|
||||||
|
readScalar(controlDict.lookup("edgeGroupSpacingCoeff"))*minCellSize
|
||||||
|
),
|
||||||
|
|
||||||
|
featurePointGuard
|
||||||
|
(
|
||||||
|
readScalar(controlDict.lookup("featurePointGuardCoeff"))*minCellSize
|
||||||
|
)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user