InjMultMode is assigned to per well

not per connection anymore based on new finding in the reference result.
This commit is contained in:
Kai Bao
2022-12-09 14:31:43 +01:00
parent 2f8f019226
commit a8a10bb81f
6 changed files with 48 additions and 45 deletions

View File

@@ -77,35 +77,28 @@ namespace RestartIO {
Defaulted,
};
enum class InjMultMode {
WREV,
CREV,
CIRR,
NONE,
};
static InjMultMode injModeFromString(const std::string& str);
struct InjMult {
InjMultMode mode {InjMultMode::NONE};
bool is_active {false};
double fracture_pressure {std::numeric_limits<double>::max()};
double multiplier_gradient {0.};
bool active() const
{
return mode != InjMultMode::NONE;
return is_active;
}
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(mode);
serializer(is_active);
serializer(fracture_pressure);
serializer(multiplier_gradient);
}
bool operator==( const InjMult& rhs ) const {
return mode == rhs.mode
return is_active == rhs.is_active
&& fracture_pressure == rhs.fracture_pressure
&& multiplier_gradient == rhs.multiplier_gradient;
}
@@ -157,6 +150,7 @@ namespace RestartIO {
CTFKind kind() const;
InjMult injmult() const;
void setInjMult(const InjMult& inj_mult);
void clearInjMult();
void setState(State state);
void setComplnum(int compnum);

View File

@@ -76,6 +76,15 @@ class Well {
public:
using Status = WellStatus;
enum class InjMultMode {
WREV,
CREV,
CIRR,
NONE,
};
static InjMultMode injModeFromString(const std::string& str);
/*
The elements in this enum are used as bitmasks to keep track
of which controls are present, i.e. the 2^n structure must
@@ -383,6 +392,7 @@ public:
Status getStatus() const;
const std::string& groupName() const;
Phase getPreferredPhase() const;
InjMultMode getInjMultMode() const;
bool hasConnections() const;
const std::vector<const Connection *> getConnections(int completion) const;
@@ -585,6 +595,7 @@ private:
Status status;
PAvg m_pavg;
double well_temperature;
InjMultMode inj_mult_mode = InjMultMode::NONE;
};
std::ostream& operator<<( std::ostream&, const Well::WellInjectionProperties& );

View File

@@ -153,8 +153,6 @@ namespace Opm {
void applyWellPIScaling(const double scaleFactor,
std::vector<bool>& scalingApplicable);
bool underWREVInjMultMode() const;
template <class Serializer>
void serializeOp(Serializer& serializer)
{

View File

@@ -355,18 +355,6 @@ Connection::State Connection::StateFromString( const std::string& stringValue )
throw std::invalid_argument("Unknown enum state string: " + stringValue );
}
Connection::InjMultMode Connection::injModeFromString(const std::string& str) {
if (str == "WREV")
return Connection::InjMultMode::WREV;
else if (str == "CREV")
return Connection::InjMultMode::CREV;
else if (str == "CIRR")
return Connection::InjMultMode::CIRR;
else if (str == "NONE")
return Connection::InjMultMode::NONE;
else
throw std::invalid_argument("Unknow enum INJMultMode string: " + str);
}
std::string Connection::Direction2String(const Direction enumValue)
@@ -464,4 +452,8 @@ void Connection::setInjMult(const Connection::InjMult& inj_mult) {
m_injmult = inj_mult;
}
void Connection::clearInjMult() {
this->setInjMult({});
}
}

View File

@@ -564,6 +564,19 @@ bool Well::updateWellGuideRate(double guide_rate_arg) {
return false;
}
Well::InjMultMode Well::injModeFromString(const std::string& str) {
if (str == "WREV")
return InjMultMode::WREV;
else if (str == "CREV")
return InjMultMode::CREV;
else if (str == "CIRR")
return InjMultMode::CIRR;
else if (str == "NONE")
return InjMultMode::NONE;
else
throw std::invalid_argument("Unknow enum INJMultMode string: " + str);
}
bool Well::updateFoamProperties(std::shared_ptr<WellFoamProperties> foam_properties_arg) {
if (this->wtype.producer()) {
@@ -1311,15 +1324,16 @@ bool Well::handleWINJMULT(const Opm::DeckRecord& record, const KeywordLocation&
return true;
};
// if this record using WREV, with the current ideas, we will rewrite the information to all the connectios regarding
// using the WINJMULT record information
// if this record use CREV or CIRR, and previoiusly, the well is using WREV, we need to discard the WREV setup for
// all the connections. For the connections not specified in the record, the injmult information will be reset.
// check whether it was under WREV previously.
// if yes, we need to reset all the connections for injmult operation
const bool is_prev_wrev = this->inj_mult_mode == InjMultMode::WREV;
const std::string mode = record.getItem("MODE").getTrimmedString(0);
this->inj_mult_mode = injModeFromString(mode);
const double fracture_pressure = record.getItem("FRACTURING_PRESSURE").getSIDouble(0);
const double multiple_gradient = record.getItem("MULTIPLIER_GRADIENT").getSIDouble(0);
auto new_connections = std::make_shared<WellConnections>(this->connections->ordering(), this->headI, this->headJ);
const Connection::InjMult inj_mult {Connection::injModeFromString(mode), fracture_pressure, multiple_gradient};
const Connection::InjMult inj_mult {true, fracture_pressure, multiple_gradient};
if (mode == "WREV") {
// all the connections will share the same INJMULT setup
@@ -1328,16 +1342,17 @@ bool Well::handleWINJMULT(const Opm::DeckRecord& record, const KeywordLocation&
new_connections->add(c);
}
} else if (mode == "CREV" || mode == "CIRR"){
// check whether it was under WREV previously.
// if yes, we need to reset all the connections for injmult operation
const bool is_prev_wrev = this->connections->underWREVInjMultMode();
for (auto c : *this->connections) {
if (match(c)) {
c.setInjMult(inj_mult);
} else {
// if previously defined with WREV for the well, for all the connections
// not specified in the new CREV or CIRR records, we do not consider they have
// an active WINJMULT setup
if (is_prev_wrev) {
// reset the injMult information for this connection
c.setInjMult({});
// basically, disable the injMult for this connection
c.clearInjMult();
}
}
new_connections->add(c);
@@ -1698,3 +1713,7 @@ int Opm::Well::eclipseControlMode(const Well& well,
return eclipseControlMode(ctrl.cmode, well.injectorType());
}
}
Opm::Well::InjMultMode Opm::Well::getInjMultMode() const {
return this->inj_mult_mode;
}

View File

@@ -284,17 +284,6 @@ namespace Opm {
}
}
bool WellConnections::underWREVInjMultMode() const {
// TODO: if the first connection is under WREV, all the connections should be under WREV
// how we can guarantee that?
// and hesitate to add extra member to this class
if (this->m_connections.empty()) {
return false;
}
const bool first_con_wrev = this->m_connections[0].injmult().mode == Connection::InjMultMode::WREV;
return first_con_wrev;
}
void WellConnections::addConnection(const int i, const int j, const int k,
const std::size_t global_index,
const int complnum,