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.
6 % This
function can be used to make old demos work. Simply load the old
7 %
'params' and
'detailed_data' and then call
9 % [model,detailed_data,plot_params] = renewmodel(params, detailed_data);
10 %
demo_rb_gui(model, detailed_data, [],plot_params,
'title');
13 if isequal(model.rb_problem_type,
'nonlin_evol')
14 nmodel = nonlin_evol_model_default;
16 nmodel = lin_evol_model_default;
19 nmodel.init_values_ptr = str2func(['init_values_', model.name_init_values]);
20 model=rmfield(model,'name_init_values');
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');
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');
32 nmodel.conv_flux_ptr = str2func(['conv_flux_', model.name_flux]);
33 model=rmfield(model,'name_flux');
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;
39 model=rmfield(model,'name_diffusive_num_flux');
41 if ~isequal(model.name_convective_num_flux, 'none')
42 if isequal(model.name_convective_num_flux, 'enquist-osher')
45 nmodel.num_conv_flux_ptr = str2func(['fv_num_conv_flux_', strrep(model.name_convective_num_flux,'-','_')]);
48 conv_lin_name = ['velocity_', model.name_convective_num_flux];
49 if exist(conv_lin_name)
50 nmodel.velocity_ptr = str2func(conv_lin_name);
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;
56 nmodel.fv_expl_conv_weight = 1.0;
58 model=rmfield(model,'name_convective_num_flux');
60 nmodel.init_values_algorithm = str2func(model.init_values_algorithm);
61 model=rmfield(model,'init_values_algorithm');
63 nmodel.implicit_operators_algorithm = str2func(model.implicit_operators_algorithm);
64 model=rmfield(model,'implicit_operators_algorithm');
66 nmodel.inner_product_matrix_algorithm = str2func(model.inner_product_matrix_algorithm);
67 model=rmfield(model,'inner_product_matrix_algorithm');
69 model.bnd_rect_index = [];
70 model.flux_quad_degree = 1;
71 model.divclean_mode = 0;
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'});
80 model_data = gen_model_data(nmodel);
81 nddata =
structcpy(detailed_data, model_data);
83 if isfield(detailed_data,
'BM')
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;
99 function [np,op] = copy_and_rm(np,op,list)
101 if isfield(op, list{i})
102 np.(list{i}) = op.(list{i});
103 op=rmfield(op,list{i});
function model = model_default(model, T, nt)
model = model_default(model)
function demo_rb_gui(varargin)
reduced basis demo with sliders
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...
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...
function num_flux = fv_num_conv_flux_engquist_osher(model, model_data, U, NU_ind)
Function computing a numerical convective Engquist-Osher flux matrix.