rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
renew_model.m
Go to the documentation of this file.
1 function [nmodel,nddata,plot_params] = renew_model(model, detailed_data)
2 % function [nmodel,nddata] = renew_model(model, detailed_data)
3 % change fields of old 'param' structure to new 'model' structure with
4 % excessive use of function pointers.
5 %
6 % This function can be used to make old demos work. Simply load the old
7 % 'params' and 'detailed_data' and then call
8 % @code
9 % [model,detailed_data,plot_params] = renewmodel(params, detailed_data);
10 % demo_rb_gui(model, detailed_data, [],plot_params,'title');
11 % @endcode
12 
13 if isequal(model.rb_problem_type, 'nonlin_evol')
14  nmodel = nonlin_evol_model_default;
15 else
16  nmodel = lin_evol_model_default;
17 end
18 
19 nmodel.init_values_ptr = str2func(['init_values_', model.name_init_values]);
20 model=rmfield(model,'name_init_values');
21 
22 if isfield(model, 'name_dirichlet_values')
23  nmodel.dirichlet_values_ptr = str2func(['dirichlet_values_', model.name_dirichlet_values]);
24  model=rmfield(model,'name_dirichlet_values');
25 end
26 
27 if isfield(model, 'name_neuman_values')
28  nmodel.neumann_values_ptr = str2func(['neumann_values_', model.name_neuman_values]);
29  model=rmfield(model,'name_neuman_values');
30 end
31 
32 nmodel.conv_flux_ptr = str2func(['conv_flux_', model.name_flux]);
33 model=rmfield(model,'name_flux');
34 
35 if ~isequal(model.name_diffusive_num_flux, 'none')
36  nmodel.num_diff_flux_ptr = str2func(['fv_num_diff_flux_', model.name_diffusive_num_flux]);
37  nmodel.fv_expl_diff_weight = 1.0;
38 end
39 model=rmfield(model,'name_diffusive_num_flux');
40 
41 if ~isequal(model.name_convective_num_flux, 'none')
42  if isequal(model.name_convective_num_flux, 'enquist-osher')
43  nmodel.num_conv_flux_ptr = @fv_num_conv_flux_engquist_osher;
44  else
45  nmodel.num_conv_flux_ptr = str2func(['fv_num_conv_flux_', strrep(model.name_convective_num_flux,'-','_')]);
46  end
47  if ~model.flux_linear
48  conv_lin_name = ['velocity_', model.name_convective_num_flux];
49  if exist(conv_lin_name)
50  nmodel.velocity_ptr = str2func(conv_lin_name);
51  else
52  warning(['using forward difference linearization for non-linear convective flux. Maybe, you need to implement:', conv_lin_name]);
53  nmodel.velocity_ptr = @velocity_forward_difference;
54  end;
55  end
56  nmodel.fv_expl_conv_weight = 1.0;
57 end
58 model=rmfield(model,'name_convective_num_flux');
59 
60 nmodel.init_values_algorithm = str2func(model.init_values_algorithm);
61 model=rmfield(model,'init_values_algorithm');
62 
63 nmodel.implicit_operators_algorithm = str2func(model.implicit_operators_algorithm);
64 model=rmfield(model,'implicit_operators_algorithm');
65 
66 nmodel.inner_product_matrix_algorithm = str2func(model.inner_product_matrix_algorithm);
67 model=rmfield(model,'inner_product_matrix_algorithm');
68 
69 model.bnd_rect_index = [];
70 model.flux_quad_degree = 1;
71 model.divclean_mode = 0;
72 
73 plot_params = [];
74 [plot_params, model] = copy_and_rm(plot_params, model, {'yscale_uicontrols', 'xscale_uicontrols', 'xscale_gui', 'yscale_gui', 'axis_equal', 'clim', 'bind_to_model', 'no_lines', 'geometry_transformation', 'show_colorbar', 'colorbar_mode'});
75 
76 nmodel = structcpy(nmodel, model);
77 
78 nmodel = model_default(nmodel);
79 
80 model_data = gen_model_data(nmodel);
81 nddata = structcpy(detailed_data, model_data);
82 
83 if isfield(detailed_data, 'BM')
84  nddata.BM=cell(1);
85  nddata.TM=cell(1);
86  nddata.QM=cell(1);
87  nddata.ei_info=cell(1);
88  nddata.BM{1} = detailed_data.BM;
89  nddata.QM{1} = detailed_data.QM;
90  nddata.TM{1} = detailed_data.TM;
91  nddata.ei_info{1} = detailed_data.ei_info;
92  nddata.implicit_crb_index = 1;
93  nddata.explicit_crb_index = 1;
94 end
95 
96 
97 end
98 
99 function [np,op] = copy_and_rm(np,op,list)
100  for i=1:length(list)
101  if isfield(op, list{i})
102  np.(list{i}) = op.(list{i});
103  op=rmfield(op,list{i});
104  end
105  end
106 end
107 %| \docupdate
function model = model_default(model, T, nt)
model = model_default(model)
Definition: model_default.m:17
function demo_rb_gui(varargin)
reduced basis demo with sliders
Definition: demo_rb_gui.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
function [ nmodel , nddata , plot_params ] = renew_model(model, detailed_data)
change fields of old param structure to new model structure with excessive use of function pointers...
Definition: renew_model.m:17
function num_flux = fv_num_conv_flux_engquist_osher(model, model_data, U, NU_ind)
Function computing a numerical convective Engquist-Osher flux matrix.