Changeset 8298 for issm/trunk/src/m/model/averaging.m
- Timestamp:
- 05/16/11 15:01:42 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/model/averaging.m
r3994 r8298 2 2 %AVERAGING - smooths the input over the mesh 3 3 % 4 % This routine takes a list over the elements or the grids in input5 % 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. 6 6 % For each iterations it computes the average over each element (average 7 % of the vertices values) and then computes the average over each grid8 % by taking the average of the element around a gridweighted by the7 % 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 9 9 % elements volume 10 10 % … … 16 16 % pressure=averaging(md,md.pressure,0); 17 17 18 if length(data)~=md.numberofelements & length(data)~=md.numberof grids18 if length(data)~=md.numberofelements & length(data)~=md.numberofnodes 19 19 error('averaging error message: data not supported yet'); 20 20 end 21 21 22 22 %initialization 23 weights=zeros(md.numberof grids,1);23 weights=zeros(md.numberofnodes,1); 24 24 data=data(:); 25 25 26 26 %load some variables (it is much faster if the variab;es are loaded from md once for all) 27 27 index=md.elements; 28 numberof grids=md.numberofgrids;28 numberofnodes=md.numberofnodes; 29 29 numberofelements=md.numberofelements; 30 30 … … 41 41 linesize=rep*numberofelements; 42 42 43 %update weights that holds the volume of all the element holding the gridi44 weights=sparse(line,ones(linesize,1),repmat(areas,rep,1),numberof grids,1);43 %update weights that holds the volume of all the element holding the node i 44 weights=sparse(line,ones(linesize,1),repmat(areas,rep,1),numberofnodes,1); 45 45 46 46 %initialization 47 47 if 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; 50 50 else 51 average_ grid=data;51 average_node=data; 52 52 end 53 53 54 54 %loop over iteration 55 55 for 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; 59 59 end 60 60 61 61 %return output as a full matrix (C code do not like sparse matrices) 62 average=full(average_ grid);62 average=full(average_node);
Note:
See TracChangeset
for help on using the changeset viewer.