rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
init_values_bl.m
1 function U0 = init_values_bl(glob,params)
2 %function U0 = init_values_bl(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 
27 decomp_mode = params.decomp_mode;
28 
29 if ~isfield(params, 'c_width')
30  params.c_width = 0.35;
31 end
32 if ~isfield(params, 'c_height')
33  params.c_height = 0.50;
34 end
35 
36 xoff = params.c_width/2;
37 yoff = params.c_height/2;
38 
39 if decomp_mode == 2
40  U0 = [params.c_high, params.c_low];
41 else
42  X = glob(:,1);
43  Y = glob(:,2);
44 
45  square = X>0.4-xoff & X<0.4+xoff & Y>0.5-yoff & Y < 0.5+yoff;
46 
47  if decomp_mode == 0
48  U0 = zeros(length(X),1);
49  U0(square) = params.c_high;
50  U0(U0 == 0) = params.c_low;
51 
52  elseif decomp_mode == 1
53  U0 = cell(2,1);
54  U0{1} = zeros(length(X),1);
55  U0{2} = zeros(length(X),1);
56  U0{1}(square) = 1;
57  U0{2} = 1 - U0{1};
58  else
59  error(['decomp_mode number ' decomp_mode, ' is unknown.']);
60  end
61 end
62