Changeset 2269


Ignore:
Timestamp:
09/22/09 09:50:19 (15 years ago)
Author:
seroussi
Message:

added new capabilities in extrude

File:
1 edited

Legend:

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

    r2252 r2269  
    1 function md=extrude(md,numlayers,extrusionexponent)
     1function md=extrude(md,varargin)
    22%EXTRUDE - vertically extrude a 2d mesh
    33%
    4 %   vertically extrude a 2d mesh and create corresponding 3d mesh following the extrusionexponent,
    5 %   the vertical distribution follows a polynomial law:');
    6 %     extrusionexponent>1    refinement at the base');
    7 %   0<extrusionexponent<1    refinement at the surface');
    8 %     extrusionexponent=1    linear extrusion');
     4%   vertically extrude a 2d mesh and create corresponding 3d mesh.
     5%   The vertical distribution can:
     6%    - follow a polynomial law
     7%    - follow two polynomial laws, one for the lower part and one for the upper part of the mesh
     8%    - be discribed by a list of coefficients (between 0 and 1)
     9%   
    910%
    1011%   Usage:
    1112%      md=extrude(md,numlayers,extrusionexponent);
     13%      md=extrude(md,numlayers,lowerexponent,upperexponent);
     14%      md=extrude(md,listofcoefficients);
    1215%
    1316%   Example:
    1417%      md=extrude(md,8,3);
     18%      md=extrude(md,8,3,2);
     19%      md=extrude(md,[0 0.2 0.5 0.7 0.9 0.95 1]);
    1520%
    1621%   See also: MODELEXTRACT, COLLAPSE
    1722
    1823%some checks on list of arguments
    19 if ((nargin~=3) | (nargout~=1)),
     24if ((nargin>4) | (nargin<2) | (nargout~=1)),
    2025        help extrude;
    2126        error('extrude error message');
     
    3136end
    3237
     38%Extrude the mesh
     39if nargin==2, %list of coefficients
     40        list=varargin{1};
     41        if any(list<0) | any(list>1),
     42                error('extrusioncoefficients must be between 0 and 1');
     43        end
     44        extrusionlist=sort(unique([list(:);0;1]));
     45        numlayers=length(extrusionlist);
     46elseif nargin==3, %one polynomial law
     47        if varargin{2}<=0,
     48                help extrude;
     49                error('extrusionexponent must be >=0');
     50        end
     51        numlayers=varargin{1};
     52        extrusionlist=((0:1:numlayers-1)/(numlayers-1)).^varargin{2};
     53elseif nargin==4, %two polynomial laws
     54        numlayers=varargin{1};
     55        lowerexp=varargin{2};
     56        upperexp=varargin{3};
     57
     58        if varargin{2}<=0 | varargin{3}<=0,
     59                help extrude;
     60                error('lower and upper extrusionexponents must be >=0');
     61        end
     62
     63        lowerextrusionlist=[(0:2/(numlayers-1):1).^lowerexp]/2;
     64        upperextrusionlist=[(0:2/(numlayers-1):1).^upperexp]/2;
     65        extrusionlist=sort(unique([lowerextrusionlist 1-upperextrusionlist]));
     66
     67end
     68
    3369if numlayers<2,
    3470        disp('number of layers should be at least 2. returning initial model...');
     
    3672end
    3773
    38 if extrusionexponent<=0,
    39         help extrude;
    40         error('extrusionexponent must be >=0');
    41 end
    42 
    43 %Extrude the mesh
    4474%Initialize with the 2d mesh
    45 x3d=md.x;
    46 y3d=md.y;
    47 z3d=md.bed;  %the lower grid is on the bed
     75x3d=[];
     76y3d=[];
     77z3d=[];  %the lower grid is on the bed
    4878thickness3d=md.thickness; %thickness and bed for these grids
    4979bed3d=md.bed;
    5080
    5181%Create the new layers
    52 for i=1:numlayers-1,
     82for i=1:numlayers,
    5383        x3d=[x3d; md.x];
    5484        y3d=[y3d; md.y];
    5585        %grids are distributed between bed and surface accordingly to the given exponent
    56         z3d=[z3d; bed3d+thickness3d*(i/(numlayers-1))^extrusionexponent];
     86        z3d=[z3d; bed3d+thickness3d*extrusionlist(i)];
    5787end
    5888number_grids3d=size(x3d,1); %number of 3d grids for the non extruded part of the mesh
Note: See TracChangeset for help on using the changeset viewer.