helperFunctionsStringConversion.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "error.H"
30 
31 #include <sstream>
32 
33 //#define DEBUG_pMesh
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
39 
40 namespace help
41 {
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
44 
45 scalar textToScalar(const word& w)
46 {
47  std::stringstream ss;
48  ss << w;
49 
50  double s;
51  ss >> s;
52  return s;
53 }
54 
55 //- convert the text to label
57 {
58  return label(textToScalar(w));
59 }
60 
61 word scalarToText(const scalar s)
62 {
63  std::ostringstream ss;
64  ss << s;
65 
66  return ss.str();
67 }
68 
70 {
71  std::ostringstream ss;
72  ss << l;
73 
74  return ss.str();
75 }
76 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
78 
79 } // End namespace help
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *//
82 
83 } // End namespace Foam
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::help::textToScalar
scalar textToScalar(const word &w)
convert the text to scalar
Definition: helperFunctionsStringConversion.C:45
w
volScalarField w(IOobject("w", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE), mesh, dimensionedScalar("w", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0))
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::help::scalarToText
word scalarToText(const scalar s)
convert the scalar value into text
Definition: helperFunctionsStringConversion.C:61
Foam::help::textToLabel
label textToLabel(const word &w)
convert the text to label
Definition: helperFunctionsStringConversion.C:56
helperFunctionsStringConversion.H
String conversion functions.
Foam::help::labelToText
word labelToText(const label l)
convert the integer value into text
Definition: helperFunctionsStringConversion.C:69
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
error.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
s
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))