From 427bbd8174228297453cb5c5beaad1b80098b6ec Mon Sep 17 00:00:00 2001 From: henry Date: Tue, 20 Oct 2009 22:17:37 +0100 Subject: [PATCH] Changed the interface for the upToDate check to avoid unnecessary object lookups by providing the independent objects directly. --- .../test/fieldDependency/fieldDependency.C | 6 +-- src/OpenFOAM/db/regIOobject/regIOobject.C | 42 ++++++++++--------- src/OpenFOAM/db/regIOobject/regIOobject.H | 37 ++++++++++++---- 3 files changed, 54 insertions(+), 31 deletions(-) diff --git a/applications/test/fieldDependency/fieldDependency.C b/applications/test/fieldDependency/fieldDependency.C index fa3c7b2e86..65812996ba 100644 --- a/applications/test/fieldDependency/fieldDependency.C +++ b/applications/test/fieldDependency/fieldDependency.C @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) Info<< "p.eventNo:" << p.eventNo() << endl; - Info<< "p.uptodate:" << p.upToDate("T")<< endl; + Info<< "p.uptodate:" << p.upToDate(T)<< endl; // Change T and mark as uptodate. Info<< "Changing T" << endl; @@ -84,12 +84,12 @@ int main(int argc, char *argv[]) Info<< "T.eventNo:" << T.eventNo() << endl; // Check p dependency: - Info<< "p.uptodate:" << p.upToDate("T")<< endl; + Info<< "p.uptodate:" << p.upToDate(T)<< endl; // Change p and mark as uptodate. Info<< "Changing p." << endl; p.setUpToDate(); - Info<< "p.uptodate:" << p.upToDate("T")<< endl; + Info<< "p.uptodate:" << p.upToDate(T)<< endl; Info<< "p.eventNo:" << p.eventNo() << endl; diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.C b/src/OpenFOAM/db/regIOobject/regIOobject.C index 6e2682e199..543bee59e8 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.C +++ b/src/OpenFOAM/db/regIOobject/regIOobject.C @@ -173,9 +173,9 @@ bool Foam::regIOobject::checkOut() } -bool Foam::regIOobject::upToDate(const word& a) const +bool Foam::regIOobject::upToDate(const regIOobject& a) const { - if (db().lookupObject(a).eventNo() >= eventNo_) + if (a.eventNo() >= eventNo_) { return false; } @@ -186,12 +186,16 @@ bool Foam::regIOobject::upToDate(const word& a) const } -bool Foam::regIOobject::upToDate(const word& a, const word& b) const +bool Foam::regIOobject::upToDate +( + const regIOobject& a, + const regIOobject& b +) const { if ( - db().lookupObject(a).eventNo() >= eventNo_ - || db().lookupObject(b).eventNo() >= eventNo_ + a.eventNo() >= eventNo_ + || b.eventNo() >= eventNo_ ) { return false; @@ -205,16 +209,16 @@ bool Foam::regIOobject::upToDate(const word& a, const word& b) const bool Foam::regIOobject::upToDate ( - const word& a, - const word& b, - const word& c + const regIOobject& a, + const regIOobject& b, + const regIOobject& c ) const { if ( - db().lookupObject(a).eventNo() >= eventNo_ - || db().lookupObject(b).eventNo() >= eventNo_ - || db().lookupObject(c).eventNo() >= eventNo_ + a.eventNo() >= eventNo_ + || b.eventNo() >= eventNo_ + || c.eventNo() >= eventNo_ ) { return false; @@ -228,18 +232,18 @@ bool Foam::regIOobject::upToDate bool Foam::regIOobject::upToDate ( - const word& a, - const word& b, - const word& c, - const word& d + const regIOobject& a, + const regIOobject& b, + const regIOobject& c, + const regIOobject& d ) const { if ( - db().lookupObject(a).eventNo() >= eventNo_ - || db().lookupObject(b).eventNo() >= eventNo_ - || db().lookupObject(c).eventNo() >= eventNo_ - || db().lookupObject(d).eventNo() >= eventNo_ + a.eventNo() >= eventNo_ + || b.eventNo() >= eventNo_ + || c.eventNo() >= eventNo_ + || d.eventNo() >= eventNo_ ) { return false; diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H index d2c9a3dcbe..cae92919b2 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.H +++ b/src/OpenFOAM/db/regIOobject/regIOobject.H @@ -154,19 +154,38 @@ public: //- Event number at last update. inline label& eventNo(); - //- Am I uptodate with respect to other regIOobjects - bool upToDate(const word&) const; - bool upToDate(const word&, const word&) const; - bool upToDate(const word&, const word&, const word&) const; + //- Return true if up-to-date with respect to given object + // otherwise false + bool upToDate(const regIOobject&) const; + + //- Return true if up-to-date with respect to given objects + // otherwise false bool upToDate ( - const word&, - const word&, - const word&, - const word& + const regIOobject&, + const regIOobject& ) const; - //- Flag me as up to date + //- Return true if up-to-date with respect to given objects + // otherwise false + bool upToDate + ( + const regIOobject&, + const regIOobject&, + const regIOobject& + ) const; + + //- Return true if up-to-date with respect to given objects + // otherwise false + bool upToDate + ( + const regIOobject&, + const regIOobject&, + const regIOobject&, + const regIOobject& + ) const; + + //- Set up to date (obviously) void setUpToDate();