Commit 98c75b87 authored by mattijs's avatar mattijs
Browse files

ENH: instant: quick time comparison

parent 3aacc8eb
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -54,15 +54,19 @@ Foam::instant::instant(const word& tname) ...@@ -54,15 +54,19 @@ Foam::instant::instant(const word& tname)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::instant::equal(const scalar b) const
{
return (value_ < b + SMALL && value_ > b - SMALL);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
bool Foam::operator==(const instant& a, const instant& b) bool Foam::operator==(const instant& a, const instant& b)
{ {
return return a.equal(b.value_);
(
a.value_ < b.value_ + SMALL
&& a.value_ > b.value_ - SMALL
);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -99,10 +99,10 @@ public: ...@@ -99,10 +99,10 @@ public:
instant(const scalar, const word&); instant(const scalar, const word&);
//- Construct from time value //- Construct from time value
instant(const scalar); explicit instant(const scalar);
//- Construct from word //- Construct from word
instant(const word&); explicit instant(const word&);
// Member Functions // Member Functions
...@@ -133,6 +133,9 @@ public: ...@@ -133,6 +133,9 @@ public:
return name_; return name_;
} }
//- Comparison used for instants to be equal
bool equal(const scalar) const;
// Friend Operators // Friend Operators
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment