rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
newton_steps.m
Go to the documentation of this file.
1 function outfile = newton_steps(step)
2 % small script demonstrating a buckley leverett problem
3 % discretization and RB model reduction
4 %
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 %%%%%% Select here, what is to be performed with the richards data %%%%%%%%
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8 %step = 1 % single detailed simulation with given data and plot. Run
9  % this with varying parameters mu until sure that scheme
10  % is stable. Modify dt or the data-functions accordingly,
11  % until a nice parameter-domain with uniformly stable
12  % detailed scheme is obtained.
13 %step = 2 % generate colateral reduced basis of L_E operator
14 %step = 3 % compare single detailed simulation with and without
15  % interpolated space operator
16 %step = 4 % generate dummy reduced basis from single trajectory and check, if
17  % ei_interpolation with projection on this space maintains
18  % result. A simple reduced simulation can also be
19  % performed. All results should be visually identical
20 %step = 5 % generate reduced basis
21 %step = 6 % time measurement of reduced simulation and
22  % use reduced basis in rb_demo_gui
23 
24 warning('off', 'RBMatlab:rb_simulation:runtime');
25 
26 imsavepath = fullfile(rbmatlabresult, 'images');
27 
28 params.model_type = 'buckley_leverett';
29 %params.model_type = 'exponential_diffusion';
30 %params.model_type = 'eoc_nonlinear';
31 %params.model_size = 'big';
32 %params.model_size = 'medium';
33 % params.model_size = 'small';
34 % params.model_type = 'nonlinear';
35 params.separate_CRBs = false;
36 
37 % test parameters
38 params.RB_detailed_test_savepath = 'test_data_100';
39 params.RB_test_size = 100;
40 
41 params.verbose = 2;
42 params.debug = 0;
43 extrapar.Mstrich = 20;
44 extrapar.N = 50;
45 extrapar.M = 150;
46 
47 % email to which status messages about processing mu vectors is sent
48 % params.email = 'mdrohmann@uni-muenster.de';
49 
50 %% parameters for visualization
51 plot_params.show_colorbar = 1;
52 plot_params.colorbar_mode = 'EastOutside';
53 plot_params.no_lines = true;
54 plot_params.plot_type = 'patch';
55 % plot_params.clim = [0, 0.5];
56 % plot_params.clim_tight = true;
57 plot_params.plot = @fv_plot;
58 plot_params.bind_to_model = true;
59 plot_params.yscale_uicontrols = 0.6;
60 
61 % output-filenames in rbmatlabresult
62 CRBfname = ['newton_', params.model_type, '_CRB_interpol.mat'];
63 if exist('model', 'var') && isfield(model, 'RB_error_indicator') ...
64  && ~strcmp(model.RB_error_indicator, 'error')
65  infix = model.RB_error_indicator;
66 else
67  infix = '';
68 end
69 detailedfname = ['newton_', params.model_type, infix, '_detailed_interpol.mat'];
70 params.step7_outputfile = fullfile(rbmatlabresult, [params.model_type, infix, '_step7_output']);
71 params.step8_outputfile = fullfile(rbmatlabresult, [params.model_type, infix, '_step8_output']);
72 params.step0file = [params.model_type, infix, 'step0'];
73 params.step1file = [params.model_type, infix, 'step1'];
74 
75 outfile = '';
76 
77 switch step
78  case 0 % initialize model data
79  basis_gen = newton_oo_model(params);
80 
81  model_data = gen_model_data(basis_gen);
82  save(fullfile(rbmatlabtemp, params.step0file), 'model','model_data')
83  outfile = fullfile(rbmatlabtemp, params.step0file);
84  case 1 % single detailed simulation and plot
86  outfile = fullfile(rbmatlabtemp, params.step1file);
87  case 1.5
88  load(fullfile(rbmatlabtemp, params.step0file));
89  tmppar.model_type = 'eoc';
90 
91  model = newton_model(tmppar);
92  model.debug = 1;
93  model.newton_solver = 0;
94  model.T = 1;
95  model.dt = model.T/model.nt;
96  model.verbose = 21;
97  err = zeros(model.nt+1,7);
98  eoc = zeros(4, 1);
99  for i = 1:7
100  model_data = gen_model_data(model);
101 
102  sim_data = detailed_simulation(model, model_data);
103 
104  ffe = @exact_function_heat_equation;
105 
106  exact_data.U = zeros(model_data.grid.nelements, model.nt+1);
107 
108  for tt = 1:model.nt+1
109  model.t = (tt-1) * model.dt;
110  exact_data.U(:,tt) = ffe([model_data.grid.CX(:), model_data.grid.CY(:)], model);
111  end
112  model.t = 0;
113 
114  err(:,i) = fv_l2_error(sim_data.U, exact_data.U, model_data.W);
115  if(i>1)
116  eoc(i-1) = log(max(err(:,i-1))/max(err(:,i)))/log(2);
117  disp(['Error: ', num2str(err(end,i)), 'EOC: ', num2str(eoc(i-1))]);
118  pause;
119  end
120 
121  model.xnumintervals = round(model.xnumintervals.*2);
122  model.ynumintervals = round(model.ynumintervals.*2);
123  end
124  outfile = fullfile(rbmatlabtemp, [params.model_type, '_step1_5']);
125  save(outfile, 'err', 'eoc');
126  case 1.75
127  load(fullfile(rbmatlabtemp, params.step0file));
128  tmppar.model_type = 'eoc_nonlinear';
129  tmppar.local_mass_matrix = @fv_local_mass_matrix_rect;
130  tmppar.element_quadrature = @cubequadrature;
131  tmppar.evaluate_basis = @fv_evaluate_basis;
132  tmppar.pdeg = 0;
133 
134  model = newton_model(tmppar);
135  %model.debug = 1;
136  % model.newton_regularisation = 0;
137  %model.verbose = 21;
138  model.dt = model.T/model.nt;
139  model.ynumintervals = 1;
140  err = zeros(model.nt+1,5);
141  eoc = zeros(4, 1);
142  for i = 1:6
143  disp(['Computing EOC step no. ', num2str(i)]);
144  model_data = gen_model_data(model);
145 
146  sim_data = detailed_simulation(model, model_data);
147 
149 
150  width = model_data.grid.X(2) - model_data.grid.X(1);
151 
152  Fe = @(einds, loc, grid, params) ffe([grid.X(einds) + loc(:,1)*width,...
153  grid.Y(einds) + loc(:,2)*width], ...
154  params);
155  tmppar.diff_k0 = model.diff_k0;
156  exact_data.U = zeros(model_data.grid.nelements, model.nt+1);
157  for tt = 1:model.nt+1
158  model.t = (tt-1) * model.dt;
159  exact_data.U(:,tt) = ffe([model_data.grid.CX(:), ...
160  model_data.grid.CY(:)], model);
161 % exact_data.U(:,tt) = l2project(Fe, 2, model_data.grid, tmppar);
162  end
163  model.t = 0;
164 
165  err(:,i) = fv_l2_error(sim_data.U, exact_data.U, model_data.W);
166  if(i>1)
167  eoc(i-1) = log(max(err(:,i-1))/max(err(:,i)))/log(2);
168  disp(['Error: ', num2str(err(end,i)), ' EOC: ', num2str(eoc(i-1))]);
169  end
170 
171  model.xnumintervals = model.xnumintervals.*2;
172  model.nt = model.nt;
173  model.dt = model.T / model.nt;
174  %model.ynumintervals = model.ynumintervals.*2;
175  end
176 
177  outfile = fullfile(rbmatlabtemp, [params.model_type, '_step1_75']);
178  save(outfile, 'err', 'eoc');
179  case 2 % empirical interpolation of space operator
180  load(fullfile(rbmatlabresult, params.step0file));
182  outfile = fullfile(rbmatlabresult, CRBfname);
183  case 3 % compare detailed simulation with and without interpolation
184  model.detailed_ei_simulation = @nonlin_evol_detailed_simulation;
186  case 4 % construct dummy reduced basis by single trajectory and simulate
187  model.detailed_ei_simulation = @nonlin_evol_detailed_simulation;
188  detailed_data = gen_detailed_data(basis_gen, model_data);
189  save(fullfile(rbmatlabresult, detailedfname), 'detailed_data', 'basis_gen');
191  case 5 % reduced basis
192 % tmp=load(fullfile(rbmatlabresult,CRBfname));
193 % detailed_data = tmp.detailed_data;
195  outfile = fullfile(rbmatlabresult, detailedfname);
196  case 6
197 % load(fullfile(rbmatlabresult,detailedfname));
199  case 7 % training-error landscape & time comparisons
200  tmp=load(fullfile(rbmatlabresult,detailedfname));
201  detailed_data = tmp.detailed_data;
202 
203 
204  model.Mstrich = 0;
205  % maximum number of reduced basis functions
206  model.Nmax = size(detailed_data.RB,2);
207  % maximum number of collateral reduced basis functions
208  model.Mmax = size(detailed_data.BM{1},2);
209  % number of reduced basis sizes to be tested.
210  Nsize = 7;
211  % number of collateral reduced basis sizes to be tested.
212  Msize = 10;
213  % sample of values for the coupling variable 'c' for which errors are
214  % computed.
215  csample = 0.1:0.1:1;
216  % axis description for plots with coupling variable 'c'
217  cdescr = '(N,M) = c * (Nmax, Mmax)';
218  % size of mu vector test set.
219  mu_set_size = 20;
220 
221  error_plots = { 'train_set', 'train_set_coupled', ...
222  'error', 'error_coupled' };
223 
224  model.M_by_N_ratio = model.Mmax/model.Nmax;
225 
227  outfile = params.step7_outputfile;
228 
229 case 7.5
230  load(params.step7_outputfile);
231  for i = 1:length(output)
232  plot_error_landscape(output{i});
233  end
234 case 8
235  disp('warning: takes a few hours!');
236  tmp = load(fullfile(rbmatlabresult,detailedfname));
237  detailed_data = tmp.detailed_data;
238 
239  % maximum number of reduced basis vectors
240  model.Nmax = model.RB_stop_Nmax;
241  % maximum number of collateral reduced basis vectors used for
242  model.Mmax = size( detailed_data.BM{1}, 2 ) - extrapar.Mstrich;
243 
244  model.M_by_N_ratio = model.Mmax/model.Nmax;
245 
246  % number of reduced basis sizes to be tested.
247  Nsize = 7;
248  % number of collateral reduced basis sizes to be tested.
249  Msize = 12;
250  % Mstrich values to be tested
251  Mstrich_samples = 1:extrapar.Mstrich;
252  % sample of values for the coupling variable 'c' for which
253  % estimators are computed.
254  csample = 0.1:0.1:1;
255  % size of mu vector test set
256  mu_set_size = 20;
257  % axis description for plots with coupling variable 'c'
258  cdescr = '(N,M) = c * (Nmax, Mmax)';
259 
261  outfile = params.step7_outputfile;
262 case 8.5
263  load(params.step8_outputfile);
264  for i = 1:length(output)
265  output{i}.bound = 1500;
266  output{i}.stab_limit = 10000;
267  plot_error_landscape(output{i});
268  end
269 case 9
270  tmp = load(fullfile(rbmatlabresult,detailedfname));
271  detailed_data = tmp.detailed_data;
272  model_data = detailed_data;
273  num_samples = 20;
274  testdir = [params.model_type, '_', num2str(num_samples), '_test'];
275  dirnames = testdir;
276  model.Nmax = size(detailed_data.RB,2);
277 
278  % generate test data if not existent
279  rand('state',123456);
280  M = rand_uniform(num_samples,model.mu_ranges);
281  save_detailed_simulations(model,model_data,M,testdir)
282 
283  % load demo_nonlin_evol_detailed_data_LE_on_RB;
284  reduced_data = gen_reduced_data(model,detailed_data);
285 
286  settings = load(fullfile(rbmatlabtemp,...
287  testdir,'settings.mat'));
288 
289  Msamples = 12;
290  Nsamples = 7;
291  % storage for maximum l2-errors (i.e. linfty([0,T],l2)-norm)
292  errs = zeros(Msamples,Nsamples);
293  model.RB_error_indicator='ei_estimator_test';
294 
295  Mstrich_set = floor(1:9.9:100);%[1,2,3,4,5,10,15,20];
296 
297  deltas = cell(size(M,2),length(Mstrich_set));
298  lambda = zeros(size(M,2),length(Mstrich_set));
299  lambdas = cell(size(M,2),length(Mstrich_set));
300  errors = cell(size(M,2),length(Mstrich_set));
301  parfor mu_ind = 1:size(M,2);
302  disp(['processing parameter vector ',num2str(mu_ind),...
303  '/',num2str(size(M,2))]);
304  deltas_tmp = cell(1, length(Mstrich_set));
305  errors_tmp = cell(1, length(Mstrich_set));
306  lambdas_tmp = cell(1, length(Mstrich_set));
307  lambda_tmp = zeros(1, length(Mstrich_set));
308  tsettings = settings;
309  textrapar = extrapar;
310  tmodel = model;
311  for msi = 1:length(Mstrich_set)
312 
313  mtemp = tmodel.set_mu(tmodel,tsettings.M(:,mu_ind));
314  sim_data = load_detailed_simulation(mu_ind,tsettings.savepath,tmodel);
315  U_H = sim_data.U;
316 
317  mtemp.M = textrapar.M;
318  mtemp.Mstrich = Mstrich_set(msi);
319  mtemp.N = textrapar.N;
320  disp(['with CRB size ',num2str(mtemp.M),...
321  ' Mstrich'' = ',num2str(mtemp.Mstrich),...
322  ' RB size ', num2str(mtemp.N)]);
323  mtemp.C_I = 1 - mtemp.diff_m;
324  simulation_data = rb_simulation(mtemp,reduced_data);
325  disp('.');
326 
327  deltas_tmp{msi} = simulation_data.Delta;
328  simulation_data = rb_reconstruction(mtemp,detailed_data,simulation_data);
329  errors_tmp{msi} = tmodel.error_algorithm(simulation_data.U, ...
330  sim_data.U, ...
331  detailed_data.W, mtemp);
332  lambdas_tmp{msi} = deltas_tmp{msi} ./ errors_tmp{msi};
333  lambda_tmp(msi) = max(deltas_tmp{msi}) / max(errors_tmp{msi});
334  disp(['true error: ', num2str(max(errors_tmp{msi})), ...
335  ' estimator: ', num2str(max(deltas_tmp{msi}))]);
336  disp(['effectivity: ', num2str(lambda_tmp(msi))]);
337 
338 % plot_sim_data(model,detailed_data,simulation_data,plot_params);
339 
340  end
341  deltas(mu_ind,:) = deltas_tmp;
342  errors(mu_ind,:) = errors_tmp;
343  lambdas(mu_ind,:) = lambdas_tmp;
344  lambda(mu_ind,:) = lambda_tmp;
345 % plot(Mstrich_set,deltas(mu_ind,:));
346 % keyboard;
347  end
348  save(fullfile(rbmatlabresult, 'step9'), 'deltas','errors','lambdas',...
349  'lambda','M','Mstrich_set');
350 
351  outfile = fullfile(rbmatlabresult, 'step9');
352 case 9.8
353  tmp = load(fullfile(rbmatlabresult, detailedfname));
354  detailed_data = tmp.detailed_data;
355 
356  %% initial data plot (as patch)
357  mu_set = {[1,0.00,0.2]};
358  plot_params.plot_type = 'patch';
359  plot_params.line_width = 1e-10;
360  plot_params.no_lines = true;
361  timeinstants = 0;
363 
364  %% some sample plots (as contour plot)
365  mu_set = {[1,0.01,0.2], [2,0.01,0.2], [4,0.01,0.2], [1,0.01,0], [2,0.01,0],[4,0.02,0]};
366 % mu_set = {[1,0.01,0], [1,0.01,0.2]};
367 % mu_set = {[0,0.01], [0.1,0.01],[0.2,1.3]};
368 % clim = [0.1, 0.7];
369  plot_params.plot_type = 'contour';
370  plot_params.contour_lines = 5;
371  plot_params.line_width = 2;
372  timeinstants = [0:1/4:1]*model.T;
373  boxed_snapshots = true;
375 
376  %% interpolation dofs
377  plot_params.plot_type = 'patch';
378  plot_params.colormap = 1/length(detailed_data.TM{1})*repmat((length(detailed_data.TM{1}):-1:1)',1,3);
379  plot_params.show_colorbar = 0;
380  u = zeros(detailed_data.grid.nelements,1);
381  u(detailed_data.TM{1}) = 1:length(detailed_data.TM{1});
382  u(1)=50;
383  u(end)=50;
384  plot_params.plot(detailed_data.grid, u, plot_params);
385  title(['Interpolation DOFS for implicit and explicit operator']);
386  set(gcf, 'Color', 'none');
387  set(gcf, 'InvertHardCopy', 'off');
388  showaxes('hide');
389  tikzparams.filepath = fullfile(imsavepath, params.model_type);
390  export_fig(fullfile(tikzparams.filepath, 'ei_dofs'),'-pdf','-a0',gcf);
391  system(['convert -density 1200x1200 -trim ', ...
392  fullfile(tikzparams.filepath, 'ei_dofs.pdf '), ...
393  fullfile(tikzparams.filepath, 'ei_dofs.png')]);
394  system(['rm ', fullfile(tikzparams.filepath, 'ei_dofs.pdf')]);
395  close(gcf);
396 
397  %% error convergence of crb generation
398  plot(detailed_data.ei_info{1}.max_err_sequence);
399  set(gca,'Yscale','log');
400  title('EI-interpolation error decrease');
401  matlab2tikz(fullfile(tikzparams.filepath, 'ei_error_decrease.tikz'));
402 
403  %% error convergence of POD greedy
404  plot(detailed_data.RB_info.max_err_sequence);
405  set(gca,'Yscale','log');
406  title('POD greedy error decrease');
407  matlab2tikz(fullfile(tikzparams.filepath, 'pod_greedy_error_decrease.tikz'));
408  close(gcf);
409 
410  %% ei snapshots
411  Msize = size(detailed_data.QM{1},2);
412 % colorm = colormap(hot(Msize));
413 % colorm = colorm(Msize:-1:1,:);
414  emus = detailed_data.ei_info{1}.extension_mus([1,3],1:Msize);
415  midmu = detailed_data.ei_info{1}.extension_mus(2,1:Msize);
416  coord1 = emus(:,midmu==0.01);
417  coord2 = emus(:,midmu==0.005);
418  [coord1u,coord1I,coordJ] = unique(sortrows(coord1'),'rows');
419  count1 = [coord1I(1); coord1I(2:end) - coord1I(1:end-1)]*10;
420  [coord2u,coord2I,coordJ] = unique(sortrows(coord2'),'rows');
421  count2 = [coord2I(1); coord2I(2:end) - coord2I(1:end-1)]*10;
422 
423  scatter(coord1u(:,1),coord1u(:,2), count1, 'black', 'filled');
424  hold on;
425  scatter(coord2u(:,1),coord2u(:,2), count2, [0.7 0.7 0.7], 'd','filled');
426  hold off;
427 
428  set(gcf, 'Color', 'none');
429  set(gcf, 'InvertHardCopy', 'off');
430 
431  showaxes('hide');
432 
433  im = export_fig(fullfile(tikzparams.filepath, 'ei_mu_snapshots'), '-png','-a3',gcf);
434  close(gcf);
435 
436  %% RB snapshots
437  Nsize = size(detailed_data.RB,2);
438 % colorm = colormap(hot(Msize));
439 % colorm = colorm(Msize:-1:1,:);
440  emus = detailed_data.RB_info.mu_sequence([1,3],1:Nsize);
441  midmu = detailed_data.RB_info.mu_sequence(2,1:Nsize);
442  coord1 = emus(:,midmu==0.01);
443  coord2 = emus(:,midmu==0.005);
444  [coord1u,coord1I,coordJ] = unique(sortrows(coord1'),'rows');
445  count1 = [coord1I(1); coord1I(2:end) - coord1I(1:end-1)]*100;
446  [coord2u,coord2I,coordJ] = unique(sortrows(coord2'),'rows');
447  count2 = [coord2I(1); coord2I(2:end) - coord2I(1:end-1)]*100;
448 
449  scatter(coord1u(:,1),coord1u(:,2), count1, 'black', 'filled');
450  hold on;
451  scatter(coord2u(:,1),coord2u(:,2), count2, [0.7 0.7 0.7], 'd','filled');
452  hold off;
453 
454  set(gcf, 'Color', 'none');
455  set(gcf, 'InvertHardCopy', 'off');
456 
457  showaxes('hide');
458 
459  im = export_fig(fullfile(tikzparams.filepath, 'rb_mu_snapshots'), '-png','-a3',gcf);
460  close(gcf);
461 
462  % error convergence of random samples
463 
464 
465 % scatter3(coord(1,:),coord(2,:),coord(3,:),20,colorm,'filled');
466 % xlabel(['\mu_1 = ',model.mu_names{1}]);
467 % ylabel(['\mu_3 = ',model.mu_names{3}]);
468  %ylabel(['\mu_2 = c_{init}']);%,model.mu_names{2}]);
469 % zlabel('time index k');
470 % title(['snapshots selected for collateral basis for operator no.'])
471 % set(gca,'Box','on');
472 % save(fullfile(tikzparams.filepath, 'ei_mu_snapshots.dat'), 'coord', '-ascii', '-double', '-tabs');
473 % matlab2tikz(fullfile(tikzparams.filepath, 'ei_mu_snapshots.tikz'));
474 % close(gcf);
475 
476 
477 case 10
478  %tmp = load(fullfile(rbmatlabresult,'strange.mat'));
479  %Cmap = tmp.Cmap;
480  tmp = load(fullfile(rbmatlabresult,detailedfname));
481  detailed_data = tmp.detailed_data;
482  model = tmp.model;
483  plot_params.no_lines = 1;
484 
485  plot_params.no_axes = 1;
486  plot_params.transparent_background = 1;
487  plot_params.show_colorbar = 0;
488  %plot_params.shrink_factor = 1.13;
489  %plot_params.colormap = Cmap;
490  plot_params.clim = [0.1,0.6];
491 
492  reduced_data = gen_reduced_data(model, detailed_data);
493  model.N = size(detailed_data.RB,2);
494  model.M = size(detailed_data.QM,2);
495  reduced_data = extract_reduced_data_subset(model, reduced_data);
496 
497  cparams.range = cell(length(model.mu_ranges)+1,1);
498  cparams.range{1} = [1, model.nt];
499  cparams.range(2:end) = model.mu_ranges(:);
500  cparams.numintervals = 2*ones(length(model.mu_ranges)+1,1);
501  cgrid = cubegrid(cparams);
502 
503  parammat = cgrid.vertex;
504  parammat(:,1) = round(parammat(:,1));
505 
506  for i=1:length(parammat)
507  tstep = parammat(i,1);
508  newmodel = model.set_mu(model, parammat(i,2:end));
509  rb_sim_data = rb_simulation(newmodel, reduced_data);
510  rb_sim_data = rb_reconstruction(model, detailed_data, rb_sim_data);
511 
512  % transformed version
513  plot_element_data(model_data.grid, rb_sim_data.U(:,tstep), plot_params);
514 
515  mustring = strrep(strrep(strrep(strrep(mat2str(parammat(i,2:end)),' ', '_'),'[',''),']',''),'.','p');
516  fp = fullfile(imsavepath, params.model_type);
517  if ~exist(fp,'dir')
518  mkdir(fp);
519  end
520  fp = fullfile(fp, ['t_', num2str(tstep)]);
521  if ~exist(fp,'dir')
522  mkdir(fp);
523  end
524  fn = ['sample_mu_', mustring];
525  disp(['Processing ', fn, ' ...']);
526 
527  tikzparams.filename = fn;
528  tikzparams.filepath = fp;
529  tikzparams.save_colorbar = 1;
530 
531  plot_as_tikzfile(model, tikzparams);
532 
533  close(gcf);
534  end
535 
536 case 11
537  load('richards_affine_detailed_interpol');
538 
539  rdata = gen_reduced_data(model, detailed_data);
540 
541  model.N = size(detailed_data,2);
542  model.M = 10;
543  model.Mstrich = 1;
544  rdata2 = extract_reduced_data_subset(model, rdata);
545  model.Mstrich = 10;
546  rdata1 = extract_reduced_data_subset(model, rdata);
547 
548  TM1 = rdata1.TM_local{1}(1:10);
549  TM2 = rdata2.TM_local{1}(1:10);
550 
551  gl1 = rdata1.grid_local_ext{1};
552  gl2 = rdata2.grid_local_ext{1};
553 
554  if(any(gl1.CX(TM1) ~= gl2.CX(TM2)))
555  disp('CX differs');
556  end
557  if(any(gl1.CY(TM1) ~= gl2.CY(TM2)))
558  disp('CY differs');
559  end
560  if(any(any(gl1.X(gl1.VI(TM1,:)) ~= gl2.X(gl2.VI(TM2,:)))))
561  disp('X differs');
562  end
563  if(any(any(gl1.Y(gl1.VI(TM1,:)) ~= gl2.Y(gl2.VI(TM2,:)))))
564  disp('Y differs');
565  end
566  if(any(any(gl1.SX(TM1,:) ~= gl2.SX(TM2,:))))
567  disp('SX differs');
568  end
569  if(any(any(gl1.SY(TM1,:) ~= gl2.SY(TM2,:))))
570  disp('SY differs');
571  end
572  if(any(gl1.EL(TM1,:) ~= gl2.EL(TM2,:)))
573  disp('EL differs');
574  end
575  if(any(gl1.DC(TM1,:) ~= gl2.DC(TM2,:)))
576  disp('DC differs');
577  end
578  if(any(gl1.NX(TM1,:) ~= gl2.NX(TM2,:)))
579  disp('NX differs');
580  end
581  if(any(gl1.NY(TM1,:) ~= gl2.NY(TM2,:)))
582  disp('NY differs');
583  end
584  if(any(gl1.ECX(TM1,:) ~= gl2.ECX(TM2,:)))
585  disp('ECX differs');
586  end
587  if(any(gl1.ECY(TM1,:) ~= gl2.ECY(TM2,:)))
588  disp('ECY differs');
589  end
590  %% neighbours
591  NBI1 = gl1.NBI(TM1,:);
592  NBI2 = gl2.NBI(TM2,:);
593  if(any(gl1.CX(NBI1) ~= gl2.CX(NBI2)))
594  disp('CX differs');
595  end
596  if(any(gl1.CY(NBI1) ~= gl2.CY(NBI2)))
597  disp('CY differs');
598  end
599  if(any(any(gl1.X(gl1.VI(NBI1,:)) ~= gl2.X(gl2.VI(NBI2,:)))))
600  disp('X differs');
601  end
602  if(any(any(gl1.Y(gl1.VI(NBI1,:)) ~= gl2.Y(gl2.VI(NBI2,:)))))
603  disp('Y differs');
604  end
605  if(any(any(gl1.SX(NBI1,:) ~= gl2.SX(NBI2,:))))
606  disp('SX differs');
607  end
608  if(any(any(gl1.SY(NBI1,:) ~= gl2.SY(NBI2,:))))
609  disp('SY differs');
610  end
611  for i = 1:length(TM1)
612  end
613 
614 otherwise
615  error('step-number is unknown!');
616 end
617 
618 end
619 
620 %| \docupdate
621