rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
RbReducedDataNode.m
1 classdef RbReducedDataNode < Greedy.User.IReducedDataNode
2  % Implementation of a Greedy.User.IReducedDataNode storing reduced data
3  % depending on reduced basis space information only. (e.g. reduced matrices
4  % of operators)
5 
6  properties
8  %
10  Nmass;
11 
13  %
15  a0;
16 
18  %
20  LL_I;
21 
23  %
25  bb_I;
26  end
27 
28  properties (SetAccess = private, Dependent)
30  %
32  N;
33  end
34 
35  methods
36  function rd = RbReducedDataNode(rmodel, detailed_data)
37  % function rd = RbReducedDataNode(rmodel, detailed_data)
38  % constructor for the generation of the reduced data.
39  %
40  % Parameters:
41  % rmodel: of type NonlinEvol.ReducedModel
42  % detailed_data: of type IDetailedData
43  %
44  % Alternative synopsis:
45  % @code RbReducedDataNode(rmodel, ei_reduced_data_node) @endcode copying
46  % a reduced data node and (optionally) extracting smaller matrices.
47  if nargin == 0
48  error('NonlinEvol.RbReducedDataNode constructor needs an argument');
49  elseif nargin == 2 && isa(rmodel, 'IReducedModel') ...
50  && isa(detailed_data, 'NonlinEvol.RbReducedDataNode')
51  copy = detailed_data;
52  copy_extract(rd, copy, rmodel);
53  elseif nargin == 2
54  fill_fields(rd, rmodel, detailed_data);
55  else
56  error('Did not find constructor for your arguments');
57  end
58  end
59 
60  function conds = get_conds(this)
61  if ~isempty(this.Nmass)
62  conds.Nmass = condest(this.Nmass);
63  end
64  if ~isempty(this.LL_I)
65  conds.LL_I = condest(this.LL_I);
66  end
67  end
68 
69  function N = get.N(this)
70  N = size(this.a0{1},2);
71  end
72 
73  function yesno = needs_subset_copy(this, rmodel)
74  % function yesno = needs_subset_copy(this, rmodel)
75  % @copybrief .Greedy.User.IReducedDataNode.needs_subset_copy()
76  %
77  % @copydetails .Greedy.User.IReducedDataNode.needs_subset_copy()
78  %
79  % Parameters:
80  % rmodel: of type NonlinEvol.ReducedModel
81  yesno = this.N ~= rmodel.N;
82  end
83 
84  end
85  methods(Access=private)
86 
87  function fill_fields(this, rmodel, detailed_data)
88 
89  model_data = detailed_data.model_data;
90  A = model_data.W;
91 
92  this.a0 = rb_init_values(rmodel, detailed_data, 1);
93  [this.LL_I, this.bb_I] = NonlinEvol.ReducedData.rb_operators(rmodel, detailed_data, 1);
94  this.Nmass = detailed_data.RB' * A * detailed_data.RB;
95 
96  end
97 
98  function copy_extract(this, reduced_data, rmodel)
99 
100  % extract correct N-sized submatrices and subvectors from reduced_data
101  if rmodel.N > reduced_data.N
102  error('N too large for current size of reduced basis!');
103  end
104 
105  N = rmodel.N;
106 
107  this.a0 = subblock_sequence(reduced_data.a0,1:N);
108  this.LL_I = subblock_sequence(reduced_data.LL_I,1:N,1:N);
109  this.bb_I = subblock_sequence(reduced_data.bb_I,1:N);
110  if ~isempty(reduced_data.Nmass)
111  this.Nmass = reduced_data.Nmass(1:N,1:N);
112  end
113 
114  end
115  end
116 
117 end