mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Implemented feature non-overpopulation functions, including some reordering of
existing tests. Mixed feature point edge group insertions done using the same functions as feature edge conformation.
This commit is contained in:
@ -583,71 +583,18 @@ void Foam::conformalVoronoiMesh::insertMixedFeaturePoints()
|
|||||||
|
|
||||||
const point& pt(feMesh.points()[ptI]);
|
const point& pt(feMesh.points()[ptI]);
|
||||||
|
|
||||||
scalar ppDist = pointPairDistance(pt);
|
|
||||||
|
|
||||||
scalar edgeGroupDistance = mixedFeaturePointDistance(pt);
|
scalar edgeGroupDistance = mixedFeaturePointDistance(pt);
|
||||||
|
|
||||||
forAll(pEds, e)
|
forAll(pEds, e)
|
||||||
{
|
{
|
||||||
label edgeI = pEds[e];
|
label edgeI = pEds[e];
|
||||||
|
|
||||||
const vectorField& feNormals = feMesh.normals();
|
|
||||||
const labelList& edNormalIs =
|
|
||||||
feMesh.edgeNormals()[edgeI];
|
|
||||||
|
|
||||||
// As this is an external or internal edge, there are two
|
|
||||||
// normals by definition
|
|
||||||
const vector& nA = feNormals[edNormalIs[0]];
|
|
||||||
const vector& nB = feNormals[edNormalIs[1]];
|
|
||||||
|
|
||||||
point edgePt =
|
point edgePt =
|
||||||
pt + edgeGroupDistance*feMesh.edgeDirection(edgeI, ptI);
|
pt + edgeGroupDistance*feMesh.edgeDirection(edgeI, ptI);
|
||||||
|
|
||||||
// Concave. master and reflected points inside the domain.
|
pointIndexHit edgeHit(true, edgePt, edgeI);
|
||||||
point refPt =
|
|
||||||
edgePt - ppDist*(nA + nB)/(1 + (nA & nB) + VSMALL);
|
|
||||||
|
|
||||||
featureEdgeMesh::edgeStatus edStatus =
|
insertEdgePointGroup(feMesh, edgeHit);
|
||||||
feMesh.getEdgeStatus(edgeI);
|
|
||||||
|
|
||||||
if (edStatus == featureEdgeMesh::INTERNAL)
|
|
||||||
{
|
|
||||||
// Generate reflected master to be outside.
|
|
||||||
point reflMasterPt = refPt + 2*(edgePt - refPt);
|
|
||||||
|
|
||||||
// Reflect reflMasterPt in both faces.
|
|
||||||
point reflectedA = reflMasterPt - 2*ppDist*nA;
|
|
||||||
|
|
||||||
point reflectedB = reflMasterPt - 2*ppDist*nB;
|
|
||||||
|
|
||||||
// index of reflMaster
|
|
||||||
label reflectedMaster = number_of_vertices() + 2;
|
|
||||||
|
|
||||||
// Master A is inside.
|
|
||||||
label reflectedAI =
|
|
||||||
insertPoint(reflectedA, reflectedMaster);
|
|
||||||
|
|
||||||
// Master B is inside.
|
|
||||||
insertPoint(reflectedB, reflectedMaster);
|
|
||||||
|
|
||||||
// Slave is outside.
|
|
||||||
insertPoint(reflMasterPt, reflectedAI);
|
|
||||||
}
|
|
||||||
else if (edStatus == featureEdgeMesh::EXTERNAL)
|
|
||||||
{
|
|
||||||
// Insert the master point referring the the first slave
|
|
||||||
label masterPtIndex =
|
|
||||||
insertPoint(refPt, number_of_vertices() + 1);
|
|
||||||
|
|
||||||
// Insert the slave points by reflecting refPt in both
|
|
||||||
// faces. with each slave refering to the master
|
|
||||||
|
|
||||||
point reflectedA = refPt + 2*ppDist*nA;
|
|
||||||
insertPoint(reflectedA, masterPtIndex);
|
|
||||||
|
|
||||||
point reflectedB = refPt + 2*ppDist*nB;
|
|
||||||
insertPoint(reflectedB, masterPtIndex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -897,9 +844,19 @@ bool Foam::conformalVoronoiMesh::nearFeatureEdgeLocation
|
|||||||
autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree
|
autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
scalar exclusionRangeSqr = sqr(0.1);
|
|
||||||
|
|
||||||
if (newEdgeLocations.size() >= max(0.01*existingEdgeLocations.size(), 100))
|
scalar exclusionRangeCoeff = 0.2;
|
||||||
|
|
||||||
|
scalar exclusionRangeSqr = sqr(exclusionRangeCoeff*targetCellSize(pt));
|
||||||
|
|
||||||
|
// 0.01 and 1000 determined from speed tests, varying the indexedOctree
|
||||||
|
// rebuild frequency and balance of additions to queries.
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
newEdgeLocations.size()
|
||||||
|
>= max(0.01*existingEdgeLocations.size(), 1000)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
existingEdgeLocations.append(newEdgeLocations);
|
existingEdgeLocations.append(newEdgeLocations);
|
||||||
|
|
||||||
@ -966,7 +923,10 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits
|
|||||||
DynamicList<pointIndexHit>& surfaceHits,
|
DynamicList<pointIndexHit>& surfaceHits,
|
||||||
DynamicList<label>& hitSurfaces,
|
DynamicList<label>& hitSurfaces,
|
||||||
DynamicList<pointIndexHit>& featureEdgeHits,
|
DynamicList<pointIndexHit>& featureEdgeHits,
|
||||||
DynamicList<label>& featureEdgeFeaturesHit
|
DynamicList<label>& featureEdgeFeaturesHit,
|
||||||
|
DynamicList<point>& newEdgeLocations,
|
||||||
|
pointField& existingEdgeLocations,
|
||||||
|
autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
List<pointIndexHit> edHits;
|
List<pointIndexHit> edHits;
|
||||||
@ -990,6 +950,12 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits
|
|||||||
keepSurfacePoint = false;
|
keepSurfacePoint = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gather edge locations but do not add them to newEdgeLocations inside the
|
||||||
|
// loop as they will prevent nearby edge locations of different types being
|
||||||
|
// conformed to.
|
||||||
|
|
||||||
|
DynamicList<point> currentEdgeLocations;
|
||||||
|
|
||||||
forAll(edHits, i)
|
forAll(edHits, i)
|
||||||
{
|
{
|
||||||
const pointIndexHit& edHit(edHits[i]);
|
const pointIndexHit& edHit(edHits[i]);
|
||||||
@ -998,30 +964,45 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits
|
|||||||
|
|
||||||
if (edHit.hit())
|
if (edHit.hit())
|
||||||
{
|
{
|
||||||
if (!nearFeaturePt(edHit.hitPoint()))
|
|
||||||
{
|
|
||||||
// Do not place edge control points too close to a feature
|
|
||||||
// point.
|
|
||||||
|
|
||||||
featureEdgeHits.append(edHit);
|
|
||||||
|
|
||||||
featureEdgeFeaturesHit.append(featureHit);
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
magSqr(edHit.hitPoint() - surfHit.hitPoint())
|
magSqr(edHit.hitPoint() - surfHit.hitPoint())
|
||||||
< surfacePtReplaceDistCoeffSqr*targetCellSizeSqr
|
< surfacePtReplaceDistCoeffSqr*targetCellSizeSqr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// If the point is within a given distance of a feature
|
// If the point is within a given distance of a feature edge,
|
||||||
// edge, shift it to being an edge control point instead,
|
// give control to edge control points instead, this will
|
||||||
// this will prevent "pits" forming.
|
// prevent "pits" forming.
|
||||||
|
|
||||||
keepSurfacePoint = false;
|
keepSurfacePoint = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!nearFeaturePt(edHit.hitPoint()))
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!nearFeatureEdgeLocation
|
||||||
|
(
|
||||||
|
edHit.hitPoint(),
|
||||||
|
newEdgeLocations,
|
||||||
|
existingEdgeLocations,
|
||||||
|
edgeLocationTree
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Do not place edge control points too close to a feature
|
||||||
|
// point or existing edge control points
|
||||||
|
|
||||||
|
featureEdgeHits.append(edHit);
|
||||||
|
featureEdgeFeaturesHit.append(featureHit);
|
||||||
|
|
||||||
|
currentEdgeLocations.append(edHit.hitPoint());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newEdgeLocations.append(currentEdgeLocations);
|
||||||
|
|
||||||
if (keepSurfacePoint)
|
if (keepSurfacePoint)
|
||||||
{
|
{
|
||||||
@ -1660,6 +1641,7 @@ void Foam::conformalVoronoiMesh::conformToSurface()
|
|||||||
|
|
||||||
startOfSurfacePointPairs_ = number_of_vertices();
|
startOfSurfacePointPairs_ = number_of_vertices();
|
||||||
|
|
||||||
|
// Initialise containers to store the edge conformation locations
|
||||||
DynamicList<point> newEdgeLocations;
|
DynamicList<point> newEdgeLocations;
|
||||||
|
|
||||||
pointField existingEdgeLocations(0);
|
pointField existingEdgeLocations(0);
|
||||||
@ -1669,50 +1651,6 @@ void Foam::conformalVoronoiMesh::conformToSurface()
|
|||||||
// Initialise the edgeLocationTree
|
// Initialise the edgeLocationTree
|
||||||
buildEdgeLocationTree(edgeLocationTree, existingEdgeLocations);
|
buildEdgeLocationTree(edgeLocationTree, existingEdgeLocations);
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
// Test nearFeatureEdgeLocation
|
|
||||||
|
|
||||||
Random rndGen(3412561);
|
|
||||||
|
|
||||||
labelList allNq((identity(10) + 1)*2);
|
|
||||||
|
|
||||||
Info<< allNq << endl;
|
|
||||||
|
|
||||||
label Nt = 250000;
|
|
||||||
|
|
||||||
forAll(allNq, q)
|
|
||||||
{
|
|
||||||
label Nq = allNq[q];
|
|
||||||
|
|
||||||
Info<< nl << "Test nearFeatureEdgeLocation" << nl
|
|
||||||
<< "Nt: " << Nt << ", Nq: " << Nq
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
timeCheck();
|
|
||||||
|
|
||||||
for (label i = 0; i < Nt/Nq; i++)
|
|
||||||
{
|
|
||||||
newEdgeLocations.append(rndGen.vector01());
|
|
||||||
|
|
||||||
for(label j = 0; j < Nq; j++)
|
|
||||||
{
|
|
||||||
nearFeatureEdgeLocation
|
|
||||||
(
|
|
||||||
rndGen.vector01(),
|
|
||||||
newEdgeLocations,
|
|
||||||
existingEdgeLocations,
|
|
||||||
edgeLocationTree
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
timeCheck();
|
|
||||||
|
|
||||||
Info<< "Test nearFeatureEdgeLocation end" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
// Initial surface protrusion conformation - nearest surface point
|
// Initial surface protrusion conformation - nearest surface point
|
||||||
{
|
{
|
||||||
Info<< " EDGE DISTANCE COEFFS HARD-CODED." << endl;
|
Info<< " EDGE DISTANCE COEFFS HARD-CODED." << endl;
|
||||||
@ -1764,7 +1702,10 @@ void Foam::conformalVoronoiMesh::conformToSurface()
|
|||||||
surfaceHits,
|
surfaceHits,
|
||||||
hitSurfaces,
|
hitSurfaces,
|
||||||
featureEdgeHits,
|
featureEdgeHits,
|
||||||
featureEdgeFeaturesHit
|
featureEdgeFeaturesHit,
|
||||||
|
newEdgeLocations,
|
||||||
|
existingEdgeLocations,
|
||||||
|
edgeLocationTree
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1794,7 +1735,7 @@ void Foam::conformalVoronoiMesh::conformToSurface()
|
|||||||
|
|
||||||
label iterationNo = 0;
|
label iterationNo = 0;
|
||||||
|
|
||||||
label maxIterations = 3;
|
label maxIterations = 10;
|
||||||
Info << " MAX ITERATIONS HARD CODED TO "<< maxIterations << endl;
|
Info << " MAX ITERATIONS HARD CODED TO "<< maxIterations << endl;
|
||||||
|
|
||||||
// Set totalHits to a positive value to enter the while loop on the first
|
// Set totalHits to a positive value to enter the while loop on the first
|
||||||
@ -1845,7 +1786,10 @@ void Foam::conformalVoronoiMesh::conformToSurface()
|
|||||||
surfaceHits,
|
surfaceHits,
|
||||||
hitSurfaces,
|
hitSurfaces,
|
||||||
featureEdgeHits,
|
featureEdgeHits,
|
||||||
featureEdgeFeaturesHit
|
featureEdgeFeaturesHit,
|
||||||
|
newEdgeLocations,
|
||||||
|
existingEdgeLocations,
|
||||||
|
edgeLocationTree
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -302,7 +302,10 @@ class conformalVoronoiMesh
|
|||||||
DynamicList<pointIndexHit>& surfaceHits,
|
DynamicList<pointIndexHit>& surfaceHits,
|
||||||
DynamicList<label>& hitSurfaces,
|
DynamicList<label>& hitSurfaces,
|
||||||
DynamicList<pointIndexHit>& featureEdgeHits,
|
DynamicList<pointIndexHit>& featureEdgeHits,
|
||||||
DynamicList<label>& featureEdgeFeaturesHit
|
DynamicList<label>& featureEdgeFeaturesHit,
|
||||||
|
DynamicList<point>& newEdgeLocations,
|
||||||
|
pointField& existingEdgeLocations,
|
||||||
|
autoPtr<indexedOctree<treeDataPoint> >& edgeLocationTree
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Dual calculation
|
//- Dual calculation
|
||||||
|
|||||||
Reference in New Issue
Block a user