IFPACK Development
Loading...
Searching...
No Matches
SubdomainGraph_dh.h
1/*@HEADER
2// ***********************************************************************
3//
4// Ifpack: Object-Oriented Algebraic Preconditioner Package
5// Copyright (2002) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40//@HEADER
41*/
42
43#ifndef SUBDOMAIN_GRAPH_DH
44#define SUBDOMAIN_GRAPH_DH
45
46#include "euclid_common.h"
47
48#ifdef __cplusplus
49extern "C"
50{
51#endif
52
53#define MAX_SUBDOMAIN_COLOR 100
54 /* could be done better: if we can't color the subdomain graph
55 with this many colors, an error is thrown in SubdomainGraph_dhColor().
56 */
57
58/* for internal timing */
59#define TIMING_BINS_SG 10
60 enum
61 { TOTAL_SGT, /* total Init (setup) time */
62 FIND_NABORS_SGT,
63 ORDER_BDRY_SGT,
64 FORM_GRAPH_SGT,
65 EXCHANGE_PERMS_SGT
66 };
67
69 {
70 int blocks; /* number of subdomains */
71 int *ptrs, *adj; /* csr structure for representing subdomain graph */
72 int *o2n_sub; /* subdomain graph permutation; */
73 int *n2o_sub; /* inverse permutation; */
74 int colors; /* number of colors used for coloring the subdomain graph */
75 bool doNotColor; /* if true, subdomain graph is not colored and reordered */
76 int *colorVec; /* if colorVec[i] = x, then subdomain i was colored "x".
77 this array is probably only useful for debugging.
78 */
79
80 int *beg_row; /* global ordering of first local row owned by P_i */
81 int *beg_rowP; /* global ordering of first local row owned by P_i after
82 subdomain reordering
83 */
84 int *row_count; /* P_i owns row_count[i] local rows */
85 int *bdry_count; /* bdry_count[i] of P_i's rows are boundary rows */
86
87 /* Nearest neighbors in subdomain graph, before reordering;
88 "self" is not included. Not used for sequential case.
89 */
90 int *loNabors, loCount;
91 int *hiNabors, hiCount;
92 int *allNabors, allCount;
93
94
95 /* permutation information for global unknowns (matrix rows) */
96 int m; /* length of n2o_row and o2n_col */
97 int *n2o_row; /* permutation for locally owned matrix rows */
98 int *o2n_col; /* permutation for locally owned matrix columns */
99
100 Hash_i_dh o2n_ext; /* permutation for external columns */
101 Hash_i_dh n2o_ext; /* inverse permutation for external columns */
102
103 double timing[TIMING_BINS_SG];
104 bool debug;
105 };
106
107 extern void SubdomainGraph_dhCreate (SubdomainGraph_dh * s);
108 extern void SubdomainGraph_dhDestroy (SubdomainGraph_dh s);
109
110 extern void SubdomainGraph_dhInit (SubdomainGraph_dh s, int blocks, bool bj,
111 void *A);
112 /* Partitions matrix A into the specified number of blocks,
113 if there is a single MPI task; for mpi use, "blocks" must be the same
114 as the number of mpi tasks; for sequential, it may vary.
115 On completion, the subdomain graph will be fully formed,
116 (all fields valid); o2n_row[] and n2o_col[] will be permutations
117 for the locally owned portion of A such that A's interior nodes are
118 ordered first.
119 This function may call a partitioner, such as METIS (currently, only for sequential).
120 On completion, "o2n" contains a natural ordering, beg_row is identical to
121 beg_rowP, and_rowP is identical to end_rowP.
122
123 if "bj" is true, the following setup steps are NOT performed:
124 form subdomain graph; find neighbors; order boundary nodes
125 */
126
127 extern void SubdomainGraph_dhColor (SubdomainGraph_dh s);
128 /*
129 Colors and orders subdomain graph; on completion, o2n[], beg_rowP[], and
130 end_rowP[] may be altered.
131 */
132
133 extern int SubdomainGraph_dhFindOwner (SubdomainGraph_dh s, int idx,
134 bool permuted);
135 /* Returns the subdomain block to which row idx belongs, or throws an error.
136 If "permuted" is true, it's assumed the graph has been permuted (i.e.,
137 'globally reordering phase' in PILU algorithm).
138 */
139
140 extern void SubdomainGraph_dhExchangePerms (SubdomainGraph_dh s);
141 /*
142 exchange permutation information for external columns with nearest neighbors;
143 caller must ensure SubdomainGraph_dhInit() has completed before calling.
144 */
145
146 extern void SubdomainGraph_dhPrintSubdomainGraph (SubdomainGraph_dh s,
147 FILE * fp);
148
149 extern void SubdomainGraph_dhPrintStatsLong (SubdomainGraph_dh s,
150 FILE * fp);
151 /* similar to Short, but prints complete list of interior/bdry node ratios;
152 also prints subdomain permutation
153 */
154
155 extern void SubdomainGraph_dhDump (SubdomainGraph_dh s, char *filename);
156 /* for testing */
157
158 extern void SubdomainGraph_dhPrintRatios (SubdomainGraph_dh s, FILE * fp);
159 /* prints ratios of interior/boundary node for all subdomains */
160
161
162 extern void SubdomainGraph_dhPrintStats (SubdomainGraph_dh sg, FILE * fp);
163
164#ifdef __cplusplus
165}
166#endif
167#endif