1 function model = newton_oo_model(params)
2 %
function model = newton_model(params)
4 % optional fields of params:
5 % model_size: -
'big' simulations are done on a larger grid with very
7 % -
'small' simulations are done on a smaller grid with
9 % model_type: -
'buckley_leverett' -- A Buckley-Leverett problem
10 % -
'linear_diffusion' -- A linear parabolic problem with
12 % `` \partial_{t} u - \nabla \cdot ( \mu_1 \nabla u ) = 0 ``
13 % -
'exponential_diffusion' -- A non-linear parabolic problem
14 % with exponential
function as diffusion coefficient
16 % - \nabla \cdot ( k_0 + \mu_1 u^{\mu_2} \nabla u ) ``
17 % -
'eoc' -- A linear diffusion problem with known exact
18 % solution
for validation of numerical scheme
19 % -
'eoc_nonlinear' -- A nonlinear diffusion problem with known
20 % exact solution
for validation of numerical scheme
27 if ~isfield(params,
'model_size')
28 params.model_size = 'normal';
31 if ~isfield(params, 'model_type')
32 params.model_type = 'exponential_diffusion';
35 model = NonlinEvol.descr_default;
36 model.name = 'newton_oo_model';
37 model.rb_problem_type = 'NonlinEvol';
41 model.xnumintervals = 100;
42 model.ynumintervals = 100;
48 %% model size, affecting grid & time domain
49 if isfield(params, 'model_size')
50 if isequal(params.model_size, 'big')
51 model.xnumintervals = 200;
52 model.ynumintervals = 200;
53 elseif isequal(params.model_size, 'small')
54 model.xnumintervals = 50;
55 model.ynumintervals = 50;
61 % set all to dirichlet-boundary by specifying "rectangles", all
62 % boundary within is set to boundary type by bnd_rect_index
63 model.bnd_rect_corner1 = [-0.999999, 0; ...
65 model.bnd_rect_corner2 = [ 2, 0.999999; ...
67 % -1 means dirichlet, -2 means neumann
68 model.bnd_rect_index = [ -2, -2 ];
71 model.diffusivity_ptr = @diffusivity_exponential;
72 model.diffusivity_derivative_ptr = @diffusivity_exponential_derivative;
78 model.num_conv_flux_ptr = @fv_num_conv_flux_engquist_osher;
79 model.num_diff_flux_ptr = @fv_num_diff_flux_gradient;
80 model.flux_linear = 0;
81 model.name_flux = 'exponential';
82 model.geometry_transformation = 'none';
88 model.operators_diff_implicit = @fv_operators_diff_implicit_gradient;
89 model.operators_conv_implicit = @fv_operators_zero;
90 model.operators_neumann_implicit = @fv_operators_zero;
91 model.fv_expl_conv_weight = 0.0;
92 model.fv_impl_diff_weight = 1.0;
93 model.implicit_gradient_operators_algorithm = ...
94 @fv_frechet_operators_diff_implicit_gradient;
96 model.implicit_nonlinear = true;
98 model.data_const_in_time = false;
101 model.dirichlet_values_ptr = @dirichlet_values_leftright;
102 model.c_dir_left = 0.1;
103 model.c_dir_right = 0.6;
104 model.dir_middle = 0.5;
107 model.neumann_values_ptr = @neumann_values_homogeneous;
108 %model.neumann_values_ptr = @neumann_values_outflow;
112 model.init_values_ptr = @init_values_bars;
115 %% velocity/convection
116 model.filecache_velocity_matrixfile_extract = 0;
117 model.divclean_mode = false;
118 model.flux_quad_degree = 1;
120 model.conv_flux_ptr = @conv_flux_linear;
122 model.velocity_ptr = @velocity_transport;
123 model.transport_x = 0.1;
124 model.transport_y = 0.1;
126 model.conv_flux_derivative_ptr = @(glob, U, params) ...
127 params.velocity_ptr(glob, params);
131 model.newton_solver = 1;
132 model.newton_steps = 60;
134 model.newton_regularisation = 0;
136 model.stencil_mode = 'edge';
137 model.local_stencil_size = 1;
140 model.mu_names = {
'diff_k0'};
141 model.mu_ranges = {[0.01, 0.5]};
144 model.parspacesize = 8;
147 stop_timeout = 24*60*60;
149 if isfield(params,
'model_type')
150 if strcmp(params.model_type, 'linear_diffusion')
151 model.mu_names = {
'diff_k0'};
152 model.mu_ranges = {[0.01, 0.5]};
153 elseif strcmp(params.model_type,
'exponential_diffusion')
154 model.diff_k0 = 0.0000;
156 model.bnd_rect_index = [-2,-2];
157 model.c_init = 0.0001;
158 model.newton_regularisation = 0;
164 model.mu_names = {
'diff_p',
'diff_m',
'c_init'};
165 model.mu_ranges = {[1 5],[0 0.01],[0 0.2]};
167 if isfield(params,
'use_laplacian') && params.use_laplacian
168 model.laplacian_derivative_ptr = @(glob, U, model) ...
169 real((model.diff_m*U.^(model.diff_p-1)));
170 model.laplacian_ptr = @(glob, U, model) ...
171 real((1/model.diff_p * model.diff_m * U.^(model.diff_p)));
172 model.diffusivity_ptr = @(glob, U, model) ...
173 struct(
'K',1,
'epsilon',0);
174 model.diffusivity_derivative = @(glob, U, model) ...
175 struct(
'K',1,
'epsilon',0);
176 model.implicit_gradient_operators_algorithm = ...
180 model.parspacesize = [4, 1, 2];
182 elseif strcmp(params.model_type,
'eoc')
184 model.xnumintervals = 10;
185 model.ynumintervals = 10;
186 model.diff_k0 = 0.05;
190 model.init_values_ptr = @exact_function_heat_equation;
191 model.dirichlet_values_ptr = @exact_function_heat_equation;
193 model.bnd_rect_index = [ -1, -1 ];
195 elseif strcmp(params.model_type, 'eoc_nonlinear')
196 model.xnumintervals = 10;
197 model.ynumintervals = 10;
199 model.newton_regularisation = 0;
208 model.init_values_ptr = @exact_function_plaplace;
209 model.dirichlet_values_ptr = @exact_function_plaplace;
211 model.bnd_rect_index = [ -1, -2 ];
214 error('buckley leverett problem type is not implemented yet.');
218 model.enable_error_estimator = 1;
221 % error norm for residual in error estimation
222 model.error_norm = 'l2';
224 %% finalize the model
227 if ~isfield(model, 'ei_space_operators')
228 model.ei_space_operators = { model.L_E_local_ptr, model.L_I_local_ptr };
231 if isfield(params,
'verbose')
232 model.verbose = params.verbose;
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 model = model_default(model, T, nt)
model = model_default(model)
function model = unitcube(model)
function adding fields to model for generating a 2D rectgrid with 100 x 100 elements on the unit-squa...
function buckley_leverett()
small script demonstrating a buckley leverett problem discretization and RB model reduction ...