From c6520033c9c404d28000acd66d236f6a49ca9c83 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 15 Oct 2018 16:16:12 +0200 Subject: [PATCH] ENH: rationalize dictionary access methods - use keyType::option enum to consolidate searching options. These enumeration names should be more intuitive to use and improve code readability. Eg, lookupEntry(key, keyType::REGEX); vs lookupEntry(key, false, true); or Eg, lookupEntry(key, keyType::LITERAL_RECURSIVE); vs lookupEntry(key, true, false); - new findEntry(), findDict(), findScoped() methods with consolidated search options for shorter naming and access names more closely aligned with other components. Behave simliarly to the methods lookupEntryPtr(), subDictPtr(), lookupScopedEntryPtr(), respectively. Default search parameters consistent with lookupEntry(). Eg, const entry* e = dict.findEntry(key); vs const entry* e = dict.lookupEntryPtr(key, false, true); - added '*' and '->' dereference operators to dictionary searchers. --- .../test/dictionary/Test-dictionary.C | 22 +- .../Test-fvSolutionCombine.C | 12 +- .../cellSizeFunction/cellSizeFunction.C | 8 +- .../conformalVoronoiMeshCalcDualMesh.C | 2 +- .../conformationSurfaces.C | 2 +- .../generation/snappyHexMesh/snappyHexMesh.C | 2 +- .../foamDictionary/foamDictionary.C | 28 +- .../profilingSummary/profilingSummary.C | 24 +- .../changeDictionary/changeDictionary.C | 40 +- src/OpenFOAM/db/Time/Time.C | 4 +- src/OpenFOAM/db/Time/TimeIO.C | 10 +- src/OpenFOAM/db/dictionary/dictionary.C | 140 ++--- src/OpenFOAM/db/dictionary/dictionary.H | 579 +++++++++++------- src/OpenFOAM/db/dictionary/dictionaryCompat.C | 31 +- src/OpenFOAM/db/dictionary/dictionaryIO.C | 19 +- src/OpenFOAM/db/dictionary/dictionarySearch.C | 97 ++- .../db/dictionary/dictionaryTemplates.C | 60 +- src/OpenFOAM/db/dictionary/entry/entryIO.C | 12 +- .../functionEntries/removeEntry/removeEntry.C | 3 +- .../primitiveEntry/primitiveEntry.C | 3 +- .../db/dynamicLibrary/codedBase/codedBase.C | 6 +- .../dynamicCode/dynamicCodeContext.C | 30 +- .../functionObjectList/functionObjectList.C | 8 +- src/OpenFOAM/global/debug/debug.C | 23 +- .../fileOperation/fileOperation.C | 3 +- .../lduMatrix/lduMatrixPreconditioner.C | 13 +- .../lduMatrix/lduMatrix/lduMatrixSmoother.C | 12 +- src/OpenFOAM/matrices/solution/solution.C | 19 +- .../Function1/Function1/Function1New.C | 2 +- .../primitives/strings/keyType/keyType.H | 22 +- .../primitives/strings/keyType/keyTypeI.H | 4 +- .../primitives/strings/stringOps/stringOps.C | 16 +- .../primitives/strings/wordRe/wordRe.H | 16 +- .../motionSmoother/motionSmootherAlgoCheck.C | 67 +- .../solutionControl/loopControl/loopControl.C | 7 +- .../codedFunctionObject/codedFunctionObject.C | 37 +- .../general/codedSource/CodedSourceIO.C | 27 +- src/lumpedPointMotion/lumpedPointMovement.C | 4 +- .../blockDescriptor/blockDescriptor.C | 2 +- .../blockMesh/blockMesh/blockMeshTopology.C | 2 +- .../blockMesh/blockMeshTools/blockMeshTools.C | 13 +- .../blockVertices/blockVertex/blockVertex.C | 4 +- .../blockVertices/namedVertex/namedVertex.C | 4 +- .../blockMesh/blocks/namedBlock/namedBlock.C | 4 +- .../meshRefinementProblemCells.C | 3 +- .../refinementSurfaces/refinementSurfaces.C | 3 +- .../shellSurfaces/shellSurfaces.C | 23 +- .../coordinate/systems/coordinateSystem.C | 2 +- .../coordinate/systems/coordinateSystemNew.C | 2 +- .../triSurfaceMesh/triSurfaceMesh.C | 6 +- .../dynamicOversetFvMesh.C | 4 +- .../oversetPolyPatch/oversetFvPatchField.C | 4 +- .../decompositionMethod/decompositionMethod.C | 2 +- .../multiLevelDecomp/multiLevelDecomp.C | 8 +- .../decompose/metisDecomp/metisDecomp.C | 2 +- .../regionModel/regionModel/regionModel.C | 20 +- 56 files changed, 769 insertions(+), 753 deletions(-) diff --git a/applications/test/dictionary/Test-dictionary.C b/applications/test/dictionary/Test-dictionary.C index 393aafe482..bddadce6fe 100644 --- a/applications/test/dictionary/Test-dictionary.C +++ b/applications/test/dictionary/Test-dictionary.C @@ -82,8 +82,8 @@ int main(int argc, char *argv[]) Info<< "dict1.toc(): " << dict1.name() << " " << dict1.toc() << endl; - dictionary dict3(dict2.subDictPtr("boundaryField")); - dictionary dict4(dict2.subDictPtr("NONEXISTENT")); + dictionary dict3(dict2.findDict("boundaryField")); + dictionary dict4(dict2.findDict("NONEXISTENT")); Info<< "dictionary construct from pointer" << nl << "ok = " << dict3.name() << " " << dict3.toc() << nl @@ -105,23 +105,17 @@ int main(int argc, char *argv[]) Info<< "Pattern find \"abc\" in top directory : " << dict.lookup("abc") << endl; Info<< "Pattern find \"abc\" in sub directory : " - << dict.subDict("someDict").lookup("abc") - << endl; + << dict.subDict("someDict").lookup("abc") << nl; Info<< "Recursive pattern find \"def\" in sub directory : " - << dict.subDict("someDict").lookup("def", true) - << endl; + << dict.subDict("someDict").lookup("def", true) << nl; Info<< "Recursive pattern find \"foo\" in sub directory : " - << dict.subDict("someDict").lookup("foo", true) - << endl; + << dict.subDict("someDict").lookup("foo", true) << nl; Info<< "Recursive pattern find \"fooz\" in sub directory : " - << dict.subDict("someDict").lookup("fooz", true) - << endl; + << dict.subDict("someDict").lookup("fooz", true) << nl; Info<< "Recursive pattern find \"bar\" in sub directory : " - << dict.subDict("someDict").lookup("bar", true) - << endl; + << dict.subDict("someDict").lookup("bar", true) << nl; Info<< "Recursive pattern find \"xxx\" in sub directory : " - << dict.subDict("someDict").lookup("xxx", true) - << endl; + << dict.subDict("someDict").lookup("xxx", true) << nl; } } else diff --git a/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C b/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C index c844c8286b..f3ed843680 100644 --- a/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C +++ b/applications/test/fvSolutionCombine/Test-fvSolutionCombine.C @@ -52,20 +52,16 @@ bool checkDictionaryContent(const dictionary& dict1, const dictionary& dict2) forAllConstIter(dictionary, dict1, iter1) { - const entry* entryPtr = dict2.lookupEntryPtr - ( - iter1().keyword(), - false, - false - ); + const entry* eptr = + dict2.findEntry(iter1().keyword(), keyType::LITERAL); - if (!entryPtr) + if (!eptr) { return false; } const entry& entry1 = iter1(); - const entry& entry2 = *entryPtr; + const entry& entry2 = *eptr; bool ok = false; if (entry1.isDict()) diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C index 740b807f40..ca4e3280e3 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/cellSizeFunction/cellSizeFunction.C @@ -63,9 +63,13 @@ Foam::cellSizeFunction::cellSizeFunction defaultCellSize_(defaultCellSize), regionIndices_(regionIndices), sideMode_(), - priority_(cellSizeFunctionDict.get