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
188 stars 68 forks source link

meshgen.build Exiting early #286

Closed soloyant closed 1 year ago

soloyant commented 1 year ago

Hi,

First of all, I want to address a big thank you to the development community for this great tool. I have been using it for the past year and can't imagine working without it anymore.

Describe the bug The issue happens when trying to mesh a wide coastal domain (100+ x 100+ km) with no coastline shapefile provided. For smaller domains or domains including a large enough cumulated area of holes/mainlands using the shapefile argument, the build method applied to a meshgen object iterates correctly. However, it ends early with no specific error returned in some cases, which seem to be depending on the domain size. Changing the geodata and edgefx parameters don't change the result, only reducing the surface covered by bbox will allow the algorithm to run completely.

To Reproduce

Script:

dem = 'SRTM15+.nc'; 
bbox = [[-91.6119;-90.1796;-90.1796;-91.6119], [29.7817;29.7817;28.5891;28.5891]];
min_el = 30;
max_el = 25000
grade = 0.2;
R = 3;
dt = 0.9;
wl = 10;
slp = 10;

gdat = geodata('dem', dem, 'h0', min_el, 'bbox', bbox);
fh = edgefx('geodata', gdat, 'fs', R, 'max_el', max_el, 'g', grade, 'dt', dt, 'wl', wl, 'slp', slp);
mshopts = meshgen('ef', fh, 'bou', gdat, 'proj', 'Mercator', 'memory_gb', 30, 'pfix', bbox);
mshopts = mshopts.build;

Output:

Current mapping parameters -
 Projection: Mercator  (function: mp_cyl)
 longitudes: -91.6119     -90.1796       
 Latitudes: 28.5891      29.7817         
 sphere: normal                          
Forming initial point distribution...
    for box #1
Using 196 fixed points.
Number of initial points after rejection is 7973
Elapsed time is 31.492860 seconds.
 ------------------------------------------------------->
Begin iterating...
Exiting

Expected behavior The build method should start iterating and improving a mesh based on given parameters regardless of the domain size.

Configuration (please complete the following information):

Additional context N/A

krober10nd commented 1 year ago

Hi,

Happy to help.

Your issue seems to me like it's triggering the following logic https://github.com/CHLNDDEV/OceanMesh2D/blob/aac023649282e8fb59c284325e7330e97700065d/%40meshgen/meshgen.m#L660

I'd check the domain definition that is being read in via

plot(your_geodata_obj,'omega')

and potentially toggle the your_geodata_obj.inpoly_flip field from 0 to 1 or from 1 to 0 (depending on what it is).

soloyant commented 1 year ago

Hi Keith,

Switching the inpoly_flip field did the trick, thank you for your help!