mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2127 Clamp sim well branch index to valid range
This commit is contained in:
@@ -106,3 +106,23 @@ void RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromSimWellName(c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RiaSimWellBranchTools::clampBranchIndex(const QString& simWellName, int branchIndexValue, bool branchDetection)
|
||||
{
|
||||
auto branches = RiaSimWellBranchTools::simulationWellBranches(simWellName, branchDetection);
|
||||
|
||||
if (branches.size() == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (branchIndexValue >= branches.size())
|
||||
{
|
||||
branchIndexValue = static_cast<int>(branches.size()) - 1;
|
||||
}
|
||||
|
||||
return branchIndexValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user