rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
richards_fv_descr.m
Go to the documentation of this file.
1 function model = richards_fv_descr(params)
2 % function model = richards_fv_descr(params)
3 % Non-linear evolution equation with geometry transformation and an example of
4 % the Richards equation
5 %
6 % Included in the following presentations:
7 % - Algoritmy 2009
8 % - MoRePaS 2009
9 %
10 % Included in the following papers:
11 % - Diploma thesis of Martin Drohmann
12 % - Algoritmy proceedings 2009
13 %
14 % See also: demo_richards_fv()
15 %
16 % optional fields of params:
17 % model_size: - 'big' simulations are done on a larger grid with very
18 % small time steps
19 % - 'small' simulations are done on a smaller grid with
20 % bigger time steps
21 % model_type:
22 % - 'linear_heat_trapezoidal' on transformed domain linear heat equation
23 % with a trapezoidal geometry parametrisation. on reference
24 % domain a linear convection-diffusion-reaction problem. It
25 % still depends on empirical interpolation, however, because
26 % of non-affine parameter dependencies of the operators
27 % introduced by geometry parametrisation. Note, that
28 % diffusion term is discretized explicitly.
29 % - 'linear_heat_polynomial' on transformed domain linear heat equation
30 % with polynomial geometry parametrization. On reference
31 % domain a linear convection-diffusion-reaction problem.
32 % Note, that diffusion term is discretized explicitly.
33 % - 'nonlinear_richards_trapezoidal' on transformed domain real Richards
34 % equation example with trapezoidal geometry parametrisation
35 % and a gravity induced convection term. On reference
36 % domain a non-linear convection-diffusion-reaction problem.
37 % Note, that diffusion term is discretized explicitly.
38 % - 'linear_heat_polynomial_implicit' On transformed domain
39 % lienar heat equation with polynomial geometry
40 % parametrisation. On reference domain a linear
41 % convection-diffusion-reaction problem with non-affine
42 % parameter dependence (resolved by EI). The diffusion term
43 % is discretized implicitly.
44 % - 'test' very small heat equation example suitable for
45 % quick test runs
46 
47  model = NonlinEvol.descr_default;
48  model.name = 'richards_fv_model';
49  model.rb_problem_type = 'NonlinEvol';
50  %% data that is definitely used outside of the detailed simulations
51  % mu_names = {'c_init','hill_height'};
52  % mu_ranges = {[-1,0],[-0.1,0.1]};
53  model.mu_names = {'c_dir_low','hill_height'};
54  model.mu_ranges = {[0,0.5],[0.0,0.4]};
55 
56 
57  %% data that might be of interest outside of the detailed simulations
58  model.T = 0.9;
59  model.nt = 300;
60 
61  %% finite volume settings
62  model.diffusivity_ptr = @diffusivity_homogeneous;
63  model.diffusivity_tensor_ptr = @diffusivity_tensor_richards;
64  % diffusivity_ptr = @diffusivity_linear_gradient;
65  % diff_left = 0.001;
66  % diff_right = 0.002;
67 
68 
69  model.num_conv_flux_ptr = @fv_num_conv_flux_engquist_osher;
70  model.num_diff_flux_ptr = @fv_num_diff_flux_gradient_tensor;
71  model.flux_linear = true;
72  model.name_flux = 'richards';
73 
74 
75  model.operators_diff_implicit = @fv_operators_diff_implicit_gradient_tensor;
76  model.operators_conv_implicit = @fv_operators_zero;
77  model.operators_neumann_implicit = @fv_operators_zero;
78  model.fv_expl_conv_weight = 1.0;
79  model.fv_expl_diff_weight = 1.0;
80  model.fv_expl_react_weight = 1.0;
81 
82  % lxf_lambda = 1.25;
83  % lxf_lambda = fv_search_max_lxf_lambda([],
84 
85 
86  %% define the grid
87  model = unitcube(model);
88  model.xnumintervals = 100;
89  model.ynumintervals = 80;
90 
91  % pointer to function in rbmatlab/datafunc/dirichlet_values
92  model.dirichlet_values_ptr = @dirichlet_values_uplow;
93  model.c_dir = 0.1;
94  model.dir_box_xrange = [-1 2];
95  model.dir_box_yrange = 0.5 + [1/320 3/320];
96  model.c_dir_left = 1;
97  model.c_dir_right = 1;
98  model.c_dir_up = 0;
99  model.c_dir_low = 0.5;
100  model.dir_middle = 0.7;
101  % name_dirichlet_values = 'homogeneous';
102  % c_dir = 0;
103 
104  % pointer to function in rbmatlab/datafunc/neumann_values
105  %neumann_values_ptr = @neumann_values_homogeneous;
106  model.neumann_values_ptr = @neumann_values_zero;
107  model.c_neu = 0;
108 
109  % name of function in rbmatlab/datafunc/init_values/
110  model.init_values_ptr = @init_values_transformed_blobs;
111  % parameters for data functions
112  model.blob_height = 0.1;
113  model.c_init = 0.1;
114 
115  model.filecache_velocity_matrixfile_extract = 0;
116 
117  model.geometry_spline_type = 'cubic';
118  model.hill_height = 0.0;
119  model.geometry_transformation_spline_x = [ 0 0.5 1 ];
120  model.geometry_transformation_spline_y = [ 0 -0.033 0 ];
121 
122  model.k = 0.005;
123  model.gravity = 0;
124 
125 
126  model.divclean_mode = false;
127  model.flux_quad_degree = 1;
128 
129  model.conv_flux_ptr = @conv_flux_linear;
130 
131  model.velocity_ptr = @velocity_richards;
132 
133  model.conv_flux_derivative_ptr = @(glob, U, params) params.velocity_ptr(glob, params);
134 
135 
136  model.data_const_in_time = 0;
137 
138  % set all to dirichlet-boundary by specifying "rectangles", all
139  % boundary within is set to boundary type by bnd_rect_index
140  model.bnd_rect_corner1 = [-0.999999, 0; ...
141  0, -0.9999999 ];
142  model.bnd_rect_corner2 = [ 2, 0.999999; ...
143  0.999999, 2 ];
144  % -1 means dirichlet, -2 means neumann
145  model.bnd_rect_index = [ -1, -2 ];
146 
147  %if isfield(params, 'separate_CRBs') && params.separate_CRBs
148  % model.separate_CRBs = params.separate_CRBs;
149  % savepath_infix = '';
150  %else
151  % savepath_infix = '_one_CRB';
152  %end
153 
154  model.ei_space_operators = { model.L_E_local_ptr };
155  model.Mstrich = 5;
156  model.num_cpus = 8;
157 
158  model.geometry_transformation = 'spline';
159 
160  model.stencil_mode = 'vertex';
161  model.local_stencil_size = 1;
162 
163  if isfield(params, 'model_size')
164  if strcmp(params.model_size, 'big') == 1
165  model.xnumintervals = 200;
166  model.ynumintervals = 200;
167  end
168  if strcmp(params.model_size, 'small') == 1
169  model.xnumintervals = 50;
170  model.ynumintervals = 50;
171  model.T = 2;
172  model.nt = 20;
173  end
174  end
175  model.implicit_nonlinear = false;
176  if isfield(params, 'model_type')
177  if strcmp(params.model_type, 'nonlinear') == 1
178  model.geometry_spline_type = 'cubic';
179  model.nt = 300;
180  elseif strcmp(params.model_type, 'linear_heat_trapezoidal') == 1
181  model.geometry_spline_type = 'affine';
182  model.T = 0.5;
183  model.nt = 260;
184  model.c_init = 0;
185  elseif strcmp(params.model_type, 'richards_affine') == 1
186  model.geometry_spline_type = 'affine';
187  model.diffusivity_ptr = @diffusivity_richards_nonlinear;
188  model.init_values_ptr = @init_values_transformed_blobs_richards;
189  % set parameters for nonlinear gradient
190  model.k = 0.002;
191  model.gravity = 0.5;
192  model.clim = [0.22,0.40];
193  % set new time parameters
194  model.T = 0.01;
195  model.nt = 195;
196  model.c_dir_up = 0.32;
197  model.c_dir_low = 0.35;
198  model.xnumintervals = 80;
199  model.ynumintervals = 100;
200  % set default mu values
201  model.c_init = 0.34;
202  model.hill_height = 0.50;
203  % choose different mu vector
204  model.mu_names = {'hill_height','c_init'};
205  model.mu_ranges = {[0,0.5],[0.22,0.34]};
206  % only neumann boundaries
207  model.bnd_rect_index = [ -2, -2 ];
208 
209  ht = @(t)(t-0.218)./(0.52-0.218);
210  model.richards_perm_ptr = @(t)(2.1*ht(t).^0.5.*(1-(1-ht(t).^(7/6)).^(6/7)).^2);
211  model.richards_retention_ptr = @(t)(35.2574./(1./(3.311258.*t-0.7218543).^(6/7)-1).^(6/7)./(3.311258.*t-0.721854).^(13/7));
212  model.postprocess = @postprocess_gravity;
213  elseif strcmp(params.model_type, 'implicit_nonaffine_linear') == 1
214  model.implicit_nonlinear = true;
215  model.hill_height = 0.4;
216  model.geometry_spline_type = 'cubic';
217  % model.mu_names = {'hill_height', 'blob_height'};
218  model.mu_ranges = {[0,0.4], [0.0,0.3]};
219  % model.c_init = 0;
220  % model.bnd_rect_index = [ -2, -2 ];
221  model.k = 0.005;
222  % k = 0.005;
223  model.nt = 100;
224  model.fv_expl_diff_weight = 0.0;
225  model.fv_impl_diff_weight = 1.0;
226  model.data_const_in_time = 1;
227  model.T = 1.5;
228 
229  model.ei_space_operators = { model.L_E_local_ptr, model.L_I_local_ptr };
230  elseif strcmp(params.model_type, 'test')
231  model.T = 0.15;
232  model.nt = 30;
233  model.geometry_spline_type = 'affine';
234  model.Mstrich = 0;
235  model.data_const_in_time = true;
236  else
237  error(['selected model type "', params.model_type, '" is unknown.']);
238  end
239  end
240  model.model_type = params.model_type;
241 
242  % error norm for residual in error estimation
243  model.error_norm = 'l2';
244 
245  model = model_default(model);
246 
247  model.verbose = 1;
248  model.debug = 0;
249 
250  % % settings for CRB generation
251  % model.Mmax = 150;
252  % model.sMmax = {50, 50};
253  % model.ei_stop_on_Mmax = 1;
254  % % build ei-basis with WHOLE trajectory
255  % model.ei_target_error = 'interpol';
256  % model.ei_numintervals = [2,4];
257  %
258  % model.RB_stop_Nmax = 50;
259  % model.RB_stop_epsilon = 1e-5;
260  % model.RB_stop_max_val_train_ratio = inf;
261  % model.RB_numintervals = [2,4];
262  %
263  % % target accuracy epsilon:
264  %
265  % % decide, whether estimator or true error is error-indicator for greedy
266  % model.RB_error_indicator = 'error'; % true error
267  % % RB_error_indicator = 'estimator'; % Delta from rb_simulation
268  % % RB_error_indicator = 'ei_estimator_test'; % Delta from rb_simulation testet against true error
269  %
270  %
271  % % richards_affine
272  %% model.ei_numintervals = [5,6];
273  %% model.RB_numintervals = [5,6];
274  %
275  %
276  %% test:
277  %% model.ei_numintervals = [2,2];
278  %% model.RB_numintervals = [2,2];
279  %% model.Mmax = 20;
280  %% model.RB_stop_Nmax = 5;
281  %% model.M = model.Mmax;
282  %% end
283 % vim: set et sw=2:
284 %| \docupdate
function r = verbose(level, message, messageId)
This function displays messages depending on a message-id and/or a level. Aditionally you can set/res...
Definition: verbose.m:17
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 data = postprocess_gravity(data, glob, params)
subtracts a previously added addent induced by gravitational effects.
function model = richards_fv_descr(params)
Non-linear evolution equation with geometry transformation and an example of the Richards equation...
function num_flux = fv_num_diff_flux_gradient_tensor(model, model_data, U, NU_ind)
computes a numerical diffusive flux for a diffusion problem including a tensor
function model = model_default(model, T, nt)
model = model_default(model)
Definition: model_default.m:17
Reduced basis implementation for non-linear evolution equations.
function model = unitcube(model)
function adding fields to model for generating a 2D rectgrid with 100 x 100 elements on the unit-squa...
Definition: unitcube.m:17
function num_flux = fv_num_conv_flux_engquist_osher(model, model_data, U, NU_ind)
Function computing a numerical convective Engquist-Osher flux matrix.
function [ flux , lambda ] = conv_flux_linear(glob, U, params)
function computing the convective flux of a convection problem.