-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for SLAVES keyword #4114
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
opm/input/eclipse/Schedule/ResCoup/ReservoirCouplingInfo.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
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 <stdexcept> | ||
|
||
#include <opm/input/eclipse/Schedule/ResCoup/ReservoirCouplingInfo.hpp> | ||
|
||
namespace Opm { | ||
namespace ReservoirCoupling { | ||
Slave Slave::serializationTestObject() | ||
{ | ||
return Slave{"RES-1", "RC-01_MOD1_PRED", "../mod1", 1}; | ||
} | ||
|
||
bool Slave::operator==(const Slave& rhs) const { | ||
return this->m_name == rhs.m_name; | ||
} | ||
|
||
bool CouplingInfo::operator==(const CouplingInfo& rhs) const { | ||
return this->m_slaves == rhs.m_slaves; | ||
} | ||
|
||
CouplingInfo CouplingInfo::serializationTestObject() | ||
{ | ||
CouplingInfo info; | ||
info.m_slaves = {{"SLAVE1", Slave::serializationTestObject()}}; | ||
return info; | ||
} | ||
|
||
} // namespace ReservoirCoupling | ||
} // namespace Opm |
111 changes: 111 additions & 0 deletions
111
opm/input/eclipse/Schedule/ResCoup/ReservoirCouplingInfo.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
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_SLAVES_HPP | ||
#define RESERVOIR_COUPLING_SLAVES_HPP | ||
|
||
#include <optional> | ||
#include <string> | ||
#include <map> | ||
#include <opm/io/eclipse/rst/well.hpp> | ||
#include <opm/io/eclipse/rst/group.hpp> | ||
|
||
namespace Opm { | ||
namespace ReservoirCoupling { | ||
|
||
class Slave { | ||
public: | ||
Slave() = default; | ||
|
||
explicit Slave(const std::string& name, const std::string& data_filename, const std::string& directory_path, unsigned int numprocs) : | ||
m_name{name}, | ||
m_data_filename{data_filename}, | ||
m_directory_path{directory_path}, | ||
m_numprocs{numprocs} | ||
{} | ||
static Slave serializationTestObject(); | ||
|
||
const std::string& name() const { | ||
return this->m_name; | ||
} | ||
const std::string& dataFilename() const { | ||
return this->m_data_filename; | ||
} | ||
const std::string& directoryPath() const { | ||
return this->m_directory_path; | ||
} | ||
unsigned int numprocs() const { | ||
return this->m_numprocs; | ||
} | ||
|
||
void name(const std::string& value) { | ||
this->m_name = value; | ||
} | ||
void dataFilename(const std::string& value) { | ||
this->m_data_filename = value; | ||
} | ||
void directoryPath(const std::string& value) { | ||
this->m_directory_path = value; | ||
} | ||
void numprocs(unsigned int value) { | ||
this->m_numprocs = value; | ||
} | ||
bool operator==(const Slave& other) const; | ||
|
||
template<class Serializer> | ||
void serializeOp(Serializer& serializer) | ||
{ | ||
serializer(m_name); | ||
serializer(m_data_filename); | ||
serializer(m_directory_path); | ||
serializer(m_numprocs); | ||
} | ||
private: | ||
std::string m_name; | ||
std::string m_data_filename; | ||
std::string m_directory_path; | ||
unsigned int m_numprocs; | ||
}; | ||
|
||
class CouplingInfo { | ||
public: | ||
CouplingInfo() = default; | ||
|
||
static CouplingInfo serializationTestObject(); | ||
std::map<std::string, Slave>& slaves() { | ||
return this->m_slaves; | ||
} | ||
bool operator==(const CouplingInfo& other) const; | ||
bool has_slave(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); | ||
} | ||
template<class Serializer> | ||
void serializeOp(Serializer& serializer) | ||
{ | ||
serializer(m_slaves); | ||
} | ||
private: | ||
std::map<std::string, Slave> m_slaves; | ||
}; | ||
|
||
} // namespace ReservoirCoupling | ||
} // namespace Opm | ||
#endif |
68 changes: 68 additions & 0 deletions
68
opm/input/eclipse/Schedule/ResCoup/ReservoirCouplingKeywordHandlers.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
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 "ReservoirCouplingKeywordHandlers.hpp" | ||
#include "ReservoirCouplingInfo.hpp" | ||
#include "../HandlerContext.hpp" | ||
|
||
#include <opm/common/OpmLog/OpmLog.hpp> | ||
#include <opm/common/utility/OpmInputError.hpp> | ||
|
||
#include <opm/input/eclipse/Parser/ParserKeywords/S.hpp> | ||
|
||
#include <opm/input/eclipse/Schedule/ScheduleState.hpp> | ||
|
||
#include <fmt/format.h> | ||
|
||
namespace Opm { | ||
|
||
namespace { | ||
|
||
void handleSLAVES(HandlerContext& handlerContext) | ||
{ | ||
auto rescoup = handlerContext.state().rescoup(); | ||
const auto& keyword = handlerContext.keyword; | ||
|
||
for (const auto& record : keyword) { | ||
const std::string& slave_name = record.getItem<ParserKeywords::SLAVES::SLAVE_RESERVOIR>().getTrimmedString(0); | ||
const std::string& data_filename = record.getItem<ParserKeywords::SLAVES::SLAVE_ECLBASE>().getTrimmedString(0); | ||
const std::string& directory_path = record.getItem<ParserKeywords::SLAVES::DIRECTORY>().getTrimmedString(0); | ||
const int numprocs_int = record.getItem<ParserKeywords::SLAVES::NUM_PE>().get<int>(0); | ||
if (numprocs_int <= 0) { | ||
std::string msg = fmt::format("Number of processors must be positive. Got: {}.", numprocs_int); | ||
throw OpmInputError(msg, handlerContext.keyword.location()); | ||
} | ||
const unsigned int numprocs = static_cast<unsigned int>(numprocs_int); | ||
ReservoirCoupling::Slave slave{ slave_name, data_filename, directory_path, numprocs}; | ||
rescoup.slaves().emplace( slave_name, std::move( slave )); | ||
} | ||
|
||
handlerContext.state().rescoup.update( std::move( rescoup )); | ||
} | ||
} // anonymous namespace | ||
|
||
std::vector<std::pair<std::string,KeywordHandlers::handler_function>> | ||
getReservoirCouplingHandlers() | ||
{ | ||
return { | ||
{ "SLAVES", &handleSLAVES }, | ||
}; | ||
} | ||
|
||
} // namespace Opm |
35 changes: 35 additions & 0 deletions
35
opm/input/eclipse/Schedule/ResCoup/ReservoirCouplingKeywordHandlers.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
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_KEYWORD_HANDLERS_HPP | ||
#define RESERVOIR_COUPLING_KEYWORD_HANDLERS_HPP | ||
|
||
#include "../KeywordHandlers.hpp" | ||
|
||
#include <string> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace Opm { | ||
|
||
//! \brief Obtain a list of reservoir coupling keyword handlers. | ||
std::vector<std::pair<std::string,KeywordHandlers::handler_function>> getReservoirCouplingHandlers(); | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we try to avoid relative paths
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this case it's correct since HandlerContext.hpp is a private header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification.