Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle partially supported options manually. #762

Merged
merged 5 commits into from
Aug 23, 2016

Conversation

qilicun
Copy link
Member

@qilicun qilicun commented Jul 14, 2016

There are some options of the keywords only partially supported by flow, handle them automatically is not that easy, so we decided to handle them manually, the lucky thing is that the number of these kind of keywords is limited.
Any feedback and suggestions are welcome.

@joakim-hove
Copy link
Member

joakim-hove commented Jul 14, 2016

I must say I am a bit sceptical to this - mainly because I think it will be a significant maintainance burden; and the moment we start reporting issues regarding (more or less) minor differences between flow and Eclipse we implicitly state that: "Everything else is implemented to perfection" - that is obviously not the case.

I do not agree with this statement:

the lucky thing is that the number of these kind of keywords is limited

and - actually as flow continues to develop a identity of it's own - the number of such differences might actually increase instead of decrease.

Iff we indeed choose to go in this direction I think the current approach is too verbose - I fear it will not be maintained. Common to all of these checks is is we check an item of a keyword for a specific value, and then report a problem. This should be possible to implement based on a collection of objects resembling:

struct PartiallySupported {
   std::string item;
   std::string item_value;
   std::string msg;
}

and a multimap something like:

std::multi_map<std::string, PartiallySupported> = {{"ENDSCALE" , PartiallySupported("DIRECT" , "DIRECT" , "Not supported ...")}, ....

Then adding a new partially supported keyword would only be to add an entry in this map.

@atgeirr
Copy link
Member

atgeirr commented Jul 15, 2016

I have no time now to make a proper review, but I like @joakim-hove's idea, it looks like a good and systematic way to do this.

@jokva
Copy link
Contributor

jokva commented Jul 18, 2016

Is there a reason for making this a multimap? It doesn't seem to me like we actually use the properties anyway.

@qilicun
Copy link
Member Author

qilicun commented Jul 18, 2016

Is there a reason for making this a multimap?

One keyword probably has more than one unsupported option.

@jokva
Copy link
Contributor

jokva commented Jul 18, 2016

Didn't notice while skimming. That's fine I suppose.



namespace Opm {

namespace MissingFeatures {

template<typename T>
struct PartiallySupported {
int item;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For increased readability I would prefer if you used item names instead - i.e std::string item.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's fine. My concern is that in the json format for these keywords, the options short cut(that is option name) are somehow different to Eclipse Manual, therefor I choose number instead, if you still think the item name is better, I will change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concern is that in the json format for these keywords, the options short cut(that is option name) are somehow different to Eclipse Manual

Yes - I see your point - I would still prefer that you use the string names:

  1. Feel free to submit PR to parser changing the names to the Eclipse names.
  2. Please use the compiled in named constants (we should be better at using these ...):
#include <opm/parser/eclipse/Parser/ParserKeywords/C.hpp>

string_options = { {ParserKeywords::COMPORD::keywordName , PartiallySupported<std::string>{1, ParseKeywords::COMPORD::TRACK::itemName}},

With some template trickery I guess it should be possible just use ParserKeywords::COMPORD and ParserKeywords::COMPORD::TRACK

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untested suggestion:

template <typename Keyword, typename Item,typename T>
void addUnsupported(std::multimap<std::string, PartiallySupported<T>& map, T itemValue) {
    std::pair<std::string,PartiallySupported<T>> pair( Keyword::keywordName , PartiallySupported<T>{ Item::itemName , itemValue});
    map.insert( pair );
}

addUnsupported<ParserKeywords::COMPORD , ParseKeywords::COMPORD::TRACK>( string_options , "TRACK");

}

@joakim-hove
Copy link
Member

Ok - this looks fine to me. I'll merke tomorrow.

@@ -55,6 +89,14 @@ namespace MissingFeatures {
"VAPPARS", "VISCREF", "WATVISCT",
"WPAVE", "WPIMULT", "WPITAB", "WTEMP",
"WTEST", "WTRACER", "ZIPPY2" };
std::multimap<std::string, PartiallySupported<std::string> > string_options;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would guess you could skip the last type in angular braces, since that can be inferred.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire thing can be brace initialised.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joakim-hove

If you mean the last type in this line, I guess the answer is no, since the compiler reports error.
addUnsupported<ParserKeywords::COMPORD, ParserKeywords::COMPORD::ORDER_TYPE, std::string>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire thing can be brace initialised.

Yes, it is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would guess you could skip the last type in angular braces, since that can be inferred.

Not in the constructor unless you give it something to infer from.

@jokva
Copy link
Contributor

jokva commented Jul 20, 2016

Clumsy syntax aside, I'm still not convinced this is a good feature at all.

@atgeirr
Copy link
Member

atgeirr commented Aug 19, 2016

I am now going to finish review and merging of this PR, sorry for ignoring it for so long! I have discussed some aspects with @joakim-hove, and will also make some comments in the diff.

@@ -55,6 +89,14 @@ namespace MissingFeatures {
"VAPPARS", "VISCREF", "WATVISCT",
"WPAVE", "WPIMULT", "WPITAB", "WTEMP",
"WTEST", "WTRACER", "ZIPPY2" };
std::multimap<std::string, PartiallySupported<std::string> > string_options;
std::multimap<std::string, PartiallySupported<int> > int_options;
addUnsupported<ParserKeywords::COMPORD, ParserKeywords::COMPORD::ORDER_TYPE, std::string>(string_options , "TRACK");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it is the DEPTH option that is unsupported, not the TRACK option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it means only TRACK is supported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize that now, and see that I should have read the code a bit more carefully. I think that must change: addUnsupported could really be called addSupported! However, instead of maintaining a list of supported features it is better I think to have a list of unsupported parts, so that addUnsupported() works as I initially assumed. Then the checking loop on line 56 should use == instead of != and of course the message must be rewritten, and the calls change to supply the complement of the current options (unsupported parts instead of supported parts).

If you do not agree with that (perhaps there are many more unsupported than supported options for this keyword?) then we must rename addUnsupported->addSupported.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps there are many more unsupported than supported options for this keyword?

This is the main reason why we check supported options, I will rename the function.

@atgeirr
Copy link
Member

atgeirr commented Aug 19, 2016

I only found one thing that must change (TRACK->DEPTH) above, otherwise this is ready to be merged. Thanks!

@qilicun
Copy link
Member Author

qilicun commented Aug 22, 2016

I only found one thing that must change (TRACK->DEPTH) above,

That's a long time, I almost forgot it means only the options listed is supported, will revert, sorry for the noise.

@qilicun qilicun force-pushed the messages-for-keywords-options branch from c30c295 to 4ae5a0a Compare August 22, 2016 02:03
@atgeirr
Copy link
Member

atgeirr commented Aug 22, 2016

Ok, I am satisfied with this and will merge when Jenkins says it's ok.

@atgeirr
Copy link
Member

atgeirr commented Aug 22, 2016

jenkins build this please

@atgeirr
Copy link
Member

atgeirr commented Aug 22, 2016

Ert fails for Jenkins, is that related to ongoing changes @akva2?

@akva2
Copy link
Member

akva2 commented Aug 22, 2016

yes

@akva2
Copy link
Member

akva2 commented Aug 22, 2016

and i'm done with the pr for all modules. usual rules apply (no self-merge), cause somebody will likely jump on me if i do.

@qilicun
Copy link
Member Author

qilicun commented Aug 23, 2016

jenkins build this please

@atgeirr
Copy link
Member

atgeirr commented Aug 23, 2016

Travis says ok after recent updates, so in it goes. Thanks!

@atgeirr atgeirr merged commit 183d2f4 into OPM:master Aug 23, 2016
@qilicun qilicun deleted the messages-for-keywords-options branch August 23, 2016 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants