From 9b6482d1fc65d375b9595759b4a349c08ff445ac Mon Sep 17 00:00:00 2001 From: Vaggelis Papoutsis <vaggelisp@gmail.com> Date: Fri, 2 May 2025 13:03:33 +0300 Subject: [PATCH] BUG: wrong cellZone addressing in uniformityCellZone (fixes #3360) The mean value, variance and volume fields for each zone were accessed using the wrong indices --- .../objectiveUniformityCellZone.C | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveUniformityCellZone/objectiveUniformityCellZone.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveUniformityCellZone/objectiveUniformityCellZone.C index 7314896024b..0e57c1ff450 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveUniformityCellZone/objectiveUniformityCellZone.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveUniformityCellZone/objectiveUniformityCellZone.C @@ -5,8 +5,8 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2007-2023 PCOpt/NTUA - Copyright (C) 2013-2023 FOSS GP + Copyright (C) 2007-2025 PCOpt/NTUA + Copyright (C) 2013-2025 FOSS GP ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -118,9 +118,9 @@ scalar objectiveUniformityCellZone::J() const volVectorField& U = vars_.UInst(); const scalarField& V = mesh_.V().field(); - for (const label zI : zones_) + forAll(zones_, zI) { - const cellZone& zoneI = mesh_.cellZones()[zI]; + const cellZone& zoneI = mesh_.cellZones()[zones_[zI]]; scalarField VZone(V, zoneI); vectorField UZone(U.primitiveField(), zoneI); volZone_[zI] = gSum(VZone); @@ -138,9 +138,9 @@ void objectiveUniformityCellZone::update_dJdv() { const volVectorField& U = vars_.U(); - for (const label zI : zones_) + forAll(zones_, zI) { - const cellZone& zoneI = mesh_.cellZones()[zI]; + const cellZone& zoneI = mesh_.cellZones()[zones_[zI]]; for (const label cellI : zoneI) { dJdvPtr_()[cellI] = (U[cellI] - UMean_[zI])/volZone_[zI]; @@ -154,9 +154,9 @@ void objectiveUniformityCellZone::update_divDxDbMultiplier() volScalarField& divDxDbMult = divDxDbMultPtr_(); const volVectorField& U = vars_.U(); - for (const label zI : zones_) + forAll(zones_, zI) { - const cellZone& zoneI = mesh_.cellZones()[zI]; + const cellZone& zoneI = mesh_.cellZones()[zones_[zI]]; for (const label cellI : zoneI) { divDxDbMult[cellI] = -- GitLab