DOLFIN
DOLFIN C++ interface
PETScFactory.h
1 // Copyright (C) 2007 Ola Skavhaug
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // Modified by Anders Logg 2011-2012
19 //
20 // First added: 2007-11-30
21 // Last changed: 2012-08-20
22 
23 #ifdef HAS_PETSC
24 
25 #ifndef __PETSC_FACTORY_H
26 #define __PETSC_FACTORY_H
27 
28 #include <string>
29 #include <memory>
30 #include <dolfin/common/types.h>
31 #include "PETScKrylovSolver.h"
32 #include "PETScLUSolver.h"
33 #include "PETScMatrix.h"
34 #include "PETScVector.h"
35 #include "TensorLayout.h"
36 #include "GenericLinearAlgebraFactory.h"
37 
38 namespace dolfin
39 {
40 
42 
44  {
45  public:
46 
48  virtual ~PETScFactory() {}
49 
51  std::shared_ptr<GenericMatrix> create_matrix(MPI_Comm comm) const;
52 
54  std::shared_ptr<GenericVector> create_vector(MPI_Comm comm) const;
55 
57  std::shared_ptr<TensorLayout> create_layout(MPI_Comm comm,
58  std::size_t rank) const;
59 
61  std::shared_ptr<GenericLinearOperator>
62  create_linear_operator(MPI_Comm comm) const;
63 
65  std::shared_ptr<GenericLinearSolver>
66  create_lu_solver(MPI_Comm comm, std::string method) const;
67 
69  std::shared_ptr<GenericLinearSolver>
70  create_krylov_solver(MPI_Comm comm,
71  std::string method,
72  std::string preconditioner) const;
73 
75  std::map<std::string, std::string> lu_solver_methods() const;
76 
78  std::map<std::string, std::string> krylov_solver_methods() const;
79 
81  std::map<std::string, std::string> krylov_solver_preconditioners() const;
82 
85  { return factory; }
86 
87  private:
88 
90  PETScFactory() {}
91  static PETScFactory factory;
92 
93  };
94 
95 }
96 
97 #endif
98 
99 #endif
Definition: adapt.h:29
std::map< std::string, std::string > krylov_solver_methods() const
Return a list of available Krylov solver methods.
Definition: PETScFactory.cpp:82
std::shared_ptr< GenericVector > create_vector(MPI_Comm comm) const
Create empty vector.
Definition: PETScFactory.cpp:43
std::shared_ptr< GenericLinearSolver > create_krylov_solver(MPI_Comm comm, std::string method, std::string preconditioner) const
Create Krylov solver.
Definition: PETScFactory.cpp:70
std::map< std::string, std::string > krylov_solver_preconditioners() const
Return a list of available preconditioners.
Definition: PETScFactory.cpp:88
virtual ~PETScFactory()
Destructor.
Definition: PETScFactory.h:48
Base class for LinearAlgebra factories.
Definition: GenericLinearAlgebraFactory.h:46
std::shared_ptr< TensorLayout > create_layout(MPI_Comm comm, std::size_t rank) const
Create empty tensor layout.
Definition: PETScFactory.cpp:49
std::shared_ptr< GenericLinearOperator > create_linear_operator(MPI_Comm comm) const
Create empty linear operator.
Definition: PETScFactory.cpp:58
std::map< std::string, std::string > lu_solver_methods() const
Return a list of available LU solver methods.
Definition: PETScFactory.cpp:77
std::shared_ptr< GenericLinearSolver > create_lu_solver(MPI_Comm comm, std::string method) const
Create LU solver.
Definition: PETScFactory.cpp:64
std::shared_ptr< GenericMatrix > create_matrix(MPI_Comm comm) const
Create empty matrix.
Definition: PETScFactory.cpp:38
static PETScFactory & instance()
Return singleton instance.
Definition: PETScFactory.h:84
PETSc linear algebra factory.
Definition: PETScFactory.h:43