rbmatlab 0.10.01
|
00001 classdef femdiscfunc < handle 00002 % class femdiscfunc 00003 % class representing a continous piecewise polynomial function of arbitrary 00004 % dimension. 'DOFS' correspond to the values of Lagrange-nodes. 00005 % 00006 % \link femdiscfunc global_dof_index 'global_dof_index(elid,lagrange_node)' 00007 % \endlink yields the global index of the first dof of the basis function 00008 % corresponding to the given Lagrange node and element elid. 00009 % 'gid:(gid+dimrange-1)' are the subsequent dofs of the vectorial function in 00010 % the lagrange node. first all dofs in nodes are counted, then all dofs in 00011 % element interior, then the dofs on edge-interiors. 00012 % 00013 % The Lagrange nodes 'l_1,...,l_m' with 'm=0.5*(pdeg+1)*(pdeg+2)' 00014 % are sorted in the following order: 00015 % @verbatim 00016 % l_m = v_3 00017 % * 00018 % |\ 00019 % | \ 00020 % | \ 00021 % * * 00022 % | \ 00023 % | \ 00024 % |______\ 00025 % * * * 00026 % v_1 = l_1 v_2 = l_(pdeg+1) 00027 % @endverbatim 00028 % 00029 % where 'v_1, v_2, v_3' denote the sorting of the triangles corners. 00030 00031 % Bernard Haasdonk 11.1.2011 00032 00033 properties 00034 pdeg; % polynomial degree 00035 00036 dimrange; % dimension of range space 00037 00038 grid; % grid of type .gridbase 00039 00040 df_info; % discrete function information of type .feminfo 00041 00042 dofs; % DOF vector 00043 00044 % dependent variables: 00045 00046 % number of elements 00047 nelements; 00048 00049 % number of DOFs 00050 ndofs; 00051 00052 % number of DOFs per grid element 00053 ndofs_per_element; 00054 00055 % the global dof index 00056 global_dof_index; 00057 00058 end 00059 00060 methods 00061 00062 function df = femdiscfunc(dofs,df_info) 00063 % constructor, dofs possibly [], grid required! 00064 % 00065 % parameters: 00066 % dofs: a vector of #'df.ndofs' global degress of freedom for the 00067 % discrete function, if '==[]' a zero vector is created. 00068 % df_info: object of type .feminfo describing the structure of the 00069 % underlying discrete function space 00070 % 00071 % required fields of df_info: 00072 % pdeg: polynomial degree of lagrange functions 00073 % dimrange: dimension of the range 00074 % grid.nelements: @copybrief gridbase.nelements 00075 df.pdeg = df_info.pdeg; 00076 df.dimrange = df_info.dimrange; 00077 df.grid = df_info.grid; 00078 df.df_info = df_info; 00079 df.dofs=dofs; 00080 % dependent: 00081 df.nelements = df_info.grid.nelements; 00082 df.ndofs = df_info.ndofs; 00083 df.ndofs_per_element = df_info.ndofs_per_element; 00084 if isempty(dofs) 00085 df.dofs = zeros(df.ndofs,1); 00086 end; 00087 df.global_dof_index = df_info.global_dof_index; 00088 end 00089 00090 function sdf = scalar_component(df,ncomp) 00091 % extraction of component of vectorial fem function 00092 [scalardofs, scalar_df_info] = ... 00093 fem_scalar_component(df.dofs, ncomp, df); 00094 sdf = femdiscfunc(scalardofs,scalar_df_info); 00095 end 00096 00097 function p = plot(df,params) 00098 % plot as colormap 00099 if nargin<2 00100 params = []; 00101 end; 00102 p = plot_discfunc(df,params); 00103 end; 00104 00105 function p = plot_dofmap(df,params) 00106 % plot as colormap 00107 if nargin<2 00108 params = []; 00109 end; 00110 p = fem_plot_dofmap(df,params); 00111 end 00112 00113 function res = evaluate(df,einds,lcoord,dummy1,dummy2) 00114 % plot as colormap 00115 % 00116 % description of evaluate function 00117 res = fem_evaluate(df,einds,lcoord,[],[]); 00118 end 00119 00120 function res = subsref(df, S) 00121 % This method enables indexation of discrete functions 00122 % 00123 % redirects arguments to evalute function, so 00124 % @code 00125 % df(einds, lcoord) == evaluate(df, einds, lcoord) 00126 % @endcode 00127 00128 % t = S.type; 00129 % keyboard; 00130 if S(1).type~='(' 00131 res = builtin('subsref', df, S); 00132 else 00133 res = evaluate(df,S.subs{:}); 00134 end; 00135 end 00136 00137 % copy 00138 function cdf = copy(df) 00139 cdf = femdiscfunc(df.dofs,df.df_info); 00140 end; 00141 00142 % addition 00143 function df3 = plus(df1,df2) 00144 df3 = femdiscfunc([],df1.df_info); 00145 df3.dofs = df1.dofs + df2.dofs; 00146 end; 00147 00148 % subtraction 00149 function df3 = minus(df1,df2) 00150 df3 = femdiscfunc([],df1.df_info); 00151 df3.dofs = df1.dofs - df2.dofs; 00152 end; 00153 00154 % negative 00155 function df2 =uminus(df1) 00156 df2 = femdiscfunc([],df1.df_info); 00157 df2.dofs = -df1.dofs; 00158 end; 00159 00160 % multiplication 00161 function df2 =mtimes(factor,df1) 00162 df2 = femdiscfunc([],df1.df_info); 00163 df2.dofs = factor * df1.dofs; 00164 end; 00165 00166 end % methods 00167 00168 end % classdef