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 snprintf(file_vtu,
sizeof(file_vtu),
"%s/%s.%d.vtu", outfile1, outfile,
myrank);
58 snprintf(file_pvtu,
sizeof(file_pvtu),
"%s.pvtu", outfile1);
59 outfp = fopen (file_pvtu,
"w");
62 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
63 fprintf (outfp,
"<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"%s\">\n",
HECMW_endian_str());
64 fprintf (outfp,
"<PUnstructuredGrid>\n");
65 fprintf (outfp,
"<FieldData>\n");
66 for(i=0; i<
data->ng_component; i++){
68 for(j=0; j<i; j++) shift +=
data->ng_dof[j];
69 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\">",
70 strcmp(
data->global_label[i],
"TOTALTIME") == 0 ?
"TimeValue" :
data->global_label[i],
72 for(k=0; k<
data->ng_dof[i]; k++){
73 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
75 fprintf (outfp,
"</DataArray>\n");
77 fprintf (outfp,
"</FieldData>\n");
78 fprintf (outfp,
"<PPoints>\n");
79 fprintf (outfp,
"<PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n");
80 fprintf (outfp,
"</PPoints>\n");
81 fprintf (outfp,
"<PCells>\n");
82 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"/>\n");
83 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"/>\n");
84 fprintf (outfp,
"<PDataArray type=\"UInt8\" Name=\"types\" format=\"ascii\"/>\n");
85 fprintf (outfp,
"</PCells>\n");
86 fprintf (outfp,
"<PPointData>\n");
87 for(i=0; i<
data->nn_component; i++){
89 strcmp(
data->node_label[i],
"NodalPrincipalSTRAIN") == 0 ||
90 strcmp(
data->node_label[i],
"NodalPrincipalSTRESS") == 0
92 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]);
94 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"/>\n",
data->node_label[i],
data->nn_dof[i]);
97 fprintf (outfp,
"</PPointData>\n");
98 fprintf (outfp,
"<PCellData>\n");
99 fprintf (outfp,
"<PDataArray type=\"Int16\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"ascii\"/>\n");
100 for(i=0; i<
data->ne_component; i++){
102 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRAIN") == 0 ||
103 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRESS") == 0
105 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]);
107 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"/>\n",
data->elem_label[i],
data->ne_dof[i]);
110 fprintf (outfp,
"</PCellData>\n");
111 for(i=0; i<petot; i++){
112 snprintf (buf,
sizeof(buf),
"./%s/%s.%d.vtu", outfile, outfile, i);
113 fprintf (outfp,
"<Piece Source=\"%s\"/>\n", buf);
115 fprintf (outfp,
"</PUnstructuredGrid>\n");
116 fprintf (outfp,
"</VTKFile>\n");
121 outfp = fopen (file_vtu,
"w");
124 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
125 fprintf (outfp,
"<VTKFile type=\"UnstructuredGrid\" version=\"1.0\">\n");
126 fprintf (outfp,
"<UnstructuredGrid>\n");
127 fprintf (outfp,
"<FieldData>\n");
128 for(i=0; i<
data->ng_component; i++){
129 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\" >\n",
130 strcmp(
data->global_label[i],
"TOTALTIME") == 0 ?
"TimeValue" :
data->global_label[i],
134 shift +=
data->ng_dof[j];
136 for(k=0; k<
data->ng_dof[i]; k++){
137 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
139 fprintf (outfp,
"\n");
140 fprintf (outfp,
"</DataArray>\n");
142 fprintf (outfp,
"</FieldData>\n");
143 fprintf (outfp,
"<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", n_node, n_elem);
144 fprintf (outfp,
"<Points>\n");
145 fprintf (outfp,
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n");
146 for(i=0; i<n_node; i++){
149 fprintf (outfp,
"</DataArray>\n");
150 fprintf (outfp,
"</Points>\n");
151 fprintf (outfp,
"<Cells>\n");
152 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n");
153 for(i=0; i<n_elem; i++){
161 for(j=jS; j<jE-shift; j++){
165 for(j=jS; j<jE-shift; j++){
169 fprintf (outfp,
"\n");
171 fprintf (outfp,
"</DataArray>\n");
172 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n");
174 for(i=0; i<n_elem; i++){
180 fprintf (outfp,
"\n");
181 fprintf (outfp,
"</DataArray>\n");
182 fprintf (outfp,
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n");
183 for(i=0; i<n_elem; i++){
186 fprintf (outfp,
"\n");
187 fprintf (outfp,
"</DataArray>\n");
188 fprintf (outfp,
"</Cells>\n");
189 fprintf (outfp,
"<PointData>\n");
190 for(i=0; i<
data->nn_component; i++){
191 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\">\n",
data->node_label[i],
data->nn_dof[i]);
194 shift +=
data->nn_dof[j];
196 for(j=0; j<n_node; j++){
197 for(k=0; k<
data->nn_dof[i]; k++){
198 fprintf (outfp,
"%e ", (
float)
data->node_val_item[j*data_tot_n+k+shift]);
200 fprintf (outfp,
"\n");
202 fprintf (outfp,
"</DataArray>\n");
204 fprintf (outfp,
"</PointData>\n");
205 fprintf (outfp,
"<CellData>\n");
206 fprintf (outfp,
"<DataArray type=\"Int16\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"ascii\">\n");
207 for(i=0; i<n_elem; i++){
210 fprintf (outfp,
"\n");
211 fprintf (outfp,
"</DataArray>\n");
212 for(i=0; i<
data->ne_component; i++){
213 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\">\n",
data->elem_label[i],
data->ne_dof[i]);
216 shift +=
data->ne_dof[j];
218 for(j=0; j<n_elem; j++){
219 for(k=0; k<
data->ne_dof[i]; k++){
220 fprintf (outfp,
"%e ", (
float)
data->elem_val_item[j*data_tot_e+k+shift]);
222 fprintf (outfp,
"\n");
224 fprintf (outfp,
"</DataArray>\n");
226 fprintf (outfp,
"</CellData>\n");
227 fprintf (outfp,
"</Piece>\n");
228 fprintf (outfp,
"</UnstructuredGrid>\n");
229 fprintf (outfp,
"</VTKFile>\n");
237 int myrank, petot, steptot;
238 int n_node, n_elem, shift, etype;
239 int data_tot_n, data_tot_e, in, ioffset;
245 float val, val1, val2, val3;
249 int table342[10] = {0, 1, 2, 3, 6, 4, 5, 7, 8, 9};
258 for(i=0; i<
data->nn_component; i++){
259 data_tot_n +=
data->nn_dof[i];
262 for(i=0; i<
data->ne_component; i++){
263 data_tot_e +=
data->ne_dof[i];
266 snprintf(file_vtu,
sizeof(file_vtu),
"%s/%s.%d.vtu", outfile1, outfile,
myrank);
273 snprintf(file_pvtu,
sizeof(file_pvtu),
"%s.pvtu", outfile1);
274 outfp = fopen (file_pvtu,
"wb");
277 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
278 fprintf (outfp,
"<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"%s\" header_type=\"UInt32\">\n",
HECMW_endian_str());
279 fprintf (outfp,
"<PUnstructuredGrid>\n");
280 fprintf (outfp,
"<FieldData>\n");
281 for(i=0; i<
data->ng_component; i++){
283 for(j=0; j<i; j++) shift +=
data->ng_dof[j];
284 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\">",
285 strcmp(
data->global_label[i],
"TOTALTIME") == 0 ?
"TimeValue" :
data->global_label[i],
287 for(k=0; k<
data->ng_dof[i]; k++){
288 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
290 fprintf (outfp,
"</DataArray>\n");
292 fprintf (outfp,
"</FieldData>\n");
293 fprintf (outfp,
"<PPoints>\n");
294 fprintf (outfp,
"<PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n");
295 fprintf (outfp,
"</PPoints>\n");
296 fprintf (outfp,
"<PCells>\n");
297 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\"/>\n");
298 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"offsets\" format=\"appended\"/>\n");
299 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"types\" format=\"appended\"/>\n");
300 fprintf (outfp,
"</PCells>\n");
301 fprintf (outfp,
"<PPointData>\n");
302 for(i=0; i<
data->nn_component; i++){
304 strcmp(
data->node_label[i],
"NodalPrincipalSTRAIN") == 0 ||
305 strcmp(
data->node_label[i],
"NodalPrincipalSTRESS") == 0
307 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]);
309 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\"/>\n",
data->node_label[i],
data->nn_dof[i]);
312 fprintf (outfp,
"</PPointData>\n");
313 fprintf (outfp,
"<PCellData>\n");
314 for(i=0; i<
data->ne_component; i++){
316 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRAIN") == 0 ||
317 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRESS") == 0
319 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]);
321 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\"/>\n",
data->elem_label[i],
data->ne_dof[i]);
324 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"appended\"/>\n");
325 fprintf (outfp,
"</PCellData>\n");
326 for(i=0; i<petot; i++){
327 snprintf (buf,
sizeof(buf),
"./%s/%s.%d.vtu", outfile, outfile, i);
328 fprintf (outfp,
"<Piece Source=\"%s\"/>\n", buf);
330 fprintf (outfp,
"</PUnstructuredGrid>\n");
331 fprintf (outfp,
"</VTKFile>\n");
337 ioffset = 5 +
data->nn_component +
data->ne_component;
341 for(i=0; i<n_elem; i++){
348 uint64 += jE-shift-jS;
352 offset[1] = offset[0] +
sizeof(int) + 3*n_node *
sizeof(
float);
353 offset[2] = offset[1] +
sizeof(int) + (
int)uint64*
sizeof(int);
354 offset[3] = offset[2] +
sizeof(int) + n_elem *
sizeof(
int);
355 offset[4] = offset[3] +
sizeof(int) + n_elem *
sizeof(
int);
356 for(i=0; i<
data->nn_component; i++){
357 offset[5+i] = offset[4+i] +
sizeof(int) +
data->nn_dof[i]*n_node*
sizeof(
int);
359 for(i=0; i<
data->ne_component; i++){
360 offset[5+
data->nn_component+i] = offset[4+
data->nn_component+i] +
sizeof(int) +
data->ne_dof[i]*n_elem*
sizeof(
int);
363 outfp = fopen (file_vtu,
"wb");
366 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
367 fprintf (outfp,
"<VTKFile type=\"UnstructuredGrid\" version=\"1.0\" byte_order=\"%s\" header_type=\"UInt32\">\n",
HECMW_endian_str());
368 fprintf (outfp,
"<UnstructuredGrid>\n");
369 fprintf (outfp,
"<FieldData>\n");
370 for(i=0; i<
data->ng_component; i++){
371 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\" >\n",
372 strcmp(
data->global_label[i],
"TOTALTIME") == 0 ?
"TimeValue" :
data->global_label[i],
376 shift +=
data->ng_dof[j];
378 for(k=0; k<
data->ng_dof[i]; k++){
379 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
381 fprintf (outfp,
"\n");
382 fprintf (outfp,
"</DataArray>\n");
384 fprintf (outfp,
"</FieldData>\n");
385 fprintf (outfp,
"<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", n_node, n_elem);
386 fprintf (outfp,
"<Points>\n");
387 fprintf (outfp,
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\"%d\">\n", offset[0]);
388 fprintf (outfp,
"</DataArray>\n");
389 fprintf (outfp,
"</Points>\n");
390 fprintf (outfp,
"<Cells>\n");
391 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\"%d\">\n", offset[1]);
392 fprintf (outfp,
"</DataArray>\n");
393 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\"%d\">\n", offset[2]);
394 fprintf (outfp,
"</DataArray>\n");
395 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"types\" format=\"appended\" offset=\"%d\">\n", offset[3]);
396 fprintf (outfp,
"</DataArray>\n");
397 fprintf (outfp,
"</Cells>\n");
398 fprintf (outfp,
"<PointData>\n");
400 for(i=0; i<
data->nn_component; i++){
401 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]);
402 fprintf (outfp,
"</DataArray>\n");
405 fprintf (outfp,
"</PointData>\n");
406 fprintf (outfp,
"<CellData>\n");
407 for(i=0; i<
data->ne_component; i++){
408 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]);
409 fprintf (outfp,
"</DataArray>\n");
412 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"appended\" offset=\"%d\">\n", offset[ioffset-1]);
413 fprintf (outfp,
"</DataArray>\n");
414 fprintf (outfp,
"</CellData>\n");
415 fprintf (outfp,
"</Piece>\n");
416 fprintf (outfp,
"</UnstructuredGrid>\n");
417 fprintf (outfp,
"<AppendedData encoding=\"raw\">\n");
419 fprintf (outfp,
" _");
420 uint32 = (uint32_t)(3*n_node*
sizeof(
float));
421 fwrite (&uint32,
sizeof(uint32), 1, outfp);
422 for(i=0; i<n_node; i++){
424 fwrite (&val,
sizeof(
float), 1, outfp);
426 fwrite (&val,
sizeof(
float), 1, outfp);
428 fwrite (&val,
sizeof(
float), 1, outfp);
431 uint32 = (uint32_t)(uint64*
sizeof(
int));
432 fwrite (&uint32,
sizeof(uint32), 1, outfp);
433 for(i=0; i<n_elem; i++){
441 for(j=jS; j<jE-shift; j++){
443 fwrite (&in,
sizeof(
int), 1, outfp);
446 for(j=jS; j<jE-shift; j++){
448 fwrite (&in,
sizeof(
int), 1, outfp);
453 uint32 = (uint32_t)(n_elem*
sizeof(
int));
454 fwrite (&uint32,
sizeof(uint32), 1, outfp);
456 for(i=0; i<n_elem; i++){
461 fwrite (&in,
sizeof(
int), 1, outfp);
464 uint32 = (uint32_t)(n_elem*
sizeof(
int));
465 fwrite (&uint32,
sizeof(uint32), 1, outfp);
466 for(i=0; i<n_elem; i++){
470 fwrite (&in,
sizeof(
int), 1, outfp);
473 for(i=0; i<
data->nn_component; i++){
474 uint32 = (uint32_t)(
data->nn_dof[i]*n_node*
sizeof(
int));
475 fwrite (&uint32,
sizeof(uint32), 1, outfp);
479 shift +=
data->nn_dof[j];
481 for(j=0; j<n_node; j++){
482 for(k=0; k<
data->nn_dof[i]; k++){
483 val = (float)
data->node_val_item[j*data_tot_n+k+shift];
484 fwrite (&val,
sizeof(
float), 1, outfp);
489 for(i=0; i<
data->ne_component; i++){
490 uint32 = (uint32_t)(
data->ne_dof[i]*n_elem*
sizeof(
int));
491 fwrite (&uint32,
sizeof(uint32), 1, outfp);
495 shift +=
data->ne_dof[j];
497 for(j=0; j<n_elem; j++){
498 for(k=0; k<
data->ne_dof[i]; k++){
499 val = (float)
data->elem_val_item[j*data_tot_e+k+shift];
500 fwrite (&val,
sizeof(
float), 1, outfp);
505 uint32 = (uint32_t)(n_elem*
sizeof(
int));
506 fwrite (&uint32,
sizeof(uint32), 1, outfp);
507 for(i=0; i<n_elem; i++){
511 fwrite (&in,
sizeof(
int), 1, outfp);
514 fprintf (outfp,
"</AppendedData>\n");
515 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