Commit f32fe75f authored by Simon Waldman's avatar Simon Waldman

read_sms_mesh.m : If we have bathymetry in the .2dm file *and* a separate

   bathymetry file is provided, use the bathymetry in the file (with a
   warning) rather than ignoring it.
parent 46a2da14
...@@ -61,6 +61,9 @@ function [Mobj] = read_sms_mesh(varargin) ...@@ -61,6 +61,9 @@ function [Mobj] = read_sms_mesh(varargin)
% 2018-05-16 Rewrote nodestring parsing. It's far less elegant, but now % 2018-05-16 Rewrote nodestring parsing. It's far less elegant, but now
% it still works if the number of nodes in a string is a multiple of 10. % it still works if the number of nodes in a string is a multiple of 10.
% (SW) % (SW)
% 2018-05-16 If we have bathymetry in the .2dm file *and* a separate
% bathymetry file provided, use the bathymetry in the file (with a
% warning) rather than ignoring it.
% %
%============================================================================== %==============================================================================
...@@ -300,38 +303,41 @@ fclose(fid); ...@@ -300,38 +303,41 @@ fclose(fid);
bath_range = max(h) - min(h); bath_range = max(h) - min(h);
if have_bath if have_bath
if bath_range == 0 if bath_range ~= 0
fid = fopen(sms_bath, 'rt'); warning(['Bathymetry is present in the .2dm file, but a bathymetry .dat file was also provided. '...
if fid < 0 'The .dat file will be used, and the depth info in the .2dm will be ignored.']);
error('file: %s does not exist', sms_bath); end
else fid = fopen(sms_bath, 'rt');
if ftbverbose; fprintf('reading sms bathymetry from: %s\n', sms_bath); end if fid < 0
end error('file: %s does not exist', sms_bath);
lin = fgetl(fid); else
lin = fgetl(fid); if ftbverbose; fprintf('reading sms bathymetry from: %s\n', sms_bath); end
lin = fgetl(fid);
C = textscan(fid, '%s %d', 1);
nVerts_tmp = C{2};
C = textscan(fid, '%s %d', 1);
nElems_tmp = C{2};
if (nVerts - nVerts_tmp) * (nElems - nElems_tmp) ~= 0
fprintf('dimensions of bathymetry file do not match 2dm file\n')
fprintf('bathymetry nVerts: %d\n',nVerts_tmp)
fprintf('bathymetry nElems: %d\n',nElems_tmp)
error('stopping...')
end
lin = fgetl(fid);
lin = fgetl(fid);
lin = fgetl(fid);
lin = fgetl(fid); % extra one for the new format from SMS 10.1, I think
C2 = textscan(fid, '%f', nVerts);
h = C2{1};
have_bath = true;
clear C2
fclose(fid);
end end
lin = fgetl(fid);
lin = fgetl(fid);
lin = fgetl(fid);
C = textscan(fid, '%s %d', 1);
nVerts_tmp = C{2};
C = textscan(fid, '%s %d', 1);
nElems_tmp = C{2};
if (nVerts - nVerts_tmp) * (nElems - nElems_tmp) ~= 0
fprintf('dimensions of bathymetry file do not match 2dm file\n')
fprintf('bathymetry nVerts: %d\n',nVerts_tmp)
fprintf('bathymetry nElems: %d\n',nElems_tmp)
error('stopping...')
end
lin = fgetl(fid);
lin = fgetl(fid);
lin = fgetl(fid);
lin = fgetl(fid); % extra one for the new format from SMS 10.1, I think
C2 = textscan(fid, '%f', nVerts);
h = C2{1};
have_bath = true;
clear C2
fclose(fid);
elseif bath_range ~= 0 elseif bath_range ~= 0
have_bath = true; have_bath = true;
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment