FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
matrix_repart.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 "hecmw_util.h"
9
10#ifdef HECMW_WITH_METIS
11#include "metis.h"
12#endif
13
14#include "matrix2graph.h"
15#include "separator.h"
17
18void bi_part_directive(int *neqns, int *nttbr, int *irow, int *jcol,
19 int *num_graph1, int *num_graph2, int *num_separator) {
20#ifdef HECMW_WITH_METIS
21 graph_type *graph;
22 int num_of_row, num_of_col, num_of_nzero;
23
24 int *perm, *iperm;
25
26 num_of_row = *neqns;
27 num_of_col = *neqns;
28 num_of_nzero = *nttbr;
29
30 graph = (graph_type *)malloc(sizeof(graph_type));
31 if (graph == NULL) separator_memory_exit("graph");
32
33 fprintf(stderr, "Start transforming matrix to graph\n");
34 matrix2graph(num_of_row, num_of_col, num_of_nzero, irow, jcol, graph);
35 fprintf(stderr,
36 "Graph Information "
37 "---------------------------------------------------\n");
38 fprintf(stderr, "#Vertices: %d, #Edges: %d\n\n", graph->nvtxs,
39 graph->nedges / 2);
40 perm = (int *)calloc(num_of_col, sizeof(int));
41 iperm = (int *)calloc(num_of_col, sizeof(int));
42 if ((perm == NULL) || (iperm == NULL))
43 separator_memory_exit("matrix_repart: perm, iperm");
44
45#if defined(METIS_VER_MAJOR) && (METIS_VER_MAJOR == 5)
46 {
47 int options[METIS_NOPTIONS];
48 METIS_SetDefaultOptions(options);
49 options[METIS_OPTION_COMPRESS] = 0;
50 METIS_NodeND(&graph->nvtxs, graph->xadj, graph->adjncy, NULL, NULL, perm,
51 iperm);
52 }
53#else
54 {
55 int options[8];
56 int num_flag;
57 /* followings are options. see METIS manual for METIS_NODEND() */
58 options[0] = 1; /* specify parameters */
59 options[1] = 3; /* default */
60 options[2] = 1; /* default */
61 options[3] = 2; /* default */
62 options[4] = 0; /* default */
63 options[5] = 0; /* do not try to compress the matrix */
64 options[6] = 0; /* default */
65 options[7] = 1; /* default */
66
67 num_flag = 0;
68 METIS_NodeND(&graph->nvtxs, graph->xadj, graph->adjncy, &num_flag, options,
69 perm, iperm);
70 }
71#endif
72 /* copy to separator */
73
74 *num_graph1 = separator->num_of_lgraph;
75 *num_graph2 = separator->num_of_rgraph;
76 *num_separator = separator->num_of_separator;
77
78#else
79 fprintf(
80 stderr,
81 "Error: Direct Parallel Solver not available. Please install Metis.\n");
83#endif
84
85 return;
86}
87
88void bi_part_directive_(int *neqns, int *nttbr, int *irow, int *jcol,
89 int *num_graph1, int *num_graph2, int *num_separator) {
90 bi_part_directive(neqns, nttbr, irow, jcol, num_graph1, num_graph2,
91 num_separator);
92}
93
94void bi_part_directive__(int *neqns, int *nttbr, int *irow, int *jcol,
95 int *num_graph1, int *num_graph2, int *num_separator) {
96 bi_part_directive(neqns, nttbr, irow, jcol, num_graph1, num_graph2,
97 num_separator);
98}
99
100void BI_PART_DIRECTIVE(int *neqns, int *nttbr, int *irow, int *jcol,
101 int *num_graph1, int *num_graph2, int *num_separator) {
102 bi_part_directive(neqns, nttbr, irow, jcol, num_graph1, num_graph2,
103 num_separator);
104}
HECMW_Comm HECMW_comm_get_comm(void)
Definition: hecmw_comm.c:699
#define NULL
void HECMW_abort(HECMW_Comm comm)
Definition: hecmw_util.c:88
struct option_rec options[]
specify command line option name and executing function name. \attension list must be terminated with...
Definition: main.c:187
void matrix2graph(int num_of_row, int num_of_col, int num_of_nzero, int *irow, int *jcol, graph_type *graph)
Definition: matrix2graph.c:12
Separator_result * separator
Definition: matrix_repart.c:16
void bi_part_directive__(int *neqns, int *nttbr, int *irow, int *jcol, int *num_graph1, int *num_graph2, int *num_separator)
Definition: matrix_repart.c:94
void bi_part_directive(int *neqns, int *nttbr, int *irow, int *jcol, int *num_graph1, int *num_graph2, int *num_separator)
Definition: matrix_repart.c:18
void bi_part_directive_(int *neqns, int *nttbr, int *irow, int *jcol, int *num_graph1, int *num_graph2, int *num_separator)
Definition: matrix_repart.c:88
void BI_PART_DIRECTIVE(int *neqns, int *nttbr, int *irow, int *jcol, int *num_graph1, int *num_graph2, int *num_separator)
void separator_memory_exit(char *var)
Definition: mem_util.c:9
int * xadj
Definition: matrix2graph.h:13
int * adjncy
Definition: matrix2graph.h:14