diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 4153ec823aefec24b28d2cbebff4f38094c8bd88..59faf93c8697c6f96c4ee281d8e8e193d20c36f6 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -333,6 +333,29 @@ void Foam::Time::setControls() } +void Foam::Time::setMonitoring() +{ + // Time objects not registered so do like objectRegistry::checkIn ourselves. + if (runTimeModifiable_) + { + monitorPtr_.reset + ( + new fileMonitor + ( + regIOobject::fileModificationChecking == inotify + || regIOobject::fileModificationChecking == inotifyMaster + ) + ); + + // Monitor all files that controlDict depends on + addWatches(controlDict_, controlDict_.files()); + } + + // Clear dependent files - not needed now + controlDict_.files().clear(); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::Time::Time @@ -401,25 +424,7 @@ Foam::Time::Time readOpt() = IOobject::MUST_READ_IF_MODIFIED; setControls(); - - // Time objects not registered so do like objectRegistry::checkIn ourselves. - if (runTimeModifiable_) - { - monitorPtr_.reset - ( - new fileMonitor - ( - regIOobject::fileModificationChecking == inotify - || regIOobject::fileModificationChecking == inotifyMaster - ) - ); - - // Monitor all files that controlDict depends on - addWatches(controlDict_, controlDict_.files()); - } - - // Clear dependent files - controlDict_.files().clear(); + setMonitoring(); } @@ -495,25 +500,7 @@ Foam::Time::Time readOpt() = IOobject::MUST_READ_IF_MODIFIED; setControls(); - - // Time objects not registered so do like objectRegistry::checkIn ourselves. - if (runTimeModifiable_) - { - monitorPtr_.reset - ( - new fileMonitor - ( - regIOobject::fileModificationChecking == inotify - || regIOobject::fileModificationChecking == inotifyMaster - ) - ); - - // Monitor all files that controlDict depends on - addWatches(controlDict_, controlDict_.files()); - } - - // Clear dependent files since not needed - controlDict_.files().clear(); + setMonitoring(); } @@ -588,25 +575,7 @@ Foam::Time::Time controlDict_.readOpt() = IOobject::MUST_READ_IF_MODIFIED; setControls(); - - // Time objects not registered so do like objectRegistry::checkIn ourselves. - if (runTimeModifiable_) - { - monitorPtr_.reset - ( - new fileMonitor - ( - regIOobject::fileModificationChecking == inotify - || regIOobject::fileModificationChecking == inotifyMaster - ) - ); - - // Monitor all files that controlDict depends on - addWatches(controlDict_, controlDict_.files()); - } - - // Clear dependent files since not needed - controlDict_.files().clear(); + setMonitoring(); } @@ -667,6 +636,7 @@ Foam::Time::Time functionObjects_(*this, enableFunctionObjects) { libs_.open(controlDict_, "libs"); + setMonitoring(); // for profiling etc } diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index cac8f2e02e8dd7d7453ed4899dcc2dbe1f74c10d..24d7abee3f89fc2fdf7fbd4c4c227bec0f42ee92 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -181,6 +181,9 @@ protected: //- Set the controls from the current controlDict void setControls(); + //- Set file monitoring, profiling, etc + void setMonitoring(); + //- Read the control dictionary and set the write controls etc. virtual void readDict();