From ebfa768fd24996e68bee9e275faef1dd7e1c604d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 16 Dec 2019 14:46:04 +0100 Subject: [PATCH] Segment: Make Type Predicates Free Functions That way, we won't have to pollute the Segment API when adding new segment types. While here, also reduce header file coupling by forward-declaring SpiralICD and Valve in Segment.hpp. --- .../EclipseState/Schedule/MSW/Segment.hpp | 40 ++++++++++--------- .../Schedule/MSW/WellSegments.hpp | 5 +++ src/opm/output/eclipse/AggregateMSWData.cpp | 15 +++---- .../EclipseState/Schedule/MSW/Segment.cpp | 4 +- .../Schedule/MSW/WellSegments.cpp | 3 +- .../EclipseState/Schedule/Schedule.cpp | 4 +- tests/parser/MultisegmentWellTests.cpp | 3 +- 7 files changed, 44 insertions(+), 30 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp b/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp index acacc8310..e408a53b1 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp @@ -22,8 +22,11 @@ #include #include -#include -#include + +namespace Opm { + class SpiralICD; + class Valve; +} namespace Opm { @@ -54,21 +57,6 @@ namespace Opm { SegmentType segmentType() const; - bool isRegular() const - { - return this->segmentType() == SegmentType::REGULAR; - } - - bool isSpiralICD() const - { - return this->segmentType() == SegmentType::SICD; - } - - bool isValve() const - { - return this->segmentType() == SegmentType::VALVE; - } - void setVolume(const double volume_in); void setDepthAndLength(const double depth_in, const double length_in); @@ -135,7 +123,7 @@ namespace Opm { bool m_data_ready; // indicate the type of the segment - // regular or spiral ICD + // regular, spiral ICD, or Valve. SegmentType m_segment_type = SegmentType::REGULAR; // information related to SpiralICD. It is nullptr for segments are not @@ -151,8 +139,22 @@ namespace Opm { // They are not used in the simulations and we are not supporting the plotting. // There are other three properties for segment related to thermal conduction, // while they are not supported by the keyword at the moment. - }; + + inline bool isRegular(const Segment& segment) + { + return segment.segmentType() == Segment::SegmentType::REGULAR; + } + + inline bool isSpiralICD(const Segment& segment) + { + return segment.segmentType() == Segment::SegmentType::SICD; + } + + inline bool isValve(const Segment& segment) + { + return segment.segmentType() == Segment::SegmentType::VALVE; + } } #endif diff --git a/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp b/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp index 939e65aab..5452155d2 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp @@ -25,6 +25,11 @@ #include +namespace Opm { + class SpiralICD; + class Valve; +} + namespace Opm { class DeckKeyword; diff --git a/src/opm/output/eclipse/AggregateMSWData.cpp b/src/opm/output/eclipse/AggregateMSWData.cpp index dad468bcd..344021200 100644 --- a/src/opm/output/eclipse/AggregateMSWData.cpp +++ b/src/opm/output/eclipse/AggregateMSWData.cpp @@ -22,8 +22,9 @@ #include #include - #include + +#include #include #include #include @@ -452,11 +453,11 @@ namespace { const std::size_t baseIndex, ISegArray& iSeg) { - if (segment.isSpiralICD()) { + if (isSpiralICD(segment)) { assignSpiralICDCharacteristics(segment, baseIndex, iSeg); } - if (segment.isValve()) { + if (isValve(segment)) { assignValveCharacteristics(baseIndex, iSeg); } } @@ -488,7 +489,7 @@ namespace { iSeg[iS + 7] = sumConnectionsSegment(completionSet, welSegSet, ind); iSeg[iS + 8] = iSeg[iS+0]; - if (! segment.isRegular()) { + if (! isRegular(segment)) { assignSegmentTypeCharacteristics(segment, iS, iSeg); } } @@ -617,11 +618,11 @@ namespace { const int baseIndex, RSegArray& rSeg) { - if (segment.isSpiralICD()) { + if (isSpiralICD(segment)) { assignSpiralICDCharacteristics(segment, usys, baseIndex, rSeg); } - if (segment.isValve()) { + if (isValve(segment)) { assignValveCharacteristics(segment, usys, baseIndex, rSeg); } } @@ -773,7 +774,7 @@ namespace { rSeg[iS + 109] = 1.0; rSeg[iS + 110] = 1.0; - if (! segment.isRegular()) { + if (! isRegular(segment)) { assignSegmentTypeCharacteristics(segment, units, iS, rSeg); } } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp index cdd1794f9..8bebd9f45 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp @@ -18,6 +18,9 @@ */ #include +#include +#include + #include namespace Opm { @@ -194,4 +197,3 @@ namespace Opm { } } - diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp index cd6134254..2e6ecd66d 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp @@ -30,9 +30,10 @@ #include #include #include +#include +#include #include - namespace Opm { const std::string& WellSegments::wellName() const { diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 34928c79e..582dbd8d3 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -46,8 +46,10 @@ #include #include #include -#include +#include #include +#include +#include #include #include diff --git a/tests/parser/MultisegmentWellTests.cpp b/tests/parser/MultisegmentWellTests.cpp index 92592f1d4..034563374 100644 --- a/tests/parser/MultisegmentWellTests.cpp +++ b/tests/parser/MultisegmentWellTests.cpp @@ -29,11 +29,12 @@ #include - #include #include #include +#include +#include #include #include