rbmatlab 0.10.01
discfunc/ldg/@ldgdiscfunc/ldgdiscfunc.m
00001 classdef ldgdiscfunc < handle
00002   % an ldg shape functions implementation
00003 
00004   properties
00005     % number of elements
00006     nelements;
00007 
00008     % polynomial degree
00009     pdeg;
00010 
00011     % number of DOFs per grid elment
00012     ndofs_per_element;
00013 
00014     % number of DOFs
00015     ndofs;
00016 
00017     % dimension of range space
00018     dimrange;
00019 
00020     % the DOF vector
00021     dofs;
00022 
00023     % grid object of type .gridbase
00024     grid;
00025   end
00026 
00027   methods
00028     function df = ldgdiscfunc(varargin)
00029       %function df = ldgdiscfunc(varargin)
00030       % initialize ldg function on triangular grids with input
00031       %
00032       % note, the only use of this class is, that by local storage of the
00033       % dof vector and a (..) as evaluation routine, these objects can be
00034       % used identically as analytical functions in integration, matrix
00035       % assembly, etc. But in general the ../ldg directory contains methods
00036       % for handling ldg functions based on seperate dof and parameter
00037       % storage. These methods are more efficient as the class&methods.
00038       %
00039       % arguments:
00040       %  varargin: This can be one of
00041       %   - inp = ldgdiscfunc : copy constructor
00042       %   - inp = {dofs, params} :
00043       %                 optional vector of dofs to be stored in the ldg function
00044       %   - inp = params:
00045       %                 Generate an empty ldg function,
00046       %                 where the required fields of params are:
00047       %                  - 'pdeg' - polynomial degree on each element
00048       %                  - 'dimrange' - dimension of function
00049       %                  - 'nelements' - number of triangles
00050       %
00051       % 'df' has a field dofs, which are sorted as follows:
00052       %  - for all elements
00053       %    - for all degrees
00054       %      - for all dimensions
00055       %
00056       % i.e. dofs with number '1,1+dimrange,1+2 dimrange' ... are the dofs
00057       % of the first scalar component, etc.
00058       %
00059       % let `\hat phi_i i=1...m` be an orthonormal basis on the reference triangle
00060       % `\hat T`. Let T be an arbitrary triangle and `F_T` be the reference
00061       % mapping from `\hat T` to `T`. Then for all global dof indices
00062       % `j=1,...,N` there exists an element `T(j)` and local index `i(j)` such that
00063       % `phi_j (x) = \hat phi_i(j) ( F_T^-1(x))`
00064       %
00065       % Then an ldg-discrete function is given by
00066       %
00067       % ``
00068       %  df (x) = sum_j=1^N dof(j) * phi_j(x)=
00069       %           sum_j=1^N dof(j) * \hat phi_i(j) (F_T(j)^-1 (x) )=
00070       % ``
00071       %
00072 
00073       % Bernard Haasdonk 27.1.2009
00074 
00075       if nargin == 0;
00076         error('no default ldgdiscfunc')
00077       end;
00078 
00079       if isa(varargin{1},'ldgdiscfunc') % copy constructor
00080 
00081         fnames = fieldnames(varargin{1});
00082         for i=1:length(fnames)
00083           df.(fnames{i}) = varargin{1}.(fnames{i});
00084         end
00085 
00086       else % assume inp argument to be "params" structure
00087 
00088         if nargin == 2
00089           df_info = varargin{2}; % formerly params
00090           dofs = varargin{1};
00091         else
00092           df_info = varargin{1};
00093           dofs = [];
00094         end;
00095 
00096         df.nelements = df_info.nelements;
00097         df.pdeg = df_info.pdeg;
00098         %df.ndofs_per_element = ldg_ndofs_per_element(params);
00099         %df.ndofs = ldg_ndofs(params);
00100         df.grid = df_info.grid;
00101         df.ndofs = df_info.ndofs;
00102         df.ndofs_per_element = df_info.ndofs_per_element;
00103         df.dimrange = df_info.dimrange;
00104 
00105         if isempty(dofs)
00106           dofs =  zeros(df.ndofs,1);
00107         end;
00108         df.dofs = dofs;
00109         %  keyboard;
00110       end;
00111 
00112     end
00113 
00114     display(df);
00115 
00116     res = evaluate(df, eindices, lcoord);
00117 
00118     res = subsasgn(df, S, val);
00119 
00120     res = subsref(df, S);
00121 
00122     function sdf = scalar_component(df,ncomp)
00123       % extraction of scalar component of vectorial ldg function
00124       [scalar_dofs, scalar_df_info] = ldg_scalar_component(df,ncomp);
00125       sdf = ldgdiscfunc(scalar_dofs,scalar_df_info);
00126     end
00127 
00128     function p = plot(df,params)
00129       % plot as colormap
00130       if nargin<2
00131         params = [];
00132       end;
00133       p = plot_discfunc(df,params);
00134     end
00135 
00136   end
00137 
00138 end
00139 
00140 %| \docupdate
All Classes Namespaces Files Functions Variables