ENH: instant: quick time comparison

This commit is contained in:
mattijs
2013-09-09 15:33:43 +01:00
parent 3aacc8eb48
commit 98c75b8790
2 changed files with 16 additions and 9 deletions

View File

@ -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_);
}

View File

@ -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