DOLFIN
DOLFIN C++ interface
TpetraFactory.h
1 // Copyright (C) 2014 Chris Richardson
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 
19 #ifdef HAS_TRILINOS
20 
21 #ifndef __TPETRA_FACTORY_H
22 #define __TPETRA_FACTORY_H
23 
24 #include <string>
25 #include <memory>
26 #include <dolfin/common/types.h>
27 #include "TpetraVector.h"
28 #include "TensorLayout.h"
29 #include "GenericLinearAlgebraFactory.h"
30 
31 namespace dolfin
32 {
33 
35 
37  {
38  public:
39 
41  virtual ~TpetraFactory() {}
42 
44  std::shared_ptr<GenericMatrix> create_matrix(MPI_Comm comm) const;
45 
47  std::shared_ptr<GenericVector> create_vector(MPI_Comm comm) const;
48 
50  std::shared_ptr<TensorLayout> create_layout(MPI_Comm comm,
51  std::size_t rank) const;
52 
54  std::shared_ptr<GenericLinearOperator>
55  create_linear_operator(MPI_Comm comm) const;
56 
58  std::shared_ptr<GenericLinearSolver>
59  create_lu_solver(MPI_Comm comm, std::string method) const;
60 
62  std::shared_ptr<GenericLinearSolver>
63  create_krylov_solver(MPI_Comm comm,
64  std::string method,
65  std::string preconditioner) const;
66 
68  std::map<std::string, std::string>
69  lu_solver_methods() const;
70 
72  std::map<std::string, std::string>
73  krylov_solver_methods() const;
74 
76  std::map<std::string, std::string> krylov_solver_preconditioners() const;
77 
80  { return factory; }
81 
82  private:
83 
85  TpetraFactory() {}
86  static TpetraFactory factory;
87 
88  };
89 
90 }
91 
92 #endif
93 
94 #endif
std::map< std::string, std::string > krylov_solver_preconditioners() const
Return a list of available preconditioners.
Definition: TpetraFactory.cpp:88
std::shared_ptr< TensorLayout > create_layout(MPI_Comm comm, std::size_t rank) const
Create empty tensor layout.
Definition: TpetraFactory.cpp:46
Definition: adapt.h:29
std::shared_ptr< GenericVector > create_vector(MPI_Comm comm) const
Create empty vector.
Definition: TpetraFactory.cpp:40
std::shared_ptr< GenericLinearOperator > create_linear_operator(MPI_Comm comm) const
Create empty linear operator.
Definition: TpetraFactory.cpp:55
virtual ~TpetraFactory()
Destructor.
Definition: TpetraFactory.h:41
Base class for LinearAlgebra factories.
Definition: GenericLinearAlgebraFactory.h:46
std::shared_ptr< GenericMatrix > create_matrix(MPI_Comm comm) const
Create empty matrix.
Definition: TpetraFactory.cpp:35
static TpetraFactory & instance()
Return singleton instance.
Definition: TpetraFactory.h:79
std::shared_ptr< GenericLinearSolver > create_krylov_solver(MPI_Comm comm, std::string method, std::string preconditioner) const
Create Krylov solver.
Definition: TpetraFactory.cpp:70
std::map< std::string, std::string > krylov_solver_methods() const
Return a list of available Krylov solver methods.
Definition: TpetraFactory.cpp:82
std::map< std::string, std::string > lu_solver_methods() const
Return a list of available LU solver methods.
Definition: TpetraFactory.cpp:77
std::shared_ptr< GenericLinearSolver > create_lu_solver(MPI_Comm comm, std::string method) const
Create LU solver.
Definition: TpetraFactory.cpp:64
Tpetra linear algebra factory.
Definition: TpetraFactory.h:36