mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: cvMesh: Initial code for required cell size in the style of required alignment
This commit is contained in:
@ -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]);
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user