mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: reduce code duplication in Time.C
This commit is contained in:
@ -3,7 +3,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-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
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 * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::Time::Time
|
Foam::Time::Time
|
||||||
@ -401,25 +424,7 @@ Foam::Time::Time
|
|||||||
readOpt() = IOobject::MUST_READ_IF_MODIFIED;
|
readOpt() = IOobject::MUST_READ_IF_MODIFIED;
|
||||||
|
|
||||||
setControls();
|
setControls();
|
||||||
|
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
|
|
||||||
controlDict_.files().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -495,25 +500,7 @@ Foam::Time::Time
|
|||||||
readOpt() = IOobject::MUST_READ_IF_MODIFIED;
|
readOpt() = IOobject::MUST_READ_IF_MODIFIED;
|
||||||
|
|
||||||
setControls();
|
setControls();
|
||||||
|
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 since not needed
|
|
||||||
controlDict_.files().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -588,25 +575,7 @@ Foam::Time::Time
|
|||||||
controlDict_.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
|
controlDict_.readOpt() = IOobject::MUST_READ_IF_MODIFIED;
|
||||||
|
|
||||||
setControls();
|
setControls();
|
||||||
|
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 since not needed
|
|
||||||
controlDict_.files().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -667,6 +636,7 @@ Foam::Time::Time
|
|||||||
functionObjects_(*this, enableFunctionObjects)
|
functionObjects_(*this, enableFunctionObjects)
|
||||||
{
|
{
|
||||||
libs_.open(controlDict_, "libs");
|
libs_.open(controlDict_, "libs");
|
||||||
|
setMonitoring(); // for profiling etc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -181,6 +181,9 @@ protected:
|
|||||||
//- Set the controls from the current controlDict
|
//- Set the controls from the current controlDict
|
||||||
void setControls();
|
void setControls();
|
||||||
|
|
||||||
|
//- Set file monitoring, profiling, etc
|
||||||
|
void setMonitoring();
|
||||||
|
|
||||||
//- Read the control dictionary and set the write controls etc.
|
//- Read the control dictionary and set the write controls etc.
|
||||||
virtual void readDict();
|
virtual void readDict();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user