gf_plot_slice

Purpose

Plots a mesh slice  

Synopsis

[hfaces, htube, hquiver, hmesh]=gf_plot_slice(mesh_slice sl, ...)

Description

This function can be used to plot mesh slices. It is also used by the gf_plot_mesh and gf_plot functions. The various options are expected as a list pair "option name"/"option value". These options are:

'data' [] the data to be plotted (expected as a row vector or matrix such that size(D,2)==gf_slice_get(sl,'nbpts')).
'mesh' 'auto' 'on' -> show the mesh (faces of edges), 'off' -> ignore mesh.
'mesh_edges' 'on' show mesh edges ? (ignored if 'mesh' is off).
'mesh_edges_color' [.6 .6 1] color (rgb or color name) of the mesh edges.
'mesh_edges_width' .7 width of mesh edges.
'mesh_slice_edges' 'on' also plot "edges" of the sliced part of the mesh ?
'mesh_slice_edges_color' [.7 0 0]
'mesh_slice_edges_width' .5
'mesh_faces' 'off' if 'on', fill the mesh faces (otherwise they are transparent).
'mesh_faces_color' [.75 .75 .75] color of mesh faces (ignored if data is not empty).
'pcolor' 'on' if the data field is scalar, a color plot of its values is plotted.
'quiver' 'on' if the field is vector, represent arrows.
'quiver_density' 50 density of arrows in quiver plot.
'quiver_scale' 1 scaling of arrows in quiver plot.
'tube' 'on' use tube plot for 'filar' (1D) parts of the slice.
'tube_color' 'red' color of tubes (ignored if 'data' is not empty and 'pcolor' is on).
'tube_radius' '0.5%' tube radius; you can use a constant, or a percentage (of the mesh size) or a vector of nodal values (similar to the data field).
'showoptions' 'on' display the list of options before plotting.

On output, this function returns the handles to the various graphical objects created: hmesh is the handles to the mesh lines, hfaces is the handles to 2D faces created (patch objects), htube is the handle of the tube plot (surface object), hquiver is the handle obtained with the matlab function quiver.

Examples

streamlines of the fluid in a tank

Consider that you have a 3D mesh fem mf and a vector field U defined on this mesh fem, solution of the Stokes problem in a tank (see the demo demo_stokes_3D_tank_draw.m in the tests directory).
figure;
% slice the mesh with two half spaces, and take the boundary of the resulting quarter-cylinder
sl=gf_slice({'boundary',{'intersection',{'planar',+1,[0;0;0],[0;1;0]},...
                                          {'planar',+1,[0;0;0],[1;0;0]}}},m,6);
Usl=gf_compute(pde.mf_u,U,'interpolate on', sl);  % interpolate the solution on the slice
% show the norm of the displacement on this slice
gf_plot_slice(sl,'mesh','on','data',sqrt(sum(Usl.^2,1)),'mesh_slice_edges','off');
  
% another slice: now we take the lower part of the mesh
sl=gf_slice({'boundary',{'intersection',{'planar',+1,[0;0;6],[0;0;-1]},...
                                        {'planar',+1,[0;0;0],[0;1;0]}}},m,6);
Usl=gf_compute(pde.mf_u,U,'interpolate on', sl);
hold on;
gf_plot_slice(sl,'mesh','on','data',sqrt(sum(Usl.^2,1)),'mesh_slice_edges','off');
  
% this slice contains the transparent mesh faces displayed on the picture
sl2=gf_slice({'boundary',{'planar',+1,[0;0;0],[0;1;0]}},...
            m,6,setdiff(all_faces',TOPfaces','rows')');
gf_plot_slice(sl2,'mesh_faces','off','mesh','on','pcolor','off'); 

% last step is to plot the streamlines
hh=[1 5 9 12.5 16 19.5]; % vertical position of the different starting points of the streamlines
H=[zeros(2,numel(hh));hh];

% compute the streamlines
tsl=gf_slice('streamlines',pde.mf_u,U,H);
Utsl=gf_compute(pde.mf_u,U,'interpolate on', tsl);

% render them with "tube plot"
[a,h]=gf_plot_slice(tsl,'mesh','off','tube_radius',.2,'tube_color','white'); 
hold off;
% use a nice colormap
caxis([0 .7]);
c=[0 0 1; 0 .5 1; 0 1 .5; 0 1 0; .5 1 0; 1 .5 0; 1 .4 0; 1 0 0; 1 .2 0; 1 .4 0; 1 .6 0; 1 .8 0];
colormap(c);  

See Also