Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test/PreconditionerFactory_LL/cxx_main.cpp
Go to the documentation of this file.
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 #ifdef NDEBUG
44 #undef NDEBUG
45 #endif
46 
47 #include "Ifpack_ConfigDefs.h"
48 
49 #ifdef HAVE_MPI
50 #include "Epetra_MpiComm.h"
51 #else
52 #include "Epetra_SerialComm.h"
53 #endif
54 #include "Epetra_CrsMatrix.h"
55 #include "Epetra_Vector.h"
56 #include "Epetra_LinearProblem.h"
57 #include "Epetra_Map.h"
58 #include "Galeri_Maps.h"
59 #include "Galeri_CrsMatrices.h"
60  #include "Teuchos_ParameterList.hpp"
61 #include "Teuchos_RefCountPtr.hpp"
62 #include "Ifpack_Preconditioner.h"
63 #include "Ifpack.h"
64 #include "AztecOO.h"
65 #ifdef HAVE_IFPACK_AMESOS
66 #include "Amesos_TestRowMatrix.h"
67 #endif
68 
69 
70 
71 
72 // =======================================================================
73 // GOAL: test that the names in the factory do not change. This test
74 // will not solve any linear system.
75 //
76 int main(int argc, char *argv[])
77 {
78  using std::cout;
79  using std::endl;
80 
81 #ifdef HAVE_MPI
82  MPI_Init(&argc,&argv);
83  Epetra_MpiComm Comm( MPI_COMM_WORLD );
84 #else
85  Epetra_SerialComm Comm;
86 #endif
87 
88  Teuchos::ParameterList GaleriList;
89  const int n = 9;
90  GaleriList.set("n", n);
91  Teuchos::RefCountPtr<Epetra_Map> Map = Teuchos::rcp( Galeri::CreateMap64("Linear", Comm, GaleriList) );
92  Teuchos::RefCountPtr<Epetra_CrsMatrix> A = Teuchos::rcp( Galeri::CreateCrsMatrix("Minij", &*Map, GaleriList) );
93 
94  Ifpack Factory;
95  Teuchos::RefCountPtr<Ifpack_Preconditioner> Prec;
96 
97  Prec = Teuchos::rcp( Factory.Create("point relaxation", &*A) );
98  assert (Prec != Teuchos::null);
99  IFPACK_CHK_ERR(Prec->Initialize());
100  IFPACK_CHK_ERR(Prec->Compute());
101  cout << *Prec;
102 
103  Prec = Teuchos::rcp( Factory.Create("point relaxation stand-alone", &*A) );
104  assert (Prec != Teuchos::null);
105  IFPACK_CHK_ERR(Prec->Initialize());
106  IFPACK_CHK_ERR(Prec->Compute());
107  cout << *Prec;
108 
109  Prec = Teuchos::rcp( Factory.Create("block relaxation", &*A) );
110  assert (Prec != Teuchos::null);
111  IFPACK_CHK_ERR(Prec->Initialize());
112  IFPACK_CHK_ERR(Prec->Compute());
113  cout << *Prec;
114 
115  Prec = Teuchos::rcp( Factory.Create("block relaxation stand-alone", &*A) );
116  assert (Prec != Teuchos::null);
117  IFPACK_CHK_ERR(Prec->Initialize());
118  IFPACK_CHK_ERR(Prec->Compute());
119  cout << *Prec;
120 
121  Prec = Teuchos::rcp( Factory.Create("IC", &*A) );
122  assert (Prec != Teuchos::null);
123  IFPACK_CHK_ERR(Prec->Initialize());
124  IFPACK_CHK_ERR(Prec->Compute());
125  cout << *Prec;
126 
127  Prec = Teuchos::rcp( Factory.Create("ICT", &*A) );
128  assert (Prec != Teuchos::null);
129  IFPACK_CHK_ERR(Prec->Initialize());
130  IFPACK_CHK_ERR(Prec->Compute());
131  cout << *Prec;
132 
133  Prec = Teuchos::rcp( Factory.Create("ILU", &*A) );
134  assert (Prec != Teuchos::null);
135  IFPACK_CHK_ERR(Prec->Initialize());
136  IFPACK_CHK_ERR(Prec->Compute());
137  cout << *Prec;
138 
139  Prec = Teuchos::rcp( Factory.Create("ILUT", &*A) );
140  assert (Prec != Teuchos::null);
141  IFPACK_CHK_ERR(Prec->Initialize());
142  IFPACK_CHK_ERR(Prec->Compute());
143  cout << *Prec;
144 
145  Prec = Teuchos::rcp( Factory.Create("IC stand-alone", &*A) );
146  assert (Prec != Teuchos::null);
147  IFPACK_CHK_ERR(Prec->Initialize());
148  IFPACK_CHK_ERR(Prec->Compute());
149  cout << *Prec;
150 
151  Prec = Teuchos::rcp( Factory.Create("ICT stand-alone", &*A) );
152  assert (Prec != Teuchos::null);
153  IFPACK_CHK_ERR(Prec->Initialize());
154  IFPACK_CHK_ERR(Prec->Compute());
155  cout << *Prec;
156 
157  Prec = Teuchos::rcp( Factory.Create("ILU stand-alone", &*A) );
158  assert (Prec != Teuchos::null);
159  IFPACK_CHK_ERR(Prec->Initialize());
160  IFPACK_CHK_ERR(Prec->Compute());
161  cout << *Prec;
162 
163  Prec = Teuchos::rcp( Factory.Create("ILUT stand-alone", &*A) );
164  assert (Prec != Teuchos::null);
165  IFPACK_CHK_ERR(Prec->Initialize());
166  IFPACK_CHK_ERR(Prec->Compute());
167  cout << *Prec;
168 
169 #ifdef HAVE_IFPACK_AMESOS
170  Prec = Teuchos::rcp( Factory.Create("Amesos", &*A) );
171  assert (Prec != Teuchos::null);
172  IFPACK_CHK_ERR(Prec->Initialize());
173  IFPACK_CHK_ERR(Prec->Compute());
174  cout << *Prec;
175 
176  Prec = Teuchos::rcp( Factory.Create("Amesos stand-alone", &*A) );
177  assert (Prec != Teuchos::null);
178  IFPACK_CHK_ERR(Prec->Initialize());
179  IFPACK_CHK_ERR(Prec->Compute());
180  cout << *Prec;
181 #endif
182 
183  Prec = Teuchos::rcp( Factory.Create("Chebyshev", &*A) );
184  assert (Prec != Teuchos::null);
185  IFPACK_CHK_ERR(Prec->Initialize());
186  IFPACK_CHK_ERR(Prec->Compute());
187  cout << *Prec;
188 
189  Prec = Teuchos::rcp( Factory.Create("Polynomial", &*A) );
190  assert (Prec != Teuchos::null);
191  IFPACK_CHK_ERR(Prec->Initialize());
192  IFPACK_CHK_ERR(Prec->Compute());
193  cout << *Prec;
194 
195  Prec = Teuchos::rcp( Factory.Create("Krylov", &*A) );
196  assert (Prec != Teuchos::null);
197  IFPACK_CHK_ERR(Prec->Initialize());
198  IFPACK_CHK_ERR(Prec->Compute());
199  cout << *Prec;
200 
201 
202 
203 
204 
205 #if defined (HAVE_IFPACK_SUPPORTGRAPH) && defined (HAVE_IFPACK_AMESOS)
206  Prec = Teuchos::rcp( Factory.Create("MSF Amesos", &*A) );
207  assert (Prec !=Teuchos::null);
208  IFPACK_CHK_ERR(Prec->Initialize());
209  IFPACK_CHK_ERR(Prec->Compute());
210  cout << *Prec;
211 
212 
213 #endif
214 
215 
216 
217 #ifdef HAVE_IFPACK_SUPPORTGRAPH
218  Prec = Teuchos::rcp( Factory.Create("MSF IC", &*A) );
219  assert (Prec != Teuchos::null);
220  IFPACK_CHK_ERR(Prec->Initialize());
221  IFPACK_CHK_ERR(Prec->Compute());
222  cout << *Prec;
223 
224 
225 #endif
226 
227  if (Comm.MyPID() == 0)
228  cout << "Test `PrecondititonerFactory_LL.exe' passed!" << endl;
229 
230 
231 
232 #ifdef HAVE_MPI
233  MPI_Finalize() ;
234 #endif
235 
236  return(EXIT_SUCCESS);
237 }
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
int MyPID() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
int main(int argc, char *argv[])
Ifpack: a function class to define Ifpack preconditioners.
Definition: Ifpack.h:144
static Ifpack_Preconditioner * Create(EPrecType PrecType, Epetra_RowMatrix *Matrix, const int overlap=0, bool overrideSerialDefault=false)
Creates an instance of Ifpack_Preconditioner given the enum value of the preconditioner type (can not...
Definition: Ifpack.cpp:253
#define IFPACK_CHK_ERR(ifpack_err)
int n