rbmatlab 0.10.01
|
00001 classdef onedgrid < gridbase 00002 % a one dimensional grid implementation 00003 00004 properties 00005 00006 global_eind; % global enumeration of entity indices '[1:nelements]' 00007 00008 end 00009 00010 methods 00011 00012 function grid=onedgrid(varargin) 00013 %function onedgrid(varargin) 00014 % constructor of a 1d grid 00015 % 00016 % required fields of params: 00017 % xnumintervals : number of elements along x directions 00018 % xrange : interval covered along the x-axes 00019 00020 % Bernard Haasdonk 18.6.2010 00021 00022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00023 % copy constructor 00024 if (nargin>0) & ... 00025 isa(varargin{1},'onedgrid') 00026 % copy constructor 00027 fnames = fieldnames(varargin{1}); 00028 for i=1:length(fnames) 00029 grid.(fnames{i}) = varargin{1}.(fnames{i}); 00030 end 00031 % the following only would copy handle!!! 00032 %grid= varargin{1}; 00033 else 00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00035 % default constructor: unit interval 00036 if (nargin==0) 00037 params.xrange = [0,1]; % 2 points 00038 params.xnumintervals = 9; 00039 else 00040 params = varargin{1}; 00041 end; 00042 00043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00044 % construct from params 00045 00046 % if ~isfield(params,'verbose') 00047 % params.verbose = 0; 00048 % end; 00049 %grid = []; 00050 dx = (params.xrange(2)-params.xrange(1))/params.xnumintervals; 00051 grid.X = params.xrange(1):dx:params.xrange(2); 00052 grid.nelements = length(grid.X); 00053 grid.NBI = [2:grid.nelements, -1; -1,1:(grid.nelements-1)]'; 00054 grid.global_eind = 1:grid.nelements; 00055 00056 % grid = class(grid,'onedgrid'); 00057 00058 end; 00059 end 00060 00061 gridp=gridpart(grid, eind); 00062 00063 function gcopy = copy(grid); 00064 % deep copies the grid 00065 % 00066 % Return values: 00067 % 'gcopy': a copy of type onedgrid. 00068 gcopy=onedgrid(grid); 00069 end 00070 00071 end % methods 00072 00073 end % classdef