ENH: snappyHexMesh: allow patch groups in layer specification

This commit is contained in:
mattijs
2012-08-20 21:57:11 +01:00
parent 34395ddcd4
commit 1950db74b0
2 changed files with 39 additions and 273 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,209 +28,14 @@ License
#include "unitConversion.H"
#include "refinementSurfaces.H"
#include "searchableSurfaces.H"
#include "regExp.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::scalar Foam::layerParameters::defaultConcaveAngle = 90;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Read the number of layers from dictionary. Per patch 0 or the number
// of layers.
Foam::labelList Foam::layerParameters::readNumLayers
(
const PtrList<dictionary>& surfaceDicts,
const refinementSurfaces& refineSurfaces,
const labelList& globalToPatch,
const polyBoundaryMesh& boundaryMesh
)
{
// Per surface the number of layers
labelList globalSurfLayers(surfaceDicts.size());
// Per surface, per region the number of layers
List<Map<label> > regionSurfLayers(surfaceDicts.size());
const labelList& surfaceIndices = refineSurfaces.surfaces();
forAll(surfaceDicts, surfI)
{
const dictionary& dict = surfaceDicts[surfI];
globalSurfLayers[surfI] = readLabel(dict.lookup("surfaceLayers"));
if (dict.found("regions"))
{
// Per-region layer information
PtrList<dictionary> regionDicts(dict.lookup("regions"));
const wordList& regionNames =
refineSurfaces.geometry()[surfaceIndices[surfI]].regions();
forAll(regionDicts, dictI)
{
const dictionary& regionDict = regionDicts[dictI];
const word regionName(regionDict.lookup("name"));
label regionI = findIndex(regionNames, regionName);
label nLayers = readLabel(regionDict.lookup("surfaceLayers"));
Info<< " region " << regionName << ':'<< nl
<< " surface layers:" << nLayers << nl;
regionSurfLayers[surfI].insert(regionI, nLayers);
}
}
}
// Transfer per surface/region information into patchwise region info
labelList nLayers(boundaryMesh.size(), 0);
forAll(surfaceIndices, surfI)
{
const wordList& regionNames =
refineSurfaces.geometry()[surfaceIndices[surfI]].regions();
forAll(regionNames, regionI)
{
const word& regionName = regionNames[regionI];
label global = refineSurfaces.globalRegion(surfI, regionI);
label patchI = globalToPatch[global];
// Initialise to surface-wise layers
nLayers[patchI] = globalSurfLayers[surfI];
// Override with region specific data if available
Map<label>::const_iterator iter =
regionSurfLayers[surfI].find(regionI);
if (iter != regionSurfLayers[surfI].end())
{
nLayers[patchI] = iter();
}
// Check
if (nLayers[patchI] < 0)
{
FatalErrorIn
(
"layerParameters::readNumLayers(..)"
) << "Illegal number of layers " << nLayers[patchI]
<< " for surface "
<< refineSurfaces.names()[surfI]
<< " region " << regionName << endl
<< exit(FatalError);
}
}
}
return nLayers;
}
// * * * * * * * * * * * * * * * * 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
(
@ -315,71 +120,51 @@ Foam::layerParameters::layerParameters
const dictionary& layersDict = dict.subDict("layers");
forAll(boundaryMesh, patchI)
forAllConstIter(dictionary, layersDict, iter)
{
const word& patchName = boundaryMesh[patchI].name();
if (layersDict.found(patchName))
if (iter().isDict())
{
const dictionary& layerDict = layersDict.subDict(patchName);
numLayers_[patchI] =
readLabel(layerDict.lookup("nSurfaceLayers"));
layerDict.readIfPresent
const word& key = iter().keyword();
const labelHashSet patchIDs
(
"expansionRatio",
expansionRatio_[patchI]
boundaryMesh.patchSet(List<wordRe>(1, key))
);
layerDict.readIfPresent
(
"finalLayerThickness",
finalLayerThickness_[patchI]
);
layerDict.readIfPresent
(
"minThickness",
minThickness_[patchI]
);
}
}
// Check whether layer specification matches any patches
const List<keyType> wildCards = layersDict.keys(true);
forAll(wildCards, i)
{
regExp re(wildCards[i]);
bool hasMatch = false;
forAll(boundaryMesh, patchI)
{
if (re.match(boundaryMesh[patchI].name()))
if (patchIDs.size() == 0)
{
hasMatch = true;
break;
IOWarningIn("layerParameters::layerParameters(..)", layersDict)
<< "Layer specification for " << key
<< " does not match any patch." << endl
<< "Valid patches are " << boundaryMesh.names() << endl;
}
}
if (!hasMatch)
{
IOWarningIn("layerParameters::layerParameters(..)", layersDict)
<< "Wildcard layer specification for " << wildCards[i]
<< " does not match any patch." << endl
<< "Valid patches are " << boundaryMesh.names() << endl;
}
}
else
{
const dictionary& layerDict = iter().dict();
const List<keyType> nonWildCards = layersDict.keys(false);
forAllConstIter(labelHashSet, patchIDs, patchIter)
{
label patchI = patchIter.key();
forAll(nonWildCards, i)
{
if (boundaryMesh.findPatchID(nonWildCards[i]) == -1)
{
IOWarningIn("layerParameters::layerParameters(..)", layersDict)
<< "Layer specification for " << nonWildCards[i]
<< " does not match any patch." << endl
<< "Valid patches are " << boundaryMesh.names() << endl;
numLayers_[patchI] =
readLabel(layerDict.lookup("nSurfaceLayers"));
layerDict.readIfPresent
(
"expansionRatio",
expansionRatio_[patchI]
);
layerDict.readIfPresent
(
"finalLayerThickness",
finalLayerThickness_[patchI]
);
layerDict.readIfPresent
(
"minThickness",
minThickness_[patchI]
);
}
}
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -109,15 +109,6 @@ class layerParameters
// Private Member Functions
//- Extract patch-wise number of layers
static labelList readNumLayers
(
const PtrList<dictionary>& surfaceDicts,
const refinementSurfaces& refineSurfaces,
const labelList& globalToPatch,
const polyBoundaryMesh& boundaryMesh
);
//- Disallow default bitwise copy construct
layerParameters(const layerParameters&);
@ -129,17 +120,7 @@ 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 - new syntax
//- Construct from dictionary
layerParameters(const dictionary& dict, const polyBoundaryMesh&);