-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalcManual.m
84 lines (59 loc) · 1.92 KB
/
CalcManual.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
prepare
set(0,'defaultlinelinewidth',4)
set(0,'defaultaxesfontsize',12)
%% Input
%config_simple;
%config_simple
%config_task4_K40_N4_absorbing_hdg
%config_task4_K40_N4_dirichlet_hdg
%config_task4_K40_N4_absorbing_lf
%config_task4_K40_N4_dirichlet_lf
%config_task5_K40_N4_dirichlet_hdg
%config_task3_K5_N1_HDG
%config_task3_K10_N1_HDG
%config_task3_K20_N1_HDG
%config_task3_K40_N1_HDG
config_task3_K80_N1_HDG
CheckInput(p);
%% Create mesh
mesh=Mesh(p);
% p.timeint.step=0.001*mesh.get_h()/(mesh.get_cmax*p.mesh.polygrad^2);
% p.timeint.step
%error('asdasd')
%% Create flux matrix
fluxer = Flux(mesh,p.bc.type);
[F,Fbound] = fluxer.EvaluateF(p.fluxtype);
%% Create other matrices
[ M,S ] = AssembleAll( mesh );
%% Consistency chekc on F-matrix
%CheckFmat(F);
%% Initial conditions
uinit=p.bc.init(mesh.nodevec);
uinit=reshape(uinit,numel(uinit),1);
%% Time Integration
%creating timesteps
numstep = floor((p.timeint.tend-0)/p.timeint.step);
timevec = (0:numstep)*p.timeint.step;
% creating selector for subset of timesteps
timestepselector=round(linspace(1,length(timevec),p.timeint.numselect));
inverseM=inv(M);
D=inverseM*(S-F-Fbound);
integrator=TimeInt(p.timeint.method,D,numstep,p.timeint.step);
Useries =integrator.Integrate(uinit,Fbound);
%select solution subset
U_selected= Useries(:,timestepselector);
time_selected=timevec(timestepselector)';
%% Error Evaluation
postproc=PostProc(mesh,p.bc.anasol,p.timeint.step);
L2mat =postproc.EvalL22(U_selected,time_selected);
%% Output Writer
outwriter=OutWriter(mesh,setupname,p.timeint.numselect,p.bc.anasol);
outwriter.Write(Useries,L2mat,timevec)
%outwriter.WriteErr(L2mat,timevec)
%% Plot Solution
plotter=Plotter1D(mesh,p.bc.anasol);
plotter.PlotSol2D(figure(),mesh.nodevec,time_selected,U_selected);
%plotter.PlotSol3D(figure(),mesh.nodevec,time_selected,U_selected);
plotter.PlotErr(figure(),L2mat,time_selected)
f=figure();
plotter.PlotAnimation(f,time_selected,U_selected);