ENH: flowRate and flowRatePartition objectives are now computed

based on phi, instead of U & Sf
This commit is contained in:
Vaggelis Papoutsis
2023-11-23 12:18:35 +02:00
committed by Andrew Heather
parent b5b48b66d1
commit e764f7b573
2 changed files with 5 additions and 8 deletions

View File

@ -77,13 +77,12 @@ objectiveFlowRate::objectiveFlowRate
scalar objectiveFlowRate::J() scalar objectiveFlowRate::J()
{ {
J_ = 0; J_ = 0;
const volVectorField& U = vars_.UInst(); const surfaceScalarField& phi = vars_.phiInst();
forAll(patches_, pI) forAll(patches_, pI)
{ {
const label patchI = patches_[pI]; const label patchI = patches_[pI];
flowRates_[pI] = flowRates_[pI] = gSum(phi.boundaryField()[patchI]);
gSum(U.boundaryField()[patchI] & mesh_.boundary()[patchI].Sf());
J_ += flowRates_[pI]; J_ += flowRates_[pI];
} }

View File

@ -115,23 +115,21 @@ objectiveFlowRatePartition::objectiveFlowRatePartition
scalar objectiveFlowRatePartition::J() scalar objectiveFlowRatePartition::J()
{ {
J_ = 0; J_ = 0;
const volVectorField& U = vars_.UInst(); const surfaceScalarField& phi = vars_.phiInst();
// Inlet patches // Inlet patches
inletFlowRate_ = 0; inletFlowRate_ = 0;
for (const label patchI : inletPatches_) for (const label patchI : inletPatches_)
{ {
const vectorField& Sf = mesh_.boundary()[patchI].Sf();
// Negative value // Negative value
inletFlowRate_ += gSum(U.boundaryField()[patchI] & Sf); inletFlowRate_ += gSum(phi.boundaryField()[patchI]);
} }
// Outlet patches // Outlet patches
forAll(outletPatches_, pI) forAll(outletPatches_, pI)
{ {
const label patchI = outletPatches_[pI]; const label patchI = outletPatches_[pI];
const vectorField& Sf = mesh_.boundary()[patchI].Sf(); const scalar outletFlowRate = gSum(phi.boundaryField()[patchI]);
const scalar outletFlowRate = gSum(U.boundaryField()[patchI] & Sf);
currentFlowRatePercentage_[pI] = -outletFlowRate/inletFlowRate_; currentFlowRatePercentage_[pI] = -outletFlowRate/inletFlowRate_;
flowRateDifference_[pI] = flowRateDifference_[pI] =
targetFlowRatePercentage_[pI] - currentFlowRatePercentage_[pI]; targetFlowRatePercentage_[pI] - currentFlowRatePercentage_[pI];