FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_init_for_partition.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 
12 #include "hecmw_msgno.h"
13 #include "hecmw_malloc.h"
14 #include "hecmw_error.h"
15 
16 #include "hecmw_part_define.h"
17 #include "hecmw_part_get_control.h"
19 
20 #define DEFAULT_CONTROL_FILE_NAME "hecmw_part_ctrl.dat"
21 
22 static void print_usage(void) {
23  fprintf(stderr, "Usage: hecmw_part1 [-f filename] [-v] [-d number] [-m KMETIS|PMETIS|RCB ] [-e number] \n");
24  fprintf(stderr, " [ -t NODE-BASED|ELEMENT-BASED ] [ -u filename ] [ -c DEFAULT|AGGREGATE|DISTRIBUTE|SIMPLE]\n");
25  fprintf(stderr, "\n");
26  fprintf(stderr, " -f specify control file name\n");
27  fprintf(stderr, " -v print verbose messages\n");
28  fprintf(stderr, " -h print usage\n");
29  fprintf(stderr, "*** If the following options are set, hecmw_part_ctrl.dat will be ignored. ***\n");
30  fprintf(stderr, " -d number of sub-domains \n");
31  fprintf(stderr, " -t partitioning type (unimplemented, default: NODE-BASED) \n");
32  fprintf(stderr, " -m partitioning method (unimplemented, default: KMETIS) \n");
33  fprintf(stderr, " -e depth of overlapping zone (unimplemented, default: 1) \n");
34  fprintf(stderr, " -u UCD file. (unimplemented, default: #no output#) \n");
35  fprintf(stderr, " -c partitioning contact (unimplemented, default: DEFAULT) \n");
36 
37 }
38 
39 extern int HECMW_init_for_partition(int argc, char **argv) {
40  int counter;
41  char control_file_name[HECMW_FILENAME_LEN + 1];
42 
43  strcpy(control_file_name, DEFAULT_CONTROL_FILE_NAME);
44 
45  if (argc > 1) {
46  counter = 1;
47  while (counter < argc) {
48  if (!strcmp(argv[counter], "-f")) {
49  counter++;
50  if (counter >= argc) {
51  print_usage();
52  goto error;
53  }
54  if (strlen(argv[counter]) > HECMW_FILENAME_LEN) {
56  "control file for partitioner");
57  goto error;
58  }
59  strcpy(control_file_name, argv[counter]);
60  counter++;
61 
62  }else if (!strcmp(argv[counter], "-d")) {
63  counter++;
64  if (counter >= argc) {
65  print_usage();
66  goto error;
67  }
68  if (HECMW_part_set_subdomains(atoi(argv[counter]))) goto error;
69  counter++;
70  } else if (!strcmp(argv[counter], "-v")) {
71  counter++;
73 
74  } else {
75  print_usage();
76  goto error;
77  }
78  }
79  }
80 
81  if (HECMW_part_set_ctrl_file_name(control_file_name)) goto error;
82 
83  return 0;
84 
85 error:
86  return -1;
87 }
hecmw_malloc.h
HECMW_LOG_DEBUG
#define HECMW_LOG_DEBUG
Definition: hecmw_log.h:21
HECMW_PART_E_TOO_LONG_FNAME
#define HECMW_PART_E_TOO_LONG_FNAME
Definition: hecmw_part_define.h:55
hecmw_error.h
hecmw_msgno.h
hecmw_init_for_partition.h
DEFAULT_CONTROL_FILE_NAME
#define DEFAULT_CONTROL_FILE_NAME
Definition: hecmw_init_for_partition.c:20
hecmw_part_define.h
HECMW_part_set_subdomains
int HECMW_part_set_subdomains(int n_domain)
Definition: hecmw_part_get_control.c:24
HECMW_part_set_ctrl_file_name
int HECMW_part_set_ctrl_file_name(char *fname)
Definition: hecmw_part_get_control.c:29
hecmw_part_get_control.h
HECMW_init_for_partition
int HECMW_init_for_partition(int argc, char **argv)
Definition: hecmw_init_for_partition.c:39
HECMW_set_error
int HECMW_set_error(int errorno, const char *fmt,...)
Definition: hecmw_error.c:37
HECMW_setloglv
void HECMW_setloglv(int loglv)
Definition: hecmw_log.c:57
HECMW_FILENAME_LEN
#define HECMW_FILENAME_LEN
Definition: hecmw_config.h:72