Home > fvcom_prepro > add_sponge_nodes_list.m

add_sponge_nodes_list

PURPOSE ^

Add a set of sponge nodes comprising a single sponge layer to Mesh structure

SYNOPSIS ^

function [Mobj] = add_sponge_nodes_list(Mobj,SpongeList,SpongeName,SpongeRadius,SpongeCoeff,plotFig)

DESCRIPTION ^

 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
    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
   
==============================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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 %    Select using ginput the set of nodes comprising a sponge layer
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 = 'add_sponge_nodes';
0036 
0037 global ftbverbose
0038 if(ftbverbose)
0039     fprintf('\n')
0040     fprintf(['begin : ' subname '\n'])
0041 end
0042 
0043 % Do we want a figure showing how we're getting along?
0044 if nargin == 5
0045     plotFig = 0;
0046 end
0047 
0048 %------------------------------------------------------------------------------
0049 % Plot the mesh
0050 %------------------------------------------------------------------------------
0051 
0052 if plotFig == 1
0053     if(lower(Mobj.nativeCoords(1:3)) == 'car')
0054         x = Mobj.x;
0055         y = Mobj.y;
0056     else
0057         x = Mobj.lon;
0058         y = Mobj.lat;
0059     end
0060 
0061     figure
0062     patch('Vertices',[x,y],'Faces',Mobj.tri,...
0063             'Cdata',Mobj.h,'edgecolor','k','facecolor','interp');
0064     hold on;
0065     plot(x(SpongeList),y(SpongeList),'wx')
0066     axis('equal','tight')
0067 end
0068 
0069 npts = length(SpongeList);
0070 
0071 if(npts == 0)
0072     fprintf('No points in given list')
0073     fprintf(['end   : ' subname '\n'])
0074     return
0075 end
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   : ' subname '\n'])
0095 end
0096

Generated on Mon 07-Dec-2015 09:59:26 by m2html © 2005