From 306e43fa40a2a1403779f3d6db4bc5ed4090bd7e Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 7 Sep 2012 15:11:21 +0100 Subject: [PATCH] ENH: shellSurfaces: allow wildcards --- .../autoHexMesh/shellSurfaces/shellSurfaces.C | 94 ++++++------------- .../autoHexMesh/shellSurfaces/shellSurfaces.H | 19 +--- 2 files changed, 30 insertions(+), 83 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.C b/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.C index 1d8ec76b84..bc3289f18e 100644 --- a/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.C +++ b/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.C @@ -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 @@ -357,51 +357,6 @@ void Foam::shellSurfaces::findHigherLevel // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::shellSurfaces::shellSurfaces -( - const searchableSurfaces& allGeometry, - const PtrList& shellDicts -) -: - allGeometry_(allGeometry) -{ - shells_.setSize(shellDicts.size()); - modes_.setSize(shellDicts.size()); - distances_.setSize(shellDicts.size()); - levels_.setSize(shellDicts.size()); - - forAll(shellDicts, shellI) - { - const dictionary& dict = shellDicts[shellI]; - const word name = dict.lookup("name"); - const word type = dict.lookup("type"); - - shells_[shellI] = allGeometry_.findSurfaceID(name); - - if (shells_[shellI] == -1) - { - FatalErrorIn - ( - "shellSurfaces::shellSurfaces" - "(const searchableSurfaces&, const PtrList&)" - ) << "No surface called " << name << endl - << "Valid surfaces are " << allGeometry_.names() - << exit(FatalError); - } - - modes_[shellI] = refineModeNames_.read(dict.lookup("refineMode")); - - // Read pairs of distance+level - setAndCheckLevels(shellI, dict.lookup("levels")); - } - - // Orient shell surfaces before any searching is done. Note that this - // only needs to be done for inside or outside. Orienting surfaces - // constructs lots of addressing which we want to avoid. - orient(); -} - - Foam::shellSurfaces::shellSurfaces ( const searchableSurfaces& allGeometry, @@ -410,34 +365,43 @@ Foam::shellSurfaces::shellSurfaces : allGeometry_(allGeometry) { - shells_.setSize(shellsDict.size()); - modes_.setSize(shellsDict.size()); - distances_.setSize(shellsDict.size()); - levels_.setSize(shellsDict.size()); + // Wilcard specification : loop over all surfaces and try to find a match. + // Count number of shells. label shellI = 0; - forAllConstIter(dictionary, shellsDict, iter) + forAll(allGeometry.names(), geomI) { - shells_[shellI] = allGeometry_.findSurfaceID(iter().keyword()); + const word& geomName = allGeometry_.names()[geomI]; - if (shells_[shellI] == -1) + if (shellsDict.found(geomName)) { - FatalErrorIn - ( - "shellSurfaces::shellSurfaces" - "(const searchableSurfaces&, const dictionary>&" - ) << "No surface called " << iter().keyword() << endl - << "Valid surfaces are " << allGeometry_.names() - << exit(FatalError); + shellI++; } - const dictionary& dict = shellsDict.subDict(iter().keyword()); + } - modes_[shellI] = refineModeNames_.read(dict.lookup("mode")); - // Read pairs of distance+level - setAndCheckLevels(shellI, dict.lookup("levels")); + // Size lists + shells_.setSize(shellI); + modes_.setSize(shellI); + distances_.setSize(shellI); + levels_.setSize(shellI); - shellI++; + shellI = 0; + forAll(allGeometry.names(), geomI) + { + const word& geomName = allGeometry_.names()[geomI]; + + if (shellsDict.found(geomName)) + { + shells_[shellI] = geomI; + const dictionary& dict = shellsDict.subDict(geomName); + modes_[shellI] = refineModeNames_.read(dict.lookup("mode")); + + // Read pairs of distance+level + setAndCheckLevels(shellI, dict.lookup("levels")); + + shellI++; + } } // Orient shell surfaces before any searching is done. Note that this diff --git a/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.H b/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.H index 96a55b5500..9b0e4c9e05 100644 --- a/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.H +++ b/src/mesh/autoMesh/autoHexMesh/shellSurfaces/shellSurfaces.H @@ -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 @@ -113,23 +113,6 @@ public: // Constructors - //- Construct from components - shellSurfaces - ( - const searchableSurfaces& allGeometry, - const labelList& shells, - const List& modes, - const List& distances, - const labelListList& levels - ); - - //- Construct from geometry and dictionaries - shellSurfaces - ( - const searchableSurfaces& allGeometry, - const PtrList& shellDicts - ); - //- Construct from geometry and dictionary shellSurfaces (