From 6084361ca3ebd846782173a10f0e4622dd88ff00 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Tue, 20 Sep 2011 13:45:25 +0100 Subject: [PATCH] ENH: autoLayerDriver: additional printing in checkAndUnmark --- .../autoHexMeshDriver/autoLayerDriver.C | 57 +++++- .../autoHexMeshDriver/autoLayerDriver.H | 1 + .../layerParameters/layerParameters.C | 187 +++++++++--------- .../layerParameters/layerParameters.H | 25 ++- 4 files changed, 167 insertions(+), 103 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 10d6499905c..c494366f40b 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -46,6 +46,7 @@ Description #include "combineFaces.H" #include "IOmanip.H" #include "globalIndex.H" +#include "DynamicField.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -1990,6 +1991,7 @@ Foam::label Foam::autoLayerDriver::checkAndUnmark ( const addPatchCellLayer& addLayer, const dictionary& meshQualityDict, + const bool additionalReporting, const List<labelPair>& baffles, const indirectPrimitivePatch& pp, const fvMesh& newMesh, @@ -2032,6 +2034,12 @@ Foam::label Foam::autoLayerDriver::checkAndUnmark ); // Check if any of the faces in error uses any face of an added cell + // - if additionalReporting print the few remaining areas for ease of + // finding out where the problems are. + + const label nReportMax = 10; + DynamicField<point> disabledFaceCentres(nReportMax); + forAll(addedCells, oldPatchFaceI) { // Get the cells (in newMesh labels) per old patch face (in mesh @@ -2052,12 +2060,58 @@ Foam::label Foam::autoLayerDriver::checkAndUnmark ) ) { + if (additionalReporting && (nChanged < nReportMax)) + { + disabledFaceCentres.append + ( + pp.faceCentres()[oldPatchFaceI] + ); + } + nChanged++; } } } - return returnReduce(nChanged, sumOp<label>()); + + label nChangedTotal = returnReduce(nChanged, sumOp<label>()); + + if (additionalReporting) + { + // Limit the number of points to be printed so that + // not too many points are reported when running in parallel + // Not accurate, i.e. not always nReportMax points are written, + // but this estimation avoid some communication here. + // The important thing, however, is that when only a few faces + // are disabled, their coordinates are printed, and this should be + // the case + label nReportLocal = + min + ( + max(nChangedTotal / Pstream::nProcs(), 1), + min + ( + nChanged, + max(nReportMax / Pstream::nProcs(), 1) + ) + ); + + Pout<< "Checked mesh with layers. Disabled extrusion at " << endl; + for (label i=0; i < nReportLocal; i++) + { + Pout<< " " << disabledFaceCentres[i] << endl; + } + + label nReportTotal = returnReduce(nReportLocal, sumOp<label>()); + + if (nReportTotal < nChangedTotal) + { + Info<< "Suppressed disabled extrusion message for other " + << nChangedTotal - nReportTotal << " faces." << endl; + } + } + + return nChangedTotal; } @@ -2858,6 +2912,7 @@ void Foam::autoLayerDriver::addLayers ( addLayer, meshQualityDict, + layerParams.additionalReporting(), newMeshBaffles, pp(), newMesh, diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H index 9b7c4c9c5ff..6bbe54a7089 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H @@ -331,6 +331,7 @@ class autoLayerDriver ( const addPatchCellLayer& addLayer, const dictionary& motionDict, + const bool additionalReporting, const List<labelPair>& baffles, const indirectPrimitivePatch& pp, const fvMesh&, diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C index 0fcadf23227..d1f66fb6e93 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C @@ -137,98 +137,98 @@ Foam::labelList Foam::layerParameters::readNumLayers // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from dictionary -Foam::layerParameters::layerParameters -( - const PtrList<dictionary>& surfaceDicts, - const refinementSurfaces& refineSurfaces, - const labelList& globalToPatch, - const dictionary& dict, - const polyBoundaryMesh& boundaryMesh -) -: - numLayers_ - ( - readNumLayers - ( - surfaceDicts, - refineSurfaces, - globalToPatch, - boundaryMesh - ) - ), - expansionRatio_ - ( - numLayers_.size(), - readScalar(dict.lookup("expansionRatio")) - ), - relativeSizes_(false), - finalLayerThickness_ - ( - numLayers_.size(), - readScalar(dict.lookup("finalLayerRatio")) - ), - minThickness_ - ( - numLayers_.size(), - readScalar(dict.lookup("minThickness")) - ), - featureAngle_(readScalar(dict.lookup("featureAngle"))), - concaveAngle_ - ( - dict.lookupOrDefault("concaveAngle", defaultConcaveAngle) - ), - nGrow_(readLabel(dict.lookup("nGrow"))), - nSmoothSurfaceNormals_ - ( - readLabel(dict.lookup("nSmoothSurfaceNormals")) - ), - nSmoothNormals_(readLabel(dict.lookup("nSmoothNormals"))), - nSmoothThickness_(readLabel(dict.lookup("nSmoothThickness"))), - maxFaceThicknessRatio_ - ( - readScalar(dict.lookup("maxFaceThicknessRatio")) - ), - layerTerminationCos_ - ( - Foam::cos(degToRad(0.5*featureAngle_)) - ), - maxThicknessToMedialRatio_ - ( - readScalar(dict.lookup("maxThicknessToMedialRatio")) - ), - minMedianAxisAngleCos_ - ( - Foam::cos(degToRad(readScalar(dict.lookup("minMedianAxisAngle")))) - ), - nBufferCellsNoExtrude_ - ( - readLabel(dict.lookup("nBufferCellsNoExtrude")) - ), - nSnap_(readLabel(dict.lookup("nSnap"))), - nLayerIter_(readLabel(dict.lookup("nLayerIter"))), - nRelaxedIter_(labelMax) -{ - if (nGrow_ > 0) - { - WarningIn("layerParameters::layerParameters(..)") - << "The nGrow parameter effect has changed with respect to 1.6.x." - << endl - << "Please set nGrow=0 for 1.6.x behaviour." - << endl; - } - - dict.readIfPresent("nRelaxedIter", nRelaxedIter_); - - if (nLayerIter_ < 0 || nRelaxedIter_ < 0) - { - FatalErrorIn("layerParameters::layerParameters(..)") - << "Layer iterations should be >= 0." << endl - << "nLayerIter:" << nLayerIter_ - << " nRelaxedIter:" << nRelaxedIter_ - << exit(FatalError); - } -} +//// Construct from dictionary +//Foam::layerParameters::layerParameters +//( +// const PtrList<dictionary>& surfaceDicts, +// const refinementSurfaces& refineSurfaces, +// const labelList& globalToPatch, +// const dictionary& dict, +// const polyBoundaryMesh& boundaryMesh +//) +//: +// numLayers_ +// ( +// readNumLayers +// ( +// surfaceDicts, +// refineSurfaces, +// globalToPatch, +// boundaryMesh +// ) +// ), +// expansionRatio_ +// ( +// numLayers_.size(), +// readScalar(dict.lookup("expansionRatio")) +// ), +// relativeSizes_(false), +// finalLayerThickness_ +// ( +// numLayers_.size(), +// readScalar(dict.lookup("finalLayerRatio")) +// ), +// minThickness_ +// ( +// numLayers_.size(), +// readScalar(dict.lookup("minThickness")) +// ), +// featureAngle_(readScalar(dict.lookup("featureAngle"))), +// concaveAngle_ +// ( +// dict.lookupOrDefault("concaveAngle", defaultConcaveAngle) +// ), +// nGrow_(readLabel(dict.lookup("nGrow"))), +// nSmoothSurfaceNormals_ +// ( +// readLabel(dict.lookup("nSmoothSurfaceNormals")) +// ), +// nSmoothNormals_(readLabel(dict.lookup("nSmoothNormals"))), +// nSmoothThickness_(readLabel(dict.lookup("nSmoothThickness"))), +// maxFaceThicknessRatio_ +// ( +// readScalar(dict.lookup("maxFaceThicknessRatio")) +// ), +// layerTerminationCos_ +// ( +// Foam::cos(degToRad(0.5*featureAngle_)) +// ), +// maxThicknessToMedialRatio_ +// ( +// readScalar(dict.lookup("maxThicknessToMedialRatio")) +// ), +// minMedianAxisAngleCos_ +// ( +// Foam::cos(degToRad(readScalar(dict.lookup("minMedianAxisAngle")))) +// ), +// nBufferCellsNoExtrude_ +// ( +// readLabel(dict.lookup("nBufferCellsNoExtrude")) +// ), +// nSnap_(readLabel(dict.lookup("nSnap"))), +// nLayerIter_(readLabel(dict.lookup("nLayerIter"))), +// nRelaxedIter_(labelMax) +//{ +// if (nGrow_ > 0) +// { +// WarningIn("layerParameters::layerParameters(..)") +// << "The nGrow parameter effect has changed with respect to 1.6.x." +// << endl +// << "Please set nGrow=0 for 1.6.x behaviour." +// << endl; +// } +// +// dict.readIfPresent("nRelaxedIter", nRelaxedIter_); +// +// if (nLayerIter_ < 0 || nRelaxedIter_ < 0) +// { +// FatalErrorIn("layerParameters::layerParameters(..)") +// << "Layer iterations should be >= 0." << endl +// << "nLayerIter:" << nLayerIter_ +// << " nRelaxedIter:" << nRelaxedIter_ +// << exit(FatalError); +// } +//} // Construct from dictionary @@ -289,7 +289,8 @@ Foam::layerParameters::layerParameters ), nSnap_(readLabel(dict.lookup("nRelaxIter"))), nLayerIter_(readLabel(dict.lookup("nLayerIter"))), - nRelaxedIter_(labelMax) + nRelaxedIter_(labelMax), + additionalReporting_(dict.lookupOrDefault("additionalReporting", false)) { if (nGrow_ > 0) { diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.H index 58937bf69fd..e6324131e94 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.H @@ -105,6 +105,7 @@ class layerParameters label nRelaxedIter_; + Switch additionalReporting_; // Private Member Functions @@ -128,15 +129,15 @@ public: // Constructors - //- Construct from dictionary - old syntax - layerParameters - ( - const PtrList<dictionary>& surfaceDicts, - const refinementSurfaces& refineSurfaces, - const labelList& globalToPatch, - const dictionary& dict, - const polyBoundaryMesh& boundaryMesh - ); + ////- Construct from dictionary - old syntax + //layerParameters + //( + // const PtrList<dictionary>& surfaceDicts, + // const refinementSurfaces& refineSurfaces, + // const labelList& globalToPatch, + // const dictionary& dict, + // const polyBoundaryMesh& boundaryMesh + //); //- Construct from dictionary - new syntax layerParameters(const dictionary& dict, const polyBoundaryMesh&); @@ -259,6 +260,12 @@ public: return nSnap_; } + const Switch& additionalReporting() const + { + return additionalReporting_; + } + + // Overall //- Number of overall layer addition iterations -- GitLab