rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ReducedModel.m
1 classdef ReducedModel < Greedy.User.IReducedModel
2  % reduced model for non-linear evolution problems as given by a
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 = false;
11 
12  impes = false;
13  end
14 
15  properties (Dependent)
16  % current time instance
17  t;
18 
19  % current time step
20  tstep;
21  end
22 
23  properties(Constant)
24  % This constant is used for a consistency check of the model descr with
25  % help of IModel.struct_check()
26  ddescr_checks = struct(...
27  'init_values_algorithm', {{@(x) isequal(class(x), 'function_handle')}}...
28  );
29 
30  end
31 
32  methods
33  function rm = ReducedModel(dmodel, bg_descr)
34  % function rm = ReducedModel(dmodel, bg_descr)
35  % Constructor for the reduced model.
36  %
37  % Parameters:
38  % dmodel: of type TwoPhaseFlow.DetailedModel
39  %
40  if nargin == 1 || isempty(bg_descr)
41  bg_descr = [];
42  end
43  % this implements a copy constructor if necessary...
44  rm = rm@Greedy.User.IReducedModel(dmodel, bg_descr);
45  % are we NOT a copy constructor?
46  if ~(isempty(bg_descr) || isa(dmodel, 'TwoPhaseFlow.ReducedModel'))
47 
48  descr = dmodel.descr;
49 
50  if ~IModel.struct_check(descr, ...
52  error('Consistency check for TwoPhaseFlow.ReducedModel failed.');
53  end
54 
55  end
56 
57  end
58 
59  function N = get_N(this, id)
60  if isequal(id, 'u0')
61  id = 'saturation';
62  end
63  N = get_by_description(this.N, id);
64  end
65 
66  function set_N(this, id, val)
67  set(this.N, get_index(this.N, id), val);
68  end
69 
70  function M = get_M(this, id)
71  M = get_by_description(this.M, id);
72  end
73 
74  function set_M(this, id, val)
75  set(this.M, get_index(this.M, id), val);
76  end
77 
78 
79  function c = copy(this)
80  % function c = copy(this)
81  % @copybrief IReducedModelcopy()
82  %
83  % Return values:
84  % c: an object of type TwoPhaseFlow.ReducedModel which is a deep copy
85  % of this object.
86  c = TwoPhaseFlow.ReducedModel(this);
87  end
88 
89  function rb_sim_data = rb_simulation(rmodel, reduced_data, sim_data, dd)
90  % function rb_sim_data = rb_simulation(rmodel, reduced_data)
91  % forwards the reduced simulation to the method rb_simulation_impl()
92  % after getting a suitable reduced data leaf element.
93  %
94  % Parameters:
95  % reduced_data: of type Greedy.User.ReducedData
96  % sim_data: structure holding simulation data, i.e. Dof-vectors with
97  % fields 'S', 'U', 'P' for the saturation, velocity and
98  % pressure field concentrations. This can be used for
99  % reference computations. @default []
100  % dd: object of type IDetailedData which can be used for
101  % reference computations. @default []
102  %
103  % Return values:
104  % rb_sim_data: structure holding the coefficient vectors of the reduced
105  % simulations and optional error estimators.
106  reduced_data_leaf = get_leaf(reduced_data, rmodel);
107  if rmodel.impes
108  if nargin == 2
109  rb_sim_data = rb_simulation_impes_impl(rmodel, reduced_data_leaf);
110  else
111  rb_sim_data = rb_simulation_impes_impl(rmodel, reduced_data_leaf, sim_data, dd);
112  end
113  else
114  if nargin == 2
115  rb_sim_data = rb_simulation_impl(rmodel, reduced_data_leaf);
116  else
117  rb_sim_data = rb_simulation_impl(rmodel, reduced_data_leaf, sim_data, dd);
118  end
119  end
120  end
121 
122  %
123  %
124  % Parameters:
125  % reduced_data: of type TwoPhaseFlow.EiRbReducedDataNode
126  rb_sim_data = rb_simulation_impl(this, reduced_data, sim_data, dd);
127 
128  %
129  %
130  % Parameters:
131  % reduced_data: of type TwoPhaseFlow.EiRbReducedDataNode
132  rb_sim_data = rb_simulation_impes_impl(this, reduced_data, sim_data, dd);
133 
134  function a0 = rb_init_values(this, detailed_data, decomp_mode)
135  % function a0 = rb_init_values(this, detailed_data, decomp_mode)
136  % @copybrief rb_init_values_separable()
137  %
138  % This calls rb_init_values_separable().
139  %
140  % Parameters:
141  % detailed_data: detailed data tree leaf object of type GreedyDataTreeDetailed.PODEILeafNode.
142  %
143  % Return values:
144  % a0: coefficient vector of size 'N x 1' for the initial values.
145  a0 = rb_init_values_separable(this, detailed_data, decomp_mode);
146  end
147 
148 
149  %
150  %
151  % Parameters:
152  % detailed_data: of type TwoPhaseFlow.DetailedData
153  rb_sim_data = rb_reconstruction(this, detailed_data, rb_sim_data);
154 
155  end
156 
157  methods(Static)
158  function Delta = get_estimators_from_sim_data(rb_sim_data)
159  % function Delta = get_estimators_from_sim_data(rb_sim_data)
160  % @copybrief IReducedModelget_estimators_from_sim_data()
161  %
162  % @copydetails IReducedModelget_estimators_from_sim_data()
163  Delta = rb_sim_data.Delta;
164  end
165 
166  function Delta = get_estimator_from_sim_data(rb_sim_data)
167  % function Delta = get_estimator_from_sim_data(rb_sim_data)
168  % @copybrief IReducedModelget_estimator_from_sim_data()
169  %
170  % @copydetails IReducedModelget_estimator_from_sim_data()
171  Delta = rb_sim_data.Delta(end);
172  end
173 
174  end
175 
176  methods
177  function t = get.t(this)
178  t = this.descr.t;
179  end
180 
181  function set.t(this, t)
182  this.detailed_model.t = t;
183  end
184 
185  function tstep = get.tstep(this)
186  tstep = this.descr.tstep;
187  end
188 
189  function set.tstep(this, tstep)
190  this.detailed_model.tstep = tstep;
191  end
192  end
193 end
Reduced data implementation for non-linear evolution problems with finite volume discretizations.
Definition: ReducedData.m:18
reduced model for non-linear evolution problems as given by a TwoPhaseFlow.DetailedModel.
Definition: ReducedModel.m:18
static const ddescr_checks
This constant is used for a consistency check of the model descr with help of IModel.struct_check() ...
Definition: ReducedModel.m:66
This is the common interface for all models, detailed and reduced ones.
Definition: IModel.m:17
function a0 = rb_init_values_separable(IReducedModel rmodel,Greedy.DataTree.Detailed.RBLeafNode detailed_data, decomp_mode)
function computing initial values for a reduced simulation.
static function ok = struct_check(descr, checks)
executes checks on the fields of a structure object
Definition: IModel.m:210
descr
The description structure holding information about the analytical parametrized problem and its discr...
Definition: IReducedModel.m:58
Reduced data implementation for non-linear evolution problems with finite volume discretizations.
Definition: leaf.m:17
an interface specialization for detailed data objects used with the Greedy algorithm.
Definition: IDetailedData.m:19
Interface classes to be implemented by the Greedy.Algorithm user.
class generating the reduced basis space for the LinEvol problem with a Greedy algorithm.
Definition: DetailedData.m:18
This is the interface for a reduced model providing methods to compute low dimensional reduced simula...
Definition: IReducedModel.m:17
IDetailedModel implementation for a two phase flow system.
Definition: DetailedModel.m:18
decomp_mode
Decomposition operation mode.
Definition: IModel.m:66
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1
interface specialization for a reduced model that can be used with the Greedy algorithm for basis gen...
Definition: IReducedModel.m:19
Interface class for the generation and storage of reduced basis spaces as described in Module (M2)...
Definition: IDetailedData.m:17