3 % Script demonstrating some basic functionality of lagrange finite
4 % element functions in the RBmatlab fem implementation
7 % the more general RBmatlab +
Fem Routines
9 % B. Haasdonk, I. Maier 26.04.2011
11 disp(
'---------------------------------');
12 disp(
' lagrange FE-functions ');
13 disp(
'---------------------------------');
20 % params.dimrange = 1;
22 params.numintervals = 5;
23 model = poisson_model(params);
24 % convert to local_model:
26 grid = construct_grid(model);
28 %tmp = load(
'circle_grid');
30 disp(
'model initialized');
32 % without model_data, detailed_simulation, etc. but
explicit
33 % calls of fem operations
35 % initialize vectorial discrete
function, extract scalar
36 % component and plot basis
function
40 disp(
'initialization of femdiscfunc successful, display:');
43 disp(
'press enter to continue');
46 %
for check of dof consistency we have a plot routine:
48 disp(
'plot of global_dof_index map for consistency check:');
51 disp(
'press enter to continue');
56 disp(
'example of dof access, scalar component extraction and plot:');
57 % set second vector component in 4th basis
function nonzero;
59 locbasisfunc_index = 4;
60 df.dofs((locbasisfunc_index-1)*df.dimrange+ncomp) = 1;
61 dfscalar = scalar_component(df,2); % should be nonzero
function
62 disp([
'entry should be 1 : ',...
63 num2str(dfscalar.dofs(locbasisfunc_index))]);
66 params.subsampling_level = 6;
67 figure,plot(dfscalar,params);
68 dfscalar.dofs(:) = 0; % now zero again.
71 disp(
'press enter to continue');
75 disp(
'example of local dof access:');
76 % local dof access via local to global map
77 eind = 4; % set dof on element number 4
78 lind = (pdeg+2); % local basis
function index with lcoord (0,1/pdeg)
79 dfscalar.dofs(dfscalar.global_dof_index(eind,lind)) = 1;
81 % example of local evaluation of
femdiscfunc simultaneous on
82 % several elements in the same local coordinate point
83 elids = [4,6,7,10]; % evaluation on some elements
84 lcoord = [0,1/pdeg]; % local coordinate vector == last point in all triangles
85 f = evaluate(dfscalar,elids,lcoord);
86 disp(['first entry should be 1 : ',num2str(f(1))]);
87 % equivalent call (!) by () operator as abbreviation for local evaluation:
88 f = dfscalar(elids,lcoord);
89 disp(['first entry should be 1 : ',num2str(f(1))]);
91 disp('press enter to continue');
94 disp('examples of norm computation:')
100 disp(['L2-norm(f(x,y)=1) = ',num2str(fem_l2_norm(df1))]);
101 disp(['H10-norm(f(x,y)=1) = ',num2str(fem_h10_norm(df1))]);
102 df1.dofs(:) = df1.grid.X(:);
103 disp(['L2-norm(f(x,y)=x) = ',num2str(fem_l2_norm(df1))]);
104 disp(['H10-norm(f(x,y)=x) = ',num2str(fem_h10_norm(df1))]);
105 df1.dofs(:) = df1.grid.Y(:);
106 disp(['L2-norm(f(x,y)=y) = ',num2str(fem_l2_norm(df1))]);
107 disp(['H10-norm(f(x,y)=y) = ',num2str(fem_h10_norm(df1))]);
109 disp('press enter to continue');
112 % evaluate df in all lagrange nodes of element 4 by loop
114 disp(['dfscalar on element 4 in all lagrange nodes,' ...
115 'only (pdeg+2) entry should be 1:']);
116 lagrange_nodes = lagrange_nodes_lcoord(pdeg);
118 for i = 1:size(lagrange_nodes,1);
119 f = evaluate(dfscalar,elid,lagrange_nodes(i,:));
120 disp(['f(l(',num2str(i),')) = ',num2str(f)]);
123 disp('press enter to continue');
127 disp('example of requirement of subsampling in plot of discfuncs:');
129 subsamp_levels = [0,2,4,16];
130 for i=1:length(subsamp_levels)
132 params.axis_equal = 1;
133 params.subsampling_level = subsamp_levels(i);
134 params.clim = [-0.15 1.15]; % rough bounds
135 plot(dfscalar,params);
136 title(['subsampling level = ',num2str(subsamp_levels(i))]);
class representing a continous piecewise polynomial function of arbitrary dimension. DOFS correspond to the values of Lagrange-nodes.
A triangular conforming grid in two dimensions.
function demo_femdiscfunc()
Script demonstrating some basic functionality of lagrange finite element functions in the RBmatlab fe...
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...
function demo_fem2_discfunc()
This demo shows the basic functionality of the discrete function class Fem.DiscFunc.