rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
ReducedData.m
1 classdef ReducedData < Greedy.User.IReducedDataNode
2  % Reduced data implementation for linear evolution problems with finite
3  % volume discretizations
4  %
5  % See @ref HO08a for details on the implementation of the reduced matrices
6  % and vectors.
7 
8 
9  properties
10  % Dof vectors of projections `\left\{{ \cal P }_{\text{red}}[u_0^q]
11  % \right\}_{q=1}^{Q_{u_0}}`.
12  %
13  % @sa LinEvol.ReducedModel.rb_init_values() for details.
14  a0;
15 
16  % `Q_I` reduced matrix for implicit operator `{\cal L}_{h,I}`
17  %
18  % The matrix entries are:
19  % ``({ \bf L}_I^q)_{ij} = \int \varphi_i {\cal L}^q_{h,I}[\varphi_j]``
20  % for `i,j=1,\ldots,N` and `q=1,\ldots,Q_I`.
21  LL_I;
22 
23  % `Q_E`-sequence of reduced matrices for explicit operator `{\cal L}_{h,E}`
24  %
25  % The matrix entries are:
26  % ``({ \bf L}_E^q)_{ij} = \int \varphi_i {\cal L}^q_{h,E}[\varphi_j]``
27  % for `i,j=1,\ldots,N` and `q=1,\ldots,Q_E`.
28  LL_E;
29 
30  % `Q_b`-sequence of reduced vectors for constant contributions `b_h`
31  %
32  % The matrix entries are:
33  % ``({ \bf b})_{i} = \int \varphi_i b^q_h``
34  % for `i=1,\ldots,N` and `q=1,\ldots,Q_b`.
35  bb;
36 
37  % `Q_I \cdot Q_I`-sequence of gram matrices
38  %
39  % The matrix entries are:
40  % ``({ \bf K}_{II}^{q_1,q_2})_{ij} = \int {\cal L}^{q_1}_{h,I}[\varphi_i] {\cal L}^{q_2}_{h,I}[\varphi_j]``
41  % for `i,j=1,\ldots,N` and `q_1,q_2=1,\ldots,Q_I`.
42  K_II;
43 
44  % `Q_I \cdot Q_E`-sequence of gram matrices
45  %
46  % The matrix entries are:
47  % ``({ \bf K}_{IE}^{q_1,q_2})_{ij} = \int {\cal L}^{q_1}_{h,I}[\varphi_i] {\cal L}^{q_2}_{h,E}[\varphi_j]``
48  % for `i,j=1,\ldots,N` and `q_1=1,\ldots,Q_I, q_2=1,\ldots,Q_E`.
49  K_IE;
50 
51  % `Q_E \cdot Q_E`-sequence of gram matrices
52  %
53  % The matrix entries are:
54  % ``({ \bf K}_{EE}^{q_1,q_2})_{ij} = \int {\cal L}^{q_1}_{h,E}[\varphi_i] {\cal L}^{q_2}_{h,E}[\varphi_j]``
55  % for `i,j=1,\ldots,N` and `q_1,q_2=1,\ldots,Q_E`.
56  K_EE;
57 
58  % `Q_I \cdot Q_b`-sequence of vectors
59  %
60  % The vector entries are:
61  % ``({ \bf m}_I^{q_1,q_2})_i = \int {\cal L}^{q_1}_{h,I}[\varphi_i] b_h^{q_2}``
62  % for `i=1,\ldots,N` and `q_1=1,\ldots,Q_I, q_2=1,\ldots,Q_b`.
63  m_I;
64 
65  % `Q_E \cdot Q_b`-sequence of vectors
66  %
67  % The vector entries are:
68  % ``({ \bf m}_E^{q_1,q_2})_i = \int {\cal L}^{q_1}_{h,E}[\varphi_i] b_h^{q_2}``
69  % for `i=1,\ldots,N` and `q_1=1,\ldots,Q_E, q_2=1,\ldots,Q_b`.
70  m_E;
71 
72  % `Q_b \cdot Q_b`-sequence of scalars
73  %
74  % The scalars are:
75  % ``{ \bf m}^{q_1,q_2} = \int b_h^{q_1} b_h^{q_2}``
76  % and `q_1,q_2=1,\ldots,Q_b`.
77  m;
78 
79  % in case of output functional this is a `Q_s`-sequence of vectors.
80  %
81  % The vector entries are:
82  % ``({ \bf s}^q)_i = s(\varphi_i)``
83  % for `i=1,\ldots,N` and `q_1=1,\ldots,Q_s`
84  s_RB;
85 
86  % in case of output functional this is a `Q_s`-sequence of scalars.
87  %
88  % The scalars are:
89  % ``{ \bf s}_{l^2}^q = \|s(\varphi_1), \ldots, s(\varphi_N)\|_{l^2}``
90  % for `q_1=1,\ldots,Q_s`
91  s_l2norm;
92  end
93 
94  properties (SetAccess = private, Dependent)
95  % number of reduced basis vectors stored in this data node.
96  N;
97  end
98 
99  properties (SetAccess = private)
100  % number of collateral reduced basis vectors stored in this data node.
101  M = 0;
102  % number of collateral reduced basis vectors used for error estimation
103  Mstrich = 0;
104  end
106  methods
107 
108  function rd = ReducedData(rmodel, detailed_data)
109  % Constructor for the generation of the reduced matrices and vectors.
110  %
111  % Parameters:
112  % rmodel: of type LinEvol.ReducedModel
113  % detailed_data: of type IDetailedData
114  %
115  %
116  if nargin == 0
117  error('LinEvol.ReducedData constructor needs an argument');
118  elseif nargin == 2 && isa(rmodel, 'IReducedModel') ...
119  && isa(detailed_data, 'LinEvol.ReducedData')
120  copy = detailed_data;
121  copy_extract(rd, copy, rmodel);
122  elseif nargin == 2 && isa(rmodel, 'IReducedModel') && isa(detailed_data, 'IDetailedData')
123  fill_fields(rd, rmodel, detailed_data);
124  else
125  error('Did not find constructor for your arguments');
126  end
127  end
128 
129  function N = get.N(this)
130  if ~isempty(this.a0)
131  N = size(this.a0{1},2);
132  else
133  N = 0;
134  end
135  end
136 
137  function yesno = needs_subset_copy(this, rmodel)
138  % function yesno = needs_subset_copy(this, rmodel)
139  % @copybrief .Greedy.User.IReducedDataNode.needs_subset_copy()
140  %
141  % @copydetails .Greedy.User.IReducedDataNode.needs_subset_copy()
142  %
143  % Parameters:
144  % rmodel: of type LinEvol.ReducedModel
145 
146  yesno = this.N ~= rmodel.N;
147  end
148 
149 
150  function conds = get_conds(this)
151  disp('get_conds needs to be implemented for LinEvol.ReducedData');
152  conds = [];
153  end
154 
155  end
156 
157  methods (Access=private)
158  function fill_fields(this, rmodel, detailed_data)
159  % function fill_fields(this, rmodel, detailed_data)
160 
161  this.a0 = rb_init_values_separable(rmodel, detailed_data, 1);
162  [this.LL_I, this.LL_E, this.bb, ...
163  this.K_II, this.K_IE, this.K_EE, ...
164  this.m_I, this.m_E, this.m ] ...
165  = LinEvol.ReducedData.rb_operators(rmodel, detailed_data, 1);
166  if isfield(rmodel.descr,'output_function_ptr')
167  d = rmodel.descr;
168  md = detailed_data.model_data;
169  [OO, this.s_l2norm] = d.operators_output(d, md);
170  this.s_RB = OO' * detailed_data.RB;
171  end
172  end
173 
174  function copy_extract(this, copy, rmodel)
175  % function copy_extract(this, copy, rmodel)
176  % @copybrief IReducedModelextract_reduced_data_subset()
177  %
178  % Parameters:
179  % rmodel: reduced model of type LinEvol.ReducedModel indicating the
180  % number of reduced basis vectors to be used in the
181  % 'reduced_data_subset'
182 
183  % extract correct N-sized submatrices and subvectors from reduced_data
184  if rmodel.N > copy.N
185  error('N too large for current size of reduced basis!');
186  end
187 
188  N = rmodel.N;
189  this.a0 = subblock_sequence(copy.a0,1:N);
190  this.LL_I = subblock_sequence(copy.LL_I,1:N,1:N);
191  this.LL_E = subblock_sequence(copy.LL_E,1:N,1:N);
192  this.bb = subblock_sequence(copy.bb,1:N);
193  this.K_EE = subblock_sequence(copy.K_EE,1:N,1:N);
194  this.K_IE = subblock_sequence(copy.K_IE,1:N,1:N);
195  this.K_II = subblock_sequence(copy.K_II,1:N,1:N);
196  this.m_I = subblock_sequence(copy.m_I,1:N);
197  this.m_E = subblock_sequence(copy.m_E,1:N);
198  this.m = copy.m;
199  % if ~isempty(copy.T)
200  % this.T = copy.T(1:N,1:N);
201  % end
202 
203  model = rmodel.detailed_model;
204  if isfield(model,'name_output_functional')
205  this.s_RB = copy.s_RB(1:N);
206  this.s_l2norm = copy.s_l2norm;
207  end
208 
209  end
210  end
211 
212  methods(Static)
213  %
214  %
215  % Parameters:
216  % rmodel : of type LinEvol.ReducedModel
217  % detailed_data : of type Greedy.DataTree.Detailed.RBLeafNode
218  [LL_I, LL_E, bb, K_II, K_IE, K_EE, m_I, m_E, m] = rb_operators(rmodel, detailed_data, decomp_mode);
219  end
220 end