rbmatlab 0.10.01
scripts/thermalblock.m
Go to the documentation of this file.
00001 function thermalblock(step)
00002 % thermalblock example
00003 %  step 1: detailed simulation with different parameters
00004 %  step 2: reduced basis simulation
00005 %  step 3: demo_rb_gui
00006 
00007 if nargin<1
00008   step = 1;
00009 end;
00010 
00011 switch step
00012  case 1 % different detailed simulations
00013 
00014   disp('detailed simulation:');
00015   
00016   
00017   descr      = thermalblock_descr;
00018   dmodel     = gen_detailed_model(descr);
00019 
00020   model_data = gen_model_data(dmodel);
00021   dmodel = set_mu(dmodel,[1,1,1,1,1,1,1,1,1]);
00022 
00023   sim_data = detailed_simulation(dmodel,model_data);
00024   plot_params.title = ['detailed solution , \mu_i=1, output s=',...
00025                        num2str(sim_data.s)];
00026   figure, plot_sim_data(dmodel,model_data,sim_data,plot_params);
00027   dmodel = set_mu(dmodel,[0.1,0.1,1,1,0.1,0.1,1,0.1,1]);
00028 
00029   sim_data = detailed_simulation(dmodel,model_data);
00030   plot_params.title = ['detailed solution , \mu_i=0.1/1, output s=',...
00031                        num2str(sim_data.s)];
00032   figure, plot_sim_data(dmodel,model_data,sim_data,plot_params);
00033 
00034  case 2 % rb treatment and comparison to detailed
00035 
00036   % for non-snapshot parameter nice error behaviour is observed
00037   % for snapshot parameter error is numerically zero, but
00038   % estimators due to numerical noise not zero.
00039 
00040   disp('detailed simulation:');
00041   descr            = thermalblock_descr;
00042   [dmodel, rmodel] = gen_models(descr);
00043   model_data       = gen_model_data(dmodel);
00044   % non-snapshot parameter, error <= Delta
00045   dmodel = set_mu(dmodel,[0.5,1,1,1,1,1,1,1,1]);
00046   % non-snapshot parameter with excellent Delta==error!!!
00047   %model = model.set_mu(model,[1,1,1,1,1,1,1,1,1]);
00048   % snapshot parameter with error, Delta approximately 0.
00049   %model = model.set_mu(model,[0.1,1,1,1,1,1,1,1,1]);
00050   sim_data = detailed_simulation(dmodel,model_data);
00051   sim_data.mu = get_mu(dmodel);
00052   plot_params.title = 'detailed solution';
00053   disp(['output s(mu) = ',num2str(sim_data.s)]);
00054   figure, plot_sim_data(dmodel,model_data,sim_data,plot_params);
00055   disp('offline computations I (gen_detailed_data: basis):');
00056   detailed_data = gen_detailed_data(rmodel,model_data);
00057   disp('offline computations II (gen_reduced_data: operator components):');
00058   reduced_data = gen_reduced_data(rmodel,detailed_data);
00059 %  model.N = 1;
00060 %  reduced_data = model.reduced_data_subset(model,reduced_data);
00061 
00062   disp('online reduced simulation:');
00063   rmodel = set_mu(rmodel, sim_data.mu);
00064   rb_sim_data = rb_simulation(rmodel,reduced_data);
00065   rb_sim_data = rb_reconstruction(rmodel, detailed_data, rb_sim_data);
00066   plot_params.title = 'reduced solution';
00067   figure, plot_sim_data(rmodel,model_data,rb_sim_data,plot_params);
00068   disp(['output sN(mu) = ',num2str(rb_sim_data.s)]);
00069 
00070   disp('-------------------------------------------');
00071   eh = sim_data.uh - rb_sim_data.uh;
00072   l2_err = fem_l2_norm(eh);
00073   h10_err = fem_h10_norm(eh);
00074   disp(['L2-error: ',num2str(l2_err)]);
00075   disp(['H10-error: ',num2str(h10_err)]);
00076   disp(['error s(mu)-sN(mu) = ',num2str(sim_data.s-rb_sim_data.s)]);
00077   disp(['error estimator Delta_u(mu) = ',num2str(rb_sim_data.Delta)]);
00078   disp(['error estimator Delta_s(mu) = ',num2str(rb_sim_data.Delta_s)]);
00079 
00080   % save detailed_data for demo_rb_gui:
00081   save(fullfile(rbmatlabtemp,'thermal_block_offline_data.mat'),...
00082        'dmodel','detailed_data');
00083 
00084  case 3 % demo_rb_gui
00085 
00086   fn = fullfile(rbmatlabtemp,'thermal_block_offline_data.mat');
00087   if ~exist(fn) % call step 2 first
00088     disp('calling thermalblock(2) for basis generation')
00089     thermalblock(2);
00090   end;
00091 
00092   disp('demo_rb_gui:')
00093   descr            = thermalblock_descr;
00094   [~, rmodel] = gen_models(descr);
00095   load(fn);
00096   rmodel.N = size(detailed_data.RB,2);
00097   %model_data       = gen_model_data(dmodel);
00098   %detailed_data    = gen_detailed_data(dmodel,model_data);
00099   plot_params.axis_tight = 1;
00100   plot_params.yscale_uicontrols = 0.5;
00101   demo_rb_gui(rmodel,detailed_data,[],plot_params);
00102 
00103 end;
00104 
All Classes Namespaces Files Functions Variables