scalarRanges.C
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) 2018-2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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\*---------------------------------------------------------------------------*/
27
28#include "scalarRanges.H"
29#include "stringOps.H"
30
31// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
32
34(
35 const std::string& str,
36 bool report
37)
38{
39 const SubStrings<std::string> items = stringOps::splitAny(str, " ,;");
40
41 scalarRanges ranges(items.size());
42
43 label n = 0;
44
45 for (const auto& item : items)
46 {
47 const std::string s(item.str());
48
49 scalarRange& range = ranges[n];
50
51 if (scalarRange::parse(s, range))
52 {
53 ++n;
54 }
55 else if (report)
56 {
57 Info<< "Bad scalar-range parsing: " << s << endl;
58 }
59 }
60
61 ranges.resize(n);
62
63 return ranges;
64}
65
66
67// ************************************************************************* //
scalar range
label n
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
Sub-ranges of a string with a structure similar to std::match_results, but without the underlying reg...
Definition: SubStrings.H:54
Scalar bounds to be used as a unary predicate.
Definition: scalarRange.H:69
A collection of scalar bounds to be used as a unary predicate.
Definition: scalarRanges.H:58
static scalarRanges parse(const std::string &str, bool report=true)
Construct by parsing string for scalar ranges.
Definition: scalarRanges.C:34
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))
Foam::SubStrings< StringType > splitAny(const StringType &str, const std::string &delim)
Split string into sub-strings using any characters in delimiter.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372