rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
dirichlet_dof_vector.m
Go to the documentation of this file.
1 function r_dir = dirichlet_dof_vector(model, df_info, bc_info)
2 %function r_dir = dirichlet_dof_vector(model, df_info, bc_info)
3 % Assembly of vector enforcing the Dirichlet boundary condition.
4 %
5 % A vector enforcing the Dirichlet boundary condition is
6 % assembled. If model.decomp_mode equals 1, a cell array containing
7 % component DoF vectors is assembled. This function is used in
8 % Fem.BcInfo().
9 %
10 % Parameters:
11 % model: structure representing model
12 % df_info: instance of discrete function information class
13 % implementing Fem.IFemInfo().
14 % bc_info: instance of boundary condition information class
15 % Fem.BcInfo().
16 %
17 % Return values:
18 % r_dir: Fem DoF vector or cell array of components representing
19 % the Dirichlet boundary condition.
20 
21 r_dir = zeros(df_info.ndofs, 1);
22 
23 for i = 1:df_info.ndofs_per_element
24 
25  dim_i = find(cellfun(@(M)any(i == M), df_info.dof_ids_local));
26 
27  edgeind = find(df_info.dofs_edges_llcoord(i, :) > -eps);
28 
29  if ~isempty(edgeind)
30 
31  for j = 1:length(edgeind)
32 
33  llcoord = df_info.dofs_edges_llcoord(i, edgeind(j));
34 
35  elinds = find(df_info.grid.NBI(:, edgeind(j)) == -1);
36  % logical indexing doesn't work here
37  [gids, Inew, ~] = intersect(...
38  df_info.get_global_dof_index(elinds, i), bc_info.dirichlet_gids);
39 
40  if ~isempty(gids)
41 
42  dirichlet_values = ...
43  model.dirichlet_values(df_info.grid, elinds(Inew), edgeind(j), llcoord, model);
44 
45  % full vector or components
46  if ~iscell(dirichlet_values)
47 
48  r_dir(gids) = dirichlet_values(:, dim_i);
49  else
50 
51  if ~iscell(r_dir)
52  r_dir = cell(1, length(dirichlet_values));
53  for q = 1:length(dirichlet_values)
54  r_dir{q} = zeros(df_info.ndofs, 1);
55  end
56  end
57 
58  for q = 1:length(dirichlet_values)
59  r_dir{q}(gids) = dirichlet_values{q}(:, dim_i);
60  end
61  end
62  end
63 
64  end
65 
66  end
67 end
68 
69 end
Class for boundary condition information. Allows more flexible usage.
Definition: BcInfo.m:18
Abstract class for implementing finite elements. Fem info classes implementing this interface are com...
Definition: IFemInfo.m:18