Add operator== to AQuiferCT

Initial pressure is stored as std::pair<bool, double> instead of
std::shared_ptr<double>.
This commit is contained in:
Joakim Hove
2020-02-05 20:00:44 +01:00
parent f666ab0544
commit f91630a62d
3 changed files with 33 additions and 8 deletions

View File

@@ -61,9 +61,11 @@ namespace Opm {
theta , // angle subtended by the aquifer boundary
c2 ; // 6.283 (METRIC, PVT-M); 1.1191 (FIELD); 6.283 (LAB).
std::shared_ptr<double> p0; //Initial aquifer pressure at datum depth, d0
std::pair<bool, double> p0; //Initial aquifer pressure at datum depth, d0
std::vector<double> td, pi;
std::vector<int> cell_id;
bool operator==(const AQUCT_data& other) const;
};
AquiferCT(const TableManager& tables, const Deck& deck);
@@ -71,6 +73,7 @@ namespace Opm {
std::size_t size() const;
std::vector<AquiferCT::AQUCT_data>::const_iterator begin() const;
std::vector<AquiferCT::AQUCT_data>::const_iterator end() const;
bool operator==(const AquiferCT& other) const;
private:
std::vector<AquiferCT::AQUCT_data> m_aquct;
};

View File

@@ -58,12 +58,11 @@ AquiferCT::AQUCT_data::AQUCT_data(const DeckRecord& record, const TableManager&
c1(1.0),
h(record.getItem("THICKNESS_AQ").getSIDouble(0)),
theta( record.getItem("INFLUENCE_ANGLE").getSIDouble(0)/360.0),
c2(6.283) // Value of C2 used by E100 (for METRIC, PVT-M and LAB unit systems)
c2(6.283), // Value of C2 used by E100 (for METRIC, PVT-M and LAB unit systems)
p0(std::make_pair(false, 0))
{
if (record.getItem("P_INI").hasValue(0)) {
double * raw_ptr = new double( record.getItem("P_INI").getSIDouble(0) );
this->p0.reset( raw_ptr );
}
if (record.getItem("P_INI").hasValue(0))
this->p0 = std::make_pair(true, record.getItem("P_INI").getSIDouble(0));
// Get the correct influence table values
if (this->inftableID > 1) {
@@ -79,6 +78,24 @@ AquiferCT::AQUCT_data::AQUCT_data(const DeckRecord& record, const TableManager&
}
bool AquiferCT::AQUCT_data::operator==(const AquiferCT::AQUCT_data& other) const {
return this->aquiferID == other.aquiferID &&
this->inftableID == other.inftableID &&
this->pvttableID == other.pvttableID &&
this->phi_aq == other.phi_aq &&
this->C_t == other.C_t &&
this->r_o == other.r_o &&
this->k_a == other.k_a &&
this->c1 == other.c1 &&
this->h == other.h &&
this->theta == other.theta &&
this->c2 == other.c2 &&
this->p0 == other.p0 &&
this->td == other.td &&
this->pi == other.pi &&
this->cell_id == other.cell_id;
}
AquiferCT::AquiferCT(const TableManager& tables, const Deck& deck)
{
using AQUCT = ParserKeywords::AQUCT;
@@ -102,4 +119,8 @@ std::vector<AquiferCT::AQUCT_data>::const_iterator AquiferCT::begin() const {
std::vector<AquiferCT::AQUCT_data>::const_iterator AquiferCT::end() const {
return this->m_aquct.end();
}
bool AquiferCT::operator==(const AquiferCT& other) const {
return this->m_aquct == other.m_aquct;
}
}

View File

@@ -112,7 +112,8 @@ BOOST_AUTO_TEST_CASE(AquiferCTTest){
BOOST_CHECK_EQUAL(it.aquiferID , 1);
BOOST_CHECK_EQUAL(it.phi_aq , 0.3);
BOOST_CHECK_EQUAL(it.inftableID , 2);
BOOST_CHECK_CLOSE(*(it.p0), 1.5e5, 1e-6);
BOOST_CHECK(it.p0.first == true);
BOOST_CHECK_CLOSE(it.p0.second, 1.5e5, 1e-6);
}
BOOST_CHECK_EQUAL(aquiferct.size(), 1);
}
@@ -124,7 +125,7 @@ BOOST_AUTO_TEST_CASE(AquiferCTTest){
BOOST_CHECK_EQUAL(it.aquiferID , 1);
BOOST_CHECK_EQUAL(it.phi_aq , 0.3);
BOOST_CHECK_EQUAL(it.inftableID , 2);
BOOST_CHECK(it.p0 == nullptr);
BOOST_CHECK(it.p0.first == false);
}
}
}