


Add a set of sponge nodes comprising a single sponge layer to Mesh structure
[Mobj] = add_sponge_nodes(Mobj)
DESCRIPTION:
Add the sponge parameters at the given nodes.
INPUT
Mobj = Matlab mesh object
SpongeList = List of nodes to which to create a Sponge Layer
SpongeName = Name of the Sponge Layer
SpongeRadius = Radius of influence of the Sponge Layer
SpongeCoeff = Sponge damping coefficient
plotFig = [optional] show a figure of the mesh (1 = yes)
OUTPUT:
Mobj = Matlab mesh object with an additional sponge nodelist
EXAMPLE USAGE
Mobj = add_sponge_nodes(Mobj,'Sponge1',10000,.0001)
Author(s):
Geoff Cowles (University of Massachusetts Dartmouth)
Pierre Cazenave (Plymouth Marine Laboratory)
Karen Thurston (National Oceanography Centre, Liverpool)
Revision history
Modifed from add_sponge_nodes to read in nodes from a supplied list.
2012-11-26 Add ability to turn off the figures.
2013-01-18 Added support for variable sponge radius
==============================================================================

0001 function [Mobj] = add_sponge_nodes_list(Mobj,SpongeList,SpongeName,SpongeRadius,SpongeCoeff,plotFig) 0002 0003 % Add a set of sponge nodes comprising a single sponge layer to Mesh structure 0004 % 0005 % [Mobj] = add_sponge_nodes(Mobj) 0006 % 0007 % DESCRIPTION: 0008 % Add the sponge parameters at the given nodes. 0009 % 0010 % INPUT 0011 % Mobj = Matlab mesh object 0012 % SpongeList = List of nodes to which to create a Sponge Layer 0013 % SpongeName = Name of the Sponge Layer 0014 % SpongeRadius = Radius of influence of the Sponge Layer 0015 % SpongeCoeff = Sponge damping coefficient 0016 % plotFig = [optional] show a figure of the mesh (1 = yes) 0017 % 0018 % OUTPUT: 0019 % Mobj = Matlab mesh object with an additional sponge nodelist 0020 % 0021 % EXAMPLE USAGE 0022 % Mobj = add_sponge_nodes(Mobj,'Sponge1',10000,.0001) 0023 % 0024 % Author(s): 0025 % Geoff Cowles (University of Massachusetts Dartmouth) 0026 % Pierre Cazenave (Plymouth Marine Laboratory) 0027 % Karen Thurston (National Oceanography Centre, Liverpool) 0028 % 0029 % Revision history 0030 % Modifed from add_sponge_nodes to read in nodes from a supplied list. 0031 % 2012-11-26 Add ability to turn off the figures. 0032 % 2013-01-18 Added support for variable sponge radius 0033 % 0034 %============================================================================== 0035 [~, subname] = fileparts(mfilename('fullpath')); 0036 0037 global ftbverbose 0038 if ftbverbose 0039 fprintf('\nbegin : %s\n', subname) 0040 end 0041 0042 % Do we want a figure showing how we're getting along? 0043 if nargin == 5 0044 plotFig = 0; 0045 end 0046 0047 %------------------------------------------------------------------------------ 0048 % Plot the mesh 0049 %------------------------------------------------------------------------------ 0050 0051 if plotFig == 1 0052 if lower(Mobj.nativeCoords(1:3)) == 'car' 0053 x = Mobj.x; 0054 y = Mobj.y; 0055 else 0056 x = Mobj.lon; 0057 y = Mobj.lat; 0058 end 0059 0060 figure 0061 patch('Vertices', [x, y], 'Faces', Mobj.tri, ... 0062 'Cdata', Mobj.h, 'edgecolor', 'k', 'facecolor', 'interp'); 0063 hold on 0064 plot(x(SpongeList), y(SpongeList), 'wx') 0065 axis('equal', 'tight') 0066 end 0067 0068 npts = length(SpongeList); 0069 0070 if npts == 0 0071 fprintf('No points in given list') 0072 fprintf('end : %s\n', subname) 0073 return 0074 end 0075 0076 if ftbverbose 0077 fprintf('%d points provided\n', npts) 0078 end 0079 0080 % add to mesh object 0081 Mobj.nSponge = Mobj.nSponge + 1; 0082 Mobj.nSpongeNodes(Mobj.nSponge) = npts; 0083 Mobj.sponge_nodes(Mobj.nSponge, 1:npts) = SpongeList; 0084 Mobj.sponge_name{Mobj.nSponge} = SpongeName; 0085 Mobj.sponge_fac(Mobj.nSponge) = SpongeCoeff; 0086 0087 if numel(unique(SpongeRadius)) == 1 % if you have a constant sponge radius 0088 Mobj.sponge_rad(Mobj.nSponge) = SpongeRadius; 0089 else % if you have a variable sponge radius 0090 Mobj.sponge_rad(Mobj.nSponge, 1:npts) = SpongeRadius; 0091 end 0092 0093 if ftbverbose 0094 fprintf('end : %s\n', subname) 0095 end 0096