Debian Codegraph @

packages/shylu/shylu_dd/core/src/epetra/shylu.cpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // ShyLU: Scalable Hybrid LU Preconditioner and Solver
4 //
5 // Copyright 2011 NTESS and the ShyLU contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 /** \file shylu.cpp
11
12 \brief Factors and solves a sparse matrix using LU factorization.
13
14 \author Siva Rajamanickam
15
16 This file is NOT yet complete. This is a place holder for the method
17 that iterates only on the Schur complement. Lot of TODOs.
18
19
20 */
21
22 #include <assert.h>
23 #include <iostream>
24 #include <sstream>
25
26 /* This define will make S block diagonal, To make this happen even some
27 zero columns/rows of C and R will be stored.
28 */
29 #define BLOCK_DIAGONAL_Si
30
31 #include "shylu_util.h"
32
33 // Epetra includes
34 #ifdef HAVE_SHYLU_DDCORE_MPI
35 # include "Epetra_MpiComm.h"
36 #endif // HAVE_SHYLU_DDCORE_MPI
37 #include "Epetra_SerialComm.h"
38 #include "Epetra_Time.h"
39 #include "Epetra_CrsMatrix.h"
40 #include "Epetra_Map.h"
41 #include "Epetra_MultiVector.h"
42 #include "Epetra_LinearProblem.h"
43 #include "Epetra_Import.h"
44 #include "Epetra_Export.h"
45
46 // Teuchos includes
47 #include "Teuchos_GlobalMPISession.hpp"
48 #include "Teuchos_XMLParameterListHelpers.hpp"
49 #include "Teuchos_LAPACK.hpp"
50
51 // EpetraExt includes
52 #include "EpetraExt_RowMatrixOut.h"
53 #include "EpetraExt_MultiVectorOut.h"
54 #include "EpetraExt_CrsMatrixIn.h"
55
56 // Amesos includes
57 #include "Amesos.h"
58 #include "Amesos_BaseSolver.h"
59
60
61 // Amesos2 includes
62 #ifdef HAVE_SHYLU_DDCORE_AMESOS2
63 #include <Amesos2.hpp>
64 #endif
65
66 // Tpetra includes
67 #ifdef HAVE_SHYLU_DDCORE_TPETRA
68 #include <Tpetra_CrsMatrix_decl.hpp>
69 #include <Tpetra_CrsMatrix_def.hpp>
70 #endif
71
72 #include "shylu.h"
73
74 int main(int argc, char *argv[])
75 {
76 #ifdef HAVE_SHYLU_DDCORE_MPI
77 Teuchos::GlobalMPISession mpiSession(&argc, &argv, 0);
78 Epetra_MpiComm Comm(MPI_COMM_WORLD);
79 #else
80 Epetra_SerialComm Comm;
81 #endif
82 int nProcs, myPID ;
83 Teuchos::ParameterList pLUList ; // ParaLU parameters
84 Teuchos::ParameterList isoList ; // Isorropia parameters
85 string ipFileName = "ShyLU.xml"; // TODO : Accept as i/p
86 int sym = 1; // TODO: Need rectangular factorization for unsymmetric case
87
88 nProcs = mpiSession.getNProc();
89 myPID = Comm.MyPID();
90
91 if (myPID == 0)
92 {
93 cout <<"Parallel execution: nProcs="<< nProcs << std::endl;
94 }
95
96 // =================== Read input xml file =============================
97 Teuchos::updateParametersFromXmlFile(ipFileName, &pLUList);
98 isoList = pLUList.sublist("Isorropia Input");
99 // Get matrix market file name
100 string MMFileName = Teuchos::getParameter<string>(pLUList, "mm_file");
101
102 if (myPID == 0)
103 {
104 cout << "Input :" << std::endl;
105 cout << "ParaLU params " << std::endl;
106 pLUList.print(std::cout, 2, true, true);
107 cout << "Matrix market file name: " << MMFileName << std::endl;
108 }
109
110
111
112 // ==================== Read input Matrix ==============================
113 Epetra_CrsMatrix *tempA;
114 EpetraExt::MatrixMarketFileToCrsMatrix(MMFileName.c_str(), Comm, tempA);
115
116 Epetra_CrsMatrix *A = balanceAndRedistribute(tempA, isoList);
117 delete tempA;
118
119 Epetra_MultiVector *localS;
120 Epetra_MultiVector *CMV;
121 Epetra_LinearProblem *LP;
122 Amesos_BaseSolver *Solver;
123 int Dnr, Snr;
124 int *DRowElems, *SRowElems, *piv;
125
126 shylu_factor(A, sym, localS, LP, Solver, Dnr, DRowElems, Snr, SRowElems,
127 piv, CMV);
128
129 delete localS;
130 delete LP;
131 delete Solver;
132 delete[] DRowElems;
133 delete[] SRowElems;
134 delete[] piv;
135 delete CMV;
136 }