rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
RB_extension_PCA_fixspace_flexible_hp.m
1 function [RBext, dummy] = RB_extension_PCA_fixspace_flexible_hp(model, ...
2  detailed_data)
3 %function [RBext, dummy] = RB_extension_PCA_fixspace_flexible_hp(model, ...
4 % detailed_data)
5 %
6 % needed for the hp algorithm
7 % modified version of RB_extension_PCA_fixspace_flexible
8 % change: return a RB basis extension with nr_nodes basis vectors
9 % nr_nodes large enought to ensure POD error < error/(rho1*rho2)
10 %
11 % function computing a RB basis extension for given parameters by
12 % the POD-Greedy algorithm.
13 %
14 % The choice is made by complete time simulation for the current parameter `mu`
15 % set via last call to set_mu() and taking the principal component of PCA
16 % keeping the RB as fixspace. This single vector is orthonormalized with
17 % respect to RB and returned in RBext.
18 %
19 % Return argument dummy is a superfluous argument not used in this routine, but
20 % necessary for a uniform argument list compatible with other extension
21 % algorithms.
22 %
23 % required fields of model:
24 % mu_names : cell array of names of the parameter-vector
25 % entries
26 %
27 % return values:
28 % RBext : the new reduced basis vector meant for extension of the current
29 % reduced basis space
30 % dummy : dummy variable making argument list compatible with other extenstion
31 % algorithms.
32 %
33 
34 % original: Bernard Haasdonk 14.10.2005
35 % modified: David Kreplin, 12.04.2013
36 
37 dummy = [];
38 
39 % cache detailed simulation
40 % sim_data = cached_detailed_simulation(model,detailed_data,sim_params);
41 %model_data.grid = detailed_data.grid;
42 %model_data.W = detailed_data.W;
43 
44 %tmp_params.mu = sim_params.mu;
45 %model = model.set_mu(model,mu);
46 % use detailed_data as model_data here
47 
48 % take care, that the arguments do not change throughout parameter variation!
49 % detailed_data: RB_info, V, W
50 % model: N, Nmax, base_model
51 
52 
53 % take care to remove some changed fields from model and detailed
54 % data, such that filecaching works!!! in RB_extension_algorithm
55 % !!!
56 tmp_model = model;
57 ifm = model.filecache_ignore_fields_in_model;
58 for i = 1:length(model.filecache_ignore_fields_in_model);
59  if isfield(model,ifm{i})
60  tmp_model = rmfield(tmp_model,ifm{i});
61  end;
62 end;
63 ifm = model.filecache_ignore_fields_in_detailed_data;
64 dim_RB = size(model.get_rb_from_detailed_data(detailed_data));
65 tmp_detailed_data = ...
66  model.set_rb_in_detailed_data(detailed_data, zeros(dim_RB(1),0));
67 for i = 1:length(model.filecache_ignore_fields_in_detailed_data);
68  if isfield(detailed_data,ifm{i})
69  tmp_detailed_data = rmfield(tmp_detailed_data,ifm{i});
70  end;
71 end;
72 
73 sim_data = filecache_function(@detailed_simulation,tmp_model, ...
74  tmp_detailed_data);
75 
76 U = model.get_dofs_from_sim_data(sim_data);
77 
78 % select single vector for extension
79 %keyboard;
80 [RBextall,evalues] = PCA_fixspace_evalues(U,...
81  model.get_rb_from_detailed_data(detailed_data), ...
82  model.get_inner_product_matrix(detailed_data));%, ...
83  %model.nr_extension_modes);
84 
85  nr_nodes=1;
86  % calculating the POD error:
87 error = sqrt(sum(evalues(2:end)));
88 % expand reduced basis until POD error < error/(roh1*roh2)
89 while error > model.error_tol1/(model.rho*model.rho_POD)
90  nr_nodes=nr_nodes+1;
91  error = sqrt(sum(evalues(nr_nodes+1:end).^2));
92 end;
93 
94 if ~isempty(RBextall)
95  RBext = RBextall(:, 1:nr_nodes);
96 else
97  disp('warning: did not find basis extension in PCA_fixspace!!!');
98  RBext = [];
99 end;
100 
101 %disp('check new basis-vector!!')
102 %keyboard;
103 
function varargout = filecache_function(funcptr, varargin)
function used for file-caching other function calls.
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1
function [ RBext , dummy ] = RB_extension_PCA_fixspace_flexible(model, detailed_data)
function computing a RB basis extension for given parameters by the POD-Greedy algorithm.