ENH: Moving span to geometry. Better far point generation.

This commit is contained in:
graham
2010-09-29 17:34:40 +01:00
parent a130676ca8
commit 16e37ad581
10 changed files with 53 additions and 55 deletions

View File

@ -137,7 +137,7 @@ public:
//- The midpoint of the bounding box
point midpoint() const
{
return 0.5 * (max_ + min_);
return 0.5*(max_ + min_);
}
//- The bounding box span (from minimum to maximum)

View File

@ -136,7 +136,7 @@ Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment
geometryToConformTo_.findSurfaceNearest
(
pt,
cvMeshControls().spanSqr(),
geometryToConformTo_.spanMagSqr(),
surfHit,
hitSurface
);
@ -186,7 +186,7 @@ Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment
0
);
spoke *= cvMeshControls().span();
spoke *= geometryToConformTo_.spanMag();
spoke = Rp & spoke;
@ -569,16 +569,21 @@ void Foam::conformalVoronoiMesh::createFeaturePoints()
{
Info<< nl << "Creating bounding points" << endl;
scalar bigSpan = 10*cvMeshControls().span();
pointField farPts = geometryToConformTo_.bounds().corners();
insertPoint(point(-bigSpan, -bigSpan, -bigSpan), Vb::ptFarPoint);
insertPoint(point(-bigSpan, -bigSpan, bigSpan), Vb::ptFarPoint);
insertPoint(point(-bigSpan, bigSpan, -bigSpan), Vb::ptFarPoint);
insertPoint(point(-bigSpan, bigSpan, bigSpan), Vb::ptFarPoint);
insertPoint(point( bigSpan, -bigSpan, -bigSpan), Vb::ptFarPoint);
insertPoint(point( bigSpan, -bigSpan, bigSpan), Vb::ptFarPoint);
insertPoint(point( bigSpan, bigSpan, -bigSpan), Vb::ptFarPoint);
insertPoint(point( bigSpan, bigSpan , bigSpan), Vb::ptFarPoint);
// Shift corners of bounds relative to origin
farPts -= geometryToConformTo_.bounds().midpoint();
// Scale the box up
farPts *= 10.0;
// Shift corners of bounds back to be relative to midpoint
farPts += geometryToConformTo_.bounds().midpoint();
forAll(farPts, fPI)
{
insertPoint(farPts[fPI], Vb::ptFarPoint);
}
Info<< nl << "Conforming to feature points" << endl;
@ -950,7 +955,7 @@ void Foam::conformalVoronoiMesh::setVertexSizeAndAlignment()
{
Info<< nl << "Looking up target cell alignment and size" << endl;
scalar spanSqr = cvMeshControls().spanSqr();
scalar spanSqr = geometryToConformTo_.spanMagSqr();
const indexedOctree<treeDataPoint>& tree = sizeAndAlignmentTree();

View File

@ -553,7 +553,7 @@ void Foam::conformalVoronoiMesh::smoothSurface
geometryToConformTo_.findSurfaceNearest
(
pt,
cvMeshControls().spanSqr(),
geometryToConformTo_.spanMagSqr(),
surfHit,
hitSurface
);
@ -642,7 +642,7 @@ Foam::label Foam::conformalVoronoiMesh::smoothSurfaceDualFaces
geometryToConformTo_.findSurfaceNearest
(
dualFace.centre(pts),
cvMeshControls().spanSqr(),
geometryToConformTo_.spanMagSqr(),
surfHit,
hitSurface
);

View File

@ -45,6 +45,8 @@ Foam::conformationSurfaces::conformationSurfaces
patchNames_(0),
patchOffsets_(),
bounds_(),
spanMag_(),
spanMagSqr_(),
referenceVolumeTypes_(0)
{
const dictionary& surfacesDict
@ -166,6 +168,10 @@ Foam::conformationSurfaces::conformationSurfaces
bounds_ = searchableSurfacesQueries::bounds(allGeometry_, surfaces_);
spanMag_ = bounds_.mag();
spanMagSqr_ = sqr(spanMag_);
// Look at all surfaces at determine whether the locationInMesh point is
// inside or outside each, to establish a signature for the domain to be
// meshed.
@ -667,7 +673,7 @@ Foam::label Foam::conformationSurfaces::findPatch(const point& pt) const
findSurfaceNearest
(
pt,
cvMesh_.cvMeshControls().spanSqr(),
spanMagSqr_,
surfHit,
hitSurface
);

View File

@ -93,6 +93,13 @@ class conformationSurfaces
//- The overall boundBox of all of the surfaces to be conformed to
boundBox bounds_;
//- Magnitude of the span of the domain
scalar spanMag_;
//- Square of span_
scalar spanMagSqr_;
//- The pattern/signature of volumeTypes representing a point in the
// domain to be meshed
List<searchableSurface::volumeType> referenceVolumeTypes_;
@ -144,6 +151,12 @@ public:
//- Return the boundBox
inline const boundBox& bounds() const;
//- Return the spanMag
inline scalar spanMag() const;
//- Return spanSqr
inline scalar spanMagSqr() const;
// Query

View File

@ -56,4 +56,16 @@ const Foam::boundBox& Foam::conformationSurfaces::bounds() const
}
inline Foam::scalar Foam::conformationSurfaces::spanMag() const
{
return spanMag_;
}
inline Foam::scalar Foam::conformationSurfaces::spanMagSqr() const
{
return spanMagSqr_;
}
// ************************************************************************* //

View File

@ -37,17 +37,6 @@ Foam::cvControls::cvControls
cvMesh_(cvMesh),
cvMeshDict_(cvMeshDict)
{
// General parameters
const boundBox& bb = cvMesh_.geometryToConformTo().bounds();
span_ =
max(mag(bb.max().x()), mag(bb.min().x()))
+ max(mag(bb.max().y()), mag(bb.min().y()))
+ max(mag(bb.max().z()), mag(bb.min().z()));
spanSqr_ = sqr(span_);
// Surface conformation controls
const dictionary& surfDict(cvMeshDict_.subDict("surfaceConformation"));

View File

@ -60,15 +60,6 @@ class cvControls
//- Reference to the cvMeshDict
const dictionary& cvMeshDict_;
// General parameters
//- Span of the domain
scalar span_;
//- Square of span_
scalar spanSqr_;
// Surface conformation controls
//- Point pair spacing coefficient - fraction of the local target
@ -301,12 +292,6 @@ public:
//- Return the cvMeshDict
inline const dictionary& cvMeshDict() const;
//- Return the span
inline scalar span() const;
//- Return spanSqr
inline scalar spanSqr() const;
//- Return the pointPairDistanceCoeff
inline scalar pointPairDistanceCoeff() const;

View File

@ -31,18 +31,6 @@ inline const Foam::dictionary& Foam::cvControls::cvMeshDict() const
}
inline Foam::scalar Foam::cvControls::span() const
{
return span_;
}
inline Foam::scalar Foam::cvControls::spanSqr() const
{
return spanSqr_;
}
inline Foam::scalar Foam::cvControls::pointPairDistanceCoeff() const
{
return pointPairDistanceCoeff_;

View File

@ -91,7 +91,7 @@ std::vector<Vb::Point> densityWeightedStochastic::initialPoints() const
scalar localSize = cvMesh_.cellSizeControl().cellSize(p);
scalar localDensity = 1/pow3(max(localSize, VSMALL));
scalar localDensity = 1/pow3(max(localSize, SMALL));
// Accept possible placements proportional to the relative local density
if (localDensity/maxDensity_ > rndGen.scalar01())