FrontISTR  5.8.0
Large-scale structural analysis program with finit element method
hecmw_partitioner.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 <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <assert.h>
10 #include <errno.h>
11 #include <limits.h>
12 
13 #include "hecmw_util.h"
14 #include "hecmw_io.h"
16 #include "hecmw_partition.h"
17 
18 int main(int argc, char **argv) {
19  struct hecmwST_local_mesh *global_mesh = NULL;
20  struct hecmwST_local_mesh *local_mesh = NULL;
21  int rtc;
22 
23  rtc = HECMW_init(&argc, &argv);
24  if (rtc != 0) goto error;
25 
26  rtc = HECMW_init_for_partition(argc, argv);
27  if (rtc != 0) goto error;
28 
29  HECMW_log(HECMW_LOG_INFO, "Reading mesh file...");
30  global_mesh = HECMW_get_mesh("part_in");
31  if (global_mesh == NULL) goto error;
32 
33  /* Debug output for large mesh analysis */
34  HECMW_log(HECMW_LOG_INFO, "Mesh loaded: nodes=%d, elements=%d",
35  global_mesh->n_node, global_mesh->n_elem);
36 
37  if (global_mesh->elem_node_index && global_mesh->n_elem > 0) {
38  size_t total_connectivity = global_mesh->elem_node_index[global_mesh->n_elem];
39  if (total_connectivity > INT_MAX) {
40  HECMW_log(HECMW_LOG_INFO, "Total element connectivity entries: %zu", total_connectivity);
41  HECMW_log(HECMW_LOG_WARN, "WARNING: Element connectivity count exceeds 32-bit integer limit %d!", INT_MAX);
42  }
43  }
44 
45  local_mesh = HECMW_partition(global_mesh);
46  if (local_mesh == NULL) goto error;
47 
48  HECMW_dist_free(global_mesh);
49 
51 
52  return 0;
53 
54 error:
55  HECMW_dist_free(global_mesh);
58 
59  return -1;
60 }
HECMW_Comm HECMW_comm_get_comm(void)
Definition: hecmw_comm.c:699
void HECMW_dist_free(struct hecmwST_local_mesh *mesh)
int HECMW_finalize(void)
Definition: hecmw_finalize.c:9
int HECMW_init(int *argc, char ***argv)
Definition: hecmw_init.c:24
int HECMW_init_for_partition(int argc, char **argv)
struct hecmwST_local_mesh * HECMW_get_mesh(char *name_ID)
#define NULL
int HECMW_log(int loglv, const char *fmt,...)
Definition: hecmw_log.c:260
#define HECMW_LOG_WARN
Definition: hecmw_log.h:17
#define HECMW_LOG_INFO
Definition: hecmw_log.h:19
struct hecmwST_local_mesh * HECMW_partition(struct hecmwST_local_mesh *global_mesh)
int main(int argc, char **argv)
void HECMW_abort(HECMW_Comm comm)
Definition: hecmw_util.c:88
long long * elem_node_index
Definition: hecmw_struct.h:195