rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
DetailedModel.m
1 classdef DetailedModel < Greedy.User.FVDetailedModelDefault
2  % a test model doing nothing
3  %
4  % In this detailed model only the name of the called member function is
5  % printed. Such it enables to set-up Greedy algorithms and check wether the
6  % functions are called in the correct order.
7 
8  methods
9  function dmei = DetailedModel(descr)
10  % function dm = DetailedModel(descr)
11  % constructor based on problem description
12  %
13  % Parameters:
14  % descr: structure of type ModelDescr describing the problem and the
15  % discretization
16  dmei = dmei@Greedy.User.FVDetailedModelDefault(descr);
17  end
18  end
19 
20  methods
21  function model_data = gen_model_data(this)
22  disp('calling model_data');
23  gp.xrange = [0 1];
24  gp.yrange = [0 1];
25  if isfield(this.descr, 'gsize')
26  gsize = this.descr.gsize;
27  else
28  gsize = [2 2];
29  end
30  gp.xnumintervals = gsize(1);
31  gp.ynumintervals = gsize(2);
32  model_data.grid = rectgrid(gp);
33  model_data.W = fv_mass_matrix([], model_data.grid, []);
34  end
35 
36  function sim_data = detailed_simulation(this, model_data)
37  % function sim_data = detailed_simulation(this, model_data)
38  % @copybrief IDetailedModeldetailed_simulation()
39  %
40  % @copydetails IDetailedModeldetailed_simulation()
41  disp('calling detailed_simulation');
42  g = model_data.grid;
43  funmode = false;
44  miny = min(g.CY);
45  xvals = g.CX(g.CY==miny);
46  if isfield(this.descr, 'xfun')
47  xdata = this.descr.xfun(this.descr, xvals);
48  funmode = true;
49  else
50  xdata = ones(length(xvals), 1);
51  end
52  minx = min(g.CX);
53  yvals = g.CY(g.CX==minx);
54  if isfield(this.descr, 'yfun')
55  ydata = this.descr.yfun(this.descr, yvals);
56  funmode = true;
57  else
58  ydata = ones(length(yvals), 1);
59  end
60 
61  if funmode
62  sim_data.U = kron(ydata, xdata);
63  else
64  sim_data.U = sum(get_mu(this)) * ones(model_data.grid.nelements,this.descr.nt);
65  end
66  end
67 
68  function p = plot_sim_data(this, model_data, sim_data, plot_params)
69  % function sim_data = detailed_simulation(this, model_data[, plot_params])
70  % @copybrief IDetailedModelplot_sim_data()
71  %
72  % @copydetails IDetailedModelplot_sim_data()
73 
74  if nargin <= 3
75  plot_params = [];
76  end
77  p = fv_plot(model_data.grid, this.get_dofs_from_sim_data(sim_data), plot_params);
78  end
79  end
80 
81  methods(Static)
82  function U = get_dofs_from_sim_data(sim_data)
83  disp('calling get_dofs_from_sim_data');
84  U = sim_data.U;
85  end
86 
87  function snapshot = get_dofs_at_time(sim_data, time_index)
88  snapshot = sim_data(:,time_index);
89  end
90  end
91 end
function p = fv_plot(gridbase grid, dofs, params)
routine plotting a single fv function of fv_functions.
Definition: fv_plot.m:17
A cartesian rectangular grid in two dimensions with axis parallel elements.
Definition: rectgrid.m:17
Struct with control fields for the analytical PDE functions, the discretization and the parametrizati...
Definition: dummyclasses.c:15
Interface classes to be implemented by the Greedy.Algorithm user.
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...
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