Commit 03c2373d authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: align meshRefinement dictionary wrapper with dictionary code

COMP: do not rely on implicit conversion to PtrList from Istream
parent 997c9a23
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -1259,7 +1259,10 @@ int main(int argc, char *argv[])
refinementFeatures features
(
mesh,
meshRefinement::lookup(refineDict, "features", dryRun),
PtrList<dictionary>
(
meshRefinement::lookup(refineDict, "features", dryRun)
),
dryRun
);
Info<< "Read features in = "
......
......@@ -3465,35 +3465,30 @@ const Foam::dictionary& Foam::meshRefinement::subDict
(
const dictionary& dict,
const word& keyword,
const bool noExit
const bool noExit,
enum keyType::option matchOpt
)
{
if (noExit)
const auto finder(dict.csearch(keyword, matchOpt));
if (!finder.good())
{
// Find non-recursive with patterns
const dictionary::const_searcher finder
(
dict.csearch
(
keyword,
keyType::REGEX
)
);
auto& err = FatalIOErrorInFunction(dict);
if (!finder.found())
err << "Entry '" << keyword << "' not found in dictionary "
<< dict.name() << nl;
if (noExit)
{
FatalIOErrorInFunction(dict)
<< "Entry '" << keyword << "' not found in dictionary "
<< dict.name();
return dictionary::null;
}
else
{
return finder.dict();
err << exit(FatalIOError);
}
}
return dict.subDict(keyword);
return finder.dict();
}
......@@ -3501,31 +3496,31 @@ Foam::ITstream& Foam::meshRefinement::lookup
(
const dictionary& dict,
const word& keyword,
const bool noExit
const bool noExit,
enum keyType::option matchOpt
)
{
if (noExit)
const auto finder(dict.csearch(keyword, matchOpt));
if (!finder.good())
{
const dictionary::const_searcher finder
(
dict.csearch(keyword, keyType::REGEX)
);
auto& err = FatalIOErrorInFunction(dict);
err << "Entry '" << keyword << "' not found in dictionary "
<< dict.name() << nl;
if (!finder.found())
if (noExit)
{
FatalIOErrorInFunction(dict)
<< "Entry '" << keyword << "' not found in dictionary "
<< dict.name();
// Fake entry
return dict.first()->stream();
}
else
{
return finder.ref().stream();
err << exit(FatalIOError);
}
}
return dict.lookup(keyword);
return finder.ref().stream();
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -66,7 +66,7 @@ SourceFiles
namespace Foam
{
// Class forward declarations
// Forward Declarations
class fvMesh;
class mapDistributePolyMesh;
class decompositionMethod;
......@@ -79,7 +79,6 @@ class removePoints;
class localPointRegion;
class snapParameters;
/*---------------------------------------------------------------------------*\
Class meshRefinement Declaration
\*---------------------------------------------------------------------------*/
......@@ -88,7 +87,7 @@ class meshRefinement
{
public:
// Public data types
// Public Data Types
//- Enumeration for what to debug. Used as a bit-pattern.
enum debugType
......@@ -143,7 +142,7 @@ public:
private:
// Static data members
// Static Data Members
//- Control of writing level
static writeType writeLevel_;
......@@ -152,7 +151,7 @@ private:
//static outputType outputLevel_;
// Private data
// Private Data
//- Reference to mesh
fvMesh& mesh_;
......@@ -1701,7 +1700,7 @@ public:
const word& keyword,
const bool noExit,
enum keyType::option matchOpt = keyType::REGEX,
const Type& defaultValue = Zero
const Type& deflt = Zero
);
//- Wrapper around dictionary::subDict which does not exit
......@@ -1709,7 +1708,8 @@ public:
(
const dictionary& dict,
const word& keyword,
const bool noExit
const bool noExit,
enum keyType::option matchOpt = keyType::REGEX
);
//- Wrapper around dictionary::lookup which does not exit
......@@ -1717,7 +1717,8 @@ public:
(
const dictionary& dict,
const word& keyword,
const bool noExit
const bool noExit,
enum keyType::option matchOpt = keyType::REGEX
);
};
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -33,8 +33,8 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Add a T entry
template<class T> void Foam::meshRefinement::updateList
template<class T>
void Foam::meshRefinement::updateList
(
const labelList& newToOld,
const T& nullValue,
......@@ -45,7 +45,7 @@ template<class T> void Foam::meshRefinement::updateList
forAll(newElems, i)
{
label oldI = newToOld[i];
const label oldI = newToOld[i];
if (oldI >= 0)
{
......@@ -332,26 +332,18 @@ Type Foam::meshRefinement::get
const word& keyword,
const bool noExit,
enum keyType::option matchOpt,
const Type& defaultValue
const Type& deflt
)
{
Type val(defaultValue);
Type val(deflt);
if
(
!dict.readEntry
(
keyword,
val,
matchOpt,
!noExit
)
)
if (!dict.readEntry(keyword, val, matchOpt, !noExit))
{
FatalIOError
FatalIOErrorInFunction(dict)
<< "Entry '" << keyword << "' not found in dictionary "
<< dict.name() << endl;
<< dict.name() << nl;
}
return val;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment