PinchMode: convert to enum class
This commit is contained in:
parent
c49f1fc354
commit
3808c85edf
@ -108,12 +108,12 @@ namespace Opm {
|
||||
the theta keywords entered sum up to exactly 360 degrees!
|
||||
*/
|
||||
|
||||
bool circle( ) const;
|
||||
bool isPinchActive( ) const;
|
||||
double getPinchThresholdThickness( ) const;
|
||||
PinchMode::ModeEnum getPinchOption( ) const;
|
||||
PinchMode::ModeEnum getMultzOption( ) const;
|
||||
PinchMode::ModeEnum getPinchGapMode( ) const;
|
||||
bool circle() const;
|
||||
bool isPinchActive() const;
|
||||
double getPinchThresholdThickness() const;
|
||||
PinchMode getPinchOption() const;
|
||||
PinchMode getMultzOption() const;
|
||||
PinchMode getPinchGapMode() const;
|
||||
|
||||
MinpvMode getMinpvMode() const;
|
||||
const std::vector<double>& getMinpvVector( ) const;
|
||||
@ -224,9 +224,9 @@ namespace Opm {
|
||||
std::vector<double> m_minpvVector;
|
||||
MinpvMode m_minpvMode;
|
||||
std::optional<double> m_pinch;
|
||||
PinchMode::ModeEnum m_pinchoutMode;
|
||||
PinchMode::ModeEnum m_multzMode;
|
||||
PinchMode::ModeEnum m_pinchGapMode;
|
||||
PinchMode m_pinchoutMode;
|
||||
PinchMode m_multzMode;
|
||||
PinchMode m_pinchGapMode;
|
||||
|
||||
mutable std::optional<std::vector<double>> active_volume;
|
||||
|
||||
|
@ -20,22 +20,24 @@
|
||||
#ifndef OPM_PINCHMODE_HPP
|
||||
#define OPM_PINCHMODE_HPP
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
namespace PinchMode {
|
||||
enum ModeEnum {
|
||||
ALL = 1,
|
||||
TOPBOT = 2,
|
||||
TOP = 3,
|
||||
GAP = 4,
|
||||
NOGAP = 5,
|
||||
};
|
||||
enum class PinchMode {
|
||||
ALL = 1,
|
||||
TOPBOT = 2,
|
||||
TOP = 3,
|
||||
GAP = 4,
|
||||
NOGAP = 5,
|
||||
};
|
||||
|
||||
std::string PinchMode2String(const PinchMode enumValue);
|
||||
PinchMode PinchModeFromString(const std::string& stringValue);
|
||||
|
||||
std::ostream& operator<<(std::ostream&, const PinchMode);
|
||||
|
||||
const std::string PinchMode2String(const ModeEnum enumValue);
|
||||
ModeEnum PinchModeFromString(const std::string& stringValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,9 +97,9 @@ EclipseGrid::EclipseGrid(const std::array<int, 3>& dims ,
|
||||
const int * actnum)
|
||||
: GridDims(dims),
|
||||
m_minpvMode(MinpvMode::Inactive),
|
||||
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
|
||||
m_multzMode(PinchMode::ModeEnum::TOP),
|
||||
m_pinchGapMode(PinchMode::ModeEnum::GAP)
|
||||
m_pinchoutMode(PinchMode::TOPBOT),
|
||||
m_multzMode(PinchMode::TOP),
|
||||
m_pinchGapMode(PinchMode::GAP)
|
||||
{
|
||||
initCornerPointGrid( coord , zcorn , actnum );
|
||||
}
|
||||
@ -113,9 +113,9 @@ EclipseGrid::EclipseGrid(const std::array<int, 3>& dims ,
|
||||
EclipseGrid::EclipseGrid(const std::string& fileName )
|
||||
: GridDims(),
|
||||
m_minpvMode(MinpvMode::Inactive),
|
||||
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
|
||||
m_multzMode(PinchMode::ModeEnum::TOP),
|
||||
m_pinchGapMode(PinchMode::ModeEnum::GAP)
|
||||
m_pinchoutMode(PinchMode::TOPBOT),
|
||||
m_multzMode(PinchMode::TOP),
|
||||
m_pinchGapMode(PinchMode::GAP)
|
||||
{
|
||||
|
||||
Opm::EclIO::EclFile egridfile(fileName);
|
||||
@ -127,9 +127,9 @@ EclipseGrid::EclipseGrid(const std::string& fileName )
|
||||
EclipseGrid::EclipseGrid(const GridDims& gd)
|
||||
: GridDims(gd),
|
||||
m_minpvMode(MinpvMode::Inactive),
|
||||
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
|
||||
m_multzMode(PinchMode::ModeEnum::TOP),
|
||||
m_pinchGapMode(PinchMode::ModeEnum::GAP)
|
||||
m_pinchoutMode(PinchMode::TOPBOT),
|
||||
m_multzMode(PinchMode::TOP),
|
||||
m_pinchGapMode(PinchMode::GAP)
|
||||
{
|
||||
this->m_nactive = this->getCartesianSize();
|
||||
this->active_volume = std::nullopt;
|
||||
@ -147,9 +147,9 @@ EclipseGrid::EclipseGrid(size_t nx, size_t ny , size_t nz,
|
||||
double dx, double dy, double dz)
|
||||
: GridDims(nx, ny, nz),
|
||||
m_minpvMode(MinpvMode::Inactive),
|
||||
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
|
||||
m_multzMode(PinchMode::ModeEnum::TOP),
|
||||
m_pinchGapMode(PinchMode::ModeEnum::GAP)
|
||||
m_pinchoutMode(PinchMode::TOPBOT),
|
||||
m_multzMode(PinchMode::TOP),
|
||||
m_pinchGapMode(PinchMode::GAP)
|
||||
{
|
||||
|
||||
m_coord.reserve((nx+1)*(ny+1)*6);
|
||||
@ -255,9 +255,9 @@ EclipseGrid::EclipseGrid(const EclipseGrid& src, const std::vector<int>& actnum)
|
||||
EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum)
|
||||
: GridDims(deck),
|
||||
m_minpvMode(MinpvMode::Inactive),
|
||||
m_pinchoutMode(PinchMode::ModeEnum::TOPBOT),
|
||||
m_multzMode(PinchMode::ModeEnum::TOP),
|
||||
m_pinchGapMode(PinchMode::ModeEnum::GAP)
|
||||
m_pinchoutMode(PinchMode::TOPBOT),
|
||||
m_multzMode(PinchMode::TOP),
|
||||
m_pinchGapMode(PinchMode::GAP)
|
||||
{
|
||||
if (deck.hasKeyword("GDFILE")){
|
||||
|
||||
@ -343,12 +343,12 @@ EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum)
|
||||
m_pinch = item.getSIDouble(0);
|
||||
|
||||
auto pinchoutString = record.getItem<ParserKeywords::PINCH::PINCHOUT_OPTION>().get< std::string >(0);
|
||||
m_pinchoutMode = PinchMode::PinchModeFromString(pinchoutString);
|
||||
m_pinchoutMode = PinchModeFromString(pinchoutString);
|
||||
|
||||
auto multzString = record.getItem<ParserKeywords::PINCH::MULTZ_OPTION>().get< std::string >(0);
|
||||
m_multzMode = PinchMode::PinchModeFromString(multzString);
|
||||
m_multzMode = PinchModeFromString(multzString);
|
||||
auto pinchGapString = record.getItem<ParserKeywords::PINCH::CONTROL_OPTION>().get< std::string >(0);
|
||||
m_pinchGapMode = PinchMode::PinchModeFromString(pinchGapString);
|
||||
m_pinchGapMode = PinchModeFromString(pinchGapString);
|
||||
}
|
||||
|
||||
if (deck.hasKeyword<ParserKeywords::MINPV>() && deck.hasKeyword<ParserKeywords::MINPVFIL>()) {
|
||||
@ -528,11 +528,11 @@ EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum)
|
||||
return m_pinch.value();
|
||||
}
|
||||
|
||||
PinchMode::ModeEnum EclipseGrid::getPinchOption( ) const {
|
||||
PinchMode EclipseGrid::getPinchOption( ) const {
|
||||
return m_pinchoutMode;
|
||||
}
|
||||
|
||||
PinchMode::ModeEnum EclipseGrid::getMultzOption( ) const {
|
||||
PinchMode EclipseGrid::getMultzOption( ) const {
|
||||
return m_multzMode;
|
||||
}
|
||||
|
||||
@ -540,7 +540,7 @@ EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum)
|
||||
return m_minpvMode;
|
||||
}
|
||||
|
||||
PinchMode::ModeEnum EclipseGrid::getPinchGapMode() const {
|
||||
PinchMode EclipseGrid::getPinchGapMode() const {
|
||||
return m_pinchGapMode;
|
||||
}
|
||||
|
||||
|
@ -20,53 +20,59 @@
|
||||
#include <opm/input/eclipse/EclipseState/Grid/PinchMode.hpp>
|
||||
#include <opm/common/utility/String.hpp>
|
||||
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
namespace PinchMode {
|
||||
std::string PinchMode2String(const PinchMode enumValue)
|
||||
{
|
||||
std::string stringValue;
|
||||
switch (enumValue) {
|
||||
case PinchMode::ALL:
|
||||
stringValue = "ALL";
|
||||
break;
|
||||
|
||||
const std::string PinchMode2String(const ModeEnum enumValue) {
|
||||
std::string stringValue;
|
||||
switch (enumValue) {
|
||||
case ModeEnum::ALL:
|
||||
stringValue = "ALL";
|
||||
break;
|
||||
case PinchMode::TOPBOT:
|
||||
stringValue = "TOPBOT";
|
||||
break;
|
||||
|
||||
case ModeEnum::TOPBOT:
|
||||
stringValue = "TOPBOT";
|
||||
break;
|
||||
case PinchMode::TOP:
|
||||
stringValue = "TOP";
|
||||
break;
|
||||
|
||||
case ModeEnum::TOP:
|
||||
stringValue = "TOP";
|
||||
break;
|
||||
|
||||
case ModeEnum::GAP:
|
||||
stringValue = "GAP";
|
||||
break;
|
||||
case ModeEnum::NOGAP:
|
||||
stringValue = "NOGAP";
|
||||
break;
|
||||
}
|
||||
|
||||
return stringValue;
|
||||
}
|
||||
|
||||
ModeEnum PinchModeFromString(const std::string& stringValue) {
|
||||
std::string s = trim_copy(stringValue);
|
||||
|
||||
ModeEnum mode;
|
||||
if (s == "ALL") { mode = ModeEnum::ALL; }
|
||||
else if (s == "TOPBOT") { mode = ModeEnum::TOPBOT; }
|
||||
else if (s == "TOP") { mode = ModeEnum::TOP; }
|
||||
else if (s == "GAP") { mode = ModeEnum::GAP; }
|
||||
else if (s == "NOGAP") { mode = ModeEnum::NOGAP; }
|
||||
else {
|
||||
std::string msg = "Unsupported pinchout mode " + s;
|
||||
throw std::invalid_argument(msg);
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
case PinchMode::GAP:
|
||||
stringValue = "GAP";
|
||||
break;
|
||||
case PinchMode::NOGAP:
|
||||
stringValue = "NOGAP";
|
||||
break;
|
||||
}
|
||||
|
||||
return stringValue;
|
||||
}
|
||||
|
||||
PinchMode PinchModeFromString(const std::string& stringValue)
|
||||
{
|
||||
std::string s = trim_copy(stringValue);
|
||||
|
||||
PinchMode mode;
|
||||
if (s == "ALL") { mode = PinchMode::ALL; }
|
||||
else if (s == "TOPBOT") { mode = PinchMode::TOPBOT; }
|
||||
else if (s == "TOP") { mode = PinchMode::TOP; }
|
||||
else if (s == "GAP") { mode = PinchMode::GAP; }
|
||||
else if (s == "NOGAP") { mode = PinchMode::NOGAP; }
|
||||
else {
|
||||
std::string msg = "Unsupported pinchout mode " + s;
|
||||
throw std::invalid_argument(msg);
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const PinchMode pm)
|
||||
{
|
||||
return (os << PinchMode2String(pm));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -836,8 +836,8 @@ BOOST_AUTO_TEST_CASE(ConstructorNORUNSPEC_PINCH) {
|
||||
BOOST_CHECK_THROW(grid1.getPinchThresholdThickness(), std::bad_optional_access);
|
||||
BOOST_CHECK(grid2.isPinchActive());
|
||||
BOOST_CHECK_EQUAL(grid2.getPinchThresholdThickness(), 0.2);
|
||||
BOOST_CHECK_EQUAL(grid2.getPinchGapMode(), Opm::PinchMode::ModeEnum::GAP);
|
||||
BOOST_CHECK_EQUAL(grid3.getPinchGapMode(), Opm::PinchMode::ModeEnum::NOGAP);
|
||||
BOOST_CHECK_EQUAL(grid2.getPinchGapMode(), Opm::PinchMode::GAP);
|
||||
BOOST_CHECK_EQUAL(grid3.getPinchGapMode(), Opm::PinchMode::NOGAP);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ConstructorMINPV) {
|
||||
|
Loading…
Reference in New Issue
Block a user