From aab660450aae87b6276dcfa3ae105d32b5de7d7a Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sat, 15 Jan 2022 21:15:41 +0000 Subject: [PATCH] fileOperation, timeSelector: Correct handling of negative time directories Resolves bug-report https://bugs.openfoam.org/view.php?id=3784 --- src/OpenFOAM/db/Time/timeSelector.C | 12 ++++++++++-- .../fileOperations/fileOperation/fileOperation.C | 8 ++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/OpenFOAM/db/Time/timeSelector.C b/src/OpenFOAM/db/Time/timeSelector.C index e2c6540fa3..f9d2362b1f 100644 --- a/src/OpenFOAM/db/Time/timeSelector.C +++ b/src/OpenFOAM/db/Time/timeSelector.C @@ -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-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -299,7 +299,15 @@ Foam::instantList Foam::timeSelector::selectIfPresent else { // No timeSelector option specified. Do not change runTime. - return instantList(1, instant(runTime.value(), runTime.timeName())); + return instantList + ( + 1, + instant + ( + runTime.timeToUserTime(runTime.value()), + runTime.timeName() + ) + ); } } diff --git a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C index 8b2e57ae51..0eda9abe1c 100644 --- a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C +++ b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -759,7 +759,11 @@ Foam::IOobject Foam::fileOperation::findInstance for (instanceI = ts.size()-1; instanceI >= 0; --instanceI) { - if (ts[instanceI].value() <= startValue) + if + ( + ts[instanceI].name() == time.constant() + || ts[instanceI].value() <= startValue + ) { break; }