Skip to content

Commit

Permalink
Add support for RCMASTS
Browse files Browse the repository at this point in the history
Adds support for the RCMASTS keyword.
  • Loading branch information
hakonhagland committed Oct 22, 2024
1 parent 0dea100 commit d492ac7
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 108 deletions.
2 changes: 2 additions & 0 deletions CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/Schedule/ResCoup/GrupSlav.cpp
opm/input/eclipse/Schedule/ResCoup/MasterGroup.cpp
opm/input/eclipse/Schedule/ResCoup/Slaves.cpp
opm/input/eclipse/Schedule/ResCoup/MasterMinimumTimeStep.cpp
opm/input/eclipse/Schedule/UDQ/UDQKeywordHandlers.cpp
opm/input/eclipse/Schedule/UDQ/UDQActive.cpp
opm/input/eclipse/Schedule/UDQ/UDQAssign.cpp
Expand Down Expand Up @@ -1307,6 +1308,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/Schedule/ResCoup/GrupSlav.hpp
opm/input/eclipse/Schedule/ResCoup/MasterGroup.hpp
opm/input/eclipse/Schedule/ResCoup/Slaves.hpp
opm/input/eclipse/Schedule/ResCoup/MasterMinimumTimeStep.hpp
opm/input/eclipse/Schedule/VFPInjTable.hpp
opm/input/eclipse/Schedule/VFPProdTable.hpp
opm/input/eclipse/Schedule/Well/Connection.hpp
Expand Down
58 changes: 58 additions & 0 deletions opm/input/eclipse/Schedule/ResCoup/MasterMinimumTimeStep.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright 2024 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/


#include <opm/input/eclipse/Schedule/ResCoup/MasterMinimumTimeStep.hpp>
#include <opm/input/eclipse/Schedule/ResCoup/ReservoirCouplingInfo.hpp>
#include <opm/input/eclipse/Schedule/ScheduleState.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/R.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/utility/OpmInputError.hpp>
#include "../HandlerContext.hpp"


namespace Opm {

void handleRCMASTS(HandlerContext& handlerContext)
{
auto& schedule_state = handlerContext.state();
auto rescoup = schedule_state.rescoup();
auto tuning = schedule_state.tuning();
const auto& keyword = handlerContext.keyword;
if (keyword.size() != 1) {
throw OpmInputError("RCMASTS keyword requires exactly one record.", keyword.location());
}
auto record = keyword[0];
auto deck_item = record.getItem<ParserKeywords::RCMASTS::MIN_TSTEP>();
if (deck_item.defaultApplied(0)) {
// The default value is the current value TSMINZ
rescoup.masterMinTimeStep(tuning.TSMINZ);
}
else {
auto tstep = deck_item.getSIDouble(0);
if (tstep < 0.0) {
throw OpmInputError("Negative value for RCMASTS is not allowed.", keyword.location());
}
rescoup.masterMinTimeStep(tstep);
}
schedule_state.rescoup.update( std::move( rescoup ));
}

} // namespace Opm

28 changes: 28 additions & 0 deletions opm/input/eclipse/Schedule/ResCoup/MasterMinimumTimeStep.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2024 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RESERVOIR_COUPLING_MASTER_MINIMUM_TIMESTEP_HPP
#define RESERVOIR_COUPLING_MASTER_MINIMUM_TIMESTEP_HPP
namespace Opm {

class HandlerContext;

extern void handleRCMASTS(HandlerContext& handlerContext);

} // namespace Opm
#endif // RESERVOIR_COUPLING_MASTER_MINIMUM_TIMESTEP_HPP
3 changes: 2 additions & 1 deletion opm/input/eclipse/Schedule/ResCoup/ReservoirCouplingInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ bool CouplingInfo::operator==(const CouplingInfo& rhs) const {
return this->m_slaves == rhs.m_slaves &&
this->m_master_groups == rhs.m_master_groups &&
this->m_grup_slavs == rhs.m_grup_slavs &&
this->m_master_mode == rhs.m_master_mode;
this->m_master_mode == rhs.m_master_mode &&
this->m_master_min_time_step == rhs.m_master_min_time_step;
}

CouplingInfo CouplingInfo::serializationTestObject()
Expand Down
85 changes: 59 additions & 26 deletions opm/input/eclipse/Schedule/ResCoup/ReservoirCouplingInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,69 +34,102 @@ class CouplingInfo {
public:
CouplingInfo() = default;

static CouplingInfo serializationTestObject();
const std::map<std::string, Slave>& slaves() const {
return this->m_slaves;
}
std::map<std::string, Slave>& slaves() {
return this->m_slaves;
}
const std::map<std::string, MasterGroup>& masterGroups() const {
return this->m_master_groups;
}
std::map<std::string, MasterGroup>& masterGroups() {
return this->m_master_groups;
}
// Inline methods (alphabetically)

const std::map<std::string, GrupSlav>& grupSlavs() const {
return this->m_grup_slavs;
}

const GrupSlav& grupSlav(const std::string& name) const {
return m_grup_slavs.at(name);
}

std::map<std::string, GrupSlav>& grupSlavs() {
return this->m_grup_slavs;
}
bool operator==(const CouplingInfo& other) const;
bool hasSlave(const std::string& name) const {
return m_slaves.find(name) != m_slaves.end();
}
const Slave& slave(const std::string& name) const {
return m_slaves.at(name);
}
int slaveCount() const {
return m_slaves.size();
}

bool hasGrupSlav(const std::string& name) const {
return m_grup_slavs.find(name) != m_grup_slavs.end();
}
const GrupSlav& grupSlav(const std::string& name) const {
return m_grup_slavs.at(name);
}

bool hasMasterGroup(const std::string& name) const {
return m_master_groups.find(name) != m_master_groups.end();
}

bool hasSlave(const std::string& name) const {
return m_slaves.find(name) != m_slaves.end();
}

const MasterGroup& masterGroup(const std::string& name) const {
return m_master_groups.at(name);
}

int masterGroupCount() const {
return m_master_groups.size();
}

const std::map<std::string, MasterGroup>& masterGroups() const {
return this->m_master_groups;
}

bool masterMode() const {
return m_master_mode;
}

void masterMode(bool master_mode) {
m_master_mode = master_mode;
}

std::map<std::string, MasterGroup>& masterGroups() {
return this->m_master_groups;
}

double masterMinTimeStep() const {
return m_master_min_time_step;
}

void masterMinTimeStep(double tstep) {
m_master_min_time_step = tstep;
}

const Slave& slave(const std::string& name) const {
return m_slaves.at(name);
}

const std::map<std::string, Slave>& slaves() const {
return this->m_slaves;
}

int slaveCount() const {
return m_slaves.size();
}

std::map<std::string, Slave>& slaves() {
return this->m_slaves;
}

template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_slaves);
serializer(m_master_groups);
serializer(m_grup_slavs);
serializer(m_master_mode);
serializer(m_master_min_time_step);
}

// Non-inline methods (defined in CouplingInfo.cpp)

bool operator==(const CouplingInfo& other) const;
static CouplingInfo serializationTestObject();

private:
std::map<std::string, Slave> m_slaves;
std::map<std::string, MasterGroup> m_master_groups;
std::map<std::string, GrupSlav> m_grup_slavs;
bool m_master_mode{false};
// Default value: No limit, however a positive value can be set by using keyword RCMASTS
double m_master_min_time_step{0.0};
};

} // namespace Opm::ReservoirCoupling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,20 @@
#include "GrupSlav.hpp"
#include "Slaves.hpp"
#include "MasterGroup.hpp"
#include "MasterMinimumTimeStep.hpp"

#include <fmt/format.h>

namespace Opm {

namespace {

} // anonymous namespace

std::vector<std::pair<std::string,KeywordHandlers::handler_function>>
getReservoirCouplingHandlers()
{
return {
{ "SLAVES", &handleSLAVES },
{ "GRUPMAST", &handleGRUPMAST},
{ "GRUPSLAV", &handleGRUPSLAV}
{ "GRUPSLAV", &handleGRUPSLAV},
{ "RCMASTS", &handleRCMASTS},
};
}

Expand Down
Loading

0 comments on commit d492ac7

Please sign in to comment.