Commit 3702ddf4 authored by Pierre Cazenave's avatar Pierre Cazenave

Update the example code to work with the changes to the toolbox.

parent 2e096b02
% example demonstrating reading in a 2DM file and constructing a model
%
% function example
% function example_forcing_setup
%
% 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
% Read in an SMS .2dm Mesh and .dat bathymetry file
% Dump river file, open boundary forcing file, time series wind forcing
% file, grid file, open boundary node list file, bathymetry file, bedflag
% file, roughness file
%
% INPUT
%
%
% OUTPUT:
% A bunch of files
% A bunch of FVCOM forcing files
%
% EXAMPLE USAGE
% example
% example_forcing_setup
%
% Author(s):
% Author(s):
% Geoff Cowles (University of Massachusetts Dartmouth)
% Pierre Cazenave (Plymouth Marine Laboratory)
%
% Revision history
%
%==============================================================================
% 2016-02-18 Update the code to work with the changes to the toolbox.
%
%=============================================================================
clear all; close all;
clear
close all
global ftbverbose
ftbverbose = true; %print information to screen [true/false]
ftbverbose = true; % print information to screen [true/false]
% read the Mesh from an SMS file
Mobj = read_sms_mesh('2dm','./samples/tst.2dm','bath','./samples/tst.dep');
% reverse the topography so that it is positive down (e.g. bathymetry)
if(mean(Mobj.h) < 0.0)
Mobj.h = -Mobj.h;
end;
Mobj.h = -Mobj.h;
end
% calculate the Corolis
Mobj = add_coriolis(Mobj,'constant',31.0);
......@@ -48,24 +50,24 @@ fprintf('estimated max external mode time step in seconds %f\n',min(Mobj.ts));
% smooth bathymetry with 4 iterations of explicit smoother
plot_field(Mobj,Mobj.h,'title','original bathymetry')
Mobj = setup_metrics(Mobj);
[Mobj.h] = smoothfield(Mobj.h,Mobj,0.5,4);
Mobj.h = smoothfield(Mobj.h,Mobj,0.5,4);
plot_field(Mobj,Mobj.h,'title','smoothed bathymetry');
% setup spatially variable bottom roughness and dump to file
hc = nodes2elems(Mobj.h,Mobj);
z0 = .008*ones(Mobj.nElems,1);
deep = find(hc > 5.);
z0(deep) = .004;
clear hc;
write_FVCOM_z0(z0,'tst_z0.nc','z0 test 1')
plot_field(Mobj,elems2nodes(z0,Mobj),'title','bottom roughness')
hc = nodes2elems(Mobj.h,Mobj);
z0 = .008*ones(Mobj.nElems,1);
deep = find(hc > 5.);
z0(deep) = .004;
clear hc
write_FVCOM_z0(z0,'tst_z0.nc','z0 test 1')
plot_field(Mobj,elems2nodes(z0,Mobj),'title','bottom roughness')
% add a river to the domain
%[Mobj] = add_river_nodes_graphic(Mobj,'tstRiver');
[Mobj] = add_river_nodes_list(Mobj,[838,844,845],'tstRiver');
Mobj = add_river_nodes_list(Mobj,[838,844,845],'tstRiver');
% add an open boundary to the Mesh
[Mobj] = add_obc_nodes_list(Mobj,[1:25],'OpenOcean',1);
Mobj = add_obc_nodes_list(Mobj,[1:25],'OpenOcean',1);
% [Mobj] = add_obc_nodes_graphic(Mobj,'OpenOcean2',1);
% add two sponge layers to the Mesh
......@@ -77,9 +79,9 @@ plot_field(Mobj,Mobj.h,'title','domain','withextra',true,'showgrid',true);
%------------------------------------------------------------------------------
% dump input files for FVCOM 3.x
%------------------------------------------------------------------------------
%-----------------------------------------------------------------------------
% dump input files for FVCOM 3.x and greater
%-----------------------------------------------------------------------------
% add river forcing
example_FVCOM_river()
......@@ -101,8 +103,9 @@ write_FVCOM_bath(Mobj,'tst_dep.dat')
% % dump open boundary node list
write_FVCOM_obc(Mobj,'tst_obc.dat')
% dump a Temp/Salinity open boundary forcing file
example_FVCOM_tsobc()
% dump a Temp/Salinity open boundary forcing file for 10 days at hourly
% resolution for a 10 layer model.
example_FVCOM_tsobc('tst', 50000:1/24:50010, 10)
% dump sponge layer file
write_FVCOM_sponge(Mobj,'tst_spg.dat');
......@@ -116,5 +119,3 @@ plot_field(Mobj,bedflag); title('bedflag');
% dump Coriolis file
write_FVCOM_cor(Mobj,'tst_cor.dat')
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