2 % Implementation of the detailed data
interface for the
ARE
4 % This
class keeps the reduced basis and the information about the
5 % calculation of \gamma.
7 % Andreas Schmidt, 2016
10 % Store the reduced basis:
14 % The size of the reduced basis
17 % Information that was returned by the basis generation algorithm
20 % Handler
for the norm of the inverse
operator norm ||L^{-1}||
21 % The field gamma is filled by the corresponding gamma_calculation
22 gamma = {}; % Information returned by gen_detailed_data from the gamma interface
23 gamma_mode; % Name of the gamma mode, stored within
this detailed data instance
25 % Model data handle, just
for the easier calculation of the reduced
30 properties(SetAccess=
protected)
31 % This is a handle to the gamma calculation interface. This can be
32 % any
class that
implements the GAMMACALCULATORINTERFACE class.
35 gamma_initialized = false;
42 this.model_data = model_data;
43 this.algorithm =
Greedy.LRFG.Algorithm(model, model_data);
45 if ~isempty(model.RB_gamma_mode)
46 this.set_gamma_mode(model);
50 function s = get_rb_size(this)
51 % GET_RB_SIZE returns the size of the reduced basis
55 function set_gamma_mode(this, model)
56 % SET_GAMMA_CALCULATION set the mode for the gamma calculation
57 % If you change the gamam mode, the state will be set to
58 % uninitialized, which means you first have to run
59 % INITIAILIZE_GAMMA in order to be able to calculate
60 mode = model.RB_gamma_mode;
61 if isempty(mode) || strcmp(mode, 'none')
62 this.gamma_calculation = [];
63 this.gamma_initialized = true;
67 this.gamma_calculation = eval([model.problem_type(), ...
68 '.GammaCalculation.', mode, '()']);
70 this.gamma_initialized = false;
71 this.gamma_mode = mode;
74 function this = initialize_gamma(this, model, model_data)
75 % INITIALIZE_GAMMA Call the gen_detailed_data method in the
76 % gamma calculation interface and populate the data to the
77 % field in detailed_data
78 if isempty(this.gamma_calculation)
79 error('Cannot initialize since no gamma calculation is defined');
82 this.gamma = this.gamma_calculation.gen_detailed_data(model, ...
84 this.gamma_initialized = true;
87 function dd = extract_subbasis(this, N)
88 % EXTRACT_SUBBASIS Extract a part of the basis
94 dd.RB_V = dd.RB_V(:, N);
95 dd.RB_W = dd.RB_W(:, N);
100 function this = initialize_with_bgen(model, model_data)
101 % This function is used in the gen_detailed_data function and
103 % instantiates the basis building procedure:
104 pt = model.problem_type();
105 this = eval([pt,'.DetailedData(model, model_data)']);
107 % Set the parameters, if there are any:
108 if ~isempty(model.RB_M_train)
109 M_train = model.RB_M_train;
110 if isa(M_train, 'char')
111 M_train = eval(['ParameterSampling.',M_train,'()']);
112 elseif isa(M_train, 'ParameterSampling.Interface')
113 elseif ismatrix(M_train)
116 error(['Please set the property RB_M_train to a valid ', ...
119 % And finally, set the M_train value
120 this.algorithm.M_train = M_train;
123 % Run the actual algorithm
124 [V,W,info] = this.algorithm.run();
128 this.RB_size = size(V,2);
131 % Initialize the gamma stuff:
132 this.set_gamma_mode(model);
133 if ~this.gamma_initialized
134 this.initialize_gamma(model, model_data);
Abstract OOP model implementation interface.
Implementation of the detailed data interface for the ARE.
Implementation of the parametric algebraic Riccati equation.
Customizable implementation of an abstract greedy algorithm.