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

Support JFUNC in TableManager #956

Closed
wants to merge 3 commits into from
Closed

Support JFUNC in TableManager #956

wants to merge 3 commits into from

Conversation

pgdr
Copy link
Contributor

@pgdr pgdr commented Oct 31, 2016

With this PR,

  • the JFUNC keyword is internalized in TableManager by the function .useJFunc()
  • the tables that should respect JFUNC will not be SI converted when tables are constructed:
  • SWFN, SGFN, SWOF, SGOF, SLGOF

Notice that the last of the three commits only contain general maintenance.

Copy link
Contributor

@jokva jokva left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@andlaus
Copy link
Contributor

andlaus commented Oct 31, 2016

the tables that should respect JFUNC will not be SI converted when tables are constructed.

it looks to me like the respective columns of the underlying 2p tables are still accessed via *pressureColumn()? If this is the case, the PR is not really an improvement because by reading the code, one would still assume that these are pressures and not J(S). IMO, a "good" solution would introduce "jfuncColumn()" methods to these tables which would throw an exception if they are called if JFUNC is not featured by the deck and vice-versa for *pressureColumn().

Also, it would be cool if you would test this on "model 2.2" with flow by running it for a few time steps...

@pgdr
Copy link
Contributor Author

pgdr commented Nov 1, 2016

@andlaus I added the getJFuncColumn-method. Are you sure we want to throw when used "inappropriately"? If so, I will add that as well.

@andlaus
Copy link
Contributor

andlaus commented Nov 1, 2016

Are you sure we want to throw when used "inappropriately"?

I'd say "yes" because it is better to get no result than a wrong one!? I guess @joakim-hove will have to decide this in the end..

@pgdr
Copy link
Contributor Author

pgdr commented Nov 1, 2016

@andlaus He told me that your will is my command. Could you check the two last commits of this PR and see if they're ok by you?

We should coordinate the merging of this with the necessary changes in material as well.

@andlaus
Copy link
Contributor

andlaus commented Nov 1, 2016

now I'm happy with this :)

please do not merge just yet, I still need to fix up opm-material...

@pgdr
Copy link
Contributor Author

pgdr commented Nov 1, 2016

Great! Thanks for reviewing.

Just merge this at will.

Pål Grønås Drange added 3 commits November 1, 2016 13:39
* Implement JFUNC keyword
* added tests for JFUNC in TableManagerTests
* added protected member m_jfunc to SimpleTable
* Added getJFuncColumn to accompany getPcowColumn
* Throws if pressure or jfunc is accessed inappropriately
 * ... meaning if getPcowColumn is called when JFUNC is in deck, or
 * getJFuncColumn is called when JFUNC is not in deck
* added tests for throwing and for getJFuncColumn
* Implemented missing method "name" in TableColumn.cpp
* add inline to method in RestartConfig to remove warning
* Whitespace changes
@pgdr
Copy link
Contributor Author

pgdr commented Nov 1, 2016

Note, I squashed and reordered commits.

@@ -60,11 +60,15 @@ namespace Opm {
*/
double evaluate(const std::string& columnName, double xPos) const;

/// throws std::invalid_argument if jf != m_jfunc
void assertJFuncPressure(const bool jf) const;
Copy link
Contributor

@andlaus andlaus Nov 3, 2016

Choose a reason for hiding this comment

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

I just noticed this now while trying to adapt opm-material: I'm pretty sure that this method is specific to (some of) the saturation function tables, i.e., it may be a bit more convenient to add it to the base class of all tables from an implementor's point of view, but it does not make too much sense IMO. do you mind moving this to SwofTable and friends?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you think it's better to have this function in five different classes than in one superclass? What about the m_jfunc boolean flag? Should that go to the five classes as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

I want to unify all the tables under one non-virtual class soon, and have them be distinguished by content. I don't think it's too unreasonable the way it is now for that reason.

If there's a compelling reason to maintain strictly different types for this I'll take it to heart and consider having multiple table types stored in the manager (in the future).

It's on the ever-growing TODO list.

Copy link
Contributor

Choose a reason for hiding this comment

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

to all of your questions: yep, since IMO it makes about zero sense for e.g., PvtoTable. alternatively, you can add a SatfuncSimpleTable but I think adding this to all satfunc tables individually is better because this is ECL and it might be that this JFUNC handling does apply to all of them.

Copy link
Contributor

Choose a reason for hiding this comment

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

I want to unify all the tables under one non-virtual class soon, and have them be distinguished by content. I don't think it's too unreasonable the way it is now for that reason.

personally I'm not a big fan of "fat interface" approaches: they sometimes might be simpler to implement and require less code, but they are also often very easy to misuse in subtle ways. (e.g. calling pvtoTable.assertJFuncPressure(true) may sometimes work but sometimes not.)

note that I nowadays consider myself just to be a user of opm-parser in 98% of all cases, so if you do it that way anyway, I won't object as long as it works as advertised.

Copy link
Contributor

Choose a reason for hiding this comment

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

personally I'm not a big fan of "fat interface" approaches:

It's mostly driven by wanting reasonable value+copy semantics, meaning pointers are clumsy. We'll obviously take care to not make the tables unusable.

@andlaus
Copy link
Contributor

andlaus commented Nov 3, 2016

hm, another problem with this patch that I've just noticed: while it throws at constructs like sgofTable.getPcogColumn() if JFUNC is present, the generic variant of accessing the same data (sgofTable.getColumn("PCOG")) passes just fine...

@pgdr
Copy link
Contributor Author

pgdr commented Nov 3, 2016

yeah, that should be fixed.

@andlaus
Copy link
Contributor

andlaus commented Nov 4, 2016

hm, I hacked around to adapt opm-material for this yesterday and I changed my opinion during this exercise: with the context dependent pressure columns, the opm-material code just became more complicated, but not better (except -- maybe -- from a conceptual point of view). I guess we should thus consider to leave things as they are now...

@pgdr
Copy link
Contributor Author

pgdr commented Nov 4, 2016

Closing this as per discussion. I will cherry-pick the internalization of the keyword (into TableManager) and the improved test at a later point, and come with a new PR on that.

@pgdr pgdr closed this Nov 4, 2016
@pgdr
Copy link
Contributor Author

pgdr commented Nov 4, 2016

Thanks for reviewing, Jørgen and Andreas ... in any case, we learnt something from this, so it is not entirely wasted time.

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.

3 participants