rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
thermalblock_output_function.m
1 function s=thermalblock_output_function(model_data)
2 
3 % output computation: Integral over boundary segment
4 
5 
6 %shortcuts
7 p=model_data.grid.p;
8 e=model_data.grid.e;
9 t=model_data.grid.t;
10 
11 zero_y_ind=find(p(2,:)==0); %find indices with y=0
12 
13 x_values=p(1,:);
14 x_value=x_values(zero_y_ind); %corresponding x values with y=0
15 
16 [x_value_sort,i]=sort(x_value); %sort vector
17 
18 u_zero_y=u(zero_y_ind); %u values at y=0
19 u_zero_y_sort=u_zero_y(i); %corresponding u values sorted
20 
21 %the following section tests, if the vector x_value contains 0,1, because
22 %we want to compute the integral in the intervall [0,1].
23 if min(x_value) ~= 0
24  x_value=[0,x_value];
25  u_zero=interp1(x_value_sort, u_zero_y_sort,0, 'cubic');
26  u_zero_y_sort=[u_zero,u_zero_y_sort];
27 end
28 
29 if max(x_value) ~= 1
30  x_value=[x_value ,1];
31  u_one = interp1(x_value_sort,u_zero_y_sort,1,'cubic');
32  u_zero_y_sort=[u_zero_y_sort,u_one];
33 end
34 
35 s = trapz(x_value_sort, u_zero_y_sort);
36 
37 if model.plot_output == 1
38  figure;
39  plot(x_value_sort, u_zero_y_sort)
40 end