Ifpack Package Browser (Single Doxygen Collection)  Development
SubdomainGraph_dh.h
Go to the documentation of this file.
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
49 extern "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 */
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  */
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 
104  bool debug;
105  };
106 
107  extern void SubdomainGraph_dhCreate (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 
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 
141  /*
142  exchange permutation information for external columns with nearest neighbors;
143  caller must ensure SubdomainGraph_dhInit() has completed before calling.
144  */
145 
147  FILE * fp);
148 
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
SubdomainGraph_dhPrintRatios
void SubdomainGraph_dhPrintRatios(SubdomainGraph_dh s, FILE *fp)
Definition: SubdomainGraph_dh.c:2199
_subdomain_dh
Definition: SubdomainGraph_dh.h:68
TIMING_BINS_SG
#define TIMING_BINS_SG
Definition: SubdomainGraph_dh.h:59
TOTAL_SGT
Definition: SubdomainGraph_dh.h:61
_subdomain_dh::loCount
int loCount
Definition: SubdomainGraph_dh.h:90
_subdomain_dh::colors
int colors
Definition: SubdomainGraph_dh.h:74
SubdomainGraph_dhDestroy
void SubdomainGraph_dhDestroy(SubdomainGraph_dh s)
Definition: SubdomainGraph_dh.c:127
euclid_common.h
_subdomain_dh::row_count
int * row_count
Definition: SubdomainGraph_dh.h:84
FIND_NABORS_SGT
Definition: SubdomainGraph_dh.h:62
_subdomain_dh::timing
double timing[TIMING_BINS_SG]
Definition: SubdomainGraph_dh.h:103
_subdomain_dh::hiNabors
int * hiNabors
Definition: SubdomainGraph_dh.h:91
SubdomainGraph_dhInit
void SubdomainGraph_dhInit(SubdomainGraph_dh s, int blocks, bool bj, void *A)
Definition: SubdomainGraph_dh.c:218
_subdomain_dh::loNabors
int * loNabors
Definition: SubdomainGraph_dh.h:90
SubdomainGraph_dhPrintStats
void SubdomainGraph_dhPrintStats(SubdomainGraph_dh sg, FILE *fp)
Definition: SubdomainGraph_dh.c:2275
SubdomainGraph_dhFindOwner
int SubdomainGraph_dhFindOwner(SubdomainGraph_dh s, int idx, bool permuted)
Definition: SubdomainGraph_dh.c:245
_subdomain_dh::allNabors
int * allNabors
Definition: SubdomainGraph_dh.h:92
SubdomainGraph_dhColor
void SubdomainGraph_dhColor(SubdomainGraph_dh s)
SubdomainGraph_dhPrintSubdomainGraph
void SubdomainGraph_dhPrintSubdomainGraph(SubdomainGraph_dh s, FILE *fp)
Definition: SubdomainGraph_dh.c:2138
_subdomain_dh::colorVec
int * colorVec
Definition: SubdomainGraph_dh.h:76
SubdomainGraph_dhCreate
void SubdomainGraph_dhCreate(SubdomainGraph_dh *s)
Definition: SubdomainGraph_dh.c:93
_subdomain_dh::n2o_sub
int * n2o_sub
Definition: SubdomainGraph_dh.h:73
_subdomain_dh::doNotColor
bool doNotColor
Definition: SubdomainGraph_dh.h:75
FORM_GRAPH_SGT
Definition: SubdomainGraph_dh.h:64
_subdomain_dh::n2o_row
int * n2o_row
Definition: SubdomainGraph_dh.h:97
_subdomain_dh::o2n_sub
int * o2n_sub
Definition: SubdomainGraph_dh.h:72
_subdomain_dh::o2n_col
int * o2n_col
Definition: SubdomainGraph_dh.h:98
_subdomain_dh::m
int m
Definition: SubdomainGraph_dh.h:96
EXCHANGE_PERMS_SGT
Definition: SubdomainGraph_dh.h:65
_subdomain_dh::bdry_count
int * bdry_count
Definition: SubdomainGraph_dh.h:85
A
SubdomainGraph_dhDump
void SubdomainGraph_dhDump(SubdomainGraph_dh s, char *filename)
Definition: SubdomainGraph_dh.c:1785
_subdomain_dh::blocks
int blocks
Definition: SubdomainGraph_dh.h:70
_subdomain_dh::adj
int * adj
Definition: SubdomainGraph_dh.h:71
SubdomainGraph_dhExchangePerms
void SubdomainGraph_dhExchangePerms(SubdomainGraph_dh s)
Definition: SubdomainGraph_dh.c:844
_hash_i_dh
Definition: Hash_i_dh.c:79
_subdomain_dh::allCount
int allCount
Definition: SubdomainGraph_dh.h:92
_subdomain_dh::hiCount
int hiCount
Definition: SubdomainGraph_dh.h:91
_subdomain_dh::o2n_ext
Hash_i_dh o2n_ext
Definition: SubdomainGraph_dh.h:100
_subdomain_dh::ptrs
int * ptrs
Definition: SubdomainGraph_dh.h:71
ORDER_BDRY_SGT
Definition: SubdomainGraph_dh.h:63
SubdomainGraph_dhPrintStatsLong
void SubdomainGraph_dhPrintStatsLong(SubdomainGraph_dh s, FILE *fp)
Definition: SubdomainGraph_dh.c:281
_subdomain_dh::n2o_ext
Hash_i_dh n2o_ext
Definition: SubdomainGraph_dh.h:101
_subdomain_dh::debug
bool debug
Definition: SubdomainGraph_dh.h:104
_subdomain_dh::beg_row
int * beg_row
Definition: SubdomainGraph_dh.h:80
_subdomain_dh::beg_rowP
int * beg_rowP
Definition: SubdomainGraph_dh.h:81