3 % This demo shows the basic functionality of the discrete
function class
14 params.numintervals = 5;
16 model = poisson_model(params);
17 % add fields
for generic fem
21 grid = construct_grid(model);
22 % generate discrete
function info
25 copy(df_info_scalar),
'dim2', ...
26 copy(df_info_scalar),
'dim3');
28 disp(
'model initialized, display function space:');
31 % initialize vectorial discrete
function, extract scalar
32 % component and plot basis
function
33 df =
Fem.
DiscFunc([], df_info); % initialize zero df
36 disp(
'initialization of discrete function successful, display:');
39 disp(
'press enter to continue');
42 % dof consistency / dofmap ?
46 disp(
'example of dof access, scalar component extraction and plot:');
47 % set second vector component in 4th basis
function nonzero
49 locbasisfunc_index = 4;
50 df.dofs((ncomp-1)*df_info_scalar.ndofs + locbasisfunc_index) = 1;
51 % extract scalar component
52 dfscalar = get_component(df, 2); % should be nonzero
function
53 disp([
'entry should be 1 : ', ...
54 num2str(dfscalar.dofs(locbasisfunc_index))]);
56 % automatic plot of all dimensions,
id-strings are used as titles
58 params.subsampling_level = 6;
59 figure, plot(df, params);
61 disp(
'press enter to continue');
65 % interpolate global gaussian
function, plot result
67 disp(
'interpolation of global function and plot:');
68 func = @(glob, params) exp(-10*sum((glob-repmat([0.5, 0.5], size(glob, 1), 1)).^2, 2));
69 df_gauss = interpol_global(df_info_scalar, func);
70 figure, plot(df_gauss);
71 title(
'df: interpolated gaussian');
73 disp(
'press enter to continue');
76 % interpolate the derivatives (smaller pdeg), plot results
78 disp(
'evaluation of derivatives (interpolation of local functions) and plot:');
81 func = @(vgrid,el,lcoord,params) subsref(df_gauss.evaluate_derivative(el,lcoord), ...
82 struct(
'type',
'()',
'subs', {{
':', 1}}));
83 df_dx = interpol_local(df_info_scalar2, func);
88 func = @(vgrid,el,lcoord,params) subsref(df_gauss.evaluate_derivative(el,lcoord), ...
89 struct(
'type',
'()',
'subs', {{
':', 2}}));
90 df_dy = interpol_local(df_info_scalar2, func);
95 disp(
'press enter to continue');
101 disp(
'examples of norm computation:')
102 dfscalar.dofs(:) = 1;
103 disp(['L2-norm(f(x,y)=1) = ', num2str(l2_norm(dfscalar))]);
104 disp(['H10-norm(f(x,y)=1) = ', num2str(h10_norm(dfscalar))]);
105 disp('previous vector-valued function, only one DoF nonzero:');
106 disp(['L2-norm(f(0.6,0)=(0,1,0)) = ', num2str(l2_norm(df))]);
107 disp(['H10-norm(f(0.6,0)=(0,1,0)) = ', num2str(h10_norm(df))]);
scalar Lagrange FE functions on triangular grid
function model = generic_fem_model_adapter(model)
Initializes a default linear and stationary model for more generic fem discretization by modifying mo...
Composite function space for composition of FE function spaces on same grid.
represents a continous piecewise polynomial function of arbitrary dimension. Can be used for all fini...
function demo_fem2_discfunc()
This demo shows the basic functionality of the discrete function class Fem.DiscFunc.