1 | |
---|
2 | % Open an XML run file to write into |
---|
3 | lib = rpLib(infile); |
---|
4 | |
---|
5 | meshtype = rpLibGetString(lib, 'input.choice(mesh).current'); |
---|
6 | contour = rpLibGetString(lib, 'input.boolean(contour).current') |
---|
7 | switch contour |
---|
8 | case 'yes' |
---|
9 | view = 'contour'; |
---|
10 | otherwise |
---|
11 | view = 'heightmap'; |
---|
12 | end |
---|
13 | |
---|
14 | switch meshtype |
---|
15 | case 'cloud' |
---|
16 | mesh = 'output.mesh'; |
---|
17 | rpLibPutString(lib, 'output.mesh.about.label', \ |
---|
18 | 'cloud in unstructured mesh', 0); |
---|
19 | rpLibPutString(lib, 'output.mesh.dim', '2', 0); |
---|
20 | rpLibPutString(lib, 'output.mesh.units', 'm', 0); |
---|
21 | rpLibPutString(lib, 'output.mesh.hide', 'yes', 0); |
---|
22 | |
---|
23 | xv = linspace(0, 1, 50) |
---|
24 | for i = 1:50 |
---|
25 | for j = 1:50 |
---|
26 | string = sprintf('%12g %12g\n', xv(i), xv(j)); |
---|
27 | rpLibPutString(lib, 'output.mesh.unstructured.points', string, 1); |
---|
28 | endfor |
---|
29 | endfor |
---|
30 | rpLibPutString(lib, 'output.mesh.unstructured.celltypes', '', 0); |
---|
31 | |
---|
32 | case 'regular' |
---|
33 | mesh = 'output.mesh'; |
---|
34 | rpLibPutString(lib, 'output.mesh.about.label', 'uniform grid mesh', 0); |
---|
35 | rpLibPutString(lib, 'output.mesh.dim', '2', 0); |
---|
36 | rpLibPutString(lib, 'output.mesh.units', 'm', 0); |
---|
37 | rpLibPutString(lib, 'output.mesh.hide', 'yes', 0); |
---|
38 | |
---|
39 | % Specify the x-axis of the mesh |
---|
40 | rpLibPutString(lib, 'output.mesh.grid.xaxis.min', '0.0', 0); |
---|
41 | rpLibPutString(lib, 'output.mesh.grid.xaxis.max', '1.0', 0); |
---|
42 | rpLibPutString(lib, 'output.mesh.grid.xaxis.numpoints', '50', 0); |
---|
43 | |
---|
44 | % Specify the y-axis of the mesh |
---|
45 | rpLibPutString(lib, 'output.mesh.grid.yaxis.min', '0.0', 0); |
---|
46 | rpLibPutString(lib, 'output.mesh.grid.yaxis.max', '1.0', 0); |
---|
47 | rpLibPutString(lib, 'output.mesh.grid.yaxis.numpoints', '50', 0); |
---|
48 | |
---|
49 | case 'irregular' |
---|
50 | mesh = 'output.mesh'; |
---|
51 | rpLibPutString(lib, 'output.mesh.about.label', 'irregular grid mesh', 0); |
---|
52 | rpLibPutString(lib, 'output.mesh.dim', '2', 0); |
---|
53 | rpLibPutString(lib, 'output.mesh.units', 'm', 0); |
---|
54 | rpLibPutString(lib, 'output.mesh.hide', 'yes', 0); |
---|
55 | |
---|
56 | xv = linspace(0, 1, 50) |
---|
57 | string = sprintf('%12g\n', xv); |
---|
58 | rpLibPutString(lib, 'output.mesh.grid.xcoords', string, 0); |
---|
59 | rpLibPutString(lib, 'output.mesh.grid.ycoords', string, 0); |
---|
60 | |
---|
61 | case 'hybrid' |
---|
62 | mesh = 'output.mesh'; |
---|
63 | rpLibPutString(lib, 'output.mesh.about.label', \ |
---|
64 | 'hybrid regular and irregular grid mesh', 0); |
---|
65 | rpLibPutString(lib, 'output.mesh.dim', '2', 0); |
---|
66 | rpLibPutString(lib, 'output.mesh.units', 'm', 0); |
---|
67 | rpLibPutString(lib, 'output.mesh.hide', 'yes', 0); |
---|
68 | |
---|
69 | xv = linspace(0, 1, 50) |
---|
70 | string = sprintf('%g\n', xv); |
---|
71 | rpLibPutString(lib, 'output.mesh.grid.xcoords', string, 0); |
---|
72 | |
---|
73 | % Specify the y-axis of the mesh |
---|
74 | rpLibPutString(lib, 'output.mesh.grid.yaxis.min', '0.0', 0); |
---|
75 | rpLibPutString(lib, 'output.mesh.grid.yaxis.max', '1.0', 0); |
---|
76 | rpLibPutString(lib, 'output.mesh.grid.yaxis.numpoints', '50', 0); |
---|
77 | |
---|
78 | case 'triangular' |
---|
79 | mesh = 'output.mesh'; |
---|
80 | rpLibPutString(lib, 'output.mesh.about.label', \ |
---|
81 | 'triangles in unstructured mesh', 0); |
---|
82 | rpLibPutString(lib, 'output.mesh.dim', '2', 0); |
---|
83 | rpLibPutString(lib, 'output.mesh.units', 'm', 0); |
---|
84 | rpLibPutString(lib, 'output.mesh.hide', 'yes', 0); |
---|
85 | |
---|
86 | f = fopen('points.txt'); |
---|
87 | points = fscanf(f, '%g'); |
---|
88 | fclose(f); |
---|
89 | string = sprintf('%g %g\n', points); |
---|
90 | rpLibPutString(lib, 'output.mesh.unstructured.points', string, 0); |
---|
91 | |
---|
92 | rpLibPutFile(lib, 'output.mesh.unstructured.triangles', 'triangles.txt', \ |
---|
93 | 0, 0); |
---|
94 | |
---|
95 | case 'unstructured' |
---|
96 | mesh = 'output.mesh'; |
---|
97 | rpLibPutString(lib, 'output.mesh.about.label', 'Unstructured Grid', 0); |
---|
98 | rpLibPutString(lib, 'output.mesh.dim', '2', 0); |
---|
99 | rpLibPutString(lib, 'output.mesh.units', 'm', 0); |
---|
100 | rpLibPutString(lib, 'output.mesh.hide', 'yes', 0); |
---|
101 | |
---|
102 | f = fopen('points.txt'); |
---|
103 | points = fscanf(f, '%g'); |
---|
104 | fclose(f); |
---|
105 | string = sprintf('%g %g\n', points); |
---|
106 | rpLibPutString(lib, 'output.mesh.unstructured.points', string, 0); |
---|
107 | |
---|
108 | rpLibPutFile(lib, 'output.mesh.unstructured.cells', 'triangles.txt', 0, 0); |
---|
109 | rpLibPutString(lib, 'output.mesh.unstructured.celltypes', 'triangle', 0); |
---|
110 | |
---|
111 | case 'cells' |
---|
112 | mesh = 'output.mesh'; |
---|
113 | rpLibPutString(lib, 'output.mesh.about.label', \ |
---|
114 | 'unstructured grid with heterogeneous cells', 0); |
---|
115 | rpLibPutString(lib, 'output.mesh.dim', '2', 0); |
---|
116 | rpLibPutString(lib, 'output.mesh.units', 'm', 0); |
---|
117 | rpLibPutString(lib, 'output.mesh.hide', 'yes', 0); |
---|
118 | |
---|
119 | f = fopen('points.txt'); |
---|
120 | points = fscanf(f, '%g'); |
---|
121 | fclose(f); |
---|
122 | string = sprintf('%g %g\n', points); |
---|
123 | rpLibPutString(lib, 'output.mesh.unstructured.points', string, 0); |
---|
124 | |
---|
125 | rpLibPutFile(lib, 'output.mesh.unstructured.cells', 'triangles.txt', 0, 0); |
---|
126 | |
---|
127 | % TO BE COMPLETED |
---|
128 | rpLibPutString(lib, 'output.mesh.unstructured.celltypes', 'triangle', 0); |
---|
129 | |
---|
130 | case 'vtkmesh' |
---|
131 | mesh = 'output.mesh'; |
---|
132 | rpLibPutString(lib, 'output.mesh.about.label', 'vtk mesh', 0); |
---|
133 | rpLibPutString(lib, 'output.mesh.dim', '2', 0); |
---|
134 | rpLibPutString(lib, 'output.mesh.units', 'm', 0); |
---|
135 | rpLibPutString(lib, 'output.mesh.hide', 'yes', 0); |
---|
136 | |
---|
137 | rpLibPutFile(lib, 'output.mesh.vtk', 'mesh.vtk', 0, 0); |
---|
138 | |
---|
139 | case 'vtkfield' |
---|
140 | |
---|
141 | rpLibPutString(lib, 'output.field(substrate).about.label', \ |
---|
142 | 'Substrate Surface', 0); |
---|
143 | rpLibPutFile(lib, 'output.field(substrate).component.vtk', 'file.vtk', \ |
---|
144 | 0, 0); |
---|
145 | rpLibPutString(lib, 'output.string.current', '', 0); |
---|
146 | rpLibResult(lib); |
---|
147 | quit; |
---|
148 | |
---|
149 | otherwise |
---|
150 | error 'unknown mesh type $meshtype' |
---|
151 | end |
---|
152 | |
---|
153 | % Read in the data since we're not simulating anything... |
---|
154 | f = fopen('substrate_data.txt'); |
---|
155 | substrate_values = fscanf(f, '%g'); |
---|
156 | fclose(f); |
---|
157 | f = fopen('particle_data.txt'); |
---|
158 | particle_values = fscanf(f, '%g'); |
---|
159 | fclose(f); |
---|
160 | |
---|
161 | rpLibPutString(lib, 'output.field(substrate).about.label', \ |
---|
162 | 'Substrate Surface', 0); |
---|
163 | rpLibPutString(lib, 'output.field(substrate).component.mesh', mesh, 0); |
---|
164 | string = sprintf('%12g\n', substrate_values); |
---|
165 | rpLibPutString(lib, 'output.field(substrate).component.values', string, 0); |
---|
166 | rpLibPutString(lib, 'output.field(substrate).about.view', view, 0); |
---|
167 | |
---|
168 | rpLibPutString(lib, 'output.field(particle).about.label', \ |
---|
169 | 'Particle Surface', 0); |
---|
170 | rpLibPutString(lib, 'output.field(particle).component.mesh', mesh, 0); |
---|
171 | string = sprintf('%12g\n', particle_values); |
---|
172 | rpLibPutString(lib, 'output.field(particle).component.values', string, 0); |
---|
173 | rpLibPutString(lib, 'output.field(particle).about.view', view, 0); |
---|
174 | |
---|
175 | rpLibPutString(lib, 'output.string.about.label', 'Mesh XML definition', 0); |
---|
176 | xml = rpLibXml(lib); |
---|
177 | rpLibPutString(lib, 'output.string.current', xml, 0); |
---|
178 | |
---|
179 | % save the updated XML describing the run... |
---|
180 | rpLibResult(lib); |
---|
181 | quit; |
---|