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 * * * * * * * * * * * * * //
30
31inline void Foam::expressions::exprDriver::setArgument(scalar val) noexcept
32{
33 arg1Value_ = val;
34}
35
36
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
66)
67{
68 return variables_[name];
69}
70
71
72template<class Type>
74(
75 const word& name,
76 const Type& val
77)
78{
79 exprResult result;
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);
93
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 * * * * * * * * * * * * * //
114
116{
117 return stashedTokenId_;
118}
119
120
122(
123 int tokenId
124) const noexcept
125{
126 int old = stashedTokenId_;
127 stashedTokenId_ = tokenId;
128 return old;
129}
130
131
133{
134 return debugScanner_;
135}
136
137
139{
140 return debugParser_;
141}
142
143
145{
146 return (searchCtrl_ & searchControls::SEARCH_REGISTRY);
147}
148
149
151{
152 return (searchCtrl_ & searchControls::SEARCH_FILES);
153}
154
155
157{
158 return (searchCtrl_ & searchControls::CACHE_READ_FIELDS);
159}
160
161
162// ************************************************************************* //
void evaluate()
Evaluate boundary conditions.
bool searchFiles() const noexcept
Definition: exprDriverI.H:150
bool cacheReadFields() const noexcept
Definition: exprDriverI.H:156
bool debugParser() const noexcept
Read access to parser debug.
Definition: exprDriverI.H:138
bool searchRegistry() const noexcept
Definition: exprDriverI.H:144
bool debugScanner() const noexcept
Read access to scanner debug.
Definition: exprDriverI.H:132
Type evaluateUniform(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return a single value.
Definition: exprDriverI.H:101
scalar argValue() const noexcept
Get special-purpose scalar reference argument.
Definition: exprDriverI.H:37
int resetStashedTokenId(int tokenId=0) const noexcept
Reset "look-behind" parsing context (mutable operation)
Definition: exprDriverI.H:122
void setArgument(const scalar val) noexcept
Set special-purpose scalar reference argument.
Definition: exprDriverI.H:31
int stashedTokenId() const noexcept
Get "look-behind" parsing context (internal bookkeeping)
Definition: exprDriverI.H:115
virtual bool hasVariable(const word &name) const
True if named variable exists.
Definition: exprDriverI.H:44
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:211
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:127
void setSingleValue(const Type &val)
Set single-value uniform result.
Definition: exprResultI.H:423
const word & variable() const
Returns the variable on which the model is based.
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
const direction noexcept
Definition: Scalar.H:223
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59