IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
SubdomainGraph_dh.h
00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2002) 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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 //@HEADER
00041 */
00042 
00043 #ifndef SUBDOMAIN_GRAPH_DH
00044 #define SUBDOMAIN_GRAPH_DH
00045 
00046 #include "euclid_common.h"
00047 
00048 #ifdef __cplusplus
00049 extern "C"
00050 {
00051 #endif
00052 
00053 #define MAX_SUBDOMAIN_COLOR 100
00054   /* could be done better: if we can't color the subdomain graph
00055      with this many colors, an error is thrown in SubdomainGraph_dhColor().
00056    */
00057 
00058 /* for internal timing */
00059 #define TIMING_BINS_SG 10
00060   enum
00061   { TOTAL_SGT,          /* total Init (setup) time */
00062     FIND_NABORS_SGT,
00063     ORDER_BDRY_SGT,
00064     FORM_GRAPH_SGT,
00065     EXCHANGE_PERMS_SGT
00066   };
00067 
00068   struct _subdomain_dh
00069   {
00070     int blocks;         /* number of subdomains */
00071     int *ptrs, *adj;        /* csr structure for representing subdomain graph */
00072     int *o2n_sub;       /* subdomain graph permutation; */
00073     int *n2o_sub;       /* inverse permutation; */
00074     int colors;         /* number of colors used  for coloring the subdomain graph */
00075     bool doNotColor;        /* if true, subdomain graph is not colored and reordered */
00076     int *colorVec;      /* if colorVec[i] = x, then subdomain i was colored "x".
00077                    this array is probably only useful for debugging.
00078                  */
00079 
00080     int *beg_row;       /* global ordering of first local row owned by P_i */
00081     int *beg_rowP;      /* global ordering of first local row owned by P_i after
00082                    subdomain reordering 
00083                  */
00084     int *row_count;     /* P_i owns row_count[i] local rows */
00085     int *bdry_count;        /* bdry_count[i] of P_i's rows are boundary rows */
00086 
00087     /* Nearest neighbors in subdomain graph, before reordering;
00088        "self" is not included.  Not used for sequential case.
00089      */
00090     int *loNabors, loCount;
00091     int *hiNabors, hiCount;
00092     int *allNabors, allCount;
00093 
00094 
00095     /* permutation information for global unknowns (matrix rows) */
00096     int m;          /* length of n2o_row and o2n_col */
00097     int *n2o_row;       /* permutation for locally owned matrix rows */
00098     int *o2n_col;       /* permutation for locally owned matrix columns */
00099 
00100     Hash_i_dh o2n_ext;      /* permutation for external columns */
00101     Hash_i_dh n2o_ext;      /* inverse permutation for external columns */
00102 
00103     double timing[TIMING_BINS_SG];
00104     bool debug;
00105   };
00106 
00107   extern void SubdomainGraph_dhCreate (SubdomainGraph_dh * s);
00108   extern void SubdomainGraph_dhDestroy (SubdomainGraph_dh s);
00109 
00110   extern void SubdomainGraph_dhInit (SubdomainGraph_dh s, int blocks, bool bj,
00111                      void *A);
00112   /* Partitions matrix A into the specified number of blocks,
00113      if there is a single MPI task; for mpi use, "blocks" must be the same 
00114      as the number of mpi tasks; for sequential, it may vary.
00115      On completion, the subdomain graph will be fully formed,
00116      (all fields valid); o2n_row[] and n2o_col[] will be permutations
00117      for the locally owned portion of A such that A's interior nodes are
00118      ordered first.
00119      This function may call a partitioner, such as METIS (currently, only for sequential).
00120      On completion, "o2n" contains a natural ordering, beg_row is identical to
00121      beg_rowP, and_rowP is identical to end_rowP.
00122 
00123      if "bj" is true, the following setup steps are NOT performed:
00124      form subdomain graph; find neighbors; order boundary nodes
00125    */
00126 
00127   extern void SubdomainGraph_dhColor (SubdomainGraph_dh s);
00128   /*
00129      Colors and orders subdomain graph; on completion, o2n[], beg_rowP[], and
00130      end_rowP[] may be altered.
00131    */
00132 
00133   extern int SubdomainGraph_dhFindOwner (SubdomainGraph_dh s, int idx,
00134                      bool permuted);
00135   /* Returns the subdomain block to which row idx belongs, or throws an error.
00136      If "permuted" is true, it's assumed the graph has been permuted (i.e.,
00137      'globally reordering phase' in PILU algorithm).
00138    */
00139 
00140   extern void SubdomainGraph_dhExchangePerms (SubdomainGraph_dh s);
00141   /*
00142      exchange permutation information for external columns with nearest neighbors;
00143      caller must ensure SubdomainGraph_dhInit() has completed before calling.
00144    */
00145 
00146   extern void SubdomainGraph_dhPrintSubdomainGraph (SubdomainGraph_dh s,
00147                             FILE * fp);
00148 
00149   extern void SubdomainGraph_dhPrintStatsLong (SubdomainGraph_dh s,
00150                            FILE * fp);
00151   /* similar to Short, but prints complete list of interior/bdry node ratios;
00152      also prints subdomain permutation
00153    */
00154 
00155   extern void SubdomainGraph_dhDump (SubdomainGraph_dh s, char *filename);
00156   /* for testing */
00157 
00158   extern void SubdomainGraph_dhPrintRatios (SubdomainGraph_dh s, FILE * fp);
00159   /* prints ratios of interior/boundary node for all subdomains */
00160 
00161 
00162   extern void SubdomainGraph_dhPrintStats (SubdomainGraph_dh sg, FILE * fp);
00163 
00164 #ifdef __cplusplus
00165 }
00166 #endif
00167 #endif
 All Classes Files Functions Variables Enumerations Friends