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++){
163 for(jj=jS; jj<jE-shift; jj++){
167 for(jj=jS; jj<jE-shift; jj++){
172 fprintf (outfp,
"\n");
174 fprintf (outfp,
"</DataArray>\n");
175 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n");
177 for(i=0; i<n_elem; i++){
183 fprintf (outfp,
"\n");
184 fprintf (outfp,
"</DataArray>\n");
185 fprintf (outfp,
"<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n");
186 for(i=0; i<n_elem; i++){
189 fprintf (outfp,
"\n");
190 fprintf (outfp,
"</DataArray>\n");
191 fprintf (outfp,
"</Cells>\n");
192 fprintf (outfp,
"<PointData>\n");
193 for(i=0; i<
data->nn_component; i++){
194 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\">\n",
data->node_label[i],
data->nn_dof[i]);
197 shift +=
data->nn_dof[j];
199 for(j=0; j<n_node; j++){
200 for(k=0; k<
data->nn_dof[i]; k++){
201 fprintf (outfp,
"%e ", (
float)
data->node_val_item[j*data_tot_n+k+shift]);
203 fprintf (outfp,
"\n");
205 fprintf (outfp,
"</DataArray>\n");
207 fprintf (outfp,
"</PointData>\n");
208 fprintf (outfp,
"<CellData>\n");
209 fprintf (outfp,
"<DataArray type=\"Int16\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"ascii\">\n");
210 for(i=0; i<n_elem; i++){
213 fprintf (outfp,
"\n");
214 fprintf (outfp,
"</DataArray>\n");
215 for(i=0; i<
data->ne_component; i++){
216 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\">\n",
data->elem_label[i],
data->ne_dof[i]);
219 shift +=
data->ne_dof[j];
221 for(j=0; j<n_elem; j++){
222 for(k=0; k<
data->ne_dof[i]; k++){
223 fprintf (outfp,
"%e ", (
float)
data->elem_val_item[j*data_tot_e+k+shift]);
225 fprintf (outfp,
"\n");
227 fprintf (outfp,
"</DataArray>\n");
229 fprintf (outfp,
"</CellData>\n");
230 fprintf (outfp,
"</Piece>\n");
231 fprintf (outfp,
"</UnstructuredGrid>\n");
232 fprintf (outfp,
"</VTKFile>\n");
240 int myrank, petot, steptot;
241 int n_node, n_elem, shift, etype;
242 int data_tot_n, data_tot_e, in, ioffset;
248 float val, val1, val2, val3;
252 int table342[10] = {0, 1, 2, 3, 6, 4, 5, 7, 8, 9};
261 for(i=0; i<
data->nn_component; i++){
262 data_tot_n +=
data->nn_dof[i];
265 for(i=0; i<
data->ne_component; i++){
266 data_tot_e +=
data->ne_dof[i];
269 snprintf(file_vtu,
sizeof(file_vtu),
"%s/%s.%d.vtu", outfile1, outfile,
myrank);
276 snprintf(file_pvtu,
sizeof(file_pvtu),
"%s.pvtu", outfile1);
277 outfp = fopen (file_pvtu,
"wb");
280 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
281 fprintf (outfp,
"<VTKFile type=\"PUnstructuredGrid\" version=\"1.0\" byte_order=\"%s\" header_type=\"UInt32\">\n",
HECMW_endian_str());
282 fprintf (outfp,
"<PUnstructuredGrid>\n");
283 fprintf (outfp,
"<FieldData>\n");
284 for(i=0; i<
data->ng_component; i++){
286 for(j=0; j<i; j++) shift +=
data->ng_dof[j];
287 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\">",
288 strcmp(
data->global_label[i],
"TOTALTIME") == 0 ?
"TimeValue" :
data->global_label[i],
290 for(k=0; k<
data->ng_dof[i]; k++){
291 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
293 fprintf (outfp,
"</DataArray>\n");
295 fprintf (outfp,
"</FieldData>\n");
296 fprintf (outfp,
"<PPoints>\n");
297 fprintf (outfp,
"<PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n");
298 fprintf (outfp,
"</PPoints>\n");
299 fprintf (outfp,
"<PCells>\n");
300 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\"/>\n");
301 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"offsets\" format=\"appended\"/>\n");
302 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"types\" format=\"appended\"/>\n");
303 fprintf (outfp,
"</PCells>\n");
304 fprintf (outfp,
"<PPointData>\n");
305 for(i=0; i<
data->nn_component; i++){
307 strcmp(
data->node_label[i],
"NodalPrincipalSTRAIN") == 0 ||
308 strcmp(
data->node_label[i],
"NodalPrincipalSTRESS") == 0
310 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]);
312 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\"/>\n",
data->node_label[i],
data->nn_dof[i]);
315 fprintf (outfp,
"</PPointData>\n");
316 fprintf (outfp,
"<PCellData>\n");
317 for(i=0; i<
data->ne_component; i++){
319 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRAIN") == 0 ||
320 strcmp(
data->elem_label[i],
"ElementalPrincipalSTRESS") == 0
322 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]);
324 fprintf (outfp,
"<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\"/>\n",
data->elem_label[i],
data->ne_dof[i]);
327 fprintf (outfp,
"<PDataArray type=\"Int32\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"appended\"/>\n");
328 fprintf (outfp,
"</PCellData>\n");
329 for(i=0; i<petot; i++){
330 snprintf (buf,
sizeof(buf),
"./%s/%s.%d.vtu", outfile, outfile, i);
331 fprintf (outfp,
"<Piece Source=\"%s\"/>\n", buf);
333 fprintf (outfp,
"</PUnstructuredGrid>\n");
334 fprintf (outfp,
"</VTKFile>\n");
340 ioffset = 5 +
data->nn_component +
data->ne_component;
344 for(i=0; i<n_elem; i++){
351 uint64 += jE-shift-jS;
355 offset[1] = offset[0] +
sizeof(int) + 3*n_node *
sizeof(
float);
356 offset[2] = offset[1] +
sizeof(int) + (
int)uint64*
sizeof(int);
357 offset[3] = offset[2] +
sizeof(int) + n_elem *
sizeof(
int);
358 offset[4] = offset[3] +
sizeof(int) + n_elem *
sizeof(
int);
359 for(i=0; i<
data->nn_component; i++){
360 offset[5+i] = offset[4+i] +
sizeof(int) +
data->nn_dof[i]*n_node*
sizeof(
int);
362 for(i=0; i<
data->ne_component; i++){
363 offset[5+
data->nn_component+i] = offset[4+
data->nn_component+i] +
sizeof(int) +
data->ne_dof[i]*n_elem*
sizeof(
int);
366 outfp = fopen (file_vtu,
"wb");
369 fprintf (outfp,
"<?xml version=\"1.0\"?>\n");
370 fprintf (outfp,
"<VTKFile type=\"UnstructuredGrid\" version=\"1.0\" byte_order=\"%s\" header_type=\"UInt32\">\n",
HECMW_endian_str());
371 fprintf (outfp,
"<UnstructuredGrid>\n");
372 fprintf (outfp,
"<FieldData>\n");
373 for(i=0; i<
data->ng_component; i++){
374 fprintf (outfp,
"<DataArray type=\"Float32\" Name=\"%s\" NumberOfTuples=\"%d\" >\n",
375 strcmp(
data->global_label[i],
"TOTALTIME") == 0 ?
"TimeValue" :
data->global_label[i],
379 shift +=
data->ng_dof[j];
381 for(k=0; k<
data->ng_dof[i]; k++){
382 fprintf (outfp,
"%e ", (
float)
data->global_val_item[k+shift]);
384 fprintf (outfp,
"\n");
385 fprintf (outfp,
"</DataArray>\n");
387 fprintf (outfp,
"</FieldData>\n");
388 fprintf (outfp,
"<Piece NumberOfPoints=\"%d\" NumberOfCells=\"%d\">\n", n_node, n_elem);
389 fprintf (outfp,
"<Points>\n");
390 fprintf (outfp,
"<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"appended\" offset=\"%d\">\n", offset[0]);
391 fprintf (outfp,
"</DataArray>\n");
392 fprintf (outfp,
"</Points>\n");
393 fprintf (outfp,
"<Cells>\n");
394 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"connectivity\" format=\"appended\" offset=\"%d\">\n", offset[1]);
395 fprintf (outfp,
"</DataArray>\n");
396 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"offsets\" format=\"appended\" offset=\"%d\">\n", offset[2]);
397 fprintf (outfp,
"</DataArray>\n");
398 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"types\" format=\"appended\" offset=\"%d\">\n", offset[3]);
399 fprintf (outfp,
"</DataArray>\n");
400 fprintf (outfp,
"</Cells>\n");
401 fprintf (outfp,
"<PointData>\n");
403 for(i=0; i<
data->nn_component; i++){
404 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]);
405 fprintf (outfp,
"</DataArray>\n");
408 fprintf (outfp,
"</PointData>\n");
409 fprintf (outfp,
"<CellData>\n");
410 for(i=0; i<
data->ne_component; i++){
411 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]);
412 fprintf (outfp,
"</DataArray>\n");
415 fprintf (outfp,
"<DataArray type=\"Int32\" Name=\"Mesh_Type\" NumberOfComponents=\"1\" format=\"appended\" offset=\"%d\">\n", offset[ioffset-1]);
416 fprintf (outfp,
"</DataArray>\n");
417 fprintf (outfp,
"</CellData>\n");
418 fprintf (outfp,
"</Piece>\n");
419 fprintf (outfp,
"</UnstructuredGrid>\n");
420 fprintf (outfp,
"<AppendedData encoding=\"raw\">\n");
422 fprintf (outfp,
" _");
423 uint32 = (uint32_t)(3*n_node*
sizeof(
float));
424 fwrite (&uint32,
sizeof(uint32), 1, outfp);
425 for(i=0; i<n_node; i++){
427 fwrite (&val,
sizeof(
float), 1, outfp);
429 fwrite (&val,
sizeof(
float), 1, outfp);
431 fwrite (&val,
sizeof(
float), 1, outfp);
434 uint32 = (uint32_t)(uint64*
sizeof(
int));
435 fwrite (&uint32,
sizeof(uint32), 1, outfp);
436 for(i=0; i<n_elem; i++){
446 for(jj=jS; jj<jE-shift; jj++){
448 fwrite (&in,
sizeof(
int), 1, outfp);
451 for(jj=jS; jj<jE-shift; jj++){
453 fwrite (&in,
sizeof(
int), 1, outfp);
459 uint32 = (uint32_t)(n_elem*
sizeof(
int));
460 fwrite (&uint32,
sizeof(uint32), 1, outfp);
462 for(i=0; i<n_elem; i++){
467 fwrite (&in,
sizeof(
int), 1, outfp);
470 uint32 = (uint32_t)(n_elem*
sizeof(
int));
471 fwrite (&uint32,
sizeof(uint32), 1, outfp);
472 for(i=0; i<n_elem; i++){
476 fwrite (&in,
sizeof(
int), 1, outfp);
479 for(i=0; i<
data->nn_component; i++){
480 uint32 = (uint32_t)(
data->nn_dof[i]*n_node*
sizeof(
int));
481 fwrite (&uint32,
sizeof(uint32), 1, outfp);
485 shift +=
data->nn_dof[j];
487 for(j=0; j<n_node; j++){
488 for(k=0; k<
data->nn_dof[i]; k++){
489 val = (float)
data->node_val_item[j*data_tot_n+k+shift];
490 fwrite (&val,
sizeof(
float), 1, outfp);
495 for(i=0; i<
data->ne_component; i++){
496 uint32 = (uint32_t)(
data->ne_dof[i]*n_elem*
sizeof(
int));
497 fwrite (&uint32,
sizeof(uint32), 1, outfp);
501 shift +=
data->ne_dof[j];
503 for(j=0; j<n_elem; j++){
504 for(k=0; k<
data->ne_dof[i]; k++){
505 val = (float)
data->elem_val_item[j*data_tot_e+k+shift];
506 fwrite (&val,
sizeof(
float), 1, outfp);
511 uint32 = (uint32_t)(n_elem*
sizeof(
int));
512 fwrite (&uint32,
sizeof(uint32), 1, outfp);
513 for(i=0; i<n_elem; i++){
517 fwrite (&in,
sizeof(
int), 1, outfp);
520 fprintf (outfp,
"</AppendedData>\n");
521 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