DOLFIN
DOLFIN C++ interface
DefaultFactory.h
1 // Copyright (C) 2008-2012 Anders Logg
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 // First added: 2008-05-17
19 // Last changed: 2012-08-21
20 
21 #ifndef __DEFAULT_FACTORY_H
22 #define __DEFAULT_FACTORY_H
23 
24 #include <string>
25 #include <memory>
26 #include <dolfin/common/MPI.h>
27 #include <dolfin/common/types.h>
28 #include "GenericLinearAlgebraFactory.h"
29 
30 namespace dolfin
31 {
32 
34 
36  {
37 
38  class GenericLinearSolver;
39 
40  public:
41 
44 
46  virtual ~DefaultFactory() {}
47 
49  virtual std::shared_ptr<GenericMatrix> create_matrix(MPI_Comm comm) const;
50 
52  virtual std::shared_ptr<GenericVector> create_vector(MPI_Comm comm) const;
53 
55  virtual std::shared_ptr<TensorLayout> create_layout(MPI_Comm comm ,
56  std::size_t rank) const;
57 
59  virtual std::shared_ptr<GenericLinearOperator>
60  create_linear_operator(MPI_Comm comm) const;
61 
63  virtual std::shared_ptr<dolfin::GenericLinearSolver>
64  create_lu_solver(MPI_Comm comm, std::string method) const;
65 
67  virtual std::shared_ptr<dolfin::GenericLinearSolver>
68  create_krylov_solver(MPI_Comm comm, std::string method,
69  std::string preconditioner) const;
70 
72  std::map<std::string, std::string> lu_solver_methods() const;
73 
75  std::map<std::string, std::string> krylov_solver_methods() const;
76 
78  std::map<std::string, std::string> krylov_solver_preconditioners() const;
79 
82 
83  };
84 
85 }
86 
87 #endif
std::map< std::string, std::string > krylov_solver_preconditioners() const
Return a list of available preconditioners.
Definition: DefaultFactory.cpp:80
DefaultFactory()
Constructor.
Definition: DefaultFactory.h:43
Definition: adapt.h:29
virtual std::shared_ptr< GenericVector > create_vector(MPI_Comm comm) const
Create empty vector.
Definition: DefaultFactory.cpp:37
virtual std::shared_ptr< TensorLayout > create_layout(MPI_Comm comm, std::size_t rank) const
Create empty tensor layout.
Definition: DefaultFactory.cpp:43
std::map< std::string, std::string > lu_solver_methods() const
Return a list of available LU solver methods.
Definition: DefaultFactory.cpp:68
Base class for LinearAlgebra factories.
Definition: GenericLinearAlgebraFactory.h:46
virtual std::shared_ptr< dolfin::GenericLinearSolver > create_krylov_solver(MPI_Comm comm, std::string method, std::string preconditioner) const
Create Krylov solver.
Definition: DefaultFactory.cpp:61
virtual ~DefaultFactory()
Destructor.
Definition: DefaultFactory.h:46
This class provides a general solver for linear systems Ax = b.
Definition: GenericLinearSolver.h:37
std::map< std::string, std::string > krylov_solver_methods() const
Return a list of available Krylov solver methods.
Definition: DefaultFactory.cpp:74
static GenericLinearAlgebraFactory & factory()
Return instance of default backend.
Definition: DefaultFactory.cpp:85
virtual std::shared_ptr< GenericMatrix > create_matrix(MPI_Comm comm) const
Create empty matrix.
Definition: DefaultFactory.cpp:32
virtual std::shared_ptr< dolfin::GenericLinearSolver > create_lu_solver(MPI_Comm comm, std::string method) const
Create LU solver.
Definition: DefaultFactory.cpp:55
virtual std::shared_ptr< GenericLinearOperator > create_linear_operator(MPI_Comm comm) const
Create empty linear operator.
Definition: DefaultFactory.cpp:49
Default linear algebra factory based on global parameter "linear_algebra_backend".
Definition: DefaultFactory.h:35