From c126464d1c788839448efa0e16ecef9c43f059dc Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 21 Feb 2018 10:05:30 +0100 Subject: [PATCH] ENH: change wordRes to be a List of wordRe instead of a wrapper (issue #259) - this permits direct storage of a list with additional matcher capabilities - provide wordRes::matcher class for similar behaviour as previously --- applications/test/DirLister/DirLister.H | 8 +- applications/test/DirLister/Test-DirLister.C | 13 +- .../test/IOobjectList/Test-IOobjectList.C | 8 +- applications/test/List/Test-List.C | 17 +-- .../test/PointEdgeWave/Test-PointEdgeWave.C | 2 +- .../test/stringList/Test-stringList.C | 2 +- applications/test/wordRe/Test-wordRe.C | 3 +- .../refineWallLayer/refineWallLayer.C | 5 +- .../generation/snappyHexMesh/snappyHexMesh.C | 2 +- .../mesh/manipulation/subsetMesh/subsetMesh.C | 2 +- .../transformPoints/transformPoints.C | 6 +- .../foamToEnsight/foamToEnsight.C | 13 +- .../foamToTecplot360/foamToTecplot360.C | 13 +- .../dataConversion/foamToVTK/foamToVTK.C | 14 +-- .../changeDictionary/changeDictionary.C | 4 +- .../createZeroDirectory/boundaryTemplates.C | 2 - .../createZeroDirectory/boundaryTemplates.H | 8 +- .../createZeroDirectory/caseInfo.C | 18 +-- .../createZeroDirectory/caseInfo.H | 6 +- .../preProcessing/mapFieldsPar/mapFieldsPar.C | 15 +-- .../surfaceMeshTriangulate.C | 8 +- .../searchableSurfaceModifier/cut.C | 14 +-- .../searchableSurfaceModifier/cut.H | 6 +- .../surfaceTransformPoints.C | 6 +- .../functionObjectList/functionObjectList.C | 12 +- .../functionObjectList/functionObjectList.H | 6 +- .../regionFunctionObject.C | 6 - .../regionFunctionObject.H | 2 +- src/OpenFOAM/global/argList/argList.H | 16 +++ src/OpenFOAM/global/argList/argListI.H | 69 +++++++--- .../primitives/strings/keyType/keyType.C | 11 +- .../primitives/strings/keyType/keyType.H | 3 +- .../primitives/strings/lists/stringListOps.H | 69 ++++++---- .../strings/lists/stringListOpsTemplates.C | 5 +- .../primitives/strings/string/string.H | 5 +- .../primitives/strings/stringOps/stringOps.H | 6 +- .../primitives/strings/wordRe/wordRe.H | 3 +- .../primitives/strings/wordRe/wordReI.H | 6 +- .../strings/wordRes/wordReListMatcher.H | 19 +-- .../primitives/strings/wordRes/wordRes.C | 31 +++-- .../primitives/strings/wordRes/wordRes.H | 119 ++++++++---------- .../primitives/strings/wordRes/wordResI.H | 74 +++-------- src/conversion/ccm/reader/ccmSolutionTable.H | 16 +-- src/conversion/common/tables/boundaryRegion.C | 13 +- src/conversion/common/tables/boundaryRegion.H | 8 +- src/conversion/common/tables/cellTable.C | 19 +-- src/conversion/common/tables/cellTable.H | 13 +- src/conversion/ensight/mesh/ensightMesh.C | 10 +- src/conversion/ensight/mesh/ensightMesh.H | 16 +-- .../ensight/mesh/ensightMeshOptions.C | 26 ++-- .../cfdTools/general/MRF/MRFZone.C | 2 +- .../cfdTools/general/MRF/MRFZone.H | 2 +- .../solutionControl/loopControl/loopControl.C | 1 - .../solutionControl/loopControl/loopControl.H | 8 +- .../fvMeshFunctionObject.C | 6 - .../fvMeshFunctionObject.H | 3 +- src/functionObjects/field/ddt2/ddt2.C | 42 +++---- src/functionObjects/field/ddt2/ddt2.H | 11 +- .../heatTransferCoeffModel.C | 5 +- .../field/mapFields/mapFields.C | 6 - .../field/mapFields/mapFields.H | 6 +- .../regionSizeDistribution.H | 8 +- .../field/zeroGradient/zeroGradient.C | 34 ++--- .../field/zeroGradient/zeroGradient.H | 10 +- .../utilities/ensightWrite/ensightWrite.C | 25 ++-- .../utilities/ensightWrite/ensightWrite.H | 5 +- .../utilities/vtkWrite/vtkWrite.C | 8 +- .../utilities/vtkWrite/vtkWrite.H | 4 +- .../utilities/writeObjects/writeObjects.C | 23 ++-- .../utilities/writeObjects/writeObjects.H | 6 +- .../inverseDistanceDiffusivity.C | 6 - .../inverseDistanceDiffusivity.H | 8 +- .../inversePointDistanceDiffusivity.C | 6 - .../inversePointDistanceDiffusivity.H | 7 +- src/meshTools/cellDist/cellDistFuncs.C | 2 +- src/meshTools/cellDist/cellDistFuncs.H | 4 +- .../subTriSurfaceMesh/subTriSurfaceMesh.C | 12 +- .../subTriSurfaceMesh/subTriSurfaceMesh.H | 6 +- .../triSurfaceLoader/triSurfaceLoader.C | 20 +-- .../triSurfaceLoader/triSurfaceLoader.H | 8 +- .../preserveFaceZonesConstraint.C | 2 +- .../preserveFaceZonesConstraint.H | 9 +- .../preservePatchesConstraint.C | 2 +- .../preservePatchesConstraint.H | 9 +- .../decompositionMethod/decompositionMethod.C | 2 +- .../structuredDecomp/structuredDecomp.H | 6 +- .../contactAngleForce/contactAngleForce.C | 4 +- .../structuredRenumber/structuredRenumber.C | 4 +- .../structuredRenumber/structuredRenumber.H | 13 +- .../rigidBodyMeshMotion/rigidBodyMeshMotion.C | 12 +- .../rigidBodyMeshMotion/rigidBodyMeshMotion.H | 16 +-- .../rigidBodyMeshMotionSolver.C | 12 +- .../rigidBodyMeshMotionSolver.H | 9 +- src/sampling/probes/patchProbes.C | 13 +- src/sampling/probes/patchProbes.H | 6 +- src/sampling/probes/probes.C | 7 +- src/sampling/probes/probes.H | 10 +- .../sampledSet/patchCloud/patchCloudSet.C | 6 - .../sampledSet/patchCloud/patchCloudSet.H | 2 +- .../sampledSet/patchSeed/patchSeedSet.C | 6 - .../sampledSet/patchSeed/patchSeedSet.H | 2 +- .../sampledSet/sampledSets/sampledSets.C | 8 +- .../sampledSet/sampledSets/sampledSets.H | 8 +- .../sampledPatch/sampledPatch.C | 13 +- .../sampledPatch/sampledPatch.H | 11 +- .../sampledSurfaces/sampledSurfaces.H | 6 +- .../surfMeshSampler/surfMeshSampler.C | 16 +-- .../surfMeshSampler/surfMeshSampler.H | 12 +- .../surfMeshSamplerTemplates.C | 12 +- .../surfMeshSamplers/surfMeshSamplers.C | 27 ++-- .../surfMeshSamplers/surfMeshSamplers.H | 8 +- .../sixDoFRigidBodyMotionSolver.C | 17 +-- .../sixDoFRigidBodyMotionSolver.H | 11 +- 113 files changed, 572 insertions(+), 801 deletions(-) diff --git a/applications/test/DirLister/DirLister.H b/applications/test/DirLister/DirLister.H index e1108e7122..497b15c07e 100644 --- a/applications/test/DirLister/DirLister.H +++ b/applications/test/DirLister/DirLister.H @@ -55,7 +55,7 @@ Description items: \code { - wordReList matchProcs + wordRes matchProcs { wordRe("processors"), wordRe("processor\\d+", wordRe::REGEX) @@ -64,7 +64,7 @@ Description for ( const word& item - : DirLister::dirs(".").where(wordRes(matchProcs)) + : DirLister::dirs(".").where(matchProcs) ) { Info<< "processor dir: " << item << nl; @@ -75,7 +75,7 @@ Description methods: \code { - wordReList matchProcs + wordRes matchProcs { wordRe("processor[0-9][0-9]*", wordRe::REGEX), wordRe("processors") @@ -83,7 +83,7 @@ Description fileNameList procDirs ( - DirLister::dirs(".").sorted(wordRes(matchProcs)) + DirLister::dirs(".").sorted(matchProcs) ); } \endcode diff --git a/applications/test/DirLister/Test-DirLister.C b/applications/test/DirLister/Test-DirLister.C index b528a1558a..50803da990 100644 --- a/applications/test/DirLister/Test-DirLister.C +++ b/applications/test/DirLister/Test-DirLister.C @@ -144,16 +144,15 @@ int main(int argc, char *argv[]) << "List files - filtered" << nl << "~~~~~~~~~~" << nl; - wordReList relist - { + wordRes relist + ({ wordRe("processors"), wordRe("processor[0-9][0-9]*", wordRe::REGEX) - }; - wordRes matcher(relist); + }); - Info<<"matcher: " << flatOutput(matcher) << endl; + Info<<"matcher: " << flatOutput(relist) << endl; - for (const word& item : DirLister::dirs(".").where(wordRes(relist))) + for (const word& item : DirLister::dirs(".").where(relist)) { Info<< "=> " << item << nl; } @@ -161,7 +160,7 @@ int main(int argc, char *argv[]) Info<< "dirList: " << flatOutput ( - DirLister::dirs(".").sorted(wordRes(relist)) + DirLister::dirs(".").sorted(relist) ) << nl; } diff --git a/applications/test/IOobjectList/Test-IOobjectList.C b/applications/test/IOobjectList/Test-IOobjectList.C index 21ab2fafaf..40b1f42e7e 100644 --- a/applications/test/IOobjectList/Test-IOobjectList.C +++ b/applications/test/IOobjectList/Test-IOobjectList.C @@ -40,7 +40,7 @@ using namespace Foam; int main(int argc, char *argv[]) { argList::noParallel(); - argList::addOption("re", "wordReList"); + argList::addOption("re", "wordRes"); // timeSelector::addOptions(); timeSelector::addOptions(true, true); @@ -48,12 +48,10 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" - wordReList matcher; - if (args.found("re")) + wordRes matcher; + if (args.readListIfPresent("re", matcher)) { - matcher = args.readList("re"); Info<<"limit names: " << matcher << nl; - } const hashedWordList subsetTypes diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index 945b0e9998..1628b6f9ed 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -34,7 +34,7 @@ See also #include "OSspecific.H" #include "argList.H" -#include "wordReList.H" +#include "wordRes.H" #include "IOstreams.H" #include "StringStream.H" @@ -446,20 +446,11 @@ int main(int argc, char *argv[]) Info<<"read float " << xxx << endl; } - if (args.found("reList")) - { - reLst = args.readList("reList"); - } + args.readListIfPresent("reList", reLst); + args.readListIfPresent("wordList", wLst); - if (args.found("wordList")) + if (args.readListIfPresent("stringList", sLst)) { - wLst = args.readList("wordList"); - } - - if (args.found("stringList")) - { - sLst = args.readList("stringList"); - printMyString(sLst); } diff --git a/applications/test/PointEdgeWave/Test-PointEdgeWave.C b/applications/test/PointEdgeWave/Test-PointEdgeWave.C index 8735043f78..ea2419c772 100644 --- a/applications/test/PointEdgeWave/Test-PointEdgeWave.C +++ b/applications/test/PointEdgeWave/Test-PointEdgeWave.C @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) labelList patchIDs ( - pbm.patchSet(wordReList(IStringStream(args[1])())).sortedToc() + pbm.patchSet(args.readList(1)).sortedToc() ); Info<< "Starting walk from patches " diff --git a/applications/test/stringList/Test-stringList.C b/applications/test/stringList/Test-stringList.C index f4ea77f062..60db8cfc7c 100644 --- a/applications/test/stringList/Test-stringList.C +++ b/applications/test/stringList/Test-stringList.C @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) "okkkey", }; - wordReList reLst(IStringStream("( okey \"[hy]e+.*\" )")()); + wordRes reLst(IStringStream("( okey \"[hy]e+.*\" )")()); Info<< "stringList " << strLst << nl; diff --git a/applications/test/wordRe/Test-wordRe.C b/applications/test/wordRe/Test-wordRe.C index 5504e66a1e..80247a11e0 100644 --- a/applications/test/wordRe/Test-wordRe.C +++ b/applications/test/wordRe/Test-wordRe.C @@ -31,7 +31,6 @@ Description #include "List.H" #include "Tuple2.H" #include "keyType.H" -#include "wordRe.H" #include "wordRes.H" #include "predicates.H" @@ -108,7 +107,7 @@ int main(int argc, char *argv[]) wordRes wrelist(wordrelist); - Info<< "re-list:" << wrelist() << endl; + Info<< "re-list:" << wrelist << endl; Info<< "match this: " << wrelist("this") << endl; Info<< "match xyz: " << wrelist("xyz") << endl; Info<< "match zyx: " << wrelist("zyx") << endl; diff --git a/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C b/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C index 7e3940ee00..aac1d730d5 100644 --- a/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C +++ b/applications/utilities/mesh/advanced/refineWallLayer/refineWallLayer.C @@ -81,12 +81,11 @@ int main(int argc, char *argv[]) const word oldInstance = mesh.pointsInstance(); // Find set of patches from the list of regular expressions provided - const wordReList patches((IStringStream(args[1])())); - const labelHashSet patchSet(mesh.boundaryMesh().patchSet(patches)); - + const wordRes patches(args.readList(1)); const scalar weight = args.read(2); const bool overwrite = args.found("overwrite"); + const labelHashSet patchSet(mesh.boundaryMesh().patchSet(patches)); if (!patchSet.size()) { FatalErrorInFunction diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index d3d4942766..44b1266aa5 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -1666,7 +1666,7 @@ int main(int argc, char *argv[]) { includePatches = bMesh.patchSet ( - wordReList(args.lookup("patches")()) + args.readList("patches") ); } else diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C index 572c039994..94e59afbc6 100644 --- a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C +++ b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C @@ -414,7 +414,7 @@ int main(int argc, char *argv[]) } else if (args.found("patches")) { - const wordReList patchNames(args.opt("patches")); + const wordRes patchNames(args.readList("patches")); exposedPatchIDs = mesh.boundaryMesh().patchSet(patchNames).sortedToc(); diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index cc25e76b55..06abc23d3a 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -360,10 +360,10 @@ int main(int argc, char *argv[]) } } - if (args.found("scale")) + List scaling; + if (args.readListIfPresent("scale", scaling)) { - // Use readList to handle single or multiple values - const List scaling = args.readList("scale"); + // readList handles single or multiple values if (scaling.size() == 1) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C index ed29448739..6633b330b6 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C @@ -127,20 +127,20 @@ int main(int argc, char *argv[]) argList::addOption ( "patches", - "wordReList", + "wordRes", "specify particular patches to write - eg '(outlet \"inlet.*\")'. " "An empty list suppresses writing the internalMesh." ); argList::addOption ( "faceZones", - "wordReList", + "wordRes", "specify faceZones to write - eg '( slice \"mfp-.*\" )'." ); argList::addOption ( "fields", - "wordReList", + "wordRes", "specify fields to export (all by default) - eg '( \"U.*\" )'." ); argList::addOption @@ -249,11 +249,8 @@ int main(int argc, char *argv[]) // const bool noLagrangian = args.found("noLagrangian"); - wordReList fieldPatterns; - if (args.found("fields")) - { - fieldPatterns = args.readList("fields"); - } + wordRes fieldPatterns; + args.readListIfPresent("fields", fieldPatterns); word cellZoneName; if (args.readIfPresent("cellZone", cellZoneName)) diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C index f8f463b626..9bd600c2bb 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C @@ -79,8 +79,7 @@ Usage #include "tensorIOField.H" #include "passiveParticleCloud.H" #include "faceSet.H" -#include "stringOps.H" -#include "wordReList.H" +#include "wordRes.H" #include "meshSubsetHelper.H" #include "readFields.H" @@ -117,7 +116,7 @@ void print(Ostream& os, const wordList& flds) labelList getSelectedPatches ( const polyBoundaryMesh& patches, - const List& excludePatches //HashSet& excludePatches + const wordRes& excludePatches ) { DynamicList