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;
};
//==================================================================================================
@ -78,9 +80,9 @@ public:
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,13 +665,8 @@ 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() )
{
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 =
@ -730,8 +725,8 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable( RifTextDataTabl
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( 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] );
@ -765,6 +760,13 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable( RifTextDataTabl
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 )
@ -1729,6 +1731,7 @@ void RicWellPathExportMswCompletionsImpl::writeValveWelsegsSegment( std::shared_
int* segmentNumber )
{
CVF_ASSERT( valve );
if ( !valve->isValid() ) return;
formatter.comment( valve->label() );