Avoid outputting invalid aicd segments

This commit is contained in:
Gaute Lindkvist 2020-10-19 18:48:37 +02:00 committed by Magne Sjaastad
parent 94abc8a9e1
commit ef242e44ae
5 changed files with 144 additions and 126 deletions

View File

@ -137,6 +137,7 @@ RigCompletionData::CompletionType RicMswPerforation::completionType() const
RicMswValve::RicMswValve( const QString& label, const RimWellPathValve* wellPathValve )
: RicMswCompletion( label )
, m_wellPathValve( wellPathValve )
, m_valid( false )
{
}
@ -148,6 +149,22 @@ const RimWellPathValve* RicMswValve::wellPathValve() const
return m_wellPathValve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicMswValve::isValid() const
{
return m_valid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicMswValve::setIsValid( bool valid )
{
m_valid = valid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -196,6 +213,7 @@ void RicMswWsegValve::setArea( double icdArea )
RicMswFishbonesICD::RicMswFishbonesICD( const QString& label, const RimWellPathValve* wellPathValve )
: RicMswWsegValve( label, wellPathValve )
{
setIsValid( true );
}
//--------------------------------------------------------------------------------------------------
@ -228,6 +246,7 @@ RigCompletionData::CompletionType RicMswPerforationICD::completionType() const
RicMswPerforationICV::RicMswPerforationICV( const QString& label, const RimWellPathValve* wellPathValve )
: RicMswWsegValve( label, wellPathValve )
{
setIsValid( true );
}
//-------------------------------------------------------------------
@ -243,7 +262,6 @@ RigCompletionData::CompletionType RicMswPerforationICV::completionType() const
//--------------------------------------------------------------------------------------------------
RicMswPerforationAICD::RicMswPerforationAICD( const QString& label, const RimWellPathValve* wellPathValve )
: RicMswValve( label, wellPathValve )
, m_valid( false )
, m_deviceOpen( false )
, m_length( 0.0 )
, m_flowScalingFactor( 0.0 )
@ -258,22 +276,6 @@ RigCompletionData::CompletionType RicMswPerforationAICD::completionType() const
return RigCompletionData::PERFORATION_AICD;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicMswPerforationAICD::isValid() const
{
return m_valid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicMswPerforationAICD::setIsValid( bool valid )
{
m_valid = valid;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -103,7 +103,11 @@ public:
const RimWellPathValve* wellPathValve() const;
bool isValid() const;
void setIsValid( bool valid );
private:
bool m_valid;
const RimWellPathValve* m_wellPathValve;
};
@ -164,8 +168,6 @@ public:
RicMswPerforationAICD( const QString& label, const RimWellPathValve* wellPathValve );
RigCompletionData::CompletionType completionType() const override;
bool isValid() const;
void setIsValid( bool valid );
bool isOpen() const;
void setIsOpen( bool deviceOpen );
double length() const;
@ -177,7 +179,6 @@ public:
std::array<double, AICD_NUM_PARAMS>& values();
private:
bool m_valid;
bool m_deviceOpen;
std::array<double, AICD_NUM_PARAMS> m_parameters;
double m_length;

View File

@ -53,10 +53,11 @@ bool RicMswICDAccumulator::accumulateValveParameters( const RimWellPathValve* we
double icdAreaFactor = totalIcdArea * overlapLength / perforationCompsegsLength;
m_areaSum += icdAreaFactor;
if ( icdAreaFactor > eps )
{
m_valid = true;
m_areaSum += icdAreaFactor;
m_coefficientCalculator.addValueAndWeight( wellPathValve->flowCoefficient(), icdAreaFactor );
return true;
}
@ -72,9 +73,10 @@ void RicMswICDAccumulator::applyToSuperValve()
std::shared_ptr<RicMswWsegValve> icd = std::dynamic_pointer_cast<RicMswWsegValve>( m_valve );
CVF_ASSERT( icd );
icd->setArea( m_areaSum );
if ( m_coefficientCalculator.validAggregatedWeight() )
if ( m_coefficientCalculator.validAggregatedWeight() && m_valid )
{
icd->setIsValid( m_valid );
icd->setArea( m_areaSum );
icd->setFlowCoefficient( m_coefficientCalculator.weightedMean() );
}
}
@ -84,7 +86,6 @@ void RicMswICDAccumulator::applyToSuperValve()
//--------------------------------------------------------------------------------------------------
RicMswAICDAccumulator::RicMswAICDAccumulator( std::shared_ptr<RicMswValve> valve, RiaEclipseUnitTools::UnitSystem unitSystem )
: RicMswValveAccumulator( valve, unitSystem )
, m_valid( false )
, m_deviceOpen( false )
, m_accumulatedLength( 0.0 )
, m_accumulatedFlowScalingFactorDivisor( 0.0 )
@ -144,9 +145,10 @@ bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* w
//--------------------------------------------------------------------------------------------------
void RicMswAICDAccumulator::applyToSuperValve()
{
const double eps = 1.0e-8;
std::shared_ptr<RicMswPerforationAICD> aicd = std::dynamic_pointer_cast<RicMswPerforationAICD>( m_valve );
if ( aicd )
if ( aicd && m_valid && m_accumulatedLength > eps )
{
std::array<double, AICD_NUM_PARAMS> values;
@ -167,7 +169,7 @@ void RicMswAICDAccumulator::applyToSuperValve()
// See https://github.com/OPM/ResInsight/issues/6126
double flowScalingFactor = 0.0;
if ( m_accumulatedFlowScalingFactorDivisor > 1.0e-8 )
if ( m_accumulatedFlowScalingFactorDivisor > eps )
{
flowScalingFactor = 1.0 / m_accumulatedFlowScalingFactorDivisor;
}
@ -177,3 +179,11 @@ void RicMswAICDAccumulator::applyToSuperValve()
aicd->values() = values;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RicMswAICDAccumulator::accumulatedLength() const
{
return m_accumulatedLength;
}

View File

@ -36,6 +36,7 @@ public:
RicMswValveAccumulator( std::shared_ptr<RicMswValve> valve, RiaEclipseUnitTools::UnitSystem unitSystem )
: m_valve( valve )
, m_unitSystem( unitSystem )
, m_valid( false )
{
}
virtual bool accumulateValveParameters( const RimWellPathValve* wellPathValve,
@ -48,6 +49,7 @@ public:
protected:
std::shared_ptr<RicMswValve> m_valve;
RiaEclipseUnitTools::UnitSystem m_unitSystem;
bool m_valid;
};
//==================================================================================================
@ -74,13 +76,13 @@ class RicMswAICDAccumulator : public RicMswValveAccumulator
{
public:
RicMswAICDAccumulator( std::shared_ptr<RicMswValve> valve, RiaEclipseUnitTools::UnitSystem unitSystem );
bool accumulateValveParameters( const RimWellPathValve* wellPathValve,
double overlapLength,
double perforationCompsegsLength ) override;
void applyToSuperValve() override;
bool accumulateValveParameters( const RimWellPathValve* wellPathValve,
double overlapLength,
double perforationCompsegsLength ) override;
void applyToSuperValve() override;
double accumulatedLength() const;
private:
bool m_valid;
bool m_deviceOpen;
std::array<RiaWeightedMeanCalculator<double>, AICD_NUM_PARAMS> m_meanCalculators;
double m_accumulatedLength;

View File

@ -665,105 +665,107 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable( RifTextDataTabl
if ( completion->completionType() == RigCompletionData::PERFORATION_AICD )
{
std::shared_ptr<RicMswPerforationAICD> aicd = std::static_pointer_cast<RicMswPerforationAICD>( completion );
if ( !aicd->isValid() )
if ( aicd->isValid() )
{
if ( !foundValve )
{
std::vector<QString> columnDescriptions =
{"Well Name",
"Segment Number",
"Segment Number",
"Strength of AICD",
"Flow Scaling Factor for AICD",
"Density of Calibration Fluid",
"Viscosity of Calibration Fluid",
"Critical water in liquid fraction for emulsions viscosity model",
"Emulsion viscosity transition region",
"Max ratio of emulsion viscosity to continuous phase viscosity",
"Flow scaling factor method",
"Maximum flowrate for AICD device",
"Volume flow rate exponent, x",
"Viscosity function exponent, y",
"Device OPEN/SHUT",
"Exponent of the oil flowing fraction in the density mixture calculation",
"Exponent of the water flowing fraction in the density mixture calculation",
"Exponent of the gas flowing fraction in the density mixture calculation",
"Exponent of the oil flowing fraction in the density viscosity calculation",
"Exponent of the water flowing fraction in the density viscosity calculation",
"Exponent of the gas flowing fraction in the density viscosity calculation"};
tighterFormatter.keyword( "WSEGAICD" );
tighterFormatter.comment( "Column Overview:" );
for ( size_t i = 0; i < columnDescriptions.size(); ++i )
{
tighterFormatter.comment(
QString( "%1: %2" ).arg( i + 1, 2, 10, QChar( '0' ) ).arg( columnDescriptions[i] ) );
}
std::vector<RifTextDataTableColumn> header;
for ( size_t i = 1; i <= 21; ++i )
{
QString cName = QString( "%1" ).arg( i, 2, 10, QChar( '0' ) );
RifTextDataTableColumn col( cName,
RifTextDataTableDoubleFormatting(
RifTextDataTableDoubleFormat::RIF_CONSISE ),
RIGHT );
header.push_back( col );
}
tighterFormatter.header( header );
foundValve = true;
}
if ( !aicd->subSegments().empty() )
{
CVF_ASSERT( aicd->subSegments().size() == 1u );
tighterFormatter.comment( aicd->label() );
tighterFormatter.add( exportInfo.wellPath()->completions()->wellNameForExport() ); // #1
tighterFormatter.add( aicd->subSegments().front()->segmentNumber() );
tighterFormatter.add( aicd->subSegments().front()->segmentNumber() );
std::array<double, AICD_NUM_PARAMS> values = aicd->values();
tighterFormatter.add( values[AICD_STRENGTH] );
tighterFormatter.add( aicd->flowScalingFactor() ); // #5 Flow scaling factor used when item #11
// is set to '1'
tighterFormatter.add( values[AICD_DENSITY_CALIB_FLUID] );
tighterFormatter.add( values[AICD_VISCOSITY_CALIB_FLUID] );
tighterFormatter.addValueOrDefaultMarker( values[AICD_CRITICAL_WATER_IN_LIQUID_FRAC],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_EMULSION_VISC_TRANS_REGION],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_MAX_RATIO_EMULSION_VISC],
RicMswExportInfo::defaultDoubleValue() ); // #10
tighterFormatter.add( 1 ); // #11 : Always use method "b. Scale factor". The value of the scale
// factor is given in item #5
tighterFormatter.addValueOrDefaultMarker( values[AICD_MAX_FLOW_RATE],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.add( values[AICD_VOL_FLOW_EXP] );
tighterFormatter.add( values[AICD_VISOSITY_FUNC_EXP] );
tighterFormatter.add( aicd->isOpen() ? "OPEN" : "SHUT" ); // #15
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_OIL_FRAC_DENSITY],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_WATER_FRAC_DENSITY],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_GAS_FRAC_DENSITY],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_OIL_FRAC_VISCOSITY],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_WATER_FRAC_VISCOSITY],
RicMswExportInfo::defaultDoubleValue() ); // #20
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_GAS_FRAC_VISCOSITY],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.rowCompleted();
}
}
else
{
RiaLogging::error( QString( "Export AICD Valve (%1): Valve is invalid. At least one required "
"template parameter is not set." )
.arg( aicd->label() ) );
}
if ( !foundValve )
{
std::vector<QString> columnDescriptions =
{"Well Name",
"Segment Number",
"Segment Number",
"Strength of AICD",
"Flow Scaling Factor for AICD",
"Density of Calibration Fluid",
"Viscosity of Calibration Fluid",
"Critical water in liquid fraction for emulsions viscosity model",
"Emulsion viscosity transition region",
"Max ratio of emulsion viscosity to continuous phase viscosity",
"Flow scaling factor method",
"Maximum flowrate for AICD device",
"Volume flow rate exponent, x",
"Viscosity function exponent, y",
"Device OPEN/SHUT",
"Exponent of the oil flowing fraction in the density mixture calculation",
"Exponent of the water flowing fraction in the density mixture calculation",
"Exponent of the gas flowing fraction in the density mixture calculation",
"Exponent of the oil flowing fraction in the density viscosity calculation",
"Exponent of the water flowing fraction in the density viscosity calculation",
"Exponent of the gas flowing fraction in the density viscosity calculation"};
tighterFormatter.keyword( "WSEGAICD" );
tighterFormatter.comment( "Column Overview:" );
for ( size_t i = 0; i < columnDescriptions.size(); ++i )
{
tighterFormatter.comment(
QString( "%1: %2" ).arg( i + 1, 2, 10, QChar( '0' ) ).arg( columnDescriptions[i] ) );
}
std::vector<RifTextDataTableColumn> header;
for ( size_t i = 1; i <= 21; ++i )
{
QString cName = QString( "%1" ).arg( i, 2, 10, QChar( '0' ) );
RifTextDataTableColumn col( cName,
RifTextDataTableDoubleFormatting(
RifTextDataTableDoubleFormat::RIF_CONSISE ),
RIGHT );
header.push_back( col );
}
tighterFormatter.header( header );
foundValve = true;
}
if ( !aicd->subSegments().empty() )
{
CVF_ASSERT( aicd->subSegments().size() == 1u );
tighterFormatter.comment( aicd->label() );
tighterFormatter.add( exportInfo.wellPath()->completions()->wellNameForExport() ); // #1
tighterFormatter.add( aicd->subSegments().front()->segmentNumber() );
tighterFormatter.add( aicd->subSegments().front()->segmentNumber() );
std::array<double, AICD_NUM_PARAMS> values = aicd->values();
tighterFormatter.add( values[AICD_STRENGTH] );
tighterFormatter.add( aicd->flowScalingFactor() ); // #5 Flow scaling factor used when item #11 is
// set to '1'
tighterFormatter.add( values[AICD_DENSITY_CALIB_FLUID] );
tighterFormatter.add( values[AICD_VISCOSITY_CALIB_FLUID] );
tighterFormatter.addValueOrDefaultMarker( values[AICD_CRITICAL_WATER_IN_LIQUID_FRAC],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_EMULSION_VISC_TRANS_REGION],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_MAX_RATIO_EMULSION_VISC],
RicMswExportInfo::defaultDoubleValue() ); // #10
tighterFormatter.add( 1 ); // #11 : Always use method "b. Scale factor". The value of the scale
// factor is given in item #5
tighterFormatter.addValueOrDefaultMarker( values[AICD_MAX_FLOW_RATE],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.add( values[AICD_VOL_FLOW_EXP] );
tighterFormatter.add( values[AICD_VISOSITY_FUNC_EXP] );
tighterFormatter.add( aicd->isOpen() ? "OPEN" : "SHUT" ); // #15
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_OIL_FRAC_DENSITY],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_WATER_FRAC_DENSITY],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_GAS_FRAC_DENSITY],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_OIL_FRAC_VISCOSITY],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_WATER_FRAC_VISCOSITY],
RicMswExportInfo::defaultDoubleValue() ); // #20
tighterFormatter.addValueOrDefaultMarker( values[AICD_EXP_GAS_FRAC_VISCOSITY],
RicMswExportInfo::defaultDoubleValue() );
tighterFormatter.rowCompleted();
}
}
}
}
@ -1729,6 +1731,7 @@ void RicWellPathExportMswCompletionsImpl::writeValveWelsegsSegment( std::shared_
int* segmentNumber )
{
CVF_ASSERT( valve );
if ( !valve->isValid() ) return;
formatter.comment( valve->label() );