Skip to content

Commit

Permalink
Avoid outputting invalid aicd segments
Browse files Browse the repository at this point in the history
  • Loading branch information
lindkvis authored and magnesj committed Oct 20, 2020
1 parent 94abc8a commit ef242e4
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
}

Expand All @@ -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;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -196,6 +213,7 @@ void RicMswWsegValve::setArea( double icdArea )
RicMswFishbonesICD::RicMswFishbonesICD( const QString& label, const RimWellPathValve* wellPathValve )
: RicMswWsegValve( label, wellPathValve )
{
setIsValid( true );
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -228,6 +246,7 @@ RigCompletionData::CompletionType RicMswPerforationICD::completionType() const
RicMswPerforationICV::RicMswPerforationICV( const QString& label, const RimWellPathValve* wellPathValve )
: RicMswWsegValve( label, wellPathValve )
{
setIsValid( true );
}

//-------------------------------------------------------------------
Expand All @@ -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 )
Expand All @@ -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;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ class RicMswValve : public RicMswCompletion

const RimWellPathValve* wellPathValve() const;

bool isValid() const;
void setIsValid( bool valid );

private:
bool m_valid;
const RimWellPathValve* m_wellPathValve;
};

Expand Down Expand Up @@ -164,8 +168,6 @@ class RicMswPerforationAICD : public RicMswValve
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;
Expand All @@ -177,7 +179,6 @@ class RicMswPerforationAICD : public RicMswValve
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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() );
}
}
Expand All @@ -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 )
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}
Expand All @@ -177,3 +179,11 @@ void RicMswAICDAccumulator::applyToSuperValve()
aicd->values() = values;
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RicMswAICDAccumulator::accumulatedLength() const
{
return m_accumulatedLength;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class RicMswValveAccumulator
RicMswValveAccumulator( std::shared_ptr<RicMswValve> valve, RiaEclipseUnitTools::UnitSystem unitSystem )
: m_valve( valve )
, m_unitSystem( unitSystem )
, m_valid( false )
{
}
virtual bool accumulateValveParameters( const RimWellPathValve* wellPathValve,
Expand All @@ -48,6 +49,7 @@ class RicMswValveAccumulator
protected:
std::shared_ptr<RicMswValve> m_valve;
RiaEclipseUnitTools::UnitSystem m_unitSystem;
bool m_valid;
};

//==================================================================================================
Expand All @@ -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;
Expand Down
Loading

0 comments on commit ef242e4

Please sign in to comment.