CHLNDDEV / OceanMesh2D

A two-dimensional triangular mesh generator with pre- and post-processing utilities written in pure MATLAB (no toolboxes required) designed specifically to build models that solve shallow-water equations or wave equations in a coastal environment (ADCIRC, FVCOM, WaveWatch3, SWAN, SCHISM, Telemac, etc.).
https://github.com/sponsors/krober10nd
GNU General Public License v3.0
179 stars 65 forks source link

Fix for irregular grid in FindLinearIdx #204

Closed WPringle closed 3 years ago

WPringle commented 3 years ago

Testing for irregular DEM grid in FindLinearIdx function in order tointerpolate properly using cell-averaged method for irregular DEM grid

krober10nd commented 3 years ago

So it looks like there's three general cases:

1) Uniform grid DEM with both axes featuring same grid spacings. 2) Varying grid spacings in x and y axes. 3) Varying grid spacings along the x/y axis itself potentially at the same time (this is the irregular case that did not work).

I'll test this this weekend and get back to you.

WPringle commented 3 years ago

Yes, that's right.

I made a test (just modification of Example2) using the DEM used in the issue #203 and it seemed to fix that alignment using the updated varying grid spacings along the x/y axes.

krober10nd commented 3 years ago

Could you send me this test please?

krober10nd commented 3 years ago

Thinking about this logic, seems maybe a bit faulty.

if max(dx) ~= min(dx)

This also could be the case for dy.

I would make this

if max(dx) ~= min(dx) || max(dy) ~= min(dy)
WPringle commented 3 years ago

True that's a good change

krober10nd commented 3 years ago

what I would like to see is a test in the tests folder that demonstrates all three cases that I enumerated below work. For example, generate a DEM from an analytical function and then build the mesh over and over again with finer solution and compare the interpolated bathymetry with the analytical function.

krober10nd commented 3 years ago

Given that this problem has now appeared three times, it's important this doesn't happen again.

WPringle commented 3 years ago

fair enough, I can work on that.

krober10nd commented 3 years ago

Let me know if you need any help

WPringle commented 3 years ago

Made a test using a subset of the CUDEM with different resolution types. Please check it out

WPringle commented 3 years ago

Made sure test does not pass with the previous interpolation method.