1 function model = advection_fv_output_vconst_model(params);
2 %
function model = advection_fv_output_vconst_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. Output functional is average concentration
7 % in subdomain. Pure
explicit discretization of convection with fv
8 % discretization. In contrast to the advection_fv_output_model,
9 % the velocity field is constant in time (but parameter
10 % dependent). The boundary conditions are decaying in time.
12 % possible fields of params:
13 % coarse_factor: coarsening factor between 1 and 8
14 % time-steps, gridsize are scaled down with this.
16 % To be used
for results of article at-Automatisierungstechnik 2010.
18 % B. Haasdonk 26.8.2009
21 if (nargin ==1) & (isfield(params,
'coarse_factor'))
22 coarse_factor = params.coarse_factor;
27 % specification of the time information
29 model.nt = 2048/coarse_factor;
30 %model.save_time_indices = 0:16/coarse_factor:model.nt;
31 model.save_time_indices = 0:8/coarse_factor:model.nt;
32 disp(
'nt to be adjusted later!');
33 model.dt = model.T/model.nt;
38 % disp(
'model with debugging turned on.');
41 model.error_estimation = 1;
44 %model.grid_initfile =
'rectangle_triagrid.mat';
45 model.gridtype =
'triagrid';
46 model.xnumintervals = 256/coarse_factor;
47 model.ynumintervals = 128/coarse_factor;
50 % set completely dirichlet boundary
51 model.bnd_rect_corner1 = [0,0]-eps;
52 model.bnd_rect_corner2 = [2,1]+eps;
53 %model.opts.bnd_rect_index = [-1];
54 model.element_quadrature = @triaquadrature;
56 model.dim_U = model.xnumintervals * model.ynumintervals * 2;
58 % Main global
function pointers expected in every model
59 model.gen_model_data = @lin_evol_gen_model_data;
60 model.gen_detailed_data = @lin_evol_gen_detailed_data;
61 model.gen_reduced_data = @lin_evol_gen_reduced_data;
62 model.detailed_simulation = @lin_evol_detailed_simulation;
63 model.rb_simulation = @lin_evol_rb_simulation;
64 model.rb_reconstruction = @lin_evol_rb_reconstruction;
65 model.plot_sim_data = @lin_evol_plot_sim_data;
67 % Dirichlet and Initial data
68 model.dirichlet_values_ptr = @dirichlet_values_affine_decomposed;
69 model.dirichlet_values_coefficients_ptr = @my_dirichlet_values_coefficients;
70 model.dirichlet_values_components_ptr = @my_dirichlet_values_components;
72 %model.dirichlet_values_coefficients_ptr = @(params) 1;
73 %model.dirichlet_values_components_ptr = @(glob,params) {ones(1, ...
75 model.rb_init_data_basis = @RB_init_data_basis;
76 model.init_values_ptr = @init_values_affine_decomposed;
77 model.init_values_coefficients_ptr = @my_dirichlet_values_coefficients_t0;
78 model.init_values_components_ptr = @my_dirichlet_values_components;
79 model.cone_number = 3; % number of components = cones
80 model.cone_range = [0,1]; % x-range of cone-support
81 model.cone_weight = 1; % leftmost cone with full weight
82 model.cone_amplitude = 1; % full amplitude
83 model.velocity_ptr = @velocity_affine_decomposed;
84 model.velocity_coefficients_ptr = @my_velocity_coefficients;
85 model.velocity_components_ptr = @my_velocity_components;
86 %model.vx_weight = 1.0;
87 model.vx_weight = 0.75;
88 %model.vy_weight = 1.0;
89 model.vy_weight = 0.75;
92 % set parameter setting
function
94 model.set_time = @set_time_default;
95 model.set_mu = @set_mu_default;
96 model.get_mu = @get_mu_default;
98 % perhaps these are redundant later...
99 model.divclean_mode = 0;
100 model.flux_quad_degree = 1;
101 model.flux_linear = 1;
103 model.init_values_algorithm = @disc_init_values;
104 model.init_values_qdeg = 0;
105 model.pdeg = 0; % FV schemes with piecewise constant ansatz functions
106 model.evaluate_basis = @fv_evaluate_basis;
107 model.l2project = @l2project;
108 model.local_mass_matrix = @fv_local_mass_matrix_tria; % triangular grid
109 model.mass_matrix = @fv_mass_matrix;
110 model.ndofs_per_element = 1;
113 %
for use of old datafunctions, use the following:
114 %model.operators_ptr = @fv_operators_implicit_explicit;
115 %model.operators_conv_explicit = @fv_operators_conv_explicit;
116 %model.operators_conv_implicit = @fv_operators_conv_implicit;
117 %model.operators_diff_explicit = @fv_operators_diff_explicit;
118 %model.operators_diff_implicit = @fv_operators_diff_implicit;
119 %model.operators_neumann_explicit = @fv_operators_neumann_explicit_old;
120 %model.operators_neumann_implicit = @fv_operators_neumann_implicit;
122 model.operators_ptr = @fv_operators_implicit_explicit;
123 %
for use of
new data
function access, use now
125 model.operators_conv_implicit = @fv_operators_zero;
126 model.operators_diff_explicit = @fv_operators_zero;
127 model.operators_diff_implicit = @fv_operators_zero;
128 model.operators_neumann_implicit = @fv_operators_zero;
129 model.operators_neumann_explicit = @fv_operators_zero;
134 %model.flux_linear = 1;
135 model.data_const_in_time = 0; % time varying data...
136 %model.diffusivity_ptr = ...;
137 %model.neumann_value_ptr = @...
138 model.affinely_decomposed = 1; % data functions allow affine
139 % parameter decomposition
141 model.compute_output_functional = 1; % turn on computation of output
142 model.output_function_ptr = @output_function_box_mean;
143 %model.sbox_xmin = 1;
147 %model.sbox_ymax = 0.5;
148 model.sbox_ymax = 0.5;
153 %model.mu_names = {
'cone_weight',
'vx_weight',
'vy_weight'};
154 model.mu_names = {
'cone_amplitude',
'vx_weight',
'vy_weight'};
155 model.mu_ranges = {[0 1],[0 1],[0,1]};
159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
160 %%%%% auxiliary functions used as pointers above:
161 %%%%% check later,
if they are of general interest to be exported
162 %%%%% as standalone functions
163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165 %
new function syntax: global coordinates as rows in glob_coord,
166 % time and parameter variables in params
168 % dirichlet-data: convex combination of equidistant cones, decaying
170 function res = my_dirichlet_values_coefficients_t0(params);
172 res = my_dirichlet_values_coefficients(params);
174 function res = my_dirichlet_values_coefficients(params);
175 % res is a vector of coefficients
176 Q_0 = params.cone_number;
178 max_pos = params.cone_weight * (Q_0-1)+1;
181 res(q) = (1-(max_pos-q))*(1-t) * ((max_pos>=q) && (max_pos < q+1)) ...
182 + (1+(max_pos-q))*(1-t) * ((max_pos>=q-1) && (max_pos < q));
184 res = res * params.cone_amplitude;
186 function res = my_dirichlet_values_components(glob,params);
187 % res is a cell-array of row-vectors of global evaluations
188 Q_0 = params.cone_number;
190 %delta_cone = 1/(Q_0+1);
191 delta_cone = (params.cone_range(2)-params.cone_range(1))/(Q_0+1);
192 cone_pos_x = delta_cone * (1:Q_0)+ params.cone_range(1);
194 res{q} = 1-min(sqrt((glob(:,1)-cone_pos_x(q)).^2+...
195 (glob(:,2)-1).^2)*(Q_0+1),1);
198 % velocity field: overlap of y- and x parabolic profiles
199 function res = my_velocity_coefficients(params);
200 %res = [params.vx_weight, params.vy_weight]*(1-params.t);
201 res = [params.vx_weight, params.vy_weight]*0.5; %*(1-params.t);
203 function res = my_velocity_components(glob,params);
204 resx = [5*(1-glob(:,2).^2),...
205 zeros(size(glob,1),1)];
206 %resy = [zeros(1,size(glob,2));...
207 % -2*((1-glob(1,:).^2 .*(glob(1,:)>=0) & (glob(1,:)<=1)...
209 resy = [zeros(size(glob,1),1),...
210 -1*((4-glob(:,1).^2))];
213 %
function res = my_velocity_coefficients2(params);
216 %
function res = my_velocity_components2(glob,params);
217 %res = {repmat([0;-1],1,size(glob,2))};
function res = intervalquadrature(poldeg, func, varargin)
integration of function func over reference interval == unit interval. by Gaussian quadrature exactly...
function [ L_I_diff , bdir_I_diff ] = fv_operators_diff_implicit_gradient(model, model_data, U, NU_ind)
computes diffusion contributions to finite volume time evolution matrices, or their Frechet derivati...
function [ L_E_conv , bdir_E_conv ] = fv_operators_conv_explicit_engquist_osher(model, model_data, U, NU_ind)
computes convection contribution to finite volume time evolution matrices, or their Frechet derivati...
function Udirichlet = dirichlet_values(model, X, Y)
UDIRICHLET = DIRICHLET_VALUES([X],[Y], MODEL) Examples dirichlet_values([0,1,2],[1,1,1],struct(name_dirichlet_values, homogeneous, ... c_dir, 1)) dirichlet_values([0:0.1:1],[0],struct(name_dirichlet_values, xstripes, ... c_dir, [0 1 2], ... dir_borders, [0.3 0.6])) dirichlet_values([0:0.1:1],[0],struct(name_dirichlet_values, box, ... c_dir, 1, ... dir_box_xrange, [0.3 0.6], ... dir_box_yrange, [-0.1 0.1]))
function [ L_E_neu , b_E_neu ] = fv_operators_neumann_explicit(model, model_data, U, NU_ind)
computes a neumann contribution matrix for finite volume time evolution operators, or their Frechet derivative
function p = fv_plot(gridbase grid, dofs, params)
routine plotting a single fv function of fv_functions.
function [ v , l2norm ] = fv_operators_output(model, model_data)
function returning components, coefficients, and complete operator for a linear output functional on ...
function p = plot_sequence(varargin)
plotting a sequence of data slices on polygonal 2d grid (constructed from params if empty) and provid...
function Umean = fv_element_mean(model, model_data, U, I)
function computing the element averages of a discrete function U in the grid elements with indices I...
function [ flux , lambda ] = conv_flux_linear(glob, U, params)
function computing the convective flux of a convection problem.