diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 1dd6baffb7..ea024a55fb 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& pts -) const -{ - if (Pstream::parRun()) - { - return decomposition_().positionOnThisProcessor(pts); - } - - return boolList(pts.size(), true); -} - - -Foam::labelList Foam::conformalVoronoiMesh::positionProc -( - const Foam::List& pts -) const -{ - if (!Pstream::parRun()) - { - return labelList(pts.size(), -1); - } - - return decomposition_().processorPosition(pts); -} - - -Foam::List > -Foam::conformalVoronoiMesh::intersectsProc -( - const List& starts, - const List& ends -) const -{ - if (!Pstream::parRun()) - { - return List >(starts.size()); - } - - return decomposition_().intersectsProcessors(starts, ends, false); -} - - //Foam::labelListList Foam::conformalVoronoiMesh::overlapsProc //( // const List& centres, diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index 7e78d35557..dcaf44f997 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& pts) const; - - //- Which processor's domain handles this point - labelList positionProc(const Foam::List& pts) const; - - //- Which other processors does each line segment intersect - List > intersectsProc - ( - const List& starts, - const List& 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 dec11ef36c..ba7d0b5782 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 9d88745ef8..542f84afe5 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 a837fb5520..a3b9f15a15 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 f128b26e8a..77b0f868a6 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 Foam::autoDensity::combinedWellInside { if (!Pstream::parRun()) { - return foamyHexMesh_.geometryToConformTo().wellInside + return geometryToConformTo().wellInside ( pts, minimumSurfaceDistanceCoeffSqr_*sqr(sizes) @@ -117,7 +117,7 @@ Foam::Field Foam::autoDensity::combinedWellInside Field insideA ( - foamyHexMesh_.geometryToConformTo().wellInside + geometryToConformTo().wellInside ( pts, minimumSurfaceDistanceCoeffSqr_*sqr(sizes) @@ -126,7 +126,7 @@ Foam::Field Foam::autoDensity::combinedWellInside Field 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& 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 insideCorners = combinedWellInside(corners, cornerSizes); @@ -450,8 +453,7 @@ bool Foam::autoDensity::fillBox ); } - lineSizes = - foamyHexMesh_.cellShapeControls().cellSize(linePoints); + lineSizes = cellShapeControls().cellSize(linePoints); Field 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 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& 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 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 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 autoDensity::initialPoints() const reduce(globalTrialPoints_, sumOp