rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
demo_interpol.m
Go to the documentation of this file.
1 function demo_interpol
2 %function femo_interpol
3 % Script using femdiscfunc for interpolating functions by local and
4 % global evaluations.
5 
6 % B. Haasdonk, I. Maier 26.04.2011
7 
8 disp('-------------------------------');
9 disp(' FE-interpolation demo ');
10 disp('-------------------------------');
11 
12 % poisson_model
13 params = [];
14 pdeg = 4;
15 params.pdeg = pdeg;
16 params.dimrange = 1;
17 params.numintervals = 5;
18 % model with evaluations via global coordinates
19 model = poisson_model(params);
20 % convert to model allowing local grid evaluations:
21 model = elliptic_discrete_model(model);
22 grid = construct_grid(model);
23 %tmp = load('circle_grid');
24 %grid = triagrid(tmp.p,tmp.t,[]);
25 disp('model initialized');
26 
27 % interpolate exact solution and other coefficient functions
28 % as fem-function and plot
29 
30 disp('examples of interpolation of analytical functions:');
31 df_info=feminfo(model,grid);
32 df = femdiscfunc([],df_info);
33 
34 df = fem_interpol_global(model.solution, df);
35 plot(df);
36 title('analytical solution');
37 
38 % discretize source function and plot
39 
40 %df = fem_interpol_local(model.source, df);
41 df = fem_interpol_global(model.source, df);
42 figure,plot(df);
43 title('source function');
44 
45 % interpolation of explicit inline function x^2+y^2:
46 f = @(glob,params) glob(:,1).^2 + glob(:,2).^2;
47 df = fem_interpol_global(f, df);
48 figure,plot(df);
49 title('function handle for x^2+y^2');
50 
51 % interpolation of df in finer fem space:
52 par.pdeg = 4;
53 par.qdeg = 8;
54 par.dimrange = 1;
55 p4_df_info = feminfo(par,df.grid);
56 df2 = femdiscfunc([],p4_df_info);
57 df_local_eval = @(grid,elids,lcoord,params) ...
58  fem_evaluate(df,elids,lcoord,[],[]);
59 % my_local_eval(grid,elids,lcoord,params,df);
60 df2 = fem_interpol_local(df_local_eval,df2);
61 figure,plot(df2);
62 title('local interpolation of discrete function');
class representing a continous piecewise polynomial function of arbitrary dimension. DOFS correspond to the values of Lagrange-nodes.
Definition: femdiscfunc.m:17
A triangular conforming grid in two dimensions.
Definition: triagrid.m:17
function local_model = elliptic_discrete_model(model)
function creating a model with local functions out of a model with global functions. See detailed description for explanation.
structure representing the fem-space information shared by all fem-functions. Implemented as handle c...
Definition: feminfo.m:17
function demo_interpol()
Script using femdiscfunc for interpolating functions by local and global evaluations.
Definition: demo_interpol.m:17