mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -74,6 +74,8 @@ namespace Foam
|
||||
defineTypeNameAndDebug(POSIX, 0);
|
||||
}
|
||||
|
||||
static bool cwdPreference_(Foam::debug::optimisationSwitch("cwd", 0));
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
@ -280,7 +282,11 @@ Foam::fileName Foam::home(const std::string& userName)
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::cwd()
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//- The physical current working directory path name (pwd -P).
|
||||
static Foam::fileName cwd_P()
|
||||
{
|
||||
label pathLengthLimit = POSIX::pathLengthChunk;
|
||||
List<char> path(pathLengthLimit);
|
||||
@ -307,7 +313,7 @@ Foam::fileName Foam::cwd()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
path.setSize(pathLengthLimit);
|
||||
path.resize(pathLengthLimit);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -319,7 +325,86 @@ Foam::fileName Foam::cwd()
|
||||
<< "Couldn't get the current working directory"
|
||||
<< exit(FatalError);
|
||||
|
||||
return fileName::null;
|
||||
return fileName();
|
||||
}
|
||||
|
||||
|
||||
//- The logical current working directory path name.
|
||||
// From the PWD environment, same as pwd -L.
|
||||
static Foam::fileName cwd_L()
|
||||
{
|
||||
const char* env = ::getenv("PWD");
|
||||
|
||||
// Basic check
|
||||
if (!env || env[0] != '/')
|
||||
{
|
||||
WarningInFunction
|
||||
<< "PWD is invalid - reverting to physical description"
|
||||
<< nl;
|
||||
|
||||
return cwd_P();
|
||||
}
|
||||
|
||||
fileName dir(env);
|
||||
|
||||
// Check for "/."
|
||||
for
|
||||
(
|
||||
std::string::size_type pos = 0;
|
||||
std::string::npos != (pos = dir.find("/.", pos));
|
||||
/*nil*/
|
||||
)
|
||||
{
|
||||
pos += 2;
|
||||
|
||||
if
|
||||
(
|
||||
// Ends in "/." or has "/./"
|
||||
!dir[pos] || dir[pos] == '/'
|
||||
|
||||
// Ends in "/.." or has "/../"
|
||||
|| (dir[pos] == '.' && (!dir[pos+1] || dir[pos+1] == '/'))
|
||||
)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "PWD contains /. or /.. - reverting to physical description"
|
||||
<< nl;
|
||||
|
||||
return cwd_P();
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, verify that PWD actually corresponds to the "." directory
|
||||
if (!fileStat(dir, true).sameINode(fileStat(".", true)))
|
||||
{
|
||||
WarningInFunction
|
||||
<< "PWD is not the cwd() - reverting to physical description"
|
||||
<< nl;
|
||||
|
||||
return cwd_P();
|
||||
}
|
||||
|
||||
|
||||
return fileName(dir);
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
Foam::fileName Foam::cwd()
|
||||
{
|
||||
return cwd(cwdPreference_);
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::cwd(bool logical)
|
||||
{
|
||||
if (logical)
|
||||
{
|
||||
return cwd_L();
|
||||
}
|
||||
|
||||
return cwd_P();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,14 +43,14 @@ Foam::fileStat::fileStat()
|
||||
|
||||
Foam::fileStat::fileStat
|
||||
(
|
||||
const fileName& fName,
|
||||
const char* fName,
|
||||
const bool followLink,
|
||||
const unsigned int maxTime
|
||||
)
|
||||
:
|
||||
isValid_(false)
|
||||
{
|
||||
if (fName.empty())
|
||||
if (!fName || !fName[0])
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -64,11 +64,11 @@ Foam::fileStat::fileStat
|
||||
{
|
||||
if (followLink)
|
||||
{
|
||||
locIsValid = (::stat(fName.c_str(), &status_) == 0);
|
||||
locIsValid = (::stat(fName, &status_) == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
locIsValid = (::lstat(fName.c_str(), &status_) == 0);
|
||||
locIsValid = (::lstat(fName, &status_) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,6 +77,17 @@ Foam::fileStat::fileStat
|
||||
}
|
||||
|
||||
|
||||
Foam::fileStat::fileStat
|
||||
(
|
||||
const fileName& fName,
|
||||
const bool followLink,
|
||||
const unsigned int maxTime
|
||||
)
|
||||
:
|
||||
fileStat(fName.c_str(), followLink, maxTime)
|
||||
{}
|
||||
|
||||
|
||||
Foam::fileStat::fileStat(Istream& is)
|
||||
{
|
||||
is >> *this;
|
||||
|
||||
@ -28,7 +28,7 @@ Description
|
||||
Wrapper for stat() and lstat() system calls.
|
||||
|
||||
Warning
|
||||
on Linux (an maybe on others) a stat() of an nfs mounted (remote)
|
||||
On Linux (an maybe on others) a stat() of an nfs mounted (remote)
|
||||
file does never timeout and cannot be interrupted!
|
||||
So e.g. Foam::ping first and hope nfs is running.
|
||||
|
||||
@ -79,16 +79,28 @@ public:
|
||||
fileStat();
|
||||
|
||||
//- Construct from components.
|
||||
// \param fName \n
|
||||
// The file name or directory name to stat.
|
||||
//
|
||||
// \param followLink \n
|
||||
// If it is a link, get the status of the source file/directory.
|
||||
// \param fName The file name or directory name to stat.
|
||||
// \param followLink If it is a link, get the status of the source
|
||||
// file/directory.
|
||||
// \param maxTime The timeout value.
|
||||
//
|
||||
// \param maxTime \n
|
||||
// The timeout value.
|
||||
// \note An empty filename is a no-op.
|
||||
fileStat
|
||||
(
|
||||
const char* fName,
|
||||
const bool followLink = true,
|
||||
const unsigned int maxTime = 0
|
||||
);
|
||||
|
||||
//- Construct from components.
|
||||
//
|
||||
// \note an empty filename is a no-op.
|
||||
// \param fName The file name or directory name to stat.
|
||||
// \param followLink If it is a link, get the status of the source
|
||||
// file/directory.
|
||||
// \param maxTime The timeout value.
|
||||
//
|
||||
// \note An empty filename is a no-op.
|
||||
fileStat
|
||||
(
|
||||
const fileName& fName,
|
||||
|
||||
@ -154,6 +154,7 @@ public:
|
||||
inline bool set(const label i) const;
|
||||
|
||||
//- Set element to given pointer and return old element (can be null)
|
||||
// No-op if the new pointer value is identical to the current content.
|
||||
inline autoPtr<T> set(label i, T* ptr);
|
||||
|
||||
//- Set element to given autoPtr and return old element
|
||||
|
||||
@ -182,7 +182,7 @@ public:
|
||||
|
||||
//- Set element to specified pointer and return the old list element,
|
||||
//- which can be a nullptr.
|
||||
// No checks on new element
|
||||
// No-op if the new pointer value is identical to the current content.
|
||||
inline T* set(const label i, T* ptr);
|
||||
|
||||
//- Reorder elements. Reordering must be unique (ie, shuffle).
|
||||
|
||||
@ -180,6 +180,10 @@ template<class T>
|
||||
inline T* Foam::UPtrList<T>::set(const label i, T* ptr)
|
||||
{
|
||||
T* old = ptrs_[i];
|
||||
if (old == ptr)
|
||||
{
|
||||
return nullptr; // Content did not change
|
||||
}
|
||||
ptrs_[i] = ptr;
|
||||
return old;
|
||||
}
|
||||
|
||||
@ -79,6 +79,7 @@ public:
|
||||
UNDEFINED = 0, //!< An undefined token-type
|
||||
|
||||
// Fundamental types
|
||||
BOOL, //!< boolean type
|
||||
FLAG, //!< stream flag (1-byte bitmask)
|
||||
PUNCTUATION, //!< single character punctuation
|
||||
LABEL, //!< label (integer) type
|
||||
@ -92,7 +93,7 @@ public:
|
||||
//!< dictionary \c $variable expansion
|
||||
VERBATIMSTRING, //!< Contents are a Foam::string representing verbatim
|
||||
//!< content
|
||||
COMPOUND, //!< Compound type such as List\<label\> etc.
|
||||
COMPOUND, //!< Compound type such as \c List\<label\> etc.
|
||||
|
||||
ERROR //!< A token error encountered
|
||||
};
|
||||
@ -115,20 +116,22 @@ public:
|
||||
TAB = '\t',
|
||||
NL = '\n',
|
||||
|
||||
END_STATEMENT = ';', //!< End entry [#isseparator]
|
||||
BEGIN_LIST = '(', //!< Begin list [#isseparator]
|
||||
END_LIST = ')', //!< End list [#isseparator]
|
||||
BEGIN_SQR = '[', //!< Begin dimensions [#isseparator]
|
||||
END_SQR = ']', //!< End dimensions [#isseparator]
|
||||
BEGIN_BLOCK = '{', //!< Begin block [#isseparator]
|
||||
END_BLOCK = '}', //!< End block [#isseparator]
|
||||
COLON = ':', //!< Colon [#isseparator]
|
||||
COMMA = ',', //!< Comma [#isseparator]
|
||||
END_STATEMENT = ';', //!< End entry [#isseparator]
|
||||
BEGIN_LIST = '(', //!< Begin list [#isseparator]
|
||||
END_LIST = ')', //!< End list [#isseparator]
|
||||
BEGIN_SQR = '[', //!< Begin dimensions [#isseparator]
|
||||
END_SQR = ']', //!< End dimensions [#isseparator]
|
||||
BEGIN_BLOCK = '{', //!< Begin block [#isseparator]
|
||||
END_BLOCK = '}', //!< End block [#isseparator]
|
||||
COLON = ':', //!< Colon [#isseparator]
|
||||
COMMA = ',', //!< Comma [#isseparator]
|
||||
HASH = '#',
|
||||
ATSYM = '@',
|
||||
SQUOTE = '\'', //!< Single quote
|
||||
DQUOTE = '"', //!< Double quote
|
||||
|
||||
BEGIN_STRING = '"',
|
||||
END_STRING = BEGIN_STRING,
|
||||
BEGIN_STRING = DQUOTE, //!< Double quote for begin string
|
||||
END_STRING = DQUOTE, //!< Double quote for end string
|
||||
|
||||
ASSIGN = '=', //!< Assignment/equals [#isseparator]
|
||||
ADD = '+', //!< Addition [#isseparator]
|
||||
@ -358,6 +361,9 @@ public:
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Create a bool token.
|
||||
inline static token boolean(bool on);
|
||||
|
||||
//- Create a token with stream flags, no sanity check
|
||||
//
|
||||
// \param bitmask the flags to set
|
||||
@ -406,6 +412,9 @@ public:
|
||||
//- True if token is ERROR
|
||||
inline bool error() const;
|
||||
|
||||
//- True if token is BOOL
|
||||
inline bool isBool() const;
|
||||
|
||||
//- True if token is FLAG
|
||||
inline bool isFlag() const;
|
||||
|
||||
@ -445,7 +454,11 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return flag bitmask
|
||||
//- Return boolean token value.
|
||||
// Report FatalIOError and return false if token is not BOOL
|
||||
inline bool boolToken() const;
|
||||
|
||||
//- Return flag bitmask value.
|
||||
// Report FatalIOError and return NO_FLAG if token is not FLAG
|
||||
inline int flagToken() const;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,6 +27,16 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::token Foam::token::boolean(bool on)
|
||||
{
|
||||
token tok;
|
||||
tok.type_ = tokenType::BOOL;
|
||||
tok.data_.labelVal = on;
|
||||
|
||||
return tok;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::token Foam::token::flag(int bitmask)
|
||||
{
|
||||
token tok;
|
||||
@ -306,6 +316,23 @@ inline bool Foam::token::setType(token::tokenType variant)
|
||||
|
||||
switch (variant)
|
||||
{
|
||||
case tokenType::BOOL:
|
||||
case tokenType::LABEL:
|
||||
{
|
||||
switch (type_)
|
||||
{
|
||||
case tokenType::BOOL:
|
||||
case tokenType::LABEL:
|
||||
type_ = variant;
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case tokenType::STRING:
|
||||
case tokenType::VARIABLE:
|
||||
case tokenType::VERBATIMSTRING:
|
||||
@ -321,10 +348,10 @@ inline bool Foam::token::setType(token::tokenType variant)
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@ -364,6 +391,24 @@ inline bool Foam::token::error() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::token::isBool() const
|
||||
{
|
||||
return (type_ == tokenType::BOOL);
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::token::boolToken() const
|
||||
{
|
||||
if (type_ == tokenType::BOOL)
|
||||
{
|
||||
return data_.labelVal;
|
||||
}
|
||||
|
||||
parseError("bool");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::token::isFlag() const
|
||||
{
|
||||
return (type_ == tokenType::FLAG);
|
||||
@ -423,7 +468,7 @@ inline Foam::label Foam::token::labelToken() const
|
||||
return data_.labelVal;
|
||||
}
|
||||
|
||||
parseError(pTraits<label>::typeName);
|
||||
parseError("label");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -441,8 +486,8 @@ inline Foam::floatScalar Foam::token::floatScalarToken() const
|
||||
return data_.floatVal;
|
||||
}
|
||||
|
||||
parseError("floatScalar");
|
||||
return 0.0;
|
||||
parseError("float");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -459,8 +504,8 @@ inline Foam::doubleScalar Foam::token::doubleScalarToken() const
|
||||
return data_.doubleVal;
|
||||
}
|
||||
|
||||
parseError("doubleScalar");
|
||||
return 0.0;
|
||||
parseError("double");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -485,8 +530,8 @@ inline Foam::scalar Foam::token::scalarToken() const
|
||||
return data_.doubleVal;
|
||||
}
|
||||
|
||||
parseError(pTraits<scalar>::typeName);
|
||||
return 0.0;
|
||||
parseError("scalar");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -508,7 +553,7 @@ inline Foam::scalar Foam::token::number() const
|
||||
}
|
||||
|
||||
parseError("number (label or scalar)");
|
||||
return 0.0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -525,7 +570,7 @@ inline const Foam::word& Foam::token::wordToken() const
|
||||
return *data_.wordPtr;
|
||||
}
|
||||
|
||||
parseError(word::typeName);
|
||||
parseError("word");
|
||||
return word::null;
|
||||
}
|
||||
|
||||
@ -559,7 +604,7 @@ inline const Foam::string& Foam::token::stringToken() const
|
||||
return *data_.stringPtr;
|
||||
}
|
||||
|
||||
parseError(string::typeName);
|
||||
parseError("string");
|
||||
return string::null;
|
||||
}
|
||||
|
||||
@ -742,6 +787,9 @@ inline bool Foam::token::operator==(const token& tok) const
|
||||
case tokenType::UNDEFINED:
|
||||
return true;
|
||||
|
||||
case tokenType::BOOL:
|
||||
return data_.labelVal == tok.data_.labelVal;
|
||||
|
||||
case tokenType::FLAG:
|
||||
return data_.flagVal == tok.data_.flagVal;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,6 +43,10 @@ static OS& printTokenInfo(OS& os, const token& tok)
|
||||
os << "undefined token";
|
||||
break;
|
||||
|
||||
case token::tokenType::BOOL:
|
||||
os << "bool '" << (tok.boolToken() ? "true" : "false") << '\'';
|
||||
break;
|
||||
|
||||
case token::tokenType::FLAG:
|
||||
os << "flag '" << int(tok.flagToken()) << '\'';
|
||||
break;
|
||||
@ -121,6 +125,7 @@ Foam::word Foam::token::name() const
|
||||
switch (type_)
|
||||
{
|
||||
case token::tokenType::UNDEFINED: return "undefined";
|
||||
case token::tokenType::BOOL: return "bool";
|
||||
case token::tokenType::FLAG: return "flag";
|
||||
case token::tokenType::PUNCTUATION: return "punctuation";
|
||||
case token::tokenType::LABEL: return "label";
|
||||
@ -160,6 +165,10 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& tok)
|
||||
<< "Undefined token" << endl;
|
||||
break;
|
||||
|
||||
case token::tokenType::BOOL:
|
||||
os << tok.data_.labelVal;
|
||||
break;
|
||||
|
||||
case token::tokenType::FLAG:
|
||||
// Swallow the flag
|
||||
break;
|
||||
@ -207,8 +216,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& tok)
|
||||
default:
|
||||
os << "UNKNOWN";
|
||||
SeriousErrorInFunction
|
||||
<< "Unknown token"
|
||||
<< endl;
|
||||
<< "Unknown token" << endl;
|
||||
}
|
||||
|
||||
os.check(FUNCTION_NAME);
|
||||
|
||||
@ -342,11 +342,11 @@ void Foam::Time::setControls()
|
||||
|
||||
void Foam::Time::setMonitoring(const bool forceProfiling)
|
||||
{
|
||||
const dictionary* profilingDict = controlDict_.subDictPtr("profiling");
|
||||
const dictionary* profilingDict = controlDict_.findDict("profiling");
|
||||
if (!profilingDict)
|
||||
{
|
||||
// ... or from etc/controlDict
|
||||
profilingDict = debug::controlDict().subDictPtr("profiling");
|
||||
profilingDict = debug::controlDict().findDict("profiling");
|
||||
}
|
||||
|
||||
// initialize profiling on request
|
||||
|
||||
@ -99,7 +99,7 @@ void Foam::Time::readDict()
|
||||
// DebugSwitches
|
||||
if
|
||||
(
|
||||
(localDict = controlDict_.subDictPtr("DebugSwitches")) != nullptr
|
||||
(localDict = controlDict_.findDict("DebugSwitches")) != nullptr
|
||||
&& localDict->size()
|
||||
)
|
||||
{
|
||||
@ -146,7 +146,7 @@ void Foam::Time::readDict()
|
||||
// InfoSwitches
|
||||
if
|
||||
(
|
||||
(localDict = controlDict_.subDictPtr("InfoSwitches")) != nullptr
|
||||
(localDict = controlDict_.findDict("InfoSwitches")) != nullptr
|
||||
&& localDict->size()
|
||||
)
|
||||
{
|
||||
@ -192,7 +192,7 @@ void Foam::Time::readDict()
|
||||
// OptimisationSwitches
|
||||
if
|
||||
(
|
||||
(localDict = controlDict_.subDictPtr("OptimisationSwitches")) != nullptr
|
||||
(localDict = controlDict_.findDict("OptimisationSwitches")) != nullptr
|
||||
&& localDict->size()
|
||||
)
|
||||
{
|
||||
@ -273,7 +273,7 @@ void Foam::Time::readDict()
|
||||
if
|
||||
(
|
||||
|
||||
(localDict = controlDict_.subDictPtr("DimensionedConstants")) != nullptr
|
||||
(localDict = controlDict_.findDict("DimensionedConstants")) != nullptr
|
||||
&& localDict->size()
|
||||
)
|
||||
{
|
||||
@ -310,7 +310,7 @@ void Foam::Time::readDict()
|
||||
// DimensionSets
|
||||
if
|
||||
(
|
||||
(localDict = controlDict_.subDictPtr("DimensionSets")) != nullptr
|
||||
(localDict = controlDict_.findDict("DimensionSets")) != nullptr
|
||||
&& localDict->size()
|
||||
)
|
||||
{
|
||||
|
||||
@ -70,8 +70,8 @@ Foam::TimePaths::TimePaths
|
||||
)
|
||||
:
|
||||
processorCase_(args.parRunControl().parRun()),
|
||||
distributed_(args.parRunControl().distributed()),
|
||||
rootPath_(args.rootPath()),
|
||||
distributed_(args.distributed()),
|
||||
globalCaseName_(args.globalCaseName()),
|
||||
case_(args.caseName()),
|
||||
system_(systemName),
|
||||
@ -93,8 +93,8 @@ Foam::TimePaths::TimePaths
|
||||
)
|
||||
:
|
||||
processorCase_(false),
|
||||
rootPath_(rootPath),
|
||||
distributed_(false),
|
||||
rootPath_(rootPath),
|
||||
globalCaseName_(caseName),
|
||||
case_(caseName),
|
||||
system_(systemName),
|
||||
@ -117,8 +117,8 @@ Foam::TimePaths::TimePaths
|
||||
)
|
||||
:
|
||||
processorCase_(processorCase),
|
||||
rootPath_(rootPath),
|
||||
distributed_(distributed),
|
||||
rootPath_(rootPath),
|
||||
globalCaseName_(globalCaseName),
|
||||
case_(caseName),
|
||||
system_(systemName),
|
||||
|
||||
@ -56,8 +56,9 @@ class TimePaths
|
||||
// Private data
|
||||
|
||||
bool processorCase_;
|
||||
const fileName rootPath_;
|
||||
bool distributed_;
|
||||
|
||||
const fileName rootPath_;
|
||||
fileName globalCaseName_;
|
||||
fileName case_;
|
||||
const word system_;
|
||||
|
||||
@ -70,12 +70,8 @@ Foam::List<bool> Foam::timeSelector::selected(const instantList& times) const
|
||||
{
|
||||
const scalar target = range.value();
|
||||
|
||||
int nearestIndex =
|
||||
TimePaths::findClosestTimeIndex
|
||||
(
|
||||
times,
|
||||
target
|
||||
);
|
||||
const label nearestIndex =
|
||||
TimePaths::findClosestTimeIndex(times, target);
|
||||
|
||||
// Note could also test if the index is too far away.
|
||||
// Eg, for times (0 10 20 30 40) selecting 100 will currently
|
||||
@ -142,11 +138,6 @@ void Foam::timeSelector::addOptions
|
||||
"latestTime",
|
||||
"Select the latest time"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"newTimes",
|
||||
"Select the new times"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"time",
|
||||
@ -297,37 +288,4 @@ Foam::instantList Foam::timeSelector::selectIfPresent
|
||||
}
|
||||
|
||||
|
||||
Foam::instantList Foam::timeSelector::select
|
||||
(
|
||||
Time& runTime,
|
||||
const argList& args,
|
||||
const word& fName
|
||||
)
|
||||
{
|
||||
instantList times(timeSelector::select0(runTime, args));
|
||||
|
||||
const label nTimes = times.size();
|
||||
|
||||
if (nTimes && args.found("newTimes"))
|
||||
{
|
||||
List<bool> selectTimes(nTimes, true);
|
||||
|
||||
for (label timei=0; timei < nTimes; ++timei)
|
||||
{
|
||||
selectTimes[timei] =
|
||||
!fileHandler().exists
|
||||
(
|
||||
runTime.path()
|
||||
/ times[timei].name()
|
||||
/ fName
|
||||
);
|
||||
}
|
||||
|
||||
return subset(selectTimes, times);
|
||||
}
|
||||
|
||||
return times;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -163,17 +163,6 @@ public:
|
||||
const argList& args
|
||||
);
|
||||
|
||||
//- Return the set of times selected based on the argList options
|
||||
//- including support for \b -newTimes in which times are selected
|
||||
//- if the file 'fName' does not exist in the time directory.
|
||||
// Also set the runTime to the first instance or the
|
||||
// \c constant/ directory if no instances are specified or available
|
||||
static instantList select
|
||||
(
|
||||
Time& runTime,
|
||||
const argList& args,
|
||||
const word& fName
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -134,13 +134,14 @@ void Foam::dictionary::checkITstream
|
||||
|
||||
Foam::dictionary::dictionary()
|
||||
:
|
||||
name_(),
|
||||
parent_(dictionary::null)
|
||||
{}
|
||||
|
||||
|
||||
Foam::dictionary::dictionary(const fileName& name)
|
||||
:
|
||||
dictionaryName(name),
|
||||
name_(name),
|
||||
parent_(dictionary::null)
|
||||
{}
|
||||
|
||||
@ -151,18 +152,18 @@ Foam::dictionary::dictionary
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
dictionaryName(dict.name()),
|
||||
parent_type(dict, *this),
|
||||
name_(dict.name()),
|
||||
parent_(parentDict)
|
||||
{
|
||||
forAllIter(parent_type, *this, iter)
|
||||
for (entry& e : *this)
|
||||
{
|
||||
hashedEntries_.insert(iter().keyword(), &iter());
|
||||
hashedEntries_.insert(e.keyword(), &e);
|
||||
|
||||
if (iter().keyword().isPattern())
|
||||
if (e.keyword().isPattern())
|
||||
{
|
||||
patterns_.insert(&iter());
|
||||
regexps_.insert(autoPtr<regExp>::New(iter().keyword()));
|
||||
patterns_.insert(&e);
|
||||
regexps_.insert(autoPtr<regExp>::New(e.keyword()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,33 +174,31 @@ Foam::dictionary::dictionary
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
dictionaryName(dict.name()),
|
||||
parent_type(dict, *this),
|
||||
name_(dict.name()),
|
||||
parent_(dictionary::null)
|
||||
{
|
||||
forAllIter(parent_type, *this, iter)
|
||||
for (entry& e : *this)
|
||||
{
|
||||
hashedEntries_.insert(iter().keyword(), &iter());
|
||||
hashedEntries_.insert(e.keyword(), &e);
|
||||
|
||||
if (iter().keyword().isPattern())
|
||||
if (e.keyword().isPattern())
|
||||
{
|
||||
patterns_.insert(&iter());
|
||||
regexps_.insert(autoPtr<regExp>::New(iter().keyword()));
|
||||
patterns_.insert(&e);
|
||||
regexps_.insert(autoPtr<regExp>::New(e.keyword()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary::dictionary
|
||||
(
|
||||
const dictionary* dictPtr
|
||||
)
|
||||
Foam::dictionary::dictionary(const dictionary* dict)
|
||||
:
|
||||
name_(),
|
||||
parent_(dictionary::null)
|
||||
{
|
||||
if (dictPtr)
|
||||
if (dict)
|
||||
{
|
||||
operator=(*dictPtr);
|
||||
operator=(*dict);
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,6 +209,7 @@ Foam::dictionary::dictionary
|
||||
dictionary&& dict
|
||||
)
|
||||
:
|
||||
name_(),
|
||||
parent_(parentDict)
|
||||
{
|
||||
transfer(dict);
|
||||
@ -222,6 +222,7 @@ Foam::dictionary::dictionary
|
||||
dictionary&& dict
|
||||
)
|
||||
:
|
||||
name_(),
|
||||
parent_(dictionary::null)
|
||||
{
|
||||
transfer(dict);
|
||||
@ -282,9 +283,9 @@ Foam::SHA1Digest Foam::dictionary::digest() const
|
||||
OSHA1stream os;
|
||||
|
||||
// Process entries
|
||||
forAllConstIter(parent_type, *this, iter)
|
||||
for (const entry& e : *this)
|
||||
{
|
||||
os << *iter;
|
||||
os << e;
|
||||
}
|
||||
|
||||
return os.digest();
|
||||
@ -297,9 +298,9 @@ Foam::tokenList Foam::dictionary::tokens() const
|
||||
OStringStream os;
|
||||
|
||||
// Process entries
|
||||
forAllConstIter(parent_type, *this, iter)
|
||||
for (const entry& e : *this)
|
||||
{
|
||||
os << *iter;
|
||||
os << e;
|
||||
}
|
||||
|
||||
// String re-parsed as a list of tokens
|
||||
@ -310,44 +311,50 @@ Foam::tokenList Foam::dictionary::tokens() const
|
||||
bool Foam::dictionary::found
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearch(keyword, recursive, patternMatch).found();
|
||||
return csearch(keyword, matchOpt).found();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
Foam::entry* Foam::dictionary::findEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return csearch(keyword, recursive, patternMatch).ptr();
|
||||
}
|
||||
|
||||
|
||||
Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
)
|
||||
{
|
||||
return search(keyword, recursive, patternMatch).ptr();
|
||||
return search(keyword, matchOpt).ptr();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry* Foam::dictionary::findEntry
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearch(keyword, matchOpt).ptr();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry* Foam::dictionary::findScoped
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearchScoped(keyword, matchOpt).ptr();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry& Foam::dictionary::lookupEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const const_searcher finder(csearch(keyword, recursive, patternMatch));
|
||||
const const_searcher finder(csearch(keyword, matchOpt));
|
||||
|
||||
if (!finder.found())
|
||||
{
|
||||
@ -364,22 +371,10 @@ const Foam::entry& Foam::dictionary::lookupEntry
|
||||
Foam::ITstream& Foam::dictionary::lookup
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return lookupEntry(keyword, recursive, patternMatch).stream();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry* Foam::dictionary::lookupScopedEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return csearchScoped(keyword, recursive, patternMatch).ptr();
|
||||
return lookupEntry(keyword, matchOpt).stream();
|
||||
}
|
||||
|
||||
|
||||
@ -394,16 +389,14 @@ bool Foam::dictionary::substituteKeyword(const word& keyword, bool mergeEntry)
|
||||
const word varName(keyword.substr(1), false);
|
||||
|
||||
// Lookup the variable name in the given dictionary
|
||||
const const_searcher finder(csearch(varName, true, true));
|
||||
const const_searcher finder(csearch(varName, keyType::REGEX_RECURSIVE));
|
||||
|
||||
// If defined insert its entries into this dictionary
|
||||
if (finder.found())
|
||||
{
|
||||
const dictionary& addDict = finder.dict();
|
||||
|
||||
forAllConstIters(addDict, iter)
|
||||
for (const entry& e : finder.dict())
|
||||
{
|
||||
add(iter(), mergeEntry);
|
||||
add(e, mergeEntry);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -428,16 +421,14 @@ bool Foam::dictionary::substituteScopedKeyword
|
||||
const word varName(keyword.substr(1), false);
|
||||
|
||||
// Lookup the variable name in the given dictionary
|
||||
const const_searcher finder(csearchScoped(varName, true, true));
|
||||
const auto finder(csearchScoped(varName, keyType::REGEX_RECURSIVE));
|
||||
|
||||
// If defined insert its entries into this dictionary
|
||||
if (finder.found())
|
||||
{
|
||||
const dictionary& addDict = finder.dict();
|
||||
|
||||
forAllConstIter(parent_type, addDict, iter)
|
||||
for (const entry& e : finder.dict())
|
||||
{
|
||||
add(iter(), mergeEntry);
|
||||
add(e, mergeEntry);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -449,29 +440,35 @@ bool Foam::dictionary::substituteScopedKeyword
|
||||
|
||||
bool Foam::dictionary::isDict(const word& keyword) const
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
return csearch(keyword, false, true).isDict();
|
||||
// Allow patterns, non-recursive
|
||||
return csearch(keyword, keyType::REGEX).isDict();
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
|
||||
Foam::dictionary* Foam::dictionary::findDict
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt
|
||||
)
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
return csearch(keyword, false, true).dictPtr();
|
||||
return search(keyword, matchOpt).dictPtr();
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword)
|
||||
const Foam::dictionary* Foam::dictionary::findDict
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
return search(keyword, false, true).dictPtr();
|
||||
return csearch(keyword, matchOpt).dictPtr();
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
const const_searcher finder(csearch(keyword, false, true));
|
||||
// Allow patterns, non-recursive
|
||||
const const_searcher finder(csearch(keyword, keyType::REGEX));
|
||||
|
||||
if (!finder.found())
|
||||
{
|
||||
@ -487,8 +484,8 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
|
||||
|
||||
Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
searcher finder = search(keyword, false, true);
|
||||
// Allow patterns, non-recursive
|
||||
searcher finder(search(keyword, keyType::REGEX));
|
||||
|
||||
if (!finder.found())
|
||||
{
|
||||
@ -508,8 +505,8 @@ Foam::dictionary Foam::dictionary::subOrEmptyDict
|
||||
const bool mandatory
|
||||
) const
|
||||
{
|
||||
// Find non-recursive with patterns
|
||||
const const_searcher finder(csearch(keyword, false, true));
|
||||
// Allow patterns, non-recursive
|
||||
const const_searcher finder(csearch(keyword, keyType::REGEX));
|
||||
|
||||
if (finder.isDict())
|
||||
{
|
||||
@ -543,7 +540,8 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict
|
||||
const word& keyword
|
||||
) const
|
||||
{
|
||||
const const_searcher finder(csearch(keyword, false, true));
|
||||
// Allow patterns, non-recursive
|
||||
const const_searcher finder(csearch(keyword, keyType::REGEX));
|
||||
|
||||
if (finder.isDict())
|
||||
{
|
||||
@ -565,15 +563,15 @@ const Foam::dictionary& Foam::dictionary::optionalSubDict
|
||||
|
||||
Foam::wordList Foam::dictionary::toc() const
|
||||
{
|
||||
wordList keys(size());
|
||||
wordList list(size());
|
||||
|
||||
label n = 0;
|
||||
forAllConstIters(*this, iter)
|
||||
for (const entry& e : *this)
|
||||
{
|
||||
keys[n++] = iter().keyword();
|
||||
list[n++] = e.keyword();
|
||||
}
|
||||
|
||||
return keys;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@ -585,19 +583,19 @@ Foam::wordList Foam::dictionary::sortedToc() const
|
||||
|
||||
Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const
|
||||
{
|
||||
List<keyType> keys(size());
|
||||
List<keyType> list(size());
|
||||
|
||||
label n = 0;
|
||||
forAllConstIters(*this, iter)
|
||||
for (const entry& e : *this)
|
||||
{
|
||||
if (iter().keyword().isPattern() ? patterns : !patterns)
|
||||
if (e.keyword().isPattern() ? patterns : !patterns)
|
||||
{
|
||||
keys[n++] = iter().keyword();
|
||||
list[n++] = e.keyword();
|
||||
}
|
||||
}
|
||||
keys.setSize(n);
|
||||
list.resize(n);
|
||||
|
||||
return keys;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@ -746,7 +744,7 @@ Foam::entry* Foam::dictionary::set(entry* entryPtr)
|
||||
}
|
||||
|
||||
// Find non-recursive with patterns
|
||||
searcher finder(search(entryPtr->keyword(), false, true));
|
||||
searcher finder(search(entryPtr->keyword(), keyType::REGEX));
|
||||
|
||||
// Clear dictionary so merge acts like overwrite
|
||||
if (finder.isDict())
|
||||
@ -781,31 +779,31 @@ bool Foam::dictionary::merge(const dictionary& dict)
|
||||
|
||||
bool changed = false;
|
||||
|
||||
forAllConstIters(dict, iter)
|
||||
for (const entry& e : dict)
|
||||
{
|
||||
auto fnd = hashedEntries_.find(iter().keyword());
|
||||
auto fnd = hashedEntries_.find(e.keyword());
|
||||
|
||||
if (fnd.found())
|
||||
{
|
||||
// Recursively merge sub-dictionaries
|
||||
// TODO: merge without copying
|
||||
if (fnd()->isDict() && iter().isDict())
|
||||
if (fnd()->isDict() && e.isDict())
|
||||
{
|
||||
if (fnd()->dict().merge(iter().dict()))
|
||||
if (fnd()->dict().merge(e.dict()))
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
add(iter().clone(*this).ptr(), true);
|
||||
add(e.clone(*this).ptr(), true);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not found - just add
|
||||
add(iter().clone(*this).ptr());
|
||||
add(e.clone(*this).ptr());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@ -853,9 +851,9 @@ void Foam::dictionary::operator=(const dictionary& rhs)
|
||||
// Create clones of the entries in the given dictionary
|
||||
// resetting the parentDict to this dictionary
|
||||
|
||||
forAllConstIters(rhs, iter)
|
||||
for (const entry& e : rhs)
|
||||
{
|
||||
add(iter().clone(*this).ptr());
|
||||
add(e.clone(*this).ptr());
|
||||
}
|
||||
}
|
||||
|
||||
@ -870,9 +868,9 @@ void Foam::dictionary::operator+=(const dictionary& rhs)
|
||||
<< abort(FatalIOError);
|
||||
}
|
||||
|
||||
forAllConstIters(rhs, iter)
|
||||
for (const entry& e : rhs)
|
||||
{
|
||||
add(iter().clone(*this).ptr());
|
||||
add(e.clone(*this).ptr());
|
||||
}
|
||||
}
|
||||
|
||||
@ -887,11 +885,11 @@ void Foam::dictionary::operator|=(const dictionary& rhs)
|
||||
<< abort(FatalIOError);
|
||||
}
|
||||
|
||||
forAllConstIters(rhs, iter)
|
||||
for (const entry& e : rhs)
|
||||
{
|
||||
if (!found(iter().keyword()))
|
||||
if (!found(e.keyword()))
|
||||
{
|
||||
add(iter().clone(*this).ptr());
|
||||
add(e.clone(*this).ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -907,9 +905,9 @@ void Foam::dictionary::operator<<=(const dictionary& rhs)
|
||||
<< abort(FatalIOError);
|
||||
}
|
||||
|
||||
forAllConstIters(rhs, iter)
|
||||
for (const entry& e : rhs)
|
||||
{
|
||||
set(iter().clone(*this).ptr());
|
||||
set(e.clone(*this).ptr());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -85,6 +85,7 @@ SeeAlso
|
||||
#ifndef dictionary_H
|
||||
#define dictionary_H
|
||||
|
||||
#include <type_traits>
|
||||
#include "entry.H"
|
||||
#include "IDLList.H"
|
||||
#include "DLList.H"
|
||||
@ -93,7 +94,10 @@ SeeAlso
|
||||
#include "HashTable.H"
|
||||
#include "wordList.H"
|
||||
#include "className.H"
|
||||
#include <type_traits>
|
||||
|
||||
// Some common data types
|
||||
#include "label.H"
|
||||
#include "scalar.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -108,70 +112,12 @@ class SHA1Digest;
|
||||
Istream& operator>>(Istream& is, dictionary& dict);
|
||||
Ostream& operator<<(Ostream& os, const dictionary& dict);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class dictionaryName Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Holds name for a dictionary
|
||||
class dictionaryName
|
||||
{
|
||||
// Private data
|
||||
|
||||
fileName name_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
dictionaryName()
|
||||
{}
|
||||
|
||||
//- Construct as copy of the given fileName
|
||||
dictionaryName(const fileName& name)
|
||||
:
|
||||
name_(name)
|
||||
{}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return the dictionary name
|
||||
const fileName& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return the dictionary name for modification (use with caution).
|
||||
fileName& name()
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return the local dictionary name (final part of scoped name)
|
||||
word dictName() const
|
||||
{
|
||||
word scopedName(name_.name());
|
||||
|
||||
const auto i = scopedName.rfind('.');
|
||||
if (i == std::string::npos)
|
||||
{
|
||||
return scopedName;
|
||||
}
|
||||
|
||||
return scopedName.substr(i+1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class dictionary Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class dictionary
|
||||
:
|
||||
public dictionaryName,
|
||||
public IDLList<entry>
|
||||
{
|
||||
public:
|
||||
@ -246,7 +192,7 @@ public:
|
||||
{}
|
||||
|
||||
|
||||
//- Entry was found.
|
||||
//- True if entry was found
|
||||
inline bool found() const
|
||||
{
|
||||
return eptr_;
|
||||
@ -294,6 +240,18 @@ public:
|
||||
{
|
||||
return *reinterpret_cast<const Searcher<!Const>*>(this);
|
||||
}
|
||||
|
||||
//- A pointer to the entry (nullptr if not found)
|
||||
pointer operator->() const
|
||||
{
|
||||
return eptr_;
|
||||
}
|
||||
|
||||
//- A reference to the entry (Error if not found)
|
||||
reference operator*() const
|
||||
{
|
||||
return *eptr_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -322,6 +280,9 @@ private:
|
||||
// Set/unset via an InfoSwitch
|
||||
static bool writeOptionalEntries;
|
||||
|
||||
//- The dictionary name
|
||||
fileName name_;
|
||||
|
||||
//- Parent dictionary
|
||||
const dictionary& parent_;
|
||||
|
||||
@ -349,6 +310,21 @@ private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Convert old-style (1806) boolean search specification to enum
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param pattern match using regular expressions as well
|
||||
static inline enum keyType::option
|
||||
matchOpt(bool recursive, bool pattern)
|
||||
{
|
||||
return
|
||||
keyType::option
|
||||
(
|
||||
(pattern ? keyType::REGEX : keyType::LITERAL)
|
||||
| (recursive ? keyType::RECURSIVE : 0)
|
||||
);
|
||||
}
|
||||
|
||||
//- Search using a '.' for scoping.
|
||||
// A leading dot means to use the parent dictionary.
|
||||
// An intermediate dot separates a sub-dictionary or sub-entry.
|
||||
@ -359,13 +335,11 @@ private:
|
||||
// The heuristic tries successively longer top-level entries
|
||||
// until there is a suitable match.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the search mode
|
||||
const_searcher csearchDotScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const;
|
||||
|
||||
//- Search using a '/' for scoping.
|
||||
@ -375,11 +349,11 @@ private:
|
||||
// ambiguity between separator and content.
|
||||
// No possibility or need for recursion.
|
||||
//
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the search mode. Recursive is ignored.
|
||||
const_searcher csearchSlashScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const;
|
||||
|
||||
|
||||
@ -407,16 +381,17 @@ public:
|
||||
explicit dictionary(const fileName& name);
|
||||
|
||||
//- Construct given the entry name, parent dictionary and Istream,
|
||||
//- reading entries until EOF
|
||||
//- reading entries until EOF, optionally keeping the header
|
||||
dictionary
|
||||
(
|
||||
const fileName& name,
|
||||
const dictionary& parentDict,
|
||||
Istream& is
|
||||
Istream& is,
|
||||
bool keepHeader = false
|
||||
);
|
||||
|
||||
//- Construct top-level dictionary from Istream,
|
||||
//- reading entries until EOF
|
||||
//- reading entries until EOF. Discards the header.
|
||||
dictionary(Istream& is);
|
||||
|
||||
//- Construct top-level dictionary from Istream,
|
||||
@ -431,7 +406,7 @@ public:
|
||||
|
||||
//- Construct top-level dictionary as copy from pointer to dictionary.
|
||||
// A null pointer is treated like an empty dictionary.
|
||||
dictionary(const dictionary* dictPtr);
|
||||
dictionary(const dictionary* dict);
|
||||
|
||||
//- Move construct for given parent dictionary
|
||||
dictionary(const dictionary& parentDict, dictionary&& dict);
|
||||
@ -450,10 +425,36 @@ public:
|
||||
virtual ~dictionary();
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- The dictionary name
|
||||
const fileName& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- The dictionary name for modification (use with caution).
|
||||
fileName& name()
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- The local dictionary name (final part of scoped name)
|
||||
word dictName() const
|
||||
{
|
||||
word scopedName(name_.name());
|
||||
|
||||
const auto i = scopedName.rfind('.');
|
||||
if (i == std::string::npos)
|
||||
{
|
||||
return scopedName;
|
||||
}
|
||||
|
||||
return scopedName.substr(i+1);
|
||||
}
|
||||
|
||||
//- Return the parent dictionary
|
||||
const dictionary& parent() const
|
||||
{
|
||||
@ -478,131 +479,137 @@ public:
|
||||
|
||||
// Search and lookup
|
||||
|
||||
//- Search dictionary for given keyword.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- Search for an entry (const access) with the given keyword.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
//
|
||||
// \return True if entry was found
|
||||
bool found
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return an entry pointer if present, or return a nullptr.
|
||||
//- Find for an entry (non-const access) with the given keyword.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
const entry* lookupEntryPtr
|
||||
// \param matchOpt the search mode
|
||||
//
|
||||
// \return the entry pointer found or a nullptr.
|
||||
entry* findEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const;
|
||||
|
||||
//- Find and return an entry pointer for manipulation if present,
|
||||
//- or return a nullptr.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
entry* lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
);
|
||||
|
||||
//- Find and return an entry if present, otherwise FatalIOError.
|
||||
//- Find an entry (const access) with the given keyword.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
//
|
||||
// \return the entry pointer found or a nullptr.
|
||||
const entry* findEntry
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Search for a scoped entry (const access) with the given keyword.
|
||||
// Allows scoping using '.'.
|
||||
// Special handling for an absolute anchor (^) at start of the keyword
|
||||
// and for '..' to ascend into the parent dictionaries.
|
||||
//
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
//
|
||||
// \return the entry pointer found or a nullptr.
|
||||
const entry* findScoped
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
dictionary* findDict
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
);
|
||||
|
||||
//- Search for an entry (const access) with the given keyword.
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
const dictionary* findDict
|
||||
(
|
||||
const word& keyword,
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
//
|
||||
// \return return an entry if present, otherwise FatalIOError.
|
||||
const entry& lookupEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const;
|
||||
|
||||
//- Find and return a T.
|
||||
//- FatalIOError if not found, or if there are excess tokens.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- FatalIOError if not found, or if the number of tokens is incorrect.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
template<class T>
|
||||
T get
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return an entry data stream.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- FatalIOError if not found, or if the number of tokens is incorrect.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
ITstream& lookup
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return a T.
|
||||
//- FatalIOError if not found, or if there are excess tokens.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- Find and return a T, or return the given default value.
|
||||
//- FatalIOError if it is found and the number of tokens is incorrect.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
//
|
||||
// \deprecated - same as the get() method
|
||||
template<class T>
|
||||
T lookupType
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
) const;
|
||||
|
||||
//- Find and return a T, or return the given default value
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
// Default search: non-recursive with patterns.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
template<class T>
|
||||
T lookupOrDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return a T, or return the given default value
|
||||
//- and add it to dictionary.
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- FatalIOError if it is found and the number of tokens is incorrect.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
template<class T>
|
||||
T lookupOrAddDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
);
|
||||
|
||||
//- Find entry and assign to T val.
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
// Default search: non-recursive with patterns.
|
||||
//- FatalIOError if it is found and the number of tokens is incorrect,
|
||||
//- or it is mandatory and not found.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param val the value to read into
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
// \param mandatory the keyword is mandatory
|
||||
//
|
||||
// \return true if the entry was found.
|
||||
template<class T>
|
||||
@ -610,18 +617,16 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
T& val,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true,
|
||||
enum keyType::option matchOpt = keyType::REGEX,
|
||||
bool mandatory = true
|
||||
) const;
|
||||
|
||||
//- Find an entry if present, and assign to T val.
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
//- FatalIOError if it is found and the number of tokens is incorrect.
|
||||
// Default search: non-recursive with patterns.
|
||||
//
|
||||
// \param val the value to read
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
// \param val the value to read into
|
||||
// \param matchOpt the default search is non-recursive with patterns
|
||||
//
|
||||
// \return true if the entry was found.
|
||||
template<class T>
|
||||
@ -629,41 +634,14 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
T& val,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option matchOpt = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return an entry pointer if present, or return a nullptr.
|
||||
// Allows scoping using '.'.
|
||||
// Special handling for an absolute anchor (^) at start of the keyword
|
||||
// and for '..' to ascend into the parent dictionaries.
|
||||
//
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
const entry* lookupScopedEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const;
|
||||
|
||||
//- Check if entry exists and is a sub-dictionary.
|
||||
//- Check if entry is found and and is a sub-dictionary.
|
||||
//
|
||||
// Search type: non-recursive with patterns.
|
||||
bool isDict(const word& keyword) const;
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// Search type: non-recursive with patterns.
|
||||
const dictionary* subDictPtr(const word& keyword) const;
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// Search type: non-recursive with patterns.
|
||||
dictionary* subDictPtr(const word& keyword);
|
||||
|
||||
//- Find and return a sub-dictionary.
|
||||
// Fatal if the entry does not exist or is not a sub-dictionary.
|
||||
//
|
||||
@ -852,8 +830,7 @@ public:
|
||||
const_searcher csearch
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Search dictionary for given keyword
|
||||
@ -864,8 +841,7 @@ public:
|
||||
const_searcher search
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Search dictionary for given keyword
|
||||
@ -876,8 +852,7 @@ public:
|
||||
searcher search
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
);
|
||||
|
||||
//- Search using scoping.
|
||||
@ -906,8 +881,7 @@ public:
|
||||
const_searcher csearchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option
|
||||
) const;
|
||||
|
||||
//- Search using dot or slash scoping.
|
||||
@ -917,8 +891,7 @@ public:
|
||||
const_searcher searchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option
|
||||
) const;
|
||||
|
||||
//- Search using dot or slash scoping.
|
||||
@ -928,25 +901,24 @@ public:
|
||||
searcher searchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option
|
||||
);
|
||||
|
||||
//- Locate a sub-dictionary using slash-scoping
|
||||
// \return nullptr if the dictionary path does not exist
|
||||
const dictionary* cfindScopedDictPtr(const fileName& dictPath) const;
|
||||
const dictionary* cfindScopedDict(const fileName& dictPath) const;
|
||||
|
||||
//- Locate a sub-dictionary using slash-scoping
|
||||
// \return nullptr if the dictionary path does not exist
|
||||
const dictionary* findScopedDictPtr(const fileName& dictPath) const;
|
||||
const dictionary* findScopedDict(const fileName& dictPath) const;
|
||||
|
||||
//- Locate a sub-dictionary using slash-scoping
|
||||
// \return nullptr if the dictionary path does not exist
|
||||
dictionary* findScopedDictPtr(const fileName& dictPath);
|
||||
dictionary* findScopedDict(const fileName& dictPath);
|
||||
|
||||
//- Locate existing or create sub-dictionary using slash-scoping
|
||||
// \return nullptr if the dictionary path could not be created
|
||||
dictionary* makeScopedDictPtr(const fileName& dictPath);
|
||||
dictionary* makeScopedDict(const fileName& dictPath);
|
||||
|
||||
|
||||
// Compatibility helpers
|
||||
@ -965,8 +937,7 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Search dictionary for given keyword and any compatibility names
|
||||
@ -980,8 +951,7 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return an entry pointer if present, or return a nullptr,
|
||||
@ -991,12 +961,11 @@ public:
|
||||
// OpenFOAM version for which they were used.
|
||||
// \param recursive search parent dictionaries
|
||||
// \param patternMatch use regular expressions
|
||||
const entry* lookupEntryPtrCompat
|
||||
const entry* findCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option
|
||||
) const;
|
||||
|
||||
//- Find and return an entry if present, otherwise FatalIOError,
|
||||
@ -1010,8 +979,7 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option
|
||||
) const;
|
||||
|
||||
//- Find and return a T
|
||||
@ -1028,8 +996,7 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return an entry data stream,
|
||||
@ -1044,8 +1011,7 @@ public:
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find and return a T, or return the given default value
|
||||
@ -1062,8 +1028,7 @@ public:
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
const T& deflt,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
//- Find entry and assign to T val
|
||||
@ -1084,8 +1049,7 @@ public:
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
T& val,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true,
|
||||
enum keyType::option = keyType::REGEX,
|
||||
bool mandatory = true
|
||||
) const;
|
||||
|
||||
@ -1107,22 +1071,12 @@ public:
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
T& val,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
enum keyType::option = keyType::REGEX
|
||||
) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Find and return an entry data stream (identical to #lookup method).
|
||||
// Search: non-recursive with patterns.
|
||||
//
|
||||
// \deprecated use lookup() method instead (deprecated JUL-2018)
|
||||
ITstream& operator[](const word& keyword) const
|
||||
{
|
||||
return lookup(keyword);
|
||||
}
|
||||
|
||||
//- Copy assignment
|
||||
void operator=(const dictionary& rhs);
|
||||
|
||||
@ -1146,6 +1100,207 @@ public:
|
||||
|
||||
//- Write dictionary to Ostream
|
||||
friend Ostream& operator<<(Ostream& os, const dictionary& dict);
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Find and return an entry data stream (identical to #lookup method).
|
||||
//
|
||||
// \deprecated use lookup() method instead (JUL-2018)
|
||||
ITstream& operator[](const word& keyword) const
|
||||
{
|
||||
return lookup(keyword);
|
||||
}
|
||||
|
||||
//- Find and return a T.
|
||||
// \deprecated - same as the get() method (OCT-2018)
|
||||
template<class T>
|
||||
T lookupType
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive = false,
|
||||
bool patternMatch = true
|
||||
) const
|
||||
{
|
||||
return get<T>(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Search dictionary for given keyword.
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
bool found
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch = true
|
||||
) const
|
||||
{
|
||||
return found(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return an entry pointer for manipulation if present,
|
||||
//- or return a nullptr.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
entry* lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
)
|
||||
{
|
||||
return findEntry(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return an entry pointer if present, or return a nullptr.
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
const entry* lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return findEntry(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return an entry pointer if present, or return a nullptr.
|
||||
// Allows scoping using '.'.
|
||||
// Special handling for an absolute anchor (^) at start of the keyword
|
||||
// and for '..' to ascend into the parent dictionaries.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
const entry* lookupScopedEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return findScoped(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// Search type: non-recursive with patterns.
|
||||
const dictionary* subDictPtr(const word& keyword) const
|
||||
{
|
||||
return findDict(keyword, keyType::REGEX);
|
||||
}
|
||||
|
||||
//- Find and return a sub-dictionary pointer if present
|
||||
// (and a sub-dictionary) otherwise return nullptr.
|
||||
//
|
||||
// Search type: non-recursive with patterns.
|
||||
dictionary* subDictPtr(const word& keyword)
|
||||
{
|
||||
return findDict(keyword, keyType::REGEX);
|
||||
}
|
||||
|
||||
//- Find and return an entry if present, otherwise FatalIOError.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
const entry& lookupEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return lookupEntry(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return an entry data stream.
|
||||
// Default search: non-recursive with patterns.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
ITstream& lookup
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch = true
|
||||
) const
|
||||
{
|
||||
return lookup(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return a T, or return the given default value
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
template<class T>
|
||||
T lookupOrDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool patternMatch = true
|
||||
) const
|
||||
{
|
||||
return
|
||||
lookupOrDefault
|
||||
(keyword, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find and return a T, or return the given default value
|
||||
//- and add it to dictionary.
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
template<class T>
|
||||
T lookupOrAddDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool patternMatch = true
|
||||
)
|
||||
{
|
||||
return
|
||||
lookupOrAddDefault
|
||||
(keyword, deflt, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
//- Find an entry if present, and assign to T val.
|
||||
//- FatalIOError if it is found and there are excess tokens.
|
||||
//
|
||||
// \deprecated - use keyType::option version instead (OCT-2018)
|
||||
template<class T>
|
||||
bool readIfPresent
|
||||
(
|
||||
const word& keyword,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool patternMatch = true
|
||||
) const
|
||||
{
|
||||
return
|
||||
readIfPresent
|
||||
(keyword, val, matchOpt(recursive, patternMatch));
|
||||
}
|
||||
|
||||
|
||||
// Shortcuts - when a templated classes also inherits from a dictionary
|
||||
|
||||
#undef defineDictionaryGetter
|
||||
#define defineDictionaryGetter(Func, Type) \
|
||||
/** Same as get\<Type\> */ \
|
||||
Type Func \
|
||||
( \
|
||||
const word& keyword, \
|
||||
enum keyType::option matchOpt = keyType::REGEX \
|
||||
) const \
|
||||
{ \
|
||||
return get<Type>(keyword, matchOpt); \
|
||||
}
|
||||
|
||||
defineDictionaryGetter(getBool, bool);
|
||||
defineDictionaryGetter(getLabel, label);
|
||||
defineDictionaryGetter(getScalar, scalar);
|
||||
defineDictionaryGetter(getWord, word);
|
||||
defineDictionaryGetter(getFileName, fileName);
|
||||
|
||||
#undef defineDictionaryGetter
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -49,11 +49,10 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const_searcher finder(csearch(keyword, recursive, patternMatch));
|
||||
const_searcher finder(csearch(keyword, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -62,7 +61,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
|
||||
|
||||
for (const std::pair<const char*,int>& iter : compat)
|
||||
{
|
||||
finder = csearch(word::validate(iter.first), recursive, patternMatch);
|
||||
finder = csearch(word::validate(iter.first), matchOpt);
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -99,23 +98,21 @@ bool Foam::dictionary::foundCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearchCompat(keyword, compat, recursive, patternMatch).found();
|
||||
return csearchCompat(keyword, compat, matchOpt).found();
|
||||
}
|
||||
|
||||
|
||||
const Foam::entry* Foam::dictionary::lookupEntryPtrCompat
|
||||
const Foam::entry* Foam::dictionary::findCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearchCompat(keyword, compat, recursive, patternMatch).ptr();
|
||||
return csearchCompat(keyword, compat, matchOpt).ptr();
|
||||
}
|
||||
|
||||
|
||||
@ -123,12 +120,10 @@ const Foam::entry& Foam::dictionary::lookupEntryCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const const_searcher
|
||||
finder(csearchCompat(keyword, compat, recursive, patternMatch));
|
||||
const const_searcher finder(csearchCompat(keyword, compat, matchOpt));
|
||||
|
||||
if (!finder.found())
|
||||
{
|
||||
@ -146,12 +141,10 @@ Foam::ITstream& Foam::dictionary::lookupCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return
|
||||
lookupEntryCompat(keyword, compat, recursive, patternMatch).stream();
|
||||
return lookupEntryCompat(keyword, compat, matchOpt).stream();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -111,26 +111,26 @@ public:
|
||||
// Member functions
|
||||
|
||||
//- Return the scoped dictionary name (eg, dictA.dictB.dictC)
|
||||
const fileName& name() const
|
||||
virtual const fileName& name() const
|
||||
{
|
||||
return dictionary::name();
|
||||
}
|
||||
|
||||
//- Return the scoped dictionary name (eg, dictA.dictB.dictC)
|
||||
fileName& name()
|
||||
virtual fileName& name()
|
||||
{
|
||||
return dictionary::name();
|
||||
}
|
||||
|
||||
//- Return line number of first token in dictionary
|
||||
label startLineNumber() const;
|
||||
virtual label startLineNumber() const;
|
||||
|
||||
//- Return line number of last token in dictionary
|
||||
label endLineNumber() const;
|
||||
virtual label endLineNumber() const;
|
||||
|
||||
//- This entry is not a primitive,
|
||||
// calling this function generates a FatalError
|
||||
ITstream& stream() const;
|
||||
virtual ITstream& stream() const;
|
||||
|
||||
|
||||
//- Return pointer to this dictionary
|
||||
@ -140,14 +140,14 @@ public:
|
||||
virtual dictionary* dictPtr();
|
||||
|
||||
//- Return dictionary
|
||||
const dictionary& dict() const;
|
||||
virtual const dictionary& dict() const;
|
||||
|
||||
//- Return non-const access to dictionary
|
||||
dictionary& dict();
|
||||
virtual dictionary& dict();
|
||||
|
||||
|
||||
//- Write
|
||||
void write(Ostream& os) const;
|
||||
virtual void write(Ostream& os) const;
|
||||
|
||||
//- Return info proxy.
|
||||
// Used to print token information to a stream
|
||||
|
||||
@ -33,31 +33,26 @@ Foam::dictionary::dictionary
|
||||
(
|
||||
const fileName& name,
|
||||
const dictionary& parentDict,
|
||||
Istream& is
|
||||
Istream& is,
|
||||
bool keepHeader
|
||||
)
|
||||
:
|
||||
dictionaryName(parentDict.name() + '.' + name),
|
||||
name_(parentDict.name() + '.' + name),
|
||||
parent_(parentDict)
|
||||
{
|
||||
read(is);
|
||||
read(is, keepHeader);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary::dictionary(Istream& is)
|
||||
:
|
||||
dictionaryName(is.name()),
|
||||
parent_(dictionary::null)
|
||||
{
|
||||
// Reset input mode as this is a "top-level" dictionary
|
||||
entry::resetInputMode();
|
||||
|
||||
read(is);
|
||||
}
|
||||
dictionary(is, false)
|
||||
{}
|
||||
|
||||
|
||||
Foam::dictionary::dictionary(Istream& is, bool keepHeader)
|
||||
:
|
||||
dictionaryName(is.name()),
|
||||
name_(is.name()),
|
||||
parent_(dictionary::null)
|
||||
{
|
||||
// Reset input mode as this is a "top-level" dictionary
|
||||
@ -174,10 +169,8 @@ void Foam::dictionary::writeEntry(const keyType& kw, Ostream& os) const
|
||||
|
||||
void Foam::dictionary::writeEntries(Ostream& os, const bool extraNewLine) const
|
||||
{
|
||||
forAllConstIter(parent_type, *this, iter)
|
||||
for (const entry& e : *this)
|
||||
{
|
||||
const entry& e = *iter;
|
||||
|
||||
// Write entry
|
||||
os << e;
|
||||
|
||||
@ -192,7 +185,7 @@ void Foam::dictionary::writeEntries(Ostream& os, const bool extraNewLine) const
|
||||
if (!os.good())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Can't write entry " << iter().keyword()
|
||||
<< "Can't write entry " << e.keyword()
|
||||
<< " for dictionary " << name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -69,8 +69,7 @@ namespace
|
||||
Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
auto scopePos = keyword.find('.');
|
||||
@ -78,9 +77,12 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
if (scopePos == string::npos)
|
||||
{
|
||||
// Normal, non-scoped search
|
||||
return csearch(keyword, recursive, patternMatch);
|
||||
return csearch(keyword, matchOpt);
|
||||
}
|
||||
|
||||
// It is '.' scoped - force non-recusive searching
|
||||
matchOpt = keyType::option(matchOpt & ~(keyType::RECURSIVE));
|
||||
|
||||
if (scopePos == 0)
|
||||
{
|
||||
// Starting with a '.' -> go up for every further '.' found
|
||||
@ -113,8 +115,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
return dictPtr->csearchDotScoped
|
||||
(
|
||||
keyword.substr(scopePos),
|
||||
false,
|
||||
patternMatch
|
||||
matchOpt
|
||||
);
|
||||
}
|
||||
|
||||
@ -122,8 +123,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
const_searcher finder = csearchDotScoped
|
||||
(
|
||||
keyword.substr(0, scopePos),
|
||||
false,
|
||||
patternMatch
|
||||
matchOpt
|
||||
);
|
||||
|
||||
// Fall back to finding key with '.' so e.g. if keyword is
|
||||
@ -137,7 +137,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
scopePos = keyword.find('.', scopePos+1);
|
||||
|
||||
// Local entry:
|
||||
finder = csearch(keyword.substr(0, scopePos), false, patternMatch);
|
||||
finder = csearch(keyword.substr(0, scopePos), matchOpt);
|
||||
|
||||
if (scopePos == string::npos)
|
||||
{
|
||||
@ -152,8 +152,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
return finder.dict().csearchDotScoped
|
||||
(
|
||||
keyword.substr(scopePos),
|
||||
false,
|
||||
patternMatch
|
||||
matchOpt
|
||||
);
|
||||
}
|
||||
|
||||
@ -164,9 +163,13 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchDotScoped
|
||||
Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
|
||||
// With '/' scoping - recursive is never allowed
|
||||
matchOpt = keyType::option(matchOpt & ~(keyType::RECURSIVE));
|
||||
|
||||
const dictionary* dictPtr = this;
|
||||
|
||||
const auto slash = keyword.find('/');
|
||||
@ -175,7 +178,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
|
||||
{
|
||||
// No slashes:
|
||||
// Can use normal (non-scoped) search at the current dictionary level
|
||||
return csearch(keyword, false, patternMatch);
|
||||
return csearch(keyword, matchOpt);
|
||||
}
|
||||
else if (slash == 0)
|
||||
{
|
||||
@ -220,7 +223,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
|
||||
// Find entry
|
||||
const word key = word::validate(cmpt);
|
||||
|
||||
auto finder = dictPtr->csearch(key, false, patternMatch);
|
||||
auto finder = dictPtr->csearch(key, matchOpt);
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -259,8 +262,7 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchSlashScoped
|
||||
Foam::dictionary::const_searcher Foam::dictionary::csearch
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const_searcher finder(this);
|
||||
@ -273,27 +275,22 @@ Foam::dictionary::const_searcher Foam::dictionary::csearch
|
||||
return finder;
|
||||
}
|
||||
|
||||
if (patternMatch && patterns_.size())
|
||||
if ((matchOpt & keyType::REGEX) && patterns_.size())
|
||||
{
|
||||
pattern_const_iterator wcLink = patterns_.begin();
|
||||
regexp_const_iterator reLink = regexps_.begin();
|
||||
|
||||
// Find in patterns using regular expressions only
|
||||
if (findInPatterns(patternMatch, keyword, wcLink, reLink))
|
||||
if (findInPatterns(true, keyword, wcLink, reLink))
|
||||
{
|
||||
finder.set(*wcLink);
|
||||
return finder;
|
||||
}
|
||||
}
|
||||
|
||||
if (recursive && &parent_ != &dictionary::null)
|
||||
if ((matchOpt & keyType::RECURSIVE) && &parent_ != &dictionary::null)
|
||||
{
|
||||
return parent_.csearch
|
||||
(
|
||||
keyword,
|
||||
recursive,
|
||||
patternMatch
|
||||
);
|
||||
return parent_.csearch(keyword, matchOpt);
|
||||
}
|
||||
|
||||
return finder;
|
||||
@ -303,22 +300,20 @@ Foam::dictionary::const_searcher Foam::dictionary::csearch
|
||||
Foam::dictionary::const_searcher Foam::dictionary::search
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearch(keyword, recursive, patternMatch);
|
||||
return csearch(keyword, matchOpt);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary::searcher Foam::dictionary::search
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
)
|
||||
{
|
||||
const_searcher finder = csearch(keyword, recursive, patternMatch);
|
||||
const_searcher finder = csearch(keyword, matchOpt);
|
||||
|
||||
return static_cast<const searcher&>(finder);
|
||||
}
|
||||
@ -327,17 +322,19 @@ Foam::dictionary::searcher Foam::dictionary::search
|
||||
Foam::dictionary::const_searcher Foam::dictionary::csearchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
if (keyword.find('/') != string::npos)
|
||||
{
|
||||
return csearchSlashScoped(keyword, patternMatch);
|
||||
return csearchSlashScoped(keyword, matchOpt);
|
||||
}
|
||||
|
||||
if (keyword[0] == ':' || keyword[0] == '^')
|
||||
{
|
||||
// It is ':' scoped - force non-recusive searching
|
||||
matchOpt = keyType::option(matchOpt & ~(keyType::RECURSIVE));
|
||||
|
||||
// Ascend to top-level
|
||||
const dictionary* dictPtr = this;
|
||||
while (&dictPtr->parent_ != &dictionary::null)
|
||||
@ -345,43 +342,36 @@ Foam::dictionary::const_searcher Foam::dictionary::csearchScoped
|
||||
dictPtr = &dictPtr->parent_;
|
||||
}
|
||||
|
||||
return dictPtr->csearchDotScoped
|
||||
(
|
||||
keyword.substr(1),
|
||||
false,
|
||||
patternMatch
|
||||
);
|
||||
return dictPtr->csearchDotScoped(keyword.substr(1), matchOpt);
|
||||
}
|
||||
|
||||
return csearchDotScoped(keyword, recursive, patternMatch);
|
||||
return csearchDotScoped(keyword, matchOpt);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary::const_searcher Foam::dictionary::searchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
return csearchScoped(keyword, recursive, patternMatch);
|
||||
return csearchScoped(keyword, matchOpt);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary::searcher Foam::dictionary::searchScoped
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
)
|
||||
{
|
||||
const_searcher finder = csearchScoped(keyword, recursive, patternMatch);
|
||||
const_searcher finder = csearchScoped(keyword, matchOpt);
|
||||
|
||||
return static_cast<const searcher&>(finder);
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary* Foam::dictionary::cfindScopedDictPtr
|
||||
const Foam::dictionary* Foam::dictionary::cfindScopedDict
|
||||
(
|
||||
const fileName& dictPath
|
||||
) const
|
||||
@ -466,26 +456,26 @@ const Foam::dictionary* Foam::dictionary::cfindScopedDictPtr
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary* Foam::dictionary::findScopedDictPtr
|
||||
const Foam::dictionary* Foam::dictionary::findScopedDict
|
||||
(
|
||||
const fileName& dictPath
|
||||
) const
|
||||
{
|
||||
return cfindScopedDictPtr(dictPath);
|
||||
return cfindScopedDict(dictPath);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary* Foam::dictionary::findScopedDictPtr
|
||||
Foam::dictionary* Foam::dictionary::findScopedDict
|
||||
(
|
||||
const fileName& dictPath
|
||||
)
|
||||
{
|
||||
const dictionary* ptr = cfindScopedDictPtr(dictPath);
|
||||
const dictionary* ptr = cfindScopedDict(dictPath);
|
||||
return const_cast<dictionary*>(ptr);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath)
|
||||
Foam::dictionary* Foam::dictionary::makeScopedDict(const fileName& dictPath)
|
||||
{
|
||||
// Or warning
|
||||
if (dictPath.empty())
|
||||
@ -536,7 +526,8 @@ Foam::dictionary* Foam::dictionary::makeScopedDictPtr(const fileName& dictPath)
|
||||
else
|
||||
{
|
||||
// Non-recursive, no patternMatch
|
||||
// -> can do direct lookup, without csearch(cmptName, false, false);
|
||||
// -> can do direct lookup,
|
||||
// without csearch(cmptName, keyType::LITERAL);
|
||||
const word cmptName(cmpt.str(), false);
|
||||
|
||||
auto iter = dictPtr->hashedEntries_.find(cmptName);
|
||||
|
||||
@ -53,12 +53,11 @@ template<class T>
|
||||
T Foam::dictionary::get
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
T val;
|
||||
readEntry<T>(keyword, val, recursive, patternMatch);
|
||||
readEntry<T>(keyword, val, matchOpt);
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -68,12 +67,11 @@ T Foam::dictionary::getCompat
|
||||
(
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
T val;
|
||||
readCompat<T>(keyword, compat, val, recursive, patternMatch);
|
||||
readCompat<T>(keyword, compat, val, matchOpt);
|
||||
return val;
|
||||
}
|
||||
|
||||
@ -84,13 +82,11 @@ bool Foam::dictionary::readCompat
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool patternMatch,
|
||||
enum keyType::option matchOpt,
|
||||
bool mandatory
|
||||
) const
|
||||
{
|
||||
const const_searcher
|
||||
finder(csearchCompat(keyword, compat, recursive, patternMatch));
|
||||
const const_searcher finder(csearchCompat(keyword, compat, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -113,29 +109,15 @@ bool Foam::dictionary::readCompat
|
||||
}
|
||||
|
||||
|
||||
// older name
|
||||
template<class T>
|
||||
T Foam::dictionary::lookupType
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
) const
|
||||
{
|
||||
return get<T>(keyword, recursive, patternMatch);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
T Foam::dictionary::lookupOrDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const const_searcher finder(csearch(keyword, recursive, patternMatch));
|
||||
const const_searcher finder(csearch(keyword, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -165,11 +147,10 @@ T Foam::dictionary::lookupOrAddDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
)
|
||||
{
|
||||
const const_searcher finder(csearch(keyword, recursive, patternMatch));
|
||||
const const_searcher finder(csearch(keyword, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -200,12 +181,11 @@ bool Foam::dictionary::readEntry
|
||||
(
|
||||
const word& keyword,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool patternMatch,
|
||||
enum keyType::option matchOpt,
|
||||
bool mandatory
|
||||
) const
|
||||
{
|
||||
const const_searcher finder(csearch(keyword, recursive, patternMatch));
|
||||
const const_searcher finder(csearch(keyword, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -233,12 +213,11 @@ bool Foam::dictionary::readIfPresent
|
||||
(
|
||||
const word& keyword,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
// Read is non-mandatory
|
||||
return readEntry<T>(keyword, val, recursive, patternMatch, false);
|
||||
return readEntry<T>(keyword, val, matchOpt, false);
|
||||
}
|
||||
|
||||
|
||||
@ -248,12 +227,10 @@ T Foam::dictionary::lookupOrDefaultCompat
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
const T& deflt,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
const const_searcher
|
||||
finder(csearchCompat(keyword, compat, recursive, patternMatch));
|
||||
const const_searcher finder(csearchCompat(keyword, compat, matchOpt));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -284,12 +261,11 @@ bool Foam::dictionary::readIfPresentCompat
|
||||
const word& keyword,
|
||||
std::initializer_list<std::pair<const char*,int>> compat,
|
||||
T& val,
|
||||
bool recursive,
|
||||
bool patternMatch
|
||||
enum keyType::option matchOpt
|
||||
) const
|
||||
{
|
||||
// Read is non-mandatory
|
||||
return readCompat<T>(keyword, compat, val, recursive, patternMatch, false);
|
||||
return readCompat<T>(keyword, compat, val, matchOpt, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
#include "entry.H"
|
||||
#include "dictionary.H"
|
||||
#include "StringStream.H"
|
||||
#include "JobInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -46,6 +47,88 @@ void Foam::entry::resetInputMode()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::entry::checkITstream(const ITstream& is) const
|
||||
{
|
||||
const word& keyword = keyword_;
|
||||
|
||||
if (is.nRemainingTokens())
|
||||
{
|
||||
const label remaining = is.nRemainingTokens();
|
||||
|
||||
// Similar to SafeFatalIOError
|
||||
if (JobInfo::constructed)
|
||||
{
|
||||
OSstream& err =
|
||||
FatalIOError
|
||||
(
|
||||
"", // functionName
|
||||
"", // sourceFileName
|
||||
0, // sourceFileLineNumber
|
||||
this->name(), // ioFileName
|
||||
is.lineNumber() // ioStartLineNumber
|
||||
);
|
||||
|
||||
err << "'" << keyword << "' has "
|
||||
<< remaining << " excess tokens in stream" << nl << nl
|
||||
<< " ";
|
||||
is.writeList(err, 0);
|
||||
|
||||
err << exit(FatalIOError);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr
|
||||
<< nl
|
||||
<< "--> FOAM FATAL IO ERROR:" << nl;
|
||||
|
||||
std::cerr
|
||||
<< "'" << keyword << "' has "
|
||||
<< remaining << " excess tokens in stream" << nl << nl;
|
||||
|
||||
std::cerr
|
||||
<< "file: " << this->name()
|
||||
<< " at line " << is.lineNumber() << '.' << nl
|
||||
<< std::endl;
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
}
|
||||
else if (!is.size())
|
||||
{
|
||||
// Similar to SafeFatalIOError
|
||||
if (JobInfo::constructed)
|
||||
{
|
||||
FatalIOError
|
||||
(
|
||||
"", // functionName
|
||||
"", // sourceFileName
|
||||
0, // sourceFileLineNumber
|
||||
this->name(), // ioFileName
|
||||
is.lineNumber() // ioStartLineNumber
|
||||
)
|
||||
<< "'" << keyword << "' had no tokens in stream" << nl << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr
|
||||
<< nl
|
||||
<< "--> FOAM FATAL IO ERROR:" << nl
|
||||
<< "'" << keyword << "' had no tokens in stream" << nl << nl;
|
||||
|
||||
std::cerr
|
||||
<< "file: " << this->name()
|
||||
<< " at line " << is.lineNumber() << '.' << nl
|
||||
<< std::endl;
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::entry::entry(const keyType& keyword)
|
||||
|
||||
@ -107,6 +107,11 @@ private:
|
||||
// \return True if it is a valid keyType.
|
||||
static bool getKeyword(keyType& keyword, Istream& is);
|
||||
|
||||
//- Check after reading if the input token stream has unconsumed
|
||||
//- tokens remaining or if there were no tokens in the first place.
|
||||
// Emits FatalIOError
|
||||
void checkITstream(const ITstream& is) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -176,7 +181,7 @@ public:
|
||||
virtual ~entry() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- Return keyword
|
||||
const keyType& keyword() const
|
||||
@ -244,7 +249,31 @@ public:
|
||||
virtual void write(Ostream& os) const = 0;
|
||||
|
||||
|
||||
// Member operators
|
||||
//- Get a T from the stream,
|
||||
//- FatalIOError if the number of tokens is incorrect.
|
||||
template<class T>
|
||||
T get() const
|
||||
{
|
||||
T val;
|
||||
readEntry<T>(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
//- Assign to T val,
|
||||
//- FatalIOError if the number of tokens is incorrect.
|
||||
//
|
||||
// \param val the value to read into
|
||||
template<class T>
|
||||
void readEntry(T& val) const
|
||||
{
|
||||
ITstream& is = this->stream();
|
||||
is >> val;
|
||||
|
||||
checkITstream(is);
|
||||
}
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
void operator=(const entry& e);
|
||||
|
||||
@ -252,7 +281,7 @@ public:
|
||||
bool operator!=(const entry& e) const;
|
||||
|
||||
|
||||
// Ostream operator
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const entry& e);
|
||||
};
|
||||
|
||||
@ -241,7 +241,8 @@ bool Foam::entry::New
|
||||
const word varName = keyword.substr(1);
|
||||
|
||||
// Lookup the variable name in the given dictionary
|
||||
const auto finder = parentDict.csearchScoped(varName, true, true);
|
||||
const auto finder =
|
||||
parentDict.csearchScoped(varName, keyType::REGEX_RECURSIVE);
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
@ -301,8 +302,8 @@ bool Foam::entry::New
|
||||
auto finder =
|
||||
(
|
||||
scoped
|
||||
? parentDict.searchScoped(keyword, false, false)
|
||||
: parentDict.search(keyword, false, false)
|
||||
? parentDict.searchScoped(keyword, keyType::LITERAL)
|
||||
: parentDict.search(keyword, keyType::LITERAL)
|
||||
);
|
||||
|
||||
// How to manage duplicate entries
|
||||
@ -387,10 +388,7 @@ bool Foam::entry::New
|
||||
// Get or create the dictionary-path.
|
||||
// fileName::path == dictionary-path
|
||||
dictionary* subDictPtr =
|
||||
parentDict.makeScopedDictPtr
|
||||
(
|
||||
fileName::path(fullPath)
|
||||
);
|
||||
parentDict.makeScopedDict(fileName::path(fullPath));
|
||||
|
||||
if (subDictPtr)
|
||||
{
|
||||
|
||||
@ -61,8 +61,7 @@ bool Foam::functionEntries::removeEntry::execute
|
||||
if (key.isLiteral() && key.find('/') != string::npos)
|
||||
{
|
||||
// Remove scoped keyword, or keyword in the local scope
|
||||
dictionary::searcher finder =
|
||||
parentDict.searchScoped(key, false, false);
|
||||
auto finder(parentDict.searchScoped(key, keyType::LITERAL));
|
||||
|
||||
if (finder.found())
|
||||
{
|
||||
|
||||
@ -78,7 +78,8 @@ bool Foam::primitiveEntry::expandVariable
|
||||
// The $internalField would be matched by the ".*" !!!
|
||||
|
||||
// Recursive, non-patterns
|
||||
const entry* eptr = dict.lookupScopedEntryPtr(varName, true, false);
|
||||
const entry* eptr = dict.findScoped(varName, keyType::LITERAL_RECURSIVE);
|
||||
|
||||
if (!eptr)
|
||||
{
|
||||
// Not found - revert to environment variable
|
||||
|
||||
@ -138,51 +138,51 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- Inherit read from ITstream
|
||||
using ITstream::read;
|
||||
|
||||
//- Return the dictionary name
|
||||
const fileName& name() const
|
||||
virtual const fileName& name() const
|
||||
{
|
||||
return ITstream::name();
|
||||
}
|
||||
|
||||
//- Return the dictionary name
|
||||
fileName& name()
|
||||
virtual fileName& name()
|
||||
{
|
||||
return ITstream::name();
|
||||
}
|
||||
|
||||
//- Return line number of first token in dictionary
|
||||
label startLineNumber() const;
|
||||
virtual label startLineNumber() const;
|
||||
|
||||
//- Return line number of last token in dictionary
|
||||
label endLineNumber() const;
|
||||
virtual label endLineNumber() const;
|
||||
|
||||
//- Return true because this entry is a stream
|
||||
bool isStream() const
|
||||
//- Return true - this entry is a stream
|
||||
virtual bool isStream() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//- Return token stream for this primitive entry
|
||||
ITstream& stream() const;
|
||||
virtual ITstream& stream() const;
|
||||
|
||||
//- This entry is not a dictionary,
|
||||
// calling this function generates a FatalError
|
||||
const dictionary& dict() const;
|
||||
virtual const dictionary& dict() const;
|
||||
|
||||
//- This entry is not a dictionary,
|
||||
// calling this function generates a FatalError
|
||||
dictionary& dict();
|
||||
virtual dictionary& dict();
|
||||
|
||||
//- Read tokens from the given stream
|
||||
virtual bool read(const dictionary& dict, Istream& is);
|
||||
|
||||
//- Write
|
||||
void write(Ostream& os) const;
|
||||
virtual void write(Ostream& os) const;
|
||||
|
||||
//- Write, optionally with contents only (no keyword, etc)
|
||||
void write(Ostream& os, const bool contentsOnly) const;
|
||||
|
||||
@ -55,14 +55,14 @@ static inline void writeEntryIfPresent
|
||||
)
|
||||
{
|
||||
// non-recursive like dictionary::found, but no pattern-match either
|
||||
const entry* ptr = dict.lookupEntryPtr(key, false, false);
|
||||
const entry* eptr = dict.findEntry(key, keyType::LITERAL);
|
||||
|
||||
if (ptr)
|
||||
if (eptr)
|
||||
{
|
||||
os.writeKeyword(key)
|
||||
<< token::HASH << token::BEGIN_BLOCK;
|
||||
|
||||
os.writeQuoted(string(ptr->stream()), false)
|
||||
os.writeQuoted(string(eptr->stream()), false)
|
||||
<< token::HASH << token::END_BLOCK
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ bool Foam::dynamicCode::writeDigest(const std::string& sha1) const
|
||||
|
||||
Foam::dynamicCode::dynamicCode(const word& codeName, const word& codeDirName)
|
||||
:
|
||||
codeRoot_(stringOps::expand("$FOAM_CASE")/topDirName),
|
||||
codeRoot_(stringOps::expand("<case>")/topDirName),
|
||||
libSubDir_(stringOps::expand("platforms/$WM_OPTIONS/lib")),
|
||||
codeName_(codeName),
|
||||
codeDirName_(codeDirName)
|
||||
|
||||
@ -197,7 +197,7 @@ public:
|
||||
}
|
||||
|
||||
//- Root for dynamic code compilation
|
||||
// Expanded from \$FOAM_CASE/dynamicCode
|
||||
// Expanded from \<case\>/dynamicCode
|
||||
const fileName& codeRoot() const
|
||||
{
|
||||
return codeRoot_;
|
||||
@ -228,12 +228,12 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
//- Path for specified code name relative to \$FOAM_CASE
|
||||
//- Path for specified code name relative to \<case\>
|
||||
// Corresponds to topDirName/codeDirName()
|
||||
fileName codeRelPath() const;
|
||||
|
||||
|
||||
//- Library path for specified code name relative to \$FOAM_CASE
|
||||
//- Library path for specified code name relative to \<case\>
|
||||
// Corresponds to
|
||||
// dynamicCode/codeDirName()/libSubDir()/lib\<codeName\>.so
|
||||
fileName libRelPath() const;
|
||||
|
||||
@ -44,53 +44,48 @@ Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
|
||||
// - necessary for compilation options, convenient for includes
|
||||
// and body.
|
||||
|
||||
const entry* codePtr = dict.lookupEntryPtr
|
||||
(
|
||||
"code",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* codePtr = dict.findEntry("code", keyType::LITERAL);
|
||||
|
||||
if (codePtr)
|
||||
{
|
||||
code_ = stringOps::trim(codePtr->stream());
|
||||
codePtr->readEntry(code_);
|
||||
stringOps::inplaceTrim(code_);
|
||||
stringOps::inplaceExpand(code_, dict);
|
||||
}
|
||||
|
||||
const entry* includePtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeInclude",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* includePtr = dict.findEntry("codeInclude", keyType::LITERAL);
|
||||
|
||||
if (includePtr)
|
||||
{
|
||||
include_ = stringOps::trim(includePtr->stream());
|
||||
includePtr->readEntry(include_);
|
||||
stringOps::inplaceTrim(include_);
|
||||
stringOps::inplaceExpand(include_, dict);
|
||||
}
|
||||
|
||||
const entry* optionsPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeOptions",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* optionsPtr = dict.findEntry("codeOptions", keyType::LITERAL);
|
||||
|
||||
if (optionsPtr)
|
||||
{
|
||||
options_ = stringOps::trim(optionsPtr->stream());
|
||||
optionsPtr->readEntry(options_);
|
||||
stringOps::inplaceTrim(options_);
|
||||
stringOps::inplaceExpand(options_, dict);
|
||||
}
|
||||
|
||||
const entry* libsPtr = dict.lookupEntryPtr("codeLibs", false, false);
|
||||
const entry* libsPtr = dict.findEntry("codeLibs", keyType::LITERAL);
|
||||
|
||||
if (libsPtr)
|
||||
{
|
||||
libs_ = stringOps::trim(libsPtr->stream());
|
||||
libsPtr->readEntry(libs_);
|
||||
stringOps::inplaceTrim(libs_);
|
||||
stringOps::inplaceExpand(libs_, dict);
|
||||
}
|
||||
|
||||
const entry* localPtr = dict.lookupEntryPtr("localCode", false, false);
|
||||
const entry* localPtr = dict.findEntry("localCode", keyType::LITERAL);
|
||||
|
||||
if (localPtr)
|
||||
{
|
||||
localCode_ = stringOps::trim(localPtr->stream());
|
||||
localPtr->readEntry(localCode_);
|
||||
stringOps::inplaceTrim(localCode_);
|
||||
stringOps::inplaceExpand(localCode_, dict);
|
||||
}
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ class dynamicCodeContext
|
||||
//- Optional "codeOptions" entry
|
||||
string options_;
|
||||
|
||||
//- Optional "codeLib" entry
|
||||
//- Optional "codeLibs" entry
|
||||
string libs_;
|
||||
|
||||
//- Calculated SHA1Digest
|
||||
|
||||
@ -140,7 +140,7 @@ bool Foam::functionObject::read(const dictionary& dict)
|
||||
{
|
||||
if (!postProcess)
|
||||
{
|
||||
log = dict.lookupOrDefault<Switch>("log", true);
|
||||
log = dict.lookupOrDefault("log", true);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -34,8 +34,8 @@ Description
|
||||
|
||||
\section secFunctionObjects Using function objects
|
||||
|
||||
FunctionObjects are selected by additional entries in the
|
||||
$FOAM_CASE/system/controlDict dictionary. Each object is listed in the \c
|
||||
FunctionObjects are selected by additional entries in the global case
|
||||
system/controlDict dictionary. Each object is listed in the \c
|
||||
functions sub-dictionary, e.g. to select the \c functionObjectType
|
||||
functionObject the following entry would be specified:
|
||||
|
||||
@ -59,7 +59,7 @@ Description
|
||||
|
||||
Where:
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
Property | Description | Required | Default
|
||||
type | Type of function object | yes |
|
||||
libs | Libraries containing implementation | yes |
|
||||
region | Name of region for multi-region cases | no |
|
||||
@ -120,7 +120,6 @@ SourceFiles
|
||||
|
||||
#include "typeInfo.H"
|
||||
#include "autoPtr.H"
|
||||
#include "Switch.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -176,7 +175,7 @@ public:
|
||||
static word outputPrefix;
|
||||
|
||||
//- Switch write log to Info
|
||||
Switch log;
|
||||
bool log;
|
||||
|
||||
|
||||
// Declare run-time constructor selection tables
|
||||
|
||||
@ -98,64 +98,54 @@ Foam::functionObject* Foam::functionObjectList::remove
|
||||
void Foam::functionObjectList::listDir
|
||||
(
|
||||
const fileName& dir,
|
||||
wordHashSet& foMap
|
||||
wordHashSet& available
|
||||
)
|
||||
{
|
||||
// Search specified directory for functionObject configuration files
|
||||
for (const fileName& f : fileHandler().readDir(dir))
|
||||
{
|
||||
fileNameList foFiles(fileHandler().readDir(dir));
|
||||
for (const fileName& f : foFiles)
|
||||
if (f.ext().empty())
|
||||
{
|
||||
if (f.ext().empty())
|
||||
{
|
||||
foMap.insert(f);
|
||||
}
|
||||
available.insert(f);
|
||||
}
|
||||
}
|
||||
|
||||
// Recurse into sub-directories
|
||||
for (const fileName& d : fileHandler().readDir(dir, fileName::DIRECTORY))
|
||||
{
|
||||
fileNameList foDirs(fileHandler().readDir(dir, fileName::DIRECTORY));
|
||||
for (const fileName& d : foDirs)
|
||||
{
|
||||
listDir(dir/d, foMap);
|
||||
}
|
||||
listDir(dir/d, available);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::list()
|
||||
{
|
||||
wordHashSet foMap;
|
||||
wordHashSet available;
|
||||
|
||||
fileNameList etcDirs(findEtcDirs(functionObjectDictPath));
|
||||
|
||||
for (const fileName& d : etcDirs)
|
||||
for (const fileName& d : findEtcDirs(functionObjectDictPath))
|
||||
{
|
||||
listDir(d, foMap);
|
||||
listDir(d, available);
|
||||
}
|
||||
|
||||
Info<< nl
|
||||
<< "Available configured functionObjects:"
|
||||
<< foMap.sortedToc()
|
||||
<< available.sortedToc()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::functionObjectList::findDict(const word& funcName)
|
||||
{
|
||||
// First check if there is a functionObject dictionary file in the
|
||||
// case system directory
|
||||
fileName dictFile = stringOps::expand("$FOAM_CASE")/"system"/funcName;
|
||||
// First check for functionObject dictionary file in globalCase system/
|
||||
|
||||
fileName dictFile = stringOps::expand("<system>")/funcName;
|
||||
|
||||
if (isFile(dictFile))
|
||||
{
|
||||
return dictFile;
|
||||
}
|
||||
|
||||
fileNameList etcDirs(findEtcDirs(functionObjectDictPath));
|
||||
|
||||
for (const fileName& d : etcDirs)
|
||||
for (const fileName& d : findEtcDirs(functionObjectDictPath))
|
||||
{
|
||||
dictFile = search(funcName, d);
|
||||
if (!dictFile.empty())
|
||||
@ -706,12 +696,8 @@ bool Foam::functionObjectList::read()
|
||||
}
|
||||
|
||||
// Update existing and add new functionObjects
|
||||
const entry* entryPtr = parentDict_.lookupEntryPtr
|
||||
(
|
||||
"functions",
|
||||
false,
|
||||
false
|
||||
);
|
||||
const entry* entryPtr =
|
||||
parentDict_.findEntry("functions", keyType::LITERAL);
|
||||
|
||||
if (entryPtr)
|
||||
{
|
||||
|
||||
@ -102,7 +102,7 @@ class functionObjectList
|
||||
|
||||
//- Search the specified directory for functionObject
|
||||
//- configuration files, add to the given map and recurse
|
||||
static void listDir(const fileName& dir, wordHashSet& foMap);
|
||||
static void listDir(const fileName& dir, wordHashSet& available);
|
||||
|
||||
//- No copy construct
|
||||
functionObjectList(const functionObjectList&) = delete;
|
||||
|
||||
@ -52,10 +52,8 @@ Foam::functionObjects::regionFunctionObject::whichSubRegistry
|
||||
{
|
||||
return obr.lookupObject<objectRegistry>(subName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return obr;
|
||||
}
|
||||
|
||||
return obr;
|
||||
}
|
||||
|
||||
|
||||
@ -71,22 +69,19 @@ bool Foam::functionObjects::regionFunctionObject::writeObject
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
const regIOobject* objPtr =
|
||||
this->lookupObjectPtr<regIOobject>(fieldName);
|
||||
const regIOobject* obj = this->findObject<regIOobject>(fieldName);
|
||||
|
||||
if (objPtr)
|
||||
if (obj)
|
||||
{
|
||||
Log << " functionObjects::" << type() << " " << name()
|
||||
<< " writing field: " << objPtr->name() << endl;
|
||||
<< " writing field: " << obj->name() << endl;
|
||||
|
||||
objPtr->write();
|
||||
obj->write();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -95,12 +90,14 @@ bool Foam::functionObjects::regionFunctionObject::clearObject
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
regIOobject* objPtr = lookupObjectRefPtr<regIOobject>(fieldName);
|
||||
if (objPtr)
|
||||
// Same as getObjectPtr, since the object is already non-const
|
||||
regIOobject* obj = this->findObject<regIOobject>(fieldName);
|
||||
|
||||
if (obj)
|
||||
{
|
||||
if (objPtr->ownedByRegistry())
|
||||
if (obj->ownedByRegistry())
|
||||
{
|
||||
return objPtr->checkOut();
|
||||
return obj->checkOut();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -94,6 +94,35 @@ protected:
|
||||
template<class ObjectType>
|
||||
bool foundObject(const word& fieldName) const;
|
||||
|
||||
//- Return const pointer to the object (eg, a field) in the
|
||||
//- (sub) objectRegistry.
|
||||
//
|
||||
// \return nullptr if the object was not found or had incorrect type.
|
||||
template<class ObjectType>
|
||||
const ObjectType* cfindObject(const word& fieldName) const;
|
||||
|
||||
//- Return const pointer to the object (eg, a field) in the
|
||||
//- (sub) objectRegistry.
|
||||
//
|
||||
// \return nullptr if the object was not found or had incorrect type.
|
||||
template<class ObjectType>
|
||||
const ObjectType* findObject(const word& fieldName) const;
|
||||
|
||||
//- Return non-const pointer to the object of the given Type,
|
||||
//- (sub) objectRegistry.
|
||||
//
|
||||
// \return nullptr if the object was not found or had incorrect type.
|
||||
template<class ObjectType>
|
||||
ObjectType* findObject(const word& fieldName);
|
||||
|
||||
//- Return non-const pointer to the object of the given Type,
|
||||
//- using a const-cast to have it behave like a mutable.
|
||||
// Exercise caution when using.
|
||||
//
|
||||
// \return nullptr if the object was not found or had incorrect type.
|
||||
template<class ObjectType>
|
||||
ObjectType* getObjectPtr(const word& fieldName) const;
|
||||
|
||||
//- Lookup and return object (eg, a field) from the (sub) objectRegistry
|
||||
template<class ObjectType>
|
||||
const ObjectType& lookupObject(const word& fieldName) const;
|
||||
@ -102,18 +131,6 @@ protected:
|
||||
template<class ObjectType>
|
||||
ObjectType& lookupObjectRef(const word& fieldName) const;
|
||||
|
||||
//- Lookup and return pointer to the object,
|
||||
// otherwise nullptr if the object was not found,
|
||||
// or had the incorrect type.
|
||||
template<class ObjectType>
|
||||
const ObjectType* lookupObjectPtr(const word& fieldName) const;
|
||||
|
||||
//- Lookup and return non-const pointer to the object,
|
||||
// otherwise nullptr if the object was not found,
|
||||
// or had the incorrect type.
|
||||
template<class ObjectType>
|
||||
ObjectType* lookupObjectRefPtr(const word& fieldName) const;
|
||||
|
||||
//- Store the field in the (sub) objectRegistry under the given name
|
||||
// Note: sets the fieldName to tfield().name() if not already set
|
||||
template<class ObjectType>
|
||||
@ -177,6 +194,25 @@ public:
|
||||
|
||||
//- Read optional controls
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Same as findObject
|
||||
// \deprecated use findObject (OCT-2018)
|
||||
template<class ObjectType>
|
||||
const ObjectType* lookupObjectPtr(const word& fieldName) const
|
||||
{
|
||||
return this->cfindObject<ObjectType>(fieldName);
|
||||
}
|
||||
|
||||
//- Same as getObjectPtr
|
||||
// \deprecated use getObjectPtr (OCT-2018)
|
||||
template<class ObjectType>
|
||||
ObjectType* lookupObjectRefPtr(const word& fieldName) const
|
||||
{
|
||||
return this->getObjectPtr<ObjectType>(fieldName);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -38,6 +38,47 @@ bool Foam::functionObjects::regionFunctionObject::foundObject
|
||||
}
|
||||
|
||||
|
||||
template<class ObjectType>
|
||||
const ObjectType* Foam::functionObjects::regionFunctionObject::cfindObject
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
return obr().cfindObject<ObjectType>(fieldName);
|
||||
}
|
||||
|
||||
|
||||
template<class ObjectType>
|
||||
const ObjectType* Foam::functionObjects::regionFunctionObject::findObject
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
return obr().findObject<ObjectType>(fieldName);
|
||||
}
|
||||
|
||||
|
||||
template<class ObjectType>
|
||||
ObjectType* Foam::functionObjects::regionFunctionObject::findObject
|
||||
(
|
||||
const word& fieldName
|
||||
)
|
||||
{
|
||||
// Need getObjectPtr to bypass const access on the objectRegistry
|
||||
return obr().getObjectPtr<ObjectType>(fieldName);
|
||||
}
|
||||
|
||||
|
||||
template<class ObjectType>
|
||||
ObjectType* Foam::functionObjects::regionFunctionObject::getObjectPtr
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
return obr().getObjectPtr<ObjectType>(fieldName);
|
||||
}
|
||||
|
||||
|
||||
template<class ObjectType>
|
||||
const ObjectType& Foam::functionObjects::regionFunctionObject::lookupObject
|
||||
(
|
||||
@ -58,26 +99,6 @@ ObjectType& Foam::functionObjects::regionFunctionObject::lookupObjectRef
|
||||
}
|
||||
|
||||
|
||||
template<class ObjectType>
|
||||
const ObjectType* Foam::functionObjects::regionFunctionObject::lookupObjectPtr
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
return obr().lookupObjectPtr<ObjectType>(fieldName);
|
||||
}
|
||||
|
||||
|
||||
template<class ObjectType>
|
||||
ObjectType* Foam::functionObjects::regionFunctionObject::lookupObjectRefPtr
|
||||
(
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
return obr().lookupObjectRefPtr<ObjectType>(fieldName);
|
||||
}
|
||||
|
||||
|
||||
template<class ObjectType>
|
||||
bool Foam::functionObjects::regionFunctionObject::store
|
||||
(
|
||||
|
||||
@ -231,8 +231,9 @@ public:
|
||||
// Lookup
|
||||
|
||||
//- Lookup and return a const sub-objectRegistry.
|
||||
// Optionally create it if it does not exist.
|
||||
// If recursive, search parent registries.
|
||||
//
|
||||
// \param forceCreate create it if it does not exist.
|
||||
// \param recursive search parent registries.
|
||||
const objectRegistry& subRegistry
|
||||
(
|
||||
const word& name,
|
||||
@ -250,7 +251,8 @@ public:
|
||||
HashTable<Type*> lookupClass(const bool strict = false);
|
||||
|
||||
//- Is the named Type found?
|
||||
// If recursive, search parent registries.
|
||||
//
|
||||
// \param recursive search parent registries
|
||||
template<class Type>
|
||||
bool foundObject
|
||||
(
|
||||
@ -258,8 +260,60 @@ public:
|
||||
const bool recursive = false
|
||||
) const;
|
||||
|
||||
//- Lookup and return the object of the given Type.
|
||||
// If recursive, search parent registries.
|
||||
//- Find const pointer to the object of the given Type.
|
||||
//
|
||||
// \param recursive search parent registries
|
||||
//
|
||||
// \return nullptr if the object was not found or had incorrect type.
|
||||
template<class Type>
|
||||
const Type* cfindObject
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive = false
|
||||
) const;
|
||||
|
||||
//- Return const pointer to the object of the given Type.
|
||||
//
|
||||
// \param recursive search parent registries
|
||||
//
|
||||
// \return nullptr if the object was not found or had incorrect type.
|
||||
template<class Type>
|
||||
const Type* findObject
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive = false
|
||||
) const;
|
||||
|
||||
//- Return non-const pointer to the object of the given Type.
|
||||
//
|
||||
// \param recursive search parent registries
|
||||
//
|
||||
// \return nullptr if the object was not found or had incorrect type.
|
||||
template<class Type>
|
||||
Type* findObject
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive = false
|
||||
);
|
||||
|
||||
//- Return non-const pointer to the object of the given Type,
|
||||
//- using a const-cast to have it behave like a mutable.
|
||||
// Exercise caution when using.
|
||||
//
|
||||
// \param recursive search parent registries.
|
||||
//
|
||||
// \return nullptr if the object was not found or had incorrect type.
|
||||
template<class Type>
|
||||
Type* getObjectPtr
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive = false
|
||||
) const;
|
||||
|
||||
//- Lookup and return const reference to the object
|
||||
//- of the given Type. Fatal if not found or the wrong type.
|
||||
//
|
||||
// \param recursive search parent registries.
|
||||
template<class Type>
|
||||
const Type& lookupObject
|
||||
(
|
||||
@ -267,8 +321,10 @@ public:
|
||||
const bool recursive = false
|
||||
) const;
|
||||
|
||||
//- Lookup and return the object of the given Type.
|
||||
// If recursive, search parent registries.
|
||||
//- Lookup and return non-const reference to the object
|
||||
//- of the given Type. Fatal if not found or the wrong type.
|
||||
//
|
||||
// \param recursive search parent registries.
|
||||
template<class Type>
|
||||
Type& lookupObjectRef
|
||||
(
|
||||
@ -276,30 +332,6 @@ public:
|
||||
const bool recursive = false
|
||||
) const;
|
||||
|
||||
//- Lookup and return pointer to the object of the given Type,
|
||||
// otherwise nullptr if the object was not found,
|
||||
// or had the incorrect type.
|
||||
// If recursive, search parent registries.
|
||||
template<class Type>
|
||||
const Type* lookupObjectPtr
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive = false
|
||||
) const;
|
||||
|
||||
|
||||
//- Lookup and return non-const pointer to the object
|
||||
// of the given Type,
|
||||
// otherwise nullptr if the object was not found,
|
||||
// or had the incorrect type.
|
||||
// If recursive, search parent registries.
|
||||
template<class Type>
|
||||
Type* lookupObjectRefPtr
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive = false
|
||||
) const;
|
||||
|
||||
|
||||
// Events
|
||||
|
||||
@ -349,6 +381,34 @@ public:
|
||||
IOstream::compressionType cmp,
|
||||
const bool valid
|
||||
) const;
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
//- Same as findObject
|
||||
// \deprecated use findObject (OCT-2018)
|
||||
template<class Type>
|
||||
const Type* lookupObjectPtr
|
||||
(
|
||||
const word& name,
|
||||
bool recursive = false
|
||||
) const
|
||||
{
|
||||
return this->cfindObject<Type>(name, recursive);
|
||||
}
|
||||
|
||||
//- Same as getObjectPtr
|
||||
//
|
||||
// \deprecated use getObjectPtr (OCT-2018)
|
||||
template<class Type>
|
||||
Type* lookupObjectRefPtr
|
||||
(
|
||||
const word& name,
|
||||
bool recursive = false
|
||||
) const
|
||||
{
|
||||
return this->getObjectPtr<Type>(name, recursive);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -156,7 +156,7 @@ Foam::HashTable<const Type*> Foam::objectRegistry::lookupClass
|
||||
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
if (strict ? isType<Type>(*iter()) : isA<Type>(*iter()))
|
||||
if (strict ? isType<Type>(*iter()) : bool(isA<Type>(*iter())))
|
||||
{
|
||||
objectsOfClass.insert
|
||||
(
|
||||
@ -180,7 +180,7 @@ Foam::HashTable<Type*> Foam::objectRegistry::lookupClass
|
||||
|
||||
forAllIters(*this, iter)
|
||||
{
|
||||
if (strict ? isType<Type>(*iter()) : isA<Type>(*iter()))
|
||||
if (strict ? isType<Type>(*iter()) : bool(isA<Type>(*iter())))
|
||||
{
|
||||
objectsOfClass.insert
|
||||
(
|
||||
@ -201,14 +201,71 @@ bool Foam::objectRegistry::foundObject
|
||||
const bool recursive
|
||||
) const
|
||||
{
|
||||
const Type* ptr = this->lookupObjectPtr<Type>(name, recursive);
|
||||
return this->cfindObject<Type>(name, recursive);
|
||||
}
|
||||
|
||||
if (ptr)
|
||||
|
||||
template<class Type>
|
||||
const Type* Foam::objectRegistry::cfindObject
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive
|
||||
) const
|
||||
{
|
||||
const_iterator iter = cfind(name);
|
||||
|
||||
if (iter.found())
|
||||
{
|
||||
return true;
|
||||
const Type* ptr = dynamic_cast<const Type*>(iter());
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
else if (recursive && this->parentNotTime())
|
||||
{
|
||||
return parent_.cfindObject<Type>(name, recursive);
|
||||
}
|
||||
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Type* Foam::objectRegistry::findObject
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive
|
||||
) const
|
||||
{
|
||||
return this->cfindObject<Type>(name, recursive);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type* Foam::objectRegistry::findObject
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive
|
||||
)
|
||||
{
|
||||
const Type* ptr = this->cfindObject<Type>(name, recursive);
|
||||
|
||||
return const_cast<Type*>(ptr);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type* Foam::objectRegistry::getObjectPtr
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive
|
||||
) const
|
||||
{
|
||||
const Type* ptr = this->cfindObject<Type>(name, recursive);
|
||||
|
||||
return const_cast<Type*>(ptr);
|
||||
}
|
||||
|
||||
|
||||
@ -219,7 +276,7 @@ const Type& Foam::objectRegistry::lookupObject
|
||||
const bool recursive
|
||||
) const
|
||||
{
|
||||
const_iterator iter = find(name);
|
||||
const_iterator iter = cfind(name);
|
||||
|
||||
if (iter.found())
|
||||
{
|
||||
@ -270,44 +327,4 @@ Type& Foam::objectRegistry::lookupObjectRef
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
const Type* Foam::objectRegistry::lookupObjectPtr
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive
|
||||
) const
|
||||
{
|
||||
const_iterator iter = find(name);
|
||||
|
||||
if (iter.found())
|
||||
{
|
||||
const Type* ptr = dynamic_cast<const Type*>(iter());
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
else if (recursive && this->parentNotTime())
|
||||
{
|
||||
return parent_.lookupObjectPtr<Type>(name, recursive);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type* Foam::objectRegistry::lookupObjectRefPtr
|
||||
(
|
||||
const word& name,
|
||||
const bool recursive
|
||||
) const
|
||||
{
|
||||
const Type* ptr = this->lookupObjectPtr<Type>(name, recursive);
|
||||
|
||||
return const_cast<Type*>(ptr);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -120,6 +120,26 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
(
|
||||
const IOobject& io,
|
||||
const Mesh& mesh,
|
||||
const dimensionSet& dims,
|
||||
const tmp<Field<Type>>& tfield
|
||||
)
|
||||
:
|
||||
regIOobject(io),
|
||||
Field<Type>(tfield.constCast(), tfield.movable()),
|
||||
mesh_(mesh),
|
||||
dimensions_(dims),
|
||||
oriented_()
|
||||
{
|
||||
tfield.clear();
|
||||
checkFieldSize();
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
(
|
||||
@ -181,26 +201,22 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
template<class Type, class GeoMesh>
|
||||
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
(
|
||||
DimensionedField<Type, GeoMesh>& df,
|
||||
bool reuse
|
||||
DimensionedField<Type, GeoMesh>&& df
|
||||
)
|
||||
:
|
||||
regIOobject(df, reuse),
|
||||
Field<Type>(df, reuse),
|
||||
mesh_(df.mesh_),
|
||||
dimensions_(df.dimensions_),
|
||||
oriented_(df.oriented_)
|
||||
DimensionedField<Type, GeoMesh>(df, true)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
(
|
||||
DimensionedField<Type, GeoMesh>&& df
|
||||
DimensionedField<Type, GeoMesh>& df,
|
||||
bool reuse
|
||||
)
|
||||
:
|
||||
regIOobject(df, true),
|
||||
Field<Type>(std::move(df)),
|
||||
regIOobject(df, reuse),
|
||||
Field<Type>(df, reuse),
|
||||
mesh_(df.mesh_),
|
||||
dimensions_(df.dimensions_),
|
||||
oriented_(df.oriented_)
|
||||
@ -214,11 +230,7 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf
|
||||
)
|
||||
:
|
||||
regIOobject(tdf.constCast(), tdf.movable()),
|
||||
Field<Type>(tdf.constCast(), tdf.movable()),
|
||||
mesh_(tdf().mesh_),
|
||||
dimensions_(tdf().dimensions_),
|
||||
oriented_(tdf().oriented_)
|
||||
DimensionedField<Type, GeoMesh>(tdf.constCast(), tdf.movable())
|
||||
{
|
||||
tdf.clear();
|
||||
}
|
||||
@ -240,6 +252,17 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
{}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
(
|
||||
const IOobject& io,
|
||||
DimensionedField<Type, GeoMesh>&& df
|
||||
)
|
||||
:
|
||||
DimensionedField<Type, GeoMesh>(io, df, true)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
(
|
||||
@ -256,6 +279,21 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
{}
|
||||
|
||||
|
||||
#ifndef NoConstructFromTmp
|
||||
template<class Type, class GeoMesh>
|
||||
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
(
|
||||
const IOobject& io,
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf
|
||||
)
|
||||
:
|
||||
DimensionedField<Type, GeoMesh>(io, tdf.constCast(), tdf.movable())
|
||||
{
|
||||
tdf.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
(
|
||||
@ -275,15 +313,10 @@ template<class Type, class GeoMesh>
|
||||
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
(
|
||||
const word& newName,
|
||||
DimensionedField<Type, GeoMesh>& df,
|
||||
bool reuse
|
||||
DimensionedField<Type, GeoMesh>&& df
|
||||
)
|
||||
:
|
||||
regIOobject(newName, df, true),
|
||||
Field<Type>(df, reuse),
|
||||
mesh_(df.mesh_),
|
||||
dimensions_(df.dimensions_),
|
||||
oriented_(df.oriented_)
|
||||
DimensionedField<Type, GeoMesh>(newName, df, true)
|
||||
{}
|
||||
|
||||
|
||||
@ -291,11 +324,12 @@ template<class Type, class GeoMesh>
|
||||
Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
(
|
||||
const word& newName,
|
||||
DimensionedField<Type, GeoMesh>&& df
|
||||
DimensionedField<Type, GeoMesh>& df,
|
||||
bool reuse
|
||||
)
|
||||
:
|
||||
regIOobject(newName, df, true),
|
||||
Field<Type>(std::move(df)),
|
||||
Field<Type>(df, reuse),
|
||||
mesh_(df.mesh_),
|
||||
dimensions_(df.dimensions_),
|
||||
oriented_(df.oriented_)
|
||||
@ -310,11 +344,7 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf
|
||||
)
|
||||
:
|
||||
regIOobject(newName, tdf(), true),
|
||||
Field<Type>(tdf.constCast(), tdf.movable()),
|
||||
mesh_(tdf().mesh_),
|
||||
dimensions_(tdf().dimensions_),
|
||||
oriented_(tdf().oriented_)
|
||||
DimensionedField<Type, GeoMesh>(newName, tdf.constCast(), tdf.movable())
|
||||
{
|
||||
tdf.clear();
|
||||
}
|
||||
@ -356,7 +386,7 @@ Foam::DimensionedField<Type, GeoMesh>::component
|
||||
dimensions_
|
||||
);
|
||||
|
||||
Foam::component(tresult(), *this, d);
|
||||
Foam::component(tresult.ref(), *this, d);
|
||||
|
||||
return tresult;
|
||||
}
|
||||
|
||||
@ -48,17 +48,18 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
// Forward declarations
|
||||
template<class Type, class GeoMesh> class DimensionedField;
|
||||
|
||||
template<class Type, class GeoMesh> Ostream& operator<<
|
||||
template<class Type, class GeoMesh>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const DimensionedField<Type, GeoMesh>& df
|
||||
);
|
||||
|
||||
template<class Type, class GeoMesh> Ostream& operator<<
|
||||
template<class Type, class GeoMesh>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf
|
||||
@ -152,6 +153,15 @@ public:
|
||||
List<Type>&& field
|
||||
);
|
||||
|
||||
//- Construct from components, copy or transfer tmp content
|
||||
DimensionedField
|
||||
(
|
||||
const IOobject& io,
|
||||
const Mesh& mesh,
|
||||
const dimensionSet& dims,
|
||||
const tmp<Field<Type>>& tfield
|
||||
);
|
||||
|
||||
//- Construct from components, setting the initial size and assigning
|
||||
//- the dimensions, but not initialising any field values.
|
||||
// Used for temporary fields which are initialised after construction
|
||||
@ -192,25 +202,15 @@ public:
|
||||
);
|
||||
|
||||
//- Copy construct
|
||||
DimensionedField
|
||||
(
|
||||
const DimensionedField<Type, GeoMesh>& df
|
||||
);
|
||||
|
||||
//- Copy construct or reuse (move) as specified.
|
||||
DimensionedField
|
||||
(
|
||||
DimensionedField<Type, GeoMesh>& df,
|
||||
bool reuse
|
||||
);
|
||||
DimensionedField(const DimensionedField<Type, GeoMesh>& df);
|
||||
|
||||
//- Move construct
|
||||
explicit DimensionedField
|
||||
(
|
||||
DimensionedField<Type, GeoMesh>&& df
|
||||
);
|
||||
DimensionedField(DimensionedField<Type, GeoMesh>&& df);
|
||||
|
||||
//- Construct as copy of tmp<DimensionedField> deleting argument
|
||||
//- Copy construct or reuse (move) as specified.
|
||||
DimensionedField(DimensionedField<Type, GeoMesh>& df, bool reuse);
|
||||
|
||||
//- Construct from tmp\<DimensionedField\> deleting argument
|
||||
#ifndef NoConstructFromTmp
|
||||
DimensionedField
|
||||
(
|
||||
@ -225,6 +225,13 @@ public:
|
||||
const DimensionedField<Type, GeoMesh>& df
|
||||
);
|
||||
|
||||
//- Move construct, resetting IO parameters
|
||||
DimensionedField
|
||||
(
|
||||
const IOobject& io,
|
||||
DimensionedField<Type, GeoMesh>&& df
|
||||
);
|
||||
|
||||
//- Copy or move construct, resetting IO parameters.
|
||||
DimensionedField
|
||||
(
|
||||
@ -233,13 +240,30 @@ public:
|
||||
bool reuse
|
||||
);
|
||||
|
||||
//- Copy construct, resetting name
|
||||
//- Construct from tmp\<DimensionedField\> deleting argument,
|
||||
//- resetting IO parameters.
|
||||
#ifndef NoConstructFromTmp
|
||||
DimensionedField
|
||||
(
|
||||
const IOobject& io,
|
||||
const tmp<DimensionedField<Type, GeoMesh>>& tdf
|
||||
);
|
||||
#endif
|
||||
|
||||
//- Copy construct with a new name
|
||||
DimensionedField
|
||||
(
|
||||
const word& newName,
|
||||
const DimensionedField<Type, GeoMesh>& df
|
||||
);
|
||||
|
||||
//- Move construct with a new name
|
||||
DimensionedField
|
||||
(
|
||||
const word& newName,
|
||||
DimensionedField<Type, GeoMesh>&& df
|
||||
);
|
||||
|
||||
//- Copy or move construct, resetting name.
|
||||
DimensionedField
|
||||
(
|
||||
@ -248,14 +272,7 @@ public:
|
||||
bool reuse
|
||||
);
|
||||
|
||||
//- Move construct with a new name
|
||||
DimensionedField
|
||||
(
|
||||
const word& newName,
|
||||
DimensionedField<Type, GeoMesh>&& df
|
||||
);
|
||||
|
||||
//- Construct as copy resetting name
|
||||
//- Construct with a new name from tmp\<DimensionedField\>
|
||||
#ifndef NoConstructFromTmp
|
||||
DimensionedField
|
||||
(
|
||||
|
||||
@ -26,7 +26,6 @@ License
|
||||
#include "DimensionedField.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
@ -81,7 +80,7 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
)
|
||||
:
|
||||
regIOobject(io),
|
||||
Field<Type>(0),
|
||||
Field<Type>(),
|
||||
mesh_(mesh),
|
||||
dimensions_(dimless),
|
||||
oriented_()
|
||||
@ -100,7 +99,7 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
|
||||
)
|
||||
:
|
||||
regIOobject(io),
|
||||
Field<Type>(0),
|
||||
Field<Type>(),
|
||||
mesh_(mesh),
|
||||
dimensions_(dimless),
|
||||
oriented_()
|
||||
|
||||
@ -132,24 +132,37 @@ FieldField<Field, Type>::FieldField
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
FieldField<Field, Type>::FieldField(const FieldField<Field, Type>& f)
|
||||
FieldField<Field, Type>::FieldField(const FieldField<Field, Type>& ff)
|
||||
:
|
||||
refCount(),
|
||||
PtrList<Field<Type>>(f)
|
||||
PtrList<Field<Type>>(ff)
|
||||
{}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
FieldField<Field, Type>::FieldField(FieldField<Field, Type>& f, bool reuse)
|
||||
FieldField<Field, Type>::FieldField(FieldField<Field, Type>&& ff)
|
||||
:
|
||||
PtrList<Field<Type>>(f, reuse)
|
||||
PtrList<Field<Type>>(std::move(ff))
|
||||
{}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
FieldField<Field, Type>::FieldField(const PtrList<Field<Type>>& tl)
|
||||
FieldField<Field, Type>::FieldField(FieldField<Field, Type>& ff, bool reuse)
|
||||
:
|
||||
PtrList<Field<Type>>(tl)
|
||||
PtrList<Field<Type>>(ff, reuse)
|
||||
{}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
FieldField<Field, Type>::FieldField(const PtrList<Field<Type>>& list)
|
||||
:
|
||||
PtrList<Field<Type>>(list)
|
||||
{}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
FieldField<Field, Type>::FieldField(PtrList<Field<Type>>&& list)
|
||||
:
|
||||
PtrList<Field<Type>>(std::move(list))
|
||||
{}
|
||||
|
||||
|
||||
@ -185,17 +198,17 @@ tmp<FieldField<Field, Type>> FieldField<Field, Type>::NewCalculatedType
|
||||
const FieldField<Field, Type2>& ff
|
||||
)
|
||||
{
|
||||
FieldField<Field, Type>* nffPtr
|
||||
(
|
||||
new FieldField<Field, Type>(ff.size())
|
||||
);
|
||||
const label len = ff.size();
|
||||
|
||||
forAll(*nffPtr, i)
|
||||
auto tresult = tmp<FieldField<Field, Type>>::New(len);
|
||||
auto& result = tresult.ref();
|
||||
|
||||
for (label i=0; i<len; ++i)
|
||||
{
|
||||
nffPtr->set(i, Field<Type>::NewCalculatedType(ff[i]).ptr());
|
||||
result.set(i, Field<Type>::NewCalculatedType(ff[i]).ptr());
|
||||
}
|
||||
|
||||
return tmp<FieldField<Field, Type>>(nffPtr);
|
||||
return tresult;
|
||||
}
|
||||
|
||||
|
||||
@ -261,13 +274,13 @@ void FieldField<Field, Type>::replace
|
||||
template<template<class> class Field, class Type>
|
||||
tmp<FieldField<Field, Type>> FieldField<Field, Type>::T() const
|
||||
{
|
||||
tmp<FieldField<Field, Type>> transpose
|
||||
auto tresult
|
||||
(
|
||||
FieldField<Field, Type>::NewCalculatedType(*this)
|
||||
);
|
||||
|
||||
::Foam::T(transpose.ref(), *this);
|
||||
return transpose;
|
||||
::Foam::T(tresult.ref(), *this);
|
||||
return tresult;
|
||||
}
|
||||
|
||||
|
||||
@ -282,6 +295,7 @@ void FieldField<Field, Type>::operator=(const FieldField<Field, Type>& f)
|
||||
<< "attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
// No size checking done
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
@ -291,19 +305,38 @@ void FieldField<Field, Type>::operator=(const FieldField<Field, Type>& f)
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
void FieldField<Field, Type>::operator=(const tmp<FieldField>& tf)
|
||||
void FieldField<Field, Type>::operator=(FieldField<Field, Type>&& ff)
|
||||
{
|
||||
if (this == &(tf()))
|
||||
if (this == &ff)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
// This is dodgy stuff, don't try this at home.
|
||||
FieldField* fieldPtr = tf.ptr();
|
||||
PtrList<Field<Type>>::transfer(*fieldPtr);
|
||||
delete fieldPtr;
|
||||
PtrList<Field<Type>>::transfer(ff);
|
||||
}
|
||||
|
||||
|
||||
template<template<class> class Field, class Type>
|
||||
void FieldField<Field, Type>::operator=(const tmp<FieldField>& tf)
|
||||
{
|
||||
// The cref() method also checks that tmp is not nullptr.
|
||||
if (this == &(tf.cref()))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "attempted assignment to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
PtrList<Field<Type>>::clear();
|
||||
|
||||
// Release the tmp pointer, or clone const reference for a new pointer.
|
||||
// Error potential when tmp is non-unique.
|
||||
|
||||
auto* tptr = tf.ptr();
|
||||
PtrList<Field<Type>>::transfer(*tptr);
|
||||
delete tptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::FieldField
|
||||
|
||||
Description
|
||||
Generic field type.
|
||||
A field of fields is a PtrList of fields with reference counting.
|
||||
|
||||
SourceFiles
|
||||
FieldField.C
|
||||
@ -91,29 +91,33 @@ public:
|
||||
|
||||
//- Construct given size
|
||||
// Used for temporary fields which are initialised after construction
|
||||
explicit FieldField(const label);
|
||||
explicit FieldField(const label size);
|
||||
|
||||
//- Construct using the Field sizes from the given FieldField
|
||||
// and the given Field type.
|
||||
// Used for temporary fields which are initialised after construction
|
||||
FieldField(const word&, const FieldField<Field, Type>&);
|
||||
//- Clone construct with new type
|
||||
FieldField(const word& type, const FieldField<Field, Type>& ff);
|
||||
|
||||
//- Construct as copy
|
||||
FieldField(const FieldField<Field, Type>&);
|
||||
//- Copy construct, cloning each element
|
||||
FieldField(const FieldField<Field, Type>& ff);
|
||||
|
||||
//- Move construct
|
||||
FieldField(FieldField<Field, Type>&& ff);
|
||||
|
||||
//- Construct as copy or re-use as specified.
|
||||
FieldField(FieldField<Field, Type>&, bool reuse);
|
||||
FieldField(FieldField<Field, Type>& ff, bool reuse);
|
||||
|
||||
//- Construct as copy of a PtrList<Field, Type>
|
||||
FieldField(const PtrList<Field<Type>>&);
|
||||
//- Copy construct from PtrList
|
||||
FieldField(const PtrList<Field<Type>>& list);
|
||||
|
||||
//- Construct as copy of tmp<FieldField>
|
||||
//- Move construct from PtrList
|
||||
FieldField(PtrList<Field<Type>>&& list);
|
||||
|
||||
//- Move/copy construct from tmp<FieldField>
|
||||
#ifndef NoConstructFromTmp
|
||||
FieldField(const tmp<FieldField<Field, Type>>&);
|
||||
FieldField(const tmp<FieldField<Field, Type>>& tf);
|
||||
#endif
|
||||
|
||||
//- Construct from Istream
|
||||
FieldField(Istream&);
|
||||
FieldField(Istream& is);
|
||||
|
||||
//- Clone
|
||||
tmp<FieldField<Field, Type>> clone() const;
|
||||
@ -147,8 +151,16 @@ public:
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Copy assignment
|
||||
void operator=(const FieldField<Field, Type>&);
|
||||
|
||||
//- Move assignment
|
||||
void operator=(FieldField<Field, Type>&&);
|
||||
|
||||
//- Move or clone assignment
|
||||
void operator=(const tmp<FieldField<Field, Type>>&);
|
||||
|
||||
//- Assign uniform value
|
||||
void operator=(const Type&);
|
||||
|
||||
void operator+=(const FieldField<Field, Type>&);
|
||||
|
||||
@ -36,17 +36,13 @@ readField
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
DebugInFunction << nl;
|
||||
|
||||
// Clear the boundary field if already initialised
|
||||
this->clear();
|
||||
|
||||
this->setSize(bmesh_.size());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction << endl;
|
||||
}
|
||||
|
||||
|
||||
label nUnset = this->size();
|
||||
|
||||
// 1. Handle explicit patch names. Note that there can be only one explicit
|
||||
@ -217,10 +213,7 @@ Boundary
|
||||
FieldField<PatchField, Type>(bmesh.size()),
|
||||
bmesh_(bmesh)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction << endl;
|
||||
}
|
||||
DebugInFunction << nl;
|
||||
|
||||
forAll(bmesh_, patchi)
|
||||
{
|
||||
@ -251,10 +244,7 @@ Boundary
|
||||
FieldField<PatchField, Type>(bmesh.size()),
|
||||
bmesh_(bmesh)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction << endl;
|
||||
}
|
||||
DebugInFunction << nl;
|
||||
|
||||
if
|
||||
(
|
||||
@ -318,10 +308,7 @@ Boundary
|
||||
FieldField<PatchField, Type>(bmesh.size()),
|
||||
bmesh_(bmesh)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction << endl;
|
||||
}
|
||||
DebugInFunction << nl;
|
||||
|
||||
forAll(bmesh_, patchi)
|
||||
{
|
||||
@ -342,10 +329,7 @@ Boundary
|
||||
FieldField<PatchField, Type>(btf.size()),
|
||||
bmesh_(btf.bmesh_)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction << endl;
|
||||
}
|
||||
DebugInFunction << nl;
|
||||
|
||||
forAll(bmesh_, patchi)
|
||||
{
|
||||
@ -365,10 +349,7 @@ Boundary
|
||||
FieldField<PatchField, Type>(btf),
|
||||
bmesh_(btf.bmesh_)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction << endl;
|
||||
}
|
||||
DebugInFunction << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -394,10 +375,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
|
||||
updateCoeffs()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction << endl;
|
||||
}
|
||||
DebugInFunction << nl;
|
||||
|
||||
forAll(*this, patchi)
|
||||
{
|
||||
@ -410,10 +388,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary::
|
||||
evaluate()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
InfoInFunction << endl;
|
||||
}
|
||||
DebugInFunction << nl;
|
||||
|
||||
if
|
||||
(
|
||||
@ -479,14 +454,14 @@ types() const
|
||||
{
|
||||
const FieldField<PatchField, Type>& pff = *this;
|
||||
|
||||
wordList Types(pff.size());
|
||||
wordList list(pff.size());
|
||||
|
||||
forAll(pff, patchi)
|
||||
{
|
||||
Types[patchi] = pff[patchi].type();
|
||||
list[patchi] = pff[patchi].type();
|
||||
}
|
||||
|
||||
return Types;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -311,17 +311,17 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
||||
const Mesh& mesh,
|
||||
const dimensionSet& ds,
|
||||
const Field<Type>& iField,
|
||||
const PtrList<PatchField<Type>>& ptfl
|
||||
const word& patchFieldType
|
||||
)
|
||||
:
|
||||
Internal(io, mesh, ds, iField),
|
||||
timeIndex_(this->time().timeIndex()),
|
||||
field0Ptr_(nullptr),
|
||||
fieldPrevIterPtr_(nullptr),
|
||||
boundaryField_(mesh.boundary(), *this, ptfl)
|
||||
boundaryField_(mesh.boundary(), *this, patchFieldType)
|
||||
{
|
||||
DebugInFunction
|
||||
<< "Copy construct from components" << nl << this->info() << endl;
|
||||
<< "Copy construct from internal field" << nl << this->info() << endl;
|
||||
|
||||
readIfPresent();
|
||||
}
|
||||
@ -334,17 +334,17 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
||||
const Mesh& mesh,
|
||||
const dimensionSet& ds,
|
||||
Field<Type>&& iField,
|
||||
const PtrList<PatchField<Type>>& ptfl
|
||||
const word& patchFieldType
|
||||
)
|
||||
:
|
||||
Internal(io, mesh, ds, std::move(iField)),
|
||||
timeIndex_(this->time().timeIndex()),
|
||||
field0Ptr_(nullptr),
|
||||
fieldPrevIterPtr_(nullptr),
|
||||
boundaryField_(mesh.boundary(), *this, ptfl)
|
||||
boundaryField_(mesh.boundary(), *this, patchFieldType)
|
||||
{
|
||||
DebugInFunction
|
||||
<< "Move construct from components" << nl << this->info() << endl;
|
||||
<< "Move construct from internal field" << nl << this->info() << endl;
|
||||
|
||||
readIfPresent();
|
||||
}
|
||||
@ -356,18 +356,18 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
||||
const IOobject& io,
|
||||
const Mesh& mesh,
|
||||
const dimensionSet& ds,
|
||||
List<Type>&& iField,
|
||||
const Field<Type>& iField,
|
||||
const PtrList<PatchField<Type>>& ptfl
|
||||
)
|
||||
:
|
||||
Internal(io, mesh, ds, std::move(iField)),
|
||||
Internal(io, mesh, ds, iField),
|
||||
timeIndex_(this->time().timeIndex()),
|
||||
field0Ptr_(nullptr),
|
||||
fieldPrevIterPtr_(nullptr),
|
||||
boundaryField_(mesh.boundary(), *this, ptfl)
|
||||
{
|
||||
DebugInFunction
|
||||
<< "Move construct from components" << nl << this->info() << endl;
|
||||
<< "Copy construct from components" << nl << this->info() << endl;
|
||||
|
||||
readIfPresent();
|
||||
}
|
||||
|
||||
@ -180,11 +180,11 @@ public:
|
||||
(
|
||||
const BoundaryMesh& bmesh,
|
||||
const Internal& field,
|
||||
const dictionary&
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- Read the boundary field
|
||||
void readField
|
||||
@ -344,6 +344,26 @@ public:
|
||||
const PtrList<PatchField<Type>>& ptfl
|
||||
);
|
||||
|
||||
//- Copy construct from internal field, with specified patch type
|
||||
GeometricField
|
||||
(
|
||||
const IOobject& io,
|
||||
const Mesh& mesh,
|
||||
const dimensionSet& ds,
|
||||
const Field<Type>& iField,
|
||||
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||
);
|
||||
|
||||
//- Move construct from internal field, with specified patch type
|
||||
GeometricField
|
||||
(
|
||||
const IOobject& io,
|
||||
const Mesh& mesh,
|
||||
const dimensionSet& ds,
|
||||
Field<Type>&& iField,
|
||||
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||
);
|
||||
|
||||
//- Copy construct from components
|
||||
GeometricField
|
||||
(
|
||||
@ -354,26 +374,6 @@ public:
|
||||
const PtrList<PatchField<Type>>& ptfl
|
||||
);
|
||||
|
||||
//- Construct from components, moving initial internal field
|
||||
GeometricField
|
||||
(
|
||||
const IOobject& io,
|
||||
const Mesh& mesh,
|
||||
const dimensionSet& ds,
|
||||
Field<Type>&& iField,
|
||||
const PtrList<PatchField<Type>>& ptfl
|
||||
);
|
||||
|
||||
//- Construct from components, moving initial internal field
|
||||
GeometricField
|
||||
(
|
||||
const IOobject& io,
|
||||
const Mesh& mesh,
|
||||
const dimensionSet& ds,
|
||||
List<Type>&& iField,
|
||||
const PtrList<PatchField<Type>>& ptfl
|
||||
);
|
||||
|
||||
//- Construct and read given IOobject
|
||||
GeometricField
|
||||
(
|
||||
@ -396,7 +396,7 @@ public:
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf
|
||||
);
|
||||
|
||||
//- Construct as copy of tmp<GeometricField> deleting argument
|
||||
//- Construct from tmp\<GeometricField\> deleting argument
|
||||
#ifndef NoConstructFromTmp
|
||||
GeometricField
|
||||
(
|
||||
@ -420,14 +420,14 @@ public:
|
||||
);
|
||||
#endif
|
||||
|
||||
//- Construct as copy resetting name
|
||||
//- Copy construct with a new name
|
||||
GeometricField
|
||||
(
|
||||
const word& newName,
|
||||
const GeometricField<Type, PatchField, GeoMesh>& gf
|
||||
);
|
||||
|
||||
//- Construct as copy resetting name
|
||||
//- Construct with a new name from tmp\<GeometricField\>
|
||||
#ifndef NoConstructFromTmp
|
||||
GeometricField
|
||||
(
|
||||
|
||||
@ -51,6 +51,7 @@ License
|
||||
|
||||
bool Foam::argList::argsMandatory_ = true;
|
||||
bool Foam::argList::checkProcessorDirectories_ = true;
|
||||
|
||||
Foam::SLList<Foam::string> Foam::argList::validArgs;
|
||||
Foam::HashSet<Foam::string> Foam::argList::advancedOptions;
|
||||
Foam::HashTable<Foam::string> Foam::argList::validOptions;
|
||||
@ -59,10 +60,11 @@ Foam::HashTable<Foam::string> Foam::argList::optionUsage;
|
||||
Foam::HashTable<std::pair<Foam::word,int>> Foam::argList::validOptionsCompat;
|
||||
Foam::HashTable<std::pair<bool,int>> Foam::argList::ignoreOptionsCompat;
|
||||
Foam::SLList<Foam::string> Foam::argList::notes;
|
||||
Foam::string::size_type Foam::argList::usageMin = 20;
|
||||
Foam::string::size_type Foam::argList::usageMax = 80;
|
||||
Foam::word Foam::argList::postProcessOptionName("postProcess");
|
||||
|
||||
std::string::size_type Foam::argList::usageMin = 20;
|
||||
std::string::size_type Foam::argList::usageMax = 80;
|
||||
|
||||
Foam::argList::initValidTables::initValidTables()
|
||||
{
|
||||
argList::addOption
|
||||
@ -256,7 +258,7 @@ void Foam::argList::addBoolOption
|
||||
(
|
||||
const word& optName,
|
||||
const string& usage,
|
||||
const bool advanced
|
||||
bool advanced
|
||||
)
|
||||
{
|
||||
addOption(optName, "", usage, advanced);
|
||||
@ -268,7 +270,7 @@ void Foam::argList::addOption
|
||||
const word& optName,
|
||||
const string& param,
|
||||
const string& usage,
|
||||
const bool advanced
|
||||
bool advanced
|
||||
)
|
||||
{
|
||||
validOptions.set(optName, param);
|
||||
@ -283,6 +285,19 @@ void Foam::argList::addOption
|
||||
}
|
||||
|
||||
|
||||
void Foam::argList::setAdvanced(const word& optName, bool advanced)
|
||||
{
|
||||
if (advanced && validOptions.found(optName))
|
||||
{
|
||||
advancedOptions.set(optName);
|
||||
}
|
||||
else
|
||||
{
|
||||
advancedOptions.erase(optName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::argList::addOptionCompat
|
||||
(
|
||||
const word& optName,
|
||||
@ -300,7 +315,7 @@ void Foam::argList::addOptionCompat
|
||||
void Foam::argList::ignoreOptionCompat
|
||||
(
|
||||
std::pair<const char*,int> compat,
|
||||
const bool expectArg
|
||||
bool expectArg
|
||||
)
|
||||
{
|
||||
ignoreOptionsCompat.insert
|
||||
@ -417,100 +432,107 @@ void Foam::argList::noCheckProcessorDirectories()
|
||||
|
||||
void Foam::argList::printOptionUsage
|
||||
(
|
||||
const label location,
|
||||
std::string::size_type start,
|
||||
const string& str
|
||||
)
|
||||
{
|
||||
const string::size_type textWidth = usageMax - usageMin;
|
||||
const string::size_type strLen = str.size();
|
||||
const auto strLen = str.length();
|
||||
|
||||
if (strLen)
|
||||
if (!strLen)
|
||||
{
|
||||
// Minimum of 2 spaces between option and usage:
|
||||
if (string::size_type(location) + 2 <= usageMin)
|
||||
Info<< nl;
|
||||
return;
|
||||
}
|
||||
|
||||
// Indent the first line. Min 2 spaces between option and usage
|
||||
if (start + 2 > usageMin)
|
||||
{
|
||||
Info<< nl;
|
||||
start = 0;
|
||||
}
|
||||
while (start < usageMin)
|
||||
{
|
||||
Info<<' ';
|
||||
++start;
|
||||
}
|
||||
|
||||
const std::string::size_type textWidth = (usageMax - usageMin);
|
||||
|
||||
// Output with text wrapping
|
||||
for (std::string::size_type pos = 0; pos < strLen; /*ni*/)
|
||||
{
|
||||
// Potential end point and next point
|
||||
std::string::size_type end = pos + textWidth - 1;
|
||||
std::string::size_type eol = str.find('\n', pos);
|
||||
std::string::size_type next = string::npos;
|
||||
|
||||
if (end >= strLen)
|
||||
{
|
||||
for (string::size_type i = location; i < usageMin; ++i)
|
||||
// No more wrapping needed
|
||||
end = strLen;
|
||||
|
||||
if (std::string::npos != eol && eol <= end)
|
||||
{
|
||||
Info<<' ';
|
||||
end = eol;
|
||||
next = str.find_first_not_of(" \t\n", end); // Next non-space
|
||||
}
|
||||
}
|
||||
else if (std::string::npos != eol && eol <= end)
|
||||
{
|
||||
// Embedded '\n' char
|
||||
end = eol;
|
||||
next = str.find_first_not_of(" \t\n", end); // Next non-space
|
||||
}
|
||||
else if (isspace(str[end]))
|
||||
{
|
||||
// Ended on a space - can use this directly
|
||||
next = str.find_first_not_of(" \t\n", end); // Next non-space
|
||||
}
|
||||
else if (isspace(str[end+1]))
|
||||
{
|
||||
// The next one is a space - so we are okay
|
||||
++end; // Otherwise the length is wrong
|
||||
next = str.find_first_not_of(" \t\n", end); // Next non-space
|
||||
}
|
||||
else
|
||||
{
|
||||
// or start a new line
|
||||
// Line break will be mid-word
|
||||
auto prev = str.find_last_of(" \t\n", end); // Prev word break
|
||||
|
||||
if (std::string::npos != prev && prev > pos)
|
||||
{
|
||||
end = prev;
|
||||
next = prev + 1; // Continue from here
|
||||
}
|
||||
}
|
||||
|
||||
// The next position to continue from
|
||||
if (std::string::npos == next)
|
||||
{
|
||||
next = end + 1;
|
||||
}
|
||||
|
||||
// Has a length
|
||||
if (end > pos)
|
||||
{
|
||||
// Indent following lines. The first one was already done.
|
||||
if (pos)
|
||||
{
|
||||
for (std::string::size_type i = 0; i < usageMin; ++i)
|
||||
{
|
||||
Info<<' ';
|
||||
}
|
||||
}
|
||||
|
||||
while (pos < end)
|
||||
{
|
||||
Info<< str[pos];
|
||||
++pos;
|
||||
}
|
||||
Info<< nl;
|
||||
for (string::size_type i = 0; i < usageMin; ++i)
|
||||
{
|
||||
Info<<' ';
|
||||
}
|
||||
}
|
||||
|
||||
// Text wrap
|
||||
string::size_type pos = 0;
|
||||
while (pos != string::npos && pos + textWidth < strLen)
|
||||
{
|
||||
// Potential end point and next point
|
||||
string::size_type curr = pos + textWidth - 1;
|
||||
string::size_type next = string::npos;
|
||||
|
||||
if (isspace(str[curr]))
|
||||
{
|
||||
// We were lucky: ended on a space
|
||||
next = str.find_first_not_of(" \t\n", curr);
|
||||
}
|
||||
else if (isspace(str[curr+1]))
|
||||
{
|
||||
// The next one is a space - so we are okay
|
||||
++curr; // otherwise the length is wrong
|
||||
next = str.find_first_not_of(" \t\n", curr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Search for end of a previous word break
|
||||
string::size_type prev = str.find_last_of(" \t\n", curr);
|
||||
|
||||
// Reposition to the end of previous word if possible
|
||||
if (prev != string::npos && prev > pos)
|
||||
{
|
||||
curr = prev;
|
||||
}
|
||||
}
|
||||
|
||||
if (next == string::npos)
|
||||
{
|
||||
next = curr + 1;
|
||||
}
|
||||
|
||||
// Indent following lines (not the first one)
|
||||
if (pos)
|
||||
{
|
||||
for (string::size_type i = 0; i < usageMin; ++i)
|
||||
{
|
||||
Info<<' ';
|
||||
}
|
||||
}
|
||||
|
||||
Info<< str.substr(pos, (curr - pos)).c_str() << nl;
|
||||
pos = next;
|
||||
}
|
||||
|
||||
// Output the remainder of the string
|
||||
if (pos != string::npos)
|
||||
{
|
||||
// Indent following lines (not the first one)
|
||||
if (pos)
|
||||
{
|
||||
for (string::size_type i = 0; i < usageMin; ++i)
|
||||
{
|
||||
Info<<' ';
|
||||
}
|
||||
}
|
||||
|
||||
Info<< str.substr(pos).c_str() << nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< nl;
|
||||
pos = next;
|
||||
}
|
||||
}
|
||||
|
||||
@ -684,72 +706,58 @@ bool Foam::argList::regroupArgv(int& argc, char**& argv)
|
||||
args_.resize(nArgs);
|
||||
|
||||
std::string::size_type len = (nArgs-1); // Spaces between args
|
||||
forAll(args_, argi)
|
||||
for (const auto& s : args_)
|
||||
{
|
||||
len += args_[argi].size();
|
||||
len += s.length();
|
||||
}
|
||||
|
||||
// Length needed for regrouped command-line
|
||||
argListStr_.reserve(len);
|
||||
commandLine_.reserve(len);
|
||||
|
||||
return nArgs < argc;
|
||||
}
|
||||
|
||||
|
||||
void Foam::argList::getRootCase()
|
||||
void Foam::argList::setCasePaths()
|
||||
{
|
||||
fileName casePath;
|
||||
fileName caseDir;
|
||||
|
||||
// [-case dir] specified
|
||||
const auto optIter = options_.cfind("case");
|
||||
const auto optIter = options_.cfind("case"); // [-case dir] specified?
|
||||
|
||||
if (optIter.found())
|
||||
{
|
||||
casePath = optIter.object();
|
||||
casePath.clean();
|
||||
caseDir = optIter.object();
|
||||
caseDir.clean();
|
||||
|
||||
if (casePath.empty() || casePath == ".")
|
||||
if (caseDir.empty() || caseDir == ".")
|
||||
{
|
||||
// Handle degenerate form and '-case .' like no -case specified
|
||||
casePath = cwd();
|
||||
// Treat "", "." and "./" as if -case was not specified
|
||||
caseDir = cwd();
|
||||
options_.erase("case");
|
||||
}
|
||||
else if (!casePath.isAbsolute() && casePath.name() == "..")
|
||||
else
|
||||
{
|
||||
// Avoid relative cases ending in '..' - makes for very ugly names
|
||||
casePath = cwd()/casePath;
|
||||
casePath.clean();
|
||||
caseDir.toAbsolute();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nothing specified, use the current dir
|
||||
casePath = cwd();
|
||||
caseDir = cwd();
|
||||
}
|
||||
|
||||
rootPath_ = casePath.path();
|
||||
globalCase_ = casePath.name();
|
||||
case_ = globalCase_;
|
||||
// The caseDir is a cleaned, absolute path
|
||||
|
||||
// The name of the executable, unless already present in the environment
|
||||
rootPath_ = caseDir.path();
|
||||
globalCase_ = caseDir.name();
|
||||
case_ = globalCase_; // The (processor) local case name
|
||||
|
||||
// Global case (directory) and case-name as environment variables
|
||||
setEnv("FOAM_CASE", caseDir, true);
|
||||
setEnv("FOAM_CASENAME", globalCase_, true);
|
||||
|
||||
// Executable name, unless already present in the environment
|
||||
setEnv("FOAM_EXECUTABLE", executable_, false);
|
||||
|
||||
// Set the case and case-name as an environment variable
|
||||
if (rootPath_.isAbsolute())
|
||||
{
|
||||
// Absolute path - use as-is
|
||||
setEnv("FOAM_CASE", rootPath_/globalCase_, true);
|
||||
setEnv("FOAM_CASENAME", globalCase_, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Qualify relative path
|
||||
casePath = cwd()/rootPath_/globalCase_;
|
||||
casePath.clean();
|
||||
|
||||
setEnv("FOAM_CASE", casePath, true);
|
||||
setEnv("FOAM_CASENAME", casePath.name(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -761,12 +769,11 @@ Foam::argList::argList
|
||||
char**& argv,
|
||||
bool checkArgs,
|
||||
bool checkOpts,
|
||||
const bool initialise
|
||||
bool initialise
|
||||
)
|
||||
:
|
||||
args_(argc),
|
||||
options_(argc),
|
||||
distributed_(false)
|
||||
options_(argc)
|
||||
{
|
||||
// Check for -fileHandler, which requires an argument.
|
||||
word handlerType(getEnv("FOAM_FILEHANDLER"));
|
||||
@ -815,7 +822,7 @@ Foam::argList::argList
|
||||
|
||||
// Convert argv -> args_ and capture ( ... ) lists
|
||||
regroupArgv(argc, argv);
|
||||
argListStr_ += args_[0];
|
||||
commandLine_ += args_[0];
|
||||
|
||||
// Set executable name immediately - useful when emitting errors.
|
||||
executable_ = fileName(args_[0]).name();
|
||||
@ -824,8 +831,8 @@ Foam::argList::argList
|
||||
int nArgs = 1;
|
||||
for (int argi = 1; argi < args_.size(); ++argi)
|
||||
{
|
||||
argListStr_ += ' ';
|
||||
argListStr_ += args_[argi];
|
||||
commandLine_ += ' ';
|
||||
commandLine_ += args_[argi];
|
||||
|
||||
if (args_[argi][0] == '-')
|
||||
{
|
||||
@ -859,8 +866,8 @@ Foam::argList::argList
|
||||
Pstream::exit(1); // works for serial and parallel
|
||||
}
|
||||
|
||||
argListStr_ += ' ';
|
||||
argListStr_ += args_[argi];
|
||||
commandLine_ += ' ';
|
||||
commandLine_ += args_[argi];
|
||||
// Handle duplicates by taking the last -option specified
|
||||
options_.set(optName, args_[argi]);
|
||||
}
|
||||
@ -904,7 +911,7 @@ Foam::argList::argList
|
||||
rootPath_(args.rootPath_),
|
||||
globalCase_(args.globalCase_),
|
||||
case_(args.case_),
|
||||
argListStr_(args.argListStr_)
|
||||
commandLine_(args.commandLine_)
|
||||
{
|
||||
parse(checkArgs, checkOpts, initialise);
|
||||
}
|
||||
@ -991,7 +998,7 @@ void Foam::argList::parse
|
||||
#endif
|
||||
<< nl
|
||||
<< "Arch : " << Foam::FOAMbuildArch << nl
|
||||
<< "Exec : " << argListStr_.c_str() << nl
|
||||
<< "Exec : " << commandLine_.c_str() << nl
|
||||
<< "Date : " << dateString.c_str() << nl
|
||||
<< "Time : " << timeString.c_str() << nl
|
||||
<< "Host : " << hostName().c_str() << nl
|
||||
@ -1003,7 +1010,7 @@ void Foam::argList::parse
|
||||
jobInfo.add("userName", userName());
|
||||
jobInfo.add("foamVersion", word(Foam::FOAMversion));
|
||||
jobInfo.add("code", executable_);
|
||||
jobInfo.add("argList", argListStr_);
|
||||
jobInfo.add("argList", commandLine_);
|
||||
jobInfo.add("currentDir", cwd());
|
||||
jobInfo.add("PPID", ppid());
|
||||
jobInfo.add("PGID", pgid());
|
||||
@ -1106,7 +1113,7 @@ void Foam::argList::parse
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Establish rootPath_/globalCase_/case_ for master
|
||||
getRootCase();
|
||||
setCasePaths();
|
||||
|
||||
// Establish location of decomposeParDict, allow override with
|
||||
// the -decomposeParDict option.
|
||||
@ -1118,7 +1125,7 @@ void Foam::argList::parse
|
||||
source = options_["decomposeParDict"];
|
||||
if (isDir(source))
|
||||
{
|
||||
source = source/"decomposeParDict";
|
||||
source /= "decomposeParDict";
|
||||
adjustOpt = true;
|
||||
}
|
||||
|
||||
@ -1141,7 +1148,7 @@ void Foam::argList::parse
|
||||
label dictNProcs = -1;
|
||||
if (this->readListIfPresent("roots", roots))
|
||||
{
|
||||
distributed_ = true;
|
||||
parRunControl_.distributed(true);
|
||||
source = "-roots";
|
||||
if (roots.size() != 1)
|
||||
{
|
||||
@ -1209,11 +1216,11 @@ void Foam::argList::parse
|
||||
|
||||
dictionary decompDict(decompDictStream);
|
||||
|
||||
dictNProcs = decompDict.get<label>("numberOfSubdomains");
|
||||
decompDict.readEntry("numberOfSubdomains", dictNProcs);
|
||||
|
||||
if (decompDict.lookupOrDefault("distributed", false))
|
||||
{
|
||||
distributed_ = true;
|
||||
parRunControl_.distributed(true);
|
||||
decompDict.readEntry("roots", roots);
|
||||
}
|
||||
}
|
||||
@ -1266,9 +1273,9 @@ void Foam::argList::parse
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
forAll(roots, i)
|
||||
for (fileName& dir : roots)
|
||||
{
|
||||
roots[i].expand();
|
||||
dir.expand();
|
||||
}
|
||||
|
||||
// Distribute the master's argument list (with new root)
|
||||
@ -1308,8 +1315,8 @@ void Foam::argList::parse
|
||||
(
|
||||
isDir
|
||||
(
|
||||
rootPath_/globalCase_/"processor"
|
||||
+ name(++nProcDirs)
|
||||
rootPath_/globalCase_
|
||||
/ ("processor" + Foam::name(++nProcDirs))
|
||||
)
|
||||
)
|
||||
{}
|
||||
@ -1341,27 +1348,32 @@ void Foam::argList::parse
|
||||
else
|
||||
{
|
||||
// Collect the master's argument list
|
||||
label nroots;
|
||||
|
||||
IPstream fromMaster
|
||||
(
|
||||
Pstream::commsTypes::scheduled,
|
||||
Pstream::masterNo()
|
||||
);
|
||||
fromMaster >> args_ >> options_ >> distributed_;
|
||||
fromMaster >> args_ >> options_ >> nroots;
|
||||
|
||||
parRunControl_.distributed(nroots);
|
||||
|
||||
// Establish rootPath_/globalCase_/case_ for slave
|
||||
getRootCase();
|
||||
setCasePaths();
|
||||
}
|
||||
|
||||
nProcs = Pstream::nProcs();
|
||||
case_ = globalCase_/(word("processor") + name(Pstream::myProcNo()));
|
||||
case_ = globalCase_/("processor" + Foam::name(Pstream::myProcNo()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Establish rootPath_/globalCase_/case_
|
||||
getRootCase();
|
||||
case_ = globalCase_;
|
||||
setCasePaths();
|
||||
case_ = globalCase_; // Redundant, but extra safety?
|
||||
}
|
||||
|
||||
|
||||
// Keep or discard slave and root information for reporting:
|
||||
if (Pstream::master() && parRunControl_.parRun())
|
||||
{
|
||||
@ -1618,7 +1630,9 @@ void Foam::argList::printUsage(bool full) const
|
||||
}
|
||||
|
||||
Info<< " -" << optName;
|
||||
label len = optName.size() + 3; // Length includes leading ' -'
|
||||
|
||||
// Length includes leading ' -'
|
||||
label len = optName.size() + 3;
|
||||
|
||||
const auto optIter = validOptions.cfind(optName);
|
||||
if (optIter().size())
|
||||
|
||||
@ -129,7 +129,7 @@ class argList
|
||||
static bool checkProcessorDirectories_;
|
||||
|
||||
//- Switch on/off parallel mode.
|
||||
// Must be first to be constructed so destructor is done last.
|
||||
// Construct first so destructor is done last.
|
||||
ParRunControl parRunControl_;
|
||||
|
||||
//- The arguments after removing known options
|
||||
@ -140,10 +140,11 @@ class argList
|
||||
|
||||
word executable_;
|
||||
fileName rootPath_;
|
||||
bool distributed_;
|
||||
fileName globalCase_;
|
||||
fileName case_;
|
||||
string argListStr_;
|
||||
|
||||
//- The command line options and arguments concatenated as a string
|
||||
string commandLine_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
@ -157,7 +158,7 @@ class argList
|
||||
//- Helper function for printUsage
|
||||
static void printOptionUsage
|
||||
(
|
||||
const label location,
|
||||
std::string::size_type start,
|
||||
const string& str
|
||||
);
|
||||
|
||||
@ -176,14 +177,14 @@ class argList
|
||||
template<class T>
|
||||
static inline void readList(ITstream& is, List<T>& list);
|
||||
|
||||
//- Get rootPath_ / globalCase_ from one of the following forms
|
||||
//- Set rootPath_, globalCase_, case_ from one of the following forms
|
||||
// * [-case dir]
|
||||
// * cwd
|
||||
//
|
||||
// Also export FOAM_CASE and FOAM_CASENAME environment variables
|
||||
// so they can be used immediately (eg, in decomposeParDict), as well
|
||||
// as the FOAM_EXECUTABLE environment.
|
||||
void getRootCase();
|
||||
void setCasePaths();
|
||||
|
||||
//- Transcribe argv into internal args_.
|
||||
// Transform sequences with "(" ... ")" into string lists
|
||||
@ -222,19 +223,17 @@ public:
|
||||
static SLList<string> notes;
|
||||
|
||||
//- Min offset for displaying usage (default: 20)
|
||||
static string::size_type usageMin;
|
||||
static std::string::size_type usageMin;
|
||||
|
||||
//- Max screen width for displaying usage (default: 80)
|
||||
static string::size_type usageMax;
|
||||
static std::string::size_type usageMax;
|
||||
|
||||
//- Standard name for the post-processing option
|
||||
static word postProcessOptionName;
|
||||
|
||||
//! \cond internalClass
|
||||
class initValidTables
|
||||
struct initValidTables
|
||||
{
|
||||
public:
|
||||
|
||||
initValidTables();
|
||||
};
|
||||
//! \endcond
|
||||
@ -274,12 +273,7 @@ public:
|
||||
|
||||
//- Scan for -help, -doc options etc prior to checking the validity
|
||||
//- of other args/opts and finally initialising.
|
||||
void parse
|
||||
(
|
||||
bool checkArgs,
|
||||
bool checkOpts,
|
||||
bool initialise
|
||||
);
|
||||
void parse(bool checkArgs, bool checkOpts, bool initialise);
|
||||
|
||||
|
||||
// Access
|
||||
@ -287,28 +281,33 @@ public:
|
||||
//- Name of executable without the path
|
||||
inline const word& executable() const;
|
||||
|
||||
//- The command line options and arguments concatenated as a string
|
||||
inline const string& commandLine() const;
|
||||
|
||||
//- Return root path
|
||||
inline const fileName& rootPath() const;
|
||||
|
||||
//- Return distributed flag
|
||||
//- (i.e. are rootPaths different on different machines)
|
||||
inline bool distributed() const;
|
||||
|
||||
//- Return case name (parallel run) or global case (serial run)
|
||||
inline const fileName& caseName() const;
|
||||
|
||||
//- Return global case name
|
||||
inline const fileName& globalCaseName() const;
|
||||
|
||||
//- Return parRunControl
|
||||
inline const ParRunControl& parRunControl() const;
|
||||
|
||||
//- Return the path to the caseName
|
||||
//- Return the full path to the (processor local) case
|
||||
// \note This is guaranteed to be an absolute path
|
||||
inline fileName path() const;
|
||||
|
||||
//- Return the path to the globalCaseName
|
||||
//- Return the full path to the global case
|
||||
// \note This is guaranteed to be an absolute path
|
||||
inline fileName globalPath() const;
|
||||
|
||||
//- Return distributed flag
|
||||
//- (i.e. are rootPaths different on different machines)
|
||||
inline bool distributed() const;
|
||||
|
||||
//- Return the ParRunControl
|
||||
inline const ParRunControl& parRunControl() const;
|
||||
|
||||
//- Return the number of arguments
|
||||
inline label size() const;
|
||||
|
||||
@ -398,7 +397,7 @@ public:
|
||||
(
|
||||
const word& optName,
|
||||
const string& usage = "",
|
||||
const bool advanced = false
|
||||
bool advanced = false
|
||||
);
|
||||
|
||||
//- Add an option to validOptions with usage information
|
||||
@ -408,9 +407,12 @@ public:
|
||||
const word& optName,
|
||||
const string& param = "",
|
||||
const string& usage = "",
|
||||
const bool advanced = false
|
||||
bool advanced = false
|
||||
);
|
||||
|
||||
//- Set an existing option as being 'advanced' or normal
|
||||
static void setAdvanced(const word& optName, bool advanced = true);
|
||||
|
||||
//- Specify an alias for the option name.
|
||||
//
|
||||
// \param optName the currently used option name
|
||||
@ -434,7 +436,7 @@ public:
|
||||
static void ignoreOptionCompat
|
||||
(
|
||||
std::pair<const char*,int> compat,
|
||||
const bool expectArg
|
||||
bool expectArg
|
||||
);
|
||||
|
||||
//- Add option usage information to optionUsage
|
||||
|
||||
@ -51,15 +51,15 @@ inline const Foam::word& Foam::argList::executable() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::fileName& Foam::argList::rootPath() const
|
||||
inline const Foam::string& Foam::argList::commandLine() const
|
||||
{
|
||||
return rootPath_;
|
||||
return commandLine_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::argList::distributed() const
|
||||
inline const Foam::fileName& Foam::argList::rootPath() const
|
||||
{
|
||||
return distributed_;
|
||||
return rootPath_;
|
||||
}
|
||||
|
||||
|
||||
@ -75,12 +75,6 @@ inline const Foam::fileName& Foam::argList::globalCaseName() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::ParRunControl& Foam::argList::parRunControl() const
|
||||
{
|
||||
return parRunControl_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::fileName Foam::argList::path() const
|
||||
{
|
||||
return rootPath()/caseName();
|
||||
@ -93,6 +87,18 @@ inline Foam::fileName Foam::argList::globalPath() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::argList::distributed() const
|
||||
{
|
||||
return parRunControl_.distributed();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::ParRunControl& Foam::argList::parRunControl() const
|
||||
{
|
||||
return parRunControl_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::argList::size() const
|
||||
{
|
||||
return args_.size();
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,18 +49,22 @@ namespace Foam
|
||||
|
||||
class ParRunControl
|
||||
{
|
||||
bool RunPar;
|
||||
bool parallel_;
|
||||
bool distributed_;
|
||||
|
||||
public:
|
||||
|
||||
//- Construct null
|
||||
ParRunControl()
|
||||
:
|
||||
RunPar(false)
|
||||
parallel_(false),
|
||||
distributed_(false)
|
||||
{}
|
||||
|
||||
//- Destructor, triggers Pstream::exit
|
||||
~ParRunControl()
|
||||
{
|
||||
if (RunPar)
|
||||
if (parallel_)
|
||||
{
|
||||
Info<< "Finalising parallel run" << endl;
|
||||
}
|
||||
@ -69,10 +73,11 @@ public:
|
||||
Pstream::exit(0);
|
||||
}
|
||||
|
||||
|
||||
//- Initialize Pstream for a parallel run
|
||||
void runPar(int& argc, char**& argv, const bool needsThread)
|
||||
void runPar(int& argc, char**& argv, bool needsThread)
|
||||
{
|
||||
RunPar = true;
|
||||
parallel_ = true;
|
||||
|
||||
if (!Pstream::init(argc, argv, needsThread))
|
||||
{
|
||||
@ -81,11 +86,22 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//- Is this a parallel run?
|
||||
//- True if this is parallel run.
|
||||
bool parRun() const
|
||||
{
|
||||
return RunPar;
|
||||
return parallel_;
|
||||
}
|
||||
|
||||
//- True if this is a parallel run and uses distributed roots.
|
||||
bool distributed() const
|
||||
{
|
||||
return parallel_ && distributed_;
|
||||
}
|
||||
|
||||
//- Set use of distributed roots.
|
||||
void distributed(bool on)
|
||||
{
|
||||
distributed_ = (parallel_ ? on : false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -135,12 +135,9 @@ Foam::dictionary& Foam::debug::switchSet
|
||||
{
|
||||
if (!subDictPtr)
|
||||
{
|
||||
entry* ePtr = controlDict().lookupEntryPtr
|
||||
(
|
||||
subDictName, false, false
|
||||
);
|
||||
entry* eptr = controlDict().findEntry(subDictName, keyType::LITERAL);
|
||||
|
||||
if (!ePtr || !ePtr->isDict())
|
||||
if (!eptr || !eptr->isDict())
|
||||
{
|
||||
cerr<< "debug::switchSet(const char*, dictionary*&):\n"
|
||||
<< " Cannot find " << subDictName << " in dictionary "
|
||||
@ -150,7 +147,7 @@ Foam::dictionary& Foam::debug::switchSet
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
subDictPtr = &ePtr->dict();
|
||||
subDictPtr = &(eptr->dict());
|
||||
}
|
||||
|
||||
return *subDictPtr;
|
||||
@ -179,7 +176,7 @@ int Foam::debug::debugSwitch(const char* name, const int defaultValue)
|
||||
{
|
||||
return debugSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
name, defaultValue, keyType::LITERAL
|
||||
);
|
||||
}
|
||||
|
||||
@ -188,7 +185,7 @@ int Foam::debug::infoSwitch(const char* name, const int defaultValue)
|
||||
{
|
||||
return infoSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
name, defaultValue, keyType::LITERAL
|
||||
);
|
||||
}
|
||||
|
||||
@ -197,7 +194,7 @@ int Foam::debug::optimisationSwitch(const char* name, const int defaultValue)
|
||||
{
|
||||
return optimisationSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
name, defaultValue, keyType::LITERAL
|
||||
);
|
||||
}
|
||||
|
||||
@ -210,7 +207,7 @@ float Foam::debug::floatOptimisationSwitch
|
||||
{
|
||||
return optimisationSwitches().lookupOrAddDefault
|
||||
(
|
||||
name, defaultValue, false, false
|
||||
name, defaultValue, keyType::LITERAL
|
||||
);
|
||||
}
|
||||
|
||||
@ -412,17 +409,17 @@ void listSwitches
|
||||
|
||||
wordHashSet controlDictDebug
|
||||
(
|
||||
controlDict.subDict("DebugSwitches").sortedToc()
|
||||
controlDict.subDict("DebugSwitches").toc()
|
||||
);
|
||||
|
||||
wordHashSet controlDictInfo
|
||||
(
|
||||
controlDict.subDict("InfoSwitches").sortedToc()
|
||||
controlDict.subDict("InfoSwitches").toc()
|
||||
);
|
||||
|
||||
wordHashSet controlDictOpt
|
||||
(
|
||||
controlDict.subDict("OptimisationSwitches").sortedToc()
|
||||
controlDict.subDict("OptimisationSwitches").toc()
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -50,8 +50,7 @@ namespace Foam
|
||||
"fileHandler",
|
||||
//Foam::fileOperations::uncollatedFileOperation::typeName,
|
||||
"uncollated",
|
||||
false,
|
||||
false
|
||||
keyType::LITERAL
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -367,8 +367,7 @@ Foam::fileOperations::masterUncollatedFileOperation::localObjectPath
|
||||
// Uncollated type, e.g. processor1
|
||||
const word procName
|
||||
(
|
||||
"processor"
|
||||
+Foam::name(Pstream::myProcNo(Pstream::worldComm))
|
||||
"processor" + Foam::name(Pstream::myProcNo(Pstream::worldComm))
|
||||
);
|
||||
return
|
||||
processorsPath
|
||||
|
||||
@ -92,9 +92,17 @@ fileName home();
|
||||
//- Return home directory path name for a particular user
|
||||
fileName home(const std::string& userName);
|
||||
|
||||
//- Return current working directory path name
|
||||
//- The physical or logical current working directory path name.
|
||||
// The behaviour is controlled by the \c cwd optimisation Switch
|
||||
// A value of 0 corresponds to the physical value, which is identical
|
||||
// to what getcwd and pwd -P would deliver.
|
||||
// A value of 1 corresponds to the logical value, which corresponds
|
||||
// to the PWD environment value and to what pwd -L would deliver.
|
||||
fileName cwd();
|
||||
|
||||
//- The physical or logical current working directory path name.
|
||||
fileName cwd(bool logical);
|
||||
|
||||
//- Change current directory to the one specified and return true on success.
|
||||
// Using an empty name is a no-op and always returns false.
|
||||
bool chDir(const fileName& dir);
|
||||
|
||||
@ -158,19 +158,19 @@ void Foam::interpolationLookUpTable<Type>::dimensionTable()
|
||||
|
||||
forAll(entries_,i)
|
||||
{
|
||||
dim_[i] = readLabel(entries_[i].lookup("N"));
|
||||
max_[i] = readScalar(entries_[i].lookup("max"));
|
||||
min_[i] = readScalar(entries_[i].lookup("min"));
|
||||
dim_[i] = entries_[i].template get<label>("N");
|
||||
max_[i] = entries_[i].template get<scalar>("max");
|
||||
min_[i] = entries_[i].template get<scalar>("min");
|
||||
delta_[i] = (max_[i] - min_[i])/dim_[i];
|
||||
tableDim *= dim_[i] + 1;
|
||||
fieldIndices_.insert(entries_[i].lookup("name"), index);
|
||||
fieldIndices_.insert(entries_[i].template get<word>("name"), index);
|
||||
entryIndices_[i] = index;
|
||||
index++;
|
||||
}
|
||||
|
||||
forAll(output_,i)
|
||||
{
|
||||
fieldIndices_.insert(output_[i].lookup("name"), index);
|
||||
fieldIndices_.insert(output_[i].template get<word>("name"), index);
|
||||
outputIndices_[i] = index;
|
||||
index++;
|
||||
}
|
||||
@ -284,7 +284,7 @@ Foam::interpolationLookUpTable<Type>::interpolationLookUpTable
|
||||
)
|
||||
:
|
||||
List<scalarField>(),
|
||||
fileName_(fileName(dict.lookup("file")).expand()),
|
||||
fileName_(dict.template get<fileName>("file").expand()),
|
||||
dim_(0),
|
||||
min_(0.0),
|
||||
delta_(0.0),
|
||||
|
||||
@ -33,10 +33,10 @@ template<class Type>
|
||||
Foam::csvTableReader<Type>::csvTableReader(const dictionary& dict)
|
||||
:
|
||||
tableReader<Type>(dict),
|
||||
headerLine_(readBool(dict.lookup("hasHeaderLine"))),
|
||||
timeColumn_(readLabel(dict.lookup("timeColumn"))),
|
||||
headerLine_(dict.get<bool>("hasHeaderLine")),
|
||||
timeColumn_(dict.get<label>("timeColumn")),
|
||||
componentColumns_(dict.lookup("valueColumns")),
|
||||
separator_(dict.lookupOrDefault<string>("separator", string(","))[0])
|
||||
separator_(dict.lookupOrDefault<string>("separator", ",")[0])
|
||||
{
|
||||
if (componentColumns_.size() != pTraits<Type>::nComponents)
|
||||
{
|
||||
|
||||
@ -94,14 +94,14 @@ Foam::uniformInterpolationTable<Type>::uniformInterpolationTable
|
||||
false // if used in BCs, could be used by multiple patches
|
||||
),
|
||||
List<scalar>(2, 0.0),
|
||||
x0_(readScalar(dict.lookup("x0"))),
|
||||
dx_(readScalar(dict.lookup("dx"))),
|
||||
x0_(dict.get<scalar>("x0")),
|
||||
dx_(dict.get<scalar>("dx")),
|
||||
log10_(dict.lookupOrDefault<Switch>("log10", false)),
|
||||
bound_(dict.lookupOrDefault<Switch>("bound", false))
|
||||
{
|
||||
if (initialiseOnly)
|
||||
{
|
||||
const scalar xMax = readScalar(dict.lookup("xMax"));
|
||||
const scalar xMax = dict.get<scalar>("xMax");
|
||||
const label nIntervals = static_cast<label>(xMax - x0_)/dx_ + 1;
|
||||
this->setSize(nIntervals);
|
||||
}
|
||||
|
||||
@ -338,12 +338,12 @@ void Foam::lduMatrix::setResidualField
|
||||
}
|
||||
|
||||
IOField<scalar>* residualPtr =
|
||||
lduMesh_.thisDb().lookupObjectRefPtr<IOField<scalar>>(lookupName);
|
||||
lduMesh_.thisDb().getObjectPtr<IOField<scalar>>(lookupName);
|
||||
|
||||
if (residualPtr)
|
||||
{
|
||||
const IOdictionary* dataPtr =
|
||||
lduMesh_.thisDb().lookupObjectPtr<IOdictionary>("data");
|
||||
lduMesh_.thisDb().findObject<IOdictionary>("data");
|
||||
|
||||
if (dataPtr)
|
||||
{
|
||||
|
||||
@ -43,8 +43,10 @@ Foam::word Foam::lduMatrix::preconditioner::getName
|
||||
{
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("preconditioner", false, false);
|
||||
// Handle primitive or dictionary entry
|
||||
const entry& e =
|
||||
solverControls.lookupEntry("preconditioner", keyType::LITERAL);
|
||||
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().readEntry("preconditioner", name);
|
||||
@ -67,8 +69,11 @@ Foam::lduMatrix::preconditioner::New
|
||||
{
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("preconditioner", false, false);
|
||||
// Handle primitive or dictionary entry
|
||||
|
||||
const entry& e =
|
||||
solverControls.lookupEntry("preconditioner", keyType::LITERAL);
|
||||
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().readEntry("preconditioner", name);
|
||||
|
||||
@ -43,8 +43,10 @@ Foam::lduMatrix::smoother::getName
|
||||
{
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("smoother", false, false);
|
||||
// Handle primitive or dictionary entry
|
||||
const entry& e =
|
||||
solverControls.lookupEntry("smoother", keyType::LITERAL);
|
||||
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().readEntry("smoother", name);
|
||||
@ -70,8 +72,10 @@ Foam::autoPtr<Foam::lduMatrix::smoother> Foam::lduMatrix::smoother::New
|
||||
{
|
||||
word name;
|
||||
|
||||
// handle primitive or dictionary entry
|
||||
const entry& e = solverControls.lookupEntry("smoother", false, false);
|
||||
// Handle primitive or dictionary entry
|
||||
const entry& e =
|
||||
solverControls.lookupEntry("smoother", keyType::LITERAL);
|
||||
|
||||
if (e.isDict())
|
||||
{
|
||||
e.dict().readEntry("smoother", name);
|
||||
|
||||
@ -50,7 +50,7 @@ Foam::dummyAgglomeration::dummyAgglomeration
|
||||
)
|
||||
:
|
||||
GAMGAgglomeration(mesh, controlDict),
|
||||
nLevels_(readLabel(controlDict.lookup("nLevels")))
|
||||
nLevels_(controlDict.get<label>("nLevels"))
|
||||
{
|
||||
const label nCoarseCells = mesh.lduAddr().size();
|
||||
|
||||
|
||||
@ -223,7 +223,7 @@ Foam::procFacesGAMGProcAgglomeration::procFacesGAMGProcAgglomeration
|
||||
)
|
||||
:
|
||||
GAMGProcAgglomeration(agglom, controlDict),
|
||||
nAgglomeratingCells_(readLabel(controlDict.lookup("nAgglomeratingCells")))
|
||||
nAgglomeratingCells_(controlDict.get<label>("nAgglomeratingCells"))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -35,9 +35,9 @@ namespace Foam
|
||||
|
||||
// List of sub-dictionaries to rewrite
|
||||
static const Foam::List<Foam::word> subDictNames
|
||||
{
|
||||
({
|
||||
"preconditioner", "smoother"
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
@ -74,7 +74,7 @@ void Foam::solution::read(const dictionary& dict)
|
||||
forAll(entryNames, i)
|
||||
{
|
||||
const word& e = entryNames[i];
|
||||
scalar value = readScalar(relaxDict.lookup(e));
|
||||
scalar value = relaxDict.get<scalar>(e);
|
||||
|
||||
if (e.startsWith("p"))
|
||||
{
|
||||
@ -184,14 +184,13 @@ Foam::label Foam::solution::upgradeSolverDict
|
||||
// 1) primitiveEntry w/o settings,
|
||||
// 2) or a dictionaryEntry.
|
||||
// transform primitiveEntry with settings -> dictionaryEntry
|
||||
forAll(subDictNames, dictI)
|
||||
for (const word& dictName : subDictNames)
|
||||
{
|
||||
const word& dictName = subDictNames[dictI];
|
||||
entry* ePtr = subdict.lookupEntryPtr(dictName,false,false);
|
||||
entry* eptr = subdict.findEntry(dictName, keyType::LITERAL);
|
||||
|
||||
if (ePtr && !ePtr->isDict())
|
||||
if (eptr && !eptr->isDict())
|
||||
{
|
||||
Istream& is = ePtr->stream();
|
||||
Istream& is = eptr->stream();
|
||||
is >> name;
|
||||
|
||||
if (!is.eof())
|
||||
@ -234,10 +233,8 @@ bool Foam::solution::cache(const word& name) const
|
||||
|
||||
return cache_.found(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -274,7 +271,7 @@ Foam::scalar Foam::solution::fieldRelaxationFactor(const word& name) const
|
||||
|
||||
if (fieldRelaxDict_.found(name))
|
||||
{
|
||||
return readScalar(fieldRelaxDict_.lookup(name));
|
||||
return fieldRelaxDict_.get<scalar>(name);
|
||||
}
|
||||
else if (fieldRelaxDefault_ > SMALL)
|
||||
{
|
||||
@ -303,7 +300,7 @@ Foam::scalar Foam::solution::equationRelaxationFactor(const word& name) const
|
||||
|
||||
if (eqnRelaxDict_.found(name))
|
||||
{
|
||||
return readScalar(eqnRelaxDict_.lookup(name));
|
||||
return eqnRelaxDict_.get<scalar>(name);
|
||||
}
|
||||
else if (eqnRelaxDefault_ > SMALL)
|
||||
{
|
||||
@ -327,12 +324,10 @@ const Foam::dictionary& Foam::solution::solutionDict() const
|
||||
{
|
||||
if (found("select"))
|
||||
{
|
||||
return subDict(word(lookup("select")));
|
||||
}
|
||||
else
|
||||
{
|
||||
return *this;
|
||||
return subDict(get<word>("select"));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -366,10 +361,8 @@ bool Foam::solution::read()
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -93,13 +93,13 @@ bool Foam::tolerances::relax(const word& name) const
|
||||
|
||||
Foam::scalar Foam::tolerances::relaxationFactor(const word& name) const
|
||||
{
|
||||
return readScalar(relaxationFactors_.lookup(name));
|
||||
return relaxationFactors_.get<scalar>(name);
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::tolerances::solverTolerance(const word& name) const
|
||||
{
|
||||
return readScalar(solverTolerances_.lookup(name));
|
||||
return solverTolerances_.get<scalar>(name);
|
||||
}
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ bool Foam::tolerances::solverRelativeTolerances() const
|
||||
|
||||
Foam::scalar Foam::tolerances::solverRelativeTolerance(const word& name) const
|
||||
{
|
||||
return readScalar(solverRelativeTolerances_.lookup(name));
|
||||
return solverRelativeTolerances_.get<scalar>(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -30,9 +30,10 @@ License
|
||||
|
||||
Foam::cellModel::cellModel(Istream& is)
|
||||
{
|
||||
dictionaryEntry dict(dictionary::null, is);
|
||||
const dictionaryEntry dictEntry(dictionary::null, is);
|
||||
const dictionary& dict = dictEntry.dict();
|
||||
|
||||
name_ = dict.keyword();
|
||||
name_ = dictEntry.keyword();
|
||||
dict.readEntry("index", index_);
|
||||
dict.readEntry("numberOfPoints", nPoints_);
|
||||
dict.readEntry("faces", faces_);
|
||||
|
||||
@ -109,8 +109,8 @@ Foam::processorPolyPatch::processorPolyPatch
|
||||
)
|
||||
:
|
||||
coupledPolyPatch(name, dict, index, bm, patchType),
|
||||
myProcNo_(readLabel(dict.lookup("myProcNo"))),
|
||||
neighbProcNo_(readLabel(dict.lookup("neighbProcNo"))),
|
||||
myProcNo_(dict.get<label>("myProcNo")),
|
||||
neighbProcNo_(dict.get<label>("neighbProcNo")),
|
||||
neighbFaceCentres_(),
|
||||
neighbFaceAreas_(),
|
||||
neighbFaceCellCentres_()
|
||||
|
||||
@ -146,12 +146,12 @@ Foam::polyPatch::polyPatch
|
||||
faceSubList
|
||||
(
|
||||
bm.mesh().faces(),
|
||||
readLabel(dict.lookup("nFaces")),
|
||||
readLabel(dict.lookup("startFace"))
|
||||
dict.get<label>("nFaces"),
|
||||
dict.get<label>("startFace")
|
||||
),
|
||||
bm.mesh().points()
|
||||
),
|
||||
start_(readLabel(dict.lookup("startFace"))),
|
||||
start_(dict.get<label>("startFace")),
|
||||
boundaryMesh_(bm),
|
||||
faceCellsPtr_(nullptr),
|
||||
mePtr_(nullptr)
|
||||
|
||||
@ -39,7 +39,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// template specialisation for pTraits<Scalar>
|
||||
// Template specialisation for pTraits<Scalar>
|
||||
template<>
|
||||
class pTraits<Scalar>
|
||||
{
|
||||
@ -403,6 +403,74 @@ inline Scalar stabilise(const Scalar s, const Scalar tol)
|
||||
}
|
||||
|
||||
|
||||
// Specializations
|
||||
|
||||
// Default definition in ops.H
|
||||
template<class T> struct compareOp;
|
||||
|
||||
//- Compare scalar values
|
||||
template<>
|
||||
struct compareOp<Scalar>
|
||||
{
|
||||
const Scalar tolerance;
|
||||
|
||||
//- Construct with specified tolerance (non-negative value)
|
||||
compareOp(Scalar tol = ScalarVSMALL)
|
||||
:
|
||||
tolerance(tol)
|
||||
{}
|
||||
|
||||
Scalar operator()(const Scalar& a, const Scalar& b) const
|
||||
{
|
||||
return (mag(a - b) <= tolerance) ? 0 : (a - b);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Default definition in ops.H
|
||||
template<class T> struct equalOp;
|
||||
|
||||
//- Compare scalar values for equality
|
||||
template<>
|
||||
struct equalOp<Scalar>
|
||||
{
|
||||
const Scalar tolerance;
|
||||
|
||||
//- Construct with specified tolerance (non-negative value)
|
||||
equalOp(Scalar tol = ScalarVSMALL)
|
||||
:
|
||||
tolerance(tol)
|
||||
{}
|
||||
|
||||
bool operator()(const Scalar& a, const Scalar& b) const
|
||||
{
|
||||
return Foam::mag(a - b) <= tolerance;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Default definition in ops.H
|
||||
template<class T> struct notEqualOp;
|
||||
|
||||
//- Compare scalar values for inequality
|
||||
template<>
|
||||
struct notEqualOp<Scalar>
|
||||
{
|
||||
const Scalar tolerance;
|
||||
|
||||
//- Construct with specified tolerance (non-negative value)
|
||||
notEqualOp(Scalar tol = ScalarVSMALL)
|
||||
:
|
||||
tolerance(tol)
|
||||
{}
|
||||
|
||||
bool operator()(const Scalar& a, const Scalar& b) const
|
||||
{
|
||||
return Foam::mag(a - b) > tolerance;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -242,11 +242,6 @@ public:
|
||||
//- Inner-product of this with another Tensor.
|
||||
inline Tensor<Cmpt> inner(const Tensor<Cmpt>& t2) const;
|
||||
|
||||
//- Inner-product of this with transpose of another Tensor.
|
||||
// Primarily useful for coordinate transformations
|
||||
// (where transpose is the same as the inverse).
|
||||
inline Tensor<Cmpt> innerT(const Tensor<Cmpt>& t2) const;
|
||||
|
||||
//- Schur-product of this with another Tensor.
|
||||
inline Tensor<Cmpt> schur(const Tensor<Cmpt>& t2) const;
|
||||
|
||||
|
||||
@ -504,29 +504,6 @@ Foam::Tensor<Cmpt>::inner(const Tensor<Cmpt>& t2) const
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Foam::Tensor<Cmpt>
|
||||
Foam::Tensor<Cmpt>::innerT(const Tensor<Cmpt>& t2) const
|
||||
{
|
||||
const Tensor<Cmpt>& t1 = *this;
|
||||
|
||||
return Tensor<Cmpt>
|
||||
(
|
||||
t1.xx()*t2.xx() + t1.xy()*t2.xy() + t1.xz()*t2.xz(),
|
||||
t1.xx()*t2.yx() + t1.xy()*t2.yy() + t1.xz()*t2.yz(),
|
||||
t1.xx()*t2.zx() + t1.xy()*t2.zy() + t1.xz()*t2.zz(),
|
||||
|
||||
t1.yx()*t2.xx() + t1.yy()*t2.xy() + t1.yz()*t2.xz(),
|
||||
t1.yx()*t2.yx() + t1.yy()*t2.yy() + t1.yz()*t2.yz(),
|
||||
t1.yx()*t2.zx() + t1.yy()*t2.zy() + t1.yz()*t2.zz(),
|
||||
|
||||
t1.zx()*t2.xx() + t1.zy()*t2.xy() + t1.zz()*t2.xz(),
|
||||
t1.zx()*t2.yx() + t1.zy()*t2.yy() + t1.zz()*t2.yz(),
|
||||
t1.zx()*t2.zx() + t1.zy()*t2.zy() + t1.zz()*t2.zz()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Foam::Tensor<Cmpt>
|
||||
Foam::Tensor<Cmpt>::schur(const Tensor<Cmpt>& t2) const
|
||||
|
||||
@ -156,11 +156,6 @@ public:
|
||||
//- Inner-product of this with another Tensor2D.
|
||||
inline Tensor2D<Cmpt> inner(const Tensor2D<Cmpt>& t2) const;
|
||||
|
||||
//- Inner-product of this with transpose of another Tensor2D.
|
||||
// Primarily useful for coordinate transformations
|
||||
// (where transpose is the same as the inverse).
|
||||
inline Tensor2D<Cmpt> innerT(const Tensor2D<Cmpt>& t2) const;
|
||||
|
||||
//- Schur-product of this with another Tensor2D.
|
||||
inline Tensor2D<Cmpt> schur(const Tensor2D<Cmpt>& t2) const;
|
||||
|
||||
|
||||
@ -202,23 +202,6 @@ Foam::Tensor2D<Cmpt>::inner(const Tensor2D<Cmpt>& t2) const
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Foam::Tensor2D<Cmpt>
|
||||
Foam::Tensor2D<Cmpt>::innerT(const Tensor2D<Cmpt>& t2) const
|
||||
{
|
||||
const Tensor2D<Cmpt>& t1 = *this;
|
||||
|
||||
return Tensor2D<Cmpt>
|
||||
(
|
||||
t1.xx()*t2.xx() + t1.xy()*t2.xy(),
|
||||
t1.xx()*t2.yx() + t1.xy()*t2.yy(),
|
||||
|
||||
t1.yx()*t2.xx() + t1.yy()*t2.xy(),
|
||||
t1.yx()*t2.yx() + t1.yy()*t2.yy()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
inline Foam::Tensor2D<Cmpt>
|
||||
Foam::Tensor2D<Cmpt>::schur(const Tensor2D<Cmpt>& t2) const
|
||||
|
||||
@ -209,12 +209,12 @@ Foam::Function1Types::CSV<Type>::CSV
|
||||
)
|
||||
:
|
||||
TableBase<Type>(entryName, dict),
|
||||
nHeaderLine_(readLabel(dict.lookup("nHeaderLine"))),
|
||||
refColumn_(readLabel(dict.lookup("refColumn"))),
|
||||
nHeaderLine_(dict.get<label>("nHeaderLine")),
|
||||
refColumn_(dict.get<label>("refColumn")),
|
||||
componentColumns_(dict.lookup("componentColumns")),
|
||||
separator_(dict.lookupOrDefault<string>("separator", string(","))[0]),
|
||||
mergeSeparators_(readBool(dict.lookup("mergeSeparators"))),
|
||||
fName_(fName != fileName::null ? fName : dict.lookup("file"))
|
||||
separator_(dict.lookupOrDefault<string>("separator", ",")[0]),
|
||||
mergeSeparators_(dict.get<bool>("mergeSeparators")),
|
||||
fName_(fName.empty() ? dict.get<fileName>("file") : fName)
|
||||
{
|
||||
if (componentColumns_.size() != pTraits<Type>::nComponents)
|
||||
{
|
||||
|
||||
@ -57,7 +57,7 @@ Foam::autoPtr<Foam::Function1<Type>> Foam::Function1<Type>::New
|
||||
}
|
||||
else
|
||||
{
|
||||
Istream& is(dict.lookup(entryName, false));
|
||||
Istream& is = dict.lookup(entryName); // non-recursive, allow patterns
|
||||
|
||||
token firstToken(is);
|
||||
word Function1Type;
|
||||
|
||||
@ -30,7 +30,7 @@ License
|
||||
void Foam::Function1Types::ramp::read(const dictionary& coeffs)
|
||||
{
|
||||
start_ = coeffs.lookupOrDefault<scalar>("start", 0);
|
||||
duration_ = coeffs.get<scalar>("duration");
|
||||
coeffs.readEntry("duration", duration_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -25,12 +25,9 @@ InNamespace
|
||||
Foam
|
||||
|
||||
Description
|
||||
Various binary and unary operations, which can be used for example,
|
||||
for parallel combine-reduce operations.
|
||||
|
||||
The information from all nodes is collected on the master node,
|
||||
combined using the given combination function and the result is
|
||||
broadcast to all nodes
|
||||
Various function objects for unary and binary operations.
|
||||
Can be used for parallel combine-reduce operations or other places
|
||||
requiring a function object.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -79,10 +76,10 @@ EqOp(eqMag, x = mag(y))
|
||||
EqOp(plusEqMagSqr, x += magSqr(y))
|
||||
EqOp(maxEq, x = max(x, y))
|
||||
EqOp(minEq, x = min(x, y))
|
||||
EqOp(minMagSqrEq, x = (magSqr(x)<=magSqr(y) ? x : y))
|
||||
EqOp(maxMagSqrEq, x = (magSqr(x)>=magSqr(y) ? x : y))
|
||||
EqOp(minMagSqrEq, x = (magSqr(x) <= magSqr(y) ? x : y))
|
||||
EqOp(maxMagSqrEq, x = (magSqr(x) >= magSqr(y) ? x : y))
|
||||
EqOp(andEq, x = (x && y))
|
||||
EqOp(orEq, x = (x || y))
|
||||
EqOp(orEq, x = (x || y))
|
||||
|
||||
EqOp(eqMinus, x = -y)
|
||||
|
||||
@ -134,9 +131,32 @@ EqOp(nopEq, (void)x)
|
||||
};
|
||||
|
||||
|
||||
// ...
|
||||
// Operations taking two parameters (unaltered), returning bool
|
||||
|
||||
#define weightedOp(opName, op) \
|
||||
#define BoolOp(opName, op) \
|
||||
\
|
||||
template<class T1, class T2> \
|
||||
struct opName##Op2 \
|
||||
{ \
|
||||
bool operator()(const T1& x, const T2& y) const WARNRETURN \
|
||||
{ \
|
||||
return op; \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
template<class T> \
|
||||
struct opName##Op \
|
||||
{ \
|
||||
bool operator()(const T& x, const T& y) const WARNRETURN \
|
||||
{ \
|
||||
return op; \
|
||||
} \
|
||||
};
|
||||
|
||||
|
||||
// Weighting operations
|
||||
|
||||
#define WeightedOp(opName, op) \
|
||||
\
|
||||
template<class T, class CombineOp> \
|
||||
class opName##WeightedOp \
|
||||
@ -178,21 +198,39 @@ Op(min, min(x, y))
|
||||
Op(minMagSqr, (magSqr(x)<=magSqr(y) ? x : y))
|
||||
Op(maxMagSqr, (magSqr(x)>=magSqr(y) ? x : y))
|
||||
Op(minMod, minMod(x, y))
|
||||
Op(and, x && y)
|
||||
Op(or, x || y)
|
||||
Op(eqEq, x == y)
|
||||
Op(less, x < y)
|
||||
Op(lessEq, x <= y)
|
||||
Op(greater, x > y)
|
||||
Op(greaterEq, x >= y)
|
||||
|
||||
weightedOp(multiply, (weight*y))
|
||||
BoolOp(and, x && y)
|
||||
BoolOp(or, x || y)
|
||||
BoolOp(equal, x == y)
|
||||
BoolOp(notEqual, x != y)
|
||||
BoolOp(less, x < y)
|
||||
BoolOp(lessEq, x <= y)
|
||||
BoolOp(greater, x > y)
|
||||
BoolOp(greaterEq, x >= y)
|
||||
|
||||
WeightedOp(multiply, (weight*y))
|
||||
|
||||
#undef Op
|
||||
#undef weightedOp
|
||||
#undef BoolOp
|
||||
#undef WeightedOp
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Three-way comparison operation of two parameters,
|
||||
// similar to the \c <=> operator in C++20.
|
||||
//
|
||||
// \return a negative value for less, a positive value for greater,
|
||||
// and zero for equal value.
|
||||
template<class T>
|
||||
struct compareOp
|
||||
{
|
||||
int operator()(const T& a, const T& b) const WARNRETURN
|
||||
{
|
||||
return (a < b) ? -1 : (b < a) ? 1 : 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//- General get operation to extract the 'name' from an object as a word.
|
||||
// The default implementation uses the 'name()' method commonly used within
|
||||
// OpenFOAM.
|
||||
|
||||
@ -209,15 +209,14 @@ Foam::fileName::Type Foam::fileName::type(const bool followLink) const
|
||||
|
||||
Foam::fileName& Foam::fileName::toAbsolute()
|
||||
{
|
||||
fileName& f = *this;
|
||||
|
||||
if (!f.isAbsolute())
|
||||
if (!isAbsolute(*this))
|
||||
{
|
||||
fileName& f = *this;
|
||||
f = cwd()/f;
|
||||
f.clean();
|
||||
}
|
||||
|
||||
return f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -426,13 +425,17 @@ Foam::fileName& Foam::fileName::operator/=(const string& other)
|
||||
{
|
||||
// Two non-empty strings: can concatenate
|
||||
|
||||
s.append("/");
|
||||
if (s.back() != '/' && other.front() != '/')
|
||||
{
|
||||
s += '/';
|
||||
}
|
||||
|
||||
s.append(other);
|
||||
}
|
||||
}
|
||||
else if (other.size())
|
||||
{
|
||||
// Or, if the first string is empty
|
||||
// The first string is empty
|
||||
s = other;
|
||||
}
|
||||
|
||||
@ -449,16 +452,23 @@ Foam::fileName Foam::operator/(const string& a, const string& b)
|
||||
if (b.size())
|
||||
{
|
||||
// Two non-empty strings: can concatenate
|
||||
return fileName(a + '/' + b);
|
||||
|
||||
if (a.back() == '/' || b.front() == '/')
|
||||
{
|
||||
return fileName(a + b);
|
||||
}
|
||||
else
|
||||
{
|
||||
return fileName(a + '/' + b);
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
return a; // The second string was empty
|
||||
}
|
||||
|
||||
// Or, if the first string is empty
|
||||
|
||||
if (b.size())
|
||||
{
|
||||
// The first string is empty
|
||||
return b;
|
||||
}
|
||||
|
||||
@ -471,9 +481,12 @@ Foam::fileName Foam::operator/(const string& a, const string& b)
|
||||
|
||||
Foam::fileName Foam::search(const word& file, const fileName& directory)
|
||||
{
|
||||
// Search the current directory for the file
|
||||
fileNameList files(fileHandler().readDir(directory, fileName::FILE));
|
||||
for (const fileName& item : files)
|
||||
// Search current directory for the file
|
||||
for
|
||||
(
|
||||
const fileName& item
|
||||
: fileHandler().readDir(directory, fileName::FILE)
|
||||
)
|
||||
{
|
||||
if (item == file)
|
||||
{
|
||||
@ -482,17 +495,20 @@ Foam::fileName Foam::search(const word& file, const fileName& directory)
|
||||
}
|
||||
|
||||
// If not found search each of the sub-directories
|
||||
fileNameList dirs(fileHandler().readDir(directory, fileName::DIRECTORY));
|
||||
for (const fileName& item : dirs)
|
||||
for
|
||||
(
|
||||
const fileName& item
|
||||
: fileHandler().readDir(directory, fileName::DIRECTORY)
|
||||
)
|
||||
{
|
||||
fileName path = search(file, directory/item);
|
||||
if (path != fileName::null)
|
||||
if (!path.empty())
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
return fileName::null;
|
||||
return fileName();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -157,7 +157,7 @@ public:
|
||||
);
|
||||
|
||||
//- This is a specialized (possibly slower) version of compare()
|
||||
// that ignores duplicate or trailing slashes.
|
||||
//- that ignores duplicate or trailing slashes.
|
||||
static bool equals(const std::string& s1, const std::string& s2);
|
||||
|
||||
|
||||
@ -229,14 +229,16 @@ public:
|
||||
//
|
||||
// Behaviour compared to /usr/bin/basename:
|
||||
// \verbatim
|
||||
// input name() basename
|
||||
// ----- ------ --------
|
||||
// "foo" "foo" "foo"
|
||||
// "/" "" "/"
|
||||
// "/foo" "foo" "foo"
|
||||
// "foo/bar" "bar" "bar"
|
||||
// "/foo/bar" "bar" "bar"
|
||||
// "/foo/bar/" "" "bar"
|
||||
// input name() basename
|
||||
// ----- ------ --------
|
||||
// "" "" ""
|
||||
// "abc" "abc" "abc"
|
||||
// "/" "" "/"
|
||||
// "/abc" "abc" "abc"
|
||||
// "abc/def" "def" "def"
|
||||
// "/abc/def" "def" "def"
|
||||
// "/abc/def/" "" "def"
|
||||
// "/abc/../def" "def" "def"
|
||||
// \endverbatim
|
||||
inline static std::string name(const std::string& str);
|
||||
|
||||
@ -261,16 +263,18 @@ public:
|
||||
//- Return directory path name (part before last /)
|
||||
// The result normally coresponds to a Foam::fileName
|
||||
//
|
||||
// Behaviour compared to /usr/bin/dirname:
|
||||
// \verbatim
|
||||
// Behaviour compared to /usr/bin/dirname:
|
||||
// \verbatim
|
||||
// input path() dirname
|
||||
// ----- ------ -------
|
||||
// "foo" "." "."
|
||||
// "" "." "."
|
||||
// "abc" "." "."
|
||||
// "/" "/" "/"
|
||||
// "/foo" "/" "foo"
|
||||
// "foo/bar" "foo" "foo"
|
||||
// "/foo/bar" "/foo" "/foo"
|
||||
// "/foo/bar/" "/foo/bar/" "/foo"
|
||||
// "/abc" "/" "/"
|
||||
// "abc/def" "abc" "abc"
|
||||
// "/abc/def" "/abc" "/abc"
|
||||
// "/abc/def/" "/abc/def" "/abc"
|
||||
// "/abc/../def" "/abc/.." "/abc/.."
|
||||
// \endverbatim
|
||||
inline static std::string path(const std::string& str);
|
||||
|
||||
@ -312,16 +316,18 @@ public:
|
||||
|
||||
//- Return path components as wordList
|
||||
//
|
||||
// Behaviour:
|
||||
// \verbatim
|
||||
// Input components()
|
||||
// ----- ------
|
||||
// "foo" ("foo")
|
||||
// "/foo" ("foo")
|
||||
// "foo/bar" ("foo", "bar")
|
||||
// "/foo/bar" ("foo", "bar")
|
||||
// "/foo/bar/" ("foo", "bar")
|
||||
// \endverbatim
|
||||
// Behaviour:
|
||||
// \verbatim
|
||||
// input components()
|
||||
// ----- ------------
|
||||
// "" ()
|
||||
// "." (".")
|
||||
// "abc" ("abc")
|
||||
// "/abc" ("abc")
|
||||
// "abc/def" ("abc", "def")
|
||||
// "/abc/def" ("abc", "def")
|
||||
// "/abc/def/" ("abc", "def")
|
||||
// \endverbatim
|
||||
wordList components(const char delimiter = '/') const;
|
||||
|
||||
//- Return a single component of the path
|
||||
|
||||
@ -140,7 +140,7 @@ inline bool Foam::fileName::isAbsolute(const std::string& str)
|
||||
|
||||
inline bool Foam::fileName::isAbsolute() const
|
||||
{
|
||||
return !empty() && operator[](0) == '/';
|
||||
return isAbsolute(*this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -82,6 +82,20 @@ public:
|
||||
static const keyType null;
|
||||
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration for search/match modes as bitmask
|
||||
// eg, (keyType::REGEX | keyType::RECURSIVE)
|
||||
enum option
|
||||
{
|
||||
LITERAL = 0, //!< String literal
|
||||
REGEX = 1, //!< Regular expression
|
||||
RECURSIVE = 0x10, //!< Recursive search (eg, in dictionary)
|
||||
LITERAL_RECURSIVE = (LITERAL | RECURSIVE),
|
||||
REGEX_RECURSIVE = (REGEX | RECURSIVE)
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
@ -100,19 +114,19 @@ public:
|
||||
inline keyType(const char* s);
|
||||
|
||||
//- Copy construct from std::string with specified treatment
|
||||
inline keyType(const std::string& s, const bool isPattern);
|
||||
inline keyType(const std::string& s, bool isPattern);
|
||||
|
||||
//- Move construct, retaining type (literal or regex)
|
||||
inline keyType(keyType&& s);
|
||||
|
||||
//- Move construct from word. Not treated as a regular expression
|
||||
//- Move construct from word, treat as literal.
|
||||
inline keyType(word&& s);
|
||||
|
||||
//- Move construct from string. Treat as regular expression.
|
||||
//- Move construct from string, treat as regular expression.
|
||||
inline keyType(string&& s);
|
||||
|
||||
//- Move construct from std::string with specified treatment
|
||||
inline keyType(std::string&& s, const bool isPattern);
|
||||
inline keyType(std::string&& s, bool isPattern);
|
||||
|
||||
//- Construct from Istream
|
||||
// Treat as regular expression if surrounded by quotation marks.
|
||||
|
||||
@ -77,7 +77,7 @@ inline Foam::keyType::keyType(const char* s)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::keyType::keyType(const std::string& s, const bool isPattern)
|
||||
inline Foam::keyType::keyType(const std::string& s, bool isPattern)
|
||||
:
|
||||
word(s, false),
|
||||
isPattern_(isPattern)
|
||||
@ -107,7 +107,7 @@ inline Foam::keyType::keyType(string&& s)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::keyType::keyType(std::string&& s, const bool isPattern)
|
||||
inline Foam::keyType::keyType(std::string&& s, bool isPattern)
|
||||
:
|
||||
word(std::move(s), false),
|
||||
isPattern_(isPattern)
|
||||
|
||||
@ -46,21 +46,30 @@ Foam::word Foam::string::ext() const
|
||||
return word::null;
|
||||
}
|
||||
|
||||
return substr(i+1, npos);
|
||||
return substr(i+1);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::string::ext(const Foam::word& ending)
|
||||
bool Foam::string::ext(const word& ending)
|
||||
{
|
||||
if (!ending.empty() && !empty() && operator[](size()-1) != '/')
|
||||
if (ending.empty() || empty() || back() == '/')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (ending[0] == '.')
|
||||
{
|
||||
if (ending.size() == 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
append(1u, '.');
|
||||
append(ending);
|
||||
|
||||
return true;
|
||||
}
|
||||
append(ending);
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -90,7 +99,7 @@ bool Foam::string::hasExt(const wordRe& ending) const
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::string end = substr(i+1, npos); // Compare *after* the dot
|
||||
const std::string end = substr(i+1); // Compare *after* the dot
|
||||
return ending.match(end);
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -437,7 +437,7 @@ Foam::string Foam::stringOps::getVariable
|
||||
{
|
||||
string value;
|
||||
|
||||
const entry* eptr = dict.lookupScopedEntryPtr(name, true, false);
|
||||
const entry* eptr = dict.findScoped(name, keyType::LITERAL_RECURSIVE);
|
||||
|
||||
if (eptr)
|
||||
{
|
||||
@ -720,20 +720,16 @@ void Foam::stringOps::inplaceExpand
|
||||
varBeg + 1 + delim,
|
||||
varEnd - varBeg - 2*delim
|
||||
),
|
||||
false
|
||||
false // Already validated
|
||||
);
|
||||
|
||||
|
||||
// Lookup in the dictionary without wildcards.
|
||||
// See note in primitiveEntry
|
||||
const entry* eptr = dict.lookupScopedEntryPtr
|
||||
(
|
||||
varName,
|
||||
true,
|
||||
false
|
||||
);
|
||||
const entry* eptr =
|
||||
dict.findScoped(varName, keyType::LITERAL_RECURSIVE);
|
||||
|
||||
// if defined - copy its entries
|
||||
// Copy its entries if defined
|
||||
if (eptr)
|
||||
{
|
||||
OStringStream buf;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -96,14 +96,14 @@ public:
|
||||
// Note that 'REGEX' is implicit if 'ICASE' is specified alone.
|
||||
enum compOption
|
||||
{
|
||||
LITERAL = 0, //!< Treat as a string literal
|
||||
DETECT = 1, //!< Detect if the string contains meta-characters
|
||||
UNKNOWN = 1, //!< Unknown content.
|
||||
REGEX = 2, //!< Treat as regular expression
|
||||
ICASE = 4, //!< Ignore case in regular expression
|
||||
NOCASE = 4, //!< \deprecated Alias for ICASE (deprecated APR-2018)
|
||||
LITERAL = 0, //!< String literal
|
||||
REGEX = 1, //!< Regular expression
|
||||
ICASE = 2, //!< Ignore case in regular expression
|
||||
NOCASE = 2, //!< \deprecated Alias for ICASE (deprecated APR-2018)
|
||||
DETECT = 4, //!< Detect if the string contains meta-characters
|
||||
UNKNOWN = 4, //!< Unknown content.
|
||||
REGEX_ICASE = (REGEX|ICASE), //!< Combined REGEX and ICASE
|
||||
DETECT_ICASE = (DETECT|ICASE), //!< Combined DETECT and ICASE
|
||||
REGEX_ICASE = (REGEX|ICASE) //!< Combined REGEX and ICASE
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ convectiveHeatTransferFvPatchScalarField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF, dict),
|
||||
L_(readScalar(dict.lookup("L")))
|
||||
L_(dict.get<scalar>("L"))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -77,8 +77,8 @@ lumpedMassWallTemperatureFvPatchScalarField
|
||||
:
|
||||
mixedFvPatchScalarField(p, iF),
|
||||
temperatureCoupledBase(patch(), dict),
|
||||
Cp_(readScalar(dict.lookup("Cp"))),
|
||||
mass_(readScalar(dict.lookup("mass"))),
|
||||
Cp_(dict.get<scalar>("Cp")),
|
||||
mass_(dict.get<scalar>("mass")),
|
||||
curTimeIndex_(-1)
|
||||
{
|
||||
refGrad() = 0.0;
|
||||
|
||||
@ -63,7 +63,7 @@ outletMachNumberPressureFvPatchScalarField
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF, dict),
|
||||
M_(dict.lookupOrDefault<scalar>("M", 0.0)),
|
||||
pBack_(readScalar(dict.lookup("pBack"))),
|
||||
pBack_(dict.get<scalar>("pBack")),
|
||||
c1_(dict.lookupOrDefault<scalar>("c1", 0.0)),
|
||||
A1_(dict.lookupOrDefault<scalar>("A1", 0.0)),
|
||||
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
|
||||
@ -165,7 +165,7 @@ void Foam::outletMachNumberPressureFvPatchScalarField::updateCoeffs()
|
||||
}
|
||||
|
||||
const fluidThermo* thermoPtr =
|
||||
db().lookupObjectPtr<fluidThermo>(basicThermo::dictName);
|
||||
db().findObject<fluidThermo>(basicThermo::dictName);
|
||||
|
||||
const volVectorField& U = db().lookupObject<volVectorField>(UName_);
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ outletMappedUniformInletHeatAdditionFvPatchField
|
||||
fixedValueFvPatchScalarField(p, iF, dict),
|
||||
outletPatchName_(dict.lookup("outletPatch")),
|
||||
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
|
||||
Q_(readScalar(dict.lookup("Q"))),
|
||||
Q_(dict.get<scalar>("Q")),
|
||||
TMin_(dict.lookupOrDefault<scalar>("TMin", 0)),
|
||||
TMax_(dict.lookupOrDefault<scalar>("TMax", 5000))
|
||||
{}
|
||||
|
||||
@ -240,7 +240,7 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
|
||||
|
||||
{
|
||||
const basicThermo* thermo =
|
||||
nbrMesh.lookupObjectPtr<basicThermo>(basicThermo::dictName);
|
||||
nbrMesh.findObject<basicThermo>(basicThermo::dictName);
|
||||
|
||||
if (thermo)
|
||||
{
|
||||
@ -269,7 +269,7 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
|
||||
// Local inertia therm
|
||||
{
|
||||
const basicThermo* thermo =
|
||||
mesh.lookupObjectPtr<basicThermo>(basicThermo::dictName);
|
||||
mesh.findObject<basicThermo>(basicThermo::dictName);
|
||||
|
||||
if (thermo)
|
||||
{
|
||||
|
||||
@ -175,7 +175,7 @@ alphatJayatillekeWallFunctionFvPatchScalarField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF, dict),
|
||||
Prt_(readScalar(dict.lookup("Prt"))), // force read to avoid ambiguity
|
||||
Prt_(dict.get<scalar>("Prt")), // force read to avoid ambiguity
|
||||
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
|
||||
E_(dict.lookupOrDefault<scalar>("E", 9.8))
|
||||
{
|
||||
|
||||
@ -161,10 +161,7 @@ Foam::LESModels::smoothDelta::smoothDelta
|
||||
),
|
||||
maxDeltaRatio_
|
||||
(
|
||||
readScalar
|
||||
(
|
||||
dict.optionalSubDict(type() + "Coeffs").lookup("maxDeltaRatio")
|
||||
)
|
||||
dict.optionalSubDict(type() + "Coeffs").get<scalar>("maxDeltaRatio")
|
||||
)
|
||||
{
|
||||
calcDelta();
|
||||
|
||||
@ -86,7 +86,7 @@ Foam::anisotropicFilter::anisotropicFilter
|
||||
LESfilter(mesh),
|
||||
widthCoeff_
|
||||
(
|
||||
readScalar(bd.optionalSubDict(type() + "Coeffs").lookup("widthCoeff"))
|
||||
bd.optionalSubDict(type() + "Coeffs").get<scalar>("widthCoeff")
|
||||
),
|
||||
coeff_
|
||||
(
|
||||
|
||||
@ -66,7 +66,7 @@ Foam::laplaceFilter::laplaceFilter(const fvMesh& mesh, const dictionary& bd)
|
||||
LESfilter(mesh),
|
||||
widthCoeff_
|
||||
(
|
||||
readScalar(bd.optionalSubDict(type() + "Coeffs").lookup("widthCoeff"))
|
||||
bd.optionalSubDict(type() + "Coeffs").get<scalar>("widthCoeff")
|
||||
),
|
||||
coeff_
|
||||
(
|
||||
|
||||
@ -78,7 +78,7 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField
|
||||
)
|
||||
:
|
||||
inletOutletFvPatchScalarField(p, iF),
|
||||
mixingLength_(readScalar(dict.lookup("mixingLength"))),
|
||||
mixingLength_(dict.get<scalar>("mixingLength")),
|
||||
kName_(dict.lookupOrDefault<word>("k", "k"))
|
||||
{
|
||||
this->phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
|
||||
@ -76,7 +76,7 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField
|
||||
)
|
||||
:
|
||||
inletOutletFvPatchScalarField(p, iF),
|
||||
mixingLength_(readScalar(dict.lookup("mixingLength"))),
|
||||
mixingLength_(dict.get<scalar>("mixingLength")),
|
||||
kName_(dict.lookupOrDefault<word>("k", "k"))
|
||||
{
|
||||
this->phiName_ = dict.lookupOrDefault<word>("phi", "phi");
|
||||
|
||||
@ -58,7 +58,7 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
|
||||
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
|
||||
D_(Function1<scalar>::New("D", dict)),
|
||||
I_(Function1<scalar>::New("I", dict)),
|
||||
length_(readScalar(dict.lookup("length"))),
|
||||
length_(dict.get<scalar>("length")),
|
||||
uniformJump_(dict.lookupOrDefault("uniformJump", false))
|
||||
{
|
||||
fvPatchField<scalar>::operator=
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user