| 1 | function plot_tensor_components(md,options,width,i,tensor,type,plot_options)
 | 
|---|
| 2 | %PLOT_TENSOR_COMPONENT - plot component of a tensor
 | 
|---|
| 3 | %
 | 
|---|
| 4 | %   Usage:
 | 
|---|
| 5 | %      plot_tensor_components(md,options,width,i,tensor,type,plot_option);
 | 
|---|
| 6 | %
 | 
|---|
| 7 | %   See also: PLOTMODEL, PLOT_UNIT, PLOT_MANAGER
 | 
|---|
| 8 | 
 | 
|---|
| 9 | %Compute the indexes of the components plots
 | 
|---|
| 10 | upperplots=fix((i-1)/width);
 | 
|---|
| 11 | if upperplots==0, leftplots=i-1; else leftplots=i-width*upperplots-1; end
 | 
|---|
| 12 | if (md.mesh.dimension==2)%3 components -> 3 indexes
 | 
|---|
| 13 |         index1=4*width*upperplots+2*leftplots+1;
 | 
|---|
| 14 |         index2=index1+1;
 | 
|---|
| 15 |         index3=index1+width*2;
 | 
|---|
| 16 | elseif md.mesh.dimension==3%6 components -> 6 indexes
 | 
|---|
| 17 |         index1=3*3*width*upperplots+3*leftplots+1;
 | 
|---|
| 18 |         index2=index1+1;
 | 
|---|
| 19 |         index3=index1+2;
 | 
|---|
| 20 |         index4=index1+width*3;
 | 
|---|
| 21 |         index5=index4+1;
 | 
|---|
| 22 |         index6=index4+2;
 | 
|---|
| 23 | end
 | 
|---|
| 24 | 
 | 
|---|
| 25 | %process data and model
 | 
|---|
| 26 | [x y z elements is2d isplanet]=processmesh(md,[],options);
 | 
|---|
| 27 | [tensor.xx datatype]=processdata(md,tensor.xx,options);
 | 
|---|
| 28 | [tensor.yy datatype]=processdata(md,tensor.yy,options);
 | 
|---|
| 29 | [tensor.xy datatype]=processdata(md,tensor.xy,options);
 | 
|---|
| 30 | if  md.mesh.dimension==3
 | 
|---|
| 31 |         [tensor.xz datatype]=processdata(md,tensor.xz,options);
 | 
|---|
| 32 |         [tensor.yz datatype]=processdata(md,tensor.yz,options);
 | 
|---|
| 33 |         [tensor.zz datatype]=processdata(md,tensor.zz,options);
 | 
|---|
| 34 | end
 | 
|---|
| 35 | 
 | 
|---|
| 36 | if ((md.mesh.dimension==2)),
 | 
|---|
| 37 |         subplot(2*width,2*width,index1),
 | 
|---|
| 38 |         plot_unit(x,y,z,elements,tensor.xx,is2d,isplanet,datatype,options)
 | 
|---|
| 39 |         Apply_options_tensor(md,options,type,'xx')
 | 
|---|
| 40 |         subplot(2*width,2*width,index2),
 | 
|---|
| 41 |         plot_unit(x,y,z,elements,tensor.yy,is2d,isplanet,datatype,options)
 | 
|---|
| 42 |         Apply_options_tensor(md,options,type,'yy')
 | 
|---|
| 43 |         subplot(2*width,2*width,index3),
 | 
|---|
| 44 |         plot_unit(x,y,z,elements,tensor.xy,is2d,isplanet,datatype,options)
 | 
|---|
| 45 |         Apply_options_tensor(md,options,type,'xy')
 | 
|---|
| 46 | else
 | 
|---|
| 47 |         subplot(3*width,3*width,index1),
 | 
|---|
| 48 |         plot_unit(x,y,z,elements,tensor.xx,is2d,isplanet,datatype,options)
 | 
|---|
| 49 |         Apply_options_tensor(md,options,type,'xx')
 | 
|---|
| 50 |         subplot(3*width,3*width,index2),
 | 
|---|
| 51 |         plot_unit(x,y,z,elements,tensor.yy,is2d,isplanet,datatype,options)
 | 
|---|
| 52 |         Apply_options_tensor(md,options,type,'yy')
 | 
|---|
| 53 |         subplot(3*width,3*width,index3),
 | 
|---|
| 54 |         plot_unit(x,y,z,elements,tensor.zz,is2d,isplanet,datatype,options)
 | 
|---|
| 55 |         Apply_options_tensor(md,options,type,'zz')
 | 
|---|
| 56 |         subplot(3*width,3*width,index4),
 | 
|---|
| 57 |         plot_unit(x,y,z,elements,tensor.xy,is2d,isplanet,datatype,options)
 | 
|---|
| 58 |         Apply_options_tensor(md,options,type,'xy')
 | 
|---|
| 59 |         subplot(3*width,3*width,index5),
 | 
|---|
| 60 |         plot_unit(x,y,z,elements,tensor.xz,is2d,isplanet,datatype,options)
 | 
|---|
| 61 |         Apply_options_tensor(md,options,type,'xz')
 | 
|---|
| 62 |         subplot(3*width,3*width,index6),
 | 
|---|
| 63 |         plot_unit(x,y,z,elements,tensor.yz,is2d,isplanet,datatype,options)
 | 
|---|
| 64 |         Apply_options_tensor(md,options,type,'yz')
 | 
|---|
| 65 | end
 | 
|---|
| 66 | end
 | 
|---|
| 67 | 
 | 
|---|
| 68 | function Apply_options_tensor(md,options,type,component)
 | 
|---|
| 69 |         %apply options
 | 
|---|
| 70 |         if ismember('_',type) %user plotet stress_tensor
 | 
|---|
| 71 |                 strings=strsplit(type,'_');
 | 
|---|
| 72 |                 string=strings{1};
 | 
|---|
| 73 |         else %default plot: user requested stress
 | 
|---|
| 74 |                 string=type;
 | 
|---|
| 75 |         end
 | 
|---|
| 76 |         options=addfielddefault(options,'title',[upper(string(1)) string(2:end) ' ' component]);
 | 
|---|
| 77 |         applyoptions(md,[],options);
 | 
|---|
| 78 | end
 | 
|---|