2 % Detailed model
for a linear evolution problem with a @ref fv discretization
4 % This is a detailed model
for a problem of the type
6 % \partial_t u(x;t,\mu) - {\cal L}(t,\mu)[u(x,t;\mu)] &= 0 \qquad &\text{in }& \Omega \times [0, T], \\\\
7 % u(x;0,\mu) &= u_0(x;\mu) \qquad &\text{in }& \Omega \times \{0\}
9 % with suitable boundary conditions and linear operators
10 % `{\cal L}(t,\mu) : {\cal W} \to {\cal W}` parametrized over the
11 % time-parameter domain `[0,T] \times {\cal M}`.
13 % The numerical scheme
for the numerical solution of
this problem is assumed
14 % to be of the following type:
16 % u_h(\cdot;t^0,\mu) &= {\cal M}_h[u_0] \\\\
17 % \left(\text{Id} - \Delta t^k {\cal L}_{h, I}(t^{k+1},\mu)\right)[u_h(\cdot;t^{k+1},\mu)]
19 % \left(\text{Id} + \Delta t^k {\cal L}_{h, E}(t^{k},\mu)\right)[u_h(\cdot;t^{k},\mu)]
21 % with the following ingredients:
22 % - a time discretization `0 = t^0 \leq t^1 = t^0 + \Delta t^0 \leq \ldots
23 % \leq t^{K+1} = t^{K} + \Delta t^{K} = T`,
24 % - solution snapshots `u_h(\cdot;t,\mu) \in { cal W }_h `
for all
25 % parameters and time instances `(t,\mu) \in [0,T] \times { \cal M }`
26 % - separable operators
for the discretization `{\cal L}_{h, I}(t,\mu):{\cal
27 % W}_h \to {\cal W}_h`, `{\cal L}_{h, E}(t,\mu):{\cal W}_h \to {\cal W}_h`
28 % and separable initial data `u_0` in the parameter argument. That is these
29 % must be decomposable like
31 % {\cal L}_{h, *}(t,\mu) &= \sum_{q=1}^{q_*} \sigma_*^q(\mu) {\cal L}^q_{h, *}(t) \\\\
32 % u_0(x;\mu) &= \sum_{q=1}^{u_0} \sigma_{u_0}^q(\mu) u_0(x)
34 % - a projection operator `{\cal M}_h : {\cal W} \to {\cal W}_h`
38 % This constant is used
for a consistency check of the model descr with
39 % help of
Greedy.Remove.IDetailedModelBase.struct_check()
40 ddescr_checks =
struct(...
41 'mass_matrix', {{@(x) isequal(
class(x),
'function_handle')}}...
46 function dm = DetailedModel(descr)
47 %
function dm = DetailedModel(descr)
48 % constructor based on problem description
51 % descr: structure describing the problem and the descretization
55 error(
'Consistency check for LinEvol.DetailedModel failed.');
59 function this = set_mu(
this, mu)
60 %
function this = set_mu(
this, mu, propagate)
61 % sets the active parameter vector `\mu \in {\cal M}`
63 % The parameter set here, is used by the detailed_simulation() function.
65 % The default implementation sets all fieldnames 'descr.mu_names' in the
69 % mu: The parameter vector `\boldsymbol\mu`.
74 assert(length(mu) == length(this.descr.mu_names));
76 this.descr.mexptr(
'set_mu', mu);
79 function mu = get_mu(
this)
80 %
function mu = get_mu(
this)
81 % returns the active parameter vector `\boldsymbol\mu \in {\cal M}`
83 % The
default implementation returns a vector of the values of the fields
84 % of the #descr structure with names
'descr.mu_names'.
87 % mu: The parameter vector `\boldsymbol\mu`
89 mu = this.descr.mexptr(
'get_mu');
91 function sim_data = detailed_simulation(
this, model_data)
92 sim_data = this.descr.mexptr('detailed_simulation');
95 function model_data = gen_model_data(this)
96 model_data.
id = this.descr.mexptr('gen_model_data');
97 model_data.mexptr = this.descr.mexptr;
100 function p =
plot_sim_data(this, model_data, sim_data, plot_params)
102 if ~isfield(plot_params, 'gcf') || isempty(plot_params.gcf)
103 ud.descr = this.descr;
105 ud.sim_data = sim_data;
107 set(fig_handle, 'UserData', ud);
109 fig_handle = plot_params.gcf;
111 fig_ud = get(fig_handle, 'UserData');
112 if ~isempty(fig_ud) && isfield(fig_ud, 'plot_dir')
113 plot_dir = fig_ud.plot_dir;
115 args = ['-c ', sim_data.cell_array_name, ' ', sim_data.outdir, ' ', sim_data.prefix];
116 [status, res] = system([fullfile(rbmatlabhome, 'dune', 'time_scene_vis.sh'), ' ', args]);
117 plot_dir = strtrim(res);
119 fig_ud.plot_dir = plot_dir;
120 set(fig_handle, 'UserData', fig_ud);
124 if ~isfield(plot_params, 'timestep')
125 plot_params.timestep = 0;
128 if isfield(plot_params, 'reload_required') && plot_params.reload_required
139 function U = get_dofs_from_sim_data(sim_data)
144 function U = get_dofs_at_time(sim_data, time)
149 methods (Static, Hidden=true)
151 function issue_plot_command(plot_dir, command)
152 f = fopen(fullfile(plot_dir, 'control.cfg'), 'w');
155 system(['kill -SIGINT $(cat ', fullfile(plot_dir, 'tsv.pid'), ')']);
158 function close_figure_and_vtk_plot(src, event)
159 fig_ud = get(gcf, 'UserData');
160 if ~isempty(fig_ud) && isfield(fig_ud, 'plot_dir')
161 plot_dir = fig_ud.plot_dir;
166 disp('Could not issue the exit command to the Paraview renderer');
169 if exist(fullfile(plot_dir, 'tsv.pid'), 'file')
170 system(['rm -rf ', plot_dir]);
static function ok = struct_check(descr, checks)
executes checks on the fields of a structure object
Reduced basis implementation for linear evolution equations.
Interface classes to be implemented by the Greedy.Algorithm user.
static const ddescr_checks
This constant is used for a consistency check of the model descr with help of Greedy.Remove.IDetailedModelBase.struct_check()
Interface specialization of an IDetailedModel ready to use with Greedy algorithms for (time dependent...
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.
function p = plot_sim_data(model, model_data, sim_data, plot_params)
function performing the plot of the simulation results as specified in model.
Customizable implementation of an abstract greedy algorithm.
Detailed model for a linear evolution problem with a Finite volume discretization.
function varargout = default_plot_control(varargin)
DEFAULT_PLOT_CONTROL M-file for default_plot_control.fig DEFAULT_PLOT_CONTROL, by itself...