STYLE: use getOrDefault instead of lookupOrDefault

- now mark methods with strict deprecation, to make it easier to find
  their use but without adding extra compilation noise for others

ENH: minor update for Enum methods and iterator

- add warnOnly (failsafe) option for readEntry and getOrDefault

- add good() method to Enum iterator (simliar to HashTable)

- replace unused/fragile Enum find() methods with iterator return
  that can be used more generally
This commit is contained in:
Mark Olesen 2023-10-13 19:27:27 +02:00
parent 3562565995
commit fb26fcedfc
26 changed files with 197 additions and 129 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -110,7 +110,7 @@ int main(int argc, char *argv[])
<< " values: " << flatOutput(otherNames2.values())
<< nl << nl;
otherNames2.append
otherNames2.push_back
({
{ 15, "fifteen"},
{ 16, "sixteen"}
@ -138,7 +138,7 @@ int main(int argc, char *argv[])
Info<< nl;
otherNames2.clear();
otherNames2.append
otherNames2.push_back
({
{ 1, "one"},
{ 2, "two"}
@ -149,6 +149,18 @@ int main(int argc, char *argv[])
<< otherNames2.values() << nl
<< nl;
for (const auto& k : {"one", "two", "three", "four" })
{
const auto iter = otherNames2.find(k);
Info<< "find(" << k << ") good:" << iter.good();
if (iter.good())
{
Info<< " value:" << int(iter.val());
}
Info<< nl;
}
dictionary testDict;
testDict.add("lookup1", "c");
@ -162,10 +174,10 @@ int main(int argc, char *argv[])
{
Info<< "dict: " << testDict << endl;
Info<< "lookupOrDefault(notFound) = "
Info<< "getOrDefault(notFound) = "
<< int
(
testing::option1Names.lookupOrDefault
testing::option1Names.getOrDefault
(
"notFound",
testDict,
@ -174,10 +186,10 @@ int main(int argc, char *argv[])
)
<< nl;
Info<< "lookupOrDefault(lookup1) = "
Info<< "getOrDefault(lookup1) = "
<< int
(
testing::option1Names.lookupOrDefault
testing::option1Names.getOrDefault
(
"lookup1",
testDict,
@ -186,10 +198,10 @@ int main(int argc, char *argv[])
)
<< nl;
Info<< "lookupOrDefault(lookup1) = "
Info<< "getOrDefault(lookup1) = "
<< int
(
testing::option2Names.lookupOrDefault
testing::option2Names.getOrDefault
(
"lookup1",
testDict,

View File

@ -136,13 +136,13 @@ int main(int argc, char *argv[])
Info<< "test2 : " << dimensionedScalar("test2", dimless, 20, dict) << nl;
Info<< "test2a : " << dimensionedScalar("test2a", dimless, 20, dict) << nl;
Info<< "test3 : "
<< dimensionedScalar::lookupOrDefault("test3", dict, 30) << nl;
<< dimensionedScalar::getOrDefault("test3", dict, 30) << nl;
Info<< "test4 : "
<< dimensionedScalar::lookupOrAddToDict("test4", dict, 40) << nl;
<< dimensionedScalar::getOrAddToDict("test4", dict, 40) << nl;
Info<< "test5 : "
<< dimensionedScalar::lookupOrAddToDict("test5", dict, -50) << nl;
<< dimensionedScalar::getOrAddToDict("test5", dict, -50) << nl;
// Deprecated
Info<< "Deprecated constructors" << nl;

View File

@ -469,8 +469,12 @@ int main(int argc, char *argv[])
// Allow override of decomposeParDict location
fileName decompDictFile(args.get<fileName>("decomposeParDict", ""));
if (!decompDictFile.empty() && !decompDictFile.isAbsolute())
fileName decompDictFile;
if
(
args.readIfPresent("decomposeParDict", decompDictFile)
&& !decompDictFile.empty() && !decompDictFile.isAbsolute()
)
{
decompDictFile = runTime.globalPath()/decompDictFile;
}

View File

@ -1307,13 +1307,9 @@ public:
// Housekeeping
//- Find and return a T, or return the given default value.
//- FatalIOError if it is found and the number of tokens is incorrect.
//
// \param keyword the keyword to search for
// \param deflt the default value to use
// \param matchOpt search mode (default: non-recursive with patterns)
//- Same as getOrDefault()
template<class T>
FOAM_DEPRECATED_STRICT(2019-06, "getOrDefault()")
T lookupOrDefault
(
const word& keyword,
@ -1325,14 +1321,9 @@ public:
}
//- Find and return a T, or return the given default value
//- and add it to dictionary.
//- FatalIOError if it is found and the number of tokens is incorrect.
//
// \param keyword the keyword to search for
// \param deflt the default value to use
// \param matchOpt search mode (default: non-recursive with patterns)
//- Same as getOrAdd()
template<class T>
FOAM_DEPRECATED_STRICT(2019-06, "getOrAdd()")
T lookupOrAddDefault
(
const word& keyword,

View File

@ -400,9 +400,8 @@ public:
FOAM_DEPRECATED_FOR(2018-11, "construct from dictionary or entry")
dimensioned(const word& name, const dimensionSet& dims, Istream& is);
//- Construct dimensioned from dictionary, with default value.
//- FatalIOError if there are excess tokens.
//- Same as getOrDefault()
FOAM_DEPRECATED_STRICT(2019-06, "getOrDefault()")
static dimensioned<Type> lookupOrDefault
(
const word& name,
@ -414,8 +413,8 @@ public:
return getOrDefault(name, dict, dims, deflt);
}
//- Construct dimensionless from dictionary, with default value.
// FatalIOError if it is found and there are excess tokens.
//- Same as getOrDefault()
FOAM_DEPRECATED_STRICT(2019-06, "getOrDefault()")
static dimensioned<Type> lookupOrDefault
(
const word& name,
@ -426,9 +425,8 @@ public:
return getOrDefault(name, dict, deflt);
}
//- Construct dimensioned from dictionary, with default value.
// If the value is not found, it is added into the dictionary.
// FatalIOError if it is found and there are excess tokens.
//- Same as getOrAddToDict()
FOAM_DEPRECATED_STRICT(2019-06, "getOrAddToDict()")
static dimensioned<Type> lookupOrAddToDict
(
const word& name,
@ -440,9 +438,8 @@ public:
return getOrAddToDict(name, dict, dims, deflt);
}
//- Construct dimensionless from dictionary, with default value.
// If the value is not found, it is added into the dictionary.
// FatalIOError if it is found and there are excess tokens.
//- Same as getOrAddToDict()
FOAM_DEPRECATED_STRICT(2019-06, "getOrAddToDict()")
static dimensioned<Type> lookupOrAddToDict
(
const word& name,

View File

@ -729,6 +729,7 @@ public:
//- Deprecated(2020-05) identical to get(const word& optName)
// \deprecated(2020-05) - use get() method
template<class T=string>
FOAM_DEPRECATED_STRICT(2020-06, "get()")
T opt(const word& optName) const
{
return this->get<T>(optName);
@ -737,6 +738,7 @@ public:
//- Deprecated(2020-05) identical to getOrDefault(...)
// \deprecated(2020-05) - use getOrDefault() method
template<class T>
FOAM_DEPRECATED_STRICT(2020-06, "getOrDefault()")
T opt(const word& optName, const T& deflt) const
{
return this->getOrDefault<T>(optName, deflt);
@ -745,6 +747,7 @@ public:
//- Deprecated(2020-05) identical to getOrDefault(...)
// \deprecated(2020-05) - use getOrDefault() method
template<class T>
FOAM_DEPRECATED_STRICT(2020-06, "getOrDefault()")
T get(const word& optName, const T& deflt) const
{
return this->getOrDefault<T>(optName, deflt);
@ -753,6 +756,7 @@ public:
//- Deprecated(2020-05) identical to getOrDefault(...)
// \deprecated(2020-05) - use getOrDefault() method
template<class T>
FOAM_DEPRECATED_STRICT(2020-06, "getOrDefault()")
T lookupOrDefault(const word& optName, const T& deflt) const
{
return this->getOrDefault<T>(optName, deflt);

View File

@ -425,7 +425,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
{
const word agglomeratorType
(
controlDict.lookupOrDefault<word>("agglomerator", "faceAreaPair")
controlDict.getOrDefault<word>("agglomerator", "faceAreaPair")
);
const_cast<Time&>(mesh.thisDb().time()).libs().open

View File

@ -160,6 +160,17 @@ bool Foam::Switch::contains(const std::string& str)
}
Foam::Switch Foam::Switch::getOrDefault
(
const word& key,
const dictionary& dict,
const Switch deflt
)
{
return dict.getOrDefault<Switch>(key, deflt, keyType::LITERAL);
}
Foam::Switch Foam::Switch::getOrAddToDict
(
const word& key,
@ -260,7 +271,7 @@ Foam::Switch::Switch
const word& key,
const dictionary& dict,
const Switch deflt,
const bool failsafe
const bool warnOnly
)
:
value_(deflt.value_)
@ -275,10 +286,10 @@ Foam::Switch::Switch
{
(*this) = sw;
}
else if (failsafe)
else if (warnOnly)
{
printTokenError(IOWarningInFunction(dict), tok)
<< "using failsafe " << deflt.c_str() << endl;
<< "using default " << deflt.c_str() << endl;
}
else
{

View File

@ -179,13 +179,13 @@ public:
//- switch value or the default if not found in dictionary.
//
// FatalIOError if the switch name is incorrect.
// Specifying failsafe downgrades the FatalIOError to an IOWarning.
// Specifying warnOnly downgrades the FatalIOError to an IOWarning.
Switch
(
const word& key, //!< Lookup key. Uses LITERAL (not REGEX)
const dictionary& dict, //!< dictionary
const Switch deflt, //!< fallback if not found
const bool failsafe = false //!< Warn only on bad input
const bool warnOnly = false //!< Warn (not fail) on bad input
);
//- Construct from Istream by reading a token
@ -194,6 +194,14 @@ public:
// Helpers
//- Construct Switch from dictionary, with default value
static Switch getOrDefault
(
const word& key, //!< Lookup key. Uses LITERAL (not REGEX)
const dictionary& dict, //!< dictionary
const Switch deflt = switchType::FALSE //!< fallback if not found
);
//- Construct from dictionary, supplying default value so that if the
//- value is not found, it is added into the dictionary.
static Switch getOrAddToDict
@ -290,6 +298,7 @@ public:
bool valid() const noexcept { return good(); }
//- Same as getOrAddToDict()
FOAM_DEPRECATED_STRICT(2019-06, "getOrAddToDict()")
static Switch lookupOrAddToDict
(
const word& name,

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2022 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -74,7 +74,7 @@ void Foam::Enum<EnumType>::push_back
template<class EnumType>
EnumType Foam::Enum<EnumType>::get(const word& enumName) const
{
const label idx = find(enumName);
const label idx = keys_.find(enumName);
if (idx < 0)
{
@ -94,7 +94,7 @@ EnumType Foam::Enum<EnumType>::lookup
const EnumType deflt
) const
{
const label idx = find(enumName);
const label idx = keys_.find(enumName);
if (idx < 0)
{
@ -110,7 +110,7 @@ EnumType Foam::Enum<EnumType>::read(Istream& is) const
{
const word enumName(is);
const label idx = find(enumName);
const label idx = keys_.find(enumName);
if (idx < 0)
{
@ -133,7 +133,7 @@ bool Foam::Enum<EnumType>::read
{
const word enumName(is);
const label idx = find(enumName);
const label idx = keys_.find(enumName);
if (idx >= 0)
{
@ -161,12 +161,13 @@ EnumType Foam::Enum<EnumType>::get
{
const word enumName(dict.get<word>(key, keyType::LITERAL));
const label idx = find(enumName);
const label idx = keys_.find(enumName);
if (idx < 0)
{
FatalIOErrorInFunction(dict)
<< enumName << " is not in enumeration: " << *this << nl
<< "Lookup:" << key << " enumeration " << enumName
<< " is not in enumeration: " << *this << nl
<< exit(FatalIOError);
}
@ -180,7 +181,7 @@ EnumType Foam::Enum<EnumType>::getOrDefault
const word& key,
const dictionary& dict,
const EnumType deflt,
const bool failsafe
const bool warnOnly
) const
{
const entry* eptr = dict.findEntry(key, keyType::LITERAL);
@ -189,26 +190,28 @@ EnumType Foam::Enum<EnumType>::getOrDefault
{
const word enumName(eptr->get<word>());
const label idx = find(enumName);
const label idx = keys_.find(enumName);
if (idx >= 0)
{
return EnumType(vals_[idx]);
}
// Found the entry, but failed the name lookup
// Found the dictionary entry, but the name not in enumeration
if (failsafe)
if (warnOnly)
{
IOWarningInFunction(dict)
<< enumName << " is not in enumeration: " << *this << nl
<< "using failsafe " << get(deflt)
<< "Lookup:" << key << " enumeration " << enumName
<< " is not in enumeration: " << *this << nl
<< "using default " << get(deflt)
<< " (value " << int(deflt) << ')' << endl;
}
else
{
FatalIOErrorInFunction(dict)
<< enumName << " is not in enumeration: " << *this << nl
<< "Lookup:" << key << " enumeration " << enumName
<< " is not in enumeration: " << *this << nl
<< exit(FatalIOError);
}
}
@ -223,7 +226,8 @@ bool Foam::Enum<EnumType>::readEntry
const word& key,
const dictionary& dict,
EnumType& val,
const bool mandatory
const bool mandatory,
const bool warnOnly
) const
{
const entry* eptr = dict.findEntry(key, keyType::LITERAL);
@ -232,7 +236,7 @@ bool Foam::Enum<EnumType>::readEntry
{
const word enumName(eptr->get<word>());
const label idx = find(enumName);
const label idx = keys_.find(enumName);
if (idx >= 0)
{
@ -240,14 +244,29 @@ bool Foam::Enum<EnumType>::readEntry
return true;
}
FatalIOErrorInFunction(dict)
<< enumName << " is not in enumeration: " << *this << nl
<< exit(FatalIOError);
// Found the dictionary entry, but the name not in enumeration
if (warnOnly)
{
IOWarningInFunction(dict)
<< "Lookup:" << key << " enumeration " << enumName
<< " is not in enumeration: " << *this << nl
<< "leaving value unchanged"
<< " (value " << int(val) << ')' << endl;
}
else
{
FatalIOErrorInFunction(dict)
<< "Lookup:" << key << " enumeration " << enumName
<< " is not in enumeration: " << *this << nl
<< exit(FatalIOError);
}
}
else if (mandatory)
{
FatalIOErrorInFunction(dict)
<< "'" << key << "' not found in dictionary " << dict.name() << nl
<< "Lookup:" << key
<< " not found in dictionary " << dict.name() << nl
<< exit(FatalIOError);
}

View File

@ -145,14 +145,6 @@ public:
//- True if there is a name corresponding to the given enumeration.
inline bool contains(const EnumType e) const;
//- Find the index of the given name.
// \return position in list or -1 if not found.
inline label find(const word& enumName) const;
//- Find the first index of given enumeration.
// \return position in list or -1 if not found.
inline label find(const EnumType e) const;
//- The enumeration corresponding to the given name.
// FatalError if not found.
EnumType get(const word& enumName) const;
@ -183,26 +175,28 @@ public:
//
// \return The value found or default if not found in dictionary.
// FatalIOError if the enumeration is incorrect.
// Specifying failsafe downgrades the FatalIOError to an IOWarning.
// Specifying warnOnly downgrades the FatalIOError to an IOWarning.
EnumType getOrDefault
(
const word& key, //!< Lookup key. Uses LITERAL (not REGEX)
const dictionary& dict, //!< dictionary
const EnumType deflt, //!< fallback if not found
const bool failsafe = false //!< Warn only on bad enumeration
const bool warnOnly = false //!< Warn (not fail) on bad enumeration
) const;
//- Find entry and assign to T val.
// FatalIOError if the enumeration is incorrect,
// or when it is mandatory but was not found.
//
// (TDB: handle IOobjectOption::readOption instead)
// \return true if the entry was found.
bool readEntry
(
const word& key, //!< Lookup key. Uses LITERAL (not REGEX)
const dictionary& dict, //!< dictionary
EnumType& val, //!< the value to read into
const bool mandatory = true //!< the keyword is mandatory
EnumType& val, //!< The value to read into
const bool mandatory = true, //!< The keyword is mandatory
const bool warnOnly = false //!< Warn (not fail) on bad enumeration
) const;
//- Find an entry if present, and assign to T val.
@ -214,7 +208,8 @@ public:
(
const word& key, //!< Lookup key. Uses LITERAL (not REGEX)
const dictionary& dict, //!< dictionary
EnumType& val //!< the value to read into
EnumType& val, //!< The value to read into
const bool warnOnly = false //!< Warn (not fail) on bad enumeration
) const;
@ -233,7 +228,7 @@ public:
) const;
//- Write the name representation of the enumeration to an Ostream
// A noop if the enumeration wasn't found.
// A no-op if the enumeration does not have a corresponding name.
inline void write(const EnumType e, Ostream& os) const;
//- Write enumeration names as a list without line-breaks
@ -276,6 +271,9 @@ public:
const label idx = 0
) noexcept;
//- True if iterator points to an entry
inline bool good() const noexcept;
//- The name at the current index
inline const word& key() const;
@ -300,23 +298,25 @@ public:
const_iterator begin() const noexcept { return cbegin(); }
const_iterator end() const noexcept { return cend(); }
//- Find the enumeration by name.
// Equal to cend() if not found, or test if good()
inline const_iterator cfind(const word& key) const;
const_iterator find(const word& key) const { return cfind(key); }
// Housekeeping
//- Find the key in the dictionary and return the corresponding
//- enumeration element based on its name.
//
// \return The value found or default if not found in dictionary.
// FatalError (or Warning) if the enumeration was incorrect.
//- Same as getOrDefault()
FOAM_DEPRECATED_STRICT(2019-06, "getOrDefault() method")
EnumType lookupOrDefault
(
const word& key, //!< Lookup key. Uses LITERAL (not REGEX)
const dictionary& dict, //!< dictionary
const EnumType deflt, //!< fallback if not found
const bool failsafe = false //!< Warn only on bad enumeration
const bool warnOnly = false //!< Warn (not fail) on bad enumeration
) const
{
return getOrDefault(key, dict, deflt, failsafe);
return getOrDefault(key, dict, deflt, warnOnly);
}
//- Deprecated(2020-11) use get() method
@ -353,6 +353,7 @@ public:
//- Append value/key pairs to the lists of known enumerations
// Does not check for duplicate entries
FOAM_DEPRECATED_STRICT(2023-06, "push_back() method")
void append
(
std::initializer_list<std::pair<EnumType, const char*>> list
@ -362,7 +363,7 @@ public:
}
//- Same as contains()
bool found(const word& enumName) const { return contains(enumName); }
bool found(const word& key) const { return contains(key); }
//- Same as contains()
bool found(const EnumType e) const { return contains(e); }

View File

@ -85,20 +85,6 @@ inline void Foam::Enum<EnumType>::clear()
}
template<class EnumType>
inline Foam::label Foam::Enum<EnumType>::find(const word& enumName) const
{
return keys_.find(enumName);
}
template<class EnumType>
inline Foam::label Foam::Enum<EnumType>::find(const EnumType e) const
{
return vals_.find(int(e));
}
template<class EnumType>
inline bool Foam::Enum<EnumType>::contains(const word& enumName) const
{
@ -116,7 +102,7 @@ inline bool Foam::Enum<EnumType>::contains(const EnumType e) const
template<class EnumType>
inline const Foam::word& Foam::Enum<EnumType>::get(const EnumType e) const
{
const label idx = find(e);
const label idx = vals_.find(int(e));
if (idx < 0)
{
@ -132,18 +118,19 @@ inline bool Foam::Enum<EnumType>::readIfPresent
(
const word& key,
const dictionary& dict,
EnumType& val
EnumType& val,
const bool warnOnly
) const
{
// Reading is non-mandatory
return readEntry(key, dict, val, false);
return readEntry(key, dict, val, false, warnOnly);
}
template<class EnumType>
inline void Foam::Enum<EnumType>::write(const EnumType e, Ostream& os) const
{
const label idx = find(e);
const label idx = vals_.find(int(e));
if (idx >= 0)
{
@ -199,6 +186,13 @@ inline EnumType Foam::Enum<EnumType>::const_iterator::val() const
}
template<class EnumType>
inline bool Foam::Enum<EnumType>::const_iterator::good() const noexcept
{
return (ptr_ && idx_ >= 0 && idx_ < ptr_->size());
}
template<class EnumType>
inline typename Foam::Enum<EnumType>::const_iterator&
Foam::Enum<EnumType>::const_iterator::operator++() noexcept
@ -244,6 +238,20 @@ Foam::Enum<EnumType>::cend() const noexcept
}
template<class EnumType>
inline typename Foam::Enum<EnumType>::const_iterator
Foam::Enum<EnumType>::cfind(const word& key) const
{
const label idx = keys_.find(key);
return typename Enum<EnumType>::const_iterator
(
this,
(idx >= 0 ? idx : this->size())
);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class EnumType>

View File

@ -32,7 +32,7 @@ Description
particular enumeration values.
\deprecated(2017-05) This class is retained for compatibility only and
should be used for any new code.
should be NOT used for any new code.
The Foam::Enum class is robuster, more flexible, easier to use.
See Also
@ -43,8 +43,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef NamedEnum_H
#define NamedEnum_H
#ifndef FoamCompat_NamedEnum_H
#define FoamCompat_NamedEnum_H
#include "HashTable.H"
#include "wordList.H"

View File

@ -26,9 +26,12 @@ License
\*---------------------------------------------------------------------------*/
#include "sliceRange.H"
#include "token.H"
#include "FixedList.H"
#include "List.H"
#include "token.H"
#include "Istream.H"
#include "Ostream.H"
#include <numeric>
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -46,14 +49,18 @@ Foam::List<Foam::label> Foam::sliceRange::labels() const
{
List<label> result(size_);
if (stride_)
if (stride_ > 1)
{
std::copy(cbegin(), cend(), result.begin());
}
else if (stride_ == 1)
{
std::iota(result.begin(), result.end(), start_);
}
else
{
// stride = 0 (identical values!)
std::fill(result.begin(), result.end(), start_);
std::fill_n(result.begin(), result.size(), start_);
}
return result;

View File

@ -38,7 +38,7 @@ SourceFiles
#ifndef Foam_sliceRange_H
#define Foam_sliceRange_H
#include "label.H"
#include "labelFwd.H"
#include <iterator>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,6 +47,8 @@ namespace Foam
{
// Forward Declarations
class Istream;
class Ostream;
template<class T> class List;
template<class T, unsigned N> class FixedList;
@ -122,6 +124,9 @@ public:
//- True if range is empty (zero-sized)
bool empty() const noexcept { return !size_; }
//- True if range has size greater than zero
bool good() const noexcept { return (size_ > 0); }
//- The (inclusive) lower value of the range.
constexpr label min() const noexcept { return start_; }
@ -141,8 +146,8 @@ public:
return start_ + i * stride_;
}
//- True if range is non-empty
explicit operator bool() const noexcept { return bool(size_); }
//- True if range has size greater than zero. Same as good()
explicit operator bool() const noexcept { return (size_ > 0); }
// Iteration / Generation

View File

@ -80,7 +80,7 @@ template<class BasicTurbulenceModel> sigma<BasicTurbulenceModel>::sigma
Ck_
(
dimensioned<scalar>::lookupOrAddToDict
dimensioned<scalar>::getOrAddToDict
(
"Ck",
this->coeffDict_,
@ -90,7 +90,7 @@ template<class BasicTurbulenceModel> sigma<BasicTurbulenceModel>::sigma
Cw_
(
dimensioned<scalar>::lookupOrAddToDict
dimensioned<scalar>::getOrAddToDict
(
"Cw",
this->coeffDict_,
@ -100,7 +100,7 @@ template<class BasicTurbulenceModel> sigma<BasicTurbulenceModel>::sigma
Csigma_
(
dimensioned<scalar>::lookupOrAddToDict
dimensioned<scalar>::getOrAddToDict
(
"Csigma",
this->coeffDict_,

View File

@ -100,7 +100,7 @@ static const Enum<int>& fieldTokenEnums()
if (enums_.empty())
{
enums_.append
enums_.push_back
({
#ifdef TOK_SCALAR_ID
FIELD_PAIR(volScalarField, SCALAR_ID),

View File

@ -98,7 +98,7 @@ static const Enum<int>& fieldTokenEnums()
if (enums_.empty())
{
enums_.append
enums_.push_back
({
#ifdef TOK_SCALAR_ID
FIELD_PAIR(volScalarField, SCALAR_ID),

View File

@ -7,7 +7,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -99,7 +99,7 @@ static const Enum<int>& fieldTokenEnums()
if (enums_.empty())
{
enums_.append
enums_.push_back
({
#ifdef TOK_SCALAR_ID
FIELD_PAIR(volScalarField, SCALAR_ID),

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -97,7 +97,7 @@ static const Enum<int>& fieldTokenEnums()
if (enums_.empty())
{
enums_.append
enums_.push_back
({
#ifdef TOK_SCALAR_ID
FIELD_PAIR(volScalarField, SCALAR_ID),

View File

@ -97,7 +97,7 @@ Foam::autoPtr<Foam::fileName> Foam::mappedPatchBase::readDatabase
{
return autoPtr<fileName>::New
(
dict.lookupOrDefault<fileName>
dict.getOrDefault<fileName>
(
"sampleDatabasePath",
fileName::null

View File

@ -1311,7 +1311,7 @@ adjointkOmegaSST::adjointkOmegaSST
),
a1_
(
dimensioned<scalar>::lookupOrAddToDict
dimensioned<scalar>::getOrAddToDict
(
"a1",
this->coeffDict_,
@ -1320,7 +1320,7 @@ adjointkOmegaSST::adjointkOmegaSST
),
b1_
(
dimensioned<scalar>::lookupOrAddToDict
dimensioned<scalar>::getOrAddToDict
(
"b1",
this->coeffDict_,
@ -1329,7 +1329,7 @@ adjointkOmegaSST::adjointkOmegaSST
),
c1_
(
dimensioned<scalar>::lookupOrAddToDict
dimensioned<scalar>::getOrAddToDict
(
"c1",
this->coeffDict_,
@ -1338,7 +1338,7 @@ adjointkOmegaSST::adjointkOmegaSST
),
F3_
(
Switch::lookupOrAddToDict
Switch::getOrAddToDict
(
"F3",
this->coeffDict_,

View File

@ -96,7 +96,7 @@ bool Foam::functionObjects::setTimeStepFaRegionsFunctionObject::read
if (timeFunctionObject::read(dict))
{
// Ensure that adjustTimeStep is active
if (!time_.controlDict().lookupOrDefault<bool>("adjustTimeStep", false))
if (!time_.controlDict().getOrDefault<bool>("adjustTimeStep", false))
{
FatalIOErrorInFunction(dict)
<< "Need to set 'adjustTimeStep' true to allow timestep control"

View File

@ -81,7 +81,7 @@ liquidFilmBase::liquidFilmBase
UName_(dict.get<word>("U")),
pName_(dict.lookupOrDefault<word>("p", word::null)),
pName_(dict.getOrDefault<word>("p", word::null)),
pRef_(dict.get<scalar>("pRef")),