add_sponge_nodes.html 8 KB
Newer Older
Geoffrey Cowles's avatar
Geoffrey Cowles committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of add_sponge_nodes</title>
  <meta name="keywords" content="add_sponge_nodes">
  <meta name="description" content="Add a set of sponge nodes comprising a single sponge layer to Mesh structure">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">fvcom_prepro</a> &gt; add_sponge_nodes.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for fvcom_prepro&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>add_sponge_nodes
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Add a set of sponge nodes comprising a single sponge layer to Mesh structure</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [Mobj]  = add_sponge_nodes(Mobj,SpongeName,SpongeRadius,SpongeCoeff) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> 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
   
==============================================================================</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="find_nearest_pt.html" class="code" title="function [Point,Distance] = find_nearest_pt(xloc,yloc,Mobj)">find_nearest_pt</a>	Find nearest point in Mesh structure to (x,y)</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [Mobj]  = add_sponge_nodes(Mobj,SpongeName,SpongeRadius,SpongeCoeff)</a>
0002 
0003 <span class="comment">% Add a set of sponge nodes comprising a single sponge layer to Mesh structure</span>
0004 <span class="comment">%</span>
0005 <span class="comment">% [Mobj] = add_sponge_nodes(Mobj)</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% DESCRIPTION:</span>
0008 <span class="comment">%    Select using ginput the set of nodes comprising a sponge layer</span>
0009 <span class="comment">%</span>
0010 <span class="comment">% INPUT</span>
0011 <span class="comment">%    Mobj = Matlab mesh object</span>
0012 <span class="comment">%    SpongeName = Name of the Sponge Layer</span>
0013 <span class="comment">%    SpongeRadius = Radius of influence of the Sponge Layer</span>
0014 <span class="comment">%    SpongeCoeff  = Sponge damping coefficient</span>
0015 <span class="comment">%</span>
0016 <span class="comment">% OUTPUT:</span>
0017 <span class="comment">%    Mobj = Matlab mesh object with an additional sponge nodelist</span>
0018 <span class="comment">%</span>
0019 <span class="comment">% EXAMPLE USAGE</span>
0020 <span class="comment">%    Mobj = add_sponge_nodes(Mobj,'Sponge1',10000,.0001)</span>
0021 <span class="comment">%</span>
0022 <span class="comment">% Author(s):</span>
0023 <span class="comment">%    Geoff Cowles (University of Massachusetts Dartmouth)</span>
0024 <span class="comment">%</span>
0025 <span class="comment">% Note:</span>
0026 <span class="comment">%    Uses ginput2 which allows zooming before selecting points and displays</span>
0027 <span class="comment">%    clicked points realtime</span>
0028 <span class="comment">%</span>
0029 <span class="comment">% Revision history</span>
0030 <span class="comment">%</span>
0031 <span class="comment">%==============================================================================</span>
0032 subname = <span class="string">'add_sponge_nodes'</span>;
0033 fprintf(<span class="string">'\n'</span>)
0034 fprintf([<span class="string">'begin : '</span> subname <span class="string">'\n'</span>])
0035 
0036 
0037 <span class="comment">%------------------------------------------------------------------------------</span>
0038 <span class="comment">% Plot the mesh</span>
0039 <span class="comment">%------------------------------------------------------------------------------</span>
0040 
0041 <span class="keyword">if</span>(lower(Mobj.nativeCoords(1:3)) == <span class="string">'car'</span>)
0042     x = Mobj.x;
0043     y = Mobj.y;
0044 <span class="keyword">else</span>
0045     x = Mobj.lon;
0046     y = Mobj.lat;
0047 <span class="keyword">end</span>;
0048 
0049 figure
0050 patch(<span class="string">'Vertices'</span>,[x,y],<span class="string">'Faces'</span>,Mobj.tri,<span class="keyword">...</span>
0051         <span class="string">'Cdata'</span>,Mobj.h,<span class="string">'edgecolor'</span>,<span class="string">'k'</span>,<span class="string">'facecolor'</span>,<span class="string">'interp'</span>);
0052 axis(<span class="string">'equal'</span>,<span class="string">'tight'</span>)
0053 hold on;
0054 
0055 <span class="comment">% use ginput2 (which allows zooming and plots points as they are clicked) to let</span>
0056 <span class="comment">% user select the boundary points</span>
0057 [xselect] = ginput2(true,<span class="string">'k+'</span>)
0058 
0059 
0060 npts = size(xselect,1);
0061 
0062 <span class="keyword">if</span>(npts == 0)
0063     fprintf(<span class="string">'you didn''t select any points'</span>)
0064     fprintf([<span class="string">'end   : '</span> subname <span class="string">'\n'</span>])
0065     <span class="keyword">return</span>
0066 <span class="keyword">end</span>;
0067 fprintf(<span class="string">'you selected %d points\n'</span>,npts)
0068 
0069 <span class="comment">% snap to the closest vertices</span>
0070 <span class="keyword">for</span> i=1:npts
0071     [ipt(i),dist] = <a href="find_nearest_pt.html" class="code" title="function [Point,Distance] = find_nearest_pt(xloc,yloc,Mobj)">find_nearest_pt</a>(xselect(i,1),xselect(i,2),Mobj);
0072 <span class="keyword">end</span>;
0073 
0074 <span class="comment">% replot domain with snapped vertices</span>
0075 plot(x(ipt),y(ipt),<span class="string">'ro'</span>);
0076 
0077 <span class="comment">% add to mesh object</span>
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([<span class="string">'end   : '</span> subname <span class="string">'\n'</span>])
0087</pre></div>
Pierre Cazenave's avatar
Pierre Cazenave committed
160
<hr><address>Generated on Wed 20-Feb-2019 16:06:01 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
Geoffrey Cowles's avatar
Geoffrey Cowles committed
161 162
</body>
</html>