-
Notifications
You must be signed in to change notification settings - Fork 59
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
ENH: add a method that creates a grid property between two input surfaces #1291
Merged
+697
−221
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8acf72a
MAINT: make decorator functimer more flexible
jcrivenaes a8c2b5d
ENH,CLN: add and migrate C++ methods for cell center computing
jcrivenaes e450ea7
ENH: add make_righthanded() method for RegularSurface
jcrivenaes 272bcbb
ENH: add method get_property_between_surfaces() for Grid class
jcrivenaes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,60 @@ grid_cell_volumes(const size_t ncol, | |
return cellvols; | ||
} | ||
|
||
/* | ||
* Get cell centers for a grid. | ||
* | ||
* @param ncol Grid dimensions ncol/nx | ||
* @param nrow Grid dimensions nrow/ny | ||
* @param nlay Grid dimensions nlay/nz | ||
* @param coordsv Grid Z coordinates vector | ||
* @param zcornsv Grid Z corners vector | ||
* @param actumsv Active cells vector | ||
* @param asmasked Process grid cells as masked (return NaN for inactive cells) | ||
* @return Arrays with the X, Y, Z coordinates of the cell centers | ||
*/ | ||
std::tuple<py::array_t<double>, py::array_t<double>, py::array_t<double>> | ||
grid_cell_centers(const size_t ncol, | ||
const size_t nrow, | ||
const size_t nlay, | ||
const py::array_t<double> &coordsv, | ||
const py::array_t<float> &zcornsv, | ||
const py::array_t<int> &actnumsv, | ||
const bool asmasked = false) | ||
{ | ||
pybind11::array_t<double> xmid({ ncol, nrow, nlay }); | ||
pybind11::array_t<double> ymid({ ncol, nrow, nlay }); | ||
pybind11::array_t<double> zmid({ ncol, nrow, nlay }); | ||
auto xmid_ = xmid.mutable_unchecked<3>(); | ||
auto ymid_ = ymid.mutable_unchecked<3>(); | ||
auto zmid_ = zmid.mutable_unchecked<3>(); | ||
auto actnumsv_ = actnumsv.unchecked<3>(); | ||
|
||
for (size_t i = 0; i < ncol; i++) { | ||
for (size_t j = 0; j < nrow; j++) { | ||
for (size_t k = 0; k < nlay; k++) { | ||
size_t idx = i * nrow * nlay + j * nlay + k; | ||
if (asmasked && actnumsv_(i, j, k) == 0) { | ||
xmid_(i, j, k) = std::numeric_limits<double>::quiet_NaN(); | ||
ymid_(i, j, k) = std::numeric_limits<double>::quiet_NaN(); | ||
zmid_(i, j, k) = std::numeric_limits<double>::quiet_NaN(); | ||
continue; | ||
} | ||
auto cr = | ||
grid3d::cell_corners(i, j, k, ncol, nrow, nlay, coordsv, zcornsv); | ||
|
||
xmid_(i, j, k) = 0.125 * (cr[0] + cr[3] + cr[6] + cr[9] + cr[12] + | ||
cr[15] + cr[18] + cr[21]); | ||
ymid_(i, j, k) = 0.125 * (cr[1] + cr[4] + cr[7] + cr[10] + cr[13] + | ||
cr[16] + cr[19] + cr[22]); | ||
zmid_(i, j, k) = 0.125 * (cr[2] + cr[5] + cr[8] + cr[11] + cr[14] + | ||
cr[17] + cr[20] + cr[23]); | ||
} | ||
} | ||
} | ||
return std::make_tuple(xmid, ymid, zmid); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a note, manual testing indicates that this function in pybind11 is 2-3 times faster than the corresponding function using swig (which it now replaces). |
||
|
||
/* | ||
* Compute cell height above ffl (free fluid level), as input to water saturation. Will | ||
* return hbot, htop, hmid (bottom of cell, top of cell, midpoint), but compute method | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed this as it seems that mypy messages are incorrect (the # type: ignore is needed, but mypy claims it is not)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an aside, but I've found this usually to happen when some imports are not quite right in some way