


Calculates the distance from coast along the open boundary nodes
Mobj=distance_along_BC(Mobj,BCnodes,conf)
DESCRIPTION:
Calculates distance from coast along open boundary nodes and
store them in a matlab mesh object
INPUT
Mobj = Mesh object structure variable
BCnodes = indices of nodes located at the boundary
conf = configuration structure variable with the
directory where the HJB_Solver_Package is installed
OUTPUT:
Mobj = matlab structure containing distance data
EXAMPLE USAGE
Mobj=distance_along_BC(Mobj,BCnodes,conf)
This function needs the HJB_solver package by Shawn Walker and can be downloaded from Matlab central
http://www.mathworks.com/matlabcentral/fileexchange/24827-hamilton-jacobi-solver-on-unstructured-triangular-grids

0001 function Mobj=distance_along_BC(Mobj,BCnodes,conf) 0002 % Calculates the distance from coast along the open boundary nodes 0003 % 0004 % Mobj=distance_along_BC(Mobj,BCnodes,conf) 0005 % 0006 % DESCRIPTION: 0007 % Calculates distance from coast along open boundary nodes and 0008 % store them in a matlab mesh object 0009 % 0010 % INPUT 0011 % Mobj = Mesh object structure variable 0012 % BCnodes = indices of nodes located at the boundary 0013 % conf = configuration structure variable with the 0014 % directory where the HJB_Solver_Package is installed 0015 % 0016 % OUTPUT: 0017 % Mobj = matlab structure containing distance data 0018 % 0019 % EXAMPLE USAGE 0020 % Mobj=distance_along_BC(Mobj,BCnodes,conf) 0021 % This function needs the HJB_solver package by Shawn Walker and can be downloaded from Matlab central 0022 % http://www.mathworks.com/matlabcentral/fileexchange/24827-hamilton-jacobi-solver-on-unstructured-triangular-grids 0023 0024 % Author(s): 0025 % Ricardo Torres (Plymouth Marine Laboratory) 0026 % 0027 % Revision history 0028 % 0029 % 2015-11-20 First version 0030 % 0031 %============================================================================== 0032 0033 dump = dbstack; 0034 subname = dump.name; 0035 clear dump 0036 global ftbverbose; 0037 if ftbverbose 0038 fprintf('\nbegin : %s \n', subname) 0039 end 0040 CD=pwd; 0041 % setup HPJ solver to calculate the distance function for the SMS mesh 0042 [~,~,~,bnd] = connectivity([Mobj.x,Mobj.y],Mobj.tri); 0043 % remove nodestring from coast. 0044 % BCnodes=[Mobj.read_obc_nodes{:}]; 0045 coast_ind=(BCnodes); 0046 0047 0048 % % calculate distance function 0049 myParam.Max_Tri_per_Star = 20; 0050 myParam.NumGaussSeidel = 40; 0051 myParam.INF_VAL = 1000000; 0052 myParam.TOL = 1e-12; 0053 % in this case, we will assume the standard Euclidean metric 0054 myMetric = []; 0055 myTM.Vtx=[Mobj.x(:),Mobj.y(:)]; 0056 myTM.DoFmap=[Mobj.tri]; 0057 myTM.NegMask=false(size(bnd)); 0058 myBdy.Nodes=coast_ind(:); 0059 myBdy.Data=zeros(size(myBdy.Nodes)); 0060 % 0061 cd (conf.HJB_Solver_Package) 0062 % 0063 % 0064 SEmex = SolveEikonalmex(myTM,myBdy,myParam,myMetric); 0065 tic 0066 Mobj.distOB = SEmex.Compute_Soln; 0067 cd(CD) 0068 if ftbverbose 0069 fprintf('end : %s \n', subname) 0070 end 0071 return