DOLFIN
DOLFIN C++ interface
LUSolver.h
1 // Copyright (C) 2007-2010 Garth N. Wells
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 #ifndef __LU_SOLVER_H
19 #define __LU_SOLVER_H
20 
21 #include <string>
22 #include <memory>
23 #include "GenericLinearSolver.h"
24 #include <dolfin/common/MPI.h>
25 
26 namespace dolfin
27 {
28 
29  // Forward declarations
30  class GenericLinearOperator;
31  class GenericVector;
32 
34 
36  {
37  public:
38 
40  LUSolver(MPI_Comm comm, std::string method= "default");
41 
43  LUSolver(std::string method= "default");
44 
46  LUSolver(MPI_Comm comm,
47  std::shared_ptr<const GenericLinearOperator> A,
48  std::string method="default");
49 
51  LUSolver(std::shared_ptr<const GenericLinearOperator> A,
52  std::string method="default");
53 
55  ~LUSolver();
56 
58  void set_operator(std::shared_ptr<const GenericLinearOperator> A);
59 
61  std::size_t solve(GenericVector& x, const GenericVector& b);
62 
64  std::size_t solve(const GenericLinearOperator& A, GenericVector& x,
65  const GenericVector& b);
66 
69  {
70  Parameters p("lu_solver");
71  p.add("report", true);
72  p.add("verbose", false);
73  p.add("symmetric", false);
74  return p;
75  }
76 
78  std::string parameter_type() const
79  { return "lu_solver"; }
80 
84  {
85  this->parameters.update(parameters);
86  solver->parameters.update(parameters);
87  }
88 
89  private:
90 
91  // Initialize solver
92  void init(MPI_Comm comm, std::string method);
93 
94  // Solver
95  std::shared_ptr<GenericLinearSolver> solver;
96 
97  };
98 }
99 
100 #endif
virtual void update_parameters(const Parameters &parameters)
Definition: LUSolver.h:83
Definition: adapt.h:29
std::string parameter_type() const
Return parameter type: "krylov_solver" or "lu_solver".
Definition: LUSolver.h:78
void add(std::string key)
Definition: Parameters.h:128
static Parameters default_parameters()
Default parameter values.
Definition: LUSolver.h:68
Definition: GenericLinearOperator.h:42
LU solver for the built-in LA backends.
Definition: LUSolver.h:35
LUSolver(MPI_Comm comm, std::string method="default")
Constructor.
Definition: LUSolver.cpp:28
std::size_t solve(GenericVector &x, const GenericVector &b)
Solve linear system Ax = b.
Definition: LUSolver.cpp:67
void set_operator(std::shared_ptr< const GenericLinearOperator > A)
Set operator (matrix)
Definition: LUSolver.cpp:60
Parameters parameters
Parameters.
Definition: Variable.h:74
Definition: Parameters.h:94
~LUSolver()
Destructor.
Definition: LUSolver.cpp:55
This class provides a general solver for linear systems Ax = b.
Definition: GenericLinearSolver.h:37
void update(const Parameters &parameters)
Update parameters with another set of parameters.
Definition: Parameters.cpp:245
This class defines a common interface for vectors.
Definition: GenericVector.h:47