49int Foam::expressions::exprDriver::getSearchControls(
const dictionary&
dict)
75static string getEntryString
77 const dictionary&
dict,
81 const entry* eptr =
dict.findEntry(key, keyType::REGEX_RECURSIVE);
86 <<
"Entry " <<
key <<
" not found in "
90 else if (eptr->isDict())
93 <<
"Entry " <<
key <<
" found in "
94 <<
dict.name() <<
" but is a dictionary" <<
nl
98 return exprTools::expressionEntry::evaluate(*eptr);
113 const word& key = iter.key();
115 if (!dest.found(key))
118 func.cref(iter.val().shallowClone());
120 dest.emplace_set(key, std::move(
func));
148 auto& funcPtr = iter.val();
149 if (funcPtr && !funcPtr.is_const())
151 (*funcPtr).resetDb(obrPtr_);
156 auto& funcPtr = iter.val();
157 if (funcPtr && !funcPtr.is_const())
159 (*funcPtr).resetDb(obrPtr_);
187 timeStatePtr_(nullptr),
192 debugScanner_(
dict.getOrDefault(
"debug.scanner", false)),
193 debugParser_(
dict.getOrDefault(
"debug.parser", false)),
194 allowShadowing_(
dict.getOrDefault(
"allowShadowing", false)),
195 prevIterIsOldTime_(
dict.getOrDefault(
"prevIterIsOldTime", false)),
207 result_(rhs.result_),
208 variableStrings_(rhs.variableStrings_),
209 variables_(rhs.variables_),
212 contextObjects_(rhs.contextObjects_),
213 arg1Value_(rhs.arg1Value_),
214 timeStatePtr_(rhs.timeStatePtr_),
215 obrPtr_(rhs.obrPtr_),
219 debugScanner_(rhs.debugScanner_),
220 debugParser_(rhs.debugParser_),
221 allowShadowing_(rhs.allowShadowing_),
222 prevIterIsOldTime_(rhs.prevIterIsOldTime_),
224 searchCtrl_(rhs.searchCtrl_)
229 resetFunctions(
dict_);
258 return timeStatePtr_;
262 return &(obrPtr_->time());
272 return timeStatePtr_->value();
276 return obrPtr_->time().value();
286 return timeStatePtr_->deltaT().value();
290 return obrPtr_->time().deltaT().value();
301 dict.readIfPresent(
"debug.driver", debug);
304 variableStrings_ = readVariableStrings(
dict);
307 resetFunctions(
dict);
334 addVariables(variableStrings_,
false);
345 result_.testIfSingleValue();
348 <<
"Evaluating: " << expr <<
" -> " << varName <<
endl
390 const auto varExpressions =
391 stringOps::split<expressions::exprString>(expr,
';');
393 for (
const auto& subMatch : varExpressions)
406 const auto eqPos = varExpr.find(
'=');
408 if (eqPos == std::string::npos)
411 <<
"No '=' found in expression " << varExpr <<
nl <<
nl
418 expressions::exprString::toExpr
425 varExpr.resize(eqPos);
429 const auto lbrace = varExpr.find(
'{');
431 if (lbrace != std::string::npos)
433 const auto rbrace = varExpr.find(
'}');
435 if (rbrace == std::string::npos || rbrace < lbrace)
439 <<
"No closing '}' found in " << varExpr <<
nl
442 else if (lbrace+1 == rbrace)
446 <<
"Empty '{}' location in " << varExpr <<
nl
454 expressions::exprString::toExpr
456 varExpr.substr(lbrace+1, rbrace-lbrace-1)
462 evaluateVariableRemote(remoteExpr, varName, rhsExpr);
468 evaluateVariable(varName, rhsExpr);
485 for (
const auto& expr : list)
487 addVariables(expr,
false);
498 debugScanner_ = scannerDebug;
499 debugParser_ = parserDebug;
515 int val(searchCtrl_);
516 bool old = (val & searchControls::CACHE_READ_FIELDS);
521 val &= ~(searchControls::CACHE_READ_FIELDS);
529 searchControls::SEARCH_REGISTRY
530 | searchControls::SEARCH_FILES
531 | searchControls::CACHE_READ_FIELDS
548 if (caching || (val & searchControls::CACHE_READ_FIELDS))
553 searchControls::SEARCH_REGISTRY
554 | searchControls::SEARCH_FILES
555 | searchControls::CACHE_READ_FIELDS
562 <<
" registry:" << searchRegistry()
563 <<
" disk:" << searchFiles()
564 <<
" cache-read:" << cacheReadFields() <<
nl;
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
A HashTable similar to std::unordered_map.
The time value with time-stepping information, user-defined remapping, etc.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Base driver for parsing (field) values.
virtual void updateSpecialVariables(bool force=false)
Examine current variable values and update stored variables.
void clearResult()
Clear the result.
void addVariables(const expressions::exprString &expr, bool clear=true)
Add/set string expressions for variables.
const TimeState * timeState() const noexcept
Reference to the current time-state (can be nullptr)
void resetDb(const objectRegistry *obrPtr=nullptr)
Reset the objectRegistry (for functions)
HashTable< refPtr< Function1< scalar > > > scalarFuncs_
bool debugParser_
Request debugging for parser.
HashTable< refPtr< Function1< vector > > > vectorFuncs_
searchControls
Search/caching controls.
@ SEARCH_REGISTRY
Search registry before disk.
@ SEARCH_FILES
Search disk (eg, standalone app)
@ CACHE_READ_FIELDS
Cache fields read from disk.
virtual void evaluateVariableRemote(string remote, const word &varName, const expressions::exprString &expr)
bool debugScanner_
Request debugging for scanner.
virtual bool readDict(const dictionary &dict)
Read variables, tables etc.
virtual scalar deltaT() const
The current deltaT value.
const dictionary & dict_
The dictionary with all input data/specification.
searchControls searchCtrl_
Registry/disk/caching control.
void setDebugging(bool scannerDebug, bool parserDebug)
Set the scanner/parser debug.
void setSearchBehaviour(enum searchControls search, const bool caching=false)
virtual exprResult getRemoteResult(const exprDriver &other) const
Get the result from another driver.
virtual bool update()
Update things.
const exprResult & result() const noexcept
Const access to expression result.
void evaluateVariable(const word &varName, const expressions::exprString &expr)
void resetTimeReference(const TimeState *ts)
Reset the time-state reference.
virtual void clearVariables()
Clear temporary variables, reset from expression strings.
const dictionary & dict() const noexcept
The dictionary with all input data/specification.
virtual scalar timeValue() const
The current time value.
bool setCaching(bool on) noexcept
Toggle CACHE_READ_FIELDS control.
A polymorphic field/result from evaluating an expression.
exprResult getUniform(const label size, const bool noWarn, const bool parRun=Pstream::parRun()) const
Construct a uniform field from the current results.
virtual void validate()
Validate the turbulence fields after construction.
Registry of regIOobjects.
A class for managing references or pointers (no reference counting)
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
string trim(const std::string &s)
Return string trimmed of leading and trailing whitespace.
void inplaceTrim(std::string &s)
Trim leading and trailing whitespace inplace.
void func(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
static void shallowCloneFunctions(HashTable< refPtr< Function1< Type > > > &dest, const HashTable< refPtr< Function1< Type > > > &rhs)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManipArg< error, int > exit(error &err, const int errNo=1)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
constexpr char nl
The newline '\n' character (0x0a)
#define forAllIters(container, iter)
Iterate across all elements in the container object.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.