rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
advection_ldg_model.m
1 function model = advection_ldg_model(params);
2 %function model = advection_ldg_model(params);
3 %
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
7 % discretization
8 %
9 % example of a model not as class but as structure plus function pointers
10 % goal: library works with structure- or class-models
11 %
12 % (Demonstration of base LDG functionality of rbmatlab library)
13 
14 % B. Haasdonk 26.8.2009
15 
16 model = [];
17 
18 % specification of the time information
19 model.T = 1;
20 model.nt = 100;
21 disp('nt to be adjusted!');
22 model.dt = model.T/model.nt;
23 model.verbose = 9;
24 
25 % grid information
26 %model.grid_initfile = 'rectangle_triagrid.mat';
27 model.gridtype = 'triagrid';
28 model.xnumintervals = 40;
29 model.ynumintervals = 20;
30 model.xrange = [0,2];
31 model.yrange = [0,1];
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];
36 
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;
40 
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;
46 
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
56 
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);
66 
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';
71 
72 return; % temporary end
73 
74 
75 
76 
77 
78 model.operators_ptr = @ldg_operators_explicit;
79 model.L_I_inv_norm_bound = 1;
80 model.L_E_norm_bound = 1;
81 
82 model.flux_linear = 1;
83 model.vx_weight = 0.5;
84 model.vy_weight = 0.5;
85 
86 % RB information:
87 model.mu_names = {'cone_weight','vx_weight','vy_weight'};
88 model.mu_ranges = {[0 1],[0 1],[0,1]};
89 
90 %model.neumann_values_ptr = 0;
91 
92 %model.name_init_values = 'decomp_function_ptr';
93 % implement below!!
94 %model.init_values_coefficients_ptr = @my_init_values_coefficients;
95 %model.init_values_components_ptr = @my_init_values_components;
96 
97 
98 model.name_diffusive_num_flux = 'none';
99 
100 %name_diffusive_num_flux = 'gradient';
101  % precomputed, divcleaned velocity field
102  name_flux = 'gdl2';
103 
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;
107  verbose = 5;
108 
109 model.rb_init_values = @rb_init_values;
110 
111 
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;
117 model.save_detailed_simulations = @save_detailed_simulations;
118 model.load_detailed_simulation = @load_detailed_simulation;
119 model.use_velocity_matrixfile = 1;
120 model.divclean_mode = 'none'; % file is already cleaned by optimization
121 
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'];
127 
128 model.lxf_lambda = 1.0194e+003;
129 model.data_const_in_time = 1;
130 
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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
136 
137 % new function syntax: global coordinates as rows in glob_coord,
138 % time and parameter variables in params
139 
140 % dirichlet-data: convex combination of equidistant cones, decaying
141 % in time
142 function res = my_dirichlet_values_coefficients(params);
143 % res is a vector of coefficients
144 Q_0 = params.cone_number;
145 res = zeros(1,Q_0)
146 max_pos = params.cone_weight * (Q_0-1)+1;
147 t = params.t;
148 for q = 1:Q_0
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));
151 end;
152 
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;
156 res = cell(1,Q_0);
157 delta_cone = 1/(Q_0+1);
158 cone_pos_x = delta_cone * (1:Q_0);
159 for q = 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);
162 end;
163 
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);
167 
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))];
173 res = {resx, resy};
174 %| \docupdate