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

ENH: instant: quick time comparison

parent 3aacc8eb
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -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 * * * * * * * * * * * * * //
bool Foam::operator==(const instant& a, const instant& b)
{
return
(
a.value_ < b.value_ + SMALL
&& a.value_ > b.value_ - SMALL
);
return a.equal(b.value_);
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -99,10 +99,10 @@ public:
instant(const scalar, const word&);
//- Construct from time value
instant(const scalar);
explicit instant(const scalar);
//- Construct from word
instant(const word&);
explicit instant(const word&);
// Member Functions
......@@ -133,6 +133,9 @@ public:
return name_;
}
//- Comparison used for instants to be equal
bool equal(const scalar) const;
// 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