rbmatlab 0.10.01
rbasis/+NonlinEvol/EiRbReducedDataNode.m
00001 classdef EiRbReducedDataNode < Greedy.User.IReducedDataNode
00002   % Reduced data implementation for non-linear evolution problems with finite
00003   % volume discretizations.
00004   %
00005   % See @ref DHO11 for details on the implementations of the reduced matrices
00006   % and vectors.
00007 
00008   properties(Dependent, SetAccess=private)
00009     % Dof vectors of projections `\left\{{ \cal P }_{\text{red}}[u_0^q]
00010     % \right\}_{q=1}^{Q_{u_0}}`.
00011     %
00012     % @sa NonlinEvol.ReducedModel.rb_init_values() for details.
00013     a0;
00014 
00015     % `Q_I` reduced matrix for implicit operator `{\cal L}_{h,I}` if it is
00016     % affinely decomposable.
00017     %
00018     % The matrix entries are:
00019     % ``({ \bf L}_I^q)_{ij} = \int \varphi_i {\cal L}^q_{h,I}[\varphi_j]``
00020     % for `i,j=1,\ldots,N` and `q=1,\ldots,Q_I`.
00021     LL_I;
00022 
00023     % `Q_b`-sequence of reduced vectors for constant contributions `b_h`
00024     %
00025     % The matrix entries are:
00026     % ``({ \bf b})_{i} = \int \varphi_i b^q_h``
00027     % for `i=1,\ldots,N` and `q=1,\ldots,Q_b`.
00028     bb_I;
00029 
00030     % reduced basis mass matrix.
00031     %
00032     % The matrix entries are:
00033     % ``({ \bf M })_{ij} = \int \varphi_i \varphi_j``
00034     % for `i,j=1,\ldots,N`
00035     Nmass;
00036 
00037     % empirical interpolation matrix `{\bf B}`
00038     %
00039     % The matrix entries are:
00040     % ``({\bf B})_{ij} = q_i(x_j)``
00041     % for `1 \leq i \leq j \leq N` and vanish elsewhere.
00042     BM;
00043 
00044     % local grid of type .gridbase with added neighbours such that a sparse
00045     % evaluation of the empirically interpolated operators in the interpolation
00046     % points is possible on this grid.
00047     grid_local_ext;
00048 
00049     % synonym for #grid_local_ext of type .gridbase
00050     grid;
00051 
00052     % indices of grid entities in the #grid_local_ext structure where the
00053     % interpolation points are situated.
00054     TM_local;
00055 
00056     % indices of grid entities in the the global grid structure where the
00057     % interpolation points are situated.
00058     TM_global;
00059 
00060     % empirical interpolation mass matrix.
00061     %
00062     % The matrix entries are:
00063     % ``({ \bf M })_{ij} = \int q_i q_j``
00064     % for `i,j=1,\ldots,M`
00065     Mmass;
00066 
00067   end
00068 
00069   properties(Dependent, SetAccess=private)
00070     % number of reduced basis vectors stored in this data node.
00071     N;
00072 
00073     % number of collateral reduced basis vectors stored in this data node.
00074     M;
00075 
00076     % number of collateral reduced basis vectors used for error estimation.
00077     Mstrich;
00078   end
00079 
00080   properties
00081     % handle of object of type NonlinEvol.RbReducedDataNode storing all reduced
00082     % magnitudes based only on the reduced basis.
00083     rb_rd;
00084 
00085     % handle of object of type NonlinEvol.EiReducedDataNode storing all reduced
00086     % magnitudes based only on the collateral reduced basis.
00087     ei_rd;
00088 
00089 
00090     % "transition" mass matrix
00091     %
00092     % The matrix entries are:
00093     % ``({ \bf D })_{ij} = \int q_i \varphi_j``
00094     % for `i=1,\ldots,M, j=1,\ldots,N`
00095     DE;
00096 
00097     % empirical interpolation matrix for operator with projection to reduced
00098     % basis space with `M+M'` basis vectors.
00099     %
00100     % This matrix is the solution `{\bf C}`of the equation system
00101     % ``{ \bf B C } = { \bf D }``
00102     % with @ref #BM "empirical interpolation matrix" `{ \bf B }` and @ref #DE
00103     % "transition matrix" `{\bf D}`.
00104     %
00105     % In case you have a vector of interpolation evaluations `\bf l` at
00106     % interpolation points, the interpolation can the be calculated as
00107     % ``{\bf C l}``.
00108     CE;
00109 
00110     % empirical interpolation matrix for operator with projection to reduced
00111     % basis space for the empirical interpolation with only `M` basis vectors.
00112     %
00113     % See also: #CE
00114     CE_red;
00115 
00116     % restriction of the reduced basis vectors to interpolation DOFs of the
00117     % local grid #grid_local_ext.
00118     RB_local_ext;
00119   end
00120 
00121   methods
00122     function rd = EiRbReducedDataNode(rb_reduced_data, rb_detailed_data, ...
00123                                       ei_reduced_data, ei_detailed_data)
00124       % Constructor for the generation of the reduced matrices and vectors.
00125       %
00126       % Parameters:
00127       %  rb_reduced_data: pure reduced basis reduced data structure of type NonlinEvol.RbReducedDataNode
00128       %  rb_detailed_data: detailed data structure of type Greedy.DataTree.Detailed.RbLeafNode
00129       %                    storing the reduced basis.
00130       %  ei_reduced_data: pure EI reduced data structure of type NonlinEvol.EiReducedDataNode
00131       %  ei_detailed_data: detailed data structure of type Greedy.DataTree.Detailed.EiLeafNode
00132       %                    storing the collateral reduced basis.
00133       if isa(rb_reduced_data, 'NonlinEvol.EiRbReducedDataNode')
00134         copy = rb_reduced_data;
00135       else
00136         copy = [];
00137       end
00138       rd = rd@Greedy.User.IReducedDataNode(copy);
00139       if nargin == 0
00140         error('NonlinEvol.EiRbReducedDataNode constructor needs an argument');
00141       elseif nargin == 4 && isa(rb_reduced_data, 'IReducedModel') ...
00142           && isa(rb_detailed_data, 'NonlinEvol.EiRbReducedDataNode')
00143         rmodel = rb_reduced_data;
00144         copy   = rb_detailed_data;
00145         copy_extract(rd, copy, rmodel, ei_reduced_data, ei_detailed_data);
00146       elseif nargin == 4
00147         fill_fields(rd, rb_reduced_data, rb_detailed_data, ei_reduced_data, ei_detailed_data);
00148       else
00149         error('Did not find constructor for your arguments');
00150       end
00151     end
00152 
00153     function conds = get_conds(this)
00154       conds_rb = get_conds(this.rb_rd);
00155       conds_ei = get_conds(this.ei_rd);
00156       if ~isempty(this.CE)
00157         conds.CE     = condest(this.CE);
00158       end
00159       if ~isempty(this.CE_red)
00160         conds.CE_red = condest(this.CE_red);
00161       end
00162       conds = structcpy(conds_rb, conds_ei);
00163     end
00164 
00165     function c = copy(this)
00166       c = NonlinEvol.EiRbReducedDataNode(this);
00167     end
00168   end
00169 
00170   methods(Access=private)
00171 
00172     function fill_fields(this, rb_red, rb_det, ei_red, ei_det)
00173       this.rb_rd = rb_red;
00174       this.ei_rd = ei_red;
00175 
00176       A       = rb_det.model_data.W;
00177       this.DE = rb_det.RB' * A * ei_det.QM;
00178 
00179       this.RB_local_ext = rb_det.RB(this.ei_rd.TM_global, :);
00180     end
00181 
00182     function copy_extract(this, copy, rmodel, rb_reduced_data, ei_reduced_data)
00183       MM                  = rmodel.M + rmodel.Mstrich;
00184       this.rb_rd = rb_reduced_data;
00185       this.ei_rd = ei_reduced_data;
00186 
00187       this.DE           = copy.DE(1:rmodel.N, 1:MM);
00188       if rmodel.M == copy.M && rmodel.Mstrich == copy.Mstrich
00189         this.RB_local_ext = copy.RB_local_ext(:, 1:rmodel.N);
00190       else
00191         eind = compute_TM_global(this.ei_rd, copy.ei_rd.grid, copy.ei_rd.TM_local(1:MM), rmodel);
00192         this.RB_local_ext = copy.RB_local_ext(eind, 1:rmodel.N);
00193       end
00194     end
00195   end
00196 
00197   methods
00198 
00199     function N  = get.N(this)
00200       N = this.rb_rd.N;
00201     end
00202 
00203     function M  = get.M(this)
00204       M = this.ei_rd.M;
00205     end
00206 
00207     function Mstrich  = get.Mstrich(this)
00208       Mstrich = this.ei_rd.Mstrich;
00209     end
00210 
00211     function BM = get.BM(this)
00212       BM = this.ei_rd.BM;
00213     end
00214 
00215 %    function this = set.BM(this, BM)
00216 %      this.ei_rd.BM = BM;
00217 %    end
00218 
00219     function Mmass = get.Mmass(this)
00220       Mmass = this.ei_rd.Mmass;
00221     end
00222 
00223 %    function this = set.Mmass(this, Mmass)
00224 %      this.ei_rd.Mmass = Mmass;
00225 %    end
00226 
00227     function grid_local_ext = get.grid_local_ext(this)
00228       grid_local_ext = this.ei_rd.grid_local_ext;
00229     end
00230 
00231 %    function this = set.grid_local_ext(this, grid_local_ext)
00232 %      this.ei_rd.grid_local_ext = grid_local_ext;
00233 %    end
00234 
00235     function grid_local_ext = get.grid(this)
00236       grid_local_ext = this.ei_rd.grid_local_ext;
00237     end
00238 
00239 %    function this = set.grid(this, grid_local_ext)
00240 %      this.ei_rd.grid_local_ext = grid_local_ext;
00241 %    end
00242 
00243     function TM_local = get.TM_local(this)
00244       TM_local = this.ei_rd.TM_local;
00245     end
00246 
00247     function TM_global = get.TM_global(this)
00248       TM_global = this.ei_rd.TM_global;
00249     end
00250 
00251     function a0 = get.a0(this)
00252       a0 = this.rb_rd.a0;
00253     end
00254 
00255     function Nmass = get.Nmass(this)
00256       Nmass = this.rb_rd.Nmass;
00257     end
00258 
00259     function LL_I = get.LL_I(this)
00260       LL_I = this.rb_rd.LL_I;
00261     end
00262 
00263     function bb_I = get.bb_I(this)
00264       bb_I = this.rb_rd.bb_I;
00265     end
00266 
00267     function yesno = needs_subset_copy(this, rmodel)
00268       % function yesno = needs_subset_copy(this, rmodel)
00269       % @copybrief .Greedy.User.IReducedDataNode.needs_subset_copy()
00270       %
00271       % @copydetails .Greedy.User.IReducedDataNode.needs_subset_copy()
00272       %
00273       % Parameters:
00274       %   rmodel: of type NonlinEvol.ReducedModel
00275 
00276       yesno = needs_subset_copy(this.rb_rd, rmodel) || needs_subset_copy(this.ei_rd, rmodel);
00277     end
00278 
00279 
00280   end
00281 end
00282 
 All Classes Namespaces Files Functions Variables