24 int n_node, n_elem, shift;
25 int data_tot_n, data_tot_e;
26 int table342[10] = {0, 1, 2, 3, 6, 4, 5, 7, 8, 9};
36 for(i=0; i<
data->nn_component; i++){
37 data_tot_n +=
data->nn_dof[i];
40 for(i=0; i<
data->ne_component; i++){
41 data_tot_e +=
data->ne_dof[i];
44 p = strrchr(outfile, (
int)(
unsigned char)
'/');
49 snprintf(file_vtu,
sizeof(file_vtu),
"%s/%s.%d.vtu", outfile1, outfile,
myrank);
56 snprintf(file_pvtu,
sizeof(file_pvtu),
"%s.pvtu", outfile1);
57 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 fprintf (outfp,
"<FieldData>\n");
64 for(i=0; i<
data->ng_component; i++){
66 for(j=0; j<i; j++) shift +=
data->ng_dof[j];
67 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\">",
68 strcmp(
data->global_label[i],
"TOTALTIME") == 0 ?
"TimeValue" :
data->global_label[i],
70 for(k=0; k<
data->ng_dof[i]; k++){
71 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
73 fprintf (outfp,
"</DataArray>\n");
75 fprintf (outfp,
"</FieldData>\n");
76 fprintf (outfp,
"<PPoints>\n");
77 fprintf (outfp,
"<PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n");
78 fprintf (outfp,
"</PPoints>\n");
79 fprintf (outfp,
"<PCells>\n");
80 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"/>\n");
81 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"/>\n");
82 fprintf (outfp,
"<PDataArray type=\"UInt8\" Name=\"types\" format=\"ascii\"/>\n");
83 fprintf (outfp,
"</PCells>\n");
84 fprintf (outfp,
"<PPointData>\n");
85 for(i=0; i<
data->nn_component; i++){
87 strcmp(
data->node_label[i],
"NodalPrincipalSTRAIN") == 0 ||
88 strcmp(
data->node_label[i],
"NodalPrincipalSTRESS") == 0
90 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]);
92 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"/>\n",
data->node_label[i],
data->nn_dof[i]);
95 fprintf (outfp,
"</PPointData>\n");
96 fprintf (outfp,
"<PCellData>\n");
97 fprintf (outfp,
"<PDataArray type=\"Int16\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"ascii\"/>\n");
98 for(i=0; i<
data->ne_component; i++){
100 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRAIN") == 0 ||
101 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRESS") == 0
103 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]);
105 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"/>\n",
data->elem_label[i],
data->ne_dof[i]);
108 fprintf (outfp,
"</PCellData>\n");
109 for(i=0; i<petot; i++){
110 snprintf (buf,
sizeof(buf),
"./%s/%s.%d.vtu", outfile, outfile, i);
111 fprintf (outfp,
"<Piece Source=\"%s\"/>\n", buf);
113 fprintf (outfp,
"</PUnstructuredGrid>\n");
114 fprintf (outfp,
"</VTKFile>\n");
119 outfp = fopen (file_vtu,
"w");
122 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
123 fprintf (outfp,
"<VTKFile type=\"UnstructuredGrid\" version=\"1.0\">\n");
124 fprintf (outfp,
"<UnstructuredGrid>\n");
125 fprintf (outfp,
"<FieldData>\n");
126 for(i=0; i<
data->ng_component; i++){
127 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\" >\n",
128 strcmp(
data->global_label[i],
"TOTALTIME") == 0 ?
"TimeValue" :
data->global_label[i],
132 shift +=
data->ng_dof[j];
134 for(k=0; k<
data->ng_dof[i]; k++){
135 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
137 fprintf (outfp,
"\n");
138 fprintf (outfp,
"</DataArray>\n");
140 fprintf (outfp,
"</FieldData>\n");
141 fprintf (outfp,
"<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", n_node, n_elem);
142 fprintf (outfp,
"<Points>\n");
143 fprintf (outfp,
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n");
144 for(i=0; i<n_node; i++){
147 fprintf (outfp,
"</DataArray>\n");
148 fprintf (outfp,
"</Points>\n");
149 fprintf (outfp,
"<Cells>\n");
150 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n");
151 for(i=0; i<n_elem; i++){
161 for(jj=jS; jj<jE-shift; jj++){
165 for(jj=jS; jj<jE-shift; jj++){
170 fprintf (outfp,
"\n");
172 fprintf (outfp,
"</DataArray>\n");
173 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n");
175 for(i=0; i<n_elem; i++){
181 fprintf (outfp,
"\n");
182 fprintf (outfp,
"</DataArray>\n");
183 fprintf (outfp,
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n");
184 for(i=0; i<n_elem; i++){
187 fprintf (outfp,
"\n");
188 fprintf (outfp,
"</DataArray>\n");
189 fprintf (outfp,
"</Cells>\n");
190 fprintf (outfp,
"<PointData>\n");
191 for(i=0; i<
data->nn_component; i++){
194 shift +=
data->nn_dof[j];
196 if (strcmp(
data->node_label[i],
"DISPLACEMENT") == 0 &&
data->nn_dof[i] == 2) {
198 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"3\" format=\"ascii\">\n",
data->node_label[i]);
199 for(j=0; j<n_node; j++){
200 fprintf (outfp,
"%e %e 0.0\n",
201 (
float)
data->node_val_item[j*data_tot_n+shift],
202 (
float)
data->node_val_item[j*data_tot_n+shift+1]);
205 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\">\n",
data->node_label[i],
data->nn_dof[i]);
206 for(j=0; j<n_node; j++){
207 for(k=0; k<
data->nn_dof[i]; k++){
208 fprintf (outfp,
"%e ", (
float)
data->node_val_item[j*data_tot_n+k+shift]);
210 fprintf (outfp,
"\n");
213 fprintf (outfp,
"</DataArray>\n");
215 fprintf (outfp,
"</PointData>\n");
216 fprintf (outfp,
"<CellData>\n");
217 fprintf (outfp,
"<DataArray type=\"Int16\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"ascii\">\n");
218 for(i=0; i<n_elem; i++){
221 fprintf (outfp,
"\n");
222 fprintf (outfp,
"</DataArray>\n");
223 for(i=0; i<
data->ne_component; i++){
224 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\">\n",
data->elem_label[i],
data->ne_dof[i]);
227 shift +=
data->ne_dof[j];
229 for(j=0; j<n_elem; j++){
230 for(k=0; k<
data->ne_dof[i]; k++){
231 fprintf (outfp,
"%e ", (
float)
data->elem_val_item[j*data_tot_e+k+shift]);
233 fprintf (outfp,
"\n");
235 fprintf (outfp,
"</DataArray>\n");
237 fprintf (outfp,
"</CellData>\n");
238 fprintf (outfp,
"</Piece>\n");
239 fprintf (outfp,
"</UnstructuredGrid>\n");
240 fprintf (outfp,
"</VTKFile>\n");
249 int n_node, n_elem, shift;
250 int data_tot_n, data_tot_e, in, ioffset;
255 float val, val1, val2, val3;
257 int table342[10] = {0, 1, 2, 3, 6, 4, 5, 7, 8, 9};
265 for(i=0; i<
data->nn_component; i++){
266 data_tot_n +=
data->nn_dof[i];
269 for(i=0; i<
data->ne_component; i++){
270 data_tot_e +=
data->ne_dof[i];
273 snprintf(file_vtu,
sizeof(file_vtu),
"%s/%s.%d.vtu", outfile1, outfile,
myrank);
280 snprintf(file_pvtu,
sizeof(file_pvtu),
"%s.pvtu", outfile1);
281 outfp = fopen (file_pvtu,
"wb");
284 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
285 fprintf (outfp,
"<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"%s\" header_type=\"UInt32\">\n",
HECMW_endian_str());
286 fprintf (outfp,
"<PUnstructuredGrid>\n");
287 fprintf (outfp,
"<FieldData>\n");
288 for(i=0; i<
data->ng_component; i++){
290 for(j=0; j<i; j++) shift +=
data->ng_dof[j];
291 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\">",
292 strcmp(
data->global_label[i],
"TOTALTIME") == 0 ?
"TimeValue" :
data->global_label[i],
294 for(k=0; k<
data->ng_dof[i]; k++){
295 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
297 fprintf (outfp,
"</DataArray>\n");
299 fprintf (outfp,
"</FieldData>\n");
300 fprintf (outfp,
"<PPoints>\n");
301 fprintf (outfp,
"<PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n");
302 fprintf (outfp,
"</PPoints>\n");
303 fprintf (outfp,
"<PCells>\n");
304 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\"/>\n");
305 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"offsets\" format=\"appended\"/>\n");
306 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"types\" format=\"appended\"/>\n");
307 fprintf (outfp,
"</PCells>\n");
308 fprintf (outfp,
"<PPointData>\n");
309 for(i=0; i<
data->nn_component; i++){
311 strcmp(
data->node_label[i],
"NodalPrincipalSTRAIN") == 0 ||
312 strcmp(
data->node_label[i],
"NodalPrincipalSTRESS") == 0
314 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]);
316 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\"/>\n",
data->node_label[i],
data->nn_dof[i]);
319 fprintf (outfp,
"</PPointData>\n");
320 fprintf (outfp,
"<PCellData>\n");
321 for(i=0; i<
data->ne_component; i++){
323 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRAIN") == 0 ||
324 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRESS") == 0
326 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]);
328 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\"/>\n",
data->elem_label[i],
data->ne_dof[i]);
331 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"appended\"/>\n");
332 fprintf (outfp,
"</PCellData>\n");
333 for(i=0; i<petot; i++){
334 snprintf (buf,
sizeof(buf),
"./%s/%s.%d.vtu", outfile, outfile, i);
335 fprintf (outfp,
"<Piece Source=\"%s\"/>\n", buf);
337 fprintf (outfp,
"</PUnstructuredGrid>\n");
338 fprintf (outfp,
"</VTKFile>\n");
343 ioffset = 5 +
data->nn_component +
data->ne_component;
347 for(i=0; i<n_elem; i++){
354 uint64 += jE-shift-jS;
358 offset[1] = offset[0] +
sizeof(int) + 3*n_node *
sizeof(
float);
359 offset[2] = offset[1] +
sizeof(int) + (
int)uint64*
sizeof(int);
360 offset[3] = offset[2] +
sizeof(int) + n_elem *
sizeof(
int);
361 offset[4] = offset[3] +
sizeof(int) + n_elem *
sizeof(
int);
362 for(i=0; i<
data->nn_component; i++){
363 offset[5+i] = offset[4+i] +
sizeof(int) +
data->nn_dof[i]*n_node*
sizeof(
int);
365 for(i=0; i<
data->ne_component; i++){
366 offset[5+
data->nn_component+i] = offset[4+
data->nn_component+i] +
sizeof(int) +
data->ne_dof[i]*n_elem*
sizeof(
int);
369 outfp = fopen (file_vtu,
"wb");
372 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
373 fprintf (outfp,
"<VTKFile type=\"UnstructuredGrid\" version=\"1.0\" byte_order=\"%s\" header_type=\"UInt32\">\n",
HECMW_endian_str());
374 fprintf (outfp,
"<UnstructuredGrid>\n");
375 fprintf (outfp,
"<FieldData>\n");
376 for(i=0; i<
data->ng_component; i++){
377 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\" >\n",
378 strcmp(
data->global_label[i],
"TOTALTIME") == 0 ?
"TimeValue" :
data->global_label[i],
382 shift +=
data->ng_dof[j];
384 for(k=0; k<
data->ng_dof[i]; k++){
385 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
387 fprintf (outfp,
"\n");
388 fprintf (outfp,
"</DataArray>\n");
390 fprintf (outfp,
"</FieldData>\n");
391 fprintf (outfp,
"<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", n_node, n_elem);
392 fprintf (outfp,
"<Points>\n");
393 fprintf (outfp,
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\"%d\">\n", offset[0]);
394 fprintf (outfp,
"</DataArray>\n");
395 fprintf (outfp,
"</Points>\n");
396 fprintf (outfp,
"<Cells>\n");
397 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\"%d\">\n", offset[1]);
398 fprintf (outfp,
"</DataArray>\n");
399 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\"%d\">\n", offset[2]);
400 fprintf (outfp,
"</DataArray>\n");
401 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"types\" format=\"appended\" offset=\"%d\">\n", offset[3]);
402 fprintf (outfp,
"</DataArray>\n");
403 fprintf (outfp,
"</Cells>\n");
404 fprintf (outfp,
"<PointData>\n");
406 for(i=0; i<
data->nn_component; i++){
407 if (strcmp(
data->node_label[i],
"DISPLACEMENT") == 0 &&
data->nn_dof[i] == 2) {
410 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"3\" format=\"appended\" offset=\"%d\">\n",
data->node_label[i], offset[4+i]);
412 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]);
414 fprintf (outfp,
"</DataArray>\n");
417 fprintf (outfp,
"</PointData>\n");
418 fprintf (outfp,
"<CellData>\n");
419 for(i=0; i<
data->ne_component; i++){
420 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]);
421 fprintf (outfp,
"</DataArray>\n");
424 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"appended\" offset=\"%d\">\n", offset[ioffset-1]);
425 fprintf (outfp,
"</DataArray>\n");
426 fprintf (outfp,
"</CellData>\n");
427 fprintf (outfp,
"</Piece>\n");
428 fprintf (outfp,
"</UnstructuredGrid>\n");
429 fprintf (outfp,
"<AppendedData encoding=\"raw\">\n");
431 fprintf (outfp,
" _");
432 uint32 = (uint32_t)(3*n_node*
sizeof(
float));
433 fwrite (&uint32,
sizeof(uint32), 1, outfp);
434 for(i=0; i<n_node; i++){
436 fwrite (&val,
sizeof(
float), 1, outfp);
438 fwrite (&val,
sizeof(
float), 1, outfp);
440 fwrite (&val,
sizeof(
float), 1, outfp);
443 uint32 = (uint32_t)(uint64*
sizeof(
int));
444 fwrite (&uint32,
sizeof(uint32), 1, outfp);
445 for(i=0; i<n_elem; i++){
455 for(jj=jS; jj<jE-shift; jj++){
457 fwrite (&in,
sizeof(
int), 1, outfp);
460 for(jj=jS; jj<jE-shift; jj++){
462 fwrite (&in,
sizeof(
int), 1, outfp);
468 uint32 = (uint32_t)(n_elem*
sizeof(
int));
469 fwrite (&uint32,
sizeof(uint32), 1, outfp);
471 for(i=0; i<n_elem; i++){
476 fwrite (&in,
sizeof(
int), 1, outfp);
479 uint32 = (uint32_t)(n_elem*
sizeof(
int));
480 fwrite (&uint32,
sizeof(uint32), 1, outfp);
481 for(i=0; i<n_elem; i++){
483 fwrite (&in,
sizeof(
int), 1, outfp);
486 for(i=0; i<
data->nn_component; i++){
487 uint32 = (uint32_t)(
data->nn_dof[i]*n_node*
sizeof(
int));
488 fwrite (&uint32,
sizeof(uint32), 1, outfp);
492 shift +=
data->nn_dof[j];
494 for(j=0; j<n_node; j++){
497 val1 = (float)
data->node_val_item[j*data_tot_n+shift];
498 val2 = (
float)
data->node_val_item[j*data_tot_n+shift+1];
500 fwrite (&val1,
sizeof(
float), 1, outfp);
501 fwrite (&val2,
sizeof(
float), 1, outfp);
502 fwrite (&val3,
sizeof(
float), 1, outfp);
504 for(k=0; k<
data->nn_dof[i]; k++){
505 val = (float)
data->node_val_item[j*data_tot_n+k+shift];
506 fwrite (&val,
sizeof(
float), 1, outfp);
512 for(i=0; i<
data->ne_component; i++){
513 uint32 = (uint32_t)(
data->ne_dof[i]*n_elem*
sizeof(
int));
514 fwrite (&uint32,
sizeof(uint32), 1, outfp);
518 shift +=
data->ne_dof[j];
520 for(j=0; j<n_elem; j++){
521 for(k=0; k<
data->ne_dof[i]; k++){
522 val = (float)
data->elem_val_item[j*data_tot_e+k+shift];
523 fwrite (&val,
sizeof(
float), 1, outfp);
528 uint32 = (uint32_t)(n_elem*
sizeof(
int));
529 fwrite (&uint32,
sizeof(uint32), 1, outfp);
530 for(i=0; i<n_elem; i++){
532 fwrite (&in,
sizeof(
int), 1, outfp);
535 fprintf (outfp,
"</AppendedData>\n");
536 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.
long long * elem_node_index