rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ReducedData.m
1 classdef ReducedData < IReducedData
2  % Reduced data implementation for linear stationary problems of the form `L_I u = f`.
3  %
4  % See @ref HO08a for details on the implementation of the reduced matrices
5  % and vectors.
6 
7 
8  properties
9  Q_A; % number of components in matrix `L_I`
10  Q_f; % number of components in vector `f`
11  Q_l; % number of components in vector `l`
12  AN_comp; % reduced components `L_I^q`
13  fN_comp; % reduced components `f^q`
14  lN_comp; % reduced components `l^q`
15  KII; % error estimator matrices `L_I^q,L_I^q'`
16  mI; % error estimator vectors `L_I^q,f^q'`
17  m; % error estimator scalars `f^q,f^q'`
18  end
19 
20  properties (SetAccess = private, Dependent)
21  % number of reduced basis vectors stored in this data node.
22  N;
23  end
24 
25  properties (SetAccess = private)
26  % number of collateral reduced basis vectors stored in this data node.
27  M = 0;
28  % number of collateral reduced basis vectors used for error estimation
29  Mstrich = 0;
30  end
31 
32  methods
33 
34  function rd = ReducedData(rmodel, detailed_data)
35  % Constructor for the generation of the reduced matrices and vectors.
36  %
37  % Parameters:
38  % rmodel: of type LinStatDune.ReducedModel
39  % detailed_data: of type IDetailedData
40  %
41  %
42  if nargin == 0
43  error('LinStatDune.ReducedData constructor needs an argument');
44  elseif nargin == 2 && isa(rmodel, 'IReducedModel') ...
45  && isa(detailed_data, 'LinStatDune.ReducedData')
46  copy = detailed_data;
47  copy_extract(rd, copy, rmodel);
48  elseif nargin == 2 && isa(rmodel, 'IReducedModel') && isa(detailed_data, 'IDetailedData')
49  fill_fields(rd, rmodel, detailed_data);
50  elseif nargin == 1 && isa(rmodel, 'LinStatDune.ReducedData')
51  fns = properties(rmodel);
52  fns = setdiff(fns,'N');
53  for i = 1:length(fns)
54  rd.(fns{i}) = rmodel.(fns{i});
55  end
56  else
57  error('Did not find constructor for your arguments');
58  end
59  end
60 
61  function N = get.N(this)
62  if ~isempty(this.fN_comp)
63  N = length(this.fN_comp{1});
64  else
65  N = 0;
66  end
67  end
68 
69  function reduced_data_subset = extract_reduced_data_subset(this, rmodel)
70  % function reduced_data_subset = extract_reduced_data_subset(this, rmodel)
71  % @copybrief IReducedModel.extract_reduced_data_subset()
72  %
73  % Parameters:
74  % rmodel: reduced model of type LinStat.ReducedModel indicating the
75  % number of reduced basis vectors to be used in the
76  % 'reduced_data_subset'
77  %
78  % Return values:
79  % reduced_data_subset: object of type LinStat.ReducedData which is a
80  % deep copy of this data node but with a number of
81  % reduced basis vectors indicated by 'rmodel.N'. If
82  % the number did not change, only a handle copy is
83  % returned.
84 
85  if this.N ~= rmodel.N
86  % extract correct N-sized submatrices and subvectors from reduced_data
87  if rmodel.N > this.N
88  error('N too large for current size of reduced basis!');
89  end
90 
91  % create a copy
92  reduced_data_subset = LinStatDune.ReducedData(this);
93 
94  N = rmodel.N;
95 
96  reduced_data_subset.AN_comp = ...
97  subblock_sequence(this.AN_comp,1:N,1:N);
98  reduced_data_subset.fN_comp = subblock_sequence(this.fN_comp,1:N);
99 
100 
101  %%%% TODO: Implement the output functinal matrix
102 % reduced_data_subset.lN_comp = subblock_sequence(this.lN_comp,1:N);
103 
104  reduced_data_subset.KII = subblock_sequence(this.KII, 1:N,1:N);
105  reduced_data_subset.mI = subblock_sequence(this.KII, 1:N);
106  else
107  reduced_data_subset = this;
108  end
109  end
110 
111  function conds = get_conds(this)
112 
113  disp('get_conds needs to be implemented for LinStat.ReducedData');
114  conds = [];
115  end
116  end
117 
118  methods(Access=private)
119 
120  function fill_fields(reduced_data, dmodel, detailed_data)
121  % function fill_fields(reduced_data, dmodel, detailed_data)
122  % actually fills the reduced data fields
123 
124  model = dmodel.descr;
125 
126  model.decomp_mode = 1; % == components
127 
128  A_str = '<Laplace[phi],phi>_L2';
129  f_str = '<RHS,phi>_L2';
130  ret = model.mexptr('rb_operators', 1, {A_str, f_str}, {});
131  reduced_data.AN_comp = ret.(A_str);
132  reduced_data.fN_comp = cellfun(@(X)X', ret.(f_str), 'UniformOutput', false);
133 
134  reduced_data.Q_A = length(reduced_data.AN_comp);
135  reduced_data.Q_f = length(reduced_data.fN_comp);
136 
137  KII_str = '<Laplace[phi],Laplace[phi]>_L2';
138  mI_str = '<Laplace[phi],RHS>_L2';
139  m_str = '<RHS,RHS>_L2';
140  ret = model.mexptr('rb_operators', 1, {KII_str, mI_str, m_str}, {});
141  reduced_data.KII = ret.(KII_str);
142  reduced_data.mI = ret.(mI_str);
143  reduced_data.m = ret.(m_str);
144 
145  if model.compute_output_functional
146  % assumption: nonparametic output functional, then simple RB
147  % evaluation possible
148 
149  %%%%%%%%% TODO: Implement output functional %%%%%%%%%%
150  l_str = '<Output,phi>_L2';
151  ret = model.mexptr('rb_operators', 1, {l_str}, {});
152  l_comp = ret.(l_str);
153  reduced_data.Q_l = length(l_comp);
154  end;
155 
156  end
157  end
158 end
159 
Reduced basis implementation for linear stationary PDEs.
Reduced data implementation for linear stationary problems with finite element discretizations.
Definition: ReducedData.m:18
Reduced data implementation for linear stationary problems of the form .
Definition: ReducedData.m:18
This is the interface for a reduced model providing methods to compute low dimensional reduced simula...
Definition: IReducedModel.m:17
N
number of reduced basis vectors stored in this data node.
Definition: ReducedData.m:90
Interface class for the generation and storage of offline matrices and vectors as described in Module...
Definition: IReducedData.m:17
Interface class for the generation and storage of reduced basis spaces as described in Module (M2)...
Definition: IDetailedData.m:17