-
Notifications
You must be signed in to change notification settings - Fork 186
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
Variable grid spacing in horizontal dimension (x or y) causes NonhydrostaticModel
instantiation to fail
#2191
Comments
I think this is indeed a limitation of Oceananigans at the moment. We have implemented a pressure solver for when the |
I think I remember reading that someplace in an issue or discussion thread... that would certainly explain the |
Could you comment on what version of Oceananigans you are using? Perhaps we need to add a validation that spits out a meaningful warning to the user when this happens. |
NonhydrostaticModel
instantiation to failNonhydrostaticModel
instantiation to fail
Indeed the pressure solver at the moment allows only a variable z-direction. This is because for a regular grid we can use a full FFT solve while with a singular stretched direction we can solve a tridiagonal system. For more than one stretched direction we should use an iterative solver to solve the Poisson equation (the solvers are there but the infrastructure not quite yet). We should implement the iterative solver as a default for two or more stretched directions. And set up the FFT-tridiagonal solver as default when we have one stretched direction (either x, y or z) In the meantime, as a hotfix, If you only need one stretched direction I would suggest you to rotate your problem to stretch it in z-direction |
I think the error is surprisingly clear actually! There's no pressure solver for grids that are stretched in But it won't be much effort to add a more specific warning in the constructor for @simone-silvestri good point that the FFT/tridiagonal solver should work in other directions! Unfortunately though I think the tridiagonal solver is hard-coded to batch in |
The error is not as clear, @glwagner.
does not immediately reads "no pressure solver for grids that are stretched in x or y". One needs to infer that from the long types of the function arguments. |
I guess I just read the first part "no method matching PressureSolver" and that made sense to me: there's no pressure solver for my input! But you're right that you don't know which input is the problem (only I know that only the grid matters). So yeah, I think some input validation for |
Fair enough! But perhaps not what would come in mind to everyone ;) |
I tend to agree with @navidcy. For that error to be clear a user would have to be familiar with Julia's multiple dispatch feature and what "method" means. Clear for us, but not super clear for a new Julia user.
Is it worth to rotate x- and y-stretched grids so that the stretching is in the |
I think transposing at each time step would be quite expensive and memory-intensive. |
I'm using v0.68.6, previously I was on v0.67.1 and saw the same error (not surprising). I was hoping to use a stretched x-grid with a stretched z-grid while I play around with some 2D internal wave simulations. I'm still new to Julia and Oceananigans so I've been trying to simulate the classic vertically oscillating sphere or cylinder as my source. I was playing around with refining the mesh near the oscillation to see if the wave beams were a little cleaner. I can make due with stretched z-grids for now! -- |
True! You likely don't want a grid that's stretched in two directions for this application, because even if we had a valid solver for such a case, it would be much slower than the regular-x case. So even though you might be able to save a few grid points, you might not end up with shorter time-to-solution. |
|
I think it might be more fruitful to generalize
Not a small refactor, so I'd argue not priority 1 right now. |
We added a more helpful error for this |
Using a variable grid spacing like the Ocean wind mixing and convection example in a direction other than
z
raises aMethodError
when creating aNonhydrostaticModel
.Modified from OWM&C:
I get the following error if I try to use the above code or put the variable grid spacing in the x-direction
The text was updated successfully, but these errors were encountered: