WGState: template Scalar type

This commit is contained in:
Arne Morten Kvarving
2024-02-17 18:13:46 +01:00
parent 67f1811234
commit 15d75c5228
4 changed files with 27 additions and 18 deletions

View File

@@ -289,7 +289,7 @@ protected:
}
const WGState& prevWGState() const
const WGState<double>& prevWGState() const
{
return this->last_valid_wgstate_;
}
@@ -301,7 +301,7 @@ protected:
last_valid_well_state_ member, that state can then be recovered
with a subsequent call to resetWellState().
*/
void commitWGState(WGState wgstate)
void commitWGState(WGState<double> wgstate)
{
this->last_valid_wgstate_ = std::move(wgstate);
}
@@ -575,9 +575,9 @@ protected:
commitWellState(), resetWellState(), nupcolWellState() and
updateNupcolWellState().
*/
WGState active_wgstate_;
WGState last_valid_wgstate_;
WGState nupcol_wgstate_;
WGState<double> active_wgstate_;
WGState<double> last_valid_wgstate_;
WGState<double> nupcol_wgstate_;
bool glift_debug = false;

View File

@@ -26,33 +26,40 @@
namespace Opm {
WGState::WGState(const PhaseUsage& pu) :
template<class Scalar>
WGState<Scalar>::WGState(const PhaseUsage& pu) :
well_state(pu),
group_state(pu.num_phases),
well_test_state{}
{}
WGState WGState::serializationTestObject(const ParallelWellInfo& pinfo)
template<class Scalar>
WGState<Scalar> WGState<Scalar>::
serializationTestObject(const ParallelWellInfo& pinfo)
{
WGState result(PhaseUsage{});
result.well_state = WellState<double>::serializationTestObject(pinfo);
result.group_state = GroupState<double>::serializationTestObject();
result.well_state = WellState<Scalar>::serializationTestObject(pinfo);
result.group_state = GroupState<Scalar>::serializationTestObject();
result.well_test_state = WellTestState::serializationTestObject();
return result;
}
void WGState::wtest_state(WellTestState wtest_state)
template<class Scalar>
void WGState<Scalar>::wtest_state(WellTestState wtest_state)
{
wtest_state.filter_wells( this->well_state.wells() );
this->well_test_state = std::move(wtest_state);
}
bool WGState::operator==(const WGState& rhs) const
template<class Scalar>
bool WGState<Scalar>::operator==(const WGState& rhs) const
{
return this->well_state == rhs.well_state &&
this->group_state == rhs.group_state &&
this->well_test_state == rhs.well_test_state;
}
template struct WGState<double>;
}

View File

@@ -34,15 +34,17 @@ class ParallelWellInfo;
struct PhaseUsage;
struct WGState {
template<class Scalar>
struct WGState
{
WGState(const PhaseUsage& pu);
static WGState serializationTestObject(const ParallelWellInfo& pinfo);
void wtest_state(WellTestState wtest_state);
WellState<double> well_state;
GroupState<double> group_state;
WellState<Scalar> well_state;
GroupState<Scalar> group_state;
WellTestState well_test_state;
bool operator==(const WGState&) const;

View File

@@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(WellState)
BOOST_AUTO_TEST_CASE(WGState)
{
Opm::ParallelWellInfo dummy;
auto data_out = Opm::WGState::serializationTestObject(dummy);
auto data_out = Opm::WGState<double>::serializationTestObject(dummy);
Opm::Serialization::MemPacker packer;
Opm::Serializer ser(packer);
ser.pack(data_out);
@@ -287,9 +287,9 @@ public:
closed_this_step_ = {"test1", "test2"};
guideRate_.setSerializationTestData();
node_pressures_ = {{"test3", 4.0}};
active_wgstate_ = WGState::serializationTestObject(dummy);
last_valid_wgstate_ = WGState::serializationTestObject(dummy);
nupcol_wgstate_ = WGState::serializationTestObject(dummy);
active_wgstate_ = WGState<double>::serializationTestObject(dummy);
last_valid_wgstate_ = WGState<double>::serializationTestObject(dummy);
nupcol_wgstate_ = WGState<double>::serializationTestObject(dummy);
last_glift_opt_time_ = 5.0;
switched_prod_groups_ = {{"test4", "test5"}};
switched_inj_groups_ = {{{"test4", Phase::SOLVENT}, "test5"}};