Loading...
Searching...
No Matches
exprDriverI.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2010-2018 Bernhard Gschaider
9 Copyright (C) 2019-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31inline void Foam::expressions::exprDriver::setArgument(scalar val) noexcept
32{
33 arg1Value_ = val;
34}
35
37inline Foam::scalar Foam::expressions::exprDriver::argValue() const noexcept
38{
39 return arg1Value_;
40}
41
42
44(
45 const word& name
46) const
47{
48 return variables_.found(name);
49}
50
51
54(
55 const word& name
56) const
57{
58 return variables_[name];
59}
60
61
64(
65 const word& name
67{
68 return variables_[name];
69}
70
71
72template<class Type>
74(
75 const word& name,
76 const Type& val
77)
78{
80 result.setSingleValue(val);
81 variables_.set(name, std::move(result));
82}
83
84
85template<class Type>
87(
88 const expressions::exprString& expr,
89 bool wantPointData
90)
91{
92 parse(expr);
94 return getResult<Type>(wantPointData);
95}
96
97
98
99template<class Type>
101(
102 const expressions::exprString& expr,
103 bool wantPointData
104)
105{
106 parse(expr);
107
108 // noWarn = true
109 return result_.getUniform(1, true).cref<Type>().first();
110}
111
112
113// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
123 int tokenId
124) const noexcept
126 int old = stashedTokenId_;
127 stashedTokenId_ = tokenId;
128 return old;
129}
130
135}
136
139{
140 return debugParser_;
141}
142
147}
148
153}
154
155
157{
158 return (searchCtrl_ & searchControls::CACHE_READ_FIELDS);
159}
160
161
162// ************************************************************************* //
bool searchFiles() const noexcept
bool cacheReadFields() const noexcept
bool debugParser() const noexcept
Read access to parser debug.
exprResult result_
The result.
Definition exprDriver.H:201
virtual exprResult & variable(const word &name)
Non-const access to the named variable (sub-classes only).
Definition exprDriverI.H:57
bool searchRegistry() const noexcept
bool debugParser_
Request debugging for parser.
Definition exprDriver.H:261
@ SEARCH_REGISTRY
Search registry before disk.
Definition exprDriver.H:148
@ SEARCH_FILES
Search disk (eg, standalone app).
Definition exprDriver.H:149
@ CACHE_READ_FIELDS
Cache fields read from disk.
Definition exprDriver.H:150
tmp< Field< Type > > evaluate(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return the field.
bool debugScanner_
Request debugging for scanner.
Definition exprDriver.H:256
bool debugScanner() const noexcept
Read access to scanner debug.
Type evaluateUniform(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return a single value.
Definition exprDriverI.H:94
HashTable< exprResult > variables_
The variables table.
Definition exprDriver.H:211
searchControls searchCtrl_
Registry/disk/caching control.
Definition exprDriver.H:276
scalar argValue() const noexcept
Get special-purpose scalar reference argument.
Definition exprDriverI.H:30
int resetStashedTokenId(int tokenId=0) const noexcept
Reset "look-behind" parsing context (mutable operation).
void setArgument(const scalar val) noexcept
Set special-purpose scalar reference argument.
Definition exprDriverI.H:24
const exprResult & result() const noexcept
Const access to expression result.
Definition exprDriver.H:463
int stashedTokenId() const noexcept
Get "look-behind" parsing context (internal bookkeeping).
virtual bool hasVariable(const word &name) const
True if named variable exists.
Definition exprDriverI.H:37
virtual unsigned parse(const std::string &expr, size_t pos=0, size_t len=std::string::npos)=0
Execute the parser.
tmp< Field< Type > > getResult(bool wantPointData=false)
Return the expression result as a tmp field.
int stashedTokenId_
Internal bookkeeping as "look-behind" parsing context.
Definition exprDriver.H:251
void addUniformVariable(const word &name, const T &val)
Add a uniform variable from an outside caller.
scalar arg1Value_
Special-purpose scalar reference argument.
Definition exprDriver.H:233
A polymorphic field/result from evaluating an expression.
Definition exprResult.H:122
A variant of Foam::string with expansion of dictionary variables into a comma-separated form.
Definition exprString.H:58
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127