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 -------------------------------------------------------------------------------
11 License
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 
32 {
33  arg1Value_ = val;
34 }
35 
36 
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 
72 template<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 
85 template<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 
99 template<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 
133 {
134  return debugScanner_;
135 }
136 
139 {
140  return debugParser_;
141 }
142 
145 {
146  return (searchCtrl_ & searchControls::SEARCH_REGISTRY);
147 }
148 
151 {
152  return (searchCtrl_ & searchControls::SEARCH_FILES);
153 }
154 
155 
157 {
158  return (searchCtrl_ & searchControls::CACHE_READ_FIELDS);
159 }
160 
161 
162 // ************************************************************************* //
bool searchRegistry() const noexcept
Definition: exprDriverI.H:137
virtual bool hasVariable(const word &name) const
True if named variable exists.
Definition: exprDriverI.H:37
bool debugScanner() const noexcept
Read access to scanner debug.
Definition: exprDriverI.H:125
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:121
scalar arg1Value_
Special-purpose scalar reference argument.
Definition: exprDriver.H:233
void addUniformVariable(const word &name, const T &val)
Add a uniform variable from an outside caller.
void setArgument(const scalar val) noexcept
Set special-purpose scalar reference argument.
Definition: exprDriverI.H:24
Type evaluateUniform(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return a single value.
Definition: exprDriverI.H:94
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
int resetStashedTokenId(int tokenId=0) const noexcept
Reset "look-behind" parsing context (mutable operation)
Definition: exprDriverI.H:115
scalar argValue() const noexcept
Get special-purpose scalar reference argument.
Definition: exprDriverI.H:30
A class for handling words, derived from Foam::string.
Definition: word.H:63
A variant of Foam::string with expansion of dictionary variables into a comma-separated form...
Definition: exprString.H:55
int stashedTokenId() const noexcept
Get "look-behind" parsing context (internal bookkeeping)
Definition: exprDriverI.H:108
const direction noexcept
Definition: Scalar.H:258
bool debugParser() const noexcept
Read access to parser debug.
Definition: exprDriverI.H:131
void setSingleValue(const Type &val)
Set single-value uniform result.
Definition: exprResultI.H:392
bool cacheReadFields() const noexcept
Definition: exprDriverI.H:149
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual exprResult & variable(const word &name)
Non-const access to the named variable (sub-classes only)
Definition: exprDriverI.H:57
tmp< Field< Type > > evaluate(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return the field.
bool searchFiles() const noexcept
Definition: exprDriverI.H:143