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()
{
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];
}

View File

@ -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];