rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
FVDetailedModelDefault.m
1 classdef FVDetailedModelDefault < Greedy.User.IDetailedModel
2  % Interface specialization of an IDetailedModel ready to use with Greedy
3  % algorithms for (time dependent) @ref fv discretizations.
4  %
5 
6  properties (Constant)
7 
8  end
9  methods
10  function rbmdmed = FVDetailedModelDefault(descr)
11  % function rbmdmed = IDetailedModel(descr)
12  % Constructor for this class
13  %
14  rbmdmed = rbmdmed@Greedy.User.IDetailedModel(descr);
15 
16  if ~isfield(descr, 'init_values_algorithm')
17  rbmdmed.descr.init_values_algorithm = @fv_init_values;
18  end
19  if ~isfield(descr, 'inner_product_matrix_algorithm')
20  rbmdmed.descr.inner_product_matrix_algorithm = @fv_inner_product_matrix;
21  end
22 
23  end
24 
25  function UON = orthonormalize(this, model_data, U)
26  % function UON = orthonormalize(model, model_data, U)
27  % @copybrief Greedy.User::IDetailedModelorthonormalize()
28  %
29  % @copydetails Greedy.User::IDetailedModelorthonormalize()
30  %
31  % This implements an orthonormalization with help of the QR method.
32 
33  % UON = model.orthonormalize(model, model_data, U, eps);
34  UON = model_orthonormalize_qr(this.descr, model_data, U, 1e-10);
35  end
36 
37  function U0 = init_values_algorithm(dmodel, model_data)
38  % function UO = init_values_algorithm(model, model_data)
39  % @copybrief Greedy.User::IDetailedModelinit_values_algorithm()
40  %
41  % @copydetails Greedy.User::IDetailedModelinit_values_algorithm()
42  %
43  % This calls the function pointer defined in the #descr structure field
44  % 'init_values_algorithm'.
45  U0 = dmodel.descr.init_values_algorithm(dmodel.descr, model_data);
46  end
47 
48  function UV = inner_product(this, model_data, U, V)
49  % function UV = inner_product(this, model_data, U, V)
51  %
53  %
54  % This uses the 'W'=get_inner_product_matrix() method in order to compute
55  % the inner product `\langle u_h, v_h \rangle = U' W V`
56  W = Greedy.User.FVDetailedModelDefault.get_inner_product_matrix(model_data);
57  UV = U' * W * V;
58  end
59 
60  end
61 
62  methods(Static)
63  function errs = l2_error_sequence_algorithm(U, Uapprox, model_data)
64  % function errs = l2_error_sequence_algorithm(U, Uapprox, model_data)
65  % @copybrief Greedy.User::IDetailedModell2_error_sequence_algorithm()
66  %
67  % @copydetails Greedy.User::IDetailedModell2_error_sequence_algorithm()
68  %
69  % This function calls fv_l2_error()
70  errs = fv_l2_error(U, Uapprox, Greedy.User.FVDetailedModelDefault.get_inner_product_matrix(model_data));
71  end
72 
73  function errs = linfty_error_sequence_algorithm(U, Uapprox, model_data)
74  % function errs = linfty_error_sequence_algorithm(U, Uapprox, model_data)
75  % @copybrief Greedy.User::IDetailedModellinfty_error_sequence_algorithm()
76  %
77  % @copydetails Greedy.User::IDetailedModellinfty_error_sequence_algorithm()
78  %
79  % This function calls fv_linfty_error();
80  errs = fv_linfty_error(U, Uapprox, []);
81  end
82 
83  function W = get_inner_product_matrix(model_data)
84  % function W = get_inner_product_matrix(model_data)
85  % @copybrief Greedy.User::IDetailedModelget_inner_product_matrix()
86  %
87  % @copydetails Greedy.User::IDetailedModelget_inner_product_matrix()
88  %
89  % Required fields of model_data:
90  % W: the inner product matrix
91  % This function returns the inner product matrix stored in 'model_data'
92  W = model_data.W;
93  end
94 
95  end
96 
97 end