00001 /*@HEADER 00002 // *********************************************************************** 00003 // 00004 // Ifpack: Object-Oriented Algebraic Preconditioner Package 00005 // Copyright (2009) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 00028 */ 00029 00030 #ifndef SUBDOMAIN_GRAPH_DH 00031 #define SUBDOMAIN_GRAPH_DH 00032 00033 #include "euclid_common.h" 00034 00035 #ifdef __cplusplus 00036 extern "C" 00037 { 00038 #endif 00039 00040 #define MAX_SUBDOMAIN_COLOR 100 00041 /* could be done better: if we can't color the subdomain graph 00042 with this many colors, an error is thrown in SubdomainGraph_dhColor(). 00043 */ 00044 00045 /* for internal timing */ 00046 #define TIMING_BINS_SG 10 00047 enum 00048 { TOTAL_SGT, /* total Init (setup) time */ 00049 FIND_NABORS_SGT, 00050 ORDER_BDRY_SGT, 00051 FORM_GRAPH_SGT, 00052 EXCHANGE_PERMS_SGT 00053 }; 00054 00055 struct _subdomain_dh 00056 { 00057 int blocks; /* number of subdomains */ 00058 int *ptrs, *adj; /* csr structure for representing subdomain graph */ 00059 int *o2n_sub; /* subdomain graph permutation; */ 00060 int *n2o_sub; /* inverse permutation; */ 00061 int colors; /* number of colors used for coloring the subdomain graph */ 00062 bool doNotColor; /* if true, subdomain graph is not colored and reordered */ 00063 int *colorVec; /* if colorVec[i] = x, then subdomain i was colored "x". 00064 this array is probably only useful for debugging. 00065 */ 00066 00067 int *beg_row; /* global ordering of first local row owned by P_i */ 00068 int *beg_rowP; /* global ordering of first local row owned by P_i after 00069 subdomain reordering 00070 */ 00071 int *row_count; /* P_i owns row_count[i] local rows */ 00072 int *bdry_count; /* bdry_count[i] of P_i's rows are boundary rows */ 00073 00074 /* Nearest neighbors in subdomain graph, before reordering; 00075 "self" is not included. Not used for sequential case. 00076 */ 00077 int *loNabors, loCount; 00078 int *hiNabors, hiCount; 00079 int *allNabors, allCount; 00080 00081 00082 /* permutation information for global unknowns (matrix rows) */ 00083 int m; /* length of n2o_row and o2n_col */ 00084 int *n2o_row; /* permutation for locally owned matrix rows */ 00085 int *o2n_col; /* permutation for locally owned matrix columns */ 00086 00087 Hash_i_dh o2n_ext; /* permutation for external columns */ 00088 Hash_i_dh n2o_ext; /* inverse permutation for external columns */ 00089 00090 double timing[TIMING_BINS_SG]; 00091 bool debug; 00092 }; 00093 00094 extern void SubdomainGraph_dhCreate (SubdomainGraph_dh * s); 00095 extern void SubdomainGraph_dhDestroy (SubdomainGraph_dh s); 00096 00097 extern void SubdomainGraph_dhInit (SubdomainGraph_dh s, int blocks, bool bj, 00098 void *A); 00099 /* Partitions matrix A into the specified number of blocks, 00100 if there is a single MPI task; for mpi use, "blocks" must be the same 00101 as the number of mpi tasks; for sequential, it may vary. 00102 On completion, the subdomain graph will be fully formed, 00103 (all fields valid); o2n_row[] and n2o_col[] will be permutations 00104 for the locally owned portion of A such that A's interior nodes are 00105 ordered first. 00106 This function may call a partitioner, such as METIS (currently, only for sequential). 00107 On completion, "o2n" contains a natural ordering, beg_row is identical to 00108 beg_rowP, and_rowP is identical to end_rowP. 00109 00110 if "bj" is true, the following setup steps are NOT performed: 00111 form subdomain graph; find neighbors; order boundary nodes 00112 */ 00113 00114 extern void SubdomainGraph_dhColor (SubdomainGraph_dh s); 00115 /* 00116 Colors and orders subdomain graph; on completion, o2n[], beg_rowP[], and 00117 end_rowP[] may be altered. 00118 */ 00119 00120 extern int SubdomainGraph_dhFindOwner (SubdomainGraph_dh s, int idx, 00121 bool permuted); 00122 /* Returns the subdomain block to which row idx belongs, or throws an error. 00123 If "permuted" is true, it's assumed the graph has been permuted (i.e., 00124 'globally reordering phase' in PILU algorithm). 00125 */ 00126 00127 extern void SubdomainGraph_dhExchangePerms (SubdomainGraph_dh s); 00128 /* 00129 exchange permutation information for external columns with nearest neighbors; 00130 caller must ensure SubdomainGraph_dhInit() has completed before calling. 00131 */ 00132 00133 extern void SubdomainGraph_dhPrintSubdomainGraph (SubdomainGraph_dh s, 00134 FILE * fp); 00135 00136 extern void SubdomainGraph_dhPrintStatsLong (SubdomainGraph_dh s, 00137 FILE * fp); 00138 /* similar to Short, but prints complete list of interior/bdry node ratios; 00139 also prints subdomain permutation 00140 */ 00141 00142 extern void SubdomainGraph_dhDump (SubdomainGraph_dh s, char *filename); 00143 /* for testing */ 00144 00145 extern void SubdomainGraph_dhPrintRatios (SubdomainGraph_dh s, FILE * fp); 00146 /* prints ratios of interior/boundary node for all subdomains */ 00147 00148 00149 extern void SubdomainGraph_dhPrintStats (SubdomainGraph_dh sg, FILE * fp); 00150 00151 #ifdef __cplusplus 00152 } 00153 #endif 00154 #endif
1.7.6.1