


Add a set of sponge nodes comprising a single sponge layer to Mesh structure
[Mobj] = add_sponge_nodes(Mobj)
DESCRIPTION:
Select using ginput the set of nodes comprising a sponge layer
INPUT
Mobj = Matlab mesh object
SpongeName = Name of the Sponge Layer
SpongeRadius = Radius of influence of the Sponge Layer
SpongeCoeff = Sponge damping coefficient
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)
Note:
Uses ginput2 which allows zooming before selecting points and displays
clicked points realtime
Revision history
==============================================================================

0001 function [Mobj] = add_sponge_nodes(Mobj,SpongeName,SpongeRadius,SpongeCoeff) 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 % Select using ginput the set of nodes comprising a sponge layer 0009 % 0010 % INPUT 0011 % Mobj = Matlab mesh object 0012 % SpongeName = Name of the Sponge Layer 0013 % SpongeRadius = Radius of influence of the Sponge Layer 0014 % SpongeCoeff = Sponge damping coefficient 0015 % 0016 % OUTPUT: 0017 % Mobj = Matlab mesh object with an additional sponge nodelist 0018 % 0019 % EXAMPLE USAGE 0020 % Mobj = add_sponge_nodes(Mobj,'Sponge1',10000,.0001) 0021 % 0022 % Author(s): 0023 % Geoff Cowles (University of Massachusetts Dartmouth) 0024 % 0025 % Note: 0026 % Uses ginput2 which allows zooming before selecting points and displays 0027 % clicked points realtime 0028 % 0029 % Revision history 0030 % 0031 %============================================================================== 0032 subname = 'add_sponge_nodes'; 0033 fprintf('\n') 0034 fprintf(['begin : ' subname '\n']) 0035 0036 0037 %------------------------------------------------------------------------------ 0038 % Plot the mesh 0039 %------------------------------------------------------------------------------ 0040 0041 if(lower(Mobj.nativeCoords(1:3)) == 'car') 0042 x = Mobj.x; 0043 y = Mobj.y; 0044 else 0045 x = Mobj.lon; 0046 y = Mobj.lat; 0047 end; 0048 0049 figure 0050 patch('Vertices',[x,y],'Faces',Mobj.tri,... 0051 'Cdata',Mobj.h,'edgecolor','k','facecolor','interp'); 0052 axis('equal','tight') 0053 hold on; 0054 0055 % use ginput2 (which allows zooming and plots points as they are clicked) to let 0056 % user select the boundary points 0057 [xselect] = ginput2(true,'k+') 0058 0059 0060 npts = size(xselect,1); 0061 0062 if(npts == 0) 0063 fprintf('you didn''t select any points') 0064 fprintf(['end : ' subname '\n']) 0065 return 0066 end; 0067 fprintf('you selected %d points\n',npts) 0068 0069 % snap to the closest vertices 0070 for i=1:npts 0071 [ipt(i),dist] = find_nearest_pt(xselect(i,1),xselect(i,2),Mobj); 0072 end; 0073 0074 % replot domain with snapped vertices 0075 plot(x(ipt),y(ipt),'ro'); 0076 0077 % add to mesh object 0078 Mobj.nSponge = Mobj.nSponge + 1; 0079 Mobj.nSpongeNodes(Mobj.nSponge) = npts; 0080 Mobj.sponge_nodes(Mobj.nSponge,1:npts) = ipt; 0081 Mobj.sponge_name{Mobj.nSponge} = SpongeName; 0082 Mobj.sponge_rad(Mobj.nSponge) = SpongeRadius; 0083 Mobj.sponge_fac(Mobj.nSponge) = SpongeCoeff; 0084 0085 0086 fprintf(['end : ' subname '\n']) 0087