mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: Function objects - updated to enable user time emtries, e.g. if using engineTime. Fixes #437
This commit is contained in:
@ -126,7 +126,8 @@ void Foam::timeControl::read(const dictionary& dict)
|
||||
case ocCpuTime:
|
||||
case ocAdjustableRunTime:
|
||||
{
|
||||
interval_ = readScalar(dict.lookup(intervalName));
|
||||
const scalar userTime = readScalar(dict.lookup(intervalName));
|
||||
interval_ = time_.userTimeToTime(userTime);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -43,8 +43,15 @@ namespace functionObjects
|
||||
|
||||
void Foam::functionObjects::timeControl::readControls()
|
||||
{
|
||||
dict_.readIfPresent("timeStart", timeStart_);
|
||||
dict_.readIfPresent("timeEnd", timeEnd_);
|
||||
if (dict_.readIfPresent("timeStart", timeStart_))
|
||||
{
|
||||
timeStart_ = time_.userTimeToTime(timeStart_);
|
||||
}
|
||||
if (dict_.readIfPresent("timeEnd", timeEnd_))
|
||||
{
|
||||
timeEnd_ = time_.userTimeToTime(timeEnd_);
|
||||
}
|
||||
|
||||
dict_.readIfPresent("nStepsToStartTimeChange", nStepsToStartTimeChange_);
|
||||
}
|
||||
|
||||
|
||||
@ -92,8 +92,8 @@ Foam::autoPtr<Foam::OFstream> Foam::functionObjects::writeFile::createFile
|
||||
|
||||
if (Pstream::master() && writeToFile_)
|
||||
{
|
||||
const word startTimeName =
|
||||
fileObr_.time().timeName(fileObr_.time().startTime().value());
|
||||
const scalar timeNow = fileObr_.time().timeOutputValue()
|
||||
const word startTimeName = Time::timeName(timeNow);
|
||||
|
||||
fileName outputDir(baseFileDir()/prefix_/startTimeName);
|
||||
|
||||
@ -105,7 +105,7 @@ Foam::autoPtr<Foam::OFstream> Foam::functionObjects::writeFile::createFile
|
||||
IFstream is(outputDir/(fName + ".dat"));
|
||||
if (is.good())
|
||||
{
|
||||
fName = fName + "_" + fileObr_.time().timeName();
|
||||
fName = fName + "_" + startTimeName;
|
||||
}
|
||||
|
||||
osPtr.set(new OFstream(outputDir/(fName + ".dat")));
|
||||
@ -258,7 +258,8 @@ void Foam::functionObjects::writeFile::writeHeader
|
||||
|
||||
void Foam::functionObjects::writeFile::writeTime(Ostream& os) const
|
||||
{
|
||||
os << setw(charWidth()) << fileObr_.time().timeName();
|
||||
const scalar timeNow = fileObr_.time().timeOutputValue()
|
||||
os << setw(charWidth()) << Time::timeName(timeNow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -176,8 +176,9 @@ bool Foam::functionObjects::blendingFactor::write()
|
||||
<< " blended cells : " << nCellsBlended << nl
|
||||
<< endl;
|
||||
|
||||
writeTime(file());
|
||||
|
||||
file()
|
||||
<< time_.time().value()
|
||||
<< token::TAB << nCellsScheme1
|
||||
<< token::TAB << nCellsScheme2
|
||||
<< token::TAB << nCellsBlended
|
||||
|
||||
@ -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-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -98,7 +98,7 @@ void Foam::functionObjects::fieldAverage::initialize()
|
||||
}
|
||||
}
|
||||
|
||||
// ensure first averaging works unconditionally
|
||||
// Ensure first averaging works unconditionally
|
||||
prevTimeIndex_ = -1;
|
||||
|
||||
Log << endl;
|
||||
@ -108,7 +108,8 @@ void Foam::functionObjects::fieldAverage::initialize()
|
||||
|
||||
void Foam::functionObjects::fieldAverage::restart()
|
||||
{
|
||||
Log << " Restarting averaging at time " << obr().time().timeName()
|
||||
Log << " Restarting averaging at time "
|
||||
<< obr().time().timeOutputValue()
|
||||
<< nl << endl;
|
||||
|
||||
totalIter_.clear();
|
||||
@ -221,7 +222,8 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
|
||||
|
||||
if (restartOnRestart_ || restartOnOutput_)
|
||||
{
|
||||
Info<< " Starting averaging at time " << obr().time().timeName()
|
||||
Info<< " Starting averaging at time "
|
||||
<< obr().time().timeOutputValue()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
@ -240,15 +242,18 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
|
||||
totalIter_[fieldi] = readLabel(fieldDict.lookup("totalIter"));
|
||||
totalTime_[fieldi] = readScalar(fieldDict.lookup("totalTime"));
|
||||
|
||||
scalar userTotalTime =
|
||||
obr().time().timeToUserTime(totalTime_[fieldi]);
|
||||
|
||||
Info<< " " << fieldName
|
||||
<< " iters = " << totalIter_[fieldi]
|
||||
<< " time = " << totalTime_[fieldi] << nl;
|
||||
<< " time = " << userTotalTime << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " " << fieldName
|
||||
<< ": starting averaging at time "
|
||||
<< obr().time().timeName() << endl;
|
||||
<< obr().time().timeOutputValue() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -312,7 +317,8 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
|
||||
if (periodicRestart_)
|
||||
{
|
||||
dict.lookup("restartPeriod") >> restartPeriod_;
|
||||
scalar userRestartPeriod = readScalar(dict.lookup("restartPeriod"));
|
||||
restartPeriod_ = obr().time().userTimeToTime(userRestartPeriod);
|
||||
|
||||
if (restartPeriod_ > 0)
|
||||
{
|
||||
@ -323,22 +329,25 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
++periodIndex_;
|
||||
}
|
||||
|
||||
Info<< " Restart period " << restartPeriod_
|
||||
<< " - next restart at " << (restartPeriod_*periodIndex_)
|
||||
Info<< " Restart period " << userRestartPeriod
|
||||
<< " - next restart at " << (userRestartPeriod*periodIndex_)
|
||||
<< nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
periodicRestart_ = false;
|
||||
|
||||
Info<< " Restart period " << restartPeriod_
|
||||
Info<< " Restart period " << userRestartPeriod
|
||||
<< " - ignored"
|
||||
<< nl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (dict.readIfPresent("restartTime", restartTime_))
|
||||
scalar userRestartTime = 0;
|
||||
if (dict.readIfPresent("restartTime", userRestartTime))
|
||||
{
|
||||
restartTime_ = obr().time().userTimeToTime(userRestartTime);
|
||||
|
||||
if (currentTime > restartTime_)
|
||||
{
|
||||
// The restart time is already in the past - ignore
|
||||
@ -346,7 +355,7 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " Restart scheduled at time " << restartTime_
|
||||
Info<< " Restart scheduled at time " << userRestartTime
|
||||
<< nl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,8 +269,9 @@ bool Foam::functionObjects::wallHeatFlux::write()
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeTime(file());
|
||||
|
||||
file()
|
||||
<< mesh_.time().value()
|
||||
<< token::TAB << pp.name()
|
||||
<< token::TAB << minHfp
|
||||
<< token::TAB << maxHfp
|
||||
|
||||
@ -249,7 +249,9 @@ bool Foam::functionObjects::wallShearStress::write()
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file() << mesh_.time().value()
|
||||
writeTime(file());
|
||||
|
||||
file()
|
||||
<< token::TAB << pp.name()
|
||||
<< token::TAB << minSsp
|
||||
<< token::TAB << maxSsp
|
||||
|
||||
@ -186,7 +186,7 @@ void Foam::functionObjects::forceCoeffs::writeBinData
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << obr_.time().value();
|
||||
writeTime(os);
|
||||
|
||||
for (label bini = 0; bini < nBin_; bini++)
|
||||
{
|
||||
|
||||
@ -593,8 +593,9 @@ void Foam::functionObjects::forces::writeIntegratedForceMoment
|
||||
{
|
||||
Ostream& os = osPtr();
|
||||
|
||||
os << obr_.time().value()
|
||||
<< tab << total
|
||||
writeTime(os);
|
||||
|
||||
os << tab << total
|
||||
<< tab << pressure
|
||||
<< tab << viscous;
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ void Foam::functionObjects::thermoCoupleProbes::sampleAndWrite
|
||||
|
||||
probeStream
|
||||
<< setw(w)
|
||||
<< vField.time().timeToUserTime(vField.time().value());
|
||||
<< vField.time().timeOutputValue();
|
||||
|
||||
forAll(*this, probeI)
|
||||
{
|
||||
|
||||
@ -45,7 +45,7 @@ void Foam::patchProbes::sampleAndWrite
|
||||
|
||||
probeStream
|
||||
<< setw(w)
|
||||
<< vField.time().timeToUserTime(vField.time().value());
|
||||
<< vField.time().timeOutputValue();
|
||||
|
||||
forAll(values, probei)
|
||||
{
|
||||
@ -71,7 +71,7 @@ void Foam::patchProbes::sampleAndWrite
|
||||
|
||||
probeStream
|
||||
<< setw(w)
|
||||
<< sField.time().timeToUserTime(sField.time().value());
|
||||
<< sField.time().timeOutputValue();
|
||||
|
||||
forAll(values, probei)
|
||||
{
|
||||
|
||||
@ -76,7 +76,7 @@ void Foam::probes::sampleAndWrite
|
||||
unsigned int w = IOstream::defaultPrecision() + 7;
|
||||
OFstream& os = *probeFilePtrs_[vField.name()];
|
||||
|
||||
os << setw(w) << vField.time().timeToUserTime(vField.time().value());
|
||||
os << setw(w) << vField.time().timeOutputValue();
|
||||
|
||||
forAll(values, probei)
|
||||
{
|
||||
@ -100,7 +100,7 @@ void Foam::probes::sampleAndWrite
|
||||
unsigned int w = IOstream::defaultPrecision() + 7;
|
||||
OFstream& os = *probeFilePtrs_[sField.name()];
|
||||
|
||||
os << setw(w) << sField.time().timeToUserTime(sField.time().value());
|
||||
os << setw(w) << sField.time().timeOutputValue();
|
||||
|
||||
forAll(values, probei)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user