diff --git a/src/OpenFOAM/meshes/boundBox/boundBox.H b/src/OpenFOAM/meshes/boundBox/boundBox.H index dec6ae658d..31982faadd 100644 --- a/src/OpenFOAM/meshes/boundBox/boundBox.H +++ b/src/OpenFOAM/meshes/boundBox/boundBox.H @@ -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) diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 34aba6ee12..fdc73aa928 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -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& tree = sizeAndAlignmentTree(); diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index ee067c22ad..dcb0ad5335 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -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 ); diff --git a/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index 1d92c17926..37a57b9bc8 100644 --- a/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -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 ); diff --git a/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H b/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H index b216b7b7db..4124d6500f 100644 --- a/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H +++ b/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H @@ -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 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 diff --git a/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H b/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H index b6a814cf5d..e4ed082531 100644 --- a/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H +++ b/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H @@ -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_; +} + + // ************************************************************************* // diff --git a/src/mesh/conformalVoronoiMesh/cvControls/cvControls.C b/src/mesh/conformalVoronoiMesh/cvControls/cvControls.C index 516fe688dc..7d4690b63d 100644 --- a/src/mesh/conformalVoronoiMesh/cvControls/cvControls.C +++ b/src/mesh/conformalVoronoiMesh/cvControls/cvControls.C @@ -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")); diff --git a/src/mesh/conformalVoronoiMesh/cvControls/cvControls.H b/src/mesh/conformalVoronoiMesh/cvControls/cvControls.H index 5f28f8a92f..083aa46ca9 100644 --- a/src/mesh/conformalVoronoiMesh/cvControls/cvControls.H +++ b/src/mesh/conformalVoronoiMesh/cvControls/cvControls.H @@ -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; diff --git a/src/mesh/conformalVoronoiMesh/cvControls/cvControlsI.H b/src/mesh/conformalVoronoiMesh/cvControls/cvControlsI.H index 4734f1398b..affca47ccb 100644 --- a/src/mesh/conformalVoronoiMesh/cvControls/cvControlsI.H +++ b/src/mesh/conformalVoronoiMesh/cvControls/cvControlsI.H @@ -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_; diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.C b/src/mesh/conformalVoronoiMesh/initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.C index 58f6ceeab9..0e9b3beab4 100644 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.C +++ b/src/mesh/conformalVoronoiMesh/initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.C @@ -91,7 +91,7 @@ std::vector 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())