diff --git a/opm/simulators/wells/PerfData.cpp b/opm/simulators/wells/PerfData.cpp index 117998fd5..1277a4927 100644 --- a/opm/simulators/wells/PerfData.cpp +++ b/opm/simulators/wells/PerfData.cpp @@ -21,16 +21,17 @@ #if HAVE_CONFIG_H #include "config.h" #endif // HAVE_CONFIG_H +#include #include -#include namespace Opm { -PerfData::PerfData(const std::size_t num_perf, - const double pressure_first_connection_, - const bool injector_, - const std::size_t num_phases) +template +PerfData::PerfData(const std::size_t num_perf, + const Scalar pressure_first_connection_, + const bool injector_, + const std::size_t num_phases) : injector(injector_) , pressure_first_connection(pressure_first_connection_) , pressure(num_perf) @@ -57,7 +58,8 @@ PerfData::PerfData(const std::size_t num_perf, } } -PerfData PerfData::serializationTestObject() +template +PerfData PerfData::serializationTestObject() { PerfData result; result.pressure_first_connection = 1.0; @@ -79,22 +81,25 @@ PerfData PerfData::serializationTestObject() result.water_throughput = {25.0, 26.0}; result.skin_pressure = {27.0, 28.0}; result.water_velocity = {29.0, 30.0}; - result.filtrate_data = ConnFiltrateData::serializationTestObject(); + result.filtrate_data = ConnFiltrateData::serializationTestObject(); return result; } -std::size_t PerfData::size() const +template +std::size_t PerfData::size() const { return this->pressure.size(); } -bool PerfData::empty() const +template +bool PerfData::empty() const { return this->pressure.empty(); } -bool PerfData::try_assign(const PerfData& other) +template +bool PerfData::try_assign(const PerfData& other) { if (this->size() != other.size()) { return false; @@ -122,7 +127,8 @@ bool PerfData::try_assign(const PerfData& other) return true; } -bool PerfData::operator==(const PerfData& rhs) const +template +bool PerfData::operator==(const PerfData& rhs) const { return (this->pressure_first_connection == rhs.pressure_first_connection) && (this->pressure == rhs.pressure) @@ -147,4 +153,6 @@ bool PerfData::operator==(const PerfData& rhs) const ; } +template class PerfData; + } // namespace Opm diff --git a/opm/simulators/wells/PerfData.hpp b/opm/simulators/wells/PerfData.hpp index acaf7bc65..64e59ebf2 100644 --- a/opm/simulators/wells/PerfData.hpp +++ b/opm/simulators/wells/PerfData.hpp @@ -28,6 +28,7 @@ namespace Opm { +template class PerfData { private: @@ -36,7 +37,7 @@ private: public: PerfData() = default; PerfData(std::size_t num_perf, - double pressure_first_connection_, + Scalar pressure_first_connection_, bool injector_, std::size_t num_phases); @@ -79,30 +80,30 @@ public: // if you're adding a new member representing a dynamically calculated // result, e.g., a flow rate, then please update try_assign() as well. - double pressure_first_connection{}; - std::vector pressure{}; - std::vector rates{}; - std::vector phase_rates{}; - std::vector> phase_mixing_rates{}; - std::vector solvent_rates{}; - std::vector polymer_rates{}; - std::vector brine_rates{}; - std::vector prod_index{}; - std::vector micp_rates{}; + Scalar pressure_first_connection{}; + std::vector pressure{}; + std::vector rates{}; + std::vector phase_rates{}; + std::vector> phase_mixing_rates{}; + std::vector solvent_rates{}; + std::vector polymer_rates{}; + std::vector brine_rates{}; + std::vector prod_index{}; + std::vector micp_rates{}; std::vector cell_index{}; - std::vector connection_transmissibility_factor{}; - std::vector connection_d_factor{}; - std::vector connection_compaction_tmult{}; + std::vector connection_transmissibility_factor{}; + std::vector connection_d_factor{}; + std::vector connection_compaction_tmult{}; std::vector satnum_id{}; std::vector ecl_index{}; // The water_throughput, skin_pressure and water_velocity variables are // only used for injectors to check the injectivity. - std::vector water_throughput{}; - std::vector skin_pressure{}; - std::vector water_velocity{}; + std::vector water_throughput{}; + std::vector skin_pressure{}; + std::vector water_velocity{}; - ConnFiltrateData filtrate_data{}; + ConnFiltrateData filtrate_data{}; }; } // namespace Opm diff --git a/opm/simulators/wells/SingleWellState.cpp b/opm/simulators/wells/SingleWellState.cpp index 81ce631a9..e521ba641 100644 --- a/opm/simulators/wells/SingleWellState.cpp +++ b/opm/simulators/wells/SingleWellState.cpp @@ -62,7 +62,7 @@ SingleWellState::SingleWellState(const std::string& name_, SingleWellState SingleWellState::serializationTestObject(const ParallelWellInfo& pinfo) { SingleWellState result("testing", pinfo, true, 1.0, {}, PhaseUsage{}, 2.0); - result.perf_data = PerfData::serializationTestObject(); + result.perf_data = PerfData::serializationTestObject(); return result; } diff --git a/opm/simulators/wells/SingleWellState.hpp b/opm/simulators/wells/SingleWellState.hpp index de769cc86..02b110610 100644 --- a/opm/simulators/wells/SingleWellState.hpp +++ b/opm/simulators/wells/SingleWellState.hpp @@ -105,7 +105,7 @@ public: std::vector surface_rates; std::vector reservoir_rates; std::vector prev_surface_rates; - PerfData perf_data; + PerfData perf_data; bool trivial_target; SegmentState segments; Events events; diff --git a/tests/test_RestartSerialization.cpp b/tests/test_RestartSerialization.cpp index 29dd74246..81fdb575c 100644 --- a/tests/test_RestartSerialization.cpp +++ b/tests/test_RestartSerialization.cpp @@ -105,7 +105,8 @@ TEST_FOR_TYPE(ALQState) TEST_FOR_TYPE(GroupState) TEST_FOR_TYPE(HardcodedTimeStepControl) TEST_FOR_TYPE(Inplace) -TEST_FOR_TYPE(PerfData) +namespace Opm { using PerfD = PerfData; } +TEST_FOR_TYPE_NAMED(PerfD, PerfData) TEST_FOR_TYPE(PIDAndIterationCountTimeStepControl) TEST_FOR_TYPE(PIDTimeStepControl) TEST_FOR_TYPE(SegmentState) diff --git a/tests/test_wellstate.cpp b/tests/test_wellstate.cpp index 7fdd5d26b..3c8eda326 100644 --- a/tests/test_wellstate.cpp +++ b/tests/test_wellstate.cpp @@ -553,10 +553,10 @@ BOOST_AUTO_TEST_CASE(TESTSegmentState2) { BOOST_AUTO_TEST_CASE(TESTPerfData) { - Opm::PerfData pd1(3, 100, true, 3); - Opm::PerfData pd2(3, 100, true, 3); - Opm::PerfData pd3(2, 100, true, 3); - Opm::PerfData pd4(3, 100, false, 3); + Opm::PerfData pd1(3, 100.0, true, 3); + Opm::PerfData pd2(3, 100.0, true, 3); + Opm::PerfData pd3(2, 100.0, true, 3); + Opm::PerfData pd4(3, 100.0, false, 3); for (std::size_t i = 0; i < 3; i++) {