source: issm/trunk-jpl/src/m/plot/plot_tensor_principalaxis.m

Last change on this file was 19336, checked in by Mathieu Morlighem, 10 years ago

BUG: removed strsplit since it is conflicting with matlab's since 2013

File size: 2.8 KB
Line 
1function plot_tensor_principalaxis(md,options,width,i,tensor,type,plot_options)
2%PLOT_TENSOR_PRINCIPALAXIS - plot ytensor principal axis
3%
4% Usage:
5% plot_tensor_principalaxis(md,options,width,i);
6%
7% See also: PLOTMODEL
8
9%prepare subplot
10subplot(width,width,i);
11
12%process data and model
13[x y z elements is2d isplanet]=processmesh(md,[],options);
14
15if dimension(md.mesh)==2,
16 eval(['Vx=tensor.principalaxis' type(end) '(:,1); Vy=tensor.principalaxis' type(end) '(:,2);'])
17 eval(['value=tensor.principalvalue' type(end) ';']);
18 [Vx datatype]=processdata(md,Vx,options);
19 [Vy datatype]=processdata(md,Vy,options);
20 [value datatype]=processdata(md,value,options);
21else
22 eval(['Vx=tensor.principalaxis' type(end) '(:,1); Vy=tensor.principalaxis' type(end) '(:,2); Vz=tensor.principalaxis' type(end) '(:,3);'])
23 [Vx datatype]=processdata(md,Vx,options);
24 [Vy datatype]=processdata(md,Vy,options);
25 [Vz datatype]=processdata(md,Vz,options);
26 [value datatype]=processdata(md,value,options);
27end
28
29%take the center of each element if ~isonnode
30if datatype==1,
31 x=mean(x(elements'))'; y=mean(y(elements'))'; z=mean(z(elements'))';
32end
33
34%plot quivers
35if dimension(md.mesh)==2,
36
37 %density
38 if exist(options,'density')
39 density=getfieldvalue(options,'density');
40 x=x(1:density:end);
41 y=y(1:density:end);
42 Vx=Vx(1:density:end);
43 Vy=Vy(1:density:end);
44 value=value(1:density:end);
45 end
46
47 %scaling:
48 delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x);
49 scale=0.5/max(sqrt((Vx.^2+Vy.^2)/delta));
50 Vx=scale*Vx; Vy=scale*Vy;
51
52 pos=find(value>=0);
53 q1=quiver(x(pos),y(pos),Vx(pos),Vy(pos),'Color','r','ShowArrowHead','off','AutoScale','off');
54 hold on
55 pos=find(value<0);
56 q2=quiver(x(pos),y(pos),Vx(pos),Vy(pos),'Color','b','ShowArrowHead','off','AutoScale','off');
57
58else
59 %density
60 if exist(options,'density')
61 density=getfieldvalue(options,'density');
62 x=x(1:density:end);
63 y=y(1:density:end);
64 z=z(1:density:end);
65 Vx=Vx(1:density:end);
66 Vy=Vy(1:density:end);
67 Vz=Vz(1:density:end);
68 value=value(1:density:end);
69 end
70
71 %scaling:
72 delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x);
73 scale=0.5/max(sqrt((Vx.^2+Vy.^2)/delta));
74 Vx=scale*Vx; Vy=scale*Vy; Vz=scale*Vz;
75
76 pos=find(value>=0);
77 q1=quiver3(x(pos),y(pos),z(pos),Vx(pos),Vy(pos),Vz(pos),'Color','r','ShowArrowHead','off','AutoScale','off');
78 hold on
79 pos=find(value<0);
80 q2=quiver3(x(pos),y(pos),z(pos),Vx(pos),Vy(pos),Vz(pos),'Color','b','ShowArrowHead','off','AutoScale','off');
81end
82
83%legend
84if strcmpi(type(1:6),'strain')
85 legend([q1 q2],'extension','compression')
86elseif strcmpi(type(1:6),'stress')
87 legend([q1 q2],'compression','traction')
88end
89
90%apply options
91strings=strsplit_strict(type,'_');
92string=strings{1};
93options=addfielddefault(options,'title',[upper(string(1)) string(2:end) ' principal axis ' type(end)]);
94options=addfielddefault(options,'colorbar',0);
95applyoptions(md,[],options);
Note: See TracBrowser for help on using the repository browser.