IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
Euclid_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 EUCLID_MPI_INTERFACE_DH
44 #define EUCLID_MPI_INTERFACE_DH
45 
46 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
47 #ifdef __GNUC__
48 #warning "The Ifpack package is deprecated"
49 #endif
50 #endif
51 
52 #define DEFAULT_DROP_TOL 0.01
53 
54 #include "euclid_common.h"
55 
56 /*======================================================================
57  * Naming convention: functions ending in _mpi are located in
58  * src/Euclid_mpi.c; those ending in _seq are in src/Euclid_seq.c;
59  * most others should be in Euclid_all.c.
60  *
61  * Exceptions: all Apply() (triangular solves) are in src/Euclid_apply.c;
62  * except for the Apply for MPI PILU, which is called
63  * Mat_dhSolve, and is in src/Mat_dh.c
64  *
65  * Users should only need to call functions with names of the form
66  * Euclid_dhXXX (public functions).
67  *
68  * Some of the functions whose names are of the form XXX_private_XXX,
69  * as could easily be static functions; similarly, the enums and
70  * structs do need to be public. They are, primarily, for ease in
71  * debugging and ready reference.
72  *
73  * Exceptions: the apply_private functions aren't listed here --- they're
74  * all static in src/Euclid_apply.c
75  *======================================================================*/
76 #ifdef __cplusplus
77 extern "C"
78 {
79 #endif
80 
81  extern void Euclid_dhCreate (Euclid_dh * ctxOUT);
82  extern void Euclid_dhDestroy (Euclid_dh ctx);
83  extern void Euclid_dhSetup (Euclid_dh ctx);
84  extern void Euclid_dhSolve (Euclid_dh ctx, Vec_dh lhs, Vec_dh rhs,
85  int *its);
86  extern void Euclid_dhApply (Euclid_dh ctx, double *lhs, double *rhs);
87 
88  extern void Euclid_dhPrintTestData (Euclid_dh ctx, FILE * fp);
89  extern void Euclid_dhPrintScaling (Euclid_dh ctx, FILE * fp);
90 
91  extern void Euclid_dhPrintStatsShort (Euclid_dh ctx, double setup,
92  double solve, FILE * fp);
93 
94 
95  extern void Euclid_dhPrintStatsShorter (Euclid_dh ctx, FILE * fp);
96  /* on-line reporting, for making quick tables */
97 
98  extern void Euclid_dhPrintHypreReport (Euclid_dh ctx, FILE * fp);
99 
100  extern void Euclid_dhPrintStats (Euclid_dh ctx, FILE * fp);
101  /* prints same info as Euclid_dhPrintParams(), but also
102  prints timing information, number of iterations, etc;
103  may be called after solve is completed.
104  */
105 
106 
107 /*----------------------------------------------------------------------
108  * Private data structures
109  *----------------------------------------------------------------------*/
110 
111 #define MAX_OPT_LEN 20
112 
113 /* for internal timing */
114 #define TIMING_BINS 10
115  enum
116  { SOLVE_START_T,
117  TRI_SOLVE_T, /* triangular solves */
118  SETUP_T, /* total setup */
119  SUB_GRAPH_T, /* setup SubdomainGraph_dh */
120  FACTOR_T, /* factorization */
121  SOLVE_SETUP_T, /* setup for solves */
122  COMPUTE_RHO_T,
123  /* note: SETUP_T - (FACTOR_T + SUB_GRAPH_T) should be small! */
124  TOTAL_SOLVE_TEMP_T,
125  TOTAL_SOLVE_T
126  };
127 
128 /* for statistical reporting */
129 #define STATS_BINS 10
130  enum
131  { NZA_STATS, /* cumulative nonzeros for all systems solved */
132  NZF_STATS, /* cumulative nonzeros for all systems solved */
133  NZA_USED_STATS, /* cumulative nonzeros NOT dropped by sparseA */
134  NZA_RATIO_STATS /* NZA_USED_STATS/NZA_STATS, over all processors */
135  };
136 
137 
138 /* primary data structure: this is monstrously long; but it works.
139  Users must ensure the following fields are initialized prior
140  to calling Euclid_dhSetup(): m, n, beg_row, A
141 */
143  {
144  bool isSetup;
145 
146  double rho_init;
147  double rho_final;
148  /* Memory allocation for factor; will initially allocate space for
149  rho_init*nzA nonzeros; rho_final is computed after factorization,
150  and is the minimum that rho_init whoulc have been to avoid
151  memory reallocation; rho_final is a maximum across all processors.
152  */
153 
154  int m; /* local rows in matrix */
155  int n; /* global rows in matrix */
156  double *rhs; /* used for debugging; this vector is not owned! */
157  void *A; /* void-pointer to Epetra_CrsMatrix */
158  Factor_dh F; /* data structure for the factor, F = L+U-I */
160 
161  REAL_DH *scale; /* row scaling vector */
162  bool isScaled; /* set at runtime, turns scaling on or off */
163 
164  /* workspace for factorization and triangular solves */
165  double *work;
166  double *work2;
167  int from, to; /* which local rows to factor or solve */
168 
169  /* runtime parameters (mostly) */
170  char algo_par[MAX_OPT_LEN]; /* parallelization strategy */
171  char algo_ilu[MAX_OPT_LEN]; /* ILU factorization method */
172  int level; /* for ILU(k) */
173  double droptol; /* for ILUT */
174  double sparseTolA; /* for sparsifying A */
175  double sparseTolF; /* for sparsifying the factors */
176  double pivotMin; /* if pivots are <= to this value, fix 'em */
177  double pivotFix; /* multiplier for adjusting small pivots */
178  double maxVal; /* largest abs. value in matrix */
179 
180  /* data structures for parallel ilu (pilu) */
181  SortedList_dh slist;
182  ExternalRows_dh extRows;
183 
184  /* for use with Euclid's internal krylov solvers; */
185  char krylovMethod[MAX_OPT_LEN];
186  int maxIts;
187  double rtol;
188  double atol;
189  int its; /* number of times preconditioner was applied since last call to Setup */
190  int itsTotal; /* cululative number of times preconditioner was applied */
191 
192  /* internal statistics */
193  int setupCount;
194  int logging;
195  double timing[TIMING_BINS];
196  double stats[STATS_BINS];
197  bool timingsWereReduced;
198  bool printStats; /* if true, on 2nd and subsequent calls to Setup,
199  calls Euclid_dhPrintStatsShorter(). Intent is to
200  print out stats for each setup phase when
201  using Euclid, e.g, for nonlinear solves.
202  */
203  };
204 
205 #ifdef __cplusplus
206 }
207 #endif
208 #endif /* #ifndef EUCLID_MPI_INTERFACE_DH */
Definition: Vec_dh.h:58