source: issm/trunk-jpl/src/m/parameterization/setmask.m@ 17433

Last change on this file since 17433 was 17433, checked in by seroussi, 11 years ago

BUG: fixed setmask in matlab

File size: 2.5 KB
Line 
1function md=setmask(md,floatingicename,groundedicename,varargin)
2%SETMASK - establish boundaries between grounded and floating ice.
3%
4% By default, ice is considered grounded. The contour floatingicename defines nodes
5% for which ice is floating. The contour groundedicename defines nodes inside an floatingice,
6% that are grounded (ie: ice rises, islands, etc ...)
7% All input files are in the Argus format (extension .exp).
8%
9% Usage:
10% md=setmask(md,floatingicename,groundedicename)
11%
12% Examples:
13% md=setmask(md,'all','');
14% md=setmask(md,'Iceshelves.exp','Islands.exp');
15
16%some checks on list of arguments
17if ((mod(nargin,2)==0) | (nargout~=1)),
18 help mask
19 error('mask error message');
20end
21
22if(nargin>3)
23 if(varargin(1)=='icedomain'),
24 icedomainname=varargin(2);
25 else
26 error('mask error message: wrong field specified. Only icedomain allowed for now.');
27 end
28 if ~exist(icedomainname),
29 error(['setmask error message: file ' icedomainname ' not found!']);
30 end
31end
32
33%Get assigned fields
34x=md.mesh.x;
35y=md.mesh.y;
36elements=md.mesh.elements;
37
38%Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{
39elementonfloatingice=FlagElements(md,floatingicename);
40elementongroundedice=FlagElements(md,groundedicename);
41
42%Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous
43%arrays come from domain outlines that can intersect one another:
44elementonfloatingice=double((elementonfloatingice & ~elementongroundedice));
45elementongroundedice=double(~elementonfloatingice);
46
47%the order here is important. we choose vertexongroundedice as default on the grounding line.
48vertexonfloatingice=zeros(md.mesh.numberofvertices,1);
49vertexongroundedice=zeros(md.mesh.numberofvertices,1);
50vertexongroundedice(md.mesh.elements(find(elementongroundedice),:))=1;
51vertexonfloatingice(find(~vertexongroundedice))=1;
52%}}}
53
54%level sets
55md.mask.groundedice_levelset=vertexongroundedice;
56md.mask.groundedice_levelset(find(vertexongroundedice==0.))=-1.;
57
58if(nargin>3)
59 if(varargin(1)=='icedomain')
60 md.mask.ice_levelset = 1.*ones(md.mesh.numberofvertices,1);
61 %use contourtomesh to set ice values inside ice domain
62 [vertexinsideicedomain,elementinsideicedomain]=ContourToMesh(elements,x,y,icedomainname,'node',1);
63 pos=find(vertexinsideicedomain==1.);
64 md.mask.ice_levelset(pos) = -1.;
65 end
66else
67 md.mask.ice_levelset = -1.*ones(md.mesh.numberofvertices,1);
68end
69
70
Note: See TracBrowser for help on using the repository browser.