diff --git a/etc/controlDict b/etc/controlDict index 7041fc67999ae0436d11e3b8e2d6debb3b7cb40c..a4880c4b9d8ce4db631a39b8bd6bfe7d037447b9 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -302,6 +302,7 @@ DebugSwitches ash 0; atomizationModel 0; attachDetach 0; + autoDensity 0; autoHexMeshDriver 0; autoLayerDriver 0; autoRefineDriver 0; @@ -530,7 +531,6 @@ DebugSwitches hhuMixtureThermo<veryInhomogeneousMixture<constTransport<specieThermo<hConstThermo<perfectGas>>>>> 0; hhuMixtureThermo<veryInhomogeneousMixture<sutherlandTransport<specieThermo<janafThermo<perfectGas>>>>> 0; hierarchical 0; - hierarchicalDensityWeightedStochastic 0; hollowConeInjector 0; iC3H8O 0; indexedOctree 0; diff --git a/src/mesh/conformalVoronoiMesh/Make/files b/src/mesh/conformalVoronoiMesh/Make/files index 21757ef3fa19643ffde19d3351ab327789c3415e..29305c3320e3620372a63a9bea4c126aea8bed4b 100644 --- a/src/mesh/conformalVoronoiMesh/Make/files +++ b/src/mesh/conformalVoronoiMesh/Make/files @@ -27,8 +27,7 @@ initialPointsMethod/uniformGrid/uniformGrid.C initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C initialPointsMethod/faceCentredCubic/faceCentredCubic.C initialPointsMethod/pointFile/pointFile.C -initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.C -initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.C +initialPointsMethod/autoDensity/autoDensity.C relaxationModel/relaxationModel/relaxationModel.C relaxationModel/adaptiveLinear/adaptiveLinear.C diff --git a/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index 69fdc97015e0df0bcfe292542658722bae4c6211..5b1c0417f83b82c431d29b61a6fc7c05f9c301a2 100644 --- a/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -989,11 +989,11 @@ Foam::backgroundMeshDecomposition::distribute if (newCellI == -1) { - Pout<< "findCell backgroundMeshDecomposition " - << v << " " - << oldCellI - << newCellI - << " find nearest cellI "; + // Pout<< "findCell backgroundMeshDecomposition " + // << v << " " + // << oldCellI + // << newCellI + // << " find nearest cellI "; newCellI = cellSearch.findNearestCell(v); @@ -1150,6 +1150,14 @@ Foam::boolList Foam::backgroundMeshDecomposition::positionOnThisProcessor return posProc; } +bool Foam::backgroundMeshDecomposition::overlapsThisProcessor +( + const treeBoundBox& box +) const +{ + return !bFTreePtr_().findBox(box).empty(); +} + Foam::pointIndexHit Foam::backgroundMeshDecomposition::findLine ( diff --git a/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H b/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H index c3f9361f4e57dca38e50304cce7511f975a75cf1..c31f1bc2b538df48642b1752d5cbfe8346d2d649 100644 --- a/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H +++ b/src/mesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H @@ -225,6 +225,10 @@ public: //- Are the given positions inside the domain of this decomposition boolList positionOnThisProcessor(const List<point>& pts) const; + //- Does the given box overlap the faces of the bounday of this + // processor + bool overlapsThisProcessor(const treeBoundBox& box) const; + //- Find nearest intersection of line between start and end, (exposing // underlying indexedOctree) pointIndexHit findLine diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 7d30b9bf93e82b1daa3ffe3745665218549dce96..3f29ba0941d53f7ee1733fb31aa6b1e173c741e5 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -1331,12 +1331,13 @@ bool Foam::conformalVoronoiMesh::distributeBackground() if (cellI == -1) { - Pout<< "findCell conformalVoronoiMesh::distribute findCell " - << vit->type() << " " - << vit->index() << " " - << v << " " - << cellI - << " find nearest cellI "; + // Pout<< "findCell conformalVoronoiMesh::distribute " + // << "findCell " + // << vit->type() << " " + // << vit->index() << " " + // << v << " " + // << cellI + // << " find nearest cellI "; cellI = cellSearch.findNearestCell(v); @@ -1916,7 +1917,7 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh // Report any Delaunay vertices that do not think that they are in the // domain the processor they are on. - reportProcessorOccupancy(); + // reportProcessorOccupancy(); if(cvMeshControls().objOutput()) { diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H index 73603ff184ad1ca31089a2ab6132b589c89531b8..e020b3811796dbf47b2e17940545940157f52035 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H @@ -472,6 +472,17 @@ Foam::conformalVoronoiMesh::geometryToConformTo() const inline const Foam::backgroundMeshDecomposition& Foam::conformalVoronoiMesh::decomposition() const { + if (!Pstream::parRun()) + { + FatalErrorIn + ( + "inline const Foam::backgroundMeshDecomposition& " + "Foam::conformalVoronoiMesh::decomposition() const" + ) + << "The backgroundMeshDecomposition cannot be asked for in serial." + << exit(FatalError) << endl; + } + return decomposition_(); } diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.C b/src/mesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C similarity index 69% rename from src/mesh/conformalVoronoiMesh/initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.C rename to src/mesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C index 2c4d18eea7ab42b9f6db917c3c825c1b646a60c3..c1b1dc334c8049e29f117c3ad7d3270d12824744 100644 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.C +++ b/src/mesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.C @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "hierarchicalDensityWeightedStochastic.H" +#include "autoDensity.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -33,17 +33,17 @@ namespace Foam // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -defineTypeNameAndDebug(hierarchicalDensityWeightedStochastic, 0); +defineTypeNameAndDebug(autoDensity, 0); addToRunTimeSelectionTable ( initialPointsMethod, - hierarchicalDensityWeightedStochastic, + autoDensity, dictionary ); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::hierarchicalDensityWeightedStochastic::writeOBJ +void Foam::autoDensity::writeOBJ ( const treeBoundBox& bb, fileName name @@ -68,8 +68,114 @@ void Foam::hierarchicalDensityWeightedStochastic::writeOBJ } } +bool Foam::autoDensity::combinedOverlaps(const treeBoundBox& box) const +{ + if (Pstream::parRun()) + { + return + cvMesh_.decomposition().overlapsThisProcessor(box) + || cvMesh_.geometryToConformTo().overlaps(box); + } + + return cvMesh_.geometryToConformTo().overlaps(box); +} + + +bool Foam::autoDensity::combinedInside(const point& p) const +{ + if (Pstream::parRun()) + { + return + cvMesh_.decomposition().positionOnThisProcessor(p) + && cvMesh_.geometryToConformTo().inside(p); + } -void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill + return cvMesh_.geometryToConformTo().inside(p); +} + + +Foam::Field<bool> Foam::autoDensity::combinedWellInside +( + const pointField& pts, + const scalarField& sizes +) const +{ + if (!Pstream::parRun()) + { + return cvMesh_.geometryToConformTo().wellInside + ( + pts, + minimumSurfaceDistanceCoeffSqr_*sqr(sizes) + ); + } + + Field<bool> inside(pts.size(), true); + + // Perform AND operation between testing the surfaces and the previous + // field, i.e the parallel result, or in serial, with true. + + Field<bool> insideA + ( + cvMesh_.geometryToConformTo().wellInside + ( + pts, + minimumSurfaceDistanceCoeffSqr_*sqr(sizes) + ) + ); + + Field<bool> insideB(cvMesh_.decomposition().positionOnThisProcessor(pts)); + + // inside = insideA && insideB; + + // Pout<< insideA << nl << insideB << endl; + + forAll(inside, i) + { + // if (inside[i] != (insideA[i] && insideB[i])) + // { + // Pout<< i << " not equal " << " " + // << pts[i] << " " << sizes[i] << " " + // << insideA[i] << " " + // << insideB[i] << " " + // << inside[i] + // << endl; + // } + + inside[i] = (insideA[i] && insideB[i]); + } + + return inside; +} + + +bool Foam::autoDensity::combinedWellInside +( + const point& p, + scalar size +) const +{ + bool inside = true; + + if (Pstream::parRun()) + { + inside = cvMesh_.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 + && cvMesh_.geometryToConformTo().wellInside + ( + p, + minimumSurfaceDistanceCoeffSqr_*sqr(size) + ); + + return inside; +} + + +void Foam::autoDensity::recurseAndFill ( std::list<Vb::Point>& initialPoints, const treeBoundBox& bb, @@ -77,8 +183,6 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill word recursionName ) const { - const conformationSurfaces& geometry = cvMesh_.geometryToConformTo(); - for (direction i = 0; i < 8; i++) { treeBoundBox subBB = bb.subBbox(i); @@ -90,7 +194,7 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill cvMesh_.timeCheck(newName); } - if (geometry.overlaps(subBB)) + if (combinedOverlaps(subBB)) { if (levelLimit > 0) { @@ -104,14 +208,14 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill } else { - // writeOBJ - // ( - // subBB, - // word(newName + "_overlap") - // ); - if (debug) { + writeOBJ + ( + subBB, + word(newName + "_overlap") + ); + Pout<< newName + "_overlap " << subBB << endl; } @@ -127,16 +231,16 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill } } } - else if (geometry.inside(subBB.midpoint())) + else if (combinedInside(subBB.midpoint())) { - // writeOBJ - // ( - // subBB, - // newName + "_inside" - // ); - if (debug) { + writeOBJ + ( + subBB, + newName + "_inside" + ); + Pout<< newName + "_inside " << subBB << endl; } @@ -153,24 +257,27 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill } else { - // writeOBJ - // ( - // subBB, - // newName + "_outside" - // ); + if (debug) + { + writeOBJ + ( + subBB, + newName + "_outside" + ); + } } } } -bool Foam::hierarchicalDensityWeightedStochastic::fillBox +bool Foam::autoDensity::fillBox ( std::list<Vb::Point>& initialPoints, const treeBoundBox& bb, bool overlapping ) const { - const conformationSurfaces& geometry = cvMesh_.geometryToConformTo(); + const conformationSurfaces& geometry(cvMesh_.geometryToConformTo()); Random& rnd = cvMesh_.rndGen(); @@ -214,7 +321,10 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (!surfHit.hit()) { - // Pout<< "box wellInside, no need to sample surface." << endl; + if (debug) + { + Pout<< "box wellInside, no need to sample surface." << endl; + } wellInside = true; } @@ -235,11 +345,7 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox List<bool>(8, false) ); - Field<bool> insideCorners = geometry.wellInside - ( - corners, - minimumSurfaceDistanceCoeffSqr_*sqr(cornerSizes) - ); + Field<bool> insideCorners = combinedWellInside(corners, cornerSizes); // Pout<< corners << nl << cornerSizes << nl << insideCorners << endl; @@ -260,11 +366,14 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (maxCellSize/minCellSize > maxSizeRatio_) { - // Pout<< "Abort fill at corner sample stage," - // << " minCellSize " << minCellSize - // << " maxCellSize " << maxCellSize - // << " maxSizeRatio " << maxCellSize/minCellSize - // << endl; + if (debug) + { + Pout<< "Abort fill at corner sample stage," + << " minCellSize " << minCellSize + << " maxCellSize " << maxCellSize + << " maxSizeRatio " << maxCellSize/minCellSize + << endl; + } return false; } @@ -274,9 +383,12 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox // If one or more corners is not "wellInside", then treat this // as an overlapping box. - // Pout<< "Inside box found to have some non-wellInside " - // << "corners, using overlapping fill." - // << endl; + if (debug) + { + Pout<< "Inside box found to have some non-wellInside " + << "corners, using overlapping fill." + << endl; + } overlapping = true; @@ -294,8 +406,6 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox scalarField lineSizes(nLine, 0.0); - Field<bool> insideLines(nLine, true); - for (label i = 0; i < surfRes_; i++) { label lPI = 0; @@ -348,10 +458,10 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox List<bool>(nLine, false) ); - insideLines = geometry.wellInside + Field<bool> insideLines = combinedWellInside ( linePoints, - minimumSurfaceDistanceCoeffSqr_*sqr(lineSizes) + lineSizes ); forAll(insideLines, i) @@ -371,11 +481,14 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (maxCellSize/minCellSize > maxSizeRatio_) { - // Pout<< "Abort fill at surface sample stage, " - // << " minCellSize " << minCellSize - // << " maxCellSize " << maxCellSize - // << " maxSizeRatio " << maxCellSize/minCellSize - // << endl; + if (debug) + { + Pout<< "Abort fill at surface sample stage, " + << " minCellSize " << minCellSize + << " maxCellSize " << maxCellSize + << " maxSizeRatio " << maxCellSize/minCellSize + << endl; + } return false; } @@ -386,10 +499,13 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox // then treat this as an overlapping box. overlapping = true; - // Pout<< "Inside box found to have some non-" - // << "wellInside surface points, using " - // << "overlapping fill." - // << endl; + if (debug) + { + Pout<< "Inside box found to have some non-" + << "wellInside surface points, using " + << "overlapping fill." + << endl; + } break; } @@ -445,10 +561,10 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox List<bool>(samplePoints.size(), false) ); - Field<bool> insidePoints = geometry.wellInside + Field<bool> insidePoints = combinedWellInside ( samplePoints, - minimumSurfaceDistanceCoeffSqr_*sqr(sampleSizes) + sampleSizes ); label nInside = 0; @@ -473,11 +589,14 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (maxCellSize/minCellSize > maxSizeRatio_) { - // Pout<< "Abort fill at sample stage," - // << " minCellSize " << minCellSize - // << " maxCellSize " << maxCellSize - // << " maxSizeRatio " << maxCellSize/minCellSize - // << endl; + if (debug) + { + Pout<< "Abort fill at sample stage," + << " minCellSize " << minCellSize + << " maxCellSize " << maxCellSize + << " maxSizeRatio " << maxCellSize/minCellSize + << endl; + } return false; } @@ -486,17 +605,26 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (nInside == 0) { - // Pout<< "No sample points found inside box" << endl; + if (debug) + { + Pout<< "No sample points found inside box" << endl; + } return true; } - // Pout<< scalar(nInside)/scalar(samplePoints.size()) - // << " full overlapping box" << endl; + if (debug) + { + Pout<< scalar(nInside)/scalar(samplePoints.size()) + << " full overlapping box" << endl; + } totalVolume *= scalar(nInside)/scalar(samplePoints.size()); - // Pout<< "Total volume to fill = " << totalVolume << endl; + if (debug) + { + Pout<< "Total volume to fill = " << totalVolume << endl; + } // Using the sampledPoints as the first test locations as they are // randomly shuffled, but unfiormly sampling space and have wellInside @@ -540,12 +668,15 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox scalar r = rnd.scalar01(); - // Pout<< "totalVolume " << totalVolume << nl - // << "volumeAdded " << volumeAdded << nl - // << "localVolume " << localVolume << nl - // << "addProbability " << addProbability << nl - // << "random " << r - // << endl; + if (debug) + { + Pout<< "totalVolume " << totalVolume << nl + << "volumeAdded " << volumeAdded << nl + << "localVolume " << localVolume << nl + << "addProbability " << addProbability << nl + << "random " << r + << endl; + } if (addProbability > r) { @@ -576,9 +707,12 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (volumeAdded < totalVolume) { - // Pout<< "Adding random points, remaining volume " - // << totalVolume - volumeAdded - // << endl; + if (debug) + { + Pout<< "Adding random points, remaining volume " + << totalVolume - volumeAdded + << endl; + } maxDensity = 1/pow3(max(minCellSize, SMALL)); @@ -599,11 +733,7 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox else { // Determine if the point is "wellInside" the domain - insidePoint = geometry.wellInside - ( - p, - minimumSurfaceDistanceCoeffSqr_*sqr(localSize) - ); + insidePoint = combinedWellInside(p, localSize); } if (insidePoint) @@ -626,11 +756,14 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (maxCellSize/minCellSize > maxSizeRatio_) { - // Pout<< "Abort fill at random fill stage," - // << " minCellSize " << minCellSize - // << " maxCellSize " << maxCellSize - // << " maxSizeRatio " << maxCellSize/minCellSize - // << endl; + if (debug) + { + Pout<< "Abort fill at random fill stage," + << " minCellSize " << minCellSize + << " maxCellSize " << maxCellSize + << " maxSizeRatio " << maxCellSize/minCellSize + << endl; + } // Discard any points already filled into this box by // setting size of initialPoints back to its starting value @@ -658,12 +791,15 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox scalar r = rnd.scalar01(); - // Pout<< "totalVolume " << totalVolume << nl - // << "volumeAdded " << volumeAdded << nl - // << "localVolume " << localVolume << nl - // << "addProbability " << addProbability << nl - // << "random " << r - // << endl; + if (debug) + { + Pout<< "totalVolume " << totalVolume << nl + << "volumeAdded " << volumeAdded << nl + << "localVolume " << localVolume << nl + << "addProbability " << addProbability << nl + << "random " << r + << endl; + } if (addProbability > r) { @@ -694,16 +830,19 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox globalTrialPoints_ += trialPoints; - // Pout<< trialPoints - // << " locations queried, " << initialPoints.size() - initialSize - // << " points placed, (" - // << scalar(initialPoints.size() - initialSize) - // /scalar(max(trialPoints, 1)) - // << " success rate)." << nl - // << "minCellSize " << minCellSize - // << ", maxCellSize " << maxCellSize - // << ", ratio " << maxCellSize/minCellSize - // << nl << endl; + if (debug) + { + Pout<< trialPoints + << " locations queried, " << initialPoints.size() - initialSize + << " points placed, (" + << scalar(initialPoints.size() - initialSize) + /scalar(max(trialPoints, 1)) + << " success rate)." << nl + << "minCellSize " << minCellSize + << ", maxCellSize " << maxCellSize + << ", ratio " << maxCellSize/minCellSize + << nl << endl; + } return true; } @@ -711,7 +850,7 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -hierarchicalDensityWeightedStochastic::hierarchicalDensityWeightedStochastic +autoDensity::autoDensity ( const dictionary& initialPointsDict, const conformalVoronoiMesh& cvMesh @@ -737,8 +876,7 @@ hierarchicalDensityWeightedStochastic::hierarchicalDensityWeightedStochastic WarningIn ( - "hierarchicalDensityWeightedStochastic::" - "hierarchicalDensityWeightedStochastic" + "autoDensity::autoDensity" "(" "const dictionary& initialPointsDict," "const conformalVoronoiMesh& cvMesh" @@ -753,15 +891,25 @@ hierarchicalDensityWeightedStochastic::hierarchicalDensityWeightedStochastic // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -std::list<Vb::Point> -hierarchicalDensityWeightedStochastic::initialPoints() const +std::list<Vb::Point> autoDensity::initialPoints() const { - const conformationSurfaces& geometry = cvMesh_.geometryToConformTo(); + treeBoundBox hierBB; - treeBoundBox hierBB = geometry.globalBounds().extend - ( - cvMesh_.rndGen(), 1e-6 - ); + // Pick up the bounds of this processor, or the whole geometry, depending + // on whether this is a parallel run. + if (Pstream::parRun()) + { + hierBB = cvMesh_.decomposition().procBounds(); + } + else + { + // Extend the global box to move it off large plane surfaces + hierBB = cvMesh_.geometryToConformTo().globalBounds().extend + ( + cvMesh_.rndGen(), + 1e-6 + ); + } std::list<Vb::Point> initialPoints; diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.H b/src/mesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.H similarity index 78% rename from src/mesh/conformalVoronoiMesh/initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.H rename to src/mesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.H index 190e70f035dc74b60e48e151e44cf6f8d05739d0..bafeebdc05816a563806b489210da06304af7104 100644 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.H +++ b/src/mesh/conformalVoronoiMesh/initialPointsMethod/autoDensity/autoDensity.H @@ -22,19 +22,19 @@ License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class - Foam::hierarchicalDensityWeightedStochastic + Foam::autoDensity Description Choose random points inside the domain and place them with a probability proportional to the target density of points. SourceFiles - hierarchicalDensityWeightedStochastic.C + autoDensity.C \*---------------------------------------------------------------------------*/ -#ifndef hierarchicalDensityWeightedStochastic_H -#define hierarchicalDensityWeightedStochastic_H +#ifndef autoDensity_H +#define autoDensity_H #include "initialPointsMethod.H" #include "treeBoundBox.H" @@ -45,10 +45,10 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class hierarchicalDensityWeightedStochastic Declaration + Class autoDensity Declaration \*---------------------------------------------------------------------------*/ -class hierarchicalDensityWeightedStochastic +class autoDensity : public initialPointsMethod { @@ -82,6 +82,30 @@ private: // Private Member Functions + //- Check if the given box overlaps the geometry or, in parallel, the + // backgroundMeshDecomposition + bool combinedOverlaps(const treeBoundBox& box) const; + + //- Check if the given point is inside the geometry and, in parallel, + // the backgroundMeshDecomposition + bool combinedInside(const point& p) const; + + //- Check if the given points are wellInside the geometry and, in + // parallel, inside the backgroundMeshDecomposition + Field<bool> combinedWellInside + ( + const pointField& pts, + const scalarField& sizes + ) const; + + //- Check if the given points are wellInside the geometry and, in + // parallel, inside the backgroundMeshDecomposition + bool combinedWellInside + ( + const point& p, + scalar size + ) const; + //- Write boundBox as obj void writeOBJ ( @@ -112,12 +136,12 @@ private: public: //- Runtime type information - TypeName("hierarchicalDensityWeightedStochastic"); + TypeName("autoDensity"); // Constructors //- Construct from components - hierarchicalDensityWeightedStochastic + autoDensity ( const dictionary& initialPointsDict, const conformalVoronoiMesh& cvMesh @@ -125,7 +149,7 @@ public: //- Destructor - virtual ~hierarchicalDensityWeightedStochastic() + virtual ~autoDensity() {} diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C b/src/mesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C index a77560efef3583c3c8fc5518670282db11bda198..d1d37be9ba1a5ccf9dfa9b27c10c0d07a26d14c8 100644 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C +++ b/src/mesh/conformalVoronoiMesh/initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C @@ -58,19 +58,30 @@ bodyCentredCubic::bodyCentredCubic std::list<Vb::Point> bodyCentredCubic::initialPoints() const { - const boundBox& bb = cvMesh_.geometryToConformTo().globalBounds(); + boundBox bb; + + // Pick up the bounds of this processor, or the whole geometry, depending + // on whether this is a parallel run. + if (Pstream::parRun()) + { + bb = cvMesh_.decomposition().procBounds(); + } + else + { + bb = cvMesh_.geometryToConformTo().globalBounds(); + } scalar x0 = bb.min().x(); scalar xR = bb.max().x() - x0; - label ni = label(xR/initialCellSize_) + 1; + label ni = label(xR/initialCellSize_); scalar y0 = bb.min().y(); scalar yR = bb.max().y() - y0; - label nj = label(yR/initialCellSize_) + 1; + label nj = label(yR/initialCellSize_); scalar z0 = bb.min().z(); scalar zR = bb.max().z() - z0; - label nk = label(zR/initialCellSize_) + 1; + label nk = label(zR/initialCellSize_); vector delta(xR/ni, yR/nj, zR/nk); @@ -82,8 +93,6 @@ std::list<Vb::Point> bodyCentredCubic::initialPoints() const std::list<Vb::Point> initialPoints; - List<bool> isSurfacePoint(2*nk, false); - for (label i = 0; i < ni; i++) { for (label j = 0; j < nj; j++) @@ -114,7 +123,19 @@ std::list<Vb::Point> bodyCentredCubic::initialPoints() const pA.z() += pert*(rndGen.scalar01() - 0.5); } - points[pI++] = pA; + if (Pstream::parRun()) + { + if (cvMesh_.decomposition().positionOnThisProcessor(pA)) + { + // Add this point in parallel only if this position is + // on this processor. + points[pI++] = pA; + } + } + else + { + points[pI++] = pA; + } if (randomiseInitialGrid_) { @@ -123,14 +144,35 @@ std::list<Vb::Point> bodyCentredCubic::initialPoints() const pB.z() += pert*(rndGen.scalar01() - 0.5); } - points[pI++] = pB; + if (Pstream::parRun()) + { + if (cvMesh_.decomposition().positionOnThisProcessor(pB)) + { + // Add this point in parallel only if this position is + // on this processor. + points[pI++] = pB; + } + } + else + { + points[pI++] = pB; + } } + points.setSize(pI); + Field<bool> insidePoints = cvMesh_.geometryToConformTo().wellInside ( points, minimumSurfaceDistanceCoeffSqr_ - *sqr(cvMesh_.cellSizeControl().cellSize(points, isSurfacePoint)) + *sqr + ( + cvMesh_.cellSizeControl().cellSize + ( + points, + List<bool>(points.size(), false) + ) + ) ); forAll(insidePoints, i) diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.C b/src/mesh/conformalVoronoiMesh/initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.C deleted file mode 100644 index 002d76705d5c9eef6b0b273c35e5be4e983c639b..0000000000000000000000000000000000000000 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.C +++ /dev/null @@ -1,147 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "densityWeightedStochastic.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -defineTypeNameAndDebug(densityWeightedStochastic, 0); -addToRunTimeSelectionTable -( - initialPointsMethod, - densityWeightedStochastic, - dictionary -); - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -densityWeightedStochastic::densityWeightedStochastic -( - const dictionary& initialPointsDict, - const conformalVoronoiMesh& cvMesh -) -: - initialPointsMethod(typeName, initialPointsDict, cvMesh), - totalVolume_(readScalar(detailsDict().lookup("totalVolume"))), - minCellSize_ - ( - detailsDict().lookupOrDefault<scalar>("minCellSize", GREAT) - ), - minCellSizeLimit_ - ( - detailsDict().lookupOrDefault<scalar>("minCellSizeLimit", 0.0) - ) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -std::list<Vb::Point> densityWeightedStochastic::initialPoints() const -{ - const boundBox& bb = cvMesh_.geometryToConformTo().globalBounds(); - - Random& rndGen = cvMesh_.rndGen(); - - std::list<Vb::Point> initialPoints; - - scalar volumeAdded = 0.0; - - const point& min = bb.min(); - - vector span = bb.span(); - - label trialPoints = 0; - - scalar maxDensity = 1/pow3(max(minCellSize_, SMALL)); - - while (volumeAdded < totalVolume_) - { - trialPoints++; - - point p = - min - + vector - ( - span.x()*rndGen.scalar01(), - span.y()*rndGen.scalar01(), - span.z()*rndGen.scalar01() - ); - - scalar localSize = cvMesh_.cellSizeControl().cellSize(p); - - if (localSize < minCellSize_) - { - minCellSize_ = max(localSize, minCellSizeLimit_); - - // 1/(minimum cell size)^3, gives the maximum permissible point - // density - maxDensity = 1/pow3(max(minCellSize_, SMALL)); - } - - scalar localDensity = 1/pow3(max(localSize, SMALL)); - - // Accept possible placements proportional to the relative local density - if (localDensity/maxDensity > rndGen.scalar01()) - { - // Determine if the point is "wellInside" the domain - if - ( - cvMesh_.geometryToConformTo().wellInside - ( - p, - minimumSurfaceDistanceCoeffSqr_*sqr(localSize) - ) - ) - { - initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z())); - - volumeAdded += 1/localDensity; - } - } - } - - Info<< nl << " " << typeName << nl - << " " << initialPoints.size() << " points placed" << nl - << " " << trialPoints << " locations queried" << nl - << " " << scalar(initialPoints.size())/scalar(trialPoints) - << " success rate" << nl - << " minCellSize " << minCellSize_ - << endl; - - return initialPoints; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.H b/src/mesh/conformalVoronoiMesh/initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.H deleted file mode 100644 index d1228a5c1ae4186d2fdca3bdc2a4008624cd63b9..0000000000000000000000000000000000000000 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.H +++ /dev/null @@ -1,106 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. - -Class - Foam::densityWeightedStochastic - -Description - Choose random points inside the domain and place them with a probability - proportional to the target density of points. - -SourceFiles - densityWeightedStochastic.C - -\*---------------------------------------------------------------------------*/ - -#ifndef densityWeightedStochastic_H -#define densityWeightedStochastic_H - -#include "initialPointsMethod.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class densityWeightedStochastic Declaration -\*---------------------------------------------------------------------------*/ - -class densityWeightedStochastic -: - public initialPointsMethod -{ - -private: - - // Private data - - //- The total volume to be filled - scalar totalVolume_; - - //- Working variable for minimum cell size, a starting value may be - // specified in the dictionary - mutable scalar minCellSize_; - - //- Smallest minimum cell size allowed, i.e. to avoid high initial - // population of areas of small size - scalar minCellSizeLimit_; - - -public: - - //- Runtime type information - TypeName("densityWeightedStochastic"); - - // Constructors - - //- Construct from components - densityWeightedStochastic - ( - const dictionary& initialPointsDict, - const conformalVoronoiMesh& cvMesh - ); - - - //- Destructor - virtual ~densityWeightedStochastic() - {} - - - // Member Functions - - //- Return the initial points for the conformalVoronoiMesh - virtual std::list<Vb::Point> initialPoints() const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.C b/src/mesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.C index 36b30fa2027b55add8e9b2d73b246233e98790e6..df61890c4028a8d1160919833aecaa770d1b7ac3 100644 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.C +++ b/src/mesh/conformalVoronoiMesh/initialPointsMethod/faceCentredCubic/faceCentredCubic.C @@ -58,19 +58,30 @@ faceCentredCubic::faceCentredCubic std::list<Vb::Point> faceCentredCubic::initialPoints() const { - const boundBox& bb = cvMesh_.geometryToConformTo().globalBounds(); + boundBox bb; + + // Pick up the bounds of this processor, or the whole geometry, depending + // on whether this is a parallel run. + if (Pstream::parRun()) + { + bb = cvMesh_.decomposition().procBounds(); + } + else + { + bb = cvMesh_.geometryToConformTo().globalBounds(); + } scalar x0 = bb.min().x(); scalar xR = bb.max().x() - x0; - label ni = label(xR/initialCellSize_) + 1; + label ni = label(xR/initialCellSize_); scalar y0 = bb.min().y(); scalar yR = bb.max().y() - y0; - label nj = label(yR/initialCellSize_) + 1; + label nj = label(yR/initialCellSize_); scalar z0 = bb.min().z(); scalar zR = bb.max().z() - z0; - label nk = label(zR/initialCellSize_) + 1; + label nk = label(zR/initialCellSize_); vector delta(xR/ni, yR/nj, zR/nk); @@ -82,8 +93,6 @@ std::list<Vb::Point> faceCentredCubic::initialPoints() const std::list<Vb::Point> initialPoints; - List<bool> isSurfacePoint(4*nk, false); - for (label i = 0; i < ni; i++) { for (label j = 0; j < nj; j++) @@ -112,7 +121,19 @@ std::list<Vb::Point> faceCentredCubic::initialPoints() const p.z() += pert*(rndGen.scalar01() - 0.5); } - points[pI++] = p; + if (Pstream::parRun()) + { + if (cvMesh_.decomposition().positionOnThisProcessor(p)) + { + // Add this point in parallel only if this position is + // on this processor. + points[pI++] = p; + } + } + else + { + points[pI++] = p; + } p = point ( @@ -128,7 +149,19 @@ std::list<Vb::Point> faceCentredCubic::initialPoints() const p.z() += pert*(rndGen.scalar01() - 0.5); } - points[pI++] = p; + if (Pstream::parRun()) + { + if (cvMesh_.decomposition().positionOnThisProcessor(p)) + { + // Add this point in parallel only if this position is + // on this processor. + points[pI++] = p; + } + } + else + { + points[pI++] = p; + } p = point ( @@ -144,7 +177,19 @@ std::list<Vb::Point> faceCentredCubic::initialPoints() const p.z() += pert*(rndGen.scalar01() - 0.5); } - points[pI++] = p; + if (Pstream::parRun()) + { + if (cvMesh_.decomposition().positionOnThisProcessor(p)) + { + // Add this point in parallel only if this position is + // on this processor. + points[pI++] = p; + } + } + else + { + points[pI++] = p; + } p = point ( @@ -160,14 +205,35 @@ std::list<Vb::Point> faceCentredCubic::initialPoints() const p.z() += pert*(rndGen.scalar01() - 0.5); } - points[pI++] = p; + if (Pstream::parRun()) + { + if (cvMesh_.decomposition().positionOnThisProcessor(p)) + { + // Add this point in parallel only if this position is + // on this processor. + points[pI++] = p; + } + } + else + { + points[pI++] = p; + } } + points.setSize(pI); + Field<bool> insidePoints = cvMesh_.geometryToConformTo().wellInside ( points, minimumSurfaceDistanceCoeffSqr_ - *sqr(cvMesh_.cellSizeControl().cellSize(points, isSurfacePoint)) + *sqr + ( + cvMesh_.cellSizeControl().cellSize + ( + points, + List<bool>(points.size(), false) + ) + ) ); forAll(insidePoints, i) diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C b/src/mesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C index 92c369743aeeffd9ec2d502fd6c9856505c7d9d5..23d903005ce32a93fb8ee7c97a60e9a47fd2ee07 100644 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C +++ b/src/mesh/conformalVoronoiMesh/initialPointsMethod/uniformGrid/uniformGrid.C @@ -146,7 +146,7 @@ std::list<Vb::Point> uniformGrid::initialPoints() const cvMesh_.cellSizeControl().cellSize ( points, - List<bool>(pI, false) + List<bool>(points.size(), false) ) ) ); diff --git a/tutorials/mesh/cvMesh/flange/system/cvMeshDict-generatePoints b/tutorials/mesh/cvMesh/flange/system/cvMeshDict-generatePoints index 5c0e6b701857219b74a7707364f9aeca7fc44c59..84ef6fb7601735fd0465c56494445e97678ae79f 100644 --- a/tutorials/mesh/cvMesh/flange/system/cvMeshDict-generatePoints +++ b/tutorials/mesh/cvMesh/flange/system/cvMeshDict-generatePoints @@ -109,14 +109,17 @@ initialPoints { minimumSurfaceDistanceCoeff 0.55; - initialPointsMethod densityWeightedStochastic; + initialPointsMethod autoDensity; // initialPointsMethod uniformGrid; // initialPointsMethod bodyCentredCubic; // initialPointsMethod pointFile; - densityWeightedStochasticDetails + autoDensityDetails { - totalVolume 1.56e-05; + minLevels 1; + maxSizeRatio 2.0; + sampleResolution 5; + surfaceSampleResolution 5; } uniformGridDetails diff --git a/tutorials/mesh/cvMesh/flange/system/cvMeshDict-usePoints b/tutorials/mesh/cvMesh/flange/system/cvMeshDict-usePoints index 8dcff375bde0d3e968ac70c5b1157752724a2590..8fa7cb3f5f842dbcb6154b3ec870ed4d6eb35b95 100644 --- a/tutorials/mesh/cvMesh/flange/system/cvMeshDict-usePoints +++ b/tutorials/mesh/cvMesh/flange/system/cvMeshDict-usePoints @@ -109,30 +109,8 @@ initialPoints { minimumSurfaceDistanceCoeff 0.55; - // initialPointsMethod densityWeightedStochastic; - // initialPointsMethod uniformGrid; - // initialPointsMethod bodyCentredCubic; initialPointsMethod pointFile; - densityWeightedStochasticDetails - { - totalVolume 1.56e-05; - } - - uniformGridDetails - { - initialCellSize 0.0015; - randomiseInitialGrid yes; - randomPerturbationCoeff 0.02; - } - - bodyCentredCubicDetails - { - initialCellSize 0.0015; - randomiseInitialGrid no; - randomPerturbationCoeff 0.1; - } - pointFileDetails { pointFile "constant/internalDelaunayVertices"; diff --git a/tutorials/mesh/cvMesh/simpleShapes/Allrun b/tutorials/mesh/cvMesh/simpleShapes/Allrun index 14ecc7060105a7df75dd55a057c80f15df5cce99..b3488904840780b6de322261f71d241b083ce7b4 100755 --- a/tutorials/mesh/cvMesh/simpleShapes/Allrun +++ b/tutorials/mesh/cvMesh/simpleShapes/Allrun @@ -6,18 +6,10 @@ cd ${0%/*} || exit 1 # run from this directory # Generate aligned points (in constant/internalDelaunayVertices) and a # mesh from that. -#cp system/controlDict-generatePoints system/controlDict -#cp system/cvMeshDict-generatePoints system/cvMeshDict runApplication surfaceFeatureExtract constant/triSurface/coneAndSphere.obj coneAndSphere -includedAngle 125 runApplication surfaceFeatureExtract constant/triSurface/domain.stl domain -includedAngle 125 runApplication cvMesh -# Use pre-generated aligned points (constant/internalDelaunayVertices) -# to generate a mesh -# cp system/controlDict-usePoints system/controlDict -# cp system/cvMeshDict-usePoints system/cvMeshDict -# runApplication cvMesh - # Generate some sets for a bit of mesh inspection runApplication topoSet diff --git a/tutorials/mesh/cvMesh/simpleShapes/system/controlDict-generatePoints b/tutorials/mesh/cvMesh/simpleShapes/system/controlDict-generatePoints deleted file mode 100644 index e6e65767e1209963207bad166ec52cc5cd1fa71a..0000000000000000000000000000000000000000 --- a/tutorials/mesh/cvMesh/simpleShapes/system/controlDict-generatePoints +++ /dev/null @@ -1,54 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ - -FoamFile -{ - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object controlDict; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -startFrom latestTime; - -startTime 0; - -stopAt endTime; - -endTime 80; - -deltaT 1; - -writeControl timeStep; - -writeInterval 1000; //10 to see the meshing steps - -purgeWrite 0; - -writeFormat ascii; - -writePrecision 10; - -writeCompression uncompressed; - -timeFormat general; - -timePrecision 6; - -runTimeModifiable yes; - - -// ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/simpleShapes/system/controlDict-usePoints b/tutorials/mesh/cvMesh/simpleShapes/system/controlDict-usePoints deleted file mode 100644 index 0aa0653eb8ba2748f7635fb4f45f2c2a5603b350..0000000000000000000000000000000000000000 --- a/tutorials/mesh/cvMesh/simpleShapes/system/controlDict-usePoints +++ /dev/null @@ -1,54 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ - -FoamFile -{ - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object controlDict; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -startFrom latestTime; - -startTime 0; - -stopAt endTime; - -endTime 0; - -deltaT 1; - -writeControl timeStep; - -writeInterval 1000; //10 to see the meshing steps - -purgeWrite 0; - -writeFormat ascii; - -writePrecision 10; - -writeCompression uncompressed; - -timeFormat general; - -timePrecision 6; - -runTimeModifiable yes; - - -// ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict b/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict deleted file mode 120000 index ca9a7ed9279f4d7e4546be42f3ac4c0015b13f95..0000000000000000000000000000000000000000 --- a/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict +++ /dev/null @@ -1 +0,0 @@ -cvMeshDict-generatePoints \ No newline at end of file diff --git a/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict b/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..f774b1a7530ace167c8911ae0cedcecc1a34e847 --- /dev/null +++ b/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict @@ -0,0 +1,280 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +FoamFile +{ + version 2.0; + format ascii; + + root ""; + case ""; + instance ""; + local ""; + + class dictionary; + object cvMeshDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// Important: +// ---------- +// Any scalar with a name <name>Coeff specifies a value that will be implemented +// as a faction of the local target cell size +// Any scalar with a name <name>Size specifies an absolute size. + + +// Geometry. Definition of all surfaces. All surfaces are of class +// searchableSurface. +// Surfaces need to be (almost) closed - use closedTriSurfaceMesh +// if they are not topologically closed. Surfaces need to be oriented so +// the space to be meshed is always on the inside of all surfaces. Use e.g. +// surfaceOrient. +geometry +{ + // Internal shape + coneAndSphere.obj + { + name coneAndSphere; + type triSurfaceMesh; + tolerance 0.00001; + } + +// // Internal shape +// coneAndSphere +// { +// type searchableSurfaceWithGaps; +// surface coneAndSphere.obj; +// gap 0.001; +// } + + // Bounds of domain + domain.stl + { + type triSurfaceMesh; + } + +} + + +surfaceConformation +{ + // Point that is inside wanted part of geometry. + locationInMesh (0 -0.5 0); + + // Balance this between + // - very low distance: little chance of interference from other + // surfaces + // - largish distance: less non-orthogonality in final cell + // (circumcentre far away from centroid) + pointPairDistanceCoeff 0.1; + + mixedFeaturePointPPDistanceCoeff 5.0; + + featurePointExclusionDistanceCoeff 0.4; + + featureEdgeExclusionDistanceCoeff 0.2; + + surfaceSearchDistanceCoeff 2.5; + + maxSurfaceProtrusionCoeff 0.1; + + maxQuadAngle 125; + + surfaceConformationRebuildFrequency 10; + + coarseConformationControls + { + initial + { + edgeSearchDistCoeff 1.1; + surfacePtReplaceDistCoeff 0.5; + } + + iteration + { + edgeSearchDistCoeff 1.25; + surfacePtReplaceDistCoeff 0.7; + } + + maxIterations 15; + + iterationToInitialHitRatioLimit 0.001; + } + + fineConformationControls + { + initial + { + edgeSearchDistCoeff 1.1; + surfacePtReplaceDistCoeff 0.5; + } + + iteration + { + edgeSearchDistCoeff 1.25; + surfacePtReplaceDistCoeff 0.7; + } + + maxIterations 15; + + iterationToInitialHitRatioLimit 0.001; + } + + geometryToConformTo + { + coneAndSphere + { + featureMethod extendedFeatureEdgeMesh; + extendedFeatureEdgeMesh "coneAndSphere.extendedFeatureEdgeMesh"; + } + + domain.stl + { + featureMethod extendedFeatureEdgeMesh; + extendedFeatureEdgeMesh "domain.extendedFeatureEdgeMesh"; + } + + } + + additionalFeatures {} +} + + +initialPoints +{ + // Do not place point closer than minimumSurfaceDistanceCoeff + // to the surface. Is fraction of local target cell size (see below) + minimumSurfaceDistanceCoeff 0.55; + + initialPointsMethod autoDensity; + // initialPointsMethod uniformGrid; + // initialPointsMethod bodyCentredCubic; + // initialPointsMethod pointFile; + + // Take boundbox of all geometry. Samples with this box. If too much + // samples (due to target cell size) in box split box. + autoDensityDetails + { + // Number of refinement levels. Needs to be enough to pick up features + // due to size ratio. + minLevels 2; + // Split box if ratio of min to max size larger than maxSizeRatio + maxSizeRatio 5.0; + // Per box sample 3x3x3 internally + sampleResolution 3; + // Additionally per face of the box sample 3 + surfaceSampleResolution 3; + } + + uniformGridDetails + { + initialCellSize 0.0015; + randomiseInitialGrid yes; + randomPerturbationCoeff 0.02; + } + + bodyCentredCubicDetails + { + initialCellSize 0.0015; + randomiseInitialGrid no; + randomPerturbationCoeff 0.1; + } + + pointFileDetails + { + pointFile "constant/internalDelaunayVertices"; + } +} + + +motionControl +{ + defaultCellSize 0.1; + + // Assign a priority to all requests for cell sizes, the highest overrules. + defaultPriority 0; + + cellSizeControlGeometry + { + } + + relaxationModel adaptiveLinear; + + adaptiveLinearCoeffs + { + relaxationStart 1.0; + relaxationEnd 0.0; + } + + objOutput no; + + timeChecks yes; + + alignmentSearchSpokes 36; + + alignmentAcceptanceAngle 48; + + sizeAndAlignmentRebuildFrequency 20; + + pointInsertionCriteria + { + cellCentreDistCoeff 1.75; + faceAreaRatioCoeff 0.0025; + acceptanceAngle 21.5; + } + + pointRemovalCriteria + { + cellCentreDistCoeff 0.65; + } + + faceAreaWeightModel piecewiseLinearRamp; + + piecewiseLinearRampCoeffs + { + lowerAreaFraction 0.5; + upperAreaFraction 1.0; + } +} + + +polyMeshFiltering +{ + filterSizeCoeff 0.2; + mergeClosenessCoeff 1e-4; + continueFilteringOnBadInitialPolyMesh true; + filterErrorReductionCoeff 0.5; + filterCountSkipThreshold 4; + maxCollapseIterations 25; + maxConsecutiveEqualFaceSets 5; + surfaceStepFaceAngle 80; + edgeCollapseGuardFraction 0.3; + maxCollapseFaceToPointSideLengthCoeff 0.35; +} + + +meshQualityControls +{ + maxNonOrtho 65; + maxBoundarySkewness 50; + maxInternalSkewness 10; + maxConcave 80; + minTetQuality 1e-30; + minVol 0; + minArea -1; + minTwist 0.02; + minDeterminant 0.001; + minFaceWeight 0.02; + minVolRatio 0.01; + minTriangleTwist -1; +} + + +// ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict-generatePoints b/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict-generatePoints deleted file mode 100644 index 987ce8de30fa3ec04f6fefdb1f1e4d22e18c6b58..0000000000000000000000000000000000000000 --- a/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict-generatePoints +++ /dev/null @@ -1,287 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ - -FoamFile -{ - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object cvMeshDict; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - -// Important: -// ---------- -// Any scalar with a name <name>Coeff specifies a value that will be implemented -// as a faction of the local target cell size -// Any scalar with a name <name>Size specifies an absolute size. - - -// Geometry. Definition of all surfaces. All surfaces are of class -// searchableSurface. -// Surfaces need to be (almost) closed - use closedTriSurfaceMesh -// if they are not topologically closed. Surfaces need to be oriented so -// the space to be meshed is always on the inside of all surfaces. Use e.g. -// surfaceOrient. -geometry -{ - // Internal shape - coneAndSphere.obj - { - name coneAndSphere; - type triSurfaceMesh; - tolerance 0.00001; - } - -// // Internal shape -// coneAndSphere -// { -// type searchableSurfaceWithGaps; -// surface coneAndSphere.obj; -// gap 0.001; -// } - - // Bounds of domain - domain.stl - { - type triSurfaceMesh; - } - -} - - -surfaceConformation -{ - // Point that is inside wanted part of geometry. - locationInMesh (0 -0.5 0); - - // Balance this between - // - very low distance: little chance of interference from other - // surfaces - // - largish distance: less non-orthogonality in final cell - // (circumcentre far away from centroid) - pointPairDistanceCoeff 0.1; - - mixedFeaturePointPPDistanceCoeff 5.0; - - featurePointExclusionDistanceCoeff 0.4; - - featureEdgeExclusionDistanceCoeff 0.2; - - surfaceSearchDistanceCoeff 2.5; - - maxSurfaceProtrusionCoeff 0.1; - - maxQuadAngle 125; - - surfaceConformationRebuildFrequency 10; - - coarseConformationControls - { - initial - { - edgeSearchDistCoeff 1.1; - surfacePtReplaceDistCoeff 0.5; - } - - iteration - { - edgeSearchDistCoeff 1.25; - surfacePtReplaceDistCoeff 0.7; - } - - maxIterations 15; - - iterationToInitialHitRatioLimit 0.001; - } - - fineConformationControls - { - initial - { - edgeSearchDistCoeff 1.1; - surfacePtReplaceDistCoeff 0.5; - } - - iteration - { - edgeSearchDistCoeff 1.25; - surfacePtReplaceDistCoeff 0.7; - } - - maxIterations 15; - - iterationToInitialHitRatioLimit 0.001; - } - - geometryToConformTo - { - coneAndSphere - { - featureMethod extendedFeatureEdgeMesh; - extendedFeatureEdgeMesh "coneAndSphere.extendedFeatureEdgeMesh"; - } - - domain.stl - { - featureMethod extendedFeatureEdgeMesh; - extendedFeatureEdgeMesh "domain.extendedFeatureEdgeMesh"; - } - - } - - additionalFeatures {} -} - - -initialPoints -{ - // Do not place point closer than minimumSurfaceDistanceCoeff - // to the surface. Is fraction of local target cell size (see below) - minimumSurfaceDistanceCoeff 0.55; - - initialPointsMethod hierarchicalDensityWeightedStochastic; - //initialPointsMethod densityWeightedStochastic; - // initialPointsMethod uniformGrid; - // initialPointsMethod bodyCentredCubic; - // initialPointsMethod pointFile; - - - // Take boundbox of all geometry. Samples with this box. If too much - // samples (due to target cell size) in box split box. - hierarchicalDensityWeightedStochasticDetails - { - // Number of refinement levels. Needs to be enough to pick up features - // due to size ratio. - minLevels 2; - // Split box if ratio of min to max size larger than maxSizeRatio - maxSizeRatio 5.0; - // Per box sample 3x3x3 internally - sampleResolution 3; - // Additionally per face of the box sample 3 - surfaceSampleResolution 3; - } - - densityWeightedStochasticDetails - { - totalVolume 1.56e-05; - } - - uniformGridDetails - { - initialCellSize 0.0015; - randomiseInitialGrid yes; - randomPerturbationCoeff 0.02; - } - - bodyCentredCubicDetails - { - initialCellSize 0.0015; - randomiseInitialGrid no; - randomPerturbationCoeff 0.1; - } - - pointFileDetails - { - pointFile "constant/internalDelaunayVertices"; - } -} - - -motionControl -{ - defaultCellSize 0.1; - - // Assign a priority to all requests for cell sizes, the highest overrules. - defaultPriority 0; - - cellSizeControlGeometry - { - } - - relaxationModel adaptiveLinear; - - adaptiveLinearCoeffs - { - relaxationStart 1.0; - relaxationEnd 0.0; - } - - objOutput no; - - timeChecks yes; - - alignmentSearchSpokes 36; - - alignmentAcceptanceAngle 48; - - sizeAndAlignmentRebuildFrequency 20; - - pointInsertionCriteria - { - cellCentreDistCoeff 1.75; - faceAreaRatioCoeff 0.0025; - acceptanceAngle 21.5; - } - - pointRemovalCriteria - { - cellCentreDistCoeff 0.65; - } - - faceAreaWeightModel piecewiseLinearRamp; - - piecewiseLinearRampCoeffs - { - lowerAreaFraction 0.5; - upperAreaFraction 1.0; - } -} - - -polyMeshFiltering -{ - filterSizeCoeff 0.2; - mergeClosenessCoeff 1e-4; - continueFilteringOnBadInitialPolyMesh true; - filterErrorReductionCoeff 0.5; - filterCountSkipThreshold 4; - maxCollapseIterations 25; - maxConsecutiveEqualFaceSets 5; - surfaceStepFaceAngle 80; - edgeCollapseGuardFraction 0.3; - maxCollapseFaceToPointSideLengthCoeff 0.35; -} - - -meshQualityControls -{ - maxNonOrtho 65; - maxBoundarySkewness 50; - maxInternalSkewness 10; - maxConcave 80; - minTetQuality 1e-30; - minVol 0; - minArea -1; - minTwist 0.02; - minDeterminant 0.001; - minFaceWeight 0.02; - minVolRatio 0.01; - minTriangleTwist -1; -} - - -// ************************************************************************* // diff --git a/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict-usePoints b/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict-usePoints deleted file mode 100644 index 8dcff375bde0d3e968ac70c5b1157752724a2590..0000000000000000000000000000000000000000 --- a/tutorials/mesh/cvMesh/simpleShapes/system/cvMeshDict-usePoints +++ /dev/null @@ -1,226 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ - -FoamFile -{ - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object cvMeshDict; -} - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// Any scalar with a name <name>Coeff specifies a value that will be implemented -// as a faction of the local target cell size - -geometry -{ - flange.obj - { - type triSurfaceMesh; - } -} - - -surfaceConformation -{ - locationInMesh (0 0 0); - - pointPairDistanceCoeff 0.1; - - mixedFeaturePointPPDistanceCoeff 5.0; - - featurePointExclusionDistanceCoeff 0.4; - - featureEdgeExclusionDistanceCoeff 0.2; - - surfaceSearchDistanceCoeff 2.5; - - maxSurfaceProtrusionCoeff 0.1; - - maxQuadAngle 125; - - surfaceConformationRebuildFrequency 10; - - coarseConformationControls - { - initial - { - edgeSearchDistCoeff 1.1; - surfacePtReplaceDistCoeff 0.5; - } - - iteration - { - edgeSearchDistCoeff 1.25; - surfacePtReplaceDistCoeff 0.7; - } - - maxIterations 15; - - iterationToInitialHitRatioLimit 0.001; - } - - fineConformationControls - { - initial - { - edgeSearchDistCoeff 1.1; - surfacePtReplaceDistCoeff 0.5; - } - - iteration - { - edgeSearchDistCoeff 1.25; - surfacePtReplaceDistCoeff 0.7; - } - - maxIterations 15; - - iterationToInitialHitRatioLimit 0.001; - } - - geometryToConformTo - { - flange.obj - { - featureMethod extendedFeatureEdgeMesh; - extendedFeatureEdgeMesh "flange.extendedFeatureEdgeMesh"; - } - } - - additionalFeatures {} -} - - -initialPoints -{ - minimumSurfaceDistanceCoeff 0.55; - - // initialPointsMethod densityWeightedStochastic; - // initialPointsMethod uniformGrid; - // initialPointsMethod bodyCentredCubic; - initialPointsMethod pointFile; - - densityWeightedStochasticDetails - { - totalVolume 1.56e-05; - } - - uniformGridDetails - { - initialCellSize 0.0015; - randomiseInitialGrid yes; - randomPerturbationCoeff 0.02; - } - - bodyCentredCubicDetails - { - initialCellSize 0.0015; - randomiseInitialGrid no; - randomPerturbationCoeff 0.1; - } - - pointFileDetails - { - pointFile "constant/internalDelaunayVertices"; - } -} - - -motionControl -{ - defaultCellSize 0.00075; - - // Assign a priority to all requests for cell sizes, the highest overrules. - defaultPriority 0; - - cellSizeControlGeometry - { - } - - relaxationModel adaptiveLinear; - - adaptiveLinearCoeffs - { - relaxationStart 1.0; - relaxationEnd 0.0; - } - - objOutput no; - - timeChecks yes; - - alignmentSearchSpokes 36; - - alignmentAcceptanceAngle 48; - - sizeAndAlignmentRebuildFrequency 20; - - pointInsertionCriteria - { - cellCentreDistCoeff 1.75; - faceAreaRatioCoeff 0.0025; - acceptanceAngle 21.5; - } - - pointRemovalCriteria - { - cellCentreDistCoeff 0.65; - } - - faceAreaWeightModel piecewiseLinearRamp; - - piecewiseLinearRampCoeffs - { - lowerAreaFraction 0.5; - upperAreaFraction 1.0; - } -} - - -polyMeshFiltering -{ - filterSizeCoeff 0.2; - mergeClosenessCoeff 1e-4; - continueFilteringOnBadInitialPolyMesh true; - filterErrorReductionCoeff 0.5; - filterCountSkipThreshold 4; - maxCollapseIterations 25; - maxConsecutiveEqualFaceSets 5; - surfaceStepFaceAngle 80; - edgeCollapseGuardFraction 0.3; - maxCollapseFaceToPointSideLengthCoeff 0.35; -} - - -meshQualityControls -{ - maxNonOrtho 65; - maxBoundarySkewness 50; - maxInternalSkewness 10; - maxConcave 80; - minTetQuality 1e-30; - minVol 0; - minArea -1; - minTwist 0.02; - minDeterminant 0.001; - minFaceWeight 0.02; - minVolRatio 0.01; - minTriangleTwist -1; -} - - -// ************************************************************************* //