PerfData: template Scalar type

This commit is contained in:
Arne Morten Kvarving
2024-02-17 17:40:22 +01:00
parent ea1f4f822b
commit d350049876
6 changed files with 46 additions and 36 deletions

View File

@@ -21,16 +21,17 @@
#if HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H
#include <opm/simulators/wells/PerfData.hpp>
#include <opm/simulators/wells/ConnFiltrateData.hpp>
#include <opm/simulators/wells/PerfData.hpp>
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<class Scalar>
PerfData<Scalar>::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<class Scalar>
PerfData<Scalar> PerfData<Scalar>::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<double>::serializationTestObject();
result.filtrate_data = ConnFiltrateData<Scalar>::serializationTestObject();
return result;
}
std::size_t PerfData::size() const
template<class Scalar>
std::size_t PerfData<Scalar>::size() const
{
return this->pressure.size();
}
bool PerfData::empty() const
template<class Scalar>
bool PerfData<Scalar>::empty() const
{
return this->pressure.empty();
}
bool PerfData::try_assign(const PerfData& other)
template<class Scalar>
bool PerfData<Scalar>::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<class Scalar>
bool PerfData<Scalar>::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<double>;
} // namespace Opm

View File

@@ -28,6 +28,7 @@
namespace Opm {
template<class Scalar>
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<double> pressure{};
std::vector<double> rates{};
std::vector<double> phase_rates{};
std::vector<std::array<double,4>> phase_mixing_rates{};
std::vector<double> solvent_rates{};
std::vector<double> polymer_rates{};
std::vector<double> brine_rates{};
std::vector<double> prod_index{};
std::vector<double> micp_rates{};
Scalar pressure_first_connection{};
std::vector<Scalar> pressure{};
std::vector<Scalar> rates{};
std::vector<Scalar> phase_rates{};
std::vector<std::array<Scalar,4>> phase_mixing_rates{};
std::vector<Scalar> solvent_rates{};
std::vector<Scalar> polymer_rates{};
std::vector<Scalar> brine_rates{};
std::vector<Scalar> prod_index{};
std::vector<Scalar> micp_rates{};
std::vector<std::size_t> cell_index{};
std::vector<double> connection_transmissibility_factor{};
std::vector<double> connection_d_factor{};
std::vector<double> connection_compaction_tmult{};
std::vector<Scalar> connection_transmissibility_factor{};
std::vector<Scalar> connection_d_factor{};
std::vector<Scalar> connection_compaction_tmult{};
std::vector<int> satnum_id{};
std::vector<std::size_t> ecl_index{};
// The water_throughput, skin_pressure and water_velocity variables are
// only used for injectors to check the injectivity.
std::vector<double> water_throughput{};
std::vector<double> skin_pressure{};
std::vector<double> water_velocity{};
std::vector<Scalar> water_throughput{};
std::vector<Scalar> skin_pressure{};
std::vector<Scalar> water_velocity{};
ConnFiltrateData<double> filtrate_data{};
ConnFiltrateData<Scalar> filtrate_data{};
};
} // namespace Opm

View File

@@ -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<double>::serializationTestObject();
return result;
}

View File

@@ -105,7 +105,7 @@ public:
std::vector<double> surface_rates;
std::vector<double> reservoir_rates;
std::vector<double> prev_surface_rates;
PerfData perf_data;
PerfData<double> perf_data;
bool trivial_target;
SegmentState segments;
Events events;

View File

@@ -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<double>; }
TEST_FOR_TYPE_NAMED(PerfD, PerfData)
TEST_FOR_TYPE(PIDAndIterationCountTimeStepControl)
TEST_FOR_TYPE(PIDTimeStepControl)
TEST_FOR_TYPE(SegmentState)

View File

@@ -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++) {