preconditioner.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 // Local Includes
21 #include "libmesh/preconditioner.h"
22 #include "libmesh/auto_ptr.h"
28 
29 namespace libMesh
30 {
31 
32 template <typename T>
33 inline
35  ParallelObject(comm_in),
36  _matrix(nullptr),
37  _preconditioner_type (ILU_PRECOND),
38  _is_initialized (false)
39 {
40 }
41 
42 
43 
44 template <typename T>
45 std::unique_ptr<Preconditioner<T>>
47  const SolverPackage solver_package)
48 {
49  // Avoid unused parameter warnings when no solver packages are enabled.
50  libmesh_ignore(comm);
51 
52  // Build and return the appropriate Preconditioner object.
53  switch (solver_package)
54  {
55 
56 #ifdef LIBMESH_HAVE_PETSC
57  case PETSC_SOLVERS:
58  {
59  return libmesh_make_unique<PetscPreconditioner<T>>(comm);
60  }
61 #endif
62 
63 #ifdef LIBMESH_TRILINOS_HAVE_EPETRA
64  case TRILINOS_SOLVERS:
65  return libmesh_make_unique<TrilinosPreconditioner<T>>(comm);
66 #endif
67 
68 #ifdef LIBMESH_HAVE_EIGEN
69  case EIGEN_SOLVERS:
70  return libmesh_make_unique<EigenPreconditioner<T>>(comm);
71 #endif
72 
73  default:
74  libmesh_error_msg("ERROR: Unrecognized solver package: " << solver_package);
75  }
76 }
77 
78 
79 
80 #ifdef LIBMESH_ENABLE_DEPRECATED
81 
82 template <typename T>
85  const SolverPackage solver_package)
86 {
87  // You should be calling build_preconditioner() instead.
88  libmesh_deprecated();
89 
90  // Call the non-deprecated method
91  std::unique_ptr<Preconditioner<T>> ptr =
92  Preconditioner<T>::build_preconditioner(comm, solver_package);
93 
94  // Vaya con dios
95  return ptr.release();
96 }
97 
98 #endif
99 
100 
101 //------------------------------------------------------------------
102 // Explicit instantiations
103 template class Preconditioner<Number>;
104 
105 } // namespace libMesh
EIGEN_SOLVERS
Definition: libmesh.C:246
TRILINOS_SOLVERS
Definition: libmesh.C:244
void libmesh_ignore(const Args &...)
Preconditioner(const libMesh::Parallel::Communicator &comm)
An object whose state is distributed along a set of processors.