Foam::searchableSurfaces::searchableSurfaces ( const IOobject& io, const dictionary& topDict ) : PtrList<searchableSurface>(topDict.size()), names_(topDict.size()), regionNames_(topDict.size()), allSurfaces_(identity(topDict.size())) { label surfI = 0; forAllConstIter(dictionary, topDict, iter) { const word& key = iter().keyword(); if (!topDict.isDict(key)) { FatalErrorIn ( "searchableSurfaces::searchableSurfaces" "( const IOobject&, const dictionary&)" ) << "Found non-dictionary entry " << iter() << " in top-level dictionary " << topDict << exit(FatalError); } const dictionary& dict = topDict.subDict(key); names_[surfI] = key; dict.readIfPresent("name", names_[surfI]); // Make IOobject with correct name autoPtr<IOobject> namedIO(io.clone()); // Note: we would like to e.g. register triSurface 'sphere.stl' as // 'sphere'. Unfortunately // no support for having object read from different location than // their object name. Maybe have stlTriSurfaceMesh which appends .stl // when reading/writing? namedIO().rename(key); // names_[surfI] // Create and hook surface set ( surfI, searchableSurface::New ( dict.lookup("type"), namedIO(), dict ) ); const searchableSurface& s = operator[](surfI); // Construct default region names by prepending surface name // to region name. const wordList& localNames = s.regions(); wordList& rNames = regionNames_[surfI]; rNames.setSize(localNames.size()); forAll(localNames, regionI) { rNames[regionI] = names_[surfI] + '_' + localNames[regionI]; } // See if dictionary provides any global region names. if (dict.found("regions")) { const dictionary& regionsDict = dict.subDict("regions"); forAllConstIter(dictionary, regionsDict, iter) { const word& key = iter().keyword(); if (regionsDict.isDict(key)) { // Get the dictionary for region iter.keyword() const dictionary& regionDict = regionsDict.subDict(key); label index = findIndex(localNames, key); if (index == -1) { FatalErrorIn ( "searchableSurfaces::searchableSurfaces" "( const IOobject&, const dictionary&)" ) << "Unknown region name " << key << " for surface " << s.name() << endl << "Valid region names are " << localNames << exit(FatalError); } rNames[index] = word(regionDict.lookup("name")); } } } surfI++; }