258
21 Two-dimensional Mesh Generators 23
y2
y1
24
x0
x1
x2
27
20
5
21
12
14
15
16
1
y0
26
19 4 13
8 1
y
25
2
9
2
10
3
4
5
28
6 17 3 6
29 22 18 11 7
x3
x (a)
(b)
Fig. 21.1 Generation of a mesh inside a rectangular block: specification of mesh lines (a), generated mesh with node and element numbering (b)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
import util.*; import elem.*; // Generate mesh of quadratic elements inside a rectangle. // Input: nx, ny - number of elements along x and y; // xs, ys - locations of element boundaries on x and y; // [mat] - material name. public class rectangle { private FeModel m; enum vars { nx, ny, xs, ys, mat, end } private vars name; private int nx, ny; String mat="1"; private double xs[], ys[]; public rectangle() { String modelName = Jmgen.RD.next(); Jmgen.PR.printf("Rectangle: %s\n", modelName); readData(); printData(); m = new FeModel(Jmgen.RD, Jmgen.PR); generateMesh(); Jmgen.blocks.put(modelName,m); Jmgen.PR.printf("Mesh " + modelName + ": nEl = %d nNod = %d\n", m.nEl, m.nNod); } private void readData() { String varName, varname; while (Jmgen.RD.hasNext()) {