[17432] | 1 | function md=setmask(md,floatingicename,groundedicename,varargin)
|
---|
[11234] | 2 | %SETMASK - establish boundaries between grounded and floating ice.
|
---|
[1] | 3 | %
|
---|
[9640] | 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,
|
---|
[1] | 6 | % that are grounded (ie: ice rises, islands, etc ...)
|
---|
| 7 | % All input files are in the Argus format (extension .exp).
|
---|
| 8 | %
|
---|
| 9 | % Usage:
|
---|
[9640] | 10 | % md=setmask(md,floatingicename,groundedicename)
|
---|
[1] | 11 | %
|
---|
| 12 | % Examples:
|
---|
[9640] | 13 | % md=setmask(md,'all','');
|
---|
| 14 | % md=setmask(md,'Iceshelves.exp','Islands.exp');
|
---|
[1] | 15 |
|
---|
| 16 | %some checks on list of arguments
|
---|
[17433] | 17 | if ((mod(nargin,2)==0) | (nargout~=1)),
|
---|
[9640] | 18 | help mask
|
---|
| 19 | error('mask error message');
|
---|
[1] | 20 | end
|
---|
| 21 |
|
---|
[17433] | 22 | if(nargin>3)
|
---|
| 23 | if(varargin(1)=='icedomain'),
|
---|
[17432] | 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 |
|
---|
[1] | 33 | %Get assigned fields
|
---|
[9734] | 34 | x=md.mesh.x;
|
---|
| 35 | y=md.mesh.y;
|
---|
[9733] | 36 | elements=md.mesh.elements;
|
---|
[1] | 37 |
|
---|
[12365] | 38 | %Assign elementonfloatingice, elementongroundedice, vertexongroundedice and vertexonfloatingice. Only change at your own peril! This is synchronized heavily with the GroundingLineMigration module. {{{
|
---|
[9640] | 39 | elementonfloatingice=FlagElements(md,floatingicename);
|
---|
| 40 | elementongroundedice=FlagElements(md,groundedicename);
|
---|
[1] | 41 |
|
---|
[9640] | 42 | %Because groundedice nodes and elements can be included into an floatingice, we need to update. Remember, all the previous
|
---|
[1] | 43 | %arrays come from domain outlines that can intersect one another:
|
---|
[9640] | 44 | elementonfloatingice=double((elementonfloatingice & ~elementongroundedice));
|
---|
| 45 | elementongroundedice=double(~elementonfloatingice);
|
---|
[7314] | 46 |
|
---|
[9640] | 47 | %the order here is important. we choose vertexongroundedice as default on the grounding line.
|
---|
[9725] | 48 | vertexonfloatingice=zeros(md.mesh.numberofvertices,1);
|
---|
| 49 | vertexongroundedice=zeros(md.mesh.numberofvertices,1);
|
---|
[9733] | 50 | vertexongroundedice(md.mesh.elements(find(elementongroundedice),:))=1;
|
---|
[9640] | 51 | vertexonfloatingice(find(~vertexongroundedice))=1;
|
---|
[7314] | 52 | %}}}
|
---|
| 53 |
|
---|
[15944] | 54 | %level sets
|
---|
[24861] | 55 | md.mask.ocean_levelset=vertexongroundedice;
|
---|
| 56 | md.mask.ocean_levelset(find(vertexongroundedice==0.))=-1.;
|
---|
[17432] | 57 |
|
---|
[17433] | 58 | if(nargin>3)
|
---|
| 59 | if(varargin(1)=='icedomain')
|
---|
[17432] | 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 |
|
---|