From fe25191f4593e3e3a025b11057d0f2760e1bf171 Mon Sep 17 00:00:00 2001 From: laurence <laurence> Date: Tue, 30 Jul 2013 15:52:09 +0100 Subject: [PATCH] ENH: foamyHexMesh: Remove some unused functions. Change initialPointMethod constructors --- .../conformalVoronoiMesh.C | 70 ++--------- .../conformalVoronoiMesh.H | 16 --- .../conformalVoronoiMeshConformToSurface.C | 16 ++- .../featurePointConformer.C | 10 +- .../featurePointConformerSpecialisations.C | 12 +- .../autoDensity/autoDensity.C | 117 ++++++++++-------- .../autoDensity/autoDensity.H | 9 +- .../bodyCentredCubic/bodyCentredCubic.C | 49 ++++---- .../bodyCentredCubic/bodyCentredCubic.H | 6 +- .../faceCentredCubic/faceCentredCubic.C | 65 +++++----- .../faceCentredCubic/faceCentredCubic.H | 6 +- .../initialPointsMethod/initialPointsMethod.C | 28 ++++- .../initialPointsMethod/initialPointsMethod.H | 90 +++++++++++--- .../initialPointsMethod/pointFile/pointFile.C | 32 +++-- .../initialPointsMethod/pointFile/pointFile.H | 6 +- .../uniformGrid/uniformGrid.C | 35 ++++-- .../uniformGrid/uniformGrid.H | 6 +- 17 files changed, 339 insertions(+), 234 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 1dd6baffb76..ea024a55fb4 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -849,7 +849,11 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh initialPointsMethod::New ( foamyHexMeshDict.subDict("initialPoints"), - *this + runTime_, + rndGen_, + geometryToConformTo_, + cellShapeControl_, + decomposition_ ) ), relaxationModel_ @@ -1273,7 +1277,11 @@ void Foam::conformalVoronoiMesh::move() { const Foam::point newPt(0.5*(dVA + dVB)); - if (positionOnThisProc(newPt)) + if + ( + Pstream::parRun() + && decomposition().positionOnThisProcessor(newPt) + ) { // Prevent insertions spanning surfaces if (internalPointIsInside(newPt)) @@ -1589,64 +1597,6 @@ void Foam::conformalVoronoiMesh::move() } -bool Foam::conformalVoronoiMesh::positionOnThisProc -( - const Foam::point& pt -) const -{ - if (Pstream::parRun()) - { - return decomposition_().positionOnThisProcessor(pt); - } - - return true; -} - - -Foam::boolList Foam::conformalVoronoiMesh::positionOnThisProc -( - const Foam::List<Foam::point>& pts -) const -{ - if (Pstream::parRun()) - { - return decomposition_().positionOnThisProcessor(pts); - } - - return boolList(pts.size(), true); -} - - -Foam::labelList Foam::conformalVoronoiMesh::positionProc -( - const Foam::List<Foam::point>& pts -) const -{ - if (!Pstream::parRun()) - { - return labelList(pts.size(), -1); - } - - return decomposition_().processorPosition(pts); -} - - -Foam::List<Foam::List<Foam::pointIndexHit> > -Foam::conformalVoronoiMesh::intersectsProc -( - const List<Foam::point>& starts, - const List<Foam::point>& ends -) const -{ - if (!Pstream::parRun()) - { - return List<List<pointIndexHit> >(starts.size()); - } - - return decomposition_().intersectsProcessors(starts, ends, false); -} - - //Foam::labelListList Foam::conformalVoronoiMesh::overlapsProc //( // const List<Foam::point>& centres, diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index 7e78d35557c..dcaf44f9975 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -836,22 +836,6 @@ public: // surface as required void move(); - //- Check if the point is in the domain handled by this processor - bool positionOnThisProc(const Foam::point& pt) const; - - //- Check if the point is in the domain handled by this processor - boolList positionOnThisProc(const Foam::List<Foam::point>& pts) const; - - //- Which processor's domain handles this point - labelList positionProc(const Foam::List<Foam::point>& pts) const; - - //- Which other processors does each line segment intersect - List<List<pointIndexHit> > intersectsProc - ( - const List<Foam::point>& starts, - const List<Foam::point>& ends - ) const; - // //- Which other processors does each sphere overlap // labelListList overlapsProc // ( diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index dec11ef36cb..ba7d0b5782e 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -1336,7 +1336,10 @@ void Foam::conformalVoronoiMesh::dualCellLargestSurfaceProtrusion if ( surfHitLargest.hit() - && !positionOnThisProc(surfHitLargest.hitPoint()) + && ( + Pstream::parRun() + && !decomposition().positionOnThisProcessor(surfHitLargest.hitPoint()) + ) ) { // A protrusion was identified, but not penetrating on this processor, @@ -1434,7 +1437,10 @@ void Foam::conformalVoronoiMesh::dualCellLargestSurfaceIncursion if ( surfHitLargest.hit() - && !positionOnThisProc(surfHitLargest.hitPoint()) + && ( + Pstream::parRun() + && !decomposition().positionOnThisProcessor(surfHitLargest.hitPoint()) + ) ) { // A protrusion was identified, but not penetrating on this processor, @@ -1457,7 +1463,11 @@ void Foam::conformalVoronoiMesh::reportProcessorOccupancy() { if (vit->real()) { - if (!positionOnThisProc(topoint(vit->point()))) + if + ( + Pstream::parRun() + && !decomposition().positionOnThisProcessor(topoint(vit->point())) + ) { Pout<< topoint(vit->point()) << " is not on this processor " << endl; diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C index 9d88745ef8f..542f84afe52 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C @@ -202,7 +202,10 @@ void Foam::featurePointConformer::createMasterAndSlavePoints if ( - !foamyHexMesh_.positionOnThisProc(featPt) + ( + Pstream::parRun() + && !foamyHexMesh_.decomposition().positionOnThisProcessor(featPt) + ) || geometryToConformTo_.outside(featPt) ) { @@ -378,7 +381,10 @@ void Foam::featurePointConformer::createMixedFeaturePoints { const Foam::point& featPt = points[ptI]; - if (!foamyHexMesh_.positionOnThisProc(featPt)) + if + ( + Pstream::parRun() + && !foamyHexMesh_.decomposition().positionOnThisProcessor(featPt)) { continue; } diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformerSpecialisations.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformerSpecialisations.C index a837fb5520a..a3b9f15a15a 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformerSpecialisations.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformerSpecialisations.C @@ -63,7 +63,11 @@ bool Foam::featurePointConformer::createSpecialisedFeaturePoint const Foam::point& featPt = feMesh.points()[ptI]; - if (!foamyHexMesh_.positionOnThisProc(featPt)) + if + ( + Pstream::parRun() + && !foamyHexMesh_.decomposition().positionOnThisProcessor(featPt) + ) { return false; } @@ -402,7 +406,11 @@ bool Foam::featurePointConformer::createSpecialisedFeaturePoint const Foam::point& featPt = feMesh.points()[ptI]; - if (!foamyHexMesh_.positionOnThisProc(featPt)) + if + ( + Pstream::parRun() + && !foamyHexMesh_.decomposition().positionOnThisProcessor(featPt) + ) { return false; } diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C index f128b26e8a3..77b0f868a6d 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C @@ -49,7 +49,7 @@ void Foam::autoDensity::writeOBJ fileName name ) const { - OFstream str(foamyHexMesh_.time().path()/name + ".obj"); + OFstream str(time().path()/name + ".obj"); Pout<< "Writing " << str.name() << endl; @@ -74,11 +74,11 @@ bool Foam::autoDensity::combinedOverlaps(const treeBoundBox& box) const if (Pstream::parRun()) { return - foamyHexMesh_.decomposition().overlapsThisProcessor(box) - || foamyHexMesh_.geometryToConformTo().overlaps(box); + decomposition().overlapsThisProcessor(box) + || geometryToConformTo().overlaps(box); } - return foamyHexMesh_.geometryToConformTo().overlaps(box); + return geometryToConformTo().overlaps(box); } @@ -87,11 +87,11 @@ bool Foam::autoDensity::combinedInside(const point& p) const if (Pstream::parRun()) { return - foamyHexMesh_.decomposition().positionOnThisProcessor(p) - && foamyHexMesh_.geometryToConformTo().inside(p); + decomposition().positionOnThisProcessor(p) + && geometryToConformTo().inside(p); } - return foamyHexMesh_.geometryToConformTo().inside(p); + return geometryToConformTo().inside(p); } @@ -103,7 +103,7 @@ Foam::Field<bool> Foam::autoDensity::combinedWellInside { if (!Pstream::parRun()) { - return foamyHexMesh_.geometryToConformTo().wellInside + return geometryToConformTo().wellInside ( pts, minimumSurfaceDistanceCoeffSqr_*sqr(sizes) @@ -117,7 +117,7 @@ Foam::Field<bool> Foam::autoDensity::combinedWellInside Field<bool> insideA ( - foamyHexMesh_.geometryToConformTo().wellInside + geometryToConformTo().wellInside ( pts, minimumSurfaceDistanceCoeffSqr_*sqr(sizes) @@ -126,7 +126,7 @@ Foam::Field<bool> Foam::autoDensity::combinedWellInside Field<bool> insideB ( - foamyHexMesh_.decomposition().positionOnThisProcessor(pts) + decomposition().positionOnThisProcessor(pts) ); // inside = insideA && insideB; @@ -162,14 +162,14 @@ bool Foam::autoDensity::combinedWellInside if (Pstream::parRun()) { - inside = foamyHexMesh_.decomposition().positionOnThisProcessor(p); + inside = decomposition().positionOnThisProcessor(p); } // Perform AND operation between testing the surfaces and the previous // result, i.e the parallel result, or in serial, with true. inside = inside - && foamyHexMesh_.geometryToConformTo().wellInside + && geometryToConformTo().wellInside ( p, minimumSurfaceDistanceCoeffSqr_*sqr(size) @@ -184,16 +184,19 @@ void Foam::autoDensity::recurseAndFill DynamicList<Vb::Point>& initialPoints, const treeBoundBox& bb, label levelLimit, - word recursionName + word recursionName, + label& nRecursionLevels ) const { + nRecursionLevels++; + for (direction i = 0; i < 8; i++) { treeBoundBox subBB = bb.subBbox(i); word newName = recursionName + "_" + Foam::name(i); - conformalVoronoiMesh::timeCheck(foamyHexMesh_.time(), newName, debug); + conformalVoronoiMesh::timeCheck(time(), newName, debug); if (combinedOverlaps(subBB)) { @@ -204,7 +207,8 @@ void Foam::autoDensity::recurseAndFill initialPoints, subBB, levelLimit - 1, - newName + newName, + nRecursionLevels ); } else @@ -227,7 +231,8 @@ void Foam::autoDensity::recurseAndFill initialPoints, subBB, levelLimit - 1, - newName + newName, + nRecursionLevels ); } } @@ -252,7 +257,8 @@ void Foam::autoDensity::recurseAndFill initialPoints, subBB, levelLimit - 1, - newName + newName, + nRecursionLevels ); } } @@ -278,9 +284,7 @@ bool Foam::autoDensity::fillBox bool overlapping ) const { - const conformationSurfaces& geometry(foamyHexMesh_.geometryToConformTo()); - - Random& rnd = foamyHexMesh_.rndGen(); + const conformationSurfaces& geometry = geometryToConformTo(); unsigned int initialSize = initialPoints.size(); @@ -340,8 +344,7 @@ bool Foam::autoDensity::fillBox pointField corners(bb.points()); - scalarField cornerSizes = - foamyHexMesh_.cellShapeControls().cellSize(corners); + scalarField cornerSizes = cellShapeControls().cellSize(corners); Field<bool> insideCorners = combinedWellInside(corners, cornerSizes); @@ -450,8 +453,7 @@ bool Foam::autoDensity::fillBox ); } - lineSizes = - foamyHexMesh_.cellShapeControls().cellSize(linePoints); + lineSizes = cellShapeControls().cellSize(linePoints); Field<bool> insideLines = combinedWellInside ( @@ -537,9 +539,9 @@ bool Foam::autoDensity::fillBox min + vector ( - delta.x()*(i + 0.5 + 0.1*(rnd.scalar01() - 0.5)), - delta.y()*(j + 0.5 + 0.1*(rnd.scalar01() - 0.5)), - delta.z()*(k + 0.5 + 0.1*(rnd.scalar01() - 0.5)) + delta.x()*(i + 0.5 + 0.1*(rndGen().scalar01() - 0.5)), + delta.y()*(j + 0.5 + 0.1*(rndGen().scalar01() - 0.5)), + delta.z()*(k + 0.5 + 0.1*(rndGen().scalar01() - 0.5)) ); } } @@ -550,10 +552,7 @@ bool Foam::autoDensity::fillBox // corner when only some these points are required. shuffle(samplePoints); - scalarField sampleSizes = foamyHexMesh_.cellShapeControls().cellSize - ( - samplePoints - ); + scalarField sampleSizes = cellShapeControls().cellSize(samplePoints); Field<bool> insidePoints = combinedWellInside ( @@ -647,7 +646,7 @@ bool Foam::autoDensity::fillBox // TODO - is there a lot of cost in the 1/density calc? Could // assess on // (1/maxDensity)/(1/localDensity) = minVolume/localVolume - if (localDensity/maxDensity > rnd.scalar01()) + if (localDensity/maxDensity > rndGen().scalar01()) { scalar localVolume = 1/localDensity; @@ -660,7 +659,7 @@ bool Foam::autoDensity::fillBox scalar addProbability = (totalVolume - volumeAdded)/localVolume; - scalar r = rnd.scalar01(); + scalar r = rndGen().scalar01(); if (debug) { @@ -714,9 +713,9 @@ bool Foam::autoDensity::fillBox { trialPoints++; - point p = min + cmptMultiply(span, rnd.vector01()); + point p = min + cmptMultiply(span, rndGen().vector01()); - scalar localSize = foamyHexMesh_.cellShapeControls().cellSize(p); + scalar localSize = cellShapeControls().cellSize(p); bool insidePoint = false; @@ -770,7 +769,7 @@ bool Foam::autoDensity::fillBox // Accept possible placements proportional to the relative local // density - if (localDensity/maxDensity > rnd.scalar01()) + if (localDensity/maxDensity > rndGen().scalar01()) { scalar localVolume = 1/localDensity; @@ -783,7 +782,7 @@ bool Foam::autoDensity::fillBox scalar addProbability = (totalVolume - volumeAdded)/localVolume; - scalar r = rnd.scalar01(); + scalar r = rndGen().scalar01(); if (debug) { @@ -847,10 +846,23 @@ bool Foam::autoDensity::fillBox autoDensity::autoDensity ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ) : - initialPointsMethod(typeName, initialPointsDict, foamyHexMesh), + initialPointsMethod + ( + typeName, + initialPointsDict, + runTime, + rndGen, + geometryToConformTo, + cellShapeControls, + decomposition + ), globalTrialPoints_(0), minCellSizeLimit_ ( @@ -875,8 +887,7 @@ autoDensity::autoDensity "const dictionary& initialPointsDict," "const conformalVoronoiMesh& foamyHexMesh" ")" - ) - << "The maxSizeRatio must be greater than one to be sensible, " + ) << "The maxSizeRatio must be greater than one to be sensible, " << "setting to " << maxSizeRatio_ << endl; } @@ -893,14 +904,14 @@ List<Vb::Point> autoDensity::initialPoints() const // on whether this is a parallel run. if (Pstream::parRun()) { - hierBB = foamyHexMesh_.decomposition().procBounds(); + hierBB = decomposition().procBounds(); } else { // Extend the global box to move it off large plane surfaces - hierBB = foamyHexMesh_.geometryToConformTo().globalBounds().extend + hierBB = geometryToConformTo().globalBounds().extend ( - foamyHexMesh_.rndGen(), + rndGen(), 1e-6 ); } @@ -914,12 +925,15 @@ List<Vb::Point> autoDensity::initialPoints() const Pout<< " Filling box " << hierBB << endl; } + label nRecursionLevels = 0; + recurseAndFill ( initialPoints, hierBB, minLevels_ - 1, - "recursionBox" + "recursionBox", + nRecursionLevels ); initialPoints.shrink(); @@ -932,11 +946,16 @@ List<Vb::Point> autoDensity::initialPoints() const reduce(globalTrialPoints_, sumOp<label>()); } - Info<< " " << nInitialPoints << " points placed" << nl - << " " << globalTrialPoints_ << " locations queried" << nl - << " " + Info<< incrIndent << incrIndent + << indent << nInitialPoints << " points placed" << nl + << indent << globalTrialPoints_ << " locations queried" << nl + << indent << scalar(nInitialPoints)/scalar(max(globalTrialPoints_, 1)) - << " success rate" + << " success rate" << nl + << indent + << returnReduce(nRecursionLevels, maxOp<label>()) + << " levels of recursion (maximum)" + << decrIndent << decrIndent << endl; return initialPoints; diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.H index 6a547be49e2..8a7fe5805de 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.H @@ -119,7 +119,8 @@ private: DynamicList<Vb::Point>& initialPoints, const treeBoundBox& bb, label levelLimit, - word recursionName + word recursionName, + label& nRecursionLevels ) const; //- Fill the given box, optionally filling surface overlapping boxes. @@ -144,7 +145,11 @@ public: autoDensity ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ); diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C index 7237d2980a8..e814193fb7f 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C @@ -41,10 +41,23 @@ addToRunTimeSelectionTable(initialPointsMethod, bodyCentredCubic, dictionary); bodyCentredCubic::bodyCentredCubic ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ) : - initialPointsMethod(typeName, initialPointsDict, foamyHexMesh), + initialPointsMethod + ( + typeName, + initialPointsDict, + runTime, + rndGen, + geometryToConformTo, + cellShapeControls, + decomposition + ), initialCellSize_(readScalar(detailsDict().lookup("initialCellSize"))), randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")), randomPerturbationCoeff_ @@ -64,11 +77,11 @@ List<Vb::Point> bodyCentredCubic::initialPoints() const // on whether this is a parallel run. if (Pstream::parRun()) { - bb = foamyHexMesh_.decomposition().procBounds(); + bb = decomposition().procBounds(); } else { - bb = foamyHexMesh_.geometryToConformTo().globalBounds(); + bb = geometryToConformTo().globalBounds(); } scalar x0 = bb.min().x(); @@ -87,8 +100,6 @@ List<Vb::Point> bodyCentredCubic::initialPoints() const delta *= pow((1.0/2.0),-(1.0/3.0)); - Random& rndGen = foamyHexMesh_.rndGen(); - scalar pert = randomPerturbationCoeff_*cmptMin(delta); DynamicList<Vb::Point> initialPoints(ni*nj*nk/10); @@ -118,17 +129,14 @@ List<Vb::Point> bodyCentredCubic::initialPoints() const if (randomiseInitialGrid_) { - pA.x() += pert*(rndGen.scalar01() - 0.5); - pA.y() += pert*(rndGen.scalar01() - 0.5); - pA.z() += pert*(rndGen.scalar01() - 0.5); + pA.x() += pert*(rndGen().scalar01() - 0.5); + pA.y() += pert*(rndGen().scalar01() - 0.5); + pA.z() += pert*(rndGen().scalar01() - 0.5); } - const backgroundMeshDecomposition& decomp = - foamyHexMesh_.decomposition(); - if (Pstream::parRun()) { - if (decomp.positionOnThisProcessor(pA)) + if (decomposition().positionOnThisProcessor(pA)) { // Add this point in parallel only if this position is // on this processor. @@ -142,14 +150,14 @@ List<Vb::Point> bodyCentredCubic::initialPoints() const if (randomiseInitialGrid_) { - pB.x() += pert*(rndGen.scalar01() - 0.5); - pB.y() += pert*(rndGen.scalar01() - 0.5); - pB.z() += pert*(rndGen.scalar01() - 0.5); + pB.x() += pert*(rndGen().scalar01() - 0.5); + pB.y() += pert*(rndGen().scalar01() - 0.5); + pB.z() += pert*(rndGen().scalar01() - 0.5); } if (Pstream::parRun()) { - if (decomp.positionOnThisProcessor(pB)) + if (decomposition().positionOnThisProcessor(pB)) { // Add this point in parallel only if this position is // on this processor. @@ -165,14 +173,11 @@ List<Vb::Point> bodyCentredCubic::initialPoints() const points.setSize(pI); Field<bool> insidePoints = - foamyHexMesh_.geometryToConformTo().wellInside + geometryToConformTo().wellInside ( points, minimumSurfaceDistanceCoeffSqr_ - *sqr - ( - foamyHexMesh_.cellShapeControls().cellSize(points) - ) + *sqr(cellShapeControls().cellSize(points)) ); forAll(insidePoints, i) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.H index 507c718bb6c..a52924385a1 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.H @@ -77,7 +77,11 @@ public: bodyCentredCubic ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ); diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.C index 9a6642170dd..a9f96cfc599 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.C @@ -41,10 +41,23 @@ addToRunTimeSelectionTable(initialPointsMethod, faceCentredCubic, dictionary); faceCentredCubic::faceCentredCubic ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ) : - initialPointsMethod(typeName, initialPointsDict, foamyHexMesh), + initialPointsMethod + ( + typeName, + initialPointsDict, + runTime, + rndGen, + geometryToConformTo, + cellShapeControls, + decomposition + ), initialCellSize_(readScalar(detailsDict().lookup("initialCellSize"))), randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")), randomPerturbationCoeff_ @@ -64,11 +77,11 @@ List<Vb::Point> faceCentredCubic::initialPoints() const // on whether this is a parallel run. if (Pstream::parRun()) { - bb = foamyHexMesh_.decomposition().procBounds(); + bb = decomposition().procBounds(); } else { - bb = foamyHexMesh_.geometryToConformTo().globalBounds(); + bb = geometryToConformTo().globalBounds(); } scalar x0 = bb.min().x(); @@ -87,8 +100,6 @@ List<Vb::Point> faceCentredCubic::initialPoints() const delta *= pow((1.0/4.0),-(1.0/3.0)); - Random& rndGen = foamyHexMesh_.rndGen(); - scalar pert = randomPerturbationCoeff_*cmptMin(delta); DynamicList<Vb::Point> initialPoints(ni*nj*nk/10); @@ -116,17 +127,14 @@ List<Vb::Point> faceCentredCubic::initialPoints() const if (randomiseInitialGrid_) { - p.x() += pert*(rndGen.scalar01() - 0.5); - p.y() += pert*(rndGen.scalar01() - 0.5); - p.z() += pert*(rndGen.scalar01() - 0.5); + p.x() += pert*(rndGen().scalar01() - 0.5); + p.y() += pert*(rndGen().scalar01() - 0.5); + p.z() += pert*(rndGen().scalar01() - 0.5); } - const backgroundMeshDecomposition& decomp = - foamyHexMesh_.decomposition(); - if (Pstream::parRun()) { - if (decomp.positionOnThisProcessor(p)) + if (decomposition().positionOnThisProcessor(p)) { // Add this point in parallel only if this position is // on this processor. @@ -147,14 +155,14 @@ List<Vb::Point> faceCentredCubic::initialPoints() const if (randomiseInitialGrid_) { - p.x() += pert*(rndGen.scalar01() - 0.5); - p.y() += pert*(rndGen.scalar01() - 0.5); - p.z() += pert*(rndGen.scalar01() - 0.5); + p.x() += pert*(rndGen().scalar01() - 0.5); + p.y() += pert*(rndGen().scalar01() - 0.5); + p.z() += pert*(rndGen().scalar01() - 0.5); } if (Pstream::parRun()) { - if (decomp.positionOnThisProcessor(p)) + if (decomposition().positionOnThisProcessor(p)) { // Add this point in parallel only if this position is // on this processor. @@ -175,14 +183,14 @@ List<Vb::Point> faceCentredCubic::initialPoints() const if (randomiseInitialGrid_) { - p.x() += pert*(rndGen.scalar01() - 0.5); - p.y() += pert*(rndGen.scalar01() - 0.5); - p.z() += pert*(rndGen.scalar01() - 0.5); + p.x() += pert*(rndGen().scalar01() - 0.5); + p.y() += pert*(rndGen().scalar01() - 0.5); + p.z() += pert*(rndGen().scalar01() - 0.5); } if (Pstream::parRun()) { - if (decomp.positionOnThisProcessor(p)) + if (decomposition().positionOnThisProcessor(p)) { // Add this point in parallel only if this position is // on this processor. @@ -203,14 +211,14 @@ List<Vb::Point> faceCentredCubic::initialPoints() const if (randomiseInitialGrid_) { - p.x() += pert*(rndGen.scalar01() - 0.5); - p.y() += pert*(rndGen.scalar01() - 0.5); - p.z() += pert*(rndGen.scalar01() - 0.5); + p.x() += pert*(rndGen().scalar01() - 0.5); + p.y() += pert*(rndGen().scalar01() - 0.5); + p.z() += pert*(rndGen().scalar01() - 0.5); } if (Pstream::parRun()) { - if (decomp.positionOnThisProcessor(p)) + if (decomposition().positionOnThisProcessor(p)) { // Add this point in parallel only if this position is // on this processor. @@ -226,14 +234,11 @@ List<Vb::Point> faceCentredCubic::initialPoints() const points.setSize(pI); Field<bool> insidePoints = - foamyHexMesh_.geometryToConformTo().wellInside + geometryToConformTo().wellInside ( points, minimumSurfaceDistanceCoeffSqr_ - *sqr - ( - foamyHexMesh_.cellShapeControls().cellSize(points) - ) + *sqr(cellShapeControls().cellSize(points)) ); forAll(insidePoints, i) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.H index 9a426c46666..ca7d9210877 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.H @@ -77,7 +77,11 @@ public: faceCentredCubic ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ); diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C index f85d23865f6..c8a8261a402 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.C @@ -43,11 +43,19 @@ initialPointsMethod::initialPointsMethod ( const word& type, const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ) : dictionary(initialPointsDict), - foamyHexMesh_(foamyHexMesh), + runTime_(runTime), + rndGen_(rndGen), + geometryToConformTo_(geometryToConformTo), + cellShapeControls_(cellShapeControls), + decomposition_(decomposition), detailsDict_(subDict(type + "Coeffs")), minimumSurfaceDistanceCoeffSqr_ ( @@ -68,7 +76,11 @@ initialPointsMethod::initialPointsMethod autoPtr<initialPointsMethod> initialPointsMethod::New ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ) { word initialPointsMethodTypeName @@ -99,7 +111,15 @@ autoPtr<initialPointsMethod> initialPointsMethod::New return autoPtr<initialPointsMethod> ( - cstrIter()(initialPointsDict, foamyHexMesh) + cstrIter() + ( + initialPointsDict, + runTime, + rndGen, + geometryToConformTo, + cellShapeControls, + decomposition + ) ); } diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.H index 362f33c0ef8..db8e8380f92 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/initialPointsMethod/initialPointsMethod.H @@ -62,8 +62,15 @@ protected: // Protected data - //- Reference to the conformalVoronoiMesh holding this object - const conformalVoronoiMesh& foamyHexMesh_; + const Time& runTime_; + + Random& rndGen_; + + const conformationSurfaces& geometryToConformTo_; + + const cellShapeControl& cellShapeControls_; + + const autoPtr<backgroundMeshDecomposition>& decomposition_; //- Method details dictionary dictionary detailsDict_; @@ -102,9 +109,20 @@ public: dictionary, ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ), - (initialPointsDict, foamyHexMesh) + ( + initialPointsDict, + runTime, + rndGen, + geometryToConformTo, + cellShapeControls, + decomposition + ) ); @@ -115,7 +133,11 @@ public: ( const word& type, const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ); @@ -125,7 +147,11 @@ public: static autoPtr<initialPointsMethod> New ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ); @@ -135,19 +161,49 @@ public: // Member Functions - //- Const access to the details dictionary - const dictionary& detailsDict() const - { - return detailsDict_; - } + // Access + + const Time& time() const + { + return runTime_; + } + + Random& rndGen() const + { + return rndGen_; + } + + const conformationSurfaces& geometryToConformTo() const + { + return geometryToConformTo_; + } + + const cellShapeControl& cellShapeControls() const + { + return cellShapeControls_; + } + + const backgroundMeshDecomposition& decomposition() const + { + return decomposition_; + } + + //- Const access to the details dictionary + const dictionary& detailsDict() const + { + return detailsDict_; + } + + Switch fixInitialPoints() const + { + return fixInitialPoints_; + } + - Switch fixInitialPoints() const - { - return fixInitialPoints_; - } + // Queries - //- Return the initial points for the conformalVoronoiMesh - virtual List<Vb::Point> initialPoints() const = 0; + //- Return the initial points for the conformalVoronoiMesh + virtual List<Vb::Point> initialPoints() const = 0; }; diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C index a44103923b4..b3eb0396606 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C @@ -41,10 +41,23 @@ addToRunTimeSelectionTable(initialPointsMethod, pointFile, dictionary); pointFile::pointFile ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ) : - initialPointsMethod(typeName, initialPointsDict, foamyHexMesh), + initialPointsMethod + ( + typeName, + initialPointsDict, + runTime, + rndGen, + geometryToConformTo, + cellShapeControls, + decomposition + ), pointFileName_(detailsDict().lookup("pointFile")) {} @@ -58,8 +71,8 @@ List<Vb::Point> pointFile::initialPoints() const IOobject ( pointFileName_.name(), - foamyHexMesh_.time().timeName(), - foamyHexMesh_.time(), + time().timeName(), + time(), IOobject::MUST_READ, IOobject::NO_WRITE ) @@ -85,13 +98,13 @@ List<Vb::Point> pointFile::initialPoints() const if (!isParentFile) { - foamyHexMesh_.decomposition().distributePoints(points); + decomposition().distributePoints(points); } else { // Otherwise, this is assumed to be points covering the whole // domain, so filter the points to be only those on this processor - boolList procPt(foamyHexMesh_.positionOnThisProc(points)); + boolList procPt(decomposition().positionOnThisProcessor(points)); List<boolList> allProcPt(Pstream::nProcs()); @@ -126,14 +139,11 @@ List<Vb::Point> pointFile::initialPoints() const } } - Field<bool> insidePoints = foamyHexMesh_.geometryToConformTo().wellInside + Field<bool> insidePoints = geometryToConformTo().wellInside ( points, minimumSurfaceDistanceCoeffSqr_ - *sqr - ( - foamyHexMesh_.cellShapeControls().cellSize(points) - ) + *sqr(cellShapeControls().cellSize(points)) ); DynamicList<Vb::Point> initialPoints(insidePoints.size()/10); diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.H index 05cc0bc4885..8595417c2ca 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.H @@ -73,7 +73,11 @@ public: pointFile ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ); diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C index 567188549df..fc4d5a2d968 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C @@ -41,10 +41,23 @@ addToRunTimeSelectionTable(initialPointsMethod, uniformGrid, dictionary); uniformGrid::uniformGrid ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ) : - initialPointsMethod(typeName, initialPointsDict, foamyHexMesh), + initialPointsMethod + ( + typeName, + initialPointsDict, + runTime, + rndGen, + geometryToConformTo, + cellShapeControls, + decomposition + ), initialCellSize_(readScalar(detailsDict().lookup("initialCellSize"))), randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")), randomPerturbationCoeff_ @@ -64,11 +77,11 @@ List<Vb::Point> uniformGrid::initialPoints() const // on whether this is a parallel run. if (Pstream::parRun()) { - bb = foamyHexMesh_.decomposition().procBounds(); + bb = decomposition().procBounds(); } else { - bb = foamyHexMesh_.geometryToConformTo().globalBounds(); + bb = geometryToConformTo().globalBounds(); } scalar x0 = bb.min().x(); @@ -87,8 +100,6 @@ List<Vb::Point> uniformGrid::initialPoints() const delta *= pow((1.0),-(1.0/3.0)); - Random& rndGen = foamyHexMesh_.rndGen(); - scalar pert = randomPerturbationCoeff_*cmptMin(delta); // Initialise points list @@ -117,15 +128,15 @@ List<Vb::Point> uniformGrid::initialPoints() const if (randomiseInitialGrid_) { - p.x() += pert*(rndGen.scalar01() - 0.5); - p.y() += pert*(rndGen.scalar01() - 0.5); - p.z() += pert*(rndGen.scalar01() - 0.5); + p.x() += pert*(rndGen().scalar01() - 0.5); + p.y() += pert*(rndGen().scalar01() - 0.5); + p.z() += pert*(rndGen().scalar01() - 0.5); } if ( Pstream::parRun() - && !foamyHexMesh_.decomposition().positionOnThisProcessor(p) + && !decomposition().positionOnThisProcessor(p) ) { // Skip this point if, in parallel, this position is not on @@ -139,13 +150,13 @@ List<Vb::Point> uniformGrid::initialPoints() const points.setSize(pI); Field<bool> insidePoints = - foamyHexMesh_.geometryToConformTo().wellInside + geometryToConformTo().wellInside ( points, minimumSurfaceDistanceCoeffSqr_ *sqr ( - foamyHexMesh_.cellShapeControls().cellSize(points) + cellShapeControls().cellSize(points) ) ); diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.H index 4782e98533f..be3a7b1fa2e 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.H @@ -77,7 +77,11 @@ public: uniformGrid ( const dictionary& initialPointsDict, - const conformalVoronoiMesh& foamyHexMesh + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr<backgroundMeshDecomposition>& decomposition ); -- GitLab