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

Do not compute WellState::numPhases #1047

Closed

Conversation

blattms
Copy link
Member

@blattms blattms commented Jun 24, 2016

but store it during initialization and reuse it afterwards. Previously it was computed by dividing
the size of the bhp_ array by the number of wells. This crashed if there were no wells present/active, e.g. when writing the report step.

Closes OPM/opm-simulators#731

but store it during initialization and reuse it
afterwards. Previously it was computed by dividing
the size of the bhp_ array by the number of wells.
This crashed if there were no wells present/active.
@blattms
Copy link
Member Author

blattms commented Jun 25, 2016

Do not merge yet. I am running into other problems now.

Otherwise numPhases might be uninitialized and/or wrong.
@blattms
Copy link
Member Author

blattms commented Jun 25, 2016

With the recent commit it works for me.

Please be aware that developers are allowed to change the welllRates and bhp vectors. That might change the number of phases. Maybe we should only use numPhases_ as fallback if there are no wells present?

@atgeirr
Copy link
Member

atgeirr commented Jun 27, 2016

I don't think this will work, as numPhases_ is not initialized unless you have a Wells* (which I believe is null in the no-wells case).

Edit: maybe simply adding a constructor argument is the best?

@blattms
Copy link
Member Author

blattms commented Jun 27, 2016

I beg to differ: It does work for the current OPM as numPhases() will be called but the result never used if there are no wells. (Norne and SPE cases run through).

The problem concerning the extra constructor argument is that the usual call sequence is:

WellState well_state;
well_state.init(wells, state);

Retrieving the number of phases from eclipse state in addition seems like extra work.

Anyway, I will post a competing PR to this one in a minute.

@blattms
Copy link
Member Author

blattms commented Jun 27, 2016

Wrong usage might still result in using a wrong number of phases and will lead to bugs that are hard to find. I prefer to get a floating point exception that make debugging much more easy. Closing...

@blattms blattms closed this Jun 27, 2016
@atgeirr
Copy link
Member

atgeirr commented Jun 27, 2016

Was this closed because the PRs in opm-simulators make sure this is never called without wells? Or did I misunderstand the relations here?

@blattms
Copy link
Member Author

blattms commented Jun 27, 2016

Yes it was closed as OPM/opm-simulators#742 can handle the problem. Furthermore getting a floating point exception when used improperly is much easier to debug than hunting wrong indexing in arrays because of a bogus number of phases.

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.

2 participants