3 % scalar Lagrange FE functions (degree 1) with additional bubble function
6 % could possibly be generalized to arbitrary pdeg of Lagrange basis
10 properties (SetAccess = private)
18 ndofs_per_element = 4;
28 l2_inner_product_matrix;
30 h10_inner_product_matrix;
35 properties (SetAccess = private, Dependent)
43 %function velocity_df_info = BubbleInfo(~, grid)
46 lbi.dof_ids_local = {1:lbi.ndofs_per_element};
49 lbi.ndofs = grid.nvertices + grid.nelements;
52 lbi.basis_weight_matrix = ...
53 [1,-1,-1, 0, 0, 0, 0, 0, 0, 0; ...
54 0, 1, 0, 0, 0, 0, 0, 0, 0, 0; ...
55 0, 0, 1, 0, 0, 0, 0, 0, 0, 0; ...
56 0, 0, 0, 0,27, 0, 0,-27,-27, 0];
58 % local coordinates of dofs
59 lbi.dofs_lcoord = [0, 0; 1, 0; 0, 1; 1/3 1/3];
61 % edge-local coordinates of dofs
62 lbi.dofs_edges_llcoord =
Fem.
Lagrange.nodes_edges_llcoord(lbi.dofs_lcoord);
64 % reaction term == 1 then reaction matrix is l2matrix
66 model.disable_caching = 1;
68 @(grid, eindices, loc, params) ones(length(eindices), 1);
69 model.qdeg = 2*lbi.pdeg;
70 lbi.l2_inner_product_matrix =
Fem.
Assembly.matrix_part(...
73 % H10_inner_product_matrix: identity diffusion
74 model.diffusivity_tensor = @(grid, eindices, loc, params) ...
75 [ones(length(eindices), 1), zeros(length(eindices), 1), ...
76 zeros(length(eindices), 1), ones(length(eindices), 1)];
77 lbi.h10_inner_product_matrix =
Fem.
Assembly.matrix_part(...
82 function obj2 = copy(obj1)
86 %function dof_ids_local = get.dof_ids_local(this)
87 % dof_ids_local = {1:this.ndofs_per_element};
90 function detDF =
get.
detDF(
this)
91 detDF = 2 * this.grid.A;
94 function res = get_global_dof_index(
this, einds, gids)
95 % returns entries of global-dof-map
for several elements and several
97 global_dof_index = ...
98 [this.grid.VI, this.grid.nvertices + (1:this.grid.nelements)
'];
99 res = global_dof_index(einds, gids);
102 function res = get_dof_ids_global(this, ~)
103 % returns global dof ids belonging to one component (indices into
108 function res = evaluate_basis(this, lcoord)
109 % evaluation of all basis functions in local coordinate
110 res = this.basis_weight_matrix * power_vector2(lcoord, this.pdeg);
113 function res = evaluate_scalar_basis_derivative(this, lcoord, ~)
114 % evaluation of the gradient of a scalar basis in local coordinate
115 res = this.basis_weight_matrix * power_vector2_derivative(lcoord, this.pdeg);
118 function res = evaluate_basis_function(this, lcoord, i)
119 % evaluation of i-th basis function in local coordinate
120 res = this.basis_weight_matrix(i, :) * power_vector2(lcoord, this.pdeg);
123 function res = evaluate_basis_function_derivative(this, lcoord, i)
124 % evaluation of the gradient of i-th basis function in local
126 res = this.basis_weight_matrix(i,:) * power_vector2_derivative(lcoord, this.pdeg);
129 function df = interpol_local(this, func, params)
130 % interpolating a given analytical function
132 % - func: function which can be evaluated at
133 % @(grid, elinds, lcoord, params)
139 df = Fem.DiscFunc([], this);
141 for i = 1:(this.ndofs_per_element - 1)
143 gids = this.get_global_dof_index(1:this.grid.nelements, i);
144 df.dofs(gids) = func(this.grid, 1:this.grid.nelements, ...
145 this.dofs_lcoord(i, :), params);
148 interp_error = triaquadrature(3, @(lcoord) ...
149 func(this.grid, 1:this.grid.nelements, lcoord, params) - ...
150 df(1:this.grid.nelements, lcoord));
152 bubble_integr = triaquadrature(3, ...
153 @(lcoord) this.evaluate_basis_function(lcoord, this.ndofs_per_element));
155 gids = this.get_global_dof_index(1:this.grid.nelements, this.ndofs_per_element);
156 df.dofs(gids) = interp_error / bubble_integr(1); % detDF cancels out
Interface for a leaf node of a data tree.
scalar Lagrange FE functions (degree 1) with additional bubble function on triangular grid ...
Abstract class for implementing finite elements. Fem info classes implementing this interface are com...