rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
SeparableOperatorNode.m
1 classdef SeparableOperatorNode < Greedy.User.IReducedDataNode
2 
3  properties (SetAccess = private)
4 
5  bb;
6 
7  sohandle;
8  end
9 
10  properties (SetAccess = private, Dependent)
11  id;
12 
13  LL;
14 
15  N;
16  end
17 
18  properties (Access=private)
19  siz;
20  LL_int;
21  end
22 
23  methods
24  function sfn = SeparableOperatorNode(rmodel, detailed_data, sohandle)
25  if nargin == 0
26  error('Greedy.DataTree.Reduced.SeparableOperatorNode needs three constructor arguments');
27  elseif nargin == 2 && isa(rmodel, 'IReducedModel') ...
28  && isa(detailed_data, 'Greedy.DataTree.Reduced.SeparableOperatorNode')
29  copy = detailed_data;
30  copy_extract(sfn, copy, rmodel);
31  elseif nargin == 3
32  sfn.sohandle = sohandle;
33  fill_fields(sfn, rmodel, detailed_data);
34  else
35  error('Wrong constructor arguments');
36  end
37  end
38 
39  function yesno = needs_subset_copy(this, rmodel)
40  % function yesno = needs_subset_copy(this, rmodel)
41  % @copybrief ::GreedyUser.IReducedDataNode.needs_subset_copy()
42  %
43  % @copydetails ::GreedyUser.IReducedDataNode.needs_subset_copy()
44  %
45  % Parameters:
46  % rmodel: of type TwoPhaseFlow.ReducedModel
47  rn = get_by_description(rmodel.N, this.id);
48  yesno = this.N ~= rn;
49 
50  end
51 
52  function N = get.N(this)
53  N = size(this.LL{1},1);
54  end
55 
56  function LL = get.LL(this)
57  len = size(this.LL_int, 2);
58  LL = cell(1, len);
59  for i = 1:len
60  LL{i} = reshape(this.LL_int, this.siz);
61  end
62  end
63 
64  function id = get.id(this)
65  id = this.sohandle.id;
66  end
67 
68  function conds = get_conds(this)
69  conds = cellfun(@condest, this.LL, 'UniformOutput', false);
70  end
71 
72  function [LL_c, bb_c] = lincomb_sequence(this, descr)
73  [L_coeffs, b_coeffs] = this.sohandle.coefficients(descr);
74  LL_c = reshape(this.LL_int * L_coeffs, this.siz);
75  bb_c = this.bb * b_coeffs;
76 
77  end
78  end
79 
80  methods(Access=private)
81 
82  function fill_fields(this, rmodel, detailed_data)
83  [LL, bbret] = this.sohandle.gram_project_components(rmodel, detailed_data);
84  this.bb = cat(1, bbret{:});
85  this.siz = size(LL{1});
86  LL = cellfun(@(X) X(:), LL, 'UniformOutput', false);
87  this.LL_int = cat(1, LL{:});
88  end
89 
90  function copy_extract(this, reduced_data, rmodel)
91  this.sohandle = reduced_data.sohandle;
92  rn = get_by_description(rmodel.N, this.id);
93 
94  if rn > this.N
95  error('N too large for current size of reduced data!');
96  end
97 
98  this.bb = reduced_data.bb(1:rn, :);
99  if isempty(this.sohandle.ret_vars)
100  nmask = 1:size(this.siz,1);
101  this.siz(2) = rn;
102  else
103  this.siz = [rn, rn];
104  nmask = 1:rn;
105  end
106  subset = zeros(rn, rn);
107  subset(nmask, 1:rn) = 1;
108  this.LL_int = this.LL_int(subset(:), :);
109  end
110  end
111 end
Interface for leaf nodes of the DataTree in Greedy.User.ReducedData objects.
Interface classes to be implemented by the Greedy.Algorithm user.
This is the interface for a reduced model providing methods to compute low dimensional reduced simula...
Definition: IReducedModel.m:17
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1