Open blattms opened 9 years ago
I agree with your issue, but you should be aware that it stems from a combination of historical baggage and dependency inversion: opm-parser is much newer than the wells code in opm-core so it could not have used the opm-parser enums when it was written. On the other hand opm-parser currently cannot use anything in opm-core because of the dependency order so new enums needed to be created. If you want to reduce these redundancies: perfect! patches are very welcome :)
I agree that this is weird - and in my opinion the enums in opm-parser should be used. At the time opm-parser was shoehorned in we tried to make the changes as non-obtrusive as possible for the other modules; that is at least the recent background.
Still valid, not resolved, not working on it, will keep open as a reminder but remove from release milestone.
Hi,
While working on PR #684 I noticed again that there are a lot of enums defined in the rest of OPM that also exist (at least in a similar way) already in opm-parser. To construct the former we always use a switch statement on the original enum. Somehow this seems like a lot of unneeded branching and code to me.
Take for example the following:
from opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp
from opm/core/wells/WellsManager_iml.hpp:
from opm/core/wells/WellsManager.cpp:
At least in this special case the only feature here is checking that the enum is not CMODE_UNDEFINED. (But maybe I am missing something here.) What I am wondering is, if this check is not done by opm-parser anyway.
This could be achieved a lot easier (if we want to keep the different enums).
We just make sure that the values are the same and skip the undefined one:
and use a simple static cast for the conversion:
Being a dardevil, might I even suggest to get rid of the duplicate ones in OPM that only exist for historic reasons (read pre-opm-parser times).
BTW: I am aware that there are other enums that are a little bit different (e.g. 0 starting in core, and starting with 1 in dune-cornerpoint). Still I would think that for most of them there is a formula to convert between them that should be used rather than a switch statement.