diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 257c31df53..6fb8e69b96 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -539,7 +539,7 @@ int main(int argc, char *argv[]) cloud::prefix/cloudDirs[i] ); - IOobject* positionsPtr = sprayObjs.lookup("positions"); + IOobject* positionsPtr = sprayObjs.lookup(word("positions")); if (positionsPtr) { diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index c774d5012c..c4a15f97b6 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -529,10 +529,8 @@ int main(int argc, char *argv[]) cloud::prefix/cloudDirs[i] ); - IOobject* positionsPtr = sprayObjs.lookup - ( - "positions" - ); + IOobject* positionsPtr = + sprayObjs.lookup(word("positions")); if (positionsPtr) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C index 53ee48b894..edb29d3998 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C @@ -98,7 +98,7 @@ bool inFileNameList int main(int argc, char *argv[]) { timeSelector::addOptions(); -# include "addRegionOption.H" + #include "addRegionOption.H" argList::addBoolOption ( @@ -129,17 +129,17 @@ int main(int argc, char *argv[]) "specify faceZones to write - eg '( slice \"mfp-.*\" )'." ); -# include "setRootCase.H" + #include "setRootCase.H" // Check options const bool binary = !args.optionFound("ascii"); const bool nodeValues = args.optionFound("nodeValues"); -# include "createTime.H" + #include "createTime.H" instantList Times = timeSelector::select0(runTime, args); -# include "createNamedMesh.H" + #include "createNamedMesh.H" // Mesh instance (region0 gets filtered out) fileName regionPrefix = ""; @@ -228,7 +228,7 @@ int main(int argc, char *argv[]) IOobjectList objects(mesh, runTime.timeName()); -# include "checkMeshMoving.H" + #include "checkMeshMoving.H" if (meshMoving) { @@ -275,7 +275,7 @@ int main(int argc, char *argv[]) cloud::prefix/cloudDirs[cloudI] ); - IOobject* positionsPtr = cloudObjs.lookup("positions"); + IOobject* positionsPtr = cloudObjs.lookup(word("positions")); if (positionsPtr) { @@ -388,7 +388,7 @@ int main(int argc, char *argv[]) { const word& fieldName = fieldNames[j]; -# include "checkData.H" + #include "checkData.H" if (!variableGood) { @@ -551,7 +551,7 @@ int main(int argc, char *argv[]) } } -# include "ensightCaseTail.H" + #include "ensightCaseTail.H" if (Pstream::master()) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C index 2b15f61a59..c58a008c50 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C @@ -131,8 +131,8 @@ int main(int argc, char *argv[]) const char* geometryName = "geometry"; -# include "setRootCase.H" -# include "createTime.H" + #include "setRootCase.H" + #include "createTime.H" // get times list instantList timeDirs = timeSelector::select0(runTime, args); @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) mkDir(ensightDir); mkDir(dataDir); -# include "createNamedMesh.H" + #include "createNamedMesh.H" // Mesh instance (region0 gets filtered out) fileName regionPrefix; @@ -203,8 +203,8 @@ int main(int argc, char *argv[]) partsList.writeSummary(partsInfoFile); } -# include "checkHasMovingMesh.H" -# include "findFields.H" + #include "checkHasMovingMesh.H" + #include "findFields.H" if (hasMovingMesh && optNoMesh) { @@ -233,7 +233,7 @@ int main(int argc, char *argv[]) { runTime.setTime(timeDirs[timeI], timeI); -# include "getTimeIndex.H" + #include "getTimeIndex.H" // remember the time index fieldTimesUsed.append(timeIndex); @@ -250,7 +250,7 @@ int main(int argc, char *argv[]) << subDir.c_str() << " " << runTime.timeName() << nl; } -# include "moveMesh.H" + #include "moveMesh.H" if (timeI == 0 || mesh.moving()) { @@ -380,7 +380,8 @@ int main(int argc, char *argv[]) ); // check that the positions field is present for this time - if (cloudObjs.lookup("positions")) + IOobject* positionPtr = cloudObjs.lookup(word("positions")); + if (positionPtr != NULL) { ensightParticlePositions ( @@ -459,7 +460,7 @@ int main(int argc, char *argv[]) } } -# include "ensightOutputCase.H" + #include "ensightOutputCase.H" Info<< "\nEnd\n"<< endl; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index d74211866e..d29bfeca1a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -386,7 +386,7 @@ int main(int argc, char *argv[]) instantList timeDirs = timeSelector::select0(runTime, args); -# include "createNamedMesh.H" + #include "createNamedMesh.H" // VTK/ directory in the case fileName fvPath(runTime.path()/"VTK"); @@ -448,7 +448,7 @@ int main(int argc, char *argv[]) cloud::prefix/cloudDirs[i] ); - IOobject* positionsPtr = sprayObjs.lookup("positions"); + IOobject* positionsPtr = sprayObjs.lookup(word("positions")); if (positionsPtr) { @@ -1094,7 +1094,7 @@ int main(int argc, char *argv[]) cloud::prefix/cloudName ); - IOobject* positionsPtr = sprayObjs.lookup("positions"); + IOobject* positionsPtr = sprayObjs.lookup(word("positions")); if (positionsPtr) { diff --git a/applications/utilities/postProcessing/graphics/PV398Readers/PV398FoamReader/vtkPV398Foam/vtkPV398FoamMeshLagrangian.C b/applications/utilities/postProcessing/graphics/PV398Readers/PV398FoamReader/vtkPV398Foam/vtkPV398FoamMeshLagrangian.C index 7c4aa8f680..294c5422af 100644 --- a/applications/utilities/postProcessing/graphics/PV398Readers/PV398FoamReader/vtkPV398Foam/vtkPV398FoamMeshLagrangian.C +++ b/applications/utilities/postProcessing/graphics/PV398Readers/PV398FoamReader/vtkPV398Foam/vtkPV398FoamMeshLagrangian.C @@ -63,7 +63,7 @@ vtkPolyData* Foam::vtkPV398Foam::lagrangianVTKMesh cloud::prefix/cloudName ); - IOobject* positionsPtr = sprayObjs.lookup("positions"); + IOobject* positionsPtr = sprayObjs.lookup(word("positions")); if (positionsPtr) { Cloud parcels(mesh, cloudName, false); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C index f9b283a8f1..d90a5162de 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -63,7 +63,7 @@ vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh cloud::prefix/cloudName ); - IOobject* positionsPtr = sprayObjs.lookup("positions"); + IOobject* positionsPtr = sprayObjs.lookup(word("positions")); if (positionsPtr) { Cloud parcels(mesh, cloudName, false); diff --git a/applications/utilities/preProcessing/mapFields/mapLagrangian.C b/applications/utilities/preProcessing/mapFields/mapLagrangian.C index 37ad7c26c2..562990dffd 100644 --- a/applications/utilities/preProcessing/mapFields/mapLagrangian.C +++ b/applications/utilities/preProcessing/mapFields/mapLagrangian.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -120,7 +120,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp) cloud::prefix/cloudDirs[cloudI] ); - IOobject* positionsPtr = objects.lookup("positions"); + IOobject* positionsPtr = objects.lookup(word("positions")); if (positionsPtr) { diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectList.C b/src/OpenFOAM/db/IOobjectList/IOobjectList.C index 128de963c7..4c15c59ebd 100644 --- a/src/OpenFOAM/db/IOobjectList/IOobjectList.C +++ b/src/OpenFOAM/db/IOobjectList/IOobjectList.C @@ -148,7 +148,7 @@ Foam::IOobject* Foam::IOobjectList::lookup(const word& name) const } -Foam::IOobjectList Foam::IOobjectList::lookupRe(const wordRe& name) const +Foam::IOobjectList Foam::IOobjectList::lookup(const wordRe& name) const { IOobjectList objectsOfName(size()); @@ -169,6 +169,29 @@ Foam::IOobjectList Foam::IOobjectList::lookupRe(const wordRe& name) const } +Foam::IOobjectList Foam::IOobjectList::lookup(const wordReList& patterns) const +{ + wordReListMatcher names(patterns); + + IOobjectList objectsOfName(size()); + + forAllConstIter(HashPtrTable, *this, iter) + { + if (names.match(iter()->name())) + { + if (IOobject::debug) + { + Info<< "IOobjectList::lookupRe : found " << iter.key() << endl; + } + + objectsOfName.insert(iter.key(), new IOobject(*iter())); + } + } + + return objectsOfName; +} + + Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& ClassName) const { IOobjectList objectsOfClass(size()); diff --git a/src/OpenFOAM/db/IOobjectList/IOobjectList.H b/src/OpenFOAM/db/IOobjectList/IOobjectList.H index 945042b728..76edfe4f67 100644 --- a/src/OpenFOAM/db/IOobjectList/IOobjectList.H +++ b/src/OpenFOAM/db/IOobjectList/IOobjectList.H @@ -37,6 +37,7 @@ SourceFiles #include "HashPtrTable.H" #include "IOobject.H" +#include "wordReList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -92,7 +93,10 @@ public: IOobject* lookup(const word& name) const; //- Return the list for all IOobects whose name matches name - IOobjectList lookupRe(const wordRe& name) const; + IOobjectList lookup(const wordRe& name) const; + + //- Return the list for all IOobects whose name matches name + IOobjectList lookup(const wordReList& patterns) const; //- Return the list for all IOobjects of a given class IOobjectList lookupClass(const word& className) const; diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.H b/src/OpenFOAM/db/objectRegistry/objectRegistry.H index 535dffe3bd..babb8a5890 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.H +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.H @@ -37,6 +37,7 @@ SourceFiles #include "HashTable.H" #include "regIOobject.H" +#include "wordReList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -147,6 +148,14 @@ public: template wordList names() const; + //- Return the list of objects whose name matches the input regExp + template + wordList names(const wordRe& name) const; + + //- Return the list of objects whose name matches the input regExp + template + wordList names(const wordReList& name) const; + //- Lookup and return a const sub-objectRegistry. Optionally create // it if it does not exist. const objectRegistry& subRegistry @@ -163,10 +172,6 @@ public: template HashTable lookupClass(const bool strict = false); - //- Return the list of objects whose name matches the input regExp - template - wordList foundObjectRe(const wordRe& name) const; - //- Is the named Type found? template bool foundObject(const word& name) const; diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C b/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C index 1b3e9ef701..b5b555485f 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "objectRegistry.H" - +#include "stringListOps.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -48,6 +48,40 @@ Foam::wordList Foam::objectRegistry::names() const } +template +Foam::wordList Foam::objectRegistry::names(const wordRe& name) const +{ + wordList objectNames(size()); + + label count = 0; + forAllConstIter(HashTable, *this, iter) + { + if (isA(*iter())) + { + const word& objectName = iter()->name(); + + if (name.match(objectName)) + { + objectNames[count++] = objectName; + } + } + } + + objectNames.setSize(count); + + return objectNames; +} + + +template +Foam::wordList Foam::objectRegistry::names(const wordReList& patterns) const +{ + wordList names(this->names()); + + return wordList(names, findStrings(patterns, names)); +} + + template Foam::HashTable Foam::objectRegistry::lookupClass ( @@ -127,31 +161,6 @@ bool Foam::objectRegistry::foundObject(const word& name) const } -template -Foam::wordList Foam::objectRegistry::foundObjectRe(const wordRe& name) const -{ - wordList objectNames(size()); - - label count = 0; - forAllConstIter(HashTable, *this, iter) - { - if (isA(*iter())) - { - const word& objectName = iter()->name(); - - if (name.match(objectName)) - { - objectNames[count++] = objectName; - } - } - } - - objectNames.setSize(count); - - return objectNames; -} - - template const Type& Foam::objectRegistry::lookupObject(const word& name) const { diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index c17e54be53..7be8181211 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -737,7 +737,7 @@ Foam::labelHashSet Foam::polyBoundaryMesh::patchSet forAll(patchNames, i) { - const word& patchName = patchNames[i]; + const wordRe& patchName = patchNames[i]; // Treat the given patch names as wild-cards and search the set // of all patch names for matches diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H index 587e67108c..e45044c997 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordRe.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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -123,7 +123,7 @@ public: inline wordRe(const keyType&, const compOption=LITERAL); //- Construct as copy of word - inline wordRe(const word&); + inline explicit wordRe(const word&); //- Construct as copy of character array // Optionally specify how it should be treated.