mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use dictionary findDict() instead of isDict() + subDict()
- avoids redundant dictionary searching STYLE: remove dictionary lookupOrDefaultCompat wrapper - deprecated and replaced by getOrDefaultCompat (2019-05). The function is usually specific to internal keyword upgrading (version compatibility) and unlikely to exist in any user code.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -373,6 +373,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const dictionary* subDictPtr = nullptr;
|
||||
|
||||
//
|
||||
// Extract features using the preferred extraction method
|
||||
//
|
||||
@ -382,9 +385,9 @@ int main(int argc, char *argv[])
|
||||
// ~~~~~~~~
|
||||
|
||||
// Option: "trimFeatures" (dictionary)
|
||||
if (surfaceDict.isDict("trimFeatures"))
|
||||
if ((subDictPtr = surfaceDict.findDict("trimFeatures")) != nullptr)
|
||||
{
|
||||
const dictionary& trimDict = surfaceDict.subDict("trimFeatures");
|
||||
const dictionary& trimDict = *subDictPtr;
|
||||
|
||||
const scalar minLen =
|
||||
trimDict.getOrDefault<scalar>("minLen", 0);
|
||||
@ -419,18 +422,15 @@ int main(int argc, char *argv[])
|
||||
List<surfaceFeatures::edgeStatus> edgeStat(features().toStatus());
|
||||
|
||||
// Option: "subsetFeatures" (dictionary)
|
||||
if (surfaceDict.isDict("subsetFeatures"))
|
||||
if ((subDictPtr = surfaceDict.findDict("subsetFeatures")) != nullptr)
|
||||
{
|
||||
const dictionary& subsetDict = surfaceDict.subDict
|
||||
(
|
||||
"subsetFeatures"
|
||||
);
|
||||
const dictionary& subsetDict = *subDictPtr;
|
||||
|
||||
treeBoundBox bb;
|
||||
|
||||
// Suboption: "insideBox"
|
||||
if (subsetDict.found("insideBox"))
|
||||
if (subsetDict.readIfPresent("insideBox", bb))
|
||||
{
|
||||
treeBoundBox bb(subsetDict.lookup("insideBox"));
|
||||
|
||||
Info<< "Subset edges inside box " << bb << endl;
|
||||
features().subsetBox(edgeStat, bb);
|
||||
|
||||
@ -445,10 +445,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
// Suboption: "outsideBox"
|
||||
else if (subsetDict.found("outsideBox"))
|
||||
else if (subsetDict.readIfPresent("outsideBox", bb))
|
||||
{
|
||||
treeBoundBox bb(subsetDict.lookup("outsideBox"));
|
||||
|
||||
Info<< "Exclude edges outside box " << bb << endl;
|
||||
features().excludeBox(edgeStat, bb);
|
||||
|
||||
@ -549,12 +547,11 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
|
||||
if (surfaceDict.isDict("addFeatures"))
|
||||
if ((subDictPtr = surfaceDict.findDict("addFeatures")) != nullptr)
|
||||
{
|
||||
const word addFeName
|
||||
(
|
||||
surfaceDict.subDict("addFeatures").get<word>("name")
|
||||
);
|
||||
const dictionary& addFeaturesDict = *subDictPtr;
|
||||
|
||||
const word addFeName = addFeaturesDict.get<word>("name");
|
||||
|
||||
Info<< "Adding (without merging) features from " << addFeName
|
||||
<< nl << endl;
|
||||
|
||||
Reference in New Issue
Block a user