rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
df_func_difference_sqr.m
1 function res = df_func_difference_sqr(lcoord,df,func)
2 %function res = df_func_difference_sqr(lcoord,df,func)
3 %
4 % auxiliary function computing the difference, which is used in l2
5 % error computation between a function allowing local element
6 % evaluation and a ldg function multiplied with integration_element
7 % ( = * triangle volume) due to transformation formula
8 %
9 % lcoord is a 2-vector of local coordinates, dofs a dof vector of
10 % the discrete function, func the analytical
11 % function with calling syntax func(einds,locs,grid,params)
12 % res is a vector of projected values on all elements. This
13 % function can be used for integration and results in the l2error
14 
15 % Bernard Haasdonk 5.2.2009
16 
17 nel = df.grid.nelements;
18 % F and DF will be a nelements x dimrange matrix
19 if isa(func, 'ldgdiscfunc')
20  %func.grid = grid;
21  F = func(1:nel,lcoord);
22 else
23  F = func(1:nel,lcoord, df.grid);
24 end
25 DF = df(1:nel,lcoord);
26 
27 if df.dimrange == 1
28  res = (DF-F).^2;
29 else
30  res = sum((DF-F).^2,2);
31 end;
32 res = res(:).*df.grid.A * 2;
33 
34 %| \docupdate