mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7452 Refactoring: extract method
This commit is contained in:
parent
66df15224f
commit
5b7a73230e
@ -263,44 +263,9 @@ bool RimStimPlanModelPressureCalculator::extractValuesForProperty( RiaDefines::C
|
|||||||
}
|
}
|
||||||
else if ( curveProperty == RiaDefines::CurveProperty::PRESSURE )
|
else if ( curveProperty == RiaDefines::CurveProperty::PRESSURE )
|
||||||
{
|
{
|
||||||
// Filter out the facies which does not have pressure depletion.
|
if ( !handleFaciesWithInitialPressure( stimPlanModel, timeStep, faciesValues, values ) )
|
||||||
std::map<int, double> faciesWithInitialPressure =
|
|
||||||
stimPlanModel->stimPlanModelTemplate()->faciesWithInitialPressure();
|
|
||||||
|
|
||||||
if ( !faciesWithInitialPressure.empty() )
|
|
||||||
{
|
{
|
||||||
std::vector<double> initialPressureValues;
|
return false;
|
||||||
std::vector<double> initialPressureMeasuredDepthValues;
|
|
||||||
std::vector<double> initialPressureTvDepthValues;
|
|
||||||
|
|
||||||
if ( !extractValuesForProperty( RiaDefines::CurveProperty::INITIAL_PRESSURE,
|
|
||||||
stimPlanModel,
|
|
||||||
timeStep,
|
|
||||||
initialPressureValues,
|
|
||||||
initialPressureMeasuredDepthValues,
|
|
||||||
initialPressureTvDepthValues,
|
|
||||||
rkbDiff ) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CAF_ASSERT( faciesValues.size() == initialPressureValues.size() );
|
|
||||||
for ( size_t i = 0; i < faciesValues.size(); i++ )
|
|
||||||
{
|
|
||||||
// Use the values from initial pressure curve
|
|
||||||
int faciesValue = static_cast<int>( faciesValues[i] );
|
|
||||||
double currentPressure = values[i];
|
|
||||||
double initialPressure = initialPressureValues[i];
|
|
||||||
auto faciesConfig = faciesWithInitialPressure.find( faciesValue );
|
|
||||||
if ( faciesConfig != faciesWithInitialPressure.end() && !std::isinf( currentPressure ) &&
|
|
||||||
!std::isinf( initialPressure ) )
|
|
||||||
{
|
|
||||||
double fraction = faciesConfig->second;
|
|
||||||
double value = initialPressure - ( initialPressure - currentPressure ) * fraction;
|
|
||||||
|
|
||||||
values[i] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,3 +642,53 @@ double RimStimPlanModelPressureCalculator::pressureDifferenceInterpolationOffset
|
|||||||
// Unit: meter
|
// Unit: meter
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimStimPlanModelPressureCalculator::handleFaciesWithInitialPressure( const RimStimPlanModel* stimPlanModel,
|
||||||
|
int timeStep,
|
||||||
|
const std::vector<double>& faciesValues,
|
||||||
|
std::vector<double>& values ) const
|
||||||
|
{
|
||||||
|
// Filter out the facies which does not have pressure depletion.
|
||||||
|
std::map<int, double> faciesWithInitialPressure = stimPlanModel->stimPlanModelTemplate()->faciesWithInitialPressure();
|
||||||
|
|
||||||
|
if ( !faciesWithInitialPressure.empty() )
|
||||||
|
{
|
||||||
|
std::vector<double> initialPressureValues;
|
||||||
|
std::vector<double> initialPressureMeasuredDepthValues;
|
||||||
|
std::vector<double> initialPressureTvDepthValues;
|
||||||
|
double rkbDiff;
|
||||||
|
if ( !extractValuesForProperty( RiaDefines::CurveProperty::INITIAL_PRESSURE,
|
||||||
|
stimPlanModel,
|
||||||
|
timeStep,
|
||||||
|
initialPressureValues,
|
||||||
|
initialPressureMeasuredDepthValues,
|
||||||
|
initialPressureTvDepthValues,
|
||||||
|
rkbDiff ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CAF_ASSERT( faciesValues.size() == initialPressureValues.size() );
|
||||||
|
for ( size_t i = 0; i < faciesValues.size(); i++ )
|
||||||
|
{
|
||||||
|
// Use the values from initial pressure curve
|
||||||
|
int faciesValue = static_cast<int>( faciesValues[i] );
|
||||||
|
double currentPressure = values[i];
|
||||||
|
double initialPressure = initialPressureValues[i];
|
||||||
|
auto faciesConfig = faciesWithInitialPressure.find( faciesValue );
|
||||||
|
if ( faciesConfig != faciesWithInitialPressure.end() && !std::isinf( currentPressure ) &&
|
||||||
|
!std::isinf( initialPressure ) )
|
||||||
|
{
|
||||||
|
double fraction = faciesConfig->second;
|
||||||
|
double value = initialPressure - ( initialPressure - currentPressure ) * fraction;
|
||||||
|
|
||||||
|
values[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -73,6 +73,10 @@ protected:
|
|||||||
const std::vector<double>& tvDepthValues,
|
const std::vector<double>& tvDepthValues,
|
||||||
const std::vector<double>& initialPressureValues,
|
const std::vector<double>& initialPressureValues,
|
||||||
std::vector<double>& values ) const;
|
std::vector<double>& values ) const;
|
||||||
|
bool handleFaciesWithInitialPressure( const RimStimPlanModel* stimPlanModel,
|
||||||
|
int timeStep,
|
||||||
|
const std::vector<double>& faciesValues,
|
||||||
|
std::vector<double>& values ) const;
|
||||||
|
|
||||||
typedef std::pair<double, double> DepthValuePair;
|
typedef std::pair<double, double> DepthValuePair;
|
||||||
typedef std::vector<DepthValuePair> DepthValuePairVector;
|
typedef std::vector<DepthValuePair> DepthValuePairVector;
|
||||||
|
Loading…
Reference in New Issue
Block a user