rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
ldgdiscfunc.m
1 classdef ldgdiscfunc < handle
2  % an ldg shape functions implementation
3 
4  properties
5  % number of elements
6  nelements;
7 
8  % polynomial degree
9  pdeg;
10 
11  % number of DOFs per grid elment
12  ndofs_per_element;
13 
14  % number of DOFs
15  ndofs;
16 
17  % dimension of range space
18  dimrange;
19 
20  % the DOF vector
21  dofs;
22 
23  % grid object of type .gridbase
24  grid;
25  end
26 
27  methods
28  function df = ldgdiscfunc(varargin)
29  %function df = ldgdiscfunc(varargin)
30  % initialize ldg function on triangular grids with input
31  %
32  % note, the only use of this class is, that by local storage of the
33  % dof vector and a (..) as evaluation routine, these objects can be
34  % used identically as analytical functions in integration, matrix
35  % assembly, etc. But in general the ../ldg directory contains methods
36  % for handling ldg functions based on seperate dof and parameter
37  % storage. These methods are more efficient as the class&methods.
38  %
39  % arguments:
40  % varargin: This can be one of
41  % - inp = ldgdiscfunc : copy constructor
42  % - inp = {dofs, df_info} :
43  % optional vector of dofs to be stored in the ldg function
44  % - inp = df_info: A descriptive object of type ldginfo.
45  %
46  % 'df' has a field dofs, which are sorted as follows:
47  % - for all elements
48  % - for all degrees
49  % - for all dimensions
50  %
51  % i.e. dofs with number '1,1+dimrange,1+2 dimrange' ... are the dofs
52  % of the first scalar component, etc.
53  %
54  % let `\hat phi_i i=1...m` be an orthonormal basis on the reference triangle
55  % `\hat T`. Let T be an arbitrary triangle and `F_T` be the reference
56  % mapping from `\hat T` to `T`. Then for all global dof indices
57  % `j=1,...,N` there exists an element `T(j)` and local index `i(j)` such that
58  % `phi_j (x) = \hat phi_i(j) ( F_T^-1(x))`
59  %
60  % Then an ldg-discrete function is given by
61  %
62  % ``
63  % df (x) = sum_j=1^N dof(j) * phi_j(x)=
64  % sum_j=1^N dof(j) * \hat phi_i(j) (F_T(j)^-1 (x) )=
65  % ``
66  %
67 
68  % Bernard Haasdonk 27.1.2009
69 
70  if nargin == 0;
71  error('no default ldgdiscfunc')
72  end;
73 
74  if isa(varargin{1},'ldgdiscfunc') % copy constructor
75 
76  fnames = fieldnames(varargin{1});
77  for i=1:length(fnames)
78  df.(fnames{i}) = varargin{1}.(fnames{i});
79  end
80 
81  else % assume inp argument to be "params" structure
82 
83  if nargin == 2
84  df_info = varargin{2}; % formerly params
85  dofs = varargin{1};
86  else
87  df_info = varargin{1};
88  dofs = [];
89  end;
90 
91  df.nelements = df_info.nelements;
92  df.pdeg = df_info.pdeg;
93  %df.ndofs_per_element = ldg_ndofs_per_element(params);
94  %df.ndofs = ldg_ndofs(params);
95  df.grid = df_info.grid;
96  df.ndofs = df_info.ndofs;
97  df.ndofs_per_element = df_info.ndofs_per_element;
98  df.dimrange = df_info.dimrange;
99 
100  if isempty(dofs)
101  dofs = zeros(df.ndofs,1);
102  end;
103  df.dofs = dofs;
104  % keyboard;
105  end;
106 
107  end
108 
109  display(df);
110 
111  res = evaluate(df, eindices, lcoord);
112 
113  res = subsasgn(df, S, val);
114 
115  res = subsref(df, S);
116 
117  function sdf = scalar_component(df,ncomp)
118  % extraction of scalar component of vectorial ldg function
119  [scalar_dofs, scalar_df_info] = ldg_scalar_component(df,ncomp);
120  sdf = ldgdiscfunc(scalar_dofs,scalar_df_info);
121  end
122 
123  function p = plot(df,params)
124  % plot as colormap
125  if nargin<2
126  params = [];
127  end;
128  p = plot_discfunc(df,params);
129  end
130 
131  end
132 
133 end
134 
135 %| \docupdate
nelements
number of elements
Definition: ldginfo.m:58
structure for the information of a ldg-function.
Definition: ldginfo.m:17
an ldg shape functions implementation
Definition: ldgdiscfunc.m:17