1 | function 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
|
---|
17 | if ((mod(nargin,2)==0) | (nargout~=1)),
|
---|
18 | help mask
|
---|
19 | error('mask error message');
|
---|
20 | end
|
---|
21 |
|
---|
22 | if(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
|
---|
31 | end
|
---|
32 |
|
---|
33 | %Get assigned fields
|
---|
34 | x=md.mesh.x;
|
---|
35 | y=md.mesh.y;
|
---|
36 | elements=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. {{{
|
---|
39 | elementonfloatingice=FlagElements(md,floatingicename);
|
---|
40 | elementongroundedice=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:
|
---|
44 | elementonfloatingice=double((elementonfloatingice & ~elementongroundedice));
|
---|
45 | elementongroundedice=double(~elementonfloatingice);
|
---|
46 |
|
---|
47 | %the order here is important. we choose vertexongroundedice as default on the grounding line.
|
---|
48 | vertexonfloatingice=zeros(md.mesh.numberofvertices,1);
|
---|
49 | vertexongroundedice=zeros(md.mesh.numberofvertices,1);
|
---|
50 | vertexongroundedice(md.mesh.elements(find(elementongroundedice),:))=1;
|
---|
51 | vertexonfloatingice(find(~vertexongroundedice))=1;
|
---|
52 | %}}}
|
---|
53 |
|
---|
54 | %level sets
|
---|
55 | md.mask.groundedice_levelset=vertexongroundedice;
|
---|
56 | md.mask.groundedice_levelset(find(vertexongroundedice==0.))=-1.;
|
---|
57 |
|
---|
58 | if(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
|
---|
66 | else
|
---|
67 | md.mask.ice_levelset = -1.*ones(md.mesh.numberofvertices,1);
|
---|
68 | end
|
---|
69 |
|
---|
70 |
|
---|