instant.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "instantList.H"
27 #include "Time.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 const char* const Foam::instant::typeName = "instant";
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 {}
37 
38 Foam::instant::instant(const scalar val, const word& tname)
39 :
40  value_(val),
41  name_(tname)
42 {}
43 
44 Foam::instant::instant(const scalar val)
45 :
46  value_(val),
47  name_(Time::timeName(val))
48 {}
49 
51 :
52  value_(atof(tname.c_str())),
53  name_(tname)
54 {}
55 
56 
57 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58 
59 bool Foam::instant::equal(const scalar b) const
60 {
61  return (value_ < b + small && value_ > b - small);
62 }
63 
64 
65 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
66 
67 bool Foam::operator==(const instant& a, const instant& b)
68 {
69  return a.equal(b.value_);
70 }
71 
72 
73 bool Foam::operator!=(const instant& a, const instant& b)
74 {
75  return !operator==(a, b);
76 }
77 
78 
79 bool Foam::operator<(const instant& a, const instant& b)
80 {
81  return a.value_ < b.value_;
82 }
83 
84 
85 bool Foam::operator>(const instant& a, const instant& b)
86 {
87  return a.value_ > b.value_;
88 }
89 
90 
91 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
92 
94 {
95  is >> I.value_ >> I.name_;
96 
97  return is;
98 }
99 
100 
102 {
103  os << I.value_ << tab << I.name_;
104 
105  return os;
106 }
107 
108 
109 // ************************************************************************* //
static const char tab
Definition: Ostream.H:264
bool operator<(const instant &, const instant &)
Definition: instant.C:79
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
static const Identity< scalar > I
Definition: Identity.H:93
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
A class for handling words, derived from string.
Definition: word.H:59
instant()
Construct null.
Definition: instant.C:35
Istream & operator>>(Istream &, directionInfo &)
word timeName
Definition: getTimeIndex.H:3
static const char *const typeName
Definition: instant.H:91
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
bool operator>(const instant &, const instant &)
Definition: instant.C:85
An instant of time. Contains the time value and name.
Definition: instant.H:66
Ostream & operator<<(Ostream &, const ensightPart &)
friend bool operator==(const instant &, const instant &)
bool operator!=(const particle &, const particle &)
Definition: particle.C:1150
bool equal(const scalar) const
Comparison used for instants to be equal.
Definition: instant.C:59