mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-25 16:51:00 -06:00
Merge pull request #4441 from akva2/alqstate_serialize
ALQState: add serialization support
This commit is contained in:
commit
f526e1a6ca
@ -21,14 +21,25 @@
|
||||
#include "config.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include <opm/simulators/wells/ALQState.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
#include <opm/simulators/wells/ALQState.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
ALQState ALQState::serializationTestObject()
|
||||
{
|
||||
ALQState result;
|
||||
result.current_alq_ = {{"test1", 1.0}};
|
||||
result.default_alq_ = {{"test2", 2.0}, {"test3", 3.0}};
|
||||
result.alq_increase_count_= {{"test4", 4}};
|
||||
result.alq_decrease_count_= {{"test5", 5}};
|
||||
result.debug_counter_ = 6;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
double ALQState::get(const std::string& wname) const {
|
||||
auto iter = this->current_alq_.find(wname);
|
||||
if (iter != this->current_alq_.end())
|
||||
@ -132,7 +143,14 @@ std::size_t ALQState::unpack_data(const double * data) {
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
bool ALQState::operator==(const ALQState& rhs) const
|
||||
{
|
||||
return this->current_alq_ == rhs.current_alq_ &&
|
||||
this->default_alq_ == rhs.default_alq_ &&
|
||||
this->alq_increase_count_ == rhs.alq_increase_count_ &&
|
||||
this->alq_decrease_count_ == rhs.alq_decrease_count_ &&
|
||||
this->debug_counter_ == rhs.debug_counter_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ namespace Opm {
|
||||
|
||||
class ALQState {
|
||||
public:
|
||||
static ALQState serializationTestObject();
|
||||
|
||||
std::size_t pack_size() const;
|
||||
std::size_t unpack_data(const double * data);
|
||||
@ -46,6 +47,18 @@ public:
|
||||
int get_debug_counter();
|
||||
int update_debug_counter();
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer(current_alq_);
|
||||
serializer(default_alq_);
|
||||
serializer(alq_increase_count_);
|
||||
serializer(alq_decrease_count_);
|
||||
serializer(debug_counter_);
|
||||
}
|
||||
|
||||
bool operator==(const ALQState&) const;
|
||||
|
||||
private:
|
||||
std::map<std::string, double> current_alq_;
|
||||
std::map<std::string, double> default_alq_;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <opm/simulators/timestepping/SimulatorTimer.hpp>
|
||||
#include <opm/simulators/timestepping/TimeStepControl.hpp>
|
||||
#include <opm/simulators/utils/SerializationPackers.hpp>
|
||||
#include <opm/simulators/wells/ALQState.hpp>
|
||||
#include <opm/simulators/wells/GroupState.hpp>
|
||||
#include <opm/simulators/wells/SegmentState.hpp>
|
||||
#include <opm/simulators/wells/SingleWellState.hpp>
|
||||
@ -77,6 +78,7 @@ BOOST_AUTO_TEST_CASE(NAME) \
|
||||
#define TEST_FOR_TYPE(TYPE) \
|
||||
TEST_FOR_TYPE_NAMED(TYPE, TYPE)
|
||||
|
||||
TEST_FOR_TYPE(ALQState)
|
||||
TEST_FOR_TYPE(GroupState)
|
||||
TEST_FOR_TYPE(HardcodedTimeStepControl)
|
||||
TEST_FOR_TYPE(PIDAndIterationCountTimeStepControl)
|
||||
|
Loading…
Reference in New Issue
Block a user