rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules 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 
25 if model.verbose >= 9
26  disp(['entered detailed simulation ']);
27 end;
28 
29 if isempty(model_data)
30  model_data = gen_model_data(model);
31 end;
32 
33 model.decomp_mode = 0; % == complete;
34 model.t = 0;
35 
36 % initial values by midpoint evaluation
37 U0 = model.init_values_algorithm(model,model_data);
38 
39 %Uzero = U0;
40 %Uzero.dofs = 0;
41 
42 % preallocate U
43 U = zeros(length(U0),model.nt+1);
44 U(:,1)=U0;
45 model.dt = model.T/model.nt;
46 %operators_required = 1;
47 %if ~isfield(model,'data_const_in_time')
48 % model.data_const_in_time = 0;
49 %end,
50 
51 params = model;
52 params.axis_equal = 1;
53 model.plot(U0,model_data.grid,params);
54 keyboard;
55 
56 % loop over time-steps
57 for t = 1:model.nt
58 % keyboard;
59  if model.verbose >= 10
60  disp(['entered time-loop step ',num2str(t)]);
61  end;
62  if model.verbose == 9
63  fprintf('.');
64  end;
65  % get matrices and bias-vector
66 
67  if operators_required
68  model.t = (t-1)*model.dt;
69  [L_I, L_E, b] = model.operators_ptr(model, model_data);
70  if model.data_const_in_time
71  operators_required = 0;
72  end;
73  end;
74 
75  rhs = L_E * U{t}.dofs + b;
76  if isequal(L_I, speye(size(L_I)))
77  U{t+1}.dofs = rhs;
78  else
79  % solve linear system
80  % disp('check symmetry and choose solver accordingly!');
81  % keyboard;
82  % nonsymmetric solvers:
83  % [U(:,t+1), flag] = bicgstab(L_I,rhs,[],1000);
84  % [U(:,t+1), flag] = cgs(L_I,rhs,[],1000);
85  %
86  % symmetric solver, non pd:
87  % omit symmlq:
88  % see bug_symmlq.mat for a very strange bug: cannot solve identity system!
89  % reported to matlab central, but no solution up to now.
90  % [U(:,t+1), flag] = symmlq(L_I,rhs,[],1000);
91  %
92  % [U(:,t+1), flag] = minres(L_I,rhs,[],1000);
93  % symmetric solver, pd:
94  %[U(:,t+1), flag] = pcg(L_I,rhs,[],1000);
95  % bicgstab works also quite well:
96  %[U(:,t+1), flag] = bicgstab(L_I,rhs,[],1000);
97  U{t+1}.dofs = L_I \ rhs;
98 
99 % if flag>0
100 % disp(['error in system solution, solver return flag = ', ...
101 % num2str(flag)]);
102 % keyboard;
103 % end;
104  end;
105 end;
106 
107 if model.verbose == 9
108  fprintf('\n');
109 end;
110 
111 sim_data.U = U;
112 
113 %| \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