2 % Reduced data implementation
for linear stationary problems with finite
3 % element discretizations.
5 % @todo Describe the matrix components, or add a link to a paper...
9 Q_A; % number of components in matrix `A`
10 Q_f; % number of components in vector `f`
11 Q_l; % number of components in vector `l`
12 AN_comp; % reduced components `A^q`
13 fN_comp; % reduced components `f^q`
14 lN_comp; % reduced components `l^q`
15 Gff; % estimator matrix components `G_{ff}`
16 Gfa; % estimator matrix components `G_{fA}`
17 Gaa; % estimator matrix components `G_{AA}`
18 G; % estimator matrix components `G`
21 properties (SetAccess =
private, Dependent)
22 % number of reduced basis vectors stored in
this data node.
29 % computes the reduced basis vectors and matrices @b or implements a copy
37 error(
'LinStat.ReducedData constructor needs an argument');
38 elseif nargin == 2 && isa(rmodel,
'IReducedModel') && isa(detailed_data,
'IDetailedData')
39 fill_fields(res, rmodel, detailed_data);
41 fns = properties(rmodel);
42 fns = setdiff(fns,'N');
44 res.(fns{i}) = rmodel.(fns{i});
46 % res.handle_to_last_subset = arg1.handle_to_last_subset;
48 error(
'Did not find constructor for your arguments');
52 function N =
get.N(
this)
53 if ~isempty(this.AN_comp{1})
54 N = size(this.AN_comp{1}, 2);
60 function reduced_data_subset = extract_reduced_data_subset(
this, rmodel)
61 %
function reduced_data_subset = extract_reduced_data_subset(
this, rmodel)
66 % number of reduced basis vectors to be used in the
67 %
'reduced_data_subset'
71 % deep copy of
this data node but with a number of
72 % reduced basis vectors indicated by
'rmodel.N'. If
73 % the number did not change, only a handle copy is
77 % extract correct N-sized submatrices and subvectors from reduced_data
79 error(
'N too large for current size of reduced basis!');
87 reduced_data_subset.AN_comp = ...
88 subblock_sequence(this.AN_comp,1:N,1:N);
89 reduced_data_subset.fN_comp = subblock_sequence(this.fN_comp,1:N);
90 reduced_data_subset.lN_comp = subblock_sequence(this.lN_comp,1:N);
92 % inner product matrix of Riesz-representers of residual components:
93 reduced_data_subset.Gff = this.Gff;
94 rQ_f = length(reduced_data_subset.fN_comp);
95 Q_a = length(reduced_data_subset.AN_comp);
96 reduced_data_subset.G = this.G(1:(rQ_f+N*Q_a),1:(rQ_f+N*Q_a));
97 reduced_data_subset.Q_f = rQ_f;
99 reduced_data_subset =
this;
103 function conds = get_conds(
this)
110 methods(Access=private)
112 function fill_fields(reduced_data, dmodel, detailed_data)
113 % function fill_fields(reduced_data, dmodel, detailed_data)
114 % actually fills the reduced data fields
116 model = dmodel.descr;
118 model.decomp_mode = 1; % == components
120 [A_comp,f_comp] = model.operators(model,detailed_data.model_data);
122 Q_A = length(A_comp);
123 reduced_data.Q_A = Q_A;
124 Q_f = length(f_comp);
125 reduced_data.Q_f = Q_f;
127 reduced_data.AN_comp = cell(1,length(A_comp));
129 reduced_data.AN_comp{q} = ...
130 detailed_data.RB
'*A_comp{q}*detailed_data.RB;
133 reduced_data.fN_comp = cell(1,length(f_comp));
135 reduced_data.fN_comp{q} = ...
136 detailed_data.RB' * f_comp{q};
139 if model.compute_output_functional
140 % assumption: nonparametic output functional, then simple RB
141 % evaluation possible
143 model.operators_output(model,detailed_data.
model_data);
144 Q_l = length(l_comp);
145 reduced_data.lN_comp = cell(1,Q_l);
147 reduced_data.lN_comp{q} = detailed_data.RB
' * l_comp{q};
149 reduced_data.Q_l = Q_l;
152 % plus error estimation quantities
154 % G = (v_r^q, v_r^q) = v_r^q' * K * v_r^q
155 % with {v_r^q}_q = (v_f^q, v_a^qq
')_{qq'}
156 % G = [Gff, Gfa; Gfa
', Gaa];
158 % (v_f^q,v_f^q') = v_f^q
' * K * v_f^q
160 % matrices of coefficient vectors of Riesz-representers:
161 % K * v_f^q = f^q (coefficient vector equations)
162 K = model.get_inner_product_matrix(detailed_data.model_data);
163 % search solution in H10, i.e. set dirichlet DOFs
165 N = get_rb_size(detailed_data);
167 v_f = zeros(size(detailed_data.RB,1),Q_f);
168 K_v_f = zeros(size(detailed_data.RB,1),Q_f);
170 K_v_f(:,q) = f_comp{q};
171 v_f(:,q) = K \ f_comp{q};
177 K_v_a{n} = zeros(size(K,1),Q_A);
178 v_a{n} = zeros(size(K,1),Q_A);
180 K_v_a{n}(:,q) = (A_comp{q}*detailed_data.RB(:,n));
181 v_a{n}(:,q) = K \ K_v_a{n}(:,q);
185 % compute matrix G components = [G_ff, G_fa{n}; G_fa{n}', G_aa{n}];
186 reduced_data.Gff = v_f
' * K_v_f;
187 reduced_data.Gfa = cell(1,N);
189 reduced_data.Gfa{n} = v_f' * K_v_a{n};
191 reduced_data.Gaa = cell(N,N);
194 reduced_data.Gaa{n1,n2} = v_a{n1}
' * K_v_a{n2};
198 % finally assemble G = [G_ff, G_fa{n}; G_fa{n}', G_aa{n}];
201 G(1:Q_f,1:Q_f) = reduced_data.Gff;
203 G(1:Q_f,Q_f+(n-1)*Q_A +(1:Q_A)) = ...
205 G(Q_f+(n-1)*Q_A +(1:Q_A),1:Q_f) = ...
206 reduced_data.Gfa{n}
';
210 G(Q_f+(n1-1)*Q_A+(1:Q_A),Q_f+(n2-1)*Q_A +(1:Q_A)) = ...
211 reduced_data.Gaa{n1,n2};
ModelData model_data
struct holding -dimensional model data, which is needed for an IDetailedModel.detailed_simulation(), e.g. a grid object.
reduced model for linear stationary problems as given by a LinStat.DetailedModel. ...
Reduced basis implementation for linear stationary PDEs.
Reduced data implementation for linear stationary problems with finite element discretizations.
So far, this only implements the SimpleDetailedData class.
N
number of reduced basis vectors stored in this data node.
function reduced_data_subset = extract_reduced_data_subset(IReducedData reduced_data)
Extracts a subset of the reduced_data generated by gen_reduced_data().
Interface class for the generation and storage of offline matrices and vectors as described in Module...