FrontISTR  5.7.1
Large-scale structural analysis program with finit element method
hecmw_fstr_output_vtk.c
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
6 
7 #include <stdint.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include <stdlib.h>
11 #include <math.h>
12 #include "hecmw_malloc.h"
13 #include "hecmw_etype.h"
14 #include "hecmw_vis_mem_util.h"
15 #include "hecmw_vis_comm_util.h"
16 #include "hecmw_vis_combine.h"
17 #include "hecmw_fstr_endian.h"
18 
19 void vtk_output (struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, char *outfile1, HECMW_Comm VIS_COMM)
20 {
21  int i, j, k;
22  int jS, jE;
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};
27  char file_pvd[HECMW_FILENAME_LEN], file_pvtu[HECMW_FILENAME_LEN], file_vtu[HECMW_FILENAME_LEN], buf[HECMW_FILENAME_LEN];
28  char *data_label, *p;
29  static int is_first=0;
30  FILE *outfp;
31  HECMW_Status stat;
32 
33  HECMW_Comm_rank (VIS_COMM, &myrank);
34  HECMW_Comm_size (VIS_COMM, &petot);
35  n_node = mesh->n_node;
36  n_elem = mesh->n_elem;
37  data_tot_n = 0;
38  for(i=0; i<data->nn_component; i++){
39  data_tot_n += data->nn_dof[i];
40  }
41  data_tot_e = 0;
42  for(i=0; i<data->ne_component; i++){
43  data_tot_e += data->ne_dof[i];
44  }
45 
46  p = strrchr(outfile, (int)(unsigned char)'/');
47  if(NULL != p){
48  outfile = p+1;
49  }
50 
51  sprintf(file_vtu, "%s/%s.%d.vtu", outfile1, outfile, myrank);
52  if(HECMW_ctrl_make_subdir(file_vtu)) {
53  HECMW_vis_print_exit("ERROR: HEC-MW-VIS-E0009: Cannot open output directory");
54  }
55 
56  if (myrank == 0) {
57  /* outpu pvtu file */
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]);
65  }
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++){
76  if(
77  strcmp(data->node_label[i], "NodalPrincipalSTRAIN") == 0 ||
78  strcmp(data->node_label[i], "NodalPrincipalSTRESS") == 0
79  ) {
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]);
81  } else {
82  fprintf (outfp, "<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"/>\n", data->node_label[i], data->nn_dof[i]);
83  }
84  }
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++){
89  if(
90  strcmp(data->elem_label[i], "ElementalPrincipalSTRAIN") == 0 ||
91  strcmp(data->elem_label[i], "ElementalPrincipalSTRESS") == 0
92  ) {
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]);
94  } else {
95  fprintf (outfp, "<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"ascii\"/>\n", data->elem_label[i], data->ne_dof[i]);
96  }
97  }
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);
102  }
103  fprintf (outfp, "</PUnstructuredGrid>\n");
104  fprintf (outfp, "</VTKFile>\n");
105  fclose (outfp);
106  }
107 
108  /* output vtu file */
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]);
116  shift=0;
117  for(j=0; j<i; j++){
118  shift += data->ng_dof[j];
119  }
120  for(k=0; k<data->ng_dof[i]; k++){
121  fprintf (outfp, "%e ", (float)data->global_val_item[k+shift]);
122  }
123  fprintf (outfp, "\n");
124  fprintf (outfp, "</DataArray>\n");
125  }
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++){
131  fprintf (outfp, "%e %e %e\n", (float)mesh->node[3*i], (float)mesh->node[3*i+1], (float)mesh->node[3*i+2]);
132  }
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++){
138  jS=mesh->elem_node_index[i];
139  jE=mesh->elem_node_index[i+1];
140  shift=0;
141  if(mesh->elem_type[i]==641) shift=2;
142  if(mesh->elem_type[i]==761) shift=3;
143  if(mesh->elem_type[i]==781) shift=4;
144  if(mesh->elem_type[i]==342){
145  for(j=jS; j<jE-shift; j++){
146  fprintf (outfp, "%d ", mesh->elem_node_item[jS+table342[j-jS]]-1);
147  }
148  }else{
149  for(j=jS; j<jE-shift; j++){
150  fprintf (outfp, "%d ", mesh->elem_node_item[j]-1);
151  }
152  }
153  fprintf (outfp, "\n");
154  }
155  fprintf (outfp, "</DataArray>\n");
156  fprintf (outfp, "<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n");
157  shift=0;
158  for(i=0; i<n_elem; i++){
159  if(mesh->elem_type[i]==641) shift+=2;
160  if(mesh->elem_type[i]==761) shift+=3;
161  if(mesh->elem_type[i]==781) shift+=4;
162  fprintf (outfp, "%d ", mesh->elem_node_index[i+1]-shift);
163  }
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++){
168  fprintf (outfp, "%d ", HECMW_get_etype_vtk_shape(mesh->elem_type[i]));
169  }
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]);
176  shift=0;
177  for(j=0; j<i; j++){
178  shift += data->nn_dof[j];
179  }
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]);
183  }
184  fprintf (outfp, "\n");
185  }
186  fprintf (outfp, "</DataArray>\n");
187  }
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++){
192  fprintf (outfp, "%d ", mesh->elem_type[i]);
193  }
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]);
198  shift=0;
199  for(j=0; j<i; j++){
200  shift += data->ne_dof[j];
201  }
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]);
205  }
206  fprintf (outfp, "\n");
207  }
208  fprintf (outfp, "</DataArray>\n");
209  }
210  fprintf (outfp, "</CellData>\n");
211  fprintf (outfp, "</Piece>\n");
212  fprintf (outfp, "</UnstructuredGrid>\n");
213  fprintf (outfp, "</VTKFile>\n");
214  fclose (outfp);
215 }
216 
217 void bin_vtk_output (struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, char *outfile1, HECMW_Comm VIS_COMM)
218 {
219  int i, j, k;
220  int jS, jE;
221  int myrank, petot, steptot;
222  int n_node, n_elem, shift, etype;
223  int data_tot_n, data_tot_e, in, ioffset;
224  int *offset;
225  uint8_t uint8;
226  uint16_t uint16;
227  uint32_t uint32;
228  uint64_t uint64;
229  float val, val1, val2, val3;
230  char file_pvd[HECMW_FILENAME_LEN], file_pvtu[HECMW_FILENAME_LEN], file_vtu[HECMW_FILENAME_LEN], buf[HECMW_FILENAME_LEN];
231  char *data_label;
232  static int is_first=0;
233  int table342[10] = {0, 1, 2, 3, 6, 4, 5, 7, 8, 9};
234  FILE *outfp;
235  HECMW_Status stat;
236 
237  HECMW_Comm_rank (VIS_COMM, &myrank);
238  HECMW_Comm_size (VIS_COMM, &petot);
239  n_node = mesh->n_node;
240  n_elem = mesh->n_elem;
241  data_tot_n = 0;
242  for(i=0; i<data->nn_component; i++){
243  data_tot_n += data->nn_dof[i];
244  }
245  data_tot_e = 0;
246  for(i=0; i<data->ne_component; i++){
247  data_tot_e += data->ne_dof[i];
248  }
249 
250  sprintf(file_vtu, "%s/%s.%d.vtu", outfile1, outfile, myrank);
251  if(HECMW_ctrl_make_subdir(file_vtu)) {
252  HECMW_vis_print_exit("ERROR: HEC-MW-VIS-E0009: Cannot open output directory");
253  }
254 
255  if (myrank == 0) {
256  /* outpu pvtu file */
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]);
264  }
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++){
275  if(
276  strcmp(data->node_label[i], "NodalPrincipalSTRAIN") == 0 ||
277  strcmp(data->node_label[i], "NodalPrincipalSTRESS") == 0
278  ) {
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]);
280  } else {
281  fprintf (outfp, "<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\"/>\n", data->node_label[i], data->nn_dof[i]);
282  }
283  }
284  fprintf (outfp, "</PPointData>\n");
285  fprintf (outfp, "<PCellData>\n");
286  for(i=0; i<data->ne_component; i++){
287  if(
288  strcmp(data->elem_label[i], "ElementalPrincipalSTRAIN") == 0 ||
289  strcmp(data->elem_label[i], "ElementalPrincipalSTRESS") == 0
290  ) {
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]);
292  } else {
293  fprintf (outfp, "<PDataArray type=\"Float32\" Name=\"%s\" NumberOfComponents=\"%d\" format=\"appended\"/>\n", data->elem_label[i], data->ne_dof[i]);
294  }
295  }
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);
301  }
302  fprintf (outfp, "</PUnstructuredGrid>\n");
303  fprintf (outfp, "</VTKFile>\n");
304  fclose (outfp);
305  is_first = 1;
306  }
307 
308  /* outpu vtu file */
309  ioffset = 5 + data->nn_component + data->ne_component;
310  offset = HECMW_malloc(sizeof(int)*ioffset);
311 
312  uint64 = 0;
313  for(i=0; i<n_elem; i++){
314  jS=mesh->elem_node_index[i];
315  jE=mesh->elem_node_index[i+1];
316  shift=0;
317  if(mesh->elem_type[i]==641) shift=2;
318  if(mesh->elem_type[i]==761) shift=3;
319  if(mesh->elem_type[i]==781) shift=4;
320  uint64 += jE-shift-jS;
321  }
322 
323  offset[0] = 0;
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);
330  }
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);
333  }
334 
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]);
342  shift=0;
343  for(j=0; j<i; j++){
344  shift += data->ng_dof[j];
345  }
346  for(k=0; k<data->ng_dof[i]; k++){
347  fprintf (outfp, "%e ", (float)data->global_val_item[k+shift]);
348  }
349  fprintf (outfp, "\n");
350  fprintf (outfp, "</DataArray>\n");
351  }
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");
367 
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");
371  }
372 
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");
378  }
379 
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");
386 
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++){
391  val = (float)mesh->node[3*i];
392  fwrite (&val, sizeof(float), 1, outfp);
393  val = (float)mesh->node[3*i+1];
394  fwrite (&val, sizeof(float), 1, outfp);
395  val = (float)mesh->node[3*i+2];
396  fwrite (&val, sizeof(float), 1, outfp);
397  }
398 
399  uint32 = (uint32_t)(uint64*sizeof(int));
400  fwrite (&uint32, sizeof(uint32), 1, outfp);
401  for(i=0; i<n_elem; i++){
402  jS=mesh->elem_node_index[i];
403  jE=mesh->elem_node_index[i+1];
404  shift=0;
405  if(mesh->elem_type[i]==641) shift=2;
406  if(mesh->elem_type[i]==761) shift=3;
407  if(mesh->elem_type[i]==781) shift=4;
408  if(mesh->elem_type[i]==342){
409  for(j=jS; j<jE-shift; j++){
410  in = (int)mesh->elem_node_item[jS+table342[j-jS]]-1;
411  fwrite (&in, sizeof(int), 1, outfp);
412  }
413  }else{
414  for(j=jS; j<jE-shift; j++){
415  in = (int)mesh->elem_node_item[j]-1;
416  fwrite (&in, sizeof(int), 1, outfp);
417  }
418  }
419  }
420 
421  uint32 = (uint32_t)(n_elem*sizeof(int));
422  fwrite (&uint32, sizeof(uint32), 1, outfp);
423  shift=0;
424  for(i=0; i<n_elem; i++){
425  if(mesh->elem_type[i]==641) shift+=2;
426  if(mesh->elem_type[i]==761) shift+=3;
427  if(mesh->elem_type[i]==781) shift+=4;
428  in = (int)mesh->elem_node_index[i+1]-shift;
429  fwrite (&in, sizeof(int), 1, outfp);
430  }
431 
432  uint32 = (uint32_t)(n_elem*sizeof(int));
433  fwrite (&uint32, sizeof(uint32), 1, outfp);
434  for(i=0; i<n_elem; i++){
435  //uint8 = (uint8_t)HECMW_get_etype_vtk_shape(mesh->elem_type[i]);
436  //fwrite (&uint8, sizeof(u_int8_t), 1, outfp);
438  fwrite (&in, sizeof(int), 1, outfp);
439  }
440 
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);
444 
445  shift=0;
446  for(j=0; j<i; j++){
447  shift += data->nn_dof[j];
448  }
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);
453  }
454  }
455  }
456 
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);
460 
461  shift=0;
462  for(j=0; j<i; j++){
463  shift += data->ne_dof[j];
464  }
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);
469  }
470  }
471  }
472 
473  uint32 = (uint32_t)(n_elem*sizeof(int));
474  fwrite (&uint32, sizeof(uint32), 1, outfp);
475  for(i=0; i<n_elem; i++){
476  //uint16 = (uint16_t)mesh->elem_type[i];
477  //fwrite (&uint16, sizeof(u_int16_t), 1, outfp);
478  in = (int)mesh->elem_type[i];
479  fwrite (&in, sizeof(int), 1, outfp);
480  }
481 
482  fprintf (outfp, "</AppendedData>\n");
483  fprintf (outfp, "</VTKFile>\n");
484  fclose (outfp);
485 }
486 
487 void HECMW_vtk_output (struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, char *outfile1, HECMW_Comm VIS_COMM)
488 {
489  vtk_output (mesh, data, outfile, outfile1, VIS_COMM);
490 }
491 
492 void HECMW_bin_vtk_output (struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, char *outfile1, HECMW_Comm VIS_COMM)
493 {
494  bin_vtk_output (mesh, data, outfile, outfile1, VIS_COMM);
495 }
int is_first
int HECMW_Comm_rank(HECMW_Comm comm, int *rank)
Definition: hecmw_comm.c:18
int HECMW_Comm_size(HECMW_Comm comm, int *size)
Definition: hecmw_comm.c:37
#define HECMW_FILENAME_LEN
Definition: hecmw_config.h:72
MPI_Status HECMW_Status
Definition: hecmw_config.h:36
MPI_Comm HECMW_Comm
Definition: hecmw_config.h:30
int HECMW_ctrl_make_subdir(char *filename)
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
int HECMW_get_etype_vtk_shape(int etype)
Definition: hecmw_etype.c:1731
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 NULL
#define HECMW_malloc(size)
Definition: hecmw_malloc.h:20
void HECMW_vis_print_exit(char *var)
integer(kind=kint) myrank
PARALLEL EXECUTION.
Definition: m_fstr.f90:96
CNFData data