Add class Nupcol
This commit is contained in:
@@ -376,6 +376,29 @@ private:
|
||||
KeywordFamily satfunc_family = KeywordFamily::Undefined;
|
||||
};
|
||||
|
||||
|
||||
class Nupcol {
|
||||
public:
|
||||
Nupcol();
|
||||
explicit Nupcol(const Deck& deck);
|
||||
void update(int value);
|
||||
int value() const;
|
||||
|
||||
static Nupcol serializeObject();
|
||||
bool operator==(const Nupcol& data) const;
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer) {
|
||||
serializer(this->nupcol_value);
|
||||
serializer(this->min_nupcol);
|
||||
}
|
||||
|
||||
private:
|
||||
int min_nupcol;
|
||||
int nupcol_value;
|
||||
};
|
||||
|
||||
|
||||
class Runspec {
|
||||
public:
|
||||
Runspec() = default;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/C.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/F.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/G.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/M.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/N.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/O.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/P.hpp>
|
||||
@@ -38,6 +39,7 @@
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace {
|
||||
Opm::Phases inferActivePhases(const Opm::Deck& deck)
|
||||
@@ -457,6 +459,43 @@ bool SatFuncControls::operator==(const SatFuncControls& rhs) const
|
||||
&& (this->family() == rhs.family());
|
||||
}
|
||||
|
||||
Nupcol::Nupcol() :
|
||||
min_nupcol(ParserKeywords::MINNPCOL::VALUE::defaultValue),
|
||||
nupcol_value(ParserKeywords::NUPCOL::NUM_ITER::defaultValue)
|
||||
{}
|
||||
|
||||
Nupcol::Nupcol(const Deck& deck) :
|
||||
Nupcol()
|
||||
{
|
||||
const RUNSPECSection runspecSection{deck};
|
||||
if (runspecSection.hasKeyword<ParserKeywords::MINNPCOL>()) {
|
||||
const auto& min_item = runspecSection.getKeyword<ParserKeywords::MINNPCOL>().getRecord(0).getItem<ParserKeywords::MINNPCOL::VALUE>();
|
||||
this->min_nupcol = min_item.get<int>(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Nupcol::update(int value) {
|
||||
if (value < this->min_nupcol)
|
||||
OpmLog::note(fmt::format("OPM Flow uses {} as minimum NUPCOL value", this->min_nupcol));
|
||||
this->nupcol_value = std::max(value, this->min_nupcol);
|
||||
}
|
||||
|
||||
Nupcol Nupcol::serializeObject() {
|
||||
Nupcol nc;
|
||||
nc.update(123);
|
||||
return nc;
|
||||
}
|
||||
|
||||
int Nupcol::value() const {
|
||||
return this->nupcol_value;
|
||||
}
|
||||
|
||||
bool Nupcol::operator==(const Nupcol& data) const {
|
||||
return this->min_nupcol == data.min_nupcol &&
|
||||
this->nupcol_value == data.nupcol_value;
|
||||
}
|
||||
|
||||
|
||||
Runspec::Runspec( const Deck& deck ) :
|
||||
active_phases( inferActivePhases(deck) ),
|
||||
m_tabdims( deck ),
|
||||
|
||||
14
src/opm/parser/eclipse/share/keywords/900_OPM/M/MINNPCOL
Normal file
14
src/opm/parser/eclipse/share/keywords/900_OPM/M/MINNPCOL
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "MINNPCOL",
|
||||
"sections": [
|
||||
"RUNSPEC"
|
||||
],
|
||||
"size": 1,
|
||||
"items": [
|
||||
{
|
||||
"name": "VALUE",
|
||||
"value_type": "INT",
|
||||
"default": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1095,6 +1095,7 @@ set( keywords
|
||||
900_OPM/G/GRUPRIG
|
||||
900_OPM/G/GASDENT
|
||||
900_OPM/M/MINPVFIL
|
||||
900_OPM/M/MINNPCOL
|
||||
900_OPM/O/OCOMPIDX
|
||||
900_OPM/O/OILDENT
|
||||
900_OPM/P/PERMFACT
|
||||
|
||||
@@ -24,6 +24,8 @@ along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/N.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/M.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -977,3 +979,27 @@ BOOST_AUTO_TEST_CASE(Co2Storage) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NUPCOL) {
|
||||
const std::string input = R"(
|
||||
RUNSPEC
|
||||
MINNPCOL
|
||||
3 /
|
||||
OIL
|
||||
GAS
|
||||
CO2STORE
|
||||
)";
|
||||
|
||||
Parser parser;
|
||||
|
||||
auto deck = parser.parseString(input);
|
||||
Nupcol np(deck);
|
||||
BOOST_CHECK_EQUAL(np.value(), ParserKeywords::NUPCOL::NUM_ITER::defaultValue);
|
||||
|
||||
np.update(10);
|
||||
BOOST_CHECK_EQUAL(np.value(), 10);
|
||||
|
||||
np.update(1);
|
||||
BOOST_CHECK_EQUAL(np.value(), 3);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user