rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ILocalizedOperator.m
1 classdef ILocalizedOperator < handle
2  % classdef ILocalizedOperator
3  % Interface for a <em>localized operator</em> that fulfills the so-called
4  % `H`-independent DOF dependence.
5  %
6  % A discrete operator `{\cal L}_h:{\cal V}_h \to {\cal W}_h` fulfills the
7  % <em>`H`-independent DOF dependence</em> if any operator evaluation
8  % restricted to a single DOF `\tau[{\cal L}_h[u_h]]` can be computed with a
9  % constant complexity `J` independently of the dimension `H` for all DOFs
10  % `\tau \in \Sigma({\cal W}_h)` and functions `u_h \in {\cal V}_h`.
11  %
12  % Example:
13  % - Grid based operators with local stencil for operator evaluations like
14  % most finite volume and finite element operators.
15  %
16  % Definitions:
17  % - Let `\Sigma({\cal V}_h):=\{\sigma_i\}_{i=1}^H` and
18  % `\Sigma({\cal W}_h):=\{\tau_i\}_{i=1}^H` be the DOFs of the discrete
19  % functions spaces `{\cal V}_h` and `{\cal W}_h`, respectively.
20  % - We denote a map of <em>interpolation DOF indices</em>
21  % `{\cal J}:\{1,\ldots,M\} \to \{1,\ldots,H\}` and
22  % - a map of <em>restriction DOF indices</em>
23  % `{\cal I}:\{1,\ldots,M\} \to \text{Pot}(\{1,\ldots,H\})`, such that
24  % ``\tau_{{\cal J}(m)}\left[
25  % {\cal L}_h \left[
26  % \sum_{m' \in {\cal I}(m)} \sigma_{m'}[u_h] \psi_{m'}
27  % \right]
28  % \right] =
29  % \tau_{{\cal J}(m)}[{\cal L}_h[u_h]]``
30  % for all `m=1,\ldots,M` and `u_h \in {\cal V}_h`.
31  % Here `\psi_i \in {\cal V}_h, i=1,\ldots,H` are basis functions of the
32  % discrete argument function space.
33  % - Sometimes it is desirable, to reduce the complexity of the discrete
34  % function spaces from `H` to `M` and `M_{\text{ext}}`. In this case, we
35  % obtain restricted DOF sets `\hat{\Sigma}_{M_{\text{ext}}}({\cal V}_h)` and
36  % `\hat{\Sigma}_{M}({\cal W}_h)`, and indices map `\hat{\cal J}_M` and
37  % `\hat{\cal I}_{M_{\text{ext}}}`.
38  %
39  properties (Constant, Abstract)
40  id; % a string name specifying the implemented operator
41  end
42 
43  methods (Abstract)
44 
45  % function [INC, INCoff, J] = apply(this, model, model_data, arg, NU_ind);
46  % compute operator evaluation on argument function for given
47  % <em>interpolation DOF indices</em> specified by 'NU_ind'
48  %
49  % Parameters:
50  % arg: the argument function `u_h \in {\cal V}_h`
51  % NU_ind: interpolation DOF indices
52  % `\nu_{\text{ind}} \subset \text{range}(\hat{\cal J}_M)`.
53  % ( Default: [] meaning `\{1,\ldots,H\}` )
54  %
55  % Return values:
56  % INC: vector of DOFs with indices `\nu_{\text{ind}}` of an
57  % operator evaluation
58  % INCoff: optionally stores the DOFs of a constant part of an
59  % operator. This has been added for compatibility with
60  % separable affine operators.
61  % J: Jacobian `D[{\cal L}_h]|_{u_h}` restricted to the vector of
62  % interpolation DOFs. This ought to be a matrix of size
63  % `M_{\text{ext}}\times M` with `M_{\text{ext}}:= \text{card}(
64  % \cup_{m\in\nu_{\text{ind}}} {\cal J}(m))`.
65  [INC, INCoff, J] = apply(this, model, model_data, arg, NU_ind);
66 
67 
68  % function ret_size = ret_size(this, model_data, NU_ind);
69  % returns the length of the return 'INC' value of an apply() method call.
70  %
71  % This should usually return `\text{card}(\nu_{\text{ind}})` or `H`.
72  %
73  % Parameters:
74  % NU_ind: interpolation DOF indices
75  % `\nu_{\text{ind}} \subset \text{range}(\hat{\cal J}_M)`.
76  % ( Default: [] meaning `\{1,\ldots,H\}` )
77  %
78  % Return values:
79  % ret_size: length of the return 'INC' value of an apply() method call.
80  ret_size = ret_size(this, model_data, NU_ind);
81 
82  % function arg_size = arg_size(this, model_data, NU_ind);
83  % returns the length of the required argument DOF vector for an apply()
84  % method call.
85  %
86  % This should usually return `\text{card}( \cup_{m\in\nu_{\text{ind}}}
87  % {\cal J}(m))` or `H`.
88  %
89  % Parameters:
90  % NU_ind: interpolation DOF indices
91  % `\nu_{\text{ind}} \subset \text{range}(\hat{\cal J}_M)`.
92  % ( Default: [] meaning `\{1,\ldots,H\}` )
93  %
94  % Return values:
95  % arg_size: length of the required argument DOF vector for an apply()
96  % method call.
97  arg_size = arg_size(this, model_data, NU_ind);
98 
99  % function [nmd,eind,eind_local] = compute_TM_global(this, model_data, TM_local);
100  % computes a subset of <em>restriction DOF indices</em>
101  % `\cup_{m \in T_{M_{\text{local}}}}
102  % \hat{{\cal I}}_{M_{\text{ext}}}(m)`
103  %
104  % The most common use-case is the computation of indices for grid cells in
105  % the reduced grid 'model_data.grid_local_ext'.
106  % For most operators the neighbors of the interpolation DOFs need to be
107  % computed somehow. Default implementations for this exist as
108  % - compute_TM_global_vertex()
109  % - compute_TM_global_edge().
110  %
111  % Parameters:
112  % TM_local: a set of local DOF indices at which the operator shall be
113  % interpolated `T_{M_{\text{local}}}`.
114  %
115  % Return values:
116  % nmd: updated 'model_data' structure with new index sets
117  % `{\cal I}_{M_{\text{ext}}}` and `{\cal J}_M`
118  % eind: a subset of <em>restriction DOF indices</em>
119  % `\cup_{m \in T_{M_{\text{local}}}} {\cal I}(m)`
120  % eind_local: the new localized set of restriciton DOF indices (relative
121  % to the new 'model_data'
122  % `\cup_{m \in T_{M_{\text{local}}}} {\cal I}_{M_{\text{ext}}}(m)`
123  [nmd,eind,eind_local] = compute_TM_global(this, model_data, TM_local);
124 
125  % function ipm = inner_product_matrix(this, model_data)
126  % return inner product matrix for range function space `{\cal Wh}`
127  %
128  % Return values:
129  % ipm: the inner product matrix of the range function space
130  ipm = inner_product_matrix(this, model_data);
131  end
132 
133  methods (Static)
134  function eind = compute_TM_global_vertex(model_data, TM_local)
135  % function eind = compute_TM_global_vertex(model_data, TM_local)
136  % Specialization of compute_TM_global() for grid based finite volume operators.
137  %
138  % If each DOF is connected to a grid cell of an underlying grid, this
139  % method selects to a set of \selected DOFs all DOFs connected to grid cells
140  % neighboring the vertices of all \em selected grid cells.
141  %
142  % Parameters:
143  % TM_local: a set of local DOF indices at which the operator shall be
144  % interpolated `T_{M_{\text{local}}}`.
145  %
146  % Return values:
147  % eind: a subset of <em>restriction DOF indices</em>
148  % `\cup_{m \in T_{M_{\text{local}}}}
149  % \hat{{\cal I}}_{M_{\text{ext}}}(m)`
150  grid = model_data.grid;
151  mask = zeros(1, grid.nelements);
152  nbi = grid.NBI(TM_local,:);
153  i = find(nbi > 0);
154  % get indices of TM_local's neighbour-neighbours
155  nnbi = grid.NBI(unique(nbi(i)),:);
156  ni = find(nnbi > 0);
157  [nnbuniq,tally] = unique(sort(nnbi(ni)),'first');
158  tally = [tally(2:end);length(nnbi(ni))+1] - tally;
159  mask(nnbuniq) = tally;
160  mask(nbi(i)) = 5;
161  mask(TM_local) = 6;
162  mask(mask < 2) = 0; % skip the elements which have no vertex with the
163  % given elements in TM_local in common
164  eind = find(mask);
165  end
166 
167  function eind = compute_TM_global_edge(model_data, TM_local, local_stencil_size)
168  % function eind = compute_TM_global_edge(model_data, TM_local, local_stencil_size)
169  % Specialization of compute_TM_global() for grid based finite volume operators.
170  %
171  % If each DOF is connected to a grid cell of an underlying grid, this
172  % method selects to a set of \selected DOFs all DOFs connected to grid cells
173  % neighboring the edges of all \em selected grid cells. The inclusion of
174  % edge-neighbors is repeated as often as indicated by
175  % 'local_stencil_size'
176  %
177  % Parameters:
178  % TM_local: a set of local DOF indices at which the operator shall be
179  % interpolated `T_{M_{\text{local}}}`.
180  % local_stencil_size: indicates how often the inclusion of
181  % edge-neighors shall be repeated. (Default: 1)
182  %
183  % Return values:
184  % eind: a subset of <em>restriction DOF indices</em>
185  % `\cup_{m \in T_{M_{\text{local}}}}
186  % \hat{{\cal I}}_{M_{\text{ext}}}(m)`
187  %
188  if nargin < 3
189  local_stencil_size = 1;
190  end
191  grid = model_data.grid;
192  eind = index_ext(grid, TM_local, local_stencil_size);
193  end
194 
195  function opdata = fill_opdata(rmodel, detailed_data)
196  % function opdata = fill_opdata(rmodel, detailed_data)
197  % This method can be called during empirical interpolation in order to
198  % collect arbitrary data (for example parameter independent or constant
199  % data) in a detailed data node.
200  %
201  % Parameters:
202  % detailed_data: of type @IDetailedData
203  %
204  % Return values:
205  % opdata: struct storing arbitrary data on the operator
206  opdata = [];
207  end
208 
209  function opdata = copy_extract_opdata(opdata_copy, rmodel, Mid)
210  % function opdata = fill_opdata(rmodel, detailed_data)
211  % Used by a copy constructor of IDetailedData objects which collect
212  % operator data with fill_opdata() methods.
213  %
214  % Parameters:
215  % opdata_copy: opdata structure to be copied
216  % Mid: Id of the 'detailed_data' structure, i.e.\ the
217  % interpolation DOFs, this operator is connected to. This
218  % can differ from the Id id.
219  %
220  % Return values:
221  % opdata: copied struct storing arbitrary data on the operator
222  opdata = [];
223  end
224 
225  end
226 end
Interface for a localized operator that fulfills the so-called -independent DOF dependence.
Interface class for the generation and storage of reduced basis spaces as described in Module (M2)...
Definition: IDetailedData.m:17