rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ReducedModel.m
1 classdef ReducedModel < LinEvol.ReducedModel
2  % reduced model for 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  mu = [];
11  end
12 
13  methods
14  function rm = ReducedModel(dmodel, bg_descr)
15  % function rm = ReducedModel(detailed_model, basis_generator)
16  % Constructor for the reduced model.
17  %
18  % Parameters:
19  % dmodel: of type LinEvol.DetailedModel
20 
21  if nargin == 1 || isempty(bg_descr)
22  bg_descr = [];
23  end
24  % this implements a copy constructor if necessary...
25  rm = rm@LinEvol.ReducedModel(dmodel, bg_descr);
26  end
27 
28  function this = set_mu(this, mu)
29  % function this = set_mu(this, mu, propagate)
30  % sets the active parameter vector `\mu \in {\cal M}`
31  %
32  % The parameter set here, is used by the detailed_simulation() function.
33  %
34  % The default implementation sets all fieldnames 'descr.mu_names' in the
35  % #descr struct.
36  %
37  % Parameters:
38  % mu: The parameter vector `\boldsymbol\mu`.
39  %
40  % Return values:
41  % this: handle of type IDetailedModel to the changed DetailedModel
42 
43  assert(length(mu) == length(this.descr.mu_names));
44 
45  this.mu = mu;
46 % this.descr.mexptr('set_mu', mu);
47  end
48 
49  function mu = get_mu(this)
50  % function mu = get_mu(this)
51  % returns the active parameter vector `\boldsymbol\mu \in {\cal M}`
52  %
53  % The default implementation returns a vector of the values of the fields
54  % of the #descr structure with names 'descr.mu_names'.
55  %
56  % Return values:
57  % mu: The parameter vector `\boldsymbol\mu`
58 
59 
60  if isempty(this.mu)
61  this.mu = get_mu(this.detailed_model);
62  end
63  mu = this.mu;
64 
65 % mu = this.descr.mexptr('get_mu');
66  end
67  function a0 = rb_init_values(this, detailed_data, decomp_mode)
68  % function a0 = rb_init_values(this, detailed_data, decomp_mode)
69  % @copybrief rb_init_values_separable()
70  %
71  % This calls rb_init_values_separable().
72  %
73  % Parameters:
74  % detailed_data: detailed data tree leaf object of type Greedy.DataTree.Detailed.RBLeafNode.
75  %
76  % Return values:
77  % a0: coefficient vector of size 'N x 1' for the initial values.
78 
79  descr = this.detailed_model.descr;
80  if decomp_mode == 2
81  a0 = descr.coeff_ops.u0_ptr(this.mu);
82  else
83  if decomp_mode ~= 1
84  this.detailed_model.set_mu(this.mu);
85  end
86  a0 = descr.mexptr('rb_init_values', decomp_mode);
87  end
88  end
89 
90  function rb_sim_data = rb_reconstruction(this, detailed_data, rb_sim_data)
91  % function rb_sim_data = rb_reconstruction(this, detailed_data, rb_sim_data)
92  % @copybrief rb_reconstruction_default()
93  %
94  % This calls rb_reconstruction_default().
95  %
96  % Parameters:
97  % detailed_data: of type LinEvol.DetailedData
98  % rb_sim_data: struct holding reduced simulation data returned by
99  % IReducedModel.rb_simulation() .
100  %
101  % Return values:
102  % rb_sim_data: struct holding the reduced simulation results and their
103  % reconstructions.
104  if isa(detailed_data, 'Greedy.User.IDetailedData')
105  dd_leaf = get_leaf(detailed_data, this);
106  else
107  dd_leaf = detailed_data;
108  end
109  dune_sim_data = this.descr.mexptr('rb_reconstruction', dd_leaf.model_data, rb_sim_data);
110  rb_sim_data = structcpy(rb_sim_data, dune_sim_data);
111  end
112 
113  function c = copy(this)
114  % function c = copy(this)
115  % @copybrief IReducedModelcopy()
116  %
117  % Return values:
118  % c: an object of type LinEvol.ReducedModel which is a deep copy of this object.
119  c = ReducedModel(this);
120  end
121 
122  end
123  methods (Static)
124  function Delta = get_estimators_from_sim_data(rb_sim_data)
125  % function Delta = get_estimators_from_sim_data(sim_data)
126  % @copybrief IReducedModelget_estimators_from_sim_data()
127  %
128  % @copydetails IReducedModelget_estimators_from_sim_data()
129  Delta = rb_sim_data.Delta;
130  end
131 
132  function Delta = get_estimator_from_sim_data(rb_sim_data)
133  % function Delta = get_estimator_from_sim_data(sim_data)
134  % @copybrief IReducedModelget_estimator_from_sim_data()
135  %
136  % @copydetails IReducedModelget_estimator_from_sim_data()
137  Delta = rb_sim_data.Delta(end);
138  end
139 
140  end
141 end
reduced model for linear evolution problems as given by a LinEvol.DetailedModel.
Definition: ReducedModel.m:18
reduced model for linear evolution problems as given by a LinEvol.DetailedModel.
Definition: ReducedModel.m:18
function rb_sim_data = rb_reconstruction_default(model, detailed_data, rb_sim_data)
(trivial) function computing a detailed reconstruction by linear combination of the coefficients in t...
function a0 = rb_init_values_separable(IReducedModel rmodel,Greedy.DataTree.Detailed.RBLeafNode detailed_data, decomp_mode)
function computing initial values for a reduced simulation.
Reduced basis implementation for linear evolution equations.
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.
This is the interface for a reduced model providing methods to compute low dimensional reduced simula...
Definition: IReducedModel.m:17
function s1 = structcpy(s1, s2)
copies the fields of structure s2 into structure s1. If the field to be copied does not exist in s1 y...
Definition: structcpy.m:17
This is the interface for a detailed model providing methods to compute high dimensional simulation s...
Detailed model for a linear evolution problem with a Finite volume discretization.
Definition: DetailedModel.m:18
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
Detailed model for a linear evolution problem with a Finite volume discretization.
Definition: DetailedModel.m:18
Interface class for the generation and storage of reduced basis spaces as described in Module (M2)...
Definition: IDetailedData.m:17