mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7339 Refactoring: extract two methods.
This commit is contained in:
parent
e695b62db1
commit
54cdb6e8ef
@ -60,8 +60,6 @@ bool RimStimPlanModelWellLogCalculator::isMatching( RiaDefines::CurveProperty cu
|
|||||||
RiaDefines::CurveProperty::POROSITY_UNSCALED,
|
RiaDefines::CurveProperty::POROSITY_UNSCALED,
|
||||||
RiaDefines::CurveProperty::PERMEABILITY_X,
|
RiaDefines::CurveProperty::PERMEABILITY_X,
|
||||||
RiaDefines::CurveProperty::PERMEABILITY_Z,
|
RiaDefines::CurveProperty::PERMEABILITY_Z,
|
||||||
RiaDefines::CurveProperty::INITIAL_PRESSURE,
|
|
||||||
RiaDefines::CurveProperty::PRESSURE,
|
|
||||||
RiaDefines::CurveProperty::NET_TO_GROSS,
|
RiaDefines::CurveProperty::NET_TO_GROSS,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,60 +77,11 @@ bool RimStimPlanModelWellLogCalculator::calculate( RiaDefines::CurveProperty cur
|
|||||||
std::vector<double>& tvDepthValues,
|
std::vector<double>& tvDepthValues,
|
||||||
double& rkbDiff ) const
|
double& rkbDiff ) const
|
||||||
{
|
{
|
||||||
RimEclipseCase* eclipseCase = stimPlanModel->eclipseCaseForProperty( curveProperty );
|
if ( !extractValuesForProperty( curveProperty, stimPlanModel, timeStep, values, measuredDepthValues, tvDepthValues, rkbDiff ) )
|
||||||
if ( !eclipseCase )
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !stimPlanModel->thicknessDirectionWellPath() )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
RigWellPath* wellPathGeometry = stimPlanModel->thicknessDirectionWellPath()->wellPathGeometry();
|
|
||||||
if ( !wellPathGeometry )
|
|
||||||
{
|
|
||||||
RiaLogging::error( "No well path geometry found for well log exctration" );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
RigEclipseWellLogExtractor eclExtractor( eclipseCase->eclipseCaseData(), wellPathGeometry, "fracture model" );
|
|
||||||
|
|
||||||
measuredDepthValues = eclExtractor.cellIntersectionMDs();
|
|
||||||
tvDepthValues = eclExtractor.cellIntersectionTVDs();
|
|
||||||
rkbDiff = eclExtractor.wellPathGeometry()->rkbDiff();
|
|
||||||
|
|
||||||
RimEclipseResultDefinition eclipseResultDefinition;
|
|
||||||
eclipseResultDefinition.setEclipseCase( eclipseCase );
|
|
||||||
eclipseResultDefinition.setResultType( stimPlanModel->eclipseResultCategory( curveProperty ) );
|
|
||||||
eclipseResultDefinition.setPorosityModel( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
|
||||||
eclipseResultDefinition.setResultVariable( stimPlanModel->eclipseResultVariable( curveProperty ) );
|
|
||||||
|
|
||||||
eclipseResultDefinition.loadResult();
|
|
||||||
|
|
||||||
if ( stimPlanModel->eclipseResultCategory( curveProperty ) != RiaDefines::ResultCatType::DYNAMIC_NATIVE ||
|
|
||||||
curveProperty == RiaDefines::CurveProperty::INITIAL_PRESSURE )
|
|
||||||
{
|
|
||||||
timeStep = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cvf::ref<RigResultAccessor> resAcc =
|
|
||||||
RigResultAccessorFactory::createFromResultDefinition( eclipseCase->eclipseCaseData(),
|
|
||||||
0,
|
|
||||||
timeStep,
|
|
||||||
&eclipseResultDefinition );
|
|
||||||
|
|
||||||
if ( resAcc.notNull() )
|
|
||||||
{
|
|
||||||
eclExtractor.curveData( resAcc.p(), &values );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RiaLogging::error( QString( "No result found for %1" ).arg( eclipseResultDefinition.resultVariable() ) );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
double overburdenHeight = stimPlanModel->overburdenHeight();
|
double overburdenHeight = stimPlanModel->overburdenHeight();
|
||||||
if ( overburdenHeight > 0.0 )
|
if ( overburdenHeight > 0.0 )
|
||||||
{
|
{
|
||||||
@ -147,64 +96,19 @@ bool RimStimPlanModelWellLogCalculator::calculate( RiaDefines::CurveProperty cur
|
|||||||
|
|
||||||
if ( hasMissingValues( values ) )
|
if ( hasMissingValues( values ) )
|
||||||
{
|
{
|
||||||
|
QString resultVariable = stimPlanModel->eclipseResultVariable( curveProperty );
|
||||||
|
|
||||||
if ( stimPlanModel->missingValueStrategy( curveProperty ) == RimStimPlanModel::MissingValueStrategy::DEFAULT_VALUE )
|
if ( stimPlanModel->missingValueStrategy( curveProperty ) == RimStimPlanModel::MissingValueStrategy::DEFAULT_VALUE )
|
||||||
{
|
{
|
||||||
// Try to locate a backup accessor (e.g. PORO_1 for PORO)
|
if ( !replaceMissingValuesWithDefault( curveProperty, stimPlanModel, timeStep, resultVariable, values ) )
|
||||||
cvf::ref<RigResultAccessor> backupResAcc = findMissingValuesAccessor( eclipseCase->eclipseCaseData(),
|
|
||||||
eclipseCase->inputPropertyCollection(),
|
|
||||||
0,
|
|
||||||
timeStep,
|
|
||||||
&eclipseResultDefinition );
|
|
||||||
|
|
||||||
if ( backupResAcc.notNull() )
|
|
||||||
{
|
{
|
||||||
RiaLogging::info( QString( "Reading missing values from input properties for %1." )
|
return false;
|
||||||
.arg( eclipseResultDefinition.resultVariable() ) );
|
|
||||||
std::vector<double> replacementValues;
|
|
||||||
eclExtractor.curveData( backupResAcc.p(), &replacementValues );
|
|
||||||
|
|
||||||
double overburdenHeight = stimPlanModel->overburdenHeight();
|
|
||||||
if ( overburdenHeight > 0.0 )
|
|
||||||
{
|
|
||||||
double defaultOverburdenValue = std::numeric_limits<double>::infinity();
|
|
||||||
if ( stimPlanModel->burdenStrategy( curveProperty ) == RimStimPlanModel::BurdenStrategy::DEFAULT_VALUE )
|
|
||||||
{
|
|
||||||
defaultOverburdenValue = stimPlanModel->getDefaultForMissingOverburdenValue( curveProperty );
|
|
||||||
}
|
|
||||||
|
|
||||||
replacementValues.insert( replacementValues.begin(), defaultOverburdenValue );
|
|
||||||
replacementValues.insert( replacementValues.begin(), defaultOverburdenValue );
|
|
||||||
}
|
|
||||||
|
|
||||||
double underburdenHeight = stimPlanModel->underburdenHeight();
|
|
||||||
if ( underburdenHeight > 0.0 )
|
|
||||||
{
|
|
||||||
double defaultUnderburdenValue = std::numeric_limits<double>::infinity();
|
|
||||||
if ( stimPlanModel->burdenStrategy( curveProperty ) == RimStimPlanModel::BurdenStrategy::DEFAULT_VALUE )
|
|
||||||
{
|
|
||||||
defaultUnderburdenValue = stimPlanModel->getDefaultForMissingUnderburdenValue( curveProperty );
|
|
||||||
}
|
|
||||||
|
|
||||||
replacementValues.push_back( defaultUnderburdenValue );
|
|
||||||
replacementValues.push_back( defaultUnderburdenValue );
|
|
||||||
}
|
|
||||||
|
|
||||||
replaceMissingValues( values, replacementValues );
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the backup accessor is not found, or does not provide all the missing values:
|
|
||||||
// use default value from the fracture model
|
|
||||||
if ( !backupResAcc.notNull() || hasMissingValues( values ) )
|
|
||||||
{
|
|
||||||
double defaultValue = stimPlanModel->getDefaultForMissingValue( curveProperty );
|
|
||||||
replaceMissingValues( values, defaultValue );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( stimPlanModel->missingValueStrategy( curveProperty ) ==
|
else if ( stimPlanModel->missingValueStrategy( curveProperty ) ==
|
||||||
RimStimPlanModel::MissingValueStrategy::LINEAR_INTERPOLATION )
|
RimStimPlanModel::MissingValueStrategy::LINEAR_INTERPOLATION )
|
||||||
{
|
{
|
||||||
RiaLogging::info(
|
RiaLogging::info( QString( "Interpolating missing values for %1" ).arg( resultVariable ) );
|
||||||
QString( "Interpolating missing values for %1" ).arg( eclipseResultDefinition.resultVariable() ) );
|
|
||||||
RiaInterpolationTools::interpolateMissingValues( measuredDepthValues, values );
|
RiaInterpolationTools::interpolateMissingValues( measuredDepthValues, values );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -295,9 +199,9 @@ cvf::ref<RigResultAccessor>
|
|||||||
RimEclipseInputPropertyCollection* inputPropertyCollection,
|
RimEclipseInputPropertyCollection* inputPropertyCollection,
|
||||||
int gridIndex,
|
int gridIndex,
|
||||||
int timeStepIndex,
|
int timeStepIndex,
|
||||||
RimEclipseResultDefinition* eclipseResultDefinition ) const
|
const QString& resultName ) const
|
||||||
{
|
{
|
||||||
QString resultName = eclipseResultDefinition->resultVariable();
|
RiaDefines::PorosityModelType porosityModelType = RiaDefines::PorosityModelType::MATRIX_MODEL;
|
||||||
|
|
||||||
for ( RimEclipseInputProperty* inputProperty : inputPropertyCollection->inputProperties() )
|
for ( RimEclipseInputProperty* inputProperty : inputPropertyCollection->inputProperties() )
|
||||||
{
|
{
|
||||||
@ -308,13 +212,12 @@ cvf::ref<RigResultAccessor>
|
|||||||
QString( "Found missing values result for %1: %2" ).arg( resultName ).arg( inputProperty->resultName() ) );
|
QString( "Found missing values result for %1: %2" ).arg( resultName ).arg( inputProperty->resultName() ) );
|
||||||
|
|
||||||
RigEclipseResultAddress resultAddress( RiaDefines::ResultCatType::INPUT_PROPERTY, inputProperty->resultName() );
|
RigEclipseResultAddress resultAddress( RiaDefines::ResultCatType::INPUT_PROPERTY, inputProperty->resultName() );
|
||||||
caseData->results( eclipseResultDefinition->porosityModel() )->ensureKnownResultLoaded( resultAddress );
|
caseData->results( porosityModelType )->ensureKnownResultLoaded( resultAddress );
|
||||||
cvf::ref<RigResultAccessor> resAcc =
|
cvf::ref<RigResultAccessor> resAcc = RigResultAccessorFactory::createFromResultAddress( caseData,
|
||||||
RigResultAccessorFactory::createFromResultAddress( caseData,
|
gridIndex,
|
||||||
gridIndex,
|
porosityModelType,
|
||||||
eclipseResultDefinition->porosityModel(),
|
timeStepIndex,
|
||||||
timeStepIndex,
|
resultAddress );
|
||||||
resultAddress );
|
|
||||||
|
|
||||||
return resAcc;
|
return resAcc;
|
||||||
}
|
}
|
||||||
@ -443,3 +346,150 @@ void RimStimPlanModelWellLogCalculator::scaleByNetToGross( const RimStimPlanMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimStimPlanModelWellLogCalculator::extractValuesForProperty( RiaDefines::CurveProperty curveProperty,
|
||||||
|
const RimStimPlanModel* stimPlanModel,
|
||||||
|
int timeStep,
|
||||||
|
std::vector<double>& values,
|
||||||
|
std::vector<double>& measuredDepthValues,
|
||||||
|
std::vector<double>& tvDepthValues,
|
||||||
|
double& rkbDiff ) const
|
||||||
|
{
|
||||||
|
RimEclipseCase* eclipseCase = stimPlanModel->eclipseCaseForProperty( curveProperty );
|
||||||
|
if ( !eclipseCase )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !stimPlanModel->thicknessDirectionWellPath() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RigWellPath* wellPathGeometry = stimPlanModel->thicknessDirectionWellPath()->wellPathGeometry();
|
||||||
|
if ( !wellPathGeometry )
|
||||||
|
{
|
||||||
|
RiaLogging::error( "No well path geometry found for well log exctration" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RigEclipseWellLogExtractor eclExtractor( eclipseCase->eclipseCaseData(), wellPathGeometry, "fracture model" );
|
||||||
|
|
||||||
|
measuredDepthValues = eclExtractor.cellIntersectionMDs();
|
||||||
|
tvDepthValues = eclExtractor.cellIntersectionTVDs();
|
||||||
|
rkbDiff = eclExtractor.wellPathGeometry()->rkbDiff();
|
||||||
|
|
||||||
|
RimEclipseResultDefinition eclipseResultDefinition;
|
||||||
|
eclipseResultDefinition.setEclipseCase( eclipseCase );
|
||||||
|
eclipseResultDefinition.setResultType( stimPlanModel->eclipseResultCategory( curveProperty ) );
|
||||||
|
eclipseResultDefinition.setPorosityModel( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||||
|
eclipseResultDefinition.setResultVariable( stimPlanModel->eclipseResultVariable( curveProperty ) );
|
||||||
|
|
||||||
|
eclipseResultDefinition.loadResult();
|
||||||
|
|
||||||
|
if ( stimPlanModel->eclipseResultCategory( curveProperty ) != RiaDefines::ResultCatType::DYNAMIC_NATIVE ||
|
||||||
|
curveProperty == RiaDefines::CurveProperty::INITIAL_PRESSURE )
|
||||||
|
{
|
||||||
|
timeStep = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
cvf::ref<RigResultAccessor> resAcc =
|
||||||
|
RigResultAccessorFactory::createFromResultDefinition( eclipseCase->eclipseCaseData(),
|
||||||
|
0,
|
||||||
|
timeStep,
|
||||||
|
&eclipseResultDefinition );
|
||||||
|
|
||||||
|
if ( resAcc.notNull() )
|
||||||
|
{
|
||||||
|
eclExtractor.curveData( resAcc.p(), &values );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RiaLogging::error( QString( "No result found for %1" ).arg( eclipseResultDefinition.resultVariable() ) );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimStimPlanModelWellLogCalculator::replaceMissingValuesWithDefault( RiaDefines::CurveProperty curveProperty,
|
||||||
|
const RimStimPlanModel* stimPlanModel,
|
||||||
|
int timeStep,
|
||||||
|
const QString& resultVariable,
|
||||||
|
std::vector<double>& values ) const
|
||||||
|
|
||||||
|
{
|
||||||
|
RimEclipseCase* eclipseCase = stimPlanModel->eclipseCaseForProperty( curveProperty );
|
||||||
|
|
||||||
|
if ( !stimPlanModel->thicknessDirectionWellPath() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RigWellPath* wellPathGeometry = stimPlanModel->thicknessDirectionWellPath()->wellPathGeometry();
|
||||||
|
if ( !wellPathGeometry )
|
||||||
|
{
|
||||||
|
RiaLogging::error( "No well path geometry found for well log exctration" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to locate a backup accessor (e.g. PORO_1 for PORO)
|
||||||
|
cvf::ref<RigResultAccessor> backupResAcc = findMissingValuesAccessor( eclipseCase->eclipseCaseData(),
|
||||||
|
eclipseCase->inputPropertyCollection(),
|
||||||
|
0,
|
||||||
|
timeStep,
|
||||||
|
resultVariable );
|
||||||
|
|
||||||
|
if ( backupResAcc.notNull() )
|
||||||
|
{
|
||||||
|
RiaLogging::info( QString( "Reading missing values from input properties for %1." ).arg( resultVariable ) );
|
||||||
|
std::vector<double> replacementValues;
|
||||||
|
|
||||||
|
RigEclipseWellLogExtractor eclExtractor( eclipseCase->eclipseCaseData(), wellPathGeometry, "fracture model" );
|
||||||
|
eclExtractor.curveData( backupResAcc.p(), &replacementValues );
|
||||||
|
|
||||||
|
double overburdenHeight = stimPlanModel->overburdenHeight();
|
||||||
|
if ( overburdenHeight > 0.0 )
|
||||||
|
{
|
||||||
|
double defaultOverburdenValue = std::numeric_limits<double>::infinity();
|
||||||
|
if ( stimPlanModel->burdenStrategy( curveProperty ) == RimStimPlanModel::BurdenStrategy::DEFAULT_VALUE )
|
||||||
|
{
|
||||||
|
defaultOverburdenValue = stimPlanModel->getDefaultForMissingOverburdenValue( curveProperty );
|
||||||
|
}
|
||||||
|
|
||||||
|
replacementValues.insert( replacementValues.begin(), defaultOverburdenValue );
|
||||||
|
replacementValues.insert( replacementValues.begin(), defaultOverburdenValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
double underburdenHeight = stimPlanModel->underburdenHeight();
|
||||||
|
if ( underburdenHeight > 0.0 )
|
||||||
|
{
|
||||||
|
double defaultUnderburdenValue = std::numeric_limits<double>::infinity();
|
||||||
|
if ( stimPlanModel->burdenStrategy( curveProperty ) == RimStimPlanModel::BurdenStrategy::DEFAULT_VALUE )
|
||||||
|
{
|
||||||
|
defaultUnderburdenValue = stimPlanModel->getDefaultForMissingUnderburdenValue( curveProperty );
|
||||||
|
}
|
||||||
|
|
||||||
|
replacementValues.push_back( defaultUnderburdenValue );
|
||||||
|
replacementValues.push_back( defaultUnderburdenValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceMissingValues( values, replacementValues );
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the backup accessor is not found, or does not provide all the missing values:
|
||||||
|
// use default value from the fracture model
|
||||||
|
if ( !backupResAcc.notNull() || hasMissingValues( values ) )
|
||||||
|
{
|
||||||
|
double defaultValue = stimPlanModel->getDefaultForMissingValue( curveProperty );
|
||||||
|
replaceMissingValues( values, defaultValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -54,7 +54,7 @@ protected:
|
|||||||
RimEclipseInputPropertyCollection* inputPropertyCollection,
|
RimEclipseInputPropertyCollection* inputPropertyCollection,
|
||||||
int gridIndex,
|
int gridIndex,
|
||||||
int timeStepIndex,
|
int timeStepIndex,
|
||||||
RimEclipseResultDefinition* eclipseResultDefinition ) const;
|
const QString& resultName ) const;
|
||||||
|
|
||||||
void addOverburden( RiaDefines::CurveProperty curveProperty,
|
void addOverburden( RiaDefines::CurveProperty curveProperty,
|
||||||
const RimStimPlanModel* stimPlanModel,
|
const RimStimPlanModel* stimPlanModel,
|
||||||
@ -72,5 +72,19 @@ protected:
|
|||||||
const std::vector<double>& netToGross,
|
const std::vector<double>& netToGross,
|
||||||
std::vector<double>& values );
|
std::vector<double>& values );
|
||||||
|
|
||||||
|
bool extractValuesForProperty( RiaDefines::CurveProperty curveProperty,
|
||||||
|
const RimStimPlanModel* stimPlanModel,
|
||||||
|
int timeStep,
|
||||||
|
std::vector<double>& values,
|
||||||
|
std::vector<double>& measuredDepthValues,
|
||||||
|
std::vector<double>& tvDepthValues,
|
||||||
|
double& rkbDiff ) const;
|
||||||
|
|
||||||
|
bool replaceMissingValuesWithDefault( RiaDefines::CurveProperty curveProperty,
|
||||||
|
const RimStimPlanModel* stimPlanModel,
|
||||||
|
int timeStep,
|
||||||
|
const QString& resultVariable,
|
||||||
|
std::vector<double>& values ) const;
|
||||||
|
|
||||||
RimStimPlanModelCalculator* m_stimPlanModelCalculator;
|
RimStimPlanModelCalculator* m_stimPlanModelCalculator;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user