From 15aec3649e3be619000044fffb2c02d6f5bcfb5a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 17 Mar 2017 09:09:31 +0100 Subject: [PATCH 1/6] BUG: incorrect patch lookup in ensight conversion (fixes #430) --- src/conversion/ensight/output/ensightOutputTemplates.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conversion/ensight/output/ensightOutputTemplates.C b/src/conversion/ensight/output/ensightOutputTemplates.C index 65ce0098af..2689c12664 100644 --- a/src/conversion/ensight/output/ensightOutputTemplates.C +++ b/src/conversion/ensight/output/ensightOutputTemplates.C @@ -254,7 +254,7 @@ bool Foam::ensightOutput::writeField forAll(patchIds, listi) { const label patchId = patchIds[listi]; - const word& patchName = patchLookup[listi]; + const word& patchName = patchLookup[patchId]; const ensightFaces& ensFaces = patchFaces[patchName]; writeFaceField From cf1df0542f7032fcbe9433809fa4ccd7b82ec8fd Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 21 Mar 2017 13:23:52 +0000 Subject: [PATCH 2/6] BUG: wallHeatFlux FO - corrected output of header info tofile. Fixes #435 --- src/functionObjects/field/wallHeatFlux/wallHeatFlux.C | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C index ad9e4d832c..dcb4c5c7ff 100644 --- a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C +++ b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C @@ -122,6 +122,8 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux mesh_.objectRegistry::store(wallHeatFluxPtr); read(dict); + + writeFileHeader(file()); } From 6ebaa63d1cd5c5e569fc028c64b8a0d472cdee5a Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 21 Mar 2017 13:27:47 +0000 Subject: [PATCH 3/6] BUG: forceCoeffs - corrected handling of pDyn for compressible cases. Fixes #436 --- src/functionObjects/forces/forceCoeffs/forceCoeffs.C | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index f4abd527f7..03bac52926 100644 --- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.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-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -250,6 +250,14 @@ bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict) // Free stream velocity magnitude dict.lookup("magUInf") >> magUInf_; + // If case is compressible we must read rhoInf (store in rhoRef_) to + // calculate the reference dynamic pressure + // - note: for incompressible, rhoRef_ is already initialised + if (rhoName_ != "rhoInf") + { + dict.lookup("rhoInf") >> rhoRef_; + } + // Reference length and area scales dict.lookup("lRef") >> lRef_; dict.lookup("Aref") >> Aref_; From 69bc13f30074225e88234659a5117faa2a422b9f Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 21 Mar 2017 13:32:55 +0000 Subject: [PATCH 4/6] BUG: Function objects - updated to enable user time emtries, e.g. if using engineTime. Fixes #437 --- .../functionObjects/timeControl/timeControl.C | 3 +- .../timeControl/timeControlFunctionObject.C | 11 +++++-- .../db/functionObjects/writeFile/writeFile.C | 9 ++--- .../field/blendingFactor/blendingFactor.C | 3 +- .../field/fieldAverage/fieldAverage.C | 33 ++++++++++++------- .../field/wallHeatFlux/wallHeatFlux.C | 3 +- .../field/wallShearStress/wallShearStress.C | 4 ++- .../forces/forceCoeffs/forceCoeffs.C | 2 +- src/functionObjects/forces/forces/forces.C | 5 +-- .../thermoCoupleProbesTemplates.C | 2 +- src/sampling/probes/patchProbesTemplates.C | 4 +-- src/sampling/probes/probesTemplates.C | 4 +-- 12 files changed, 53 insertions(+), 30 deletions(-) diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C index c7915338ee..5a41fee6f6 100644 --- a/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C @@ -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; } diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C index 87f9da4c95..344899ee93 100644 --- a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C @@ -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_); } diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C index 02a7261bfa..92d7a3bb44 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.C @@ -92,8 +92,8 @@ Foam::autoPtr 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::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); } diff --git a/src/functionObjects/field/blendingFactor/blendingFactor.C b/src/functionObjects/field/blendingFactor/blendingFactor.C index 4c5bcc592b..c6627b1130 100644 --- a/src/functionObjects/field/blendingFactor/blendingFactor.C +++ b/src/functionObjects/field/blendingFactor/blendingFactor.C @@ -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 diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.C b/src/functionObjects/field/fieldAverage/fieldAverage.C index ba00d299e7..5ed8b6634b 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverage.C +++ b/src/functionObjects/field/fieldAverage/fieldAverage.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-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; } } diff --git a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C index dcb4c5c7ff..8d4486fc9e 100644 --- a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C +++ b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C @@ -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 diff --git a/src/functionObjects/field/wallShearStress/wallShearStress.C b/src/functionObjects/field/wallShearStress/wallShearStress.C index 1391123441..c90a02ea03 100644 --- a/src/functionObjects/field/wallShearStress/wallShearStress.C +++ b/src/functionObjects/field/wallShearStress/wallShearStress.C @@ -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 diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index 03bac52926..d886256e24 100644 --- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -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++) { diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index 97de38581f..a1886f6c19 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -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; diff --git a/src/functionObjects/utilities/thermoCoupleProbes/thermoCoupleProbesTemplates.C b/src/functionObjects/utilities/thermoCoupleProbes/thermoCoupleProbesTemplates.C index c92524b29e..a1199b2e3c 100644 --- a/src/functionObjects/utilities/thermoCoupleProbes/thermoCoupleProbesTemplates.C +++ b/src/functionObjects/utilities/thermoCoupleProbes/thermoCoupleProbesTemplates.C @@ -38,7 +38,7 @@ void Foam::functionObjects::thermoCoupleProbes::sampleAndWrite probeStream << setw(w) - << vField.time().timeToUserTime(vField.time().value()); + << vField.time().timeOutputValue(); forAll(*this, probeI) { diff --git a/src/sampling/probes/patchProbesTemplates.C b/src/sampling/probes/patchProbesTemplates.C index c6991df35f..d43444cb91 100644 --- a/src/sampling/probes/patchProbesTemplates.C +++ b/src/sampling/probes/patchProbesTemplates.C @@ -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) { diff --git a/src/sampling/probes/probesTemplates.C b/src/sampling/probes/probesTemplates.C index 84d1ca2aa0..3ac7b08379 100644 --- a/src/sampling/probes/probesTemplates.C +++ b/src/sampling/probes/probesTemplates.C @@ -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) { From e6d9402e5ad5c319fb8aeddbb2bf5bb78c63bb69 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 21 Mar 2017 13:34:57 +0000 Subject: [PATCH 5/6] BUG: nacaAirfoil tutorial - updated patches used by forceCoeffs function object. Fixes #438 --- .../sonicFoam/RAS/nacaAirfoil/system/controlDict | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/system/controlDict b/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/system/controlDict index 68d2573d4f..53f7c61f2c 100644 --- a/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/system/controlDict +++ b/tutorials/compressible/sonicFoam/RAS/nacaAirfoil/system/controlDict @@ -51,16 +51,15 @@ functions { type forceCoeffs; libs ("libforces.so"); - writeControl timeStep; - writeInterval 1; + writeControl writeTime; patches ( - WALL10 + wall_4 ); - log true; rhoInf 1; + CofR (0 0 0); liftDir (-0.239733 0.970839 0); dragDir (0.970839 0.239733 0); From bbe490506ece680c78a8939223d8773dd1a6c9b9 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 21 Mar 2017 13:35:22 +0000 Subject: [PATCH 6/6] STYLE: Minor documentation update --- .../surfaceInterpolation/schemes/CoBlended/CoBlended.H | 1 + 1 file changed, 1 insertion(+) diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/CoBlended/CoBlended.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/CoBlended/CoBlended.H index 047d959f0f..f311c7b60f 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/CoBlended/CoBlended.H +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/CoBlended/CoBlended.H @@ -44,6 +44,7 @@ Description The weight applies to the first scheme and 1-weight to the second scheme. +Usage Example of the CoBlended scheme specification using LUST for Courant numbers less than 1 and linearUpwind for Courant numbers greater than 10: \verbatim