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
181 stars 65 forks source link

NaN bathy value sneaking in when bottom right corner of mesh is just outside the bbox #142

Open HamishB opened 3 years ago

HamishB commented 3 years ago

Hi,

around half the time I run m = interp(m, gdat); on a high res. inset mesh I get NaNs sneaking into m.b. Sometimes even two of them. This happens at nodes which end up just ever so slightly outside the bbox, even though there is valid elevation data in the gdat DEM well beyond the given bbox. If the (possibly massive) DEM is being clipped to the bbox, perhaps a small buffer area could be added to the clipping box? e.g. 1% of the width or height of the bbox or an extra row/column or two of the DEM grid.

(often the bottom right corner, but not always)

dumb work-around: just re-run mshopts.build.grd until sum(isnan(m.b)) == 0.

thanks, Hamish

krober10nd commented 3 years ago

Yes, we only read in the portion of the domain that intersects with the bbox. A buffer is a good idea when reading the DEM.

krober10nd commented 3 years ago

Also, just a commentary I wouldn't interpolate from the gdat object. I would interpolate from the original DEM at the DEM's native resolution.

The idea being that the gdat may downsample the DEM to match the minimum mesh resolution depending on available memory.