Skip to content

Commit

Permalink
ENH: snappyHexMesh: optional parameter for additional printing in lay…
Browse files Browse the repository at this point in the history
…ering
  • Loading branch information
mattijs committed Sep 20, 2011
1 parent 2e66330 commit 5ecee62
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 103 deletions.
Expand Up @@ -311,6 +311,11 @@ addLayersControls
// get used. Up to nRelaxIter it uses the settings in meshQualityControls,
// after nRelaxIter it uses the values in meshQualityControls::relaxed.
nRelaxedIter 20;

// Additional reporting: if there are just a few faces where there
// are mesh errors (after adding the layers) print their face centres.
// This helps in tracking down problematic mesh areas.
//additionalReporting true;
}

// Generic mesh quality settings. At any undoable phase these determine
Expand Down
Expand Up @@ -46,6 +46,7 @@ Description
#include "combineFaces.H"
#include "IOmanip.H"
#include "globalIndex.H"
#include "DynamicField.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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;
}


Expand Down Expand Up @@ -2858,6 +2912,7 @@ void Foam::autoLayerDriver::addLayers
(
addLayer,
meshQualityDict,
layerParams.additionalReporting(),
newMeshBaffles,
pp(),
newMesh,
Expand Down
Expand Up @@ -331,6 +331,7 @@ class autoLayerDriver
(
const addPatchCellLayer& addLayer,
const dictionary& motionDict,
const bool additionalReporting,
const List<labelPair>& baffles,
const indirectPrimitivePatch& pp,
const fvMesh&,
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
Expand Up @@ -105,6 +105,7 @@ class layerParameters

label nRelaxedIter_;

Switch additionalReporting_;

// Private Member Functions

Expand All @@ -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&);
Expand Down Expand Up @@ -259,6 +260,12 @@ public:
return nSnap_;
}

const Switch& additionalReporting() const
{
return additionalReporting_;
}


// Overall

//- Number of overall layer addition iterations
Expand Down

0 comments on commit 5ecee62

Please sign in to comment.