From fdfb5b1825a3237bd2a6e0b04530a24947c8a753 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 7 Mar 2019 16:22:34 +0000 Subject: [PATCH] data: Reset solver data only when non-sub cycled time index changes Resolves bug report https://bugs.openfoam.org/view.php?id=3189 --- src/OpenFOAM/meshes/data/data.C | 4 ++-- src/OpenFOAM/meshes/data/dataTemplates.C | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/OpenFOAM/meshes/data/data.C b/src/OpenFOAM/meshes/data/data.C index a305b999f..36f934a35 100644 --- a/src/OpenFOAM/meshes/data/data.C +++ b/src/OpenFOAM/meshes/data/data.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-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,7 +45,7 @@ Foam::data::data(const objectRegistry& obr) IOobject::NO_WRITE ) ), - prevTimeIndex_(0) + prevTimeIndex_(-1) { set("solverPerformance", dictionary()); } diff --git a/src/OpenFOAM/meshes/data/dataTemplates.C b/src/OpenFOAM/meshes/data/dataTemplates.C index c6b0b7e36..b8a99fff9 100644 --- a/src/OpenFOAM/meshes/data/dataTemplates.C +++ b/src/OpenFOAM/meshes/data/dataTemplates.C @@ -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-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,10 +40,15 @@ void Foam::data::setSolverPerformance List> perfs; - if (prevTimeIndex_ != this->time().timeIndex()) + const label timeIndex = + this->time().subCycling() + ? this->time().prevTimeState().timeIndex() + : this->time().timeIndex(); + + if (prevTimeIndex_ != timeIndex) { // Reset solver performance between iterations - prevTimeIndex_ = this->time().timeIndex(); + prevTimeIndex_ = timeIndex; dict.clear(); } else