rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
porsche_output_functional.m
1 function out_func = porsche_output_functional(model, model_data, uh)
2 %function out_func = porsche_output_functional(model, model_data, uh)
3 %
4 % function calculates the detailed output functional of the porsche model.
5 %
6 % The output-functional is:
7 % \int_{\Omega_{front,ref}} v \times t dx
8 % so the gradient of the solution (this is v) times the tangent on the
9 % front of the car.
10 %
11 % needed fields in model_data:
12 % model_data.front_ref_domain.linear_ind_front : linear indices of the
13 % car-front
14 %
15 %
16 %
17 % Oliver Zeeb, 05.05.11
18 
19 
20 out_func=[];
21 
22 %%%%%%%%%%%%%%%%%%%
23 % calculation of the gradient of the solution
24 %%%%%%%%%%%%%%%%%%%
25 % PASST DIE GRADIENTENBERECHNUNG????
26 %calculation of the gradient in the midpoints of the front-elements!
27 %since we need to calculate the gradient, which is not defined in the
28 %vertices of the grid, we need to get the midpoints of the elements
29 %and calculate the gradient in these points
30 % el_midpts_x=model_data.grid.CX(el_ind_front);
31 % el_midpts_y=model_data.grid.CY(el_ind_front);
32 %[uh_grad_front_x, uh_grad_front_y] = disc_gradient([el_midpts_x, el_midpts_y], uh);
33 
34 %calculation of the gradient in the midpoints of the front-edges!
35 % edge_midpts_x=model_data.grid.ECX(linear_ind_front);
36 % edge_midpts_y=model_data.grid.ECY(linear_ind_front);
37 edge_length=model_data.front_ref_domain.edge_length_front;
38 edge_midpts=model_data.front_ref_domain.edge_midpts_front;
39 [uh_grad_front_x, uh_grad_front_y] = ...
40  disc_gradient(edge_midpts, uh);
41 % PASST DIE GRADIENTENBERECHNUNG????
42 %%%%%%%%%%%%%%%%%%%
43 
44 %Bei linearen finiten elementen ist der gradient auf dem gesamten element
45 %konstant!!! --> Ich darf in der Mitte auswerten und dann über den Rand
46 %integrieren.
47 % Daher die Ausgabe, dass nur pdeg=1 verwendet werden darf!
48 if(model.pdeg ~= 1)
49  warning('Polynomial degree of Finite Elements is ~= 1!')
50  warning('Output calculation is not correct!')
51 end
52 
53 tx_front = model_data.front_ref_domain.tangent_front(:,1);
54 ty_front = model_data.front_ref_domain.tangent_front(:,2);
55 grad_times_t = tx_front.*uh_grad_front_x + ty_front.*uh_grad_front_y;
56 %integral as sum
57 out_func = edge_length' * grad_times_t;
58 
59 % NOT NEEDED SO FAR:
60 %
61 %pressure=compute_pressure(model,uh_grad_front_x,uh_grad_front_y);
62 %
63 %X_front and Y_front are the vertices of the grid that belong to the
64 %front of the car:
65 % p_ind_front=model_data.grid.VI(linear_ind_front); %indices of the points belonging to the front
66 % X_front = model_data.grid.X(p_ind_front);
67 % Y_front = model_data.grid.Y(p_ind_front);
68 
69 
70 
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 %%% Tests zu dieser Funktion!
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 
75 %TESTPLOT 1:
76 %FINDET ER DIE RICHTIGEN FRONT-ELEMENTE?!
77 %--> Frontelemente einzeln plotten!
78 %
79 % grid=model_data.grid;
80 % figure(2)
81 % hold on
82 % for k=1:length(el_ind_front)
83 % x=grid.X(grid.VI(el_ind_front(k),:));
84 % x=[x;grid.X(grid.VI(el_ind_front(k),1))]; %ersten punkt hinten hinhängen
85 %
86 % y=grid.Y(grid.VI(el_ind_front(k),:));
87 % y=[y;grid.Y(grid.VI(el_ind_front(k),1))];
88 %
89 % plot(x,y)
90 % end
91 % axis equal
92 %ENDE: TESTPLOT 1
93 
94 %TESTPLOT 2:
95 %FINDET ER DIE RICHTIGEN FRONT-PUNKTE?
96 %
97 % plot(X_front,Y_front,'.');
98 % axis equal
99 %ENDE: TESTPLOT 2
100 
101 %TESTPLOT 3:
102 %PLOTTE DIE NORMALEN- UND TANGENTENVEKTOREN
103 %
104 % s = 1; %plot start
105 % e = length(nx_front); %plot end
106 % %e = 1;
107 % figure(1)
108 % quiver(model_data.grid.CX(el_ind_front(s:e)),model_data.grid.CY(el_ind_front(s:e)), nx_front(s:e), ny_front(s:e), 'blue')
109 % hold on
110 % quiver(model_data.grid.CX(el_ind_front(s:e)),model_data.grid.CY(el_ind_front(s:e)), tx_front(s:e), ty_front(s:e), 'red')
111 % axis equal
112 % legend('Normale','Tangente')
113 %ENDE: TESTPLOT 3
114 
115 
116 % TEST 1: Gradient in Normalenrichtung aufsummiert --> sollte eigentlich 0
117 % geben wegen Neumann-0-Randbedingungen
118 %
119 % grad_times_n = nx_front.*uh_grad_front_x + ny_front.*uh_grad_front_y;
120 % out_func_n = edge_length' * grad_times_n;
121 % NOCH SEHR HOCH?! Sollte doch eigentlich in der nähe von 0 liegen, wegen
122 % neumann randbedingungen...
123 % 645,7544 : bei originalgitter
124 % 340,7974 : einmal verfeinert in PDE-Toolbox
125 % 176,7265 : zwei mal verfeinert in PDE-Toolbox
126 % 91,1955 : drei mal verfeinert in PDE-Toolbox
127 % Fehler ist vor allem in knickpunkten sehr hoch!
128 %siehe dazu:
129 % x_plot=X_front(find(abs(grad_times_n)>5)); %wähle die x-punkte, in denen grad_times_n größer 10 ist
130 % y_plot=Y_front(find(abs(grad_times_n)>5)); % ... y-punkte ...
131 % plot(X_front,Y_front,'b.')
132 % hold on
133 % plot(x_plot,y_plot,'rd')
134 %ENDE TEST 1
135 
136 
137