libMesh
preconditioner.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 // C++ includes
21 
22 // Local Includes
23 #include "libmesh/auto_ptr.h"
24 #include "libmesh/preconditioner.h"
25 #include "libmesh/eigen_preconditioner.h"
26 #include "libmesh/petsc_preconditioner.h"
27 #include "libmesh/trilinos_preconditioner.h"
28 
29 
30 
31 namespace libMesh
32 {
33 
34 //------------------------------------------------------------------
35 // Preconditioner members
36 template <typename T>
37 Preconditioner<T> *
39  const SolverPackage solver_package)
40 {
41  // Avoid unused parameter warnings when no solver packages are enabled.
42  libmesh_ignore(comm);
43 
44  // Build the appropriate solver
45  switch (solver_package)
46  {
47 
48 #ifdef LIBMESH_HAVE_PETSC
49  case PETSC_SOLVERS:
50  {
51  return new PetscPreconditioner<T>(comm);
52  }
53 #endif
54 
55 #ifdef LIBMESH_TRILINOS_HAVE_EPETRA
56  case TRILINOS_SOLVERS:
57  return new TrilinosPreconditioner<T>(comm);
58 #endif
59 
60 #ifdef LIBMESH_HAVE_EIGEN
61  case EIGEN_SOLVERS:
62  return new EigenPreconditioner<T>(comm);
63 #endif
64 
65  default:
66  libmesh_error_msg("ERROR: Unrecognized solver package: " << solver_package);
67  }
68 
69  return libmesh_nullptr;
70 }
71 
72 
73 
74 //------------------------------------------------------------------
75 // Explicit instantiations
76 template class Preconditioner<Number>;
77 
78 } // namespace libMesh
Encapsulates the MPI_Comm object.
Definition: parallel.h:657
This class provides an interface to the suite of preconditioners available from PETSc.
SolverPackage
Defines an enum for various linear solver packages.
const class libmesh_nullptr_t libmesh_nullptr
The libMesh namespace provides an interface to certain functionality in the library.
This class provides an interface to the suite of preconditioners available from Trilinos.
void libmesh_ignore(const T &)
This class provides an interface to the suite of preconditioners available from Eigen.
static Preconditioner< T > * build(const libMesh::Parallel::Communicator &comm LIBMESH_CAN_DEFAULT_TO_COMMWORLD, const SolverPackage solver_package=libMesh::default_solver_package())
Builds a Preconditioner using the linear solver package specified by solver_package.