rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
IDetailedModel.m
1 classdef IDetailedModel < IModel
2  % This is the interface for a detailed model providing methods to compute
3  % high dimensional simulation snapshots.
4  %
5  % An IDetailedModel implementation can be combined used as a basis for
6  % reduced basis generation routines and a reduced model as described in the
7  % section on the @ref rbm_interface "main interfaces".
8  %
9  % Some basis generation algorithms, however, depend on models with a
10  % specialized interface. For example the Greedy.Algorithm class comes with a
11  % derived interface class Greedy.User.IDetailedModel.
12 
13  properties (GetAccess = public, SetAccess = protected)
14  % The description structure holding information about the analytical
15  % parametrized problem and its discretization
16  descr;
17 
18  end
19 
20  properties (Dependent)
21  decomp_mode;
22  end
23 
24  properties(Constant)
25  % this structure holds variable names that need to be defined by the
26  % descr structure.
27  base_checks = struct('mu_names', {{@iscell}}, ...
28  'mu_ranges', {{@iscell}}, ...
29  'debug', {{@isscalar}},...
30  'verbose', {{@isscalar}} );
31  end
32 
33  properties (SetAccess = private, Dependent)
34  % cell array of strings describing the parameters of the model
35  mu_names;
36 
37  % cell array of vectors of size two defining the allowed interval range for
38  % the parameter components
39  mu_ranges;
40 
41  % an integer defining the verbosity level of information output during
42  % basis generation
43  verbose;
44 
45  % an integer defining the debugging level controlling error output and
46  % extra tests during basis generation
47  debug;
48  end
49 
50 
51  methods
52  function dmbif = IDetailedModel(descr)
53  % constructor
54  %
55  % Parameters:
56  % descr: The underlying description of the analytical problem and
57  % its discretization.
58 
59  dmbif.descr = descr;
60  if ~IDetailedModel.struct_check(descr, ...
62  error('Consistency check for IDetailedModel failed');
63  end
64  if ~isfield(descr, 'decomp_mode')
65  dmbif.descr.decomp_mode = 0;
66  end
67  end
68 
69  function mu_ranges = get.mu_ranges(this)
70  mu_ranges = this.descr.mu_ranges;
71  end
72 
73  function mu_names = get.mu_names(this)
74  mu_names = this.descr.mu_names;
75  end
76 
77  function decomp_mode = get.decomp_mode(this)
78  decomp_mode = this.descr.decomp_mode;
79  end
80 
81  function set.decomp_mode(this, decomp_mode)
82  this.descr.decomp_mode = decomp_mode;
83  end
84 
85  function debug = get.debug(this)
86  debug = this.descr.debug;
87  end
88 
89  function verbose = get.verbose(this)
90  verbose = this.descr.verbose;
91  end
92 
93  function isequal = eq(this, other)
94  % function eq(this, other)
95  % overloaded equality ('==') operator, by default comparing the #descr variables
96  %
97  % This can be used as ' this == other ' and returns whether the two
98  % DetailedModels are identical.
99  %
100  % Parameters:
101  % other: The object of type IDetailedModel to compare with
102  %
103  % Return values:
104  % isequal: boolean value indiciating whether ' this == other '
105  ignorelist = { 'filecache_ignore_fields_in_model', 'decomp_mode', 't', ...
106  'tstep' };
107  ignorelist = [ ignorelist, this.descr.mu_names ];
108  if isfield(this.descr, 'filecache_ignore_fields_in_model')
109  ignorelist = [ ignorelist, this.descr.filecache_ignore_fields_in_model ];
110  end
111  [isequal, a, b, c] = structcmp(this.descr, other.descr, ignorelist);
112  if ~isequal
113  disp('fields of model and stored model differs:')
114  disp('differing fields:');
115  cellfun(@disp,a);
116  disp('additional fields in model:');
117  cellfun(@disp,b);
118  disp('additional fields in stored model:');
119  cellfun(@disp,c);
120  end
121  end
122 
123  function this = set_mu(this, mu)
124  % function this = set_mu(this, mu, propagate)
125  % sets the active parameter vector `\mu \in {\cal M}`
126  %
127  % The parameter set here, is used by the detailed_simulation() function.
128  %
129  % The default implementation sets all fieldnames 'descr.mu_names' in the
130  % #descr struct.
131  %
132  % Parameters:
133  % mu: The parameter vector `\boldsymbol\mu`.
134  %
135  % Return values:
136  % this: handle of type IDetailedModel to the changed DetailedModel
137 
138  assert(length(mu) == length(this.descr.mu_names));
139 
140  for i = 1:length(this.descr.mu_names)
141  this.descr.(this.descr.mu_names{i}) = mu(i);
142  end
143  end
144 
145  function mu = get_mu(this)
146  % function mu = get_mu(this)
147  % returns the active parameter vector `\boldsymbol\mu \in {\cal M}`
148  %
149  % The default implementation returns a vector of the values of the fields
150  % of the #descr structure with names 'descr.mu_names'.
151  %
152  % Return values:
153  % mu: The parameter vector `\boldsymbol\mu`
154 
155 
156 
157  mu = cellfun(@(x) this.descr.(x), this.descr.mu_names, 'UniformOutput', true);
158  end
159  end
160 
161  methods (Abstract)
162 
163  % function model_data = gen_model_data(this)
164  % generates large model data.
165  %
166  % This function generates e.g. a grid, which is not to be stored in the
167  % model, but required for numerics.
168  %
169  % Return values:
170  % model_data: Matlab structure of type ModelData storing high dimensional
171  % data needed by detailed_simulation().
172  model_data = gen_model_data(this);
173 
174  % function sim_data = detailed_simulation(this, model_data)
175  % executes a detailed simulation for a given parameter
176  %
177  % This function computes a numerical scheme defined by the #descr for the
178  % parameter set via the set_mu() method.
179  %
180  % Return values:
181  % sim_data: structure holding the `H`-dimensional simulation data.
182  sim_data = detailed_simulation(this, model_data);
183 
184 
185  % function p = plot_sim_data(dmodel, model_data, sim_data, plot_params)
186  % plots the simulation data as returned by detailed_simulation()
187  %
188  % Parameters:
189  % sim_data: simulation data structure as returned by detailed_simulation()
190  % plot_params: structure which controls the plot output
191  %
192  % Return values:
193  % p: GUI handle to the created MATLAB figure
194  p = plot_sim_data(dmodel, model_data, sim_data, plot_params);
195  end
196 
197  methods (Static, Abstract)
198 
199  % function U = get_dofs_from_sim_data(sim_data)
200  % extracts the `H` dimensional Dof vector from the 'sim_data' structure
201  %
202  % Return values:
203  % U: `H` dimensional Dof vector
204  U = get_dofs_from_sim_data(sim_data);
205  end
206 
207 end
static const base_checks
this structure holds variable names that need to be defined by the descr structure.
function r = verbose(level, message, messageId)
This function displays messages depending on a message-id and/or a level. Aditionally you can set/res...
Definition: verbose.m:17
default greedy basis generation class
Definition: Algorithm.m:18
This is the common interface for all models, detailed and reduced ones.
Definition: IModel.m:17
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...
This is the interface for a detailed model providing methods to compute high dimensional simulation s...
function p = plot_sim_data(model, model_data, sim_data, plot_params)
function performing the plot of the simulation results as specified in model.
Definition: plot_sim_data.m:17
Customizable implementation of an abstract greedy algorithm.
Definition: DuneRBLeafNode.m:1
Struct with high dimensional data needed for a high dimensional simulation.
Definition: dummyclasses.c:1