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

Number of nodes and element change #303

Closed aribal2018 closed 11 months ago

aribal2018 commented 11 months ago

Hi All,

It seems to me that number of nodes and elements obtained from OceanMesh2D are slightly random. When I rerun the setup, I will get different number of nodes and elements.

Is the any way to produce exactly the same nodes and elements for the same setup?

Another thing is, can we plot node numbers on the top of the mesh please. By doing this, the node can be easily identified.

Thank you very much. Best regards, Agustinus

krober10nd commented 11 months ago

Correct, OceanMesh relies on random number generation for the initial point creation following the DistMesh algorithm. You can however fix the seeds using https://www.mathworks.com/help/matlab/ref/rng.html

You can plot node numbers on the mesh yourself after plotting the mesh. By default doing that would overload the graphic and make inspection difficult for even small scale meshes.

To achieve this in MATLAB, you will utilize the text function to annotate your plot with the indices of the points.

m.plot('type','tri','proj','none');
hold on;
% Annotating each point with its index
for i = 1:size(m.p, 1)
    text(m.p(i, 1), m.p(i, 2), num2str(i), 'VerticalAlignment','bottom','HorizontalAlignment','right');
end
aribal2018 commented 11 months ago

Thanks Keith. Have a great weekend.