FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_dlb_migrate.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  *****************************************************************************/
5 
6 #include "hecmw_repart.h"
7 /*
8 extern void write_mesh_display(char *outfile, struct local_mesh *mesh, struct
9 node_elem_data *node);
10 extern void write2_mesh_display(char *outfile, struct local_mesh *mesh, struct
11 node_elem_data *node);
12 */
13 
14 extern struct hecmwST_local_mesh *mesh;
15 extern struct hecmwST_result_data *data;
16 extern struct hecmwST_local_mesh *new_mesh;
17 extern struct hecmwST_result_data *new_data;
18 
19 extern void mesh_migration(int mynode, int pesize, Result_part *result,
20  int *vtxdist);
21 extern void mesh_migration_adapt(int mynode, int pesize, Result_part *result,
22  int *vtxdist);
23 extern void write_dist_mesh_display(char *outfile,
26 extern void write_one_mesh_display(char *outfile,
29  HECMW_Comm VIS_COMM, int mynode, int pesize);
31  struct hecmwST_result_data *data,
32  char *resultfile_dist);
33 
34 /*
35 extern void mesh_migration(int pesize, int mynode, struct local_mesh *mesh,
36 struct node_elem_data *node, struct local_mesh *new_mesh,
37  struct node_elem_data *new_node,
38 Result_part *result,
39  int *vtxdist, int *new_vtxdist, int
40 *global_new2old, HECMW_Comm repart_comm);
41 extern void grp_migration(int pesize, int mynode, int t_node, struct local_mesh
42 *new_mesh, struct local_mesh *mesh, struct grp_data *grp,
43  struct grp_data *new_grp, int *vtxdist,int
44 *new_vtxdist,
45  int *global_new2old, HECMW_Comm repart_comm);
46 
47 
48 
49 void redistribute_mesh(struct local_mesh *mesh, struct grp_data *grp, GraphType
50 *graph,
51  Result_part *result, struct local_mesh
52 *new_mesh, struct grp_data *new_grp, struct node_elem_data *new_node,
53  HECMW_Comm VIS_COMM)
54  */
55 
56 void redistribute_mesh(GraphType *graph, Result_part *result, int mynode,
57  int pesize)
58 
59 {
60  int i, j, k, m;
61  Adj_find *p1, *p2;
62  HECMW_Status stat;
63  int *tmp_index, tmp_nvtxs, tmp_sum_node, tmp_sum_adj, tmp_sum_elem, tmp_pe,
64  tmp_lid, tmp_sum;
65  FILE *fp_test, *fp_orig, *fp;
66  char test_file[128], orig_file[128];
67  int *send_node_num, *send_node, *count_node, *send_adj_num, *count_adj,
68  *send_adj, *send_elem_num, *send_elem, *count_elem;
69  int *recv_node_num, *recv_elem_num, *recv_elem, *recv_node;
70  int *flag_hit;
71  int n_elem_type;
72  int *new_part;
73  int tmp_int, *tmp_send, *tmp_recv;
74  int max_global_elem_num, new_n_elem;
75  int *elem_keep_flag, *elem_hit_flag, *node_global_hit;
76  Import_link_struct *import_link, *p3, *p4;
77  int *recv_import_num, *recv_import, *send_import_num, *send_import,
78  *send_recv_num, import_num;
79  double *tmp_send_d, *tmp_recv_d;
80  int *global_new2old, *new_vtxdist, *vtxdist;
81  int tn_component, ne_internal, tmp_count;
82  char *resultfile, buf2[HECMW_FILENAME_LEN],
83  resultfile_dist[HECMW_FILENAME_LEN];
84 
85  if (mynode == 0)
86  fprintf(stderr, "Start migration for generating new mesh among PEs \n");
87  /* update_ne_internal(mynode, mesh);
88  fp_orig=fopen(orig_filename, "r");
89  for(i=0;i<mesh->n_elem;i++)
90  fprintf(fp_orig, "n_elem=%d ne_internal=%d\n", i+1,
91  mesh->ne_internal_list[i]);
92  fclose(fp_orig);
93  */
94  /*
95 
96  write2_mesh_display(orig_filename, mesh, node);
97 
98 
99  sprintf(orig_filename, "orig_mesh.%d.inp", mynode);
100 
101  write_mesh_display(orig_filename, mesh, node);
102  */
103  vtxdist = (int *)calloc(pesize + 1, sizeof(int));
104  for (i = 0; i < pesize + 1; i++) vtxdist[i] = graph->vtxdist[i];
105  /* new_vtxdist=(int *)calloc(pesize+1, sizeof(int));
106 
107  global_new2old=(int *)calloc(result->t_node, sizeof(int));
108  if((new_vtxdist==NULL) || (global_new2old==NULL))
109  HECMW_dlb_memory_exit("global_new2old");
110  */
111  /* if(mesh->hecmw_flag_adapt==0)
112  mesh_migration(mynode,pesize, result, vtxdist);
113  else if(mesh->hecmw_flag_adapt==1)
114  */
115  mesh_migration_adapt(mynode, pesize, result, vtxdist);
116  if (mynode == 0)
117  fprintf(stderr, "Start output balanced mesh and result to files\n");
118  HECMW_put_mesh(new_mesh, "mesh-dlb-out");
119 
120  resultfile =
122  sprintf(resultfile_dist, "%s.%d", resultfile, mynode);
124 
125  /* free(node->data);
126 free(node->n_free);
127 
128 grp_migration(pesize, mynode, result->t_node, new_mesh, mesh, grp, new_grp,
129 graph->vtxdist, new_vtxdist, global_new2old,
130  repart_comm);
131 
132 free(global_new2old);
133 free(new_vtxdist);
134 */
135  /* sprintf(orig_file, "orig_mesh.%d.inp", mynode);
136  write_dist_mesh_display(orig_file, mesh, data);
137 
138  sprintf(test_file, "bala_mesh.%d.inp", mynode);
139  write_dist_mesh_display(test_file, new_mesh, new_data);
140  */
141  /* sprintf(test_file, "test_result.%d", mynode);
142 
143  if ((fp = fopen(test_file, "w")) == NULL) {
144  fprintf(stderr, "output file error: %s\n", test_file);
145  exit (1);
146  }
147  */
148  /* tn_component=0;
149  for(i=0;i<new_data->nn_component;i++)
150  tn_component+=new_data->nn_dof[i];
151  ne_internal=0;
152  for(i=0;i<new_mesh->ne_internal;i++) {
153  if(new_mesh->adapt_type[new_mesh->elem_internal_list[i]-1]==0)
154  ne_internal++;
155  }
156 
157  fprintf(fp, "%d %d %d %d %d\n", new_mesh->n_node, ne_internal, tn_component,
158  0, 0);
159  for(i=0;i<new_mesh->n_node;i++)
160  fprintf(fp, "%d %lf %lf %lf\n", i+1, new_mesh->node[i*3],
161  new_mesh->node[i*3+1], new_mesh->node[i*3+2]);
162  tmp_count=0;
163  for(i=0;i<new_mesh->ne_internal;i++) {
164  if(new_mesh->adapt_type[new_mesh->elem_internal_list[i]-1]==0) {
165  tmp_count++;
166  fprintf(fp, "%d 1 ", tmp_count);
167  tmp_int=new_mesh->elem_internal_list[i]-1;
168  if((new_mesh->elem_node_index[tmp_int+1]-new_mesh->elem_node_index[tmp_int])
169  == 4)
170  fprintf(fp, " tet ");
171  else
172  fprintf(fp, " prism ");
173  for(j=new_mesh->elem_node_index[tmp_int];j<new_mesh->elem_node_index[tmp_int+1];j++)
174  fprintf(fp, "%d ",
175  new_mesh->elem_node_item[j]);
176  fprintf(fp,"\n");
177  }
178  }
179  fprintf(fp, "%d ", new_data->nn_component);
180  for(i=0;i<new_data->nn_component;i++)
181  fprintf(fp, "%d ", new_data->nn_dof[i]);
182  fprintf(fp, "\n");
183  for(i=0;i<new_data->nn_component;i++)
184  fprintf(fp, "%s,\n", new_data->node_label[i]);
185  for(i=0;i<new_mesh->n_node;i++) {
186  fprintf(fp, "%d ", i+1);
187  for(j=0;j<tn_component;j++)
188  fprintf(fp, "%lf ",
189  new_data->node_val_item[i*tn_component+j]);
190  fprintf(fp, "\n");
191  }
192  */
193  /* fprintf(fp, "%d\n", new_mesh->n_neighbor_pe);
194  for(i=0;i<new_mesh->n_neighbor_pe;i++)
195  fprintf(fp, "%d ", new_mesh->neighbor_pe[i]);
196  fprintf(fp, "\n");
197  for(i=0;i<new_mesh->n_neighbor_pe+1;i++)
198  fprintf(fp, "%d ", new_mesh->import_index[i]);
199  fprintf(fp, "\n");
200  for(i=0;i<new_mesh->n_neighbor_pe+1;i++)
201  fprintf(fp, "%d ", new_mesh->export_index[i]);
202  fprintf(fp, "\n");
203  fprintf(fp, "=====import nodes ====\n");
204  for(i=0;i<new_mesh->import_index[new_mesh->n_neighbor_pe];i++)
205  fprintf(fp, "%d\n", new_mesh->import_item[i]);
206  fprintf(fp, "=====export nodes ====\n");
207  for(i=0;i<new_mesh->export_index[new_mesh->n_neighbor_pe];i++)
208  fprintf(fp, "%d\n", new_mesh->export_item[i]);
209 
210  fclose(fp);
211  */
212 
213  return;
214 }
hecmwST_result_data
Definition: hecmw_result.h:11
_adj_find_struct
Definition: hecmw_repart.h:58
mesh_migration_adapt
void mesh_migration_adapt(int mynode, int pesize, Result_part *result, int *vtxdist)
Definition: hecmw_dlb_elem_sr_adapt.c:50
write_one_mesh_display
void write_one_mesh_display(char *outfile, struct hecmwST_local_mesh *new_mesh, struct hecmwST_result_data *new_data, HECMW_Comm VIS_COMM, int mynode, int pesize)
hecmwST_local_mesh
Definition: hecmw_struct.h:139
hecmw_repart.h
new_mesh
struct hecmwST_local_mesh * new_mesh
Definition: hecmw_repart.h:72
HECMW_Status
MPI_Status HECMW_Status
Definition: hecmw_config.h:36
HECMW_put_result_from_structure
void HECMW_put_result_from_structure(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *resultfile_dist)
Definition: hecmw_dlb_output_result.c:8
write_dist_mesh_display
void write_dist_mesh_display(char *outfile, struct hecmwST_local_mesh *new_mesh, struct hecmwST_result_data *new_data)
Definition: output_ucd_c.c:8
data
struct hecmwST_result_data * data
Definition: neu_reporter.cpp:18
_result_partition_struct
Definition: hecmw_repart.h:52
mesh_migration
void mesh_migration(int mynode, int pesize, Result_part *result, int *vtxdist)
mesh
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
HECMW_Comm
MPI_Comm HECMW_Comm
Definition: hecmw_config.h:30
new_data
struct hecmwST_result_data * new_data
Definition: hecmw_repart.h:76
redistribute_mesh
void redistribute_mesh(GraphType *graph, Result_part *result, int mynode, int pesize)
Definition: hecmw_dlb_migrate.c:56
HECMW_FILENAME_LEN
#define HECMW_FILENAME_LEN
Definition: hecmw_config.h:72
HECMW_ctrl_get_result_fileheader
char * HECMW_ctrl_get_result_fileheader(char *name_ID, int istep, int *fg_text)
Definition: hecmw_control.c:2321
HECMW_put_mesh
int HECMW_put_mesh(struct hecmwST_local_mesh *mesh, char *name_ID)
Definition: hecmw_io_put_mesh.c:13