Rename BC to BCPROP and add error message for BC

This commit is contained in:
Tor Harald Sandve
2023-04-28 09:25:43 +02:00
parent c7a7e80698
commit 4b36741f33
12 changed files with 157 additions and 53 deletions

View File

@@ -161,7 +161,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Schedule/Action/State.cpp
src/opm/input/eclipse/Schedule/Action/WGNames.cpp
src/opm/input/eclipse/Schedule/ArrayDimChecker.cpp
src/opm/input/eclipse/Schedule/BC.cpp
src/opm/input/eclipse/Schedule/BCProp.cpp
src/opm/input/eclipse/Schedule/CompletedCells.cpp
src/opm/input/eclipse/Schedule/eval_uda.cpp
src/opm/input/eclipse/Schedule/Events.cpp
@@ -1210,7 +1210,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/Schedule/Action/State.hpp
opm/input/eclipse/Schedule/Action/WGNames.hpp
opm/input/eclipse/Schedule/ArrayDimChecker.hpp
opm/input/eclipse/Schedule/BC.hpp
opm/input/eclipse/Schedule/BCProp.hpp
opm/input/eclipse/Schedule/GasLiftOpt.hpp
opm/input/eclipse/Schedule/Network/Balance.hpp
opm/input/eclipse/Schedule/Network/Branch.hpp

View File

@@ -18,8 +18,8 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_BC_HPP
#define OPM_BC_HPP
#ifndef OPM_BC_PROP_HPP
#define OPM_BC_PROP_HPP
#include <vector>
#include <cstddef>
@@ -53,7 +53,7 @@ enum class BCComponent {
};
class BCVAL {
class BCPROP {
public:
struct BCFace {
@@ -84,18 +84,18 @@ public:
};
BCVAL() = default;
explicit BCVAL(const Deck& deck);
BCPROP() = default;
explicit BCPROP(const Deck& deck);
static BCVAL serializationTestObject();
static BCPROP serializationTestObject();
std::size_t size() const;
std::vector<BCFace>::const_iterator begin() const;
std::vector<BCFace>::const_iterator end() const;
bool operator==(const BCVAL& other) const;
BCFace operator[](std::size_t index) const;
bool operator==(const BCPROP& other) const;
BCFace operator[](int index) const;
void updateBC(const DeckRecord& record);
void updateBCProp(const DeckRecord& record);
template<class Serializer>
void serializeOp(Serializer& serializer)

View File

@@ -679,7 +679,7 @@ namespace Opm
void handleAQUCT (HandlerContext&);
void handleAQUFETP (HandlerContext&);
void handleAQUFLUX (HandlerContext&);
void handleBC (HandlerContext&);
void handleBCProp (HandlerContext&);
void handleBRANPROP (HandlerContext&);
void handleCOMPDAT (HandlerContext&);
void handleCOMPLUMP (HandlerContext&);

View File

@@ -35,7 +35,7 @@
#include <opm/input/eclipse/Schedule/Tuning.hpp>
#include <opm/input/eclipse/Schedule/OilVaporizationProperties.hpp>
#include <opm/input/eclipse/Schedule/Events.hpp>
#include <opm/input/eclipse/Schedule/BC.hpp>
#include <opm/input/eclipse/Schedule/BCProp.hpp>
#include <opm/input/eclipse/Schedule/Group/Group.hpp>
#include <opm/input/eclipse/Schedule/Well/WellEnums.hpp>
#include <opm/input/eclipse/Schedule/MessageLimits.hpp>
@@ -483,7 +483,7 @@ namespace Opm {
map_member<std::string, Well> wells;
// constant flux aquifers
std::unordered_map<int, SingleAquiferFlux> aqufluxs;
BCVAL bc;
BCPROP bcprop;
std::unordered_map<std::string, double> target_wellpi;
std::optional<NextStep> next_tstep;
@@ -512,7 +512,7 @@ namespace Opm {
serializer(m_whistctl_mode);
serializer(target_wellpi);
serializer(aqufluxs);
serializer(bc);
serializer(bcprop);
}

View File

@@ -22,6 +22,8 @@
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/B.hpp>
#include <opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.hpp>
#include <opm/common/utility/OpmInputError.hpp>
namespace Opm {
@@ -85,6 +87,17 @@ bool BCConfig::BCFace::operator==(const BCConfig::BCFace& other) const {
BCConfig::BCConfig(const Deck& deck) {
if(deck.hasKeyword<ParserKeywords::BC>()){
for (const auto* keyword : deck.getKeywordList<ParserKeywords::BC>()) {
const std::string reason = "ERROR: The BC keyword is obsolute. \n "
"Instead use BCCON in the GRID section to specify the connections. \n "
"And BCPROP in the SCHEDULE section to specify the type and values. \n"
"Check the OPM manual for details.";
throw OpmInputError { reason, keyword->location()};
}
}
GridDims grid( deck );
for (const auto& kw: deck.getKeywordList<ParserKeywords::BCCON>()) {
for (const auto& record : *kw)

View File

@@ -22,7 +22,7 @@
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/B.hpp>
#include <opm/input/eclipse/Schedule/BC.hpp>
#include <opm/input/eclipse/Schedule/BCProp.hpp>
namespace Opm {
namespace {
@@ -74,8 +74,8 @@ BCComponent component(const std::string& s) {
}
}
using BCKEY = ParserKeywords::BC;
BCVAL::BCFace::BCFace(const DeckRecord& record) :
using BCKEY = ParserKeywords::BCPROP;
BCPROP::BCFace::BCFace(const DeckRecord& record) :
index(record.getItem<BCKEY::INDEX>().get<int>(0)),
bctype(fromstring::bctype(record.getItem<BCKEY::TYPE>().get<std::string>(0))),
component(fromstring::component(record.getItem<BCKEY::COMPONENT>().get<std::string>(0))),
@@ -89,7 +89,7 @@ BCVAL::BCFace::BCFace(const DeckRecord& record) :
}
}
BCVAL::BCFace BCVAL::BCFace::serializationTestObject()
BCPROP::BCFace BCPROP::BCFace::serializationTestObject()
{
BCFace result;
result.index = 100;
@@ -103,7 +103,7 @@ BCVAL::BCFace BCVAL::BCFace::serializationTestObject()
}
bool BCVAL::BCFace::operator==(const BCVAL::BCFace& other) const {
bool BCPROP::BCFace::operator==(const BCPROP::BCFace& other) const {
return this->index == other.index &&
this->bctype == other.bctype &&
this->component == other.component &&
@@ -114,12 +114,12 @@ bool BCVAL::BCFace::operator==(const BCVAL::BCFace& other) const {
BCVAL::BCVAL(const Deck& /*deck*/) {
BCPROP::BCPROP(const Deck& /*deck*/) {
// TODO Read the indices from BCCON and initial with NONE type???
}
void BCVAL::updateBC(const DeckRecord& record) {
const BCVAL::BCFace bcnew( record );
void BCPROP::updateBCProp(const DeckRecord& record) {
const BCPROP::BCFace bcnew( record );
for (auto& bc : m_faces) {
if (bc.index == bcnew.index)
{
@@ -132,28 +132,28 @@ void BCVAL::updateBC(const DeckRecord& record) {
BCVAL BCVAL::serializationTestObject()
BCPROP BCPROP::serializationTestObject()
{
BCVAL result;
BCPROP result;
result.m_faces = {BCFace::serializationTestObject()};
return result;
}
std::size_t BCVAL::size() const {
std::size_t BCPROP::size() const {
return this->m_faces.size();
}
std::vector<BCVAL::BCFace>::const_iterator BCVAL::begin() const {
std::vector<BCPROP::BCFace>::const_iterator BCPROP::begin() const {
return this->m_faces.begin();
}
std::vector<BCVAL::BCFace>::const_iterator BCVAL::end() const {
std::vector<BCPROP::BCFace>::const_iterator BCPROP::end() const {
return this->m_faces.end();
}
BCVAL::BCFace BCVAL::operator[](std::size_t index) const {
BCPROP::BCFace BCPROP::operator[](int index) const {
for (auto& bc : m_faces) {
if (bc.index == index)
{
@@ -164,7 +164,7 @@ BCVAL::BCFace BCVAL::operator[](std::size_t index) const {
return this->m_faces[0];
}
bool BCVAL::operator==(const BCVAL& other) const {
bool BCPROP::operator==(const BCPROP& other) const {
return this->m_faces == other.m_faces;
}

View File

@@ -145,10 +145,10 @@ namespace {
}
}
void Schedule::handleBC(Schedule::HandlerContext& handlerContext) {
auto& bc = this->snapshots.back().bc;
void Schedule::handleBCProp(Schedule::HandlerContext& handlerContext) {
auto& bcprop = this->snapshots.back().bcprop;
for (const auto& record : handlerContext.keyword) {
bc.updateBC(record);
bcprop.updateBCProp(record);
}
}
@@ -2473,7 +2473,7 @@ Well{0} entered with 'FIELD' parent group:
{ "AQUCT", &Schedule::handleAQUCT },
{ "AQUFETP", &Schedule::handleAQUFETP },
{ "AQUFLUX", &Schedule::handleAQUFLUX },
{ "BC", &Schedule::handleBC },
{ "BCPROP", &Schedule::handleBCProp },
{ "BOX", &Schedule::handleGEOKeyword},
{ "BRANPROP", &Schedule::handleBRANPROP },
{ "COMPDAT" , &Schedule::handleCOMPDAT },

View File

@@ -1,13 +1,37 @@
{
"name": "BC",
"sections": [
"SCHEDULE"
"SOLUTION"
],
"items": [
{
"name": "INDEX",
"name": "I1",
"value_type": "INT"
},
{
"name": "I2",
"value_type": "INT"
},
{
"name": "J1",
"value_type": "INT"
},
{
"name": "J2",
"value_type": "INT"
},
{
"name": "K1",
"value_type": "INT"
},
{
"name": "K2",
"value_type": "INT"
},
{
"name": "DIRECTION",
"value_type": "STRING"
},
{
"name": "TYPE",
"value_type": "STRING"

View File

@@ -0,0 +1,38 @@
{
"name": "BCPROP",
"sections": [
"SCHEDULE"
],
"items": [
{
"name": "INDEX",
"value_type": "INT"
},
{
"name": "TYPE",
"value_type": "STRING"
},
{
"name": "COMPONENT",
"value_type": "STRING",
"default": "NONE"
},
{
"name": "RATE",
"value_type": "DOUBLE",
"dimension": "Mass/Time*Length*Length",
"default": 0
},
{
"name": "PRESSURE",
"value_type": "DOUBLE",
"dimension": "Pressure",
"default": 1
},
{
"name": "TEMPERATURE",
"value_type": "DOUBLE",
"dimension": "Temperature"
}
]
}

View File

@@ -1105,6 +1105,7 @@ set( keywords
900_OPM/B/BC
900_OPM/B/BCCON
900_OPM/B/BCPROP
900_OPM/C/CO2STOR
900_OPM/C/COMPTRAJ
900_OPM/D/DISGASW

View File

@@ -5442,22 +5442,11 @@ BOOST_AUTO_TEST_CASE(createDeckWithBC) {
START -- 0
19 JUN 2007 /
DIMENS
20 1 10 /
GRID
BCCON
1 1 1 1 1 1 10 X- /
2 20 20 1 1 6 10 X /
/
SOLUTION
SCHEDULE
BC
BCPROP
1 RATE GAS 100.0 /
2 FREE /
/
@@ -5465,18 +5454,16 @@ BC
DATES -- 1
10 OKT 2008 /
/
BC
BCPROP
1 RATE GAS 200.0 /
2 FREE 4* /
/
)";
const auto& schedule = make_schedule(input);
const auto& deck = Parser{}.parseString(input);
BCConfig bcconfig(deck);
{
size_t currentStep = 0;
const auto& bc = schedule[currentStep].bc;
const auto& bc = schedule[currentStep].bcprop;
BOOST_CHECK_EQUAL(bc.size(), 2);
const auto& bcface0 = bc[0];
BOOST_CHECK_CLOSE(bcface0.rate * 3600 * 24, 100, 1e-8 );
@@ -5484,7 +5471,7 @@ BC
{
size_t currentStep = 1;
const auto& bc = schedule[currentStep].bc;
const auto& bc = schedule[currentStep].bcprop;
BOOST_CHECK_EQUAL(bc.size(), 2);
const auto& bcface0 = bc[0];
BOOST_CHECK_CLOSE(bcface0.rate * 3600 * 24, 200, 1e-8 );

View File

@@ -119,6 +119,30 @@ GRID
REGIONS
)";
const std::string& inputStr_bc = R"(
RUNSPEC
DIMENS
10 3 4 /
GRID
SOLUTION
BC
1 1 1 1 1 10 X- FREE GAS/
/
REGIONS
)";
const std::string& inputStr_bccon = R"(
RUNSPEC
DIMENS
10 3 4 /
GRID
BCCON
1 1 1 1 1 1 1 X- /
2 10 10 4* X /
/
REGIONS
)";
namespace {
std::string simDeckStringTEMP()
{
@@ -150,6 +174,23 @@ static Deck createDeck(const std::string& input) {
return parser.parseString(input);
}
BOOST_AUTO_TEST_CASE(SimulationConfigBCCON) {
auto deck = createDeck(inputStr_bccon);
BCConfig bcconfig(deck);
std::vector<int> i1s = { 1, 10};
std::vector<int> k2s = { 1, 4};
std::vector<Opm::FaceDir::DirEnum> dirs = { Opm::FaceDir::XMinus , Opm::FaceDir::XPlus};
for (const auto bc : bcconfig) {
BOOST_CHECK(bc.i1 == (i1s[bc.index - 1 ]) - 1);
BOOST_CHECK(bc.k2 == (k2s[bc.index - 1 ]) - 1);
BOOST_CHECK(bc.dir == dirs[bc.index -1 ]);
}
}
BOOST_AUTO_TEST_CASE(SimulationConfigBC) {
BOOST_CHECK_THROW( BCConfig(createDeck(inputStr_bc)), OpmInputError );
}
BOOST_AUTO_TEST_CASE(SimulationConfigGetThresholdPressureTableTest) {
auto deck = createDeck(inputStr);