functionObjects: Fixes to restart and run-time modification behaviour

All function objects now re-read as a result of run-time modifications
to the system/controlDict.

Function objects that write log files (via the logFiles class) will now
generate a new postProcessing/<funcName>/<time> directory as a result of
either restart or run-time modification. Log files will therefore never
be overwritten by restart or run-time modification, except for when a
case is restarted at the same time as a previous execution (e.g.,
repeated runs at the start time).
This commit is contained in:
Will Bainbridge
2021-01-22 10:34:37 +00:00
parent 4e301e9227
commit 3ca14ebe58
24 changed files with 99 additions and 100 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -415,7 +415,6 @@ Foam::functionObjects::sizeDistribution::sizeDistribution
binCmpt_(0)
{
read(dict);
resetName(name);
switch (coordinateType_)
{
@ -466,6 +465,8 @@ bool Foam::functionObjects::sizeDistribution::read(const dictionary& dict)
geometric_ = dict.lookupOrDefault<Switch>("geometric", false);
maxOrder_ = dict.lookupOrDefault("maxOrder", 3);
resetName(name());
return false;
}

View File

@ -33,14 +33,13 @@ void Foam::functionObjects::logFiles::createFiles()
{
if (Pstream::master())
{
const word startTimeName =
fileObr_.time().timeName(fileObr_.time().startTime().value());
const word timeName = fileObr_.time().timeName();
forAll(names_, i)
{
if (!filePtrs_.set(i))
{
const fileName outputDir(baseFileDir()/prefix_/startTimeName);
const fileName outputDir(baseFileDir()/prefix_/timeName);
mkDir(outputDir);
filePtrs_.set(i, new OFstream(outputDir/(names_[i] + ".dat")));
initStream(filePtrs_[i]);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,19 +41,19 @@ namespace functionObjects
// * * * * * * * * * * * * * * * Private Members * * * * * * * * * * * * * * //
void Foam::functionObjects::timeControl::readControls()
void Foam::functionObjects::timeControl::readControls(const dictionary& dict)
{
if (!dict_.readIfPresent("startTime", startTime_))
if (!dict.readIfPresent("startTime", startTime_))
{
dict_.readIfPresent("timeStart", startTime_);
dict.readIfPresent("timeStart", startTime_);
}
if (!dict_.readIfPresent("endTime", endTime_))
if (!dict.readIfPresent("endTime", endTime_))
{
dict_.readIfPresent("timeEnd", endTime_);
dict.readIfPresent("timeEnd", endTime_);
}
dict_.readIfPresent("nStepsToStartTimeChange", nStepsToStartTimeChange_);
dict.readIfPresent("nStepsToStartTimeChange", nStepsToStartTimeChange_);
}
@ -76,7 +76,6 @@ Foam::functionObjects::timeControl::timeControl
:
functionObject(name),
time_(t),
dict_(dict),
startTime_(-vGreat),
endTime_(vGreat),
nStepsToStartTimeChange_
@ -85,9 +84,9 @@ Foam::functionObjects::timeControl::timeControl
),
executeControl_(t, dict, "execute"),
writeControl_(t, dict, "write"),
foPtr_(functionObject::New(name, t, dict_))
foPtr_(functionObject::New(name, t, dict))
{
readControls();
read(dict);
}
@ -174,32 +173,23 @@ Foam::scalar Foam::functionObjects::timeControl::timeToNextWrite()
}
bool Foam::functionObjects::timeControl::read
(
const dictionary& dict
)
bool Foam::functionObjects::timeControl::read(const dictionary& dict)
{
if (dict != dict_)
{
dict_ = dict;
writeControl_.read(dict);
executeControl_.read(dict);
readControls();
readControls(dict);
if (active())
{
foPtr_->read(dict);
}
return true;
}
else
{
return false;
}
}
void Foam::functionObjects::timeControl::updateMesh
(
const mapPolyMesh& mpm
)
void Foam::functionObjects::timeControl::updateMesh(const mapPolyMesh& mpm)
{
if (active())
{
@ -208,10 +198,7 @@ void Foam::functionObjects::timeControl::updateMesh
}
void Foam::functionObjects::timeControl::movePoints
(
const polyMesh& mesh
)
void Foam::functionObjects::timeControl::movePoints(const polyMesh& mesh)
{
if (active())
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -64,9 +64,6 @@ class timeControl
//- Reference to the time database
const Time& time_;
//- Input dictionary
dictionary dict_;
// Optional user inputs
@ -94,7 +91,7 @@ class timeControl
// Private Member Functions
//- Read relevant dictionary entries
void readControls();
void readControls(const dictionary& dict);
//- Returns true if within time bounds
bool active() const;
@ -127,9 +124,6 @@ public:
//- Return time database
inline const Time& time() const;
//- Return the input dictionary
inline const dictionary& dict() const;
//- Return the execute control object
inline const Foam::timeControl& executeControl() const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,12 +31,6 @@ inline const Foam::Time& Foam::functionObjects::timeControl::time() const
}
inline const Foam::dictionary& Foam::functionObjects::timeControl::dict() const
{
return dict_;
}
inline const Foam::timeControl&
Foam::functionObjects::timeControl::executeControl() const
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -110,7 +110,6 @@ Foam::functionObjects::fieldMinMax::fieldMinMax
fieldSet_()
{
read(dict);
resetName(typeName);
}
@ -131,6 +130,8 @@ bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
mode_ = modeTypeNames_[dict.lookupOrDefault<word>("mode", "magnitude")];
dict.lookup("fields") >> fieldSet_;
resetName(typeName);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -52,11 +52,11 @@ Foam::functionObjects::fieldValue::fieldValue
fvMeshFunctionObject(name, runTime, dict),
logFiles(obr_, name),
dict_(dict),
valueType_(valueType),
regionName_(word::null),
resultDict_(fileName("name"), dictionary::null)
{
read(dict);
resetName(valueType);
}
@ -71,11 +71,11 @@ Foam::functionObjects::fieldValue::fieldValue
fvMeshFunctionObject(name, obr, dict),
logFiles(obr_, name),
dict_(dict),
valueType_(valueType),
regionName_(word::null),
resultDict_(fileName("name"), dictionary::null)
{
read(dict);
resetName(valueType);
}
@ -99,6 +99,8 @@ bool Foam::functionObjects::fieldValue::read(const dictionary& dict)
dict.lookup("fields") >> fields_;
dict.lookup("writeFields") >> writeFields_;
resetName(valueType_);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,6 +73,9 @@ protected:
//- Construction dictionary
dictionary dict_;
//- The name of the type of value (volFieldValue, or surfaceFieldValue)
const word valueType_;
//- Name of region (patch, zone, etc.)
word regionName_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -113,7 +113,6 @@ Foam::functionObjects::fieldValues::fieldValueDelta::fieldValueDelta
region2Ptr_(nullptr)
{
read(dict);
resetName(typeName);
}
@ -155,6 +154,8 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::read
operation_ = operationTypeNames_.read(dict.lookup("operation"));
resetName(typeName);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -224,7 +224,6 @@ Foam::functionObjects::interfaceHeight::interfaceHeight
interpolationScheme_("cellPoint")
{
read(dict);
resetNames({"height", "position"});
}
@ -238,11 +237,15 @@ Foam::functionObjects::interfaceHeight::~interfaceHeight()
bool Foam::functionObjects::interfaceHeight::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
dict.readIfPresent("alpha", alphaName_);
dict.readIfPresent("liquid", liquid_);
dict.lookup("locations") >> locations_;
dict.readIfPresent("interpolationScheme", interpolationScheme_);
resetNames({"height", "position"});
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,8 +72,6 @@ Foam::functionObjects::turbulenceIntensity::turbulenceIntensity
writeLocalObjects(obr_, log)
{
read(dict);
resetName(typeName);
resetLocalObjectName("I");
}
@ -90,6 +88,9 @@ bool Foam::functionObjects::turbulenceIntensity::read(const dictionary& dict)
fvMeshFunctionObject::read(dict);
writeLocalObjects::read(dict);
resetName(typeName);
resetLocalObjectName("I");
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -120,8 +120,6 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
patchSet_()
{
read(dict);
resetName(typeName);
resetLocalObjectName(typeName);
}
@ -185,6 +183,9 @@ bool Foam::functionObjects::wallHeatFlux::read(const dictionary& dict)
patchSet_ = filteredPatchSet;
}
resetName(typeName);
resetLocalObjectName(typeName);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,15 +76,13 @@ Foam::functionObjects::wallHeatTransferCoeff::wallHeatTransferCoeff
fvMeshFunctionObject(name, runTime, dict),
logFiles(obr_, name),
writeLocalObjects(obr_, log),
coeffModel_(wallHeatTransferCoeffModel::New(dict.name(), mesh_, dict)),
rho_("rho", dimDensity, Zero),
Cp_("Cp", dimArea/sqr(dimTime)/dimTemperature, Zero),
runTime_(runTime),
patchSet_()
{
coeffModel_ = wallHeatTransferCoeffModel::New(dict.name(), mesh_, dict);
read(dict);
resetName(typeName);
resetLocalObjectName(typeName);
}
@ -162,6 +160,9 @@ bool Foam::functionObjects::wallHeatTransferCoeff::read(const dictionary& dict)
coeffModel_->read(dict);
resetName(typeName);
resetLocalObjectName(typeName);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -105,8 +105,6 @@ Foam::functionObjects::wallShearStress::wallShearStress
patchSet_()
{
read(dict);
resetName(typeName);
resetLocalObjectName(typeName);
}
@ -170,6 +168,9 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
patchSet_ = filteredPatchSet;
}
resetName(typeName);
resetLocalObjectName(typeName);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -138,8 +138,6 @@ Foam::functionObjects::yPlus::yPlus
phaseName_(dict.lookupOrDefault<word>("phase", word::null))
{
read(dict);
resetName(IOobject::groupName(typeName, phaseName_));
resetLocalObjectName(IOobject::groupName(typeName, phaseName_));
}
@ -156,6 +154,9 @@ bool Foam::functionObjects::yPlus::read(const dictionary& dict)
fvMeshFunctionObject::read(dict);
writeLocalObjects::read(dict);
resetName(IOobject::groupName(typeName, phaseName_));
resetLocalObjectName(IOobject::groupName(typeName, phaseName_));
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -559,7 +559,6 @@ Foam::functionObjects::forces::forces
initialised_(false)
{
read(dict);
resetNames(createFileNames(dict));
}
@ -594,7 +593,6 @@ Foam::functionObjects::forces::forces
initialised_(false)
{
read(dict);
resetNames(createFileNames(dict));
}
@ -739,6 +737,8 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
moment_[2].setSize(1);
}
resetNames(createFileNames(dict));
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -87,8 +87,6 @@ bool Foam::functionObjects::cloudInfo::read(const dictionary& dict)
{
regionFunctionObject::read(dict);
logFiles::resetNames(dict.lookup("clouds"));
Info<< type() << " " << name() << ": ";
if (names().size())
{
@ -104,6 +102,8 @@ bool Foam::functionObjects::cloudInfo::read(const dictionary& dict)
Info<< "no clouds to be processed" << nl << endl;
}
resetNames(dict.lookup("clouds"));
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,7 +58,6 @@ Foam::functionObjects::residuals::residuals
fieldSet_()
{
read(dict);
resetName(typeName);
}
@ -76,6 +75,8 @@ bool Foam::functionObjects::residuals::read(const dictionary& dict)
dict.lookup("fields") >> fieldSet_;
resetName(typeName);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -61,8 +61,6 @@ Foam::functionObjects::time::time
clockTime0_(time_.elapsedClockTime())
{
read(dict);
resetName(typeName);
write();
}
@ -80,6 +78,8 @@ bool Foam::functionObjects::time::read(const dictionary& dict)
dict.readIfPresent("perTimeStep", perTimeStep_);
resetName(typeName);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,7 +58,6 @@ Foam::functionObjects::timeStep::timeStep
logFiles(obr_, name)
{
read(dict);
resetName(typeName);
}
@ -74,6 +73,8 @@ bool Foam::functionObjects::timeStep::read(const dictionary& dict)
{
functionObject::read(dict);
resetName(typeName);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2019-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -61,7 +61,6 @@ Foam::functionObjects::rigidBodyState::rigidBodyState
names_(motion().movingBodyNames())
{
read(dict);
resetNames(names_);
}
@ -86,8 +85,11 @@ Foam::functionObjects::rigidBodyState::motion() const
bool Foam::functionObjects::rigidBodyState::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
angleFormat_ = dict.lookupOrDefault<word>("angleFormat", "radians");
resetNames(names_);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -60,7 +60,6 @@ Foam::functionObjects::sixDoFRigidBodyControl::sixDoFRigidBodyControl
meanAngularVelocity_(Zero)
{
read(dict);
resetName(typeName);
}
@ -80,6 +79,8 @@ bool Foam::functionObjects::sixDoFRigidBodyControl::read(const dictionary& dict)
dict.lookup("convergedVelocity") >> convergedVelocity_;
dict.lookup("convergedAngularVelocity") >> convergedAngularVelocity_;
resetName(typeName);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -60,7 +60,6 @@ Foam::functionObjects::sixDoFRigidBodyState::sixDoFRigidBodyState
logFiles(obr_, name)
{
read(dict);
resetName(typeName);
}
@ -75,8 +74,11 @@ Foam::functionObjects::sixDoFRigidBodyState::~sixDoFRigidBodyState()
bool Foam::functionObjects::sixDoFRigidBodyState::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
angleFormat_ = dict.lookupOrDefault<word>("angleFormat", "radians");
resetName(typeName);
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -89,7 +89,7 @@ Foam::functionObjects::specieReactionRates::specieReactionRates
)
)
{
resetName("specieReactionRates");
read(dict);
}
@ -103,7 +103,9 @@ Foam::functionObjects::specieReactionRates::~specieReactionRates()
bool Foam::functionObjects::specieReactionRates::read(const dictionary& dict)
{
regionFunctionObject::read(dict);
fvMeshFunctionObject::read(dict);
resetName("specieReactionRates");
return true;
}