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

Additional Functionality needed for PINCH Option(4) ALL support #4181

Merged
merged 8 commits into from
Oct 4, 2024

Conversation

blattms
Copy link
Member

@blattms blattms commented Sep 4, 2024

We will need to be able to

  • Calculate vertical transmissibilities during grid setup, which needs cell and face centers and face normal. Hence there is a function to get those.
  • We need an easy way to add multiple NNCs at once that will also hold transmissibilities. Those NNCs will be used to overwrite transmissibilities over pinched out cells in this case.

There are upcoming PRs in opm-grid and opm-simulators, but they still need some. I'll make this WIP because of that as changes migth be needed.

@blattms
Copy link
Member Author

blattms commented Sep 4, 2024

jenkins build this please

@blattms blattms changed the title Additional Functionality needed support PINCH Option(4) ALL Additional Functionality needed for PINCH Option(4) ALL support Sep 4, 2024
@blattms
Copy link
Member Author

blattms commented Sep 4, 2024

One question here is also whether to set EclipseGrid::m_multzMode to TOP unconditionally if EclipseGrid::m_pinchoutMode is ALL.

@blattms
Copy link
Member Author

blattms commented Sep 4, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@blattms
Copy link
Member Author

blattms commented Sep 5, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@blattms blattms marked this pull request as ready for review September 5, 2024 11:39
Copy link
Member

@atgeirr atgeirr 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, should be merged after addressing issues. One potential (not new!) bug, otherwise mostly suggestions for small improvements.

opm/input/eclipse/EclipseState/Grid/FieldPropsManager.cpp Outdated Show resolved Hide resolved
@@ -160,6 +160,9 @@ namespace Opm {
/// Will return a vector a length num_active; where the value
/// of each element is the corresponding global index.
const std::vector<int>& getActiveMap() const;
/// \brief get cell center, and center and normal of bottom face
std::tuple<std::array<double, 3>,std::array<double, 3>,std::array<double, 3>>
Copy link
Member

Choose a reason for hiding this comment

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

This is fine, but if/when we merge this module with opm-grid, then Dune::FieldVector would be available. Do you think that would be a good idea to user throughout here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It might reduce code duplication and facilitate code reuse, indeed. ... once the modules are merged.

*(Y.begin() + 6),
*(Z.begin() + 6)};

for(const auto cornerIndex: bottomIndices)
Copy link
Member

Choose a reason for hiding this comment

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

I suggest instead doing the cross product of the diagonals, that is the same order of accuracy, and less complex to write and read.

Copy link
Member Author

@blattms blattms Sep 17, 2024

Choose a reason for hiding this comment

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

I know that the code is complex. It basically mirrors the way it is done in opm-grid (which does the same but due to lack of docs is even harder to understand). I had the same reaction when I saw that code as you now.

But (after contemplating about the original code for some time) I think that the complexity is there for a reason. The problem is that we are talking about corner point grids. Where the corners of the top and bottom face do not need to span a plan. For a plane there is no difference,
But those points can e.g. lie rather awkwardly on the columns, such that the face is actually kind of curved and flat. Then doing it this way (with the additional center of mass) is a better approximation to the curved "plane", I think...

opm/input/eclipse/EclipseState/Grid/NNC.hpp Outdated Show resolved Hide resolved
std::swap(item.cell1, item.cell2);
});
std::sort(m_input.begin() + old_size, m_input.end());
std::inplace_merge(m_input.begin(), m_input.begin() + old_size, m_input.end());
Copy link
Member

Choose a reason for hiding this comment

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

This requires that both partial ranges are sorted, and for the incoming data that is ensured here in this function. Could this be changed to combine two NNC objects instead, or would that be inefficient for some reason? Then both ranges would already be sorted, since addNNC() already ensures this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably. I will see what I can do.
Not even sure anymore, whether I will need this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, there is nothing to be done here. as the m_input should always be sorted, see load_input and the likes.

Copy link
Member Author

Choose a reason for hiding this comment

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

They are both sorted, see load_input and the likes.

Copy link
Member

Choose a reason for hiding this comment

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

If so, then this function can be reduced to just:

        const auto old_size = m_input.size();
        m_input.insert(m_input.end(), data.begin(), data.end());
        std::inplace_merge(m_input.begin(), m_input.begin() + old_size, m_input.end());

(If my reading of load_input() is correct.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I should not have said both.

I do not want to rely on anything here for the function parameter. Hence I need to make sure that the indices are correct and sort that one. That is what I am doing.

Copy link
Member Author

@blattms blattms left a comment

Choose a reason for hiding this comment

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

thanks a lot for the review. I will try to address most of those. First I need to fix some still lingering bugs (materializing in the real wold) in the approach, though.

*(Y.begin() + 6),
*(Z.begin() + 6)};

for(const auto cornerIndex: bottomIndices)
Copy link
Member Author

@blattms blattms Sep 17, 2024

Choose a reason for hiding this comment

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

I know that the code is complex. It basically mirrors the way it is done in opm-grid (which does the same but due to lack of docs is even harder to understand). I had the same reaction when I saw that code as you now.

But (after contemplating about the original code for some time) I think that the complexity is there for a reason. The problem is that we are talking about corner point grids. Where the corners of the top and bottom face do not need to span a plan. For a plane there is no difference,
But those points can e.g. lie rather awkwardly on the columns, such that the face is actually kind of curved and flat. Then doing it this way (with the additional center of mass) is a better approximation to the curved "plane", I think...

@@ -160,6 +160,9 @@ namespace Opm {
/// Will return a vector a length num_active; where the value
/// of each element is the corresponding global index.
const std::vector<int>& getActiveMap() const;
/// \brief get cell center, and center and normal of bottom face
std::tuple<std::array<double, 3>,std::array<double, 3>,std::array<double, 3>>
Copy link
Member Author

Choose a reason for hiding this comment

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

It might reduce code duplication and facilitate code reuse, indeed. ... once the modules are merged.

std::swap(item.cell1, item.cell2);
});
std::sort(m_input.begin() + old_size, m_input.end());
std::inplace_merge(m_input.begin(), m_input.begin() + old_size, m_input.end());
Copy link
Member Author

Choose a reason for hiding this comment

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

Probably. I will see what I can do.
Not even sure anymore, whether I will need this.

opm/input/eclipse/EclipseState/Grid/NNC.hpp Outdated Show resolved Hide resolved
@blattms blattms marked this pull request as draft September 20, 2024 16:21
@blattms blattms force-pushed the feature/get-centers-egrid branch 2 times, most recently from e035942 to 97afe21 Compare September 23, 2024 11:28
@blattms
Copy link
Member Author

blattms commented Sep 23, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@blattms blattms marked this pull request as ready for review September 24, 2024 15:42
@blattms
Copy link
Member Author

blattms commented Sep 24, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

1 similar comment
@blattms
Copy link
Member Author

blattms commented Sep 24, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@bska
Copy link
Member

bska commented Sep 26, 2024

I notice that there's a merge conflict here, but that the PR otherwise is marked ready for review. What's the status of this overall feature–i.e., this PR and its downstream companion PRs? Is everything ready for review?

@blattms
Copy link
Member Author

blattms commented Sep 27, 2024

Shoot. Somehow I forgot pushing yesterday.
This is now working for the test cases and the model that I have.

@blattms
Copy link
Member Author

blattms commented Sep 27, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@blattms
Copy link
Member Author

blattms commented Sep 30, 2024

I will rebase this to make it work for users again.

Just note, that I am factoring out another PR (for OPERATER), but some tests are still giving bad results-

This is needed to calculate Z transmissibilities for pinched out
cells.
This will be needed when computing transmissibilties for pinched
cells. Then we will need to apply them only for a subset of cells.
This is needed for PINCH optio 4 ALL.
These are the keywords that are needed to calculate transmissibilties
for the deactivated cells for the case that PINCH(4) is ALL: PERM*,
TRANZ* (for the transmissibility multiplier).

After we process PINCH we make those local again.
To mark these keywords we use keyword_info::local_in_schedule
This cleaner and does not increase the storage size for the normal
NNCs. It will also be needed for correct multiplier application.
@blattms
Copy link
Member Author

blattms commented Oct 1, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@blattms
Copy link
Member Author

blattms commented Oct 1, 2024

Unfortunately my answers are not seen here in threaded mode. I gues you have to go to the "Files changed" tab to see the context. Seems like there currently is nothing to here.

@blattms
Copy link
Member Author

blattms commented Oct 1, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

1 similar comment
@bska
Copy link
Member

bska commented Oct 1, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@blattms
Copy link
Member Author

blattms commented Oct 1, 2024

Why the heck should this change alugrid results?

Branches were out of sync. Retrying...

@blattms
Copy link
Member Author

blattms commented Oct 1, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@blattms
Copy link
Member Author

blattms commented Oct 1, 2024

Seems like my push in opm-simulators was previously not successful. Let's try again

@blattms
Copy link
Member Author

blattms commented Oct 1, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

Copy link
Member

@atgeirr atgeirr left a comment

Choose a reason for hiding this comment

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

Having reread the changed parts, I think that aside from some very minor issues, this is ready to be merged. Will be looking at the PRs in the other repos next.

bool global = false;
/// \brief Supply global storage but remove it once the SCHEDULE is executed
///
/// Needed to get rid off global storage for keywords needed for PINCH
Copy link
Member

Choose a reason for hiding this comment

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

Typo: "rid of".

return *this;
}

keyword_info<T>& global_kw_until_edit() {
this->global = this->local_in_schedule = true;
Copy link
Member

Choose a reason for hiding this comment

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

While correct code, it is easy to misread in a hurry. I would very much prefer a single assignment per line.

@blattms
Copy link
Member Author

blattms commented Oct 1, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@atgeirr
Copy link
Member

atgeirr commented Oct 2, 2024

jenkins build this please

@blattms
Copy link
Member Author

blattms commented Oct 3, 2024

Can be merged alone but triggering jenkins for the whole chain anyway.

@blattms
Copy link
Member Author

blattms commented Oct 3, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@blattms
Copy link
Member Author

blattms commented Oct 4, 2024

And another time. To test typo fixes in opm-grid...

@blattms
Copy link
Member Author

blattms commented Oct 4, 2024

jenkins build this opm-grid=756 opm-simulators=5577 please

@blattms blattms merged commit 7459cdf into OPM:master Oct 4, 2024
1 check passed
@blattms blattms deleted the feature/get-centers-egrid branch October 4, 2024 19:02
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.

4 participants