1 function [sim_data, fl] = nonlin_evol_detailed_rb_proj_simulation(model,detailed_data, refU)
2 %
function sim_data = nonlin_evol_detailed_rb_proj_simulation(model,detailed_data)
4 % required fields of model:
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 (model, model_data)
10 % example: fv_init_values
11 % data_const_in_time :
if this optional field is 1, the time
12 % evolution is performed with constant operators,
13 % i.e. only the initial-time-operators are computed
14 % and used throughout the time simulation.
15 % L_E_local_ptr :
function pointer to the local space-discretization
16 %
operator evaluation with syntax
18 % INC_local = L_local(U_local_ext, ind_local,
20 % where *_local indicates results on a set of
21 % elements, *_local_ext includes information including
22 % their neighbours, i.e. the grid must be known
23 % also
for the neighbours, the values of the
24 % previous timstep must be known on the
25 % neighbours. The subset of elements, which are
26 % to be computed are given in ind_local and the
27 % values produced are INC_local.
28 % A time-step can then be realized by
29 % NU_local = U_local_ext(ind_local) - dt * INC_local
32 % Martin Drohmann 14.04.2007 based on detailed_nonlin_evol_simulation.m by
36 error(
'wrong number of parameters!');
40 disp(
'entered detailed simulation ');
43 %
for a detailed simulation we
do not need the affine parameter
45 model.decomp_mode = 0;
47 % initial values by midpoint evaluation
48 U0 = model.init_values_algorithm(model,detailed_data);
56 %N = model.Np + model.Nm;
57 %RBp = detailed_data.RBp;
58 %RBm = detailed_data.RBm;
60 %RB = [detailed_data.RBp,detailed_data.RBm];
61 RB = detailed_data.RB;
64 W = model.get_inner_product_matrix(detailed_data);
66 %U = vpa(zeros(length(U0(:)),model.nt+1));
67 U = zeros(length(U0(:)),model.nt+1);
68 a = zeros(N, model.nt+1);
70 %a(1:Np,1) = RBp
' * W * U0(:);
71 %U0min = U0(:) - RBp * a(1:Np,1);
72 %a(Np+1:N,1) = RBm' * W * U0min;
76 %a = RBp' * W * U0(:) + RBm
' * W * U0(:);
80 %disp(norm(U(:,1)-U0(:)));
82 if ~isfield(model,'data_const_in_time
')
83 model.data_const_in_time = 0;
86 fl = cell(model.nt, 1);
88 if model.fv_impl_diff_weight ~= 0
89 % diffusive part is computed implicitly.
91 [L_diff_I, const_diff_I] = model.implicit_operators_algorithm(model, detailed_data, []);
95 model.dt = model.T / model.nt;
98 model.t = (t-1)*model.dt;
100 if model.verbose > 19
101 disp(['entered time-loop step
',num2str(t), ' for non linear evolution equation
']);
102 elseif model.verbose > 9
106 [inc, fluxes] = model.L_E_local_ptr(model, detailed_data, U(:,t), []);
107 [refinc, dummy] = model.L_E_local_ptr(model, detailed_data, refU(:,t), []);
112 if all([model.fv_impl_conv_weight, model.fv_impl_diff_weight, model.fv_impl_react_weight] == [0, 0, 0])
113 % purely explicit scheme
114 % a(:,t+1) = a(:,t) - model.dt * ainc;
115 a(:,t+1) = a(:,t) - model.dt * inc;
116 else % scheme with implicit parts
118 inc = inc + const_diff_I;
119 % inc = double(single(inc));
120 refinc = refinc + const_diff_I;
121 % refres(t) = (inc-refinc)' * W * (inc-refinc);
123 ainc = RB
' * W * inc;
124 % ainc = RBp' * W * inc + RBm
' * W * inc;
127 % ainc(1:Np) = RBp' * W * inc;
128 % incminus = inc - RBp * ainc(1:Np);
129 % ainc(Np+1:N) = RBm
' * W * incminus;
132 L_I = L_I * model.dt + speye(size(L_I));
133 % L_I = sparse(double(single(full(L_I))));
134 aL_I = RB' * W * L_I * RB;
135 % aL_Ip = RBp
' * W * L_I * RBp + RBm' * W * L_I * RBm;
136 % aL_Im = RBm
' * W * L_I * RBp + RBp' * W * L_I * RBm;
137 % aL_I = [aL_Ip, aL_Im; aL_Im, aL_Ip];
138 %aL_I = RBp
' * W * L_I * RBp + RBp' * W * L_I * RBm + RBm
' * W * L_I * RBp + RBm' * W * L_I * RBm;
139 % L_I = speye(size(L_diff_I));
141 arhs = a(:,t) - model.dt * ainc; % + model.dt * L_diff_I * U(:,t);
142 % rhs = U(:,t) - model.dt * RB * ainc; % + model.dt * L_diff_I * U(:,t);
143 % rhsdiff = U(:,t) - model.dt * inc - refU(:,t) + model.dt * refinc;
144 % rhsres(t) = rhsdiff
' * W * rhsdiff;
149 % U(:,t+1) = L_I \ rhs;
150 % atemp = aL_I \ [arhs; zeros(size(arhs))];
151 % a(:,t+1) = atemp(1:length(arhs)) + atemp(length(arhs)+1:end);
152 a(:,t+1) = aL_I \ arhs;
153 % [a(:,t+1), flag] = bicgstab(aL_I, arhs, 100*eps, 1000);
154 % a(:,t+1) = aL_I \ arhs;
155 % LIresi = RB * a(:,t+1) - (RB*RB')*W*U(:,t+1);
156 % a(:,t+1) = aL_I \ arhs;
157 % residuum = aL_I * a(:,t+1) - arhs;
158 % residuum = residuum
' * residuum;
160 % U(:,t+1) = L_I \ rhs;
161 % disp(condest(L_I));
162 U(:,t+1) = RB * a(:,t+1);
163 % residuum = L_I * U(:,t+1) - U(:,t) + model.dt * inc;
164 % res(t) = sqrt(residuum' * W * residuum);
165 % LIres(t) = sqrt(LIresi
' * W * LIresi);
166 % Urefres(t+1) = sqrt((U(:,t+1)-refU(:,t+1))' * W * (U(:,t+1)-refU(:,t+1)));
167 % disp([
'res: ', num2str(res(t))]);
168 % disp([
'inc: ', num2str(refres(t))]);
169 % disp([
'rhs: ', num2str(rhsres(t))]);
170 % disp([
'LI: ', num2str(LIres(t))]);
171 % disp([
'err: ', num2str(Urefres(t))]);
174 % a(:,t+1) = RB
' * W * U(:,t+1);
175 % U(:,t+1) = RB * a(:,t+1);
177 disp(['error in system solution, solver
return flag =
', ...
184 % disp(['res: max=
', num2str(max(res)), ' sum=
', num2str(sum(res))]);
185 % disp(['inc: max=
', num2str(max(refres)), ' sum=
', num2str(sum(refres))]);
186 % disp(['rhs: max=
', num2str(max(rhsres)), ' sum=
', num2str(sum(rhsres))]);
187 % disp(['LI: max=
', num2str(max(LIres)), ' sum=
', num2str(sum(LIres))]);
function INC = fv_conv_explicit_space(U, NU_ind,gridbase grid, params)
fv_conv_explicit_space(U,NU_ind,grid,params) function applying an FV-space-discretization operator st...