-
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 averaging interpolation #179
Comments
Also, this is strictly for 3D, but for discretize it probably would have to be generalized to also work for 1D and 2D. |
As with #175 , there might also be a way within PyVista to do the same, @banesullivan ? |
Numba can, AFAIK, not access structure attributes, that is why the above function call is more complicated then necessary. But with a small wrapper this can be solved:
And it can be used then like
|
Note: This volume-averaging is massively slower than simple linear interpolation. (There might be smarter ways to implement it though...) So in the current state it should not be used within an inversion or something, just to build models. |
Thanks @prisae: this is a good point! We have a few of the pieces for this - within discretize, I would see this being implemented via the construction of a sparse-matrix but same idea |
Yes, that makes sense, I would love to see a sparse-matrix volume averaging implementation! |
I bet we can get a nice quick cython implementations |
Unless you change the algorithm per se I'd be surprised if a cython implementation is significantly faster than numba. |
It would still be ideal though for discretize, because discretize has already the Cython dependency. |
Sorry, I just saw this, @prisae - can you explain this algorithm? There's likely a way to do it in PyVista/VTK - but I want to make sure I understand this correctly. At a glance, this looks pretty similar to how PyVista's |
It simply means that the volume average of a property stays constant. So you don't just interpolate, say, from old cell centres to new cell centres. But you multiply the values with their You could make a very small example in 2D:
Say, in the first case, the left cell has value 100 (at cell centre |
So, from what I'm seeing in the code essentially the operation is in three steps:
Correct me if i'm wrong |
Correct @jcapriot, that is exactly what it does. And yes, it only contributes the overlapping part (your point with the '?'). |
Volume averaging was implemented in #212 |
As a follow up of questions I asked on Slack (Simpeg#discretize and Swung#python). EM fields are arguably best interpolated by a cubic spline (#175). Up- or downscaling model parameters is, however, often best done with a method which keeps the total value constant (
X*Y*Z*value = constant
), something which is not given with linear nor cubic spline interpolation. Although there are more sophisticated solutions (based on effective medium theory) the volume averaging technique is a simple method to ensure the total value of the property remains unchanged.I implemented the technique in
emg3d
, following Plessix et al., 2007, Geophysics. I post it here if you ever want to implement it in discretize. This is a numba-version, but it could be re-written for a Cython (unless discretize makes numba a dependency):The text was updated successfully, but these errors were encountered: