1 /*****************************************************************************
2 * Copyright (c) 2019 FrontISTR Commons
3 * This software is released under the MIT License, see LICENSE.txt
4 *****************************************************************************/
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include "hecmw_struct.h"
9 #include "hecmw_result.h"
10 #include "hecmw_util.h"
11 #include "hecmw_io.h"
12 #include "hecmw_visualizer.h"
13
14 extern PSF_link *psf;
15 extern PVR_link *pvr;
16
main(int argc,char ** argv)17 int main(int argc, char **argv) {
18 int i;
19 struct hecmwST_local_mesh *mesh;
20 struct hecmwST_result_data *data;
21 char *resultfile, resultfile1[HECMW_FILENAME_LEN];
22 int min_step, max_step, interval, timestep;
23 PSF_link *tp1;
24 PVR_link *tv1;
25 int fg_text;
26 int mynode;
27
28 if (HECMW_init(&argc, &argv)) abort();
29
30 mesh = HECMW_get_mesh("fstrMSH");
31 if (mesh == NULL) HECMW_abort(HECMW_comm_get_comm());
32
33 HECMW_Comm_rank(mesh->HECMW_COMM, &mynode);
34
35 HECMW_visualize_init();
36
37 min_step = 100000000;
38 max_step = -10000000;
39 tp1 = psf->next_psf;
40 tv1 = pvr->next_pvr;
41 for (i = 0; i < psf->num_of_psf; i++) {
42 if ((tp1->visual_start_step != -1) && (tp1->visual_start_step < min_step))
43 min_step = tp1->visual_start_step;
44 if ((tp1->visual_end_step != -1) && (tp1->visual_end_step > max_step))
45 max_step = tp1->visual_end_step;
46 interval = tp1->visual_interval_step;
47 tp1 = tp1->next_psf;
48 }
49 for (i = 0; i < pvr->num_of_pvr; i++) {
50 if ((tv1->visual_start_step != -1) && (tv1->visual_start_step < min_step))
51 min_step = tv1->visual_start_step;
52 if ((tv1->visual_end_step != -1) && (tv1->visual_end_step > max_step))
53 max_step = tv1->visual_end_step;
54 interval = tp1->visual_interval_step;
55 tv1 = tv1->next_pvr;
56 }
57 if ((min_step == 100000000) && (max_step == -10000000)) {
58 min_step = 1;
59 max_step = 1;
60 interval = 1;
61 }
62
63 for (timestep = min_step; timestep <= max_step; timestep++) {
64 if ((timestep % interval) != 0 && timestep != max_step) continue;
65
66 resultfile = HECMW_ctrl_get_result_fileheader("fstrRES", timestep,
67 &fg_text);
68 sprintf(resultfile1, "%s.%d.%d", resultfile, mynode, timestep);
69 data = HECMW_result_read_by_fname(resultfile1);
70 if (data == NULL) HECMW_abort(HECMW_comm_get_comm());
71
72 HECMW_visualize(mesh, data, timestep);
73
74 HECMW_result_free(data);
75 }
76
77 HECMW_visualize_finalize();
78
79 HECMW_dist_free(mesh);
80
81 HECMW_finalize();
82
83 return 0;
84 }
85