OpenFOAM
v2406
The open source CFD toolbox
expressionEntryI.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) 2014-2018 Bernhard Gschaider
9
Copyright (C) 2019 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
#include "
OStringStream.H
"
30
31
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32
33
inline
Foam::string
34
Foam::exprTools::expressionEntry::evaluate
(
const
entry
&
e
)
35
{
36
return
e
.stream().toString();
37
}
38
39
40
template
<
class
Type>
41
inline
Foam::string
42
Foam::exprTools::expressionEntry::toExprStr
(
const
Type& data)
43
{
44
OStringStream
buf;
45
46
buf << pTraits<Type>::typeName <<
'('
;
47
for
(
direction
cmpt=0;
cmpt < pTraits<Type>::nComponents
; ++cmpt)
48
{
49
if
(cmpt) buf <<
','
;
50
buf <<
component
(data, cmpt);
51
}
52
buf <<
')'
;
53
54
return
buf.
str
();
55
}
56
57
58
template
<
class
Type>
59
inline
Foam::string
60
Foam::exprTools::expressionEntry::toExprStr
(
ITstream
& is)
61
{
62
Type data(
Zero
);
63
is >> data;
64
65
return
toExprStr<Type>(data);
66
}
67
68
69
// ************************************************************************* //
Foam::direction
uint8_t direction
Definition:
direction.H:46
Foam::expressions::Detail::nComponents
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
Definition:
exprTraits.C:40
Foam::exprTools::expressionEntry::evaluate
static string evaluate(const entry &e)
Generic concatenate tokens to space-separated string.
Definition:
expressionEntryI.H:27
Foam::OStringStream::str
Foam::string str() const
Get the string. As Foam::string instead of std::string (may change in future)
Definition:
StringStream.H:256
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition:
createFields.H:11
Foam::exprTools::expressionEntry::toExprStr
static string toExprStr(const Type &data)
Stringified version of data with comma-separated components. Uses prefix corresponding to the pTraits...
OStringStream.H
Foam::string
A class for handling character strings derived from std::string.
Definition:
string.H:72
Foam::component
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Definition:
FieldFieldFunctions.C:37
Foam::OStringStream
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Definition:
StringStream.H:208
Foam::ITstream
An input stream of tokens.
Definition:
ITstream.H:52
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition:
entry.H:63
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition:
zero.H:127
src
OpenFOAM
expressions
exprEntry
expressionEntryI.H
Generated by
1.8.14