rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
feminfo.m
1 classdef feminfo < handle
2  %classdef feminfo < handle
3 % structure representing the fem-space information shared by all
4 % fem-functions. Implemented as handle class, in order to be linked
5 % into df-classes.
6 
7 % B. Haasdonk 13.1.2011
8 
9 % adapted to new assembly
10 
11 % I. Maier 24.03.2011
12 
13 properties
14  % polynomial degree
15  pdeg;
16 
17  % dimension of ranges space
18  dimrange;
19 
20  % index vector of global DOFs
21  global_dof_index;
22 
23  % number of DOFs
24  ndofs;
25 
26  % number of DOFs per grid element
27  ndofs_per_element;
28 
29  % object of type .gridbase
30  grid;
31 
32  % number of lagrange node indices
33  nlagrange_nodes;
34 
35  % the lagrange points on nodes
36  lagrange_nodes;
37 
38  % the lagrange points on edges
39  lagrange_edges;
40 
41  % determinant of reference mapping
42  detDF;
43 
44  % global IDs of dirichlet DOFs
45  dirichlet_gids;
46 
47  % element IDs of Robin DOFs
48  robin_elind;
49 
50  % edge IDs of Robin DOFs
51  robin_edgeind;
52 
53  % element IDs of Neumann DOFs
54  neumann_elind;
55 
56  % edge IDs of Neumann DOFs
57  neumann_edgeind;
58 
59  % weight matrix for `L^2` inner product
60  l2_inner_product_matrix;
61 
62  % weight matrix for `H^1_0` inner product
63  h10_inner_product_matrix;
64 
65  % weight matrix for regularized `H^1_0` inner product
66  regularized_h10_inner_product_matrix;
67 end
68 
69 methods
70 
71  function df_info = feminfo (model,grid)
72  %function feminfo(model,grid)
73  % required fields of model:
74  % pdeg: polynomial degree
75  df_info.pdeg = model.pdeg;
76  df_info.dimrange = model.dimrange;
77  df_info.ndofs = fem_ndofs(model,grid);
78  df_info.ndofs_per_element = fem_ndofs_per_element(model);
79  df_info.global_dof_index = fem_global_dof_index(model,grid);
80  df_info.grid = grid;
81 
82  df_info.lagrange_nodes = lagrange_nodes_lcoord(model.pdeg);
83  df_info.nlagrange_nodes = size(df_info.lagrange_nodes,1);
84  df_info.lagrange_edges = lagrange_nodes_edges(model.pdeg);
85  df_info.detDF = grid.A(:)*2; % determinant of reference mapping per element;
86  df_info.dirichlet_gids = [];
87 
88  % l2_inner_product and h10_inner product for now only for
89  % scalar functions. Extend later.
90  % make sure, that the folliwing is called with empty
91  % dirichlet nodes, as fem_matrix_volume_component_assembly does
92  % dirichlet treatment!!!
93  % reaction term == 1 then reaction matrix is l2matrix
94  if df_info.dimrange == 1
95  model.reaction = @(grid,eindices,loc,params) ones(size(eindices,1),1);
96  model.qdeg = 2*df_info.pdeg;
97  df_info.l2_inner_product_matrix = ...
98  fem_matrix_volume_part_assembly(@fem_matrix_reac_integral_kernel,model,df_info);
99  % H10_inner_product_matrix: identity diffusion
100  model.diffusivity_tensor = @(grid,eindices,loc,params) ...
101  [ones(size(eindices,1),1), zeros(size(eindices,1),1), ...
102  zeros(size(eindices,1),1), ones(size(eindices,1),1)];
103  df_info.h10_inner_product_matrix = ...
104  fem_matrix_volume_part_assembly(@fem_matrix_diff_integral_kernel,model,df_info);
105  end;
106 
107  % find dirichlet indices as preparation
108  is_dirichlet_gid = zeros(df_info.ndofs,1);
109  % dirichlet-treatment: insert unit-vector row into A in dirichlet
110  % rows. Little loop over local lagrange node index
111  % this is repeated in r assembly as these will be kept separated
112  for i=1:df_info.nlagrange_nodes
113  % search all elements, in which the i-th Lagrange node is
114  % dirichlet point
115  eids = find(df_info.lagrange_edges(i,:)==1);
116  if ~isempty(eids)
117  for e = eids; % possibly one point belongs to 2 edges!!
118  elids = find(grid.NBI(:,e)==-1);
119  gids = df_info.global_dof_index(elids,i);
120  is_dirichlet_gid(gids) = 1;
121  end;
122  end;
123  end
124  df_info.dirichlet_gids = find(is_dirichlet_gid);
125 
126  % find robin boundary elements and edge numbers
127  ind = find(grid.NBI==-3);
128  [df_info.robin_elind,df_info.robin_edgeind] = ind2sub(size(grid.NBI),ind);
129 
130  % find neumann boundary elements and edge numbers
131  ind = find(grid.NBI==-2);
132  [df_info.neumann_elind,df_info.neumann_edgeind] = ind2sub(size(grid.NBI),ind);
133  % regularized_h10_inner_product_matrix: make unit rows in
134  % dirichlet indices:
135 
136  if df_info.dimrange == 1
137  reg_mat = df_info.h10_inner_product_matrix;
138  if ~isempty(df_info.dirichlet_gids)
139  reg_mat(df_info.dirichlet_gids,:) = 0;
140  reg_mat(:,df_info.dirichlet_gids) = 0;
141  A_dirichlet = sparse(df_info.dirichlet_gids,...
142  df_info.dirichlet_gids, ...
143  ones(size(df_info.dirichlet_gids)),...
144  df_info.ndofs,df_info.ndofs);
145  reg_mat = reg_mat + A_dirichlet;
146  end;
147  df_info.regularized_h10_inner_product_matrix = reg_mat;
148  end;
149 
150  end
152 end
153 
154 end
155 
156 
function global_dof_index = fem_global_dof_index(params,triagrid grid)
function computing the local-to-global dof map of a fem discrete function
structure representing the fem-space information shared by all fem-functions. Implemented as handle c...
Definition: feminfo.m:17