ENH: Input in objectiveFlowRatePartition now reads "targetFractions"
instead of targetPercentages, with a compatibility read on the latter. Changed corresponding tutorials too.
This commit is contained in:
parent
eabb821926
commit
c3b212e06c
@ -75,23 +75,30 @@ objectiveFlowRatePartition::objectiveFlowRatePartition
|
||||
dict.get<wordRes>("outletPatches")
|
||||
).sortedToc()
|
||||
),
|
||||
targetFlowRatePercentage_(),
|
||||
currentFlowRatePercentage_(outletPatches_.size(), Zero),
|
||||
targetFlowRateFraction_(),
|
||||
currentFlowRateFraction_(outletPatches_.size(), Zero),
|
||||
inletFlowRate_(0),
|
||||
flowRateDifference_(outletPatches_.size(), Zero)
|
||||
{
|
||||
// Read target percentages if present, otherwise treat them as equally
|
||||
// Read target fractions if present, otherwise treat them as equally
|
||||
// distributed
|
||||
if (!dict.readIfPresent("targetPercentages", targetFlowRatePercentage_))
|
||||
if
|
||||
(
|
||||
!dict.readIfPresentCompat
|
||||
(
|
||||
"targetFractions", {{"targetPercentages", 2306}},
|
||||
targetFlowRateFraction_
|
||||
)
|
||||
)
|
||||
{
|
||||
const label nOutPatches = outletPatches_.size();
|
||||
targetFlowRatePercentage_.setSize(nOutPatches, 1.0/scalar(nOutPatches));
|
||||
targetFlowRateFraction_.setSize(nOutPatches, 1.0/scalar(nOutPatches));
|
||||
}
|
||||
// Sanity checks
|
||||
if (targetFlowRatePercentage_.size() != outletPatches_.size())
|
||||
if (targetFlowRateFraction_.size() != outletPatches_.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Inconsistent sizes for targetPercentages and outletPatches"
|
||||
<< "Inconsistent sizes for targetFractions and outletPatches"
|
||||
<< exit(FatalError);
|
||||
|
||||
}
|
||||
@ -130,9 +137,9 @@ scalar objectiveFlowRatePartition::J()
|
||||
{
|
||||
const label patchI = outletPatches_[pI];
|
||||
const scalar outletFlowRate = gSum(phi.boundaryField()[patchI]);
|
||||
currentFlowRatePercentage_[pI] = -outletFlowRate/inletFlowRate_;
|
||||
currentFlowRateFraction_[pI] = -outletFlowRate/inletFlowRate_;
|
||||
flowRateDifference_[pI] =
|
||||
targetFlowRatePercentage_[pI] - currentFlowRatePercentage_[pI];
|
||||
targetFlowRateFraction_[pI] - currentFlowRateFraction_[pI];
|
||||
J_ += 0.5*flowRateDifference_[pI]*flowRateDifference_[pI];
|
||||
}
|
||||
|
||||
@ -172,7 +179,7 @@ void objectiveFlowRatePartition::addHeaderInfo() const
|
||||
const fvPatch& patch = mesh_.boundary()[patchI];
|
||||
objFunctionFilePtr_()
|
||||
<< setw(width_) << word("#" + patch.name() + "Tar") << " "
|
||||
<< setw(width_) << targetFlowRatePercentage_[pI] << endl;
|
||||
<< setw(width_) << targetFlowRateFraction_[pI] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,7 +197,7 @@ void objectiveFlowRatePartition::addHeaderColumns() const
|
||||
|
||||
void objectiveFlowRatePartition::addColumnValues() const
|
||||
{
|
||||
for (const scalar flowRate : currentFlowRatePercentage_)
|
||||
for (const scalar flowRate : currentFlowRateFraction_)
|
||||
{
|
||||
objFunctionFilePtr_()
|
||||
<< setw(width_) << flowRate << " ";
|
||||
|
@ -61,8 +61,8 @@ class objectiveFlowRatePartition
|
||||
|
||||
labelList inletPatches_;
|
||||
labelList outletPatches_;
|
||||
scalarList targetFlowRatePercentage_;
|
||||
scalarList currentFlowRatePercentage_;
|
||||
scalarList targetFlowRateFraction_;
|
||||
scalarList currentFlowRateFraction_;
|
||||
scalar inletFlowRate_;
|
||||
scalarList flowRateDifference_;
|
||||
|
||||
|
@ -66,7 +66,7 @@ adjointManagers
|
||||
outletPatches (outlet1 outlet2);
|
||||
// Optional entry. If abscent, inlet flow rate will
|
||||
// be partitioned equally between outlets
|
||||
// targetPercentages (0.5 0.5);
|
||||
// targetFractions (0.5 0.5);
|
||||
normalize true;
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet outlet-right);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet outlet-right);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
normalize true;
|
||||
target 1.e-5;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet outlet-right);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet outlet-right);
|
||||
targetPercentages (0.3 0.7);
|
||||
targetFractions (0.5 0.5);
|
||||
target 1.e-05;
|
||||
normalize true;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet outlet-right);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet outlet-right);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
target 1.e-05;
|
||||
normalize true;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet outlet-right);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet outlet-right);
|
||||
targetPercentages (0.7 0.3);
|
||||
targetFractions (0.5 0.5);
|
||||
target 1.e-05;
|
||||
normalize true;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet1 outlet2);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet1 outlet2);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
normalize true;
|
||||
target 1.e-5;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet1 outlet2);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet1 outlet2);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
normalize true;
|
||||
target 1.e-5;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet1 outlet2);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet1 outlet2);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet outlet-right);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ adjointManagers
|
||||
type flowRatePartition;
|
||||
inletPatches (inlet);
|
||||
outletPatches (outlet outlet-right);
|
||||
targetPercentages (0.5 0.5);
|
||||
targetFractions (0.5 0.5);
|
||||
normalize true;
|
||||
target 1.e-5;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user