Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update msh.m #132

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion @msh/msh.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@

% write mesh to disk
function write(obj,fname,type)
% Usage:
% write(obj,fname,type)
%
% Examples:
% write(obj); % writes all available data to fort_1.xx (ADCIRC) files
% write(obj,fname); % writes all available data to fname.xx (ADCIRC) files
% write(obj,fname,'14'); % writes mesh data to fname.14 (ADCIRC) file
% write(obj,fname,'gr3'); % writes mesh data to fname.gr3 (SCHISM) file
% write(obj,fname,'ww3'); % writes mesh data to fname.ww3 (WaveWatchIII) file
% write(obj,fname,{'13','14'}); % writes mesh data and f13 attribute data to fname.14 and fname.13 (ADCIRC) files
if nargin == 1
fname = 'fort_1';
end
Expand Down Expand Up @@ -207,7 +217,8 @@ function write(obj,fname,type)
writefort5354( obj.f5354, fname );
end
else
if any(contains(type,'14')) || any(contains(type,'ww3'))
if any(contains(type,'14')) || any(contains(type,'ww3')) || ...
any(contains(type,'gr3'))
if isempty(obj.p)
error('No mesh, cannot write.')
end
Expand All @@ -220,6 +231,15 @@ function write(obj,fname,type)
writefort14( [fname '.14'] , obj.t, obj.p, b_t, ...
obj.op , obj.bd ,obj.title ) ;
end
if any(contains(type,'gr3'))
if ~isempty(obj.bd)
% schism only accepts ibtype 0 or 1 for land bcs
obj.bd.ibtype(obj.bd.ibtype == 21) = 1;
obj.bd.ibtype(obj.bd.ibtype == 20) = 0;
end
writefort14( [fname '.gr3'] , obj.t, obj.p, b_t, ...
obj.op , obj.bd ,obj.title ) ;
end
if any(contains(type,'ww3'))
writeww3( [fname '.ww3'] , obj.t, obj.p, b_t, ...
obj.op , obj.title ) ;
Expand Down