Goal
Show the list of named parameters (items) for an OPM Flow / Eclipse keyword inside ResInsight — e.g. that COMPDAT has WELL, I, J, K1, K2, STATE, SAT_TABLE, CONNECTION_TRANSMISSIBILITY_FACTOR, DIAMETER, Kh, SKIN, D_FACTOR, DIR, PR.
Constraint: all information must come from opm-common only.
Proposed approach: query the parser we already link
ResInsight already links custom-opm-common, and ThirdParty/custom-opm-common/generated-opm-common/ParserInit.cpp registers 1121 keywords with full item metadata. Opm::Parser is already in use in ApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp.
So the parameter names are already compiled into the binary — we only need an accessor layer. No new data file, no resource to keep in sync, and by construction nothing manual-derived enters ResInsight.
Sketch
New tools file, e.g. RiaOpmKeywordTools, next to RiaOpmParserTools:
struct RiaOpmKeywordItem
{
QString name;
QString typeName; // "INT" | "DOUBLE" | "STRING" | "RAW_STRING" | "UDA"
QString dimension; // joined item.dimensions(), may be empty
QString defaultValue; // empty if no default
QString description; // usually empty - opm-common rarely sets it
bool isVariadic; // sizeType() == item_size::ALL
};
struct RiaOpmKeywordRecord
{
std::vector<RiaOpmKeywordItem> items;
};
struct RiaOpmKeywordInfo
{
QString name;
std::vector<QString> validSections;
std::vector<RiaOpmKeywordRecord> records; // >1 for WELSEGS, VFPPROD, ...
bool isDataKeyword;
};
namespace RiaOpmKeywordTools
{
std::vector<QString> allKeywordNames();
std::optional<RiaOpmKeywordInfo> keywordInfo( const QString& keywordName );
} // namespace RiaOpmKeywordTools
Implementation notes / traps
-
Share one Opm::Parser. Construction runs 1121 keyword constructors, so build it once lazily:
static const Opm::Parser& sharedParser()
{
static const Opm::Parser parser( true ); // true = add default keywords
return parser;
}
-
Enumerate via getAllDeckNames(). The keyword store is private; this is the only public enumeration. It returns deck names (so aliases such as DIFFMR- appear alongside the canonical keyword) plus wildcard entries, in hash-map order — sort and dedupe before display.
-
Resolve with getParserKeywordFromDeckName() rather than getKeyword() when the input may be a deck alias. Guard with isRecognizedKeyword() — both throw on a miss.
-
Walk with range-for. ParserKeyword iterates its records, ParserRecord iterates its items.
-
Dispatch defaults strictly on dataType(). getDefault<T>() throws std::invalid_argument when T does not match the item's tag. Two specific traps:
ParserItem::to_string() throws for UDA — write our own switch instead.
getDefault<RawString> has no explicit template instantiation in the library, so using it on a raw_string item is a link error. Treat that case as "no default".
Goal
Show the list of named parameters (items) for an OPM Flow / Eclipse keyword inside ResInsight — e.g. that
COMPDAThasWELL, I, J, K1, K2, STATE, SAT_TABLE, CONNECTION_TRANSMISSIBILITY_FACTOR, DIAMETER, Kh, SKIN, D_FACTOR, DIR, PR.Constraint: all information must come from opm-common only.
Proposed approach: query the parser we already link
ResInsight already links
custom-opm-common, andThirdParty/custom-opm-common/generated-opm-common/ParserInit.cppregisters 1121 keywords with full item metadata.Opm::Parseris already in use inApplicationLibCode/ProjectDataModel/RiaOpmParserTools.cpp.So the parameter names are already compiled into the binary — we only need an accessor layer. No new data file, no resource to keep in sync, and by construction nothing manual-derived enters ResInsight.
Sketch
New tools file, e.g.
RiaOpmKeywordTools, next toRiaOpmParserTools:Implementation notes / traps
Share one
Opm::Parser. Construction runs 1121 keyword constructors, so build it once lazily:Enumerate via
getAllDeckNames(). The keyword store is private; this is the only public enumeration. It returns deck names (so aliases such asDIFFMR-appear alongside the canonical keyword) plus wildcard entries, in hash-map order — sort and dedupe before display.Resolve with
getParserKeywordFromDeckName()rather thangetKeyword()when the input may be a deck alias. Guard withisRecognizedKeyword()— both throw on a miss.Walk with range-for.
ParserKeyworditerates its records,ParserRecorditerates its items.Dispatch defaults strictly on
dataType().getDefault<T>()throwsstd::invalid_argumentwhenTdoes not match the item's tag. Two specific traps:ParserItem::to_string()throws forUDA— write our own switch instead.getDefault<RawString>has no explicit template instantiation in the library, so using it on araw_stringitem is a link error. Treat that case as "no default".