Mentions légales du service

Skip to content
  • GILLES Sebastien's avatar
    #1302 LuaOptionFile: shorten the file by making the selection of a parameter more simple. · 987c119e
    GILLES Sebastien authored
    Previously, you had to fill each individual type of possibility for a Parameter, regardless of the one finally chosen. For instance, you had something like (skipping the documentation...):
    
    VolumicMass
    {
        nature = "constant"
        scalar = 1.
        lua_function = none
        piecewise_constant_domain_id = { }
        piecewise_constant_domain_value = { }
    }
    
    and each of these entries should be filled (a shortcut 'none' was however created for lua_function).
    
    This made the Lua files rather heavy, and moreover signaled the non used fields (here VolumicMass.lua_function, VolumicMass.piecewise_constant_domain_id and VolumicMass.piecewise_constant_domain_value) as unused.
    
    Now using up the strength of newly introduced in C++17 std::variant (or boost::variant for Apple Clang currently - see #1305), a more synthetic writing ha been introduced:
    
    VolumicMass
    {
        nature = "constant"
        value = 1.
    }
    
    where 'value' type depends on the 'nature' choice. For instance, a user might replace it by:
    
    VolumicMass
    {
        nature = "piecewise_constant_by_domain"
        value = { [3] = 1., [5] = 0.5 }
    }
    
    Please notice the usage of the associative container which was introduced when LuaOptionFile replaced Ops.
    
    NOTE: Rather unusually, I have here merged many commits into one: due to the large scope of the modifications to do, I worked only on a specific test. Consequently, other models and tests stopped to compile, and I really like the code to at least compile at all of its commit not to break the git bisect functionality.
    987c119e