instant.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 | Copyright (C) 2011-2013 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 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
80 
82 {
83  is >> I.value_ >> I.name_;
84 
85  return is;
86 }
87 
88 
90 {
91  os << I.value_ << tab << I.name_;
92 
93  return os;
94 }
95 
96 
97 // ************************************************************************* //
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
static const sphericalTensor I(1)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A class for handling words, derived from string.
Definition: word.H:59
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:133
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
bool equal(const scalar) const
Comparison used for instants to be equal.
Definition: instant.C:59
bool operator!=(const particle &, const particle &)
Definition: particle.C:147
An instant of time. Contains the time value and name.
Definition: instant.H:64
static const char tab
Definition: Ostream.H:259
friend bool operator==(const instant &, const instant &)
static const char *const typeName
Definition: instant.H:89
instant()
Construct null.
Definition: instant.C:35
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:144
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
word timeName
Definition: getTimeIndex.H:3