rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
test_ldgfunc.m
1 function OK = test_ldgfunc
2 % function testing ldgfunc abilities
3 %
4 % currently testing:
5 % l2projection of vectorial function
6 % extraction of scalar component
7 % local evaluation of vectorial function
8 % ldg_l2error
9 
10 % Bernard Haasdonk 18.1.2010
11 
12 OK = 1;
13 
14 % initialize grid
15 grid = triagrid();
16 
17 %params.nelements = grid.nelements;
18 params.pdeg = 1;
19 params.dimrange = 2; % vectorial function
20 %params.ndofs = ldg_ndofs(params);
21 %params.ndofs_per_element = ldg_ndofs_per_element(params);
22 df_info = ldginfo(params,grid);
23 
24 % function constant [1.0, 1.0]
25 f = @(einds,loc,grid,params) ones(length(einds),1)*[1.0, 1.0];
26 
27 %f = @(einds,loc,grid,params) f_global(...
28 % local2global(grid,einds,loc,params),params);
29 
30 qdeg = 4;
31 df = ldgdiscfunc(df_info);
32 df.dofs = ldg_l2project(f,qdeg,df_info);
33 
34 df_scalar = scalar_component(df,1);
35 %[dofs1, params1 ] = ldg_scalar_component(dofs,1,params);
36 %disp('local evaluation should be constant [1 1]');
37 
38 res = df(1:10,[0,0]);
39 if max(max(abs(res-ones(10,df.dimrange))))>1e-6
40  disp('test_ldgfunc: local evaluation result of projected dofs not [1,1]!!');
41  OK = 0;
42 end;
43 
44 res = df_scalar(1:10,[0,0]);
45 if max(max(abs(res-ones(10,1))))>1e-6
46  disp('test_ldgfunc: local evaluation of scalar component not 1!!');
47  OK = 0;
48 end;
49 
50 res = ldg_l2error(df,f,qdeg);
51 if abs(res)>1e-6
52  disp('test_ldgfunc: ldg_l2error not 0!!');
53  OK = 0;
54 end;
55 
56 %disp('plot should be constant 1');
57 %plot(df_scalar,[]);