3 % init value
function with a gradient box profile in Y-direction as output
5 %
function constructing the initial values of the convection diffusion
6 % problem in the specified global points glob and parameters.
7 % ``u_0 = ( c_0 (y-y_{\min}) + c_1 (y_{\max}-y) ) \cdot
8 % \frac{1}{y_{\max}-y_{\min}} \cdot \chi_{B}``
9 % where `B=[x_{\min},x_{\max}] \times [y_{\min},y_{\max}]` denotes the
10 % gradient box with `(x_{\min},x_{\max}) = (0.35,0.55)` and
11 % `(y_{\min},y_{\max}) = (0.2,0.9)`.
13 % required fields of params:
14 % c_init_up : constant value at upper boundary of gradient box `c_0`
15 % c_init_low : constant value at lower boundary of gradient box `c_1`
19 if ~isempty(glob) && size(glob,1) < size(glob,2)
20 warning('coordinates in variable glob are given row-wise, but expected them to be column-wise');
27 decomp_mode = params.decomp_mode;
30 U0 = [params.c_init_up, params.c_init_lo];
37 ymax = ymid+ height/2;
39 BX = abs(glob(:,1)-xmid);
40 BY = abs(glob(:,2)-ymid);
41 I = (BX<width/2) & (BY<height/2);
42 % y = ymin => 0 + c_init_lo
43 % y = ymax => c_init_up + 0
44 U0 = (params.c_init_up * (glob(:,2)-ymin) + ...
45 + params.c_init_lo * (ymax-glob(:,2))) .* I / (ymax-ymin);
46 elseif decomp_mode == 1
48 BX = abs(glob(:,1)-xmid);
49 BY = abs(glob(:,2)-ymid);
50 I = (BX<width/2) & (BY<height/2);
51 U0{1} = (glob(:,2)-ymin) .* I / (ymax-ymin);
52 U0{2} = (ymax-glob(:,2)) .* I / (ymax-ymin);
function U0 = init_values_gradient_box(glob, params)
init value function with a gradient box profile in Y-direction as output