rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
ReducedModel.m
1 classdef ReducedModel < Greedy.User.IReducedModel
2  % reduced model for linear evolution problems as given by a
3  % LinEvol.DetailedModel.
4  %
5  % This is compatible with Greedy.User.IReducedModel and can therefore make
6  % use of @ref Greedy.User.IDetailedData "detailed data objects" created by
7  % Greedy algorithms.
8 
9  properties
10  enable_error_estimator = true;
11  end
12 
13  properties(Constant)
14  % This constant is used for a consistency check of the model descr with
15  % help of IModel.struct_check()
16  ddescr_checks = struct(...
17  'operators_ptr', {{@(x) isequal(class(x), 'function_handle')}},...
18  'init_values_algorithm', {{@(x) isequal(class(x), 'function_handle')}},...
19  'error_norm', {{@ischar, 'values', {'l2', 'energy'} }}...
20  );
21  end
22 
23  methods
24  function rm = ReducedModel(dmodel, bg_descr)
25  % function rm = ReducedModel(detailed_model, basis_generator)
26  % Constructor for the reduced model.
27  %
28  % Parameters:
29  % dmodel: of type LinEvol.DetailedModel
30 
31  if nargin == 1 || isempty(bg_descr)
32  bg_descr = [];
33  end
34  % this implements a copy constructor if necessary...
35  rm = rm@Greedy.User.IReducedModel(dmodel, bg_descr);
36  % are we NOT a copy constructor?
37  if ~(isempty(bg_descr) || isa(dmodel, 'LinEvol.ReducedModel'))
38  if ~IModel.struct_check(dmodel.descr, ...
39  LinEvol.ReducedModel.ddescr_checks);
40  error('Consistency check for LinEvol.ReducedModel failed.');
41  end
42  end
43  end
44 
45  function a0 = rb_init_values(this, detailed_data, decomp_mode)
46  % function a0 = rb_init_values(this, detailed_data, decomp_mode)
47  % @copybrief rb_init_values_separable()
48  %
49  % This calls rb_init_values_separable().
50  %
51  % Parameters:
52  % detailed_data: detailed data tree leaf object of type Greedy.DataTree.Detailed.RBLeafNode.
53  %
54  % Return values:
55  % a0: coefficient vector of size 'N x 1' for the initial values.
56  a0 = rb_init_values_separable(this, detailed_data, decomp_mode);
57  end
58 
59  %
60  %
61  % Parameters:
62  % reduced_data: of type LinEvol.ReducedData
63  rb_sim_data = rb_simulation_impl(this, reduced_data);
64 
65  function rb_sim_data = rb_reconstruction(this, detailed_data, rb_sim_data)
66  % function rb_sim_data = rb_reconstruction(this, detailed_data, rb_sim_data)
67  % @copybrief rb_reconstruction_default()
68  %
69  % This calls rb_reconstruction_default().
70  %
71  % Parameters:
72  % detailed_data: of type LinEvol.DetailedData
73  % rb_sim_data: struct holding reduced simulation data returned by
75  %
76  % Return values:
77  % rb_sim_data: struct holding the reduced simulation results and their
78  % reconstructions.
79  if isa(detailed_data, 'Greedy.User.IDetailedData')
80  dd_leaf = get_leaf(detailed_data, this);
81  else
82  dd_leaf = detailed_data;
83  end
84  rb_sim_data = rb_reconstruction_default(this, dd_leaf, rb_sim_data);
85  end
86 
87  function c = copy(this)
88  % function c = copy(this)
89  % @copybrief IReducedModelcopy()
90  %
91  % Return values:
92  % c: an object of type LinEvol.ReducedModel which is a deep copy of this object.
93  c = ReducedModel(this);
94  end
95 
96  end
97  methods (Static)
98  function Delta = get_estimators_from_sim_data(rb_sim_data)
99  % function Delta = get_estimators_from_sim_data(sim_data)
100  % @copybrief IReducedModelget_estimators_from_sim_data()
101  %
102  % @copydetails IReducedModelget_estimators_from_sim_data()
103  Delta = rb_sim_data.Delta;
104  end
105 
106  function Delta = get_estimator_from_sim_data(rb_sim_data)
107  % function Delta = get_estimator_from_sim_data(sim_data)
108  % @copybrief IReducedModelget_estimator_from_sim_data()
109  %
110  % @copydetails IReducedModelget_estimator_from_sim_data()
111  Delta = rb_sim_data.Delta(end);
112  end
113 
114  end
115 end