-
Notifications
You must be signed in to change notification settings - Fork 35
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
Volume average #212
Volume average #212
Conversation
… updating matrix return.
Also make function in interputils return something
optimzations to static typing of functions in cython
Codecov Report
@@ Coverage Diff @@
## master #212 +/- ##
==========================================
+ Coverage 81.39% 81.48% +0.09%
==========================================
Files 24 24
Lines 5197 5228 +31
==========================================
+ Hits 4230 4260 +30
- Misses 967 968 +1
Continue to review full report at Codecov.
|
@prisae I know I never responded to it, but I did see your comment before, and implemented something that does the same thing, but bypasses the numpy boolean indexing. Let me know if that is sufficient. The idea was to speed it up when you're interpolating a large mesh extent onto a smaller mesh extent, without loosing too much time. |
I'll try to have a look before the meeting today. |
Yes, I like it now, great work @jcapriot! |
Improves speed if the new mesh is much smaller than the old mesh. See simpeg/discretize#212
Improves speed if the new mesh is much smaller than the old mesh. See simpeg/discretize#212
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.
Great to have this function built-in.
So I ran a small test (notebook attached) comparing the projection matrix between this one and the one used in simpeg.maps.TileMap
. The good news is that both give the same answer, even after applying active cells. This one appears to be a lot slower, however, by about a factor 10x fairly consistently.
I am guessing there is a cost for having more general Tensor <-> Octree?
Yes, there is certainly a cost associated with the general Tensor to OcTree... but you do bring up a good point. There's no reason the function could not recognize that a Tensor and OcTree share the same base mesh and switch to the faster version. Also, which operation is the first timing operation doing there, where the discretize one is faster than the SimPEG one? |
YEa not sure why the first in the loop is different. Maybe some imports on the simpeg side? |
@jcapriot: would it be possible to do a beta release to make this available on conda-forge? I am having trouble installing discretize from source on a remote machine at the moment... |
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.
This is a great addition @jcapriot! I have been testing it out on the EM problem, and it is working well for this case :)
@@ -82,3 +83,109 @@ def interpmat(locs, x, y=None, z=None): | |||
Q = sp.csr_matrix((vals, (I, J)), | |||
shape=(npts, np.prod(shape))) | |||
return Q | |||
|
|||
def volume_average(mesh_in, mesh_out, values=None, output=None): | |||
"""Volume averaging interpolation between meshes. |
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.
Thanks for such a beautiful docstring :)
@domfournier Can you check the timings again for me? I added shortcuts for when meshes share the same base mesh edited: actually never mind I'll run your notebook, thanks for that |
This PR implements the volume averaging operation for
TensorMesh
andTreeMesh
, as well as combinations of the two. I have used the Tensor to Tensor myself, however the Tree to X operations could use some more test driving.Of course there's some simple tests in here to ensure it's doing what I think it should be doing.
I was also running into issues getting the numpydoc's plot directive to automatically work in the Examples section of docstrings, and the solution was to remove the napoleon docs, since we're already using the
numpydoc
extension, and I couldn't find any examples of Google style docstrings, I just removed that fromconf.py
. So if this is okay, I'd like to just remove thenapoleon
Sphinx extension.