rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
femdiscfunc.m
1 classdef femdiscfunc < handle
2 %classdef femdiscfunc
3 % class representing a continous piecewise polynomial function of arbitrary
4 % dimension. 'DOFS' correspond to the values of Lagrange-nodes.
5 %
6 % \link femdiscfunc.global_dof_index 'global_dof_index(elid,lagrange_node)'
7 % \endlink yields the global index of the first dof of the basis function
8 % corresponding to the given Lagrange node and element elid.
9 % 'gid:(gid+dimrange-1)' are the subsequent dofs of the vectorial function in
10 % the lagrange node. first all dofs in nodes are counted, then all dofs in
11 % element interior, then the dofs on edge-interiors.
12 %
13 % The Lagrange nodes 'l_1,...,l_m' with 'm=0.5*(pdeg+1)*(pdeg+2)'
14 % are sorted in the following order:
15 % @verbatim
16 % l_m = v_3
17 % *
18 % |\
19 % | \
20 % | \
21 % * *
22 % | \
23 % | \
24 % |______\
25 % * * *
26 % v_1 = l_1 v_2 = l_(pdeg+1)
27 % @endverbatim
28 %
29 % where 'v_1, v_2, v_3' denote the sorting of the triangles corners.
30 
31 % Bernard Haasdonk 11.1.2011
32 
33  properties
34  pdeg; % polynomial degree
35 
36  dimrange; % dimension of range space
37 
38  grid; % grid of type .gridbase
39 
40  df_info; % discrete function information of type .feminfo
41 
42  dofs; % DOF vector
43 
44  % dependent variables:
45 
46  % number of elements
47  nelements;
48 
49  % number of DOFs
50  ndofs;
51 
52  % number of DOFs per grid element
53  ndofs_per_element;
54 
55  % the global dof index
56  global_dof_index;
57 
58  end
59 
60  methods
61 
62  function df = femdiscfunc(dofs,df_info)
63  % constructor, dofs possibly [], grid required!
64  %
65  % parameters:
66  % dofs: a vector of #'df.ndofs' global degress of freedom for the
67  % discrete function, if '==[]' a zero vector is created.
68  % df_info: object of type .feminfo describing the structure of the
69  % underlying discrete function space
70  %
71  % required fields of df_info:
72  % pdeg: polynomial degree of lagrange functions
73  % dimrange: dimension of the range
74  % grid.nelements: @copybrief gridbase.nelements
75  df.pdeg = df_info.pdeg;
76  df.dimrange = df_info.dimrange;
77  df.grid = df_info.grid;
78  df.df_info = df_info;
79  df.dofs=dofs;
80  % dependent:
81  df.nelements = df_info.grid.nelements;
82  df.ndofs = df_info.ndofs;
83  df.ndofs_per_element = df_info.ndofs_per_element;
84  if isempty(dofs)
85  df.dofs = zeros(df.ndofs,1);
86  end;
87  df.global_dof_index = df_info.global_dof_index;
88  end
89 
90  function sdf = scalar_component(df,ncomp)
91  % extraction of component of vectorial fem function
92  [scalardofs, scalar_df_info] = ...
93  fem_scalar_component(df.dofs, ncomp, df);
94  sdf = femdiscfunc(scalardofs,scalar_df_info);
95  end
96 
97  function p = plot(df,params)
98  % plot as colormap
99  if nargin<2
100  params = [];
101  end;
102  p = plot_discfunc(df,params);
103  end;
104 
105  function p = plot_dofmap(df,params)
106  % plot as colormap
107  if nargin<2
108  params = [];
109  end;
110  p = fem_plot_dofmap(df,params);
111  end
112 
113  function res = evaluate(df,einds,lcoord,dummy1,dummy2)
114  % plot as colormap
115  %
116  % description of evaluate function
117  res = fem_evaluate(df,einds,lcoord,[],[]);
118  end
120  function res = subsref(df, S)
121  % This method enables indexation of discrete functions
122  %
123  % redirects arguments to evalute function, so
124  % @code
125  % df(einds, lcoord) == evaluate(df, einds, lcoord)
126  % @endcode
127 
128  % t = S.type;
129  % keyboard;
130  if S(1).type~='('
131  res = builtin('subsref', df, S);
132  else
133  res = evaluate(df,S.subs{:});
134  end;
135  end
136 
137  % copy
138  function cdf = copy(df)
139  cdf = femdiscfunc(df.dofs,df.df_info);
140  end;
141 
142  % addition
143  function df3 = plus(df1,df2)
144  df3 = femdiscfunc([],df1.df_info);
145  df3.dofs = df1.dofs + df2.dofs;
146  end;
147 
148  % subtraction
149  function df3 = minus(df1,df2)
150  df3 = femdiscfunc([],df1.df_info);
151  df3.dofs = df1.dofs - df2.dofs;
152  end;
153 
154  % negative
155  function df2 =uminus(df1)
156  df2 = femdiscfunc([],df1.df_info);
157  df2.dofs = -df1.dofs;
158  end;
159 
160  % multiplication
161  function df2 =mtimes(factor,df1)
162  df2 = femdiscfunc([],df1.df_info);
163  df2.dofs = factor * df1.dofs;
164  end;
165 
166  end % methods
167 
168 end % classdef
class representing a continous piecewise polynomial function of arbitrary dimension. DOFS correspond to the values of Lagrange-nodes.
Definition: femdiscfunc.m:17
nelements
dependent variables: number of elements
Definition: femdiscfunc.m:94
nelements
number of overall elements (leaf + nonleaf)
Definition: gridbase.m:30
global_dof_index
the global dof index
Definition: femdiscfunc.m:119