mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: align meshRefinement dictionary wrapper with dictionary code
COMP: do not rely on implicit conversion to PtrList from Istream
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2019 OpenCFD Ltd.
|
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -1259,7 +1259,10 @@ int main(int argc, char *argv[])
|
|||||||
refinementFeatures features
|
refinementFeatures features
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
meshRefinement::lookup(refineDict, "features", dryRun),
|
PtrList<dictionary>
|
||||||
|
(
|
||||||
|
meshRefinement::lookup(refineDict, "features", dryRun)
|
||||||
|
),
|
||||||
dryRun
|
dryRun
|
||||||
);
|
);
|
||||||
Info<< "Read features in = "
|
Info<< "Read features in = "
|
||||||
|
|||||||
@ -3465,35 +3465,30 @@ const Foam::dictionary& Foam::meshRefinement::subDict
|
|||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
const word& keyword,
|
const word& keyword,
|
||||||
const bool noExit
|
const bool noExit,
|
||||||
|
enum keyType::option matchOpt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
const auto finder(dict.csearch(keyword, matchOpt));
|
||||||
|
|
||||||
|
if (!finder.good())
|
||||||
|
{
|
||||||
|
auto& err = FatalIOErrorInFunction(dict);
|
||||||
|
|
||||||
|
err << "Entry '" << keyword << "' not found in dictionary "
|
||||||
|
<< dict.name() << nl;
|
||||||
|
|
||||||
if (noExit)
|
if (noExit)
|
||||||
{
|
{
|
||||||
// Find non-recursive with patterns
|
|
||||||
const dictionary::const_searcher finder
|
|
||||||
(
|
|
||||||
dict.csearch
|
|
||||||
(
|
|
||||||
keyword,
|
|
||||||
keyType::REGEX
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!finder.found())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "Entry '" << keyword << "' not found in dictionary "
|
|
||||||
<< dict.name();
|
|
||||||
return dictionary::null;
|
return dictionary::null;
|
||||||
}
|
}
|
||||||
else
|
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 dictionary& dict,
|
||||||
const word& keyword,
|
const word& keyword,
|
||||||
const bool noExit
|
const bool noExit,
|
||||||
|
enum keyType::option matchOpt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
const auto finder(dict.csearch(keyword, matchOpt));
|
||||||
|
|
||||||
|
if (!finder.good())
|
||||||
|
{
|
||||||
|
auto& err = FatalIOErrorInFunction(dict);
|
||||||
|
|
||||||
|
err << "Entry '" << keyword << "' not found in dictionary "
|
||||||
|
<< dict.name() << nl;
|
||||||
|
|
||||||
if (noExit)
|
if (noExit)
|
||||||
{
|
{
|
||||||
const dictionary::const_searcher finder
|
|
||||||
(
|
|
||||||
dict.csearch(keyword, keyType::REGEX)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!finder.found())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "Entry '" << keyword << "' not found in dictionary "
|
|
||||||
<< dict.name();
|
|
||||||
// Fake entry
|
// Fake entry
|
||||||
return dict.first()->stream();
|
return dict.first()->stream();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return finder.ref().stream();
|
err << exit(FatalIOError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dict.lookup(keyword);
|
return finder.ref().stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2015-2019 OpenCFD Ltd.
|
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -66,7 +66,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Class forward declarations
|
// Forward Declarations
|
||||||
class fvMesh;
|
class fvMesh;
|
||||||
class mapDistributePolyMesh;
|
class mapDistributePolyMesh;
|
||||||
class decompositionMethod;
|
class decompositionMethod;
|
||||||
@ -79,7 +79,6 @@ class removePoints;
|
|||||||
class localPointRegion;
|
class localPointRegion;
|
||||||
class snapParameters;
|
class snapParameters;
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class meshRefinement Declaration
|
Class meshRefinement Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -88,7 +87,7 @@ class meshRefinement
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Public data types
|
// Public Data Types
|
||||||
|
|
||||||
//- Enumeration for what to debug. Used as a bit-pattern.
|
//- Enumeration for what to debug. Used as a bit-pattern.
|
||||||
enum debugType
|
enum debugType
|
||||||
@ -143,7 +142,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Static data members
|
// Static Data Members
|
||||||
|
|
||||||
//- Control of writing level
|
//- Control of writing level
|
||||||
static writeType writeLevel_;
|
static writeType writeLevel_;
|
||||||
@ -152,7 +151,7 @@ private:
|
|||||||
//static outputType outputLevel_;
|
//static outputType outputLevel_;
|
||||||
|
|
||||||
|
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Reference to mesh
|
//- Reference to mesh
|
||||||
fvMesh& mesh_;
|
fvMesh& mesh_;
|
||||||
@ -1701,7 +1700,7 @@ public:
|
|||||||
const word& keyword,
|
const word& keyword,
|
||||||
const bool noExit,
|
const bool noExit,
|
||||||
enum keyType::option matchOpt = keyType::REGEX,
|
enum keyType::option matchOpt = keyType::REGEX,
|
||||||
const Type& defaultValue = Zero
|
const Type& deflt = Zero
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Wrapper around dictionary::subDict which does not exit
|
//- Wrapper around dictionary::subDict which does not exit
|
||||||
@ -1709,7 +1708,8 @@ public:
|
|||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
const word& keyword,
|
const word& keyword,
|
||||||
const bool noExit
|
const bool noExit,
|
||||||
|
enum keyType::option matchOpt = keyType::REGEX
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Wrapper around dictionary::lookup which does not exit
|
//- Wrapper around dictionary::lookup which does not exit
|
||||||
@ -1717,7 +1717,8 @@ public:
|
|||||||
(
|
(
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
const word& keyword,
|
const word& keyword,
|
||||||
const bool noExit
|
const bool noExit,
|
||||||
|
enum keyType::option matchOpt = keyType::REGEX
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -33,8 +33,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Add a T entry
|
template<class T>
|
||||||
template<class T> void Foam::meshRefinement::updateList
|
void Foam::meshRefinement::updateList
|
||||||
(
|
(
|
||||||
const labelList& newToOld,
|
const labelList& newToOld,
|
||||||
const T& nullValue,
|
const T& nullValue,
|
||||||
@ -45,7 +45,7 @@ template<class T> void Foam::meshRefinement::updateList
|
|||||||
|
|
||||||
forAll(newElems, i)
|
forAll(newElems, i)
|
||||||
{
|
{
|
||||||
label oldI = newToOld[i];
|
const label oldI = newToOld[i];
|
||||||
|
|
||||||
if (oldI >= 0)
|
if (oldI >= 0)
|
||||||
{
|
{
|
||||||
@ -332,26 +332,18 @@ Type Foam::meshRefinement::get
|
|||||||
const word& keyword,
|
const word& keyword,
|
||||||
const bool noExit,
|
const bool noExit,
|
||||||
enum keyType::option matchOpt,
|
enum keyType::option matchOpt,
|
||||||
const Type& defaultValue
|
const Type& deflt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Type val(defaultValue);
|
Type val(deflt);
|
||||||
|
|
||||||
if
|
if (!dict.readEntry(keyword, val, matchOpt, !noExit))
|
||||||
(
|
|
||||||
!dict.readEntry
|
|
||||||
(
|
|
||||||
keyword,
|
|
||||||
val,
|
|
||||||
matchOpt,
|
|
||||||
!noExit
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
FatalIOError
|
FatalIOErrorInFunction(dict)
|
||||||
<< "Entry '" << keyword << "' not found in dictionary "
|
<< "Entry '" << keyword << "' not found in dictionary "
|
||||||
<< dict.name() << endl;
|
<< dict.name() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user