rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
init_values_bars.m
1 function U0 = init_values_bars(glob,params)
2 %function U0 = init_values_bars(glob,params)
3 %
4 % function constructing the initial values of the convection diffusion
5 % problem in the specified global points glob and parameters.
6 % It returns an initial data function that is mosly homogeneous with several
7 % (seven) blob like structures of higher concentration that drops exponentially
8 % away from their centres.
9 %
10 % required fields in params
11 % c_init: constant for homogeneous initial data to be returned
12 %
13 % in 'coefficient' mode the model_data structure is empty
14 
15 % Martin Drohmann 23.9.2009
16 
17 % glob column check
18 if params.debug
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');
21  if params.debug > 2
22  keyboard;
23  end
24  end
25 end
26 decomp_mode = params.decomp_mode;
27 
28 if ~isfield(params, 'bars_width')
29  params.bars_width = 0.10;
30 end
31 
32 if decomp_mode == 2
33  U0 = [params.c_init, [1, 1/2, 1/3, 1/4, 1/5]*0.5];
34 else
35  X = glob(:,1);
36  Y = glob(:,2);
37  offset1 = 1.1-params.bars_width/2;
38  offset2 = 1.1+params.bars_width/2;
39  if decomp_mode == 0
40  U0 = params.c_init * ones(length(X),1);
41  Uleft = zeros(size(X));
42  for i = 1:3
43 % U0 = U0 + 0.5/i*(X(:) > -0.123+0.2*i & X(:) < -0.077+0.2*i & Y(:) < 0.5);
44  Uleft = Uleft + 0.5/i*(X > offset1-0.2*i & X < offset2-0.2*i & Y > 0.5 & X > 0.5) ...
45  + 0.5/(6-i)*(X > offset1-0.2*i & X < offset2-0.2*i & Y < 0.5 & X > 0.5);
46 % U0 = U0 + 0.5/i*(X(:) > 1.075-0.2*i & X(:) < 1.125-0.2*i & Y(:) > 0.5);
47 % U0 = U0 + 0.5/(6-i)*(X(:) > 1.075-0.2*i & X(:) < 1.125-0.2*i & Y(:) < 0.5);
48  end
49  ysize = size(Uleft, 2);
50  xsize = size(Uleft, 1);
51 
52  Uright(xsize:-1:1, ysize:-1:1) = Uleft;
53  U0 = U0 + Uleft(:) + Uright(:) + 0.5/3 * (X==0.5);
54  elseif decomp_mode == 1
55  U0 = cell(7,1);
56  U0{1} = ones(length(X),1);
57  Uleft = cell(6,1);
58  Uright = cell(6,1);
59  for i = 1:6
60  Uleft{i} = zeros(size(X));
61  end
62  for i = 1:3
63  Uleft{i} = Uleft{i} + ...
64  (X > offset1-0.2*i & X < offset2-0.2*i & Y > 0.5 & X > 0.5);
65  Uleft{6-i} = Uleft{6-i} + ...
66  (X > offset1-0.2*i & X < offset2-0.2*i & Y < 0.5 & X > 0.5);
67  end
68  ysize = size(Uleft{1}, 2);
69  xsize = size(Uleft{1}, 1);
70  for i = 1:6
71  Uright{i}(xsize:-1:1, ysize:-1:1) = Uleft{i};
72  end
73  for i = 1:6
74  U0{i+1} = Uleft{i}(:) + Uright{i}(:);
75  end
76  U0{4} = U0{4} + 0.5/3 * (X==0.5);
77  else
78  error(['decomp_mode number ' decomp_mode, ' is unknown.']);
79  end
80 end
81 
82 %| \docupdate