1 % small script testing, whether detailed and local
operator
2 % evaluation are the same
for detailed_nonlin_evol_simulation
4 % Bernard Haasdonk 21.5.2007
6 load demo_nonlin_evol_params;
7 % only perform one step
8 params.T = params.T/params.nt;
10 params.c_init = 1; % hereby nontrivial structure is visible
11 params.k = 0; % damit nur explizit
13 params.filecache_velocity_matrixfile_extract = 1;
16 grid = construct_grid(params);
18 % construct a subgrid with some cells
20 eindmask = zeros(grid.nelements,1);
21 % select randomly 10 points
23 eindmask(ceil(rand(1,10)*grid.nelements)) = 1;
26 eind2 = find(eindmask);
27 NBI = grid.NBI(eind2,:);
28 inner_edge = find(NBI>0);
29 eindmask(NBI(inner_edge))= 1;
33 eind = find(eindmask);
34 subgrid = gridpart(grid,eind);
36 % and determine inner elements
37 inner_els_mask = ones(subgrid.nelements,1);
38 [i,j] = find(subgrid.NBI==-10); % i.e.cut edge
39 inner_els_mask(i) = 0;
40 eind_local = find(inner_els_mask);
42 %subplot(2,1,1), plot(grid);
43 %subplot(2,1,2), plot(subgrid);
45 % generate initial data
46 params.affine_decomp_mode =
'complete';
47 U0 = feval(params.init_values_algorithm,grid,params);
49 params.dt = params.T/params.nt;
51 %detailed
explicit step
52 inc = feval(params.L_E_local_name, ...
55 U = U0 - params.dt * inc;
57 % local
explicit step on subgrid
58 incsub = feval(params.L_E_local_name, ...
59 U0sub, eind_local, ...
61 Usub_local = U0sub(eind_local) - params.dt * incsub;
62 Usub = zeros(subgrid.nelements,1);
63 Usub(eind_local) = Usub_local;
65 subplot(3,1,1), plot_element_data(grid,U,params);
66 title(
'complete solution after 1 step')
67 subplot(3,1,2), plot_element_data(subgrid,Usub,params);
68 title('local solution after 1 step')
69 set(gca,'Xlim',params.xrange,'Ylim',params.yrange);
71 err = zeros(subgrid.nelements,1);
72 err(eind_local) = Usub(eind_local) - U(eind(eind_local));
73 subplot(3,1,3), plot_element_data(subgrid,err,params);
74 set(gca,'Xlim',params.xrange,'Ylim',params.yrange);
75 maxerr = abs(max(err));
76 title(['local error after 1 step: max(err) =',num2str(maxerr)]);
79 % das folgende geht natuerlich nicht, weil 'cut'-fluxes nicht
81 %Usub = detailed_simulation(subgrid,params);
83 disp('detailed_simulation und local simulation give');
85 disp('different results! Test failed');
87 disp('identical result! Test OK');
92 % TO BE ADJUSTED TO NEW SYNTAX