


example demonstrating reading in a 2DM file and constructing a model
function example
DESCRIPTION:
Read in a 2DM Mesh and bathymetry file
Dump river file, open boundary forcing file, time series wind forcing
file, grid file, open boundary node list file, bathymetry file,
beflag file, roughness file
INPUT
OUTPUT:
A bunch of files
EXAMPLE USAGE
example
Author(s):
Geoff Cowles (University of Massachusetts Dartmouth)
Revision history
==============================================================================

0001 % example demonstrating reading in a 2DM file and constructing a model 0002 % 0003 % function example 0004 % 0005 % DESCRIPTION: 0006 % Read in a 2DM Mesh and bathymetry file 0007 % Dump river file, open boundary forcing file, time series wind forcing 0008 % file, grid file, open boundary node list file, bathymetry file, 0009 % beflag file, roughness file 0010 % 0011 % INPUT 0012 % 0013 % OUTPUT: 0014 % A bunch of files 0015 % 0016 % EXAMPLE USAGE 0017 % example 0018 % 0019 % Author(s): 0020 % Geoff Cowles (University of Massachusetts Dartmouth) 0021 % 0022 % Revision history 0023 % 0024 %============================================================================== 0025 0026 0027 clear all; close all; 0028 0029 global ftbverbose 0030 ftbverbose = true; %print information to screen [true/false] 0031 0032 % read the Mesh from an SMS file 0033 Mobj = read_sms_mesh('2dm','./samples/tst.2dm','bath','./samples/tst.dep'); 0034 0035 % reverse the topography so that it is positive down (e.g. bathymetry) 0036 if(mean(Mobj.h) < 0.0) 0037 Mobj.h = -Mobj.h; 0038 end; 0039 0040 % calculate the Corolis 0041 Mobj = add_coriolis(Mobj,'constant',31.0); 0042 0043 % check the time step and plot 0044 Mobj = estimate_ts(Mobj); 0045 plot_field(Mobj,Mobj.ts,'title','timestep (s)') 0046 fprintf('estimated max external mode time step in seconds %f\n',min(Mobj.ts)); 0047 0048 % smooth bathymetry with 4 iterations of explicit smoother 0049 plot_field(Mobj,Mobj.h,'title','original bathymetry') 0050 Mobj = setup_metrics(Mobj); 0051 [Mobj.h] = smoothfield(Mobj.h,Mobj,0.5,4); 0052 plot_field(Mobj,Mobj.h,'title','smoothed bathymetry'); 0053 0054 % setup spatially variable bottom roughness and dump to file 0055 hc = nodes2elems(Mobj.h,Mobj); 0056 z0 = .008*ones(Mobj.nElems,1); 0057 deep = find(hc > 5.); 0058 z0(deep) = .004; 0059 clear hc; 0060 write_FVCOM_z0(z0,'tst_z0.nc','z0 test 1') 0061 plot_field(Mobj,elems2nodes(z0,Mobj),'title','bottom roughness') 0062 0063 % add a river to the domain 0064 %[Mobj] = add_river_nodes_graphic(Mobj,'tstRiver'); 0065 [Mobj] = add_river_nodes_list(Mobj,[838,844,845],'tstRiver'); 0066 0067 % add an open boundary to the Mesh 0068 [Mobj] = add_obc_nodes_list(Mobj,[1:25],'OpenOcean',1); 0069 % [Mobj] = add_obc_nodes_graphic(Mobj,'OpenOcean2',1); 0070 0071 % add two sponge layers to the Mesh 0072 % [Mobj] = add_sponge_nodes(Mobj,'Sponge1',10000,.0001); 0073 % [Mobj] = add_sponge_nodes(Mobj,'Sponge2',5000,.0004); 0074 0075 % plot everything 0076 plot_field(Mobj,Mobj.h,'title','domain','withextra',true,'showgrid',true); 0077 0078 0079 0080 %------------------------------------------------------------------------------ 0081 % dump input files for FVCOM 3.x 0082 %------------------------------------------------------------------------------ 0083 0084 % add river forcing 0085 example_FVCOM_river() 0086 0087 % add harmonic forcing to open boundary 0088 set_spectide(Mobj) 0089 0090 % add Julian forcing to the open boundary using t_tide station 0091 0092 % wind time series wind forcing example here 0093 example_FVCOM_wind_ts 0094 0095 % dump mesh and connectivity 0096 write_FVCOM_grid(Mobj,'tst_grd.dat') 0097 0098 % dump bathymetry 0099 write_FVCOM_bath(Mobj,'tst_dep.dat') 0100 0101 % % dump open boundary node list 0102 write_FVCOM_obc(Mobj,'tst_obc.dat') 0103 0104 % dump a Temp/Salinity open boundary forcing file 0105 example_FVCOM_tsobc() 0106 0107 % dump sponge layer file 0108 write_FVCOM_sponge(Mobj,'tst_spg.dat'); 0109 0110 % do not allow for bed processes (erosion/deposition) east of the inlet 0111 pts = find(Mobj.x > 2.85e5); 0112 bedflag = ones(Mobj.nVerts,1); 0113 bedflag(pts) = 0; 0114 write_FVCOM_bedflag(bedflag,'tst_bedflag.nc','no bed processes east of inlet') 0115 plot_field(Mobj,bedflag); title('bedflag'); 0116 0117 % dump Coriolis file 0118 write_FVCOM_cor(Mobj,'tst_cor.dat') 0119 0120