rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
ldg_conv_detailed_simulation.m
1 function sim_data = ldg_conv_detailed_simulation(model,model_data,dummy)
2 %function sim_data = ldg_conv_detailed_simulation(model,model_data,dummy)
3 %
4 % required fields of model:
5 % T : final time
6 % nt : number of time-intervals until T, i.e. nt+1
7 % solution slices are computed
8 % init_values_algorithm: name of function for computing the
9 % initvalues-DOF with arguments (grid, params)
10 % example: init_values_cog
11 % operators_algorithm: name of function for computing the
12 % L_E,L_I,b-operators with arguments (grid, params)
13 % example operators_conv_diff
14 % data_const_in_time : if this optional field is 1, the time
15 % evolution is performed with constant operators,
16 % i.e. only the initial-time-operators are computed
17 % and used throughout the time simulation.
18 %
19 % fields of sim_data: U an array of columnwise degrees of freedom-vectors
20 
21 % Bernard Haasdonk 27.8.2009
22 
23 disp(' to be adjusted!! ');
24 keyboard;
25 
26 if model.verbose >= 9
27  disp(['entered detailed simulation ']);
28 end;
29 
30 if isempty(model_data)
31  model_data = gen_model_data(model);
32 end;
33 
34 model.decomp_mode = 0; % == complete;
35 model.t = 0;
36 
37 % initial values by midpoint evaluation
38 U0 = model.init_values_algorithm(model,model_data);
39 
40 %Uzero = U0;
41 %Uzero.dofs = 0;
42 
43 % preallocate U
44 U = zeros(length(U0),model.nt+1);
45 U(:,1)=U0;
46 model.dt = model.T/model.nt;
47 %operators_required = 1;
48 %if ~isfield(model,'data_const_in_time')
49 % model.data_const_in_time = 0;
50 %end,
51 
52 params = model;
53 params.axis_equal = 1;
54 model.plot(U0,model_data.grid,params);
55 keyboard;
56 
57 % loop over time-steps
58 for t = 1:model.nt
59 % keyboard;
60  if model.verbose >= 10
61  disp(['entered time-loop step ',num2str(t)]);
62  end;
63  if model.verbose == 9
64  fprintf('.');
65  end;
66  % get matrices and bias-vector
67 
68  if operators_required
69  model.t = (t-1)*model.dt;
70  [L_I, L_E, b] = model.operators_ptr(model, model_data);
71  if model.data_const_in_time
72  operators_required = 0;
73  end;
74  end;
75 
76  rhs = L_E * U{t}.dofs + b;
77  if isequal(L_I, speye(size(L_I)))
78  U{t+1}.dofs = rhs;
79  else
80  % solve linear system
81  % disp('check symmetry and choose solver accordingly!');
82  % keyboard;
83  % nonsymmetric solvers:
84  % [U(:,t+1), flag] = bicgstab(L_I,rhs,[],1000);
85  % [U(:,t+1), flag] = cgs(L_I,rhs,[],1000);
86  %
87  % symmetric solver, non pd:
88  % omit symmlq:
89  % see bug_symmlq.mat for a very strange bug: cannot solve identity system!
90  % reported to matlab central, but no solution up to now.
91  % [U(:,t+1), flag] = symmlq(L_I,rhs,[],1000);
92  %
93  % [U(:,t+1), flag] = minres(L_I,rhs,[],1000);
94  % symmetric solver, pd:
95  %[U(:,t+1), flag] = pcg(L_I,rhs,[],1000);
96  % bicgstab works also quite well:
97  %[U(:,t+1), flag] = bicgstab(L_I,rhs,[],1000);
98  U{t+1}.dofs = L_I \ rhs;
99 
100 % if flag>0
101 % disp(['error in system solution, solver return flag = ', ...
102 % num2str(flag)]);
103 % keyboard;
104 % end;
105  end;
106 end;
107 
108 if model.verbose == 9
109  fprintf('\n');
110 end;
111 
112 sim_data.U = U;
113 
114 %| \docupdate