Debian Codegraph @

packages/intrepid/matlab/intrelab/mesh/RectGridLine.m

raw
1 function [mesh] = RectGridLine(xmin, xmax, nx)
2 %
3 % [mesh] = RectGridLine(xmin, xmax, nx)
4 %
5 %RECTGRIDLINE sets up the grid on a line.
6 %
7 % The grid is constructed by subdividing the x-interval into
8 % nx subintervals.
9 %
10 %
11 % Input
12 % xmin, xmax size of the domain
13 % nx number of subintervals on x-interval
14 %
15 % Output
16 % mesh structure array with the following fields
17 %
18 % mesh.p Real num_nodes x 1
19 % array containing the x-coordinates
20 % of the nodes
21 %
22 % mesh.t Integer num_cells x 2
23 % - t(i,1:2) contains the indices of the
24 % vertices of line segment i
25 %
26 % mesh.e empty
27 %
28 % mesh.sidesPerCell Integer = 2
29 %
30 % mesh.elem_ss{i} = global element IDs on sideset (boundary) i
31 %
32 % mesh.side_ss{i} = local side (subcell) IDs on sideset (boundary) i
33 %
34 % mesh.cellType = string for cell type (= 'Line')
35 %
36 % mesh.sideType = string for side subcell type (= 'Vertex')
37 %
38 %
39 % AUTHORS:
40 % Denis Ridzal
41 % Sandia National Laboratories
42
43 np = nx+1;
44
45 nt = nx;
46 % Create connectivity array
47 mesh.t = zeros(nt,2);
48 mesh.t(:,1) = [1:nx]';
49 mesh.t(:,2) = [2:nx+1]';
50
51 % Create point array
52 mesh.p = zeros(np,1);
53
54 % Create vertex coodinates
55 hx = (xmax-xmin)/nx;
56 mesh.p(:,1) = [xmin:hx:xmax]';
57
58 mesh.e = [];
59
60 % sides per cell
61 mesh.sidesPerCell = 2;
62 % cell type
63 mesh.cellType = 'Line';
64 % side type
65 mesh.sideType = 'Vertex';
66
67 % sidesets
68 mesh.elem_ss{1} = 1; % left
69 mesh.elem_ss{2} = nx; % right
70
71 % local side ids for sidesets
72 mesh.side_ss{1} = 0; % left
73 mesh.side_ss{2} = 1; % right
74
75 end