1 function out_func = porsche_output_functional(model, model_data, uh)
2 %
function out_func = porsche_output_functional(model, model_data, uh)
4 %
function calculates the detailed output functional of the porsche model.
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
11 % needed fields in model_data:
12 % model_data.front_ref_domain.linear_ind_front : linear indices of the
17 % Oliver Zeeb, 05.05.11
23 % calculation of the gradient of the solution
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);
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????
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
47 % Daher die Ausgabe, dass nur pdeg=1 verwendet werden darf!
49 warning(
'Polynomial degree of Finite Elements is ~= 1!')
50 warning('Output calculation is not correct!')
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;
57 out_func = edge_length' * grad_times_t;
61 %pressure=compute_pressure(model,uh_grad_front_x,uh_grad_front_y);
63 %X_front and Y_front are the vertices of the grid that belong to the
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);
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 %%% Tests zu dieser Funktion!
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 %FINDET ER DIE RICHTIGEN FRONT-ELEMENTE?!
77 %--> Frontelemente einzeln plotten!
79 % grid=model_data.grid;
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
86 % y=grid.Y(grid.VI(el_ind_front(k),:));
87 % y=[y;grid.Y(grid.VI(el_ind_front(k),1))];
95 %FINDET ER DIE RICHTIGEN FRONT-PUNKTE?
97 % plot(X_front,Y_front,'.');
102 %PLOTTE DIE NORMALEN- UND TANGENTENVEKTOREN
105 % e = length(nx_front); %plot end
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')
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')
112 % legend('Normale','Tangente')
116 % TEST 1: Gradient in Normalenrichtung aufsummiert --> sollte eigentlich 0
117 % geben wegen Neumann-0-Randbedingungen
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!
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.')
133 % plot(x_plot,y_plot,'rd')