evalEntry.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) 2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::functionEntries::evalEntry
28 
29 Description
30  Uses expressions::fieldExprDriver to evaluate mathematical expressions
31  with scalars, vectors etc.
32 
33  The input can any form of string or, for convenience,
34  a '{}' delimited string literal. In all cases, C/C++ comment stripping
35  is also performed.
36 
37  For example,
38 
39  \verbatim
40  a 1;
41  b 3;
42  c #eval "sin(pi()*$a/$b)";
43 
44  d #eval{
45  // ignore: sin(pi()*$a/$b)
46  sin(degToRad(45))
47  };
48  \endverbatim
49 
50 Note
51  The string expansions support use of environment variables.
52  Unknown variables will expand to an empty string, so it can be advisable
53  to an expansion with an alternative. For example,
54 
55  \verbatim
56  d #eval{ sin(degToRad( ${angle:-0} )) };
57  \endverbatim
58 
59 SourceFiles
60  evalEntry.C
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #ifndef evalEntry_H
65 #define evalEntry_H
66 
67 #include "functionEntry.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 namespace functionEntries
74 {
75 
76 /*---------------------------------------------------------------------------*\
77  Class evalEntry Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 class evalEntry
81 :
82  public functionEntry
83 {
84 
85  //- Evaluate and return a token list
86  static tokenList evaluate(const dictionary& parentDict, Istream& is);
87 
88 
89 public:
90 
91  //- Execute in a primitiveEntry context
92  static bool execute
93  (
94  const dictionary& parentDict,
95  primitiveEntry& thisEntry,
96  Istream& is
97  );
98 };
99 
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 } // End namespace functionEntries
104 } // End namespace Foam
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 #endif
109 
110 // ************************************************************************* //
Foam::primitiveEntry
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
Definition: primitiveEntry.H:62
functionEntry.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionEntry
A functionEntry causes entries to be added/manipulated on the specified dictionary given an input str...
Definition: functionEntry.H:65
Foam::functionEntries::evalEntry
Uses expressions::fieldExprDriver to evaluate mathematical expressions with scalars,...
Definition: evalEntry.H:79
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:102
Foam::functionEntries::evalEntry::execute
static bool execute(const dictionary &parentDict, primitiveEntry &thisEntry, Istream &is)
Execute in a primitiveEntry context.
Definition: evalEntry.C:168