rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
demo_dom_dec.m
1 function demo_dom_dec()
2 %function demo_dom_dec()
3 %
4 % demo showing the functionality of the dom_dec routines.
5 % plotting some iteratives of the iterative procedure,
6 % comparing the detailed and reduced simulation.
7 
8 % I.Maier 19.07.2011
9 
10 disp('start domain decomposition demo');
11 disp('-------------------------------');
12 disp('visualize detailed simulation');
13 disp('-----------------------------');
14 
15 params = [];
16 % specify geometrical decomposition
17 params.dd_rect_corner1 = {[0,0],[0.25,0],[0.75,0]};
18 params.dd_rect_corner2 = {[0.25,0.25],[0.75,0.75],[1,0.5]};
19 
20 params.numintervals = 24; % discretization parameter
21 params.RB_numintervals = 2;
22 params.subsampling_level = 4; % for plotting
23 
24 % create models
25 base_model = thermalblock_dd_model(params);
26 model = dom_dec_model(base_model,params);
27 disp('models created');
28 
29 dir = model.dirichlet_side;
30 no_dir = mod(dir,2)+1;
31 
32 % generate model_data
33 model_data = gen_model_data(model);
34 disp('model_data created');
35 
36 %%%%%%%%%%%%%%% visualize detailed simulation
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 
39 model = set_mu(model,[1.843,2.878,8.879,0.874]);
40 
41 % plot source function
42 disp('plot source function');
43 source = femdiscfunc([],model_data.base_model_data.df_info);
44 source = fem_interpol_local(model.base_model.source,source, ...
45  model.base_model);
46 figure,
47 plot(source,params);
48 title('source function');
49 
50 % perform detailed simulation
51 sim_data = detailed_simulation(model,model_data);
52 
53 disp('plotting');
54 for i = [1 5 10]
55  figure,
56 
57  for j = 1:2
58  sim_data.uh{j}.dofs = sim_data.all_dofs{j}(:,i);
59  plot(sim_data.uh{j},params);
60  end;
61 
62  title(['iterative solution, ', num2str(i),' iterations']);
63 end;
64 
65 for j = 1:2
66  sim_data.uh{j}.dofs = sim_data.all_dofs{j}(:,end);
67 end;
68 
69 % compute un-decomposed solution - perform detailed simulation of
70 % base_model
71 disp('perform detailed simulation of base_model');
72 base_sim_data = detailed_simulation(model.base_model, ...
73  model_data.base_model_data);
74 figure,
75 plot_sim_data(model.base_model,model_data.base_model_data, ...
76  base_sim_data,params);
77 title('monolithic solution');
78 
79 disp('press enter to continue');
80 pause;
81 
82 %%%%%%%%%%%%%% compare detailed and reduced simulation
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 disp('---------------------------------------');
85 disp('compare detailed und reduced simulation');
86 disp('---------------------------------------');
87 model.det_sim_tol = 1e-07;
88 model.RB_sim_tol = 1e-07;
89 model.N_max = {12 12};
90 model.RB_generation_mode = 'PCA_trajectories';
91 model.RB_generation_epsilon = 1e-7;
92 
93 % build reduced basis
94 disp('generate detailed_data');
95 model.verbose = 0;
96 detailed_data = gen_detailed_data(model,model_data);
97 model.verbose = 1;
98 disp('dimensions of reduced basis:');
99 disp([' N_1^0 = ',num2str(length(detailed_data.I_0{dir}))]);
100 disp([' N_1^G = ',num2str(length(detailed_data.I_G{dir}))]);
101 disp([' N_2^0 = ',num2str(length(detailed_data.I_0{no_dir}))]);
102 disp([' N_2^G = ',num2str(length(detailed_data.I_G{no_dir}))]);
103 
104 disp('generate reduced_data');
105 reduced_data = gen_reduced_data(model,detailed_data);
106 
107 % perform detailed simulation
108 tic;
109 sim_data = detailed_simulation(model,model_data);
110 det_sim_time = toc;
111 
112 sim_data = model.compute_error(model,model_data,sim_data);
113 
114 disp('------------------------------------------');
115 disp(['elapsed time of detailed simulation: ', ...
116  num2str(det_sim_time,3),'s']);
117 disp(['error of iterative solution: ',num2str(sim_data.X_err(end),3)]);
118 
119 % perform reduced simulation
120 tic;
121 rb_sim_data = rb_simulation(model,reduced_data);
122 rb_sim_time = toc;
123 
124 rb_sim_data = rb_reconstruction(model,detailed_data,rb_sim_data);
125 rb_sim_data = model.compute_error(model,detailed_data,rb_sim_data);
126 
127 disp('------------------------------------------');
128 disp(['elapsed time of reduced simulation: ',num2str(rb_sim_time,3), ...
129  's']);
130 disp(['error of reduced iterative solution: ', ...
131  num2str(rb_sim_data.X_err(end),3)]);
132 disp(['error estimate of reduced iterative solution: ', ...
133  num2str(rb_sim_data.Delta(end),3)]);
134 
135 plot_sim_data(model, model_data, sim_data, params);
136 title('detailed solution');
137 plot_sim_data(model, model_data, rb_sim_data, params);
138 title('reduced solution');