1 function [RBext,info] = RB_extension_max_error_snapshot(model,detailed_data)
2 %
function [RBext,par] = RB_extension_max_error_snapshot(model,detailed_data)
4 %
function computing the snapshot
for parameter mu which is set in
5 % params, which causes the largest increase of the posterior error estimator
6 % in time. This snapshot is orthonormalized with respect to detailed_data.RB and
9 % Occasionally, the selected snapshot is already within the span
10 % of the reduced basis RB, then the second max-error snapshot is taken,
13 % The values returned in info are:
14 % snapshot: the snapshot before orthonormalization
15 % ti: the absolute simulation time of the snapshot
16 % rank: rank of the snapshot in the list of
17 % error-prediction.increases
19 % required fields of params
20 % detailed_simulation_algorithm: name of the
function to be called
21 % with parameters (grid,params) and resulting in DOF-vectors
22 % e.g. fv_conv_diff_operators
23 % or detailed_simulation with additional fields
24 % mu_names: cell array of names of the parameter-vector entries
25 % inner_product_matrix_algorithm : function computing the correct inner
26 % product matrix between function DOF-vectors
28 % Bernard Haasdonk 13.10.2005
32 % perform full and RB simulation
33 %U = fv_conv_diff(params);
35 % grid = grid_geometry(params);
38 % take care to remove some changed fields from model and detailed
39 % data, such that filecaching works!!! in RB_extension_algorithm
42 ifm = model.filecache_ignore_fields_in_model;
43 for i = 1:length(model.filecache_ignore_fields_in_model);
44 if isfield(model,ifm{i})
45 tmp_model = rmfield(tmp_model,ifm{i});
48 ifm = model.filecache_ignore_fields_in_detailed_data;
49 dim_RB = size(model.get_rb_from_detailed_data(detailed_data));
50 tmp_detailed_data = ...
51 model.set_rb_in_detailed_data(detailed_data, zeros(dim_RB(1),0));
52 for i = 1:length(model.filecache_ignore_fields_in_detailed_data);
53 if isfield(detailed_data,ifm{i})
54 tmp_detailed_data = rmfield(tmp_detailed_data,ifm{i});
57 % U = fv_conv_diff_operators(grid,params);
61 % perform RB-simulation
62 reduced_data = gen_reduced_data(model,detailed_data);
63 simulation_data = rb_simulation(model,reduced_data);
64 Urec = rb_reconstruction(model,detailed_data,simulation_data);
65 %[A,pe] = fv_conv_diff_galerkin(RB,params);
67 simulation_data.Delta = fv_error(Urec,U,detailed_data.W,model);
69 % rank timesteps according to error increase
70 post_est_diff = simulation_data.Delta
' - ...
71 [0; simulation_data.Delta(1:end-1)'];
72 [m,ti] = sort(-post_est_diff); % -> post_est_diff(ti) ist sortiert
74 % select snapshot by following rank-list
78 W = model.get_inner_product_matrix(detailed_data);
82 % orthonormalize snapshot at rank ra
83 Uproj = U(:,ti(ra)) - detailed_data.RB * (detailed_data.RB' * W * U(:,ti(ra)));
85 % if nonzero projection error -> end with new snapshot
86 % Uproj = Uproj/norm(Uproj).*params.vec_to_func;
87 % due to scaling, no precise orthonormalization is obtained. So perform
88 % explicit orthonormalization
89 RBtmp = orthonormalize([detailed_data.RB,Uproj],W);
90 if size(RBtemp,2)> size(detailed_data.RB,2)
91 Uproj = RBtmp(:,end); %.*grid.Ainv(:).^(0.5);
94 error('accuracy problem, should not reach this point!!');
102 info.snapshot = U(:,ra);
103 info.ti = (ti(ra)-1)*params.T/params.nt;
function varargout = filecache_function(funcptr, varargin)
function used for file-caching other function calls.