23 int myrank, petot, steptot;
24 int n_node, n_elem, shift, etype;
25 int data_tot_n, data_tot_e;
26 int table342[10] = {0, 1, 2, 3, 6, 4, 5, 7, 8, 9};
38 for(i=0; i<
data->nn_component; i++){
39 data_tot_n +=
data->nn_dof[i];
42 for(i=0; i<
data->ne_component; i++){
43 data_tot_e +=
data->ne_dof[i];
46 p = strrchr(outfile, (
int)(
unsigned char)
'/');
51 sprintf(file_vtu,
"%s/%s.%d.vtu", outfile1, outfile,
myrank);
58 sprintf(file_pvtu,
"%s.pvtu", outfile1);
59 outfp = fopen (file_pvtu,
"w");
60 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
61 fprintf (outfp,
"<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"%s\">\n",
HECMW_endian_str());
62 fprintf (outfp,
"<PUnstructuredGrid>\n");
63 for(i=0; i<
data->ng_component; i++){
64 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\"/>\n",
data->global_label[i],
data->ng_dof[i]);
66 fprintf (outfp,
"<PPoints>\n");
67 fprintf (outfp,
"<PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n");
68 fprintf (outfp,
"</PPoints>\n");
69 fprintf (outfp,
"<PCells>\n");
70 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"/>\n");
71 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"/>\n");
72 fprintf (outfp,
"<PDataArray type=\"UInt8\" Name=\"types\" format=\"ascii\"/>\n");
73 fprintf (outfp,
"</PCells>\n");
74 fprintf (outfp,
"<PPointData>\n");
75 for(i=0; i<
data->nn_component; i++){
77 strcmp(
data->node_label[i],
"NodalPrincipalSTRAIN") == 0 ||
78 strcmp(
data->node_label[i],
"NodalPrincipalSTRESS") == 0
80 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" ComponentName0=\"1st\" ComponentName1=\"2nd\" ComponentName2=\"3rd\" format=\"ascii\"/>\n",
data->node_label[i],
data->nn_dof[i]);
82 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"/>\n",
data->node_label[i],
data->nn_dof[i]);
85 fprintf (outfp,
"</PPointData>\n");
86 fprintf (outfp,
"<PCellData>\n");
87 fprintf (outfp,
"<PDataArray type=\"Int16\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"ascii\"/>\n");
88 for(i=0; i<
data->ne_component; i++){
90 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRAIN") == 0 ||
91 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRESS") == 0
93 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" ComponentName0=\"1st\" ComponentName1=\"2nd\" ComponentName2=\"3rd\" format=\"ascii\"/>\n",
data->elem_label[i],
data->ne_dof[i]);
95 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"/>\n",
data->elem_label[i],
data->ne_dof[i]);
98 fprintf (outfp,
"</PCellData>\n");
99 for(i=0; i<petot; i++){
100 sprintf (buf,
"./%s/%s.%d.vtu", outfile, outfile, i);
101 fprintf (outfp,
"<Piece Source=\"%s\"/>\n", buf);
103 fprintf (outfp,
"</PUnstructuredGrid>\n");
104 fprintf (outfp,
"</VTKFile>\n");
109 outfp = fopen (file_vtu,
"w");
110 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
111 fprintf (outfp,
"<VTKFile type=\"UnstructuredGrid\" version=\"1.0\">\n");
112 fprintf (outfp,
"<UnstructuredGrid>\n");
113 fprintf (outfp,
"<FieldData>\n");
114 for(i=0; i<
data->ng_component; i++){
115 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\" >\n",
data->global_label[i],
data->ng_dof[i]);
118 shift +=
data->ng_dof[j];
120 for(k=0; k<
data->ng_dof[i]; k++){
121 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
123 fprintf (outfp,
"\n");
124 fprintf (outfp,
"</DataArray>\n");
126 fprintf (outfp,
"</FieldData>\n");
127 fprintf (outfp,
"<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", n_node, n_elem);
128 fprintf (outfp,
"<Points>\n");
129 fprintf (outfp,
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n");
130 for(i=0; i<n_node; i++){
133 fprintf (outfp,
"</DataArray>\n");
134 fprintf (outfp,
"</Points>\n");
135 fprintf (outfp,
"<Cells>\n");
136 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n");
137 for(i=0; i<n_elem; i++){
145 for(j=jS; j<jE-shift; j++){
149 for(j=jS; j<jE-shift; j++){
153 fprintf (outfp,
"\n");
155 fprintf (outfp,
"</DataArray>\n");
156 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n");
158 for(i=0; i<n_elem; i++){
164 fprintf (outfp,
"\n");
165 fprintf (outfp,
"</DataArray>\n");
166 fprintf (outfp,
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n");
167 for(i=0; i<n_elem; i++){
170 fprintf (outfp,
"\n");
171 fprintf (outfp,
"</DataArray>\n");
172 fprintf (outfp,
"</Cells>\n");
173 fprintf (outfp,
"<PointData>\n");
174 for(i=0; i<
data->nn_component; i++){
175 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\">\n",
data->node_label[i],
data->nn_dof[i]);
178 shift +=
data->nn_dof[j];
180 for(j=0; j<n_node; j++){
181 for(k=0; k<
data->nn_dof[i]; k++){
182 fprintf (outfp,
"%e ", (
float)
data->node_val_item[j*data_tot_n+k+shift]);
184 fprintf (outfp,
"\n");
186 fprintf (outfp,
"</DataArray>\n");
188 fprintf (outfp,
"</PointData>\n");
189 fprintf (outfp,
"<CellData>\n");
190 fprintf (outfp,
"<DataArray type=\"Int16\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"ascii\">\n");
191 for(i=0; i<n_elem; i++){
194 fprintf (outfp,
"\n");
195 fprintf (outfp,
"</DataArray>\n");
196 for(i=0; i<
data->ne_component; i++){
197 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\">\n",
data->elem_label[i],
data->ne_dof[i]);
200 shift +=
data->ne_dof[j];
202 for(j=0; j<n_elem; j++){
203 for(k=0; k<
data->ne_dof[i]; k++){
204 fprintf (outfp,
"%e ", (
float)
data->elem_val_item[j*data_tot_e+k+shift]);
206 fprintf (outfp,
"\n");
208 fprintf (outfp,
"</DataArray>\n");
210 fprintf (outfp,
"</CellData>\n");
211 fprintf (outfp,
"</Piece>\n");
212 fprintf (outfp,
"</UnstructuredGrid>\n");
213 fprintf (outfp,
"</VTKFile>\n");
221 int myrank, petot, steptot;
222 int n_node, n_elem, shift, etype;
223 int data_tot_n, data_tot_e, in, ioffset;
229 float val, val1, val2, val3;
233 int table342[10] = {0, 1, 2, 3, 6, 4, 5, 7, 8, 9};
242 for(i=0; i<
data->nn_component; i++){
243 data_tot_n +=
data->nn_dof[i];
246 for(i=0; i<
data->ne_component; i++){
247 data_tot_e +=
data->ne_dof[i];
250 sprintf(file_vtu,
"%s/%s.%d.vtu", outfile1, outfile,
myrank);
257 sprintf(file_pvtu,
"%s.pvtu", outfile1);
258 outfp = fopen (file_pvtu,
"wb");
259 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
260 fprintf (outfp,
"<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"%s\" header_type=\"UInt32\">\n",
HECMW_endian_str());
261 fprintf (outfp,
"<PUnstructuredGrid>\n");
262 for(i=0; i<
data->ng_component; i++){
263 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\"/>\n",
data->global_label[i],
data->ng_dof[i]);
265 fprintf (outfp,
"<PPoints>\n");
266 fprintf (outfp,
"<PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n");
267 fprintf (outfp,
"</PPoints>\n");
268 fprintf (outfp,
"<PCells>\n");
269 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\"/>\n");
270 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"offsets\" format=\"appended\"/>\n");
271 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"types\" format=\"appended\"/>\n");
272 fprintf (outfp,
"</PCells>\n");
273 fprintf (outfp,
"<PPointData>\n");
274 for(i=0; i<
data->nn_component; i++){
276 strcmp(
data->node_label[i],
"NodalPrincipalSTRAIN") == 0 ||
277 strcmp(
data->node_label[i],
"NodalPrincipalSTRESS") == 0
279 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" ComponentName0=\"1st\" ComponentName1=\"2nd\" ComponentName2=\"3rd\" format=\"appended\"/>\n",
data->node_label[i],
data->nn_dof[i]);
281 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\"/>\n",
data->node_label[i],
data->nn_dof[i]);
284 fprintf (outfp,
"</PPointData>\n");
285 fprintf (outfp,
"<PCellData>\n");
286 for(i=0; i<
data->ne_component; i++){
288 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRAIN") == 0 ||
289 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRESS") == 0
291 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" ComponentName0=\"1st\" ComponentName1=\"2nd\" ComponentName2=\"3rd\" format=\"appended\"/>\n",
data->elem_label[i],
data->ne_dof[i]);
293 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\"/>\n",
data->elem_label[i],
data->ne_dof[i]);
296 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"appended\"/>\n");
297 fprintf (outfp,
"</PCellData>\n");
298 for(i=0; i<petot; i++){
299 sprintf (buf,
"./%s/%s.%d.vtu", outfile, outfile, i);
300 fprintf (outfp,
"<Piece Source=\"%s\"/>\n", buf);
302 fprintf (outfp,
"</PUnstructuredGrid>\n");
303 fprintf (outfp,
"</VTKFile>\n");
309 ioffset = 5 +
data->nn_component +
data->ne_component;
313 for(i=0; i<n_elem; i++){
320 uint64 += jE-shift-jS;
324 offset[1] = offset[0] +
sizeof(int) + 3*n_node *
sizeof(
float);
325 offset[2] = offset[1] +
sizeof(int) + (
int)uint64*
sizeof(int);
326 offset[3] = offset[2] +
sizeof(int) + n_elem *
sizeof(
int);
327 offset[4] = offset[3] +
sizeof(int) + n_elem *
sizeof(
int);
328 for(i=0; i<
data->nn_component; i++){
329 offset[5+i] = offset[4+i] +
sizeof(int) +
data->nn_dof[i]*n_node*
sizeof(
int);
331 for(i=0; i<
data->ne_component; i++){
332 offset[5+
data->nn_component+i] = offset[4+
data->nn_component+i] +
sizeof(int) +
data->ne_dof[i]*n_elem*
sizeof(
int);
335 outfp = fopen (file_vtu,
"wb");
336 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
337 fprintf (outfp,
"<VTKFile type=\"UnstructuredGrid\" version=\"1.0\" byte_order=\"%s\" header_type=\"UInt32\">\n",
HECMW_endian_str());
338 fprintf (outfp,
"<UnstructuredGrid>\n");
339 fprintf (outfp,
"<FieldData>\n");
340 for(i=0; i<
data->ng_component; i++){
341 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\" >\n",
data->global_label[i],
data->ng_dof[i]);
344 shift +=
data->ng_dof[j];
346 for(k=0; k<
data->ng_dof[i]; k++){
347 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
349 fprintf (outfp,
"\n");
350 fprintf (outfp,
"</DataArray>\n");
352 fprintf (outfp,
"</FieldData>\n");
353 fprintf (outfp,
"<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", n_node, n_elem);
354 fprintf (outfp,
"<Points>\n");
355 fprintf (outfp,
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\"%d\">\n", offset[0]);
356 fprintf (outfp,
"</DataArray>\n");
357 fprintf (outfp,
"</Points>\n");
358 fprintf (outfp,
"<Cells>\n");
359 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\"%d\">\n", offset[1]);
360 fprintf (outfp,
"</DataArray>\n");
361 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\"%d\">\n", offset[2]);
362 fprintf (outfp,
"</DataArray>\n");
363 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"types\" format=\"appended\" offset=\"%d\">\n", offset[3]);
364 fprintf (outfp,
"</DataArray>\n");
365 fprintf (outfp,
"</Cells>\n");
366 fprintf (outfp,
"<PointData>\n");
368 for(i=0; i<
data->nn_component; i++){
369 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\" offset=\"%d\">\n",
data->node_label[i],
data->nn_dof[i], offset[4+i]);
370 fprintf (outfp,
"</DataArray>\n");
373 fprintf (outfp,
"</PointData>\n");
374 fprintf (outfp,
"<CellData>\n");
375 for(i=0; i<
data->ne_component; i++){
376 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\" offset=\"%d\">\n",
data->elem_label[i],
data->ne_dof[i], offset[4+
data->nn_component+i]);
377 fprintf (outfp,
"</DataArray>\n");
380 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"appended\" offset=\"%d\">\n", offset[ioffset-1]);
381 fprintf (outfp,
"</DataArray>\n");
382 fprintf (outfp,
"</CellData>\n");
383 fprintf (outfp,
"</Piece>\n");
384 fprintf (outfp,
"</UnstructuredGrid>\n");
385 fprintf (outfp,
"<AppendedData encoding=\"raw\">\n");
387 fprintf (outfp,
" _");
388 uint32 = (uint32_t)(3*n_node*
sizeof(
float));
389 fwrite (&uint32,
sizeof(uint32), 1, outfp);
390 for(i=0; i<n_node; i++){
392 fwrite (&val,
sizeof(
float), 1, outfp);
394 fwrite (&val,
sizeof(
float), 1, outfp);
396 fwrite (&val,
sizeof(
float), 1, outfp);
399 uint32 = (uint32_t)(uint64*
sizeof(
int));
400 fwrite (&uint32,
sizeof(uint32), 1, outfp);
401 for(i=0; i<n_elem; i++){
409 for(j=jS; j<jE-shift; j++){
411 fwrite (&in,
sizeof(
int), 1, outfp);
414 for(j=jS; j<jE-shift; j++){
416 fwrite (&in,
sizeof(
int), 1, outfp);
421 uint32 = (uint32_t)(n_elem*
sizeof(
int));
422 fwrite (&uint32,
sizeof(uint32), 1, outfp);
424 for(i=0; i<n_elem; i++){
429 fwrite (&in,
sizeof(
int), 1, outfp);
432 uint32 = (uint32_t)(n_elem*
sizeof(
int));
433 fwrite (&uint32,
sizeof(uint32), 1, outfp);
434 for(i=0; i<n_elem; i++){
438 fwrite (&in,
sizeof(
int), 1, outfp);
441 for(i=0; i<
data->nn_component; i++){
442 uint32 = (uint32_t)(
data->nn_dof[i]*n_node*
sizeof(
int));
443 fwrite (&uint32,
sizeof(uint32), 1, outfp);
447 shift +=
data->nn_dof[j];
449 for(j=0; j<n_node; j++){
450 for(k=0; k<
data->nn_dof[i]; k++){
451 val = (float)
data->node_val_item[j*data_tot_n+k+shift];
452 fwrite (&val,
sizeof(
float), 1, outfp);
457 for(i=0; i<
data->ne_component; i++){
458 uint32 = (uint32_t)(
data->ne_dof[i]*n_elem*
sizeof(
int));
459 fwrite (&uint32,
sizeof(uint32), 1, outfp);
463 shift +=
data->ne_dof[j];
465 for(j=0; j<n_elem; j++){
466 for(k=0; k<
data->ne_dof[i]; k++){
467 val = (float)
data->elem_val_item[j*data_tot_e+k+shift];
468 fwrite (&val,
sizeof(
float), 1, outfp);
473 uint32 = (uint32_t)(n_elem*
sizeof(
int));
474 fwrite (&uint32,
sizeof(uint32), 1, outfp);
475 for(i=0; i<n_elem; i++){
479 fwrite (&in,
sizeof(
int), 1, outfp);
482 fprintf (outfp,
"</AppendedData>\n");
483 fprintf (outfp,
"</VTKFile>\n");
int HECMW_Comm_rank(HECMW_Comm comm, int *rank)
int HECMW_Comm_size(HECMW_Comm comm, int *size)
#define HECMW_FILENAME_LEN
int HECMW_ctrl_make_subdir(char *filename)
struct hecmwST_local_mesh * mesh
int HECMW_get_etype_vtk_shape(int etype)
const char * HECMW_endian_str(void)
function for investigating endian of running CPU
void vtk_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, char *outfile1, HECMW_Comm VIS_COMM)
void HECMW_vtk_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, char *outfile1, HECMW_Comm VIS_COMM)
void HECMW_bin_vtk_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, char *outfile1, HECMW_Comm VIS_COMM)
void bin_vtk_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, char *outfile1, HECMW_Comm VIS_COMM)
#define HECMW_malloc(size)
void HECMW_vis_print_exit(char *var)
integer(kind=kint) myrank
PARALLEL EXECUTION.