IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends
Euclid_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 EUCLID_MPI_INTERFACE_DH
00044 #define EUCLID_MPI_INTERFACE_DH
00045 
00046 #define DEFAULT_DROP_TOL 0.01
00047 
00048 #include "euclid_common.h"
00049 
00050 /*======================================================================
00051  * Naming convention: functions ending in _mpi are located in
00052  * src/Euclid_mpi.c; those ending in _seq are in src/Euclid_seq.c;
00053  * most others should be in Euclid_all.c.
00054  *
00055  * Exceptions: all Apply() (triangular solves) are in src/Euclid_apply.c;
00056  *             except for the Apply for MPI PILU, which is called
00057  *             Mat_dhSolve, and is in src/Mat_dh.c
00058  *
00059  * Users should only need to call functions with names of the form
00060  * Euclid_dhXXX (public functions). 
00061  *
00062  * Some of the functions whose names are of the form XXX_private_XXX,
00063  * as could easily be static functions; similarly, the enums and
00064  * structs do need to be public.  They are, primarily, for ease in
00065  * debugging and ready reference.
00066  *
00067  * Exceptions: the apply_private functions aren't listed here --- they're
00068  * all static in src/Euclid_apply.c
00069  *======================================================================*/
00070 #ifdef __cplusplus
00071 extern "C"
00072 {
00073 #endif
00074 
00075   extern void Euclid_dhCreate (Euclid_dh * ctxOUT);
00076   extern void Euclid_dhDestroy (Euclid_dh ctx);
00077   extern void Euclid_dhSetup (Euclid_dh ctx);
00078   extern void Euclid_dhSolve (Euclid_dh ctx, Vec_dh lhs, Vec_dh rhs,
00079                   int *its);
00080   extern void Euclid_dhApply (Euclid_dh ctx, double *lhs, double *rhs);
00081 
00082   extern void Euclid_dhPrintTestData (Euclid_dh ctx, FILE * fp);
00083   extern void Euclid_dhPrintScaling (Euclid_dh ctx, FILE * fp);
00084 
00085   extern void Euclid_dhPrintStatsShort (Euclid_dh ctx, double setup,
00086                     double solve, FILE * fp);
00087 
00088 
00089   extern void Euclid_dhPrintStatsShorter (Euclid_dh ctx, FILE * fp);
00090   /* on-line reporting, for making quick tables */
00091 
00092   extern void Euclid_dhPrintHypreReport (Euclid_dh ctx, FILE * fp);
00093 
00094   extern void Euclid_dhPrintStats (Euclid_dh ctx, FILE * fp);
00095   /* prints same info as Euclid_dhPrintParams(), but also
00096      prints timing information, number of iterations, etc;
00097      may be called after solve is completed.
00098    */
00099 
00100 
00101 /*----------------------------------------------------------------------
00102  * Private data structures
00103  *----------------------------------------------------------------------*/
00104 
00105 #define MAX_OPT_LEN 20
00106 
00107 /* for internal timing */
00108 #define TIMING_BINS 10
00109   enum
00110   { SOLVE_START_T,
00111     TRI_SOLVE_T,        /* triangular solves */
00112     SETUP_T,            /* total setup */
00113     SUB_GRAPH_T,        /* setup SubdomainGraph_dh */
00114     FACTOR_T,           /* factorization */
00115     SOLVE_SETUP_T,      /* setup for solves */
00116     COMPUTE_RHO_T,
00117     /* note: SETUP_T - (FACTOR_T + SUB_GRAPH_T) should be small! */
00118     TOTAL_SOLVE_TEMP_T,
00119     TOTAL_SOLVE_T
00120   };
00121 
00122 /* for statistical reporting */
00123 #define STATS_BINS 10
00124   enum
00125   { NZA_STATS,          /* cumulative nonzeros for all systems solved */
00126     NZF_STATS,          /* cumulative nonzeros for all systems solved */
00127     NZA_USED_STATS,     /* cumulative nonzeros NOT dropped by sparseA */
00128     NZA_RATIO_STATS     /* NZA_USED_STATS/NZA_STATS, over all processors */
00129   };
00130 
00131 
00132 /* primary data structure: this is monstrously long; but it works. 
00133    Users must ensure the following fields are initialized prior
00134    to calling Euclid_dhSetup(): m, n, beg_row, A
00135 */
00136   struct _mpi_interface_dh
00137   {
00138     bool isSetup;
00139 
00140     double rho_init;
00141     double rho_final;
00142     /* Memory allocation for factor; will initially allocate space for 
00143        rho_init*nzA nonzeros; rho_final is computed after factorization,
00144        and is the minimum that rho_init whoulc have been to avoid
00145        memory reallocation; rho_final is a maximum across all processors.
00146      */
00147 
00148     int m;          /* local rows in matrix */
00149     int n;          /* global rows in matrix */
00150     double *rhs;        /* used for debugging; this vector is not owned! */
00151     void *A;            /*  void-pointer to Epetra_CrsMatrix */
00152     Factor_dh F;        /* data structure for the factor, F = L+U-I */
00153     SubdomainGraph_dh sg;
00154 
00155     REAL_DH *scale;     /* row scaling vector */
00156     bool isScaled;      /* set at runtime, turns scaling on or off */
00157 
00158     /* workspace for factorization and triangular solves */
00159     double *work;
00160     double *work2;
00161     int from, to;       /* which local rows to factor or solve */
00162 
00163     /* runtime parameters (mostly) */
00164     char algo_par[MAX_OPT_LEN]; /* parallelization strategy */
00165     char algo_ilu[MAX_OPT_LEN]; /* ILU factorization method */
00166     int level;          /* for ILU(k) */
00167     double droptol;     /* for ILUT */
00168     double sparseTolA;      /* for sparsifying A */
00169     double sparseTolF;      /* for sparsifying the factors */
00170     double pivotMin;        /* if pivots are <= to this value, fix 'em */
00171     double pivotFix;        /* multiplier for adjusting small pivots */
00172     double maxVal;      /* largest abs. value in matrix */
00173 
00174     /* data structures for parallel ilu (pilu) */
00175     SortedList_dh slist;
00176     ExternalRows_dh extRows;
00177 
00178     /* for use with Euclid's internal krylov solvers; */
00179     char krylovMethod[MAX_OPT_LEN];
00180     int maxIts;
00181     double rtol;
00182     double atol;
00183     int its;            /* number of times preconditioner was applied since last call to Setup */
00184     int itsTotal;       /* cululative number of times preconditioner was applied */
00185 
00186     /* internal statistics */
00187     int setupCount;
00188     int logging;
00189     double timing[TIMING_BINS];
00190     double stats[STATS_BINS];
00191     bool timingsWereReduced;
00192     bool printStats;        /* if true, on 2nd and subsequent calls to Setup,
00193                    calls Euclid_dhPrintStatsShorter().  Intent is to
00194                    print out stats for each setup phase when 
00195                    using Euclid, e.g, for nonlinear solves.
00196                  */
00197   };
00198 
00199 #ifdef __cplusplus
00200 }
00201 #endif
00202 #endif              /*  #ifndef EUCLID_MPI_INTERFACE_DH */
 All Classes Files Functions Variables Enumerations Friends