1 function animate_basisgen(detailed_data,params)
2 %
function animate_basisgen(detailed_data,params)
4 % perform an animation of a 2D RB basis construction process
for
5 % grid-based approaches. i.e. the 'RB_generation_mode' in params
6 % being 'uniform_fixed', 'uniform_refined', 'adaptive_refined'
7 % the mesh is plotted, the colors indicating the numbers of the
8 % basis-functions located in the parameter vertices.
9 % Only 2 parameters, i.e. a 2D parameter grid are plotted currently
11 % optional fields of params:
12 % animation_pause : number of seconds after each basis-vector addition
15 % Bernard Haasdonk 29.3.2007
17 %save_avi = 1; % generate
basisgen.avi
18 save_avi = 0; % generate
basisgen.avi
20 if ~isfield(params,
'animation_pause')
21 params.animation_pause = 0.05; % pause after each plot
24 if length(params.mu_names)~=2
25 error('currently only 2D parameter spaces are animated!');
28 params.axis_equal = 0;
29 mu_values = detailed_data.RB_info.mu_sequence;
33 vertices_old = zeros(0,2);
35 switch params.RB_generation_mode
37 mesh_index = detailed_data.RB_info.mesh_index_sequence;
38 MMesh_sequence = detailed_data.RB_info.MMesh_list;
40 par.numintervals = params.RB_numintervals;
41 par.range = params.mu_ranges;
43 MMesh_sequence = {MMesh0};
44 mesh_index = ones(1,size(mu_values,2));
46 error(
'RB_generation_mode not supported for animation.')
53 mov = avifile('basisgen_animat.avi');
55 mov = set(mov,'Compression','None');
56 frame_rep = ceil(15*params.animation_pause);
59 for i = 1:length(mesh_index)
60 if isempty(find(isnan(mu_values(:,i)),1))
61 % get mu_frequency for current collection
62 MMesh = MMesh_sequence{mesh_index(i)};
63 if (mesh_index(i)> mesh_index_old)
64 % extend mu_frequency and check that vertices have remained the same!
65 nvertices =
get(MMesh_sequence{mesh_index(i)},
'nvertices');
66 mu_frequency = [mu_frequency, ...
67 zeros(1, nvertices-nvertices_old)];
68 vertices =
get(MMesh_sequence{mesh_index(i)},
'vertex');
69 if ~isequal(vertices(1:nvertices_old,:),vertices_old)
70 error('grid vertices changes during refinement!');
72 vertices_old = vertices;
73 nvertices_old = nvertices;
75 % find mu_vector in vertex list
77 j = find_vector(mu_values(:,i), vertices',epsilon);
78 if (isempty(j) || length(j)>1)
79 error('vector not or multiply found in vertex list!!');
81 mu_frequency(j(1)) = mu_frequency(j(1)) + 1;
83 plot_leafvertex_data(MMesh,mu_frequency, params); hold on;
84 p = plot(mu_values(1,i),mu_values(2,i),'.','Markersize',30);
85 title([num2str(sum(mu_frequency)),' basis vectors added']);
86 pause(params.animation_pause);
87 xlabel(params.mu_names{1});
88 ylabel(params.mu_names{2});
93 mov = addframe(mov,F);
97 disp([
'skipped animation of mu-point ',num2str(i)]);
105 set(p,
'visible',
'off');
108 % TO BE ADJUSTED TO NEW SYNTAX