ShyLU  Version of the Day
shylu.h
Go to the documentation of this file.
1 
2 //@HEADER
3 // ************************************************************************
4 //
5 // ShyLU: Hybrid preconditioner package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 
49 #ifndef SHYLU_H
50 #define SHYLU_H
51 
52 // Epetra include
53 #include "Epetra_CrsMatrix.h"
54 #include "Epetra_Map.h"
55 #include "Epetra_MultiVector.h"
56 #include "Epetra_LinearProblem.h"
57 #include "Epetra_SerialComm.h"
58 
59 // Amesos includes
60 #include "Amesos_BaseSolver.h"
61 
62 // Ifpack includes
63 #include "Ifpack.h"
64 #include "Ifpack_Preconditioner.h"
65 
66 // AztecOO includes
67 #include "AztecOO.h"
68 
69 // Isorropia includes
70 #include "Isorropia_EpetraProber.hpp"
71 
72 // Amesos2 includes
73 #ifdef HAVE_SHYLUCORE_AMESOS2
74 #include <Amesos2.hpp>
75 #endif
76 
77 // Tpetra includes
78 #ifdef HAVE_SHYLUCORE_TPETRA
80 #include <Tpetra_CrsMatrix_def.hpp>
81 #endif
82 
83 // Zoltan2 includes
84 #ifdef HAVE_SHYLUCORE_ZOLTAN2
85 #include <Zoltan2_XpetraCrsMatrixAdapter.hpp>
86 #include <Zoltan2_XpetraMultiVectorAdapter.hpp>
87 #include <Zoltan2_PartitioningProblem.hpp>
88 #endif
89 
90 
91 // Shylu includes
92 #include "shylu_symbolic.h"
93 #include "shylu_config.h"
94 #include "shylu_probing_operator.h"
95 #include "shylu_amesos_schur_operator.h"
96 
97 #include <IQRSolver.h>
98 
99 //#include "shylu_debug_manager.hpp"
100 
101 #define MIN(a, b) (((a) < (b)) ? a : b)
102 #define MAX(a, b) (((a) > (b)) ? a : b)
103 
108 typedef struct
109 {
110  int Dnr; // #local rows
111  int Dnc; // #local cols
112  int Snr; // #remote rows
113  int *DRowElems; // local rows
114  int *SRowElems; // remote rows
115  int *DColElems; // Columns in D
116  int *gvals; // O(n) array differentiating local/global
117  // row/col
118  //Epetra_SerialComm *SComm; // Serial comm for block diagonals
119  Teuchos::RCP<Epetra_Map> LDRowMap; // RowMap for block diagonals
120  Teuchos::RCP<Epetra_Map> LGRowMap; // RowMap for G (local)
121  Teuchos::RCP<Epetra_Map> GMap; // Dist Map for G
122 
123  Teuchos::RCP<Epetra_Import> BdImporter;
124  Teuchos::RCP<Epetra_Import> DistImporter;
125  Teuchos::RCP<Epetra_Import> BsImporter;
126  Teuchos::RCP<Epetra_Import> XsImporter;
127  Teuchos::RCP<Epetra_Export> XdExporter;
128  Teuchos::RCP<Epetra_Export> XsExporter;
129 
138 
139  // temp timers
140  //Teuchos::RCP<Teuchos::Time> importExportTime;
141  //Teuchos::RCP<Teuchos::Time> innerIterTime;
142  //Teuchos::RCP<Teuchos::Time> fwdTime;
143  //Teuchos::RCP<Teuchos::Time> amesosSchurTime;
144 
145  //Epetra_CrsMatrix *D; // Actual D Matrix, not reqd for Amesos_KLU
146  // but required for Amesos_Pardiso
147  Teuchos::RCP<IQR::IQRSolver> iqrSolver; // Solver object for IQR func.
148  Teuchos::RCP<Epetra_CrsMatrix> Sbar; // Approx Schur complement
149  Teuchos::RCP<Epetra_CrsGraph> localSbargraph; // graph of local Sbar
150  AztecOO *innersolver; // inner solver
153  Teuchos::RCP<Epetra_LinearProblem> LP2; // Local problem to solve
154  Teuchos::RCP<Epetra_LinearProblem> OrigLP2; // Local problem to solve D
156  Amesos_BaseSolver *dsolver; // Local Subdomain solver
159  int lmax; // May be this is optimizing too much
160  int rmax; // May be this is optimizing too much
161  Teuchos::RCP<Isorropia::Epetra::Prober> guided_prober; // Guided Prober for Sbar
162  int num_compute; // # of times Compute() has been called before
163  // or in otherwords #nonlinear iteration-1
164 } shylu_data;
165 
170 int shylu_factor(Epetra_CrsMatrix *A, shylu_symbolic *ssym, shylu_data *data,
171  shylu_config *config);
172 
177 (
178  Epetra_CrsMatrix *A, // i/p: A matrix
179  shylu_symbolic *ssym, // symbolic structure
180  shylu_data *data, // numeric structure, TODO: Required ?
181  shylu_config *config // i/p: library configuration
182 );
183 
187 int shylu_solve(shylu_symbolic *ssym, shylu_data *data, shylu_config *config,
188  const Epetra_MultiVector& X, Epetra_MultiVector& Y);
189 
196  shylu_symbolic *ssym,
197  Epetra_CrsMatrix *G, Epetra_CrsMatrix *R,
198  Epetra_LinearProblem *LP, Amesos_BaseSolver *solver,
199  Ifpack_Preconditioner *ifSolver, Epetra_CrsMatrix *C,
200  Epetra_Map *localDRowMap);
201 
208  shylu_config *config,
209  shylu_symbolic *ssym, // symbolic structure
210  Epetra_CrsMatrix *G, Epetra_CrsMatrix *R,
211  Epetra_LinearProblem *LP, Amesos_BaseSolver *solver,
212  Ifpack_Preconditioner *ifSolver, Epetra_CrsMatrix *C,
213  Epetra_Map *localDRowMap);
214 
220 (
221  shylu_config *config,
222  shylu_symbolic *ssym, // symbolic structure
223  shylu_data *data, // numeric structure
224  Epetra_Map *localDRowMap
225 );
226 #endif // SHYLU_H
int shylu_solve(shylu_symbolic *ssym, shylu_data *data, shylu_config *config, const Epetra_MultiVector &X, Epetra_MultiVector &Y)
Call solve on multiple RHS.
Teuchos::RCP< Epetra_CrsMatrix > computeSchur_GuidedProbing(shylu_config *config, shylu_symbolic *ssym, shylu_data *data, Epetra_Map *localDRowMap)
Compute an approximate Schur Complement using the option of Guided Probing.
Teuchos::RCP< Epetra_CrsMatrix > computeApproxSchur(shylu_config *config, shylu_symbolic *ssym, Epetra_CrsMatrix *G, Epetra_CrsMatrix *R, Epetra_LinearProblem *LP, Amesos_BaseSolver *solver, Ifpack_Preconditioner *ifSolver, Epetra_CrsMatrix *C, Epetra_Map *localDRowMap)
Compute an approximate Schur Complement (Narrow Sep)
Definition: shylu_schur.cpp:56
Teuchos::RCP< Epetra_CrsMatrix > computeApproxWideSchur(shylu_config *config, shylu_symbolic *ssym, Epetra_CrsMatrix *G, Epetra_CrsMatrix *R, Epetra_LinearProblem *LP, Amesos_BaseSolver *solver, Ifpack_Preconditioner *ifSolver, Epetra_CrsMatrix *C, Epetra_Map *localDRowMap)
Compute an approximate Shur Complete (Wide Sep)
Encapsulates the IQR inexact solver functionality.
int shylu_factor(Epetra_CrsMatrix *A, shylu_symbolic *ssym, shylu_data *data, shylu_config *config)
Main function call into ShylU.
Main data structure holding needed offset and temp variables.
Definition: shylu.h:108
int shylu_symbolic_factor(Epetra_CrsMatrix *A, shylu_symbolic *ssym, shylu_data *data, shylu_config *config)
Call symbolic factorization on matrix.