1 function model = advection_ldg_model(params);
2 %
function model = advection_ldg_model(params);
4 % model
for the
new advection model with functional output
5 % two overlapping velocity fields and boundary value modification
6 % are the parameters. Pure
explicit discretization of convection with ldg
9 % example of a model not as
class but as structure plus function pointers
10 % goal: library works with structure- or class-models
12 % (Demonstration of base LDG functionality of rbmatlab library)
14 % B. Haasdonk 26.8.2009
18 % specification of the time information
21 disp(
'nt to be adjusted!');
22 model.dt = model.T/model.nt;
26 %model.grid_initfile =
'rectangle_triagrid.mat';
27 model.gridtype =
'triagrid';
28 model.xnumintervals = 40;
29 model.ynumintervals = 20;
32 %
set completely dirichlet boundary
33 model.bnd_rect_corner1 = [0,0]-eps;
34 model.bnd_rect_corner2 = [2,1]+eps;
35 model.bnd_rect_index = [-1];
37 % Main global
function pointers expected in every model
38 model.detailed_simulation = @ldg_conv_detailed_simulation;
39 model.gen_model_data = @lin_evol_gen_model_data;
41 % model can only perform detailed simulations
42 %model.gen_detailed_data = @lin_evol_gen_detailed_data;
43 %model.gen_reduced_data = @lin_evol_gen_reduced_data;
44 %model.rb_simulation = @lin_evol_rb_simulation;
45 %model.rb_reconstruction = @lin_evol_rb_reconstruction;
47 % Dirichlet and Initial data
48 model.dirichlet_values_ptr = @dirichlet_values_affine_decomposed;
49 model.dirichlet_values_coefficients_ptr = @my_dirichlet_values_coefficients;
50 model.dirichlet_values_components_ptr = @my_dirichlet_values_components;
51 model.init_values_ptr = @init_values_affine_decomposed;
52 model.init_values_coefficients_ptr = @my_dirichlet_values_coefficients;
53 model.init_values_components_ptr = @my_dirichlet_values_components;
54 model.cone_number = 5; % number of components = cones
55 model.cone_weight = 1; % leftmost cone with full weight
57 model.dimrange = 1; % scalar equation
58 model.pdeg = 2; % polynomial degree of solution and init ansatz
function
59 model.init_values_qdeg = 4; % quadrature degree
60 model.init_values_algorithm = @disc_init_values;
61 model.l2project = @ldg_l2project;
62 model.evaluate = @ldg_evaluate;
63 model.evaluate_basis = @ldg_evaluate_basis;
64 model.plot = @ldg_plot;
65 model.ndofs_per_element = ldg_ndofs_per_element(model);
67 model.velocity_ptr = @velocity_affine_decomposed;
68 model.velocity_coefficients_ptr = @my_velocity_coefficients;
69 model.velocity_components_ptr = @my_velocity_components;
70 model.convflux =
'advection';
72 return; % temporary end
78 model.operators_ptr = @ldg_operators_explicit;
79 model.L_I_inv_norm_bound = 1;
80 model.L_E_norm_bound = 1;
82 model.flux_linear = 1;
83 model.vx_weight = 0.5;
84 model.vy_weight = 0.5;
87 model.mu_names = {
'cone_weight',
'vx_weight',
'vy_weight'};
88 model.mu_ranges = {[0 1],[0 1],[0,1]};
90 %model.neumann_values_ptr = 0;
92 %model.name_init_values =
'decomp_function_ptr';
94 %model.init_values_coefficients_ptr = @my_init_values_coefficients;
95 %model.init_values_components_ptr = @my_init_values_components;
98 model.name_diffusive_num_flux =
'none';
100 %name_diffusive_num_flux =
'gradient';
101 % precomputed, divcleaned velocity field
104 lambda = 2.0e-7; % v = - lambda * grad p
105 name_convective_num_flux = 'lax-friedrichs';
106 inner_product_matrix_algorithm = @fv_inner_product_matrix;
109 model.rb_init_values = @rb_init_values;
112 % further method pointers, which are specific to model:
113 model.orthonormalize = @model_orthonormalize_gram_schmidt;
114 model.inner_product = @fv_inner_product;
115 model.PCA = @model_PCA_fixspace;
116 model.cached_detailed_simulation = @cached_detailed_simulation;
119 model.use_velocity_matrixfile = 1;
120 model.divclean_mode =
'none'; % file is already cleaned by optimization
122 %
set matrix-file name for optional generation or reading of file
123 model.velocity_matrixfile = ['vel_', model.name_flux,'_',...
124 num2str( model.xnumintervals),'x',...
125 num2str( model.ynumintervals),...
126 '_l',num2str( model.lambda),'.mat'];
128 model.lxf_lambda = 1.0194e+003;
129 model.data_const_in_time = 1;
131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 %%%%% auxiliary functions used as pointers above:
133 %%%%% check later,
if they are of general interest to be exported
134 %%%%% as standalone functions
135 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137 %
new function syntax: global coordinates as rows in glob_coord,
138 % time and parameter variables in params
140 % dirichlet-data: convex combination of equidistant cones, decaying
142 function res = my_dirichlet_values_coefficients(params);
143 % res is a vector of coefficients
144 Q_0 = params.cone_number;
146 max_pos = params.cone_weight * (Q_0-1)+1;
149 res(q) = (1-(max_pos-q))*(1-t) * ((max_pos>=q) && (max_pos < q+1)) ...
150 + (1+(max_pos-q))*(1-t) * ((max_pos>=q-1) && (max_pos < q));
153 function res = my_dirichlet_values_components(glob,params);
154 % res is a cell-array of row-vectors of global evaluations
155 Q_0 = params.cone_number;
157 delta_cone = 1/(Q_0+1);
158 cone_pos_x = delta_cone * (1:Q_0);
160 res{q} = 1-min(sqrt((glob(:,1)-cone_pos_x(q)).^2+...
161 (glob(:,2)-1).^2)*(Q_0+1),1);
164 % velocity field: overlap of y- and x parabolic profiles
165 function res = my_velocity_coefficients(params);
166 res = [params.vx_weight, params.vy_weight]*(1-params.t);
168 function res = my_velocity_components(glob,params);
169 resx = [(1-glob(:,2).^2);...
170 zeros(1,size(glob,1))];
171 resy = [zeros(1,size(glob,1));...
172 (1-glob(:,1).^2.*(glob(:,1)>=0 && glob(:,1)<=1))];