stringOpsEvaluate.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-2021 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 InNamespace
27  Foam::stringOps
28 
29 Description
30  String expression evaluation.
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef stringOpsEvaluate_H
35 #define stringOpsEvaluate_H
36 
37 #include "labelFwd.H"
38 #include "string.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 namespace stringOps
45 {
46  //- String evaluation with specified (positive, non-zero) field width
47  string evaluate
48  (
49  label fieldWidth,
50  const std::string& s,
51  size_t pos = 0,
52  size_t len = std::string::npos
53  );
54 
55  //- A simple string evaluation that handles various basic
56  //- expressions. For trivial input, use readScalar instead (faster).
57  //
58  // The evaluation supports the following:
59  // - operations: - + * / %
60  // - functions: exp, log, log10, pow, sqrt, cbrt, sqr, mag, magSqr
61  // - trigonometric: sin, cos, tan, asin, acos, atan, atan2, hypot
62  // - hyperbolic: sinh, cosh, tanh
63  // - conversions: degToRad, radToDeg
64  // - type conversion: bool, mag
65  // - constants: pi(), true, false
66  // - limits: neg, pos, neg0, pos0, sign, floor, ceil, round
67  // - other: rand, rand(seed)
68  // - logic: ! ? : == != <= => < >
69  //
70  // \note
71  // Unlike C/C++, the ternary and logical operations are \b not
72  // short-circuiting. So additional guards may be required.
73  //
74  // \note
75  // The rand() function returns a uniform scalar on [0-1] interval
76  // and uses a constant seed.
77  string evaluate
78  (
79  const std::string& s,
80  size_t pos = 0,
81  size_t len = std::string::npos
82  );
83 
84 } // End namespace stringOps
85 
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 
88 } // End namespace Foam
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 #endif
93 
94 // ************************************************************************* //
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputSpray.H:25
string.H
labelFwd.H
Typedefs for label/uLabel without requiring label.H.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
Definition: stringOpsEvaluate.C:37
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:177