diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C index ecfff62ac3..ddf162dd0f 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/layerParameters/layerParameters.C @@ -29,6 +29,7 @@ License #include "mathematicalConstants.H" #include "refinementSurfaces.H" #include "searchableSurfaces.H" +#include "regExp.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -300,10 +301,44 @@ Foam::layerParameters::layerParameters // readScalar(layerDict.lookup("minThickness")); } } + + + // Check whether layer specification matches any patches + const List wildCards = layersDict.keys(true); + + forAll(wildCards, i) + { + regExp re(wildCards[i]); + + bool hasMatch = false; + forAll(boundaryMesh, patchI) + { + if (re.match(boundaryMesh[patchI].name())) + { + hasMatch = true; + break; + } + } + if (!hasMatch) + { + IOWarningIn("layerParameters::layerParameters(..)", layersDict) + << "Wildcard layer specification for " << wildCards[i] + << " does not match any patch." << endl; + } + } + + const List nonWildCards = layersDict.keys(false); + + forAll(nonWildCards, i) + { + if (boundaryMesh.findPatchID(nonWildCards[i]) == -1) + { + IOWarningIn("layerParameters::layerParameters(..)", layersDict) + << "Layer specification for " << nonWildCards[i] + << " does not match any patch." << endl; + } + } } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C b/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C index a626103cd1..6bbb1c8d39 100644 --- a/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C +++ b/src/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C @@ -265,101 +265,112 @@ Foam::refinementSurfaces::refinementSurfaces zoneInside_(surfacesDict.size()), regionOffset_(surfacesDict.size()) { - labelList globalMinLevel(surfacesDict.size(), 0); - labelList globalMaxLevel(surfacesDict.size(), 0); - scalarField globalAngle(surfacesDict.size(), -GREAT); - List > regionMinLevel(surfacesDict.size()); - List > regionMaxLevel(surfacesDict.size()); - List > regionAngle(surfacesDict.size()); + // Wilcard specification : loop over all surface, all regions + // and try to find a match. + // Count number of surfaces. label surfI = 0; - forAllConstIter(dictionary, surfacesDict, iter) + forAll(allGeometry.names(), geomI) { - names_[surfI] = iter().keyword(); + const word& geomName = allGeometry_.names()[geomI]; - surfaces_[surfI] = allGeometry_.findSurfaceID(names_[surfI]); - - if (surfaces_[surfI] == -1) + if (surfacesDict.found(geomName)) { - FatalErrorIn - ( - "refinementSurfaces::refinementSurfaces" - "(const searchableSurfaces&, const dictionary>&" - ) << "No surface called " << iter().keyword() << endl - << "Valid surfaces are " << allGeometry_.names() - << exit(FatalError); + surfI++; } - const dictionary& dict = surfacesDict.subDict(iter().keyword()); + } - const labelPair refLevel(dict.lookup("level")); - globalMinLevel[surfI] = refLevel[0]; - globalMaxLevel[surfI] = refLevel[1]; + // Size lists + surfaces_.setSize(surfI); + names_.setSize(surfI); + faceZoneNames_.setSize(surfI); + cellZoneNames_.setSize(surfI); + zoneInside_.setSize(surfI); + regionOffset_.setSize(surfI); - // Global zone names per surface - if (dict.found("faceZone")) + labelList globalMinLevel(surfI, 0); + labelList globalMaxLevel(surfI, 0); + scalarField globalAngle(surfI, -GREAT); + List > regionMinLevel(surfI); + List > regionMaxLevel(surfI); + List > regionAngle(surfI); + + surfI = 0; + forAll(allGeometry.names(), geomI) + { + const word& geomName = allGeometry_.names()[geomI]; + + if (surfacesDict.found(geomName)) { - dict.lookup("faceZone") >> faceZoneNames_[surfI]; - dict.lookup("cellZone") >> cellZoneNames_[surfI]; - dict.lookup("zoneInside") >> zoneInside_[surfI]; - } + const dictionary& dict = surfacesDict.subDict(geomName); - // Global perpendicular angle - if (dict.found("perpendicularAngle")) - { - globalAngle[surfI] = readScalar(dict.lookup("perpendicularAngle")); - } + names_[surfI] = geomName; + surfaces_[surfI] = geomI; - if (dict.found("regions")) - { - const dictionary& regionsDict = dict.subDict("regions"); - const wordList& regionNames = - allGeometry_[surfaces_[surfI]].regions(); + const labelPair refLevel(dict.lookup("level")); + globalMinLevel[surfI] = refLevel[0]; + globalMaxLevel[surfI] = refLevel[1]; - forAllConstIter(dictionary, regionsDict, iter) + // Global zone names per surface + if (dict.found("faceZone")) { - const word& key = iter().keyword(); + dict.lookup("faceZone") >> faceZoneNames_[surfI]; + dict.lookup("cellZone") >> cellZoneNames_[surfI]; + dict.lookup("zoneInside") >> zoneInside_[surfI]; + } - if (regionsDict.isDict(key)) + // Global perpendicular angle + if (dict.found("perpendicularAngle")) + { + globalAngle[surfI] = readScalar + ( + dict.lookup("perpendicularAngle") + ); + } + + if (dict.found("regions")) + { + const dictionary& regionsDict = dict.subDict("regions"); + const wordList& regionNames = + allGeometry_[surfaces_[surfI]].regions(); + + forAll(regionNames, regionI) { - // Get the dictionary for region iter.keyword() - const dictionary& regionDict = regionsDict.subDict(key); - - label regionI = findIndex(regionNames, key); - if (regionI == -1) + if (regionsDict.found(regionNames[regionI])) { - FatalErrorIn + // Get the dictionary for region + const dictionary& regionDict = regionsDict.subDict ( - "refinementSurfaces::refinementSurfaces" - "(const searchableSurfaces&, const dictionary>&" - ) << "No region called " << key << " on surface " - << allGeometry_[surfaces_[surfI]].name() << endl - << "Valid regions are " << regionNames - << exit(FatalError); - } - - const labelPair refLevel(regionDict.lookup("level")); - - regionMinLevel[surfI].insert(regionI, refLevel[0]); - regionMaxLevel[surfI].insert(regionI, refLevel[1]); - - if (regionDict.found("perpendicularAngle")) - { - regionAngle[surfI].insert - ( - regionI, - readScalar(regionDict.lookup("perpendicularAngle")) + regionNames[regionI] ); + + const labelPair refLevel(regionDict.lookup("level")); + + regionMinLevel[surfI].insert(regionI, refLevel[0]); + regionMaxLevel[surfI].insert(regionI, refLevel[1]); + + if (regionDict.found("perpendicularAngle")) + { + regionAngle[surfI].insert + ( + regionI, + readScalar + ( + regionDict.lookup("perpendicularAngle") + ) + ); + } } } } + surfI++; } - surfI++; } // Calculate local to global region offset label nRegions = 0; - forAll(surfacesDict, surfI) + forAll(surfaces_, surfI) { regionOffset_[surfI] = nRegions; nRegions += allGeometry_[surfaces_[surfI]].regions().size();