From f064cc57cf4a548b2188a5b43a2c7293e7504aed Mon Sep 17 00:00:00 2001 From: graham <g.macpherson@opencfd.co.uk> Date: Mon, 15 Nov 2010 22:06:16 +0000 Subject: [PATCH] ENH: Moving timeCheck to be public. --- .../conformalVoronoiMesh.H | 6 +- .../conformalVoronoiMeshI.H | 20 +-- .../hierarchicalDensityWeightedStochastic.C | 143 ++++++++++-------- 3 files changed, 91 insertions(+), 78 deletions(-) diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index f56ed62897c..3c0ce11b812 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -172,9 +172,6 @@ private: // Private Member Functions - //- Write the elapsedCpuTime - inline void timeCheck() const; - //- Return the local target cell size at the given location. Takes // boolean argument to allow speed-up of queries if the point is going // to be on a surface. @@ -719,6 +716,9 @@ public: // Write + //- Write the elapsedCpuTime + inline void timeCheck() const; + //- Write Delaunay points to .obj file void writePoints(const fileName& fName, bool internalOnly) const; diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H index d93a37dfc38..31855b5dd10 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H @@ -25,16 +25,6 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -inline void Foam::conformalVoronoiMesh::timeCheck() const -{ - if (cvMeshControls().timeChecks()) - { - Info<< nl << "--- [ " << runTime_.elapsedCpuTime() << "s, delta " - << runTime_.cpuTimeIncrement()<< "s ] --- " << endl; - } -} - - inline Foam::scalar Foam::conformalVoronoiMesh::targetCellSize ( const point& pt, @@ -471,4 +461,14 @@ Foam::conformalVoronoiMesh::cvMeshControls() const } +inline void Foam::conformalVoronoiMesh::timeCheck() const +{ + if (cvMeshControls().timeChecks()) + { + Info<< nl << "--- [ " << runTime_.elapsedCpuTime() << "s, delta " + << runTime_.cpuTimeIncrement()<< "s ] --- " << endl; + } +} + + // ************************************************************************* // diff --git a/src/mesh/conformalVoronoiMesh/initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.C b/src/mesh/conformalVoronoiMesh/initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.C index 9164a0b15d3..464b4e3702c 100644 --- a/src/mesh/conformalVoronoiMesh/initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.C +++ b/src/mesh/conformalVoronoiMesh/initialPointsMethod/hierarchicalDensityWeightedStochastic/hierarchicalDensityWeightedStochastic.C @@ -92,6 +92,8 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill word newName = recursionName + "_" + Foam::name(i); + // cvMesh_.timeCheck(); + if (geometry.overlaps(subBB)) { if (levelLimit > 0) @@ -112,6 +114,8 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill // word(newName + "_overlap") // ); + // Info<< newName + "_overlap " << subBB << endl; + if (!fillBox(initialPoints, subBB, true)) { recurseAndFill @@ -132,6 +136,8 @@ void Foam::hierarchicalDensityWeightedStochastic::recurseAndFill // newName + "_inside" // ); + // Info<< newName + "_inside " << subBB << endl; + if (!fillBox(initialPoints, subBB, false)) { recurseAndFill @@ -221,22 +227,20 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox pointField corners(bb.points()); - scalarField cornerSizes(8, 0.0); - - Field<bool> insideCorners(8, true); - - cornerSizes = cvMesh_.cellSizeControl().cellSize + scalarField cornerSizes = cvMesh_.cellSizeControl().cellSize ( corners, List<bool>(8, false) ); - insideCorners = geometry.wellInside + Field<bool> insideCorners = geometry.wellInside ( corners, minimumSurfaceDistanceCoeffSqr_*sqr(cornerSizes) ); + // Info<< corners << nl << cornerSizes << nl << insideCorners << endl; + forAll(insideCorners, i) { // Use the sizes to improve the min/max cell size estimate @@ -254,8 +258,11 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (maxCellSize/minCellSize > maxSizeRatio_) { - // Info<< "Abort fill at corner sample stage, maxSizeRatio = " - // << maxCellSize/minCellSize << endl; + // Info<< "Abort fill at corner sample stage," + // << " minCellSize " << minCellSize + // << " maxCellSize " << maxCellSize + // << " maxSizeRatio " << maxCellSize/minCellSize + // << endl; return false; } @@ -363,8 +370,10 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (maxCellSize/minCellSize > maxSizeRatio_) { // Info<< "Abort fill at surface sample stage, " - // << "maxSizeRatio = " - // << maxCellSize/minCellSize << endl; + // << " minCellSize " << minCellSize + // << " maxCellSize " << maxCellSize + // << " maxSizeRatio " << maxCellSize/minCellSize + // << endl; return false; } @@ -462,8 +471,11 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (maxCellSize/minCellSize > maxSizeRatio_) { - // Info<< "Abort fill at sample stage, maxSizeRatio = " - // << maxCellSize/minCellSize << endl; + // Info<< "Abort fill at sample stage," + // << " minCellSize " << minCellSize + // << " maxCellSize " << maxCellSize + // << " maxSizeRatio " << maxCellSize/minCellSize + // << endl; return false; } @@ -535,7 +547,7 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (addProbability > r) { - // Do not place this volume, finished filling this + // Place this volume before finishing filling this // box // Info<< "Final volume probability break accept" @@ -572,68 +584,64 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox { trialPoints++; - point p = - min - + vector - ( - span.x()*rnd.scalar01(), - span.y()*rnd.scalar01(), - span.z()*rnd.scalar01() - ); + point p = min + cmptMultiply(span, rnd.vector01()); scalar localSize = cvMesh_.cellSizeControl().cellSize(p); - if (localSize > maxCellSize) - { - maxCellSize = localSize; - } + bool insidePoint = false; - if (localSize < minCellSize) + if (!overlapping) { - minCellSize = max(localSize, minCellSizeLimit_); - - localSize = minCellSize; - - // 1/(minimum cell size)^3, gives the maximum permissible point - // density - maxDensity = 1/pow3(max(minCellSize, SMALL)); + insidePoint = true; } - - if (maxCellSize/minCellSize > maxSizeRatio_) + else { - // Info<< "Abort fill at random fill stage, maxSizeRatio = " - // << maxCellSize/minCellSize << endl; - - // Discard any points already filled into this box by setting - // size of initialPoints back to its starting value - initialPoints.resize(initialSize); - - return false; + // Determine if the point is "wellInside" the domain + insidePoint = geometry.wellInside + ( + p, + minimumSurfaceDistanceCoeffSqr_*sqr(localSize) + ); } - scalar localDensity = 1/pow3(max(localSize, SMALL)); - - // Accept possible placements proportional to the relative local - // density - if (localDensity/maxDensity > rnd.scalar01()) + if (insidePoint) { - bool insidePoint = false; + if (localSize > maxCellSize) + { + maxCellSize = localSize; + } - if (!overlapping) + if (localSize < minCellSize) { - insidePoint = true; + minCellSize = max(localSize, minCellSizeLimit_); + + localSize = minCellSize; + + // 1/(minimum cell size)^3, gives the maximum permissible + // point density + maxDensity = 1/pow3(max(minCellSize, SMALL)); } - else + + if (maxCellSize/minCellSize > maxSizeRatio_) { - // Determine if the point is "wellInside" the domain - insidePoint = geometry.wellInside - ( - p, - minimumSurfaceDistanceCoeffSqr_*sqr(localSize) - ); + // Info<< "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 + initialPoints.resize(initialSize); + + return false; } - if (insidePoint) + scalar localDensity = 1/pow3(max(localSize, SMALL)); + + // Accept possible placements proportional to the relative local + // density + if (localDensity/maxDensity > rnd.scalar01()) { scalar localVolume = 1/localDensity; @@ -657,7 +665,7 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox if (addProbability > r) { - // Do not place this volume, finished filling this + // Place this volume before finishing filling this // box // Info<< "Final volume probability break accept" @@ -687,7 +695,8 @@ bool Foam::hierarchicalDensityWeightedStochastic::fillBox // Info<< trialPoints // << " locations queried, " << initialPoints.size() - initialSize // << " points placed, (" - // << scalar(initialPoints.size() - initialSize)/scalar(trialPoints) + // << scalar(initialPoints.size() - initialSize) + // /scalar(max(trialPoints, 1)) // << " success rate)." << nl // << "minCellSize " << minCellSize // << ", maxCellSize " << maxCellSize @@ -755,18 +764,22 @@ hierarchicalDensityWeightedStochastic::initialPoints() const std::vector<Vb::Point> initialPoints; + // Info<< "Filling box " << hierBB << endl; + + Info<< nl << " " << typeName << endl; + recurseAndFill ( initialPoints, hierBB, - maxLevels_, + maxLevels_ - 1, "recursionBox" ); - Info<< nl << " " << typeName << nl - << " " << initialPoints.size() << " points placed" << nl + Info<< " " << initialPoints.size() << " points placed" << nl << " " << globalTrialPoints_ << " locations queried" << nl - << " " << scalar(initialPoints.size())/scalar(globalTrialPoints_) + << " " + << scalar(initialPoints.size())/scalar(max(globalTrialPoints_, 1)) << " success rate" << endl; -- GitLab