make ParserItems always defaultable
i.e. remove the defaultSet() method and its friends. this is required to be able to specify defaults in DATA items like grid properties or saturation tables. e.g. SGL 10*0.1 10* 10*0.2 / would not be possible without this. If no meaningful default for an item is defined, float and double items get NaN, int items get -1 and string ones get an empty string. The hope is that if these values get used in the simulation, they will make the result obviously incorrect. (Whether a data point of an item was defaulted can be queried using item->defaultApplied(index).)
This commit is contained in:
@@ -34,10 +34,14 @@ namespace Opm
|
||||
ParserItemSizeEnum sizeType_) :
|
||||
ParserItem(itemName, sizeType_)
|
||||
{
|
||||
// use NaN as 'default default'. (Keep in mind that in the deck it can be queried
|
||||
// using deckItem->defaultApplied(idx) if an item was defaulted or not...
|
||||
m_default = std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
|
||||
ParserDoubleItem::ParserDoubleItem(const std::string& itemName) : ParserItem(itemName)
|
||||
{
|
||||
m_default = std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +58,7 @@ namespace Opm
|
||||
|
||||
|
||||
double ParserDoubleItem::getDefault() const {
|
||||
if (m_defaultSet)
|
||||
return m_default;
|
||||
else
|
||||
throw std::invalid_argument("Tried get default from parser item " + name() + " No default has been configured");
|
||||
return m_default;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +72,7 @@ namespace Opm
|
||||
ParserDoubleItem::ParserDoubleItem(const Json::JsonObject& jsonConfig) :
|
||||
ParserItem(jsonConfig)
|
||||
{
|
||||
m_default = std::numeric_limits<double>::quiet_NaN();
|
||||
if (jsonConfig.has_item("default"))
|
||||
setDefault( jsonConfig.get_double("default") );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user