Skip to content

Orion Events: improve error message when invalid keyword or field name is used #14535

Description

@kriben

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

  1. 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;
    }
  2. 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.

  3. Resolve with getParserKeywordFromDeckName() rather than getKeyword() when the input may be a deck alias. Guard with isRecognizedKeyword() — both throw on a miss.

  4. Walk with range-for. ParserKeyword iterates its records, ParserRecord iterates its items.

  5. 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".

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions