rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
onedgrid.m
1 classdef onedgrid < gridbase
2  % a one dimensional grid implementation
3 
4  properties
5 
6  global_eind; % global enumeration of entity indices '[1:nelements]'
7 
8  end
9 
10  methods
11 
12  function grid=onedgrid(varargin)
13  %function onedgrid(varargin)
14  % constructor of a 1d grid
15  %
16  % required fields of params:
17  % xnumintervals : number of elements along x directions
18  % xrange : interval covered along the x-axes
19 
20  % Bernard Haasdonk 18.6.2010
21 
22  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23  % copy constructor
24  if (nargin>0) & ...
25  isa(varargin{1},'onedgrid')
26  % copy constructor
27  fnames = fieldnames(varargin{1});
28  for i=1:length(fnames)
29  grid.(fnames{i}) = varargin{1}.(fnames{i});
30  end
31  % the following only would copy handle!!!
32  %grid= varargin{1};
33  else
34  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35  % default constructor: unit interval
36  if (nargin==0)
37  params.xrange = [0,1]; % 2 points
38  params.xnumintervals = 9;
39  else
40  params = varargin{1};
41  end;
42 
43  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44  % construct from params
45 
46  % if ~isfield(params,'verbose')
47  % params.verbose = 0;
48  % end;
49  %grid = [];
50  dx = (params.xrange(2)-params.xrange(1))/params.xnumintervals;
51  grid.X = params.xrange(1):dx:params.xrange(2);
52  grid.nelements = length(grid.X);
53  grid.NBI = [2:grid.nelements, -1; -1,1:(grid.nelements-1)]';
54  grid.global_eind = 1:grid.nelements;
55 
56  % grid = class(grid,'onedgrid');
57 
58  end;
59  end
60 
61  gridp=gridpart(grid, eind);
62 
63  function gcopy = copy(grid);
64  % deep copies the grid
65  %
66  % Return values:
67  % 'gcopy': a copy of type onedgrid.
68  gcopy=onedgrid(grid);
69  end
70 
71  end % methods
72 
73 end % classdef
X
vector of vertex x-coordinates
Definition: gridbase.m:74
Base class for all grid classes.
Definition: gridbase.m:17
a one dimensional grid implementation
Definition: onedgrid.m:17