From e764f7b57323a7763fd33fa9639aa06307eae917 Mon Sep 17 00:00:00 2001 From: Vaggelis Papoutsis Date: Thu, 23 Nov 2023 12:18:35 +0200 Subject: [PATCH] ENH: flowRate and flowRatePartition objectives are now computed based on phi, instead of U & Sf --- .../incompressible/objectiveFlowRate/objectiveFlowRate.C | 5 ++--- .../objectiveFlowRatePartition.C | 8 +++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveFlowRate/objectiveFlowRate.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveFlowRate/objectiveFlowRate.C index d3a3b7859e..dda2508357 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveFlowRate/objectiveFlowRate.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveFlowRate/objectiveFlowRate.C @@ -77,13 +77,12 @@ objectiveFlowRate::objectiveFlowRate scalar objectiveFlowRate::J() { J_ = 0; - const volVectorField& U = vars_.UInst(); + const surfaceScalarField& phi = vars_.phiInst(); forAll(patches_, pI) { const label patchI = patches_[pI]; - flowRates_[pI] = - gSum(U.boundaryField()[patchI] & mesh_.boundary()[patchI].Sf()); + flowRates_[pI] = gSum(phi.boundaryField()[patchI]); J_ += flowRates_[pI]; } diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveFlowRatePartition/objectiveFlowRatePartition.C b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveFlowRatePartition/objectiveFlowRatePartition.C index ca05e51c69..6c30f833ca 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveFlowRatePartition/objectiveFlowRatePartition.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/incompressible/objectiveFlowRatePartition/objectiveFlowRatePartition.C @@ -115,23 +115,21 @@ objectiveFlowRatePartition::objectiveFlowRatePartition scalar objectiveFlowRatePartition::J() { J_ = 0; - const volVectorField& U = vars_.UInst(); + const surfaceScalarField& phi = vars_.phiInst(); // Inlet patches inletFlowRate_ = 0; for (const label patchI : inletPatches_) { - const vectorField& Sf = mesh_.boundary()[patchI].Sf(); // Negative value - inletFlowRate_ += gSum(U.boundaryField()[patchI] & Sf); + inletFlowRate_ += gSum(phi.boundaryField()[patchI]); } // Outlet patches forAll(outletPatches_, pI) { const label patchI = outletPatches_[pI]; - const vectorField& Sf = mesh_.boundary()[patchI].Sf(); - const scalar outletFlowRate = gSum(U.boundaryField()[patchI] & Sf); + const scalar outletFlowRate = gSum(phi.boundaryField()[patchI]); currentFlowRatePercentage_[pI] = -outletFlowRate/inletFlowRate_; flowRateDifference_[pI] = targetFlowRatePercentage_[pI] - currentFlowRatePercentage_[pI];