Ignore:
Timestamp:
02/08/10 14:12:12 (15 years ago)
Author:
seroussi
Message:

added possibility to use a vector to specify land (instead of an expfile) in geography2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/public/geography2.m

    r1758 r2986  
    11function md=geography2(md,landname,iceshelfname,icesheetname)
     2%GEOGRAPHY2 - establish land, ice sheet and ice shelf areas in a domains.
     3%
     4%   Usage:
     5%      md=geography2(md,landname,iceshelfname,icesheetname)
     6%
     7%   Examples:
     8%      md=geography2(md,'LandName.exp','Iceshelves.exp','Islands.exp');
    29
    310%Get assigned fields
     
    714
    815%recover elements and grids on land.
    9 [gridonland,elementonland]=ContourToMesh(elements,x,y,expread(landname,1),'element and node',2);
     16if ischar(landname),
     17        [gridonland,elementonland]=ContourToMesh(elements,x,y,expread(landname,1),'element and node',2);
     18elseif isfloat(landname),
     19        if size(landname,1)~=md.numberofelements,
     20                error('Landname for area must be of same size as number of elements in model');
     21        end
     22        elementonland=landname;
     23        gridonland=zeros(md.numberofgrids,1);
     24        gridonland(md.elements(find(elementonland),:))=1;
     25else
     26        error('Invalid area option option');
     27end
    1028
    1129%any element with 3 grids on land should be on land:
     
    4260
    4361%recover arrays of ice shelf grids and elements, and ice sheet grids and elements.
    44 if strcmp(iceshelfname,''), %no iceshelf contour file, we are dealing with a pure ice sheet.
    45         gridoniceshelf=zeros(md.numberofgrids,1);
    46         elementoniceshelf=zeros(md.numberofelements,1);
    47 elseif strcmp(iceshelfname,'all'), %we are dealing with a pure ice shelf.
    48         gridoniceshelf=ones(md.numberofgrids,1);
    49         elementoniceshelf=ones(md.numberofelements,1);
    50 else
    51         [gridoniceshelf,elementoniceshelf]=ContourToMesh(elements,x,y,expread(iceshelfname,1),'element and node',2);
    52 end
     62elementoniceshelf=FlagElements(md,iceshelfname);
     63elementonicesheet=FlagElements(md,icesheetname);
    5364
    54 if strcmp(icesheetname,''), %no icesheet contour file, we are dealing with a pure ice shelf.
    55         gridonicesheet=zeros(md.numberofgrids,1);
    56         elementonicesheet=zeros(md.numberofelements,1);
    57 else
    58         [gridonicesheet,elementonicesheet]=ContourToMesh(elements,x,y,expread(icesheetname,1),'element and node',2);
    59 end
    60 
     65%Because icesheet grids and elements can be included into an iceshelf, we need to update. Remember, all the previous
     66%arrays come from domain outlines that can intersect one another:
     67gridoniceshelf=zeros(md.numberofgrids,1);
     68gridonicesheet=zeros(md.numberofgrids,1);
     69elementoniceshelf=double((elementoniceshelf & ~elementonicesheet));
     70elementonicesheet=double(~elementoniceshelf);
     71gridoniceshelf(md.elements(find(elementoniceshelf),:))=1;
     72gridonicesheet(md.elements(find(elementonicesheet),:))=1;
    6173
    6274%now correct, so that none of the iceshelf and icesheet elements and nodes are in the water.
Note: See TracChangeset for help on using the changeset viewer.