3 % scalar Lagrange FE functions on triangular grid
5 properties (SetAccess =
private)
15 % index vector of global DOFs
21 % weight matrix for `L^2` inner product
22 l2_inner_product_matrix;
24 % weight matrix for `H^1_0` inner product
25 h10_inner_product_matrix;
30 properties (SetAccess = private, Dependent)
43 df_info.ndofs = lagrange_ndofs(df_info);
44 df_info.ndofs_per_element = (pdeg+1) * (pdeg+2) / 2;
46 df_info.dof_ids_local = {1:df_info.ndofs_per_element};
48 df_info.global_dof_index =
Fem.
Lagrange.global_dof_index(df_info, grid);
50 df_info.basis_weight_matrix = lagrange_basis_weight_matrix(df_info);
52 df_info.dofs_lcoord =
Fem.
Lagrange.nodes_lcoord(pdeg);
53 df_info.dofs_edges_llcoord =
Fem.
Lagrange.nodes_edges_llcoord(df_info.dofs_lcoord);
55 % reaction term == 1 then reaction matrix is l2matrix
57 model.disable_caching = 1;
59 @(grid, eindices, loc, params) ones(length(eindices), 1);
60 model.qdeg = 2*df_info.pdeg;
61 df_info.l2_inner_product_matrix =
Fem.
Assembly.matrix_part(...
64 % H10_inner_product_matrix: identity diffusion
65 model.diffusivity_tensor = @(grid, eindices, loc, params) ...
66 [ones(length(eindices), 1), zeros(length(eindices), 1), ...
67 zeros(length(eindices), 1), ones(length(eindices), 1)];
68 df_info.h10_inner_product_matrix =
Fem.
Assembly.matrix_part(...
73 function obj2 = copy(obj1)
77 function detDF = get.detDF(this)
78 detDF = this.grid.A(:)*2;
81 %function dof_ids_local = get.dof_ids_local(this)
82 % dof_ids_local = {1:this.ndofs_per_element};
85 function res = evaluate_basis(
this, lcoord)
86 res = this.basis_weight_matrix * power_vector2(lcoord, this.pdeg);
89 function res = evaluate_scalar_basis_derivative(this, lcoord, ~)
90 res = this.basis_weight_matrix * power_vector2_derivative(lcoord, this.pdeg);
93 function res = evaluate_basis_function(this, lcoord, i)
94 res = this.basis_weight_matrix(i, :) * power_vector2(lcoord, this.pdeg);
97 function res = evaluate_basis_function_derivative(this, lcoord, i)
98 res = this.basis_weight_matrix(i,:) * power_vector2_derivative(lcoord, this.pdeg);
101 function res = get_global_dof_index(this, varargin)
103 res = this.global_dof_index;
105 res = this.global_dof_index(varargin{:});
109 function res = get_dof_ids_global(
this, ~)
113 function df = interpol_local(this, func, params)
120 for i = 1:this.ndofs_per_element
121 df.dofs(this.global_dof_index(:, i)) = func(this.grid, 1:this.grid.nelements, ...
122 this.dofs_lcoord(i, :), params);
126 p = plot_dofmap(this,params);
130 methods (Access = private, Hidden)
132 function res = lagrange_ndofs(this)
133 ndof_nodes = this.grid.nvertices;
134 ndof_edges = (this.grid.nedges_interior + this.grid.nedges_boundary) * (this.pdeg-1);
135 ndof_elements = this.grid.nelements * (this.pdeg-1) * (this.pdeg-2) / 2;
136 res = ndof_nodes + ndof_edges + ndof_elements;
139 function V = lagrange_basis_weight_matrix(this)
156 2 -11 -11 18 36 18 -9 -27 -27 -9
157 0 18 0 -45 -45 0 27 54 27 0
158 0 -9 0 36 9 0 -27 -27 0 0
160 0 0 18 0 -45 -45 0 27 54 27
161 0 0 0 0 54 0 0 -54 -54 0
162 0 0 0 0 -9 0 0 27 0 0
163 0 0 -9 0 9 36 0 0 -27 -27
164 0 0 0 0 -9 0 0 0 27 0
169 3 -25 -25 70 140 70 -80 -240 -240 -80 32 128 192 128 32
170 0 48 0 -208 -208 0 288 576 288 0 -128 -384 -384 -128 0
171 0 -36 0 228 84 0 -384 -432 -48 0 192 384 192 0 0
172 0 16 0 -112 -16 0 224 96 0 0 -128 -128 0 0 0
173 0 -3 0 22 0 0 -48 0 0 0 32 0 0 0 0
174 0 0 48 0 -208 -208 0 288 576 288 0 -128 -384 -384 -128
175 0 0 0 0 288 0 0 -672 -672 0 0 384 768 384 0
176 0 0 0 0 -96 0 0 480 96 0 0 -384 -384 0 0
177 0 0 0 0 16 0 0 -96 0 0 0 128 0 0 0
178 0 0 -36 0 84 228 0 -48 -432 -384 0 0 192 384 192
179 0 0 0 0 -96 0 0 96 480 0 0 0 -384 -384 0
180 0 0 0 0 12 0 0 -48 -48 0 0 0 192 0 0
181 0 0 16 0 -16 -112 0 0 96 224 0 0 0 -128 -128
182 0 0 0 0 16 0 0 0 -96 0 0 0 0 128 0
183 0 0 -3 0 0 22 0 0 0 -48 0 0 0 0 32
186 % these computations should not be done everytime!
187 % for higher pdeg, perhaps also use higher accuracy!!!
188 disp(['please hardcode the following matrix into' ...
190 % V = inv(P) where P = (p(l1),...p(lm)) powervector of lagrange-nodes
191 lagrange_nodes = this.dofs_lcoord;
192 P = zeros(size(lagrange_nodes,1));
193 for i = 1: size(lagrange_nodes,1)
194 P(:,i) = power_vector2(lagrange_nodes(i,:), this.pdeg);
scalar Lagrange FE functions on triangular grid
Interface for a leaf node of a data tree.
represents a continous piecewise polynomial function of arbitrary dimension. Can be used for all fini...
Abstract class for implementing finite elements. Fem info classes implementing this interface are com...