Skip to content

Parsing of dictionaries with overloaded entries #773

@RamogninoF

Description

@RamogninoF

I have noticed that FoamFile is not able to handle parsing of an OF dictionary with overloaded entries (see below). Specifically, the parser seems to require uniqueness of keys and fails with a FoamFileDecodeError here.

FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      autoHexMeshDict;
}

entry_1 1.0;

// ...

subdict
{
    variable_1 1.0;
    
    // ...
    
    variable_1 2.0; // <---- Overloading. OpenFoam reads only this value in the subdictionary and overwrites the previous one
}

I know this is not a best-practice scenario, but this case is digested by OpenFOAM, while files containing such entries are now impossible to be parsed/handled with foamlib.

I think it could be useful to add the possibility to the parser to manage multiple entries (I noticed that the function already returns a MultiDict, why not exploiting it?), or at least add a way to pre-process the input and cleanup the file from these occurrences (instead of doing it by hand) so that it can be correctly parsed by foamlib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions