diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.cpp index 53c0b08419..59c0115fd0 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.cpp @@ -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; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.h b/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.h index 6fa140ae6a..2f92ce141d 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswCompletions.h @@ -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; }; @@ -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; @@ -177,7 +179,6 @@ class RicMswPerforationAICD : public RicMswValve std::array& values(); private: - bool m_valid; bool m_deviceOpen; std::array m_parameters; double m_length; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp index ed454464c1..b71bbb2fa0 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp @@ -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 icd = std::dynamic_pointer_cast( 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 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 aicd = std::dynamic_pointer_cast( m_valve ); - if ( aicd ) + if ( aicd && m_valid && m_accumulatedLength > eps ) { std::array 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; +} diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h index 7f4532431f..19222368b7 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.h @@ -36,6 +36,7 @@ class RicMswValveAccumulator RicMswValveAccumulator( std::shared_ptr valve, RiaEclipseUnitTools::UnitSystem unitSystem ) : m_valve( valve ) , m_unitSystem( unitSystem ) + , m_valid( false ) { } virtual bool accumulateValveParameters( const RimWellPathValve* wellPathValve, @@ -48,6 +49,7 @@ class RicMswValveAccumulator protected: std::shared_ptr m_valve; RiaEclipseUnitTools::UnitSystem m_unitSystem; + bool m_valid; }; //================================================================================================== @@ -74,13 +76,13 @@ class RicMswAICDAccumulator : public RicMswValveAccumulator { public: RicMswAICDAccumulator( std::shared_ptr 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, AICD_NUM_PARAMS> m_meanCalculators; double m_accumulatedLength; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index cf9ada5609..91f9fd75bd 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -665,104 +665,106 @@ void RicWellPathExportMswCompletionsImpl::generateWsegAicdTable( RifTextDataTabl if ( completion->completionType() == RigCompletionData::PERFORATION_AICD ) { std::shared_ptr aicd = std::static_pointer_cast( 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 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 ) + if ( !foundValve ) { - tighterFormatter.comment( - QString( "%1: %2" ).arg( i + 1, 2, 10, QChar( '0' ) ).arg( columnDescriptions[i] ) ); - } + std::vector 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 header; - for ( size_t i = 1; i <= 21; ++i ) + std::vector 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() ) { - QString cName = QString( "%1" ).arg( i, 2, 10, QChar( '0' ) ); - RifTextDataTableColumn col( cName, - RifTextDataTableDoubleFormatting( - RifTextDataTableDoubleFormat::RIF_CONSISE ), - RIGHT ); - header.push_back( col ); + 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 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(); } - tighterFormatter.header( header ); - - foundValve = true; } - if ( !aicd->subSegments().empty() ) + else { - 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 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(); + RiaLogging::error( QString( "Export AICD Valve (%1): Valve is invalid. At least one required " + "template parameter is not set." ) + .arg( aicd->label() ) ); } } } @@ -1729,6 +1731,7 @@ void RicWellPathExportMswCompletionsImpl::writeValveWelsegsSegment( std::shared_ int* segmentNumber ) { CVF_ASSERT( valve ); + if ( !valve->isValid() ) return; formatter.comment( valve->label() );