Ignore:
Timestamp:
05/16/11 15:01:42 (14 years ago)
Author:
seroussi
Message:

changed grid to node in matlab

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/model/averaging.m

    r3994 r8298  
    22%AVERAGING - smooths the input over the mesh
    33%
    4 %   This routine takes a list over the elements or the grids in input
    5 %   and return a list over the grids.
     4%   This routine takes a list over the elements or the nodes in input
     5%   and return a list over the nodes.
    66%   For each iterations it computes the average over each element (average
    7 %   of the vertices values) and then computes the average over each grid
    8 %   by taking the average of the element around a grid weighted by the
     7%   of the vertices values) and then computes the average over each node
     8%   by taking the average of the element around a node weighted by the
    99%   elements volume
    1010%
     
    1616%      pressure=averaging(md,md.pressure,0);
    1717
    18 if length(data)~=md.numberofelements & length(data)~=md.numberofgrids
     18if length(data)~=md.numberofelements & length(data)~=md.numberofnodes
    1919        error('averaging error message: data not supported yet');
    2020end
    2121
    2222%initialization
    23 weights=zeros(md.numberofgrids,1);
     23weights=zeros(md.numberofnodes,1);
    2424data=data(:);
    2525
    2626%load some variables (it is much faster if the variab;es are loaded from md once for all)
    2727index=md.elements;
    28 numberofgrids=md.numberofgrids;
     28numberofnodes=md.numberofnodes;
    2929numberofelements=md.numberofelements;
    3030
     
    4141linesize=rep*numberofelements;
    4242
    43 %update weights that holds the volume of all the element holding the grid i
    44 weights=sparse(line,ones(linesize,1),repmat(areas,rep,1),numberofgrids,1);
     43%update weights that holds the volume of all the element holding the node i
     44weights=sparse(line,ones(linesize,1),repmat(areas,rep,1),numberofnodes,1);
    4545
    4646%initialization
    4747if length(data)==numberofelements
    48         average_grid=sparse(line,ones(linesize,1),repmat(areas.*data,rep,1),numberofgrids,1);
    49         average_grid=average_grid./weights;
     48        average_node=sparse(line,ones(linesize,1),repmat(areas.*data,rep,1),numberofnodes,1);
     49        average_node=average_node./weights;
    5050else
    51         average_grid=data;
     51        average_node=data;
    5252end
    5353
    5454%loop over iteration
    5555for i=1:iterations
    56         average_el=average_grid(index)*summation;
    57         average_grid=sparse(line,ones(linesize,1),repmat(areas.*average_el,rep,1),numberofgrids,1);
    58         average_grid=average_grid./weights;
     56        average_el=average_node(index)*summation;
     57        average_node=sparse(line,ones(linesize,1),repmat(areas.*average_el,rep,1),numberofnodes,1);
     58        average_node=average_node./weights;
    5959end
    6060
    6161%return output as a full matrix (C code do not like sparse matrices)
    62 average=full(average_grid);
     62average=full(average_node);
Note: See TracChangeset for help on using the changeset viewer.