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 
31 inline void Foam::expressions::exprDriver::setArgument(scalar val) noexcept
32 {
33  arg1Value_ = val;
34 }
35 
36 
37 inline 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 
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 
131 
133 {
134  return debugScanner_;
135 }
136 
137 
138 inline bool Foam::expressions::exprDriver::debugParser() const noexcept
139 {
140  return debugParser_;
141 }
142 
143 
145 {
146  return (searchCtrl_ & searchControls::SEARCH_REGISTRY);
147 }
148 
149 
150 inline bool Foam::expressions::exprDriver::searchFiles() const noexcept
151 {
152  return (searchCtrl_ & searchControls::SEARCH_FILES);
153 }
154 
155 
157 {
158  return (searchCtrl_ & searchControls::CACHE_READ_FIELDS);
159 }
160 
161 
162 // ************************************************************************* //
Foam::expressions::exprDriver::evaluateUniform
Type evaluateUniform(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return a single value.
Definition: exprDriverI.H:101
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::expressions::exprDriver::debugParser
bool debugParser() const noexcept
Read access to parser debug.
Definition: exprDriverI.H:138
Foam::expressions::exprDriver::stashedTokenId
int stashedTokenId() const noexcept
Get "look-behind" parsing context (internal bookkeeping)
Definition: exprDriverI.H:115
Foam::expressions::exprDriver::setArgument
void setArgument(const scalar val) noexcept
Set special-purpose scalar reference argument.
Definition: exprDriverI.H:31
Foam::expressions::exprDriver::hasVariable
virtual bool hasVariable(const word &name) const
True if named variable exists.
Definition: exprDriverI.H:44
Foam::expressions::exprDriver::argValue
scalar argValue() const noexcept
Get special-purpose scalar reference argument.
Definition: exprDriverI.H:37
Foam::expressions::exprResult
A polymorphic field/result from evaluating an expression.
Definition: exprResult.H:124
Foam::expressions::exprResult::setSingleValue
void setSingleValue(const Type &val)
Set single-value uniform result.
Definition: exprResultI.H:423
Foam::expressions::exprDriver::addUniformVariable
void addUniformVariable(const word &name, const T &val)
Add a uniform variable from an outside caller.
Foam::expressions::exprDriver::arg1Value_
scalar arg1Value_
Special-purpose scalar reference argument.
Definition: exprDriver.H:210
Foam::expressions::exprDriver::resetStashedTokenId
int resetStashedTokenId(int tokenId=0) const noexcept
Reset "look-behind" parsing context (mutable operation)
Definition: exprDriverI.H:122
Foam::expressions::exprDriver::variable
virtual exprResult & variable(const word &name)
Non-const access to the named variable (sub-classes only)
Definition: exprDriverI.H:64
Foam::expressions::exprDriver::searchRegistry
bool searchRegistry() const noexcept
Definition: exprDriverI.H:144
Foam::expressions::exprDriver::evaluate
tmp< Field< Type > > evaluate(const expressions::exprString &expr, bool wantPointData=false)
Evaluate the expression and return the field.
Foam::expressions::exprString
Definition: exprString.H:60
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::expressions::exprDriver::searchFiles
bool searchFiles() const noexcept
Definition: exprDriverI.H:150
Foam::expressions::exprDriver::cacheReadFields
bool cacheReadFields() const noexcept
Definition: exprDriverI.H:156
Foam::expressions::exprDriver::debugScanner
bool debugScanner() const noexcept
Read access to scanner debug.
Definition: exprDriverI.H:132