Allium  0.1.0
linear_solver.hpp
1 // Copyright 2020 Hannah Rittich
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef ALLIUM_LA_LINEAR_SOLVER_HPP
16 #define ALLIUM_LA_LINEAR_SOLVER_HPP
17 
18 #include <memory>
19 #include "vector_storage.hpp"
20 #include "linear_operator.hpp"
21 
22 namespace allium {
23 
32  enum class InitialGuess {
33  NOT_PROVIDED,
34  PROVIDED
35  };
36 
40  template <typename V>
42  {
43  public:
44  virtual ~LinearSolver() {}
45  static_assert(std::is_base_of<VectorStorage<typename V::Number>, V>::value);
46 
47  using Matrix = LinearOperator<V>;
48  using Vector = V;
49 
50  virtual void setup(std::shared_ptr<Matrix> mat) = 0;
51  virtual void solve(Vector& solution,
52  const Vector& rhs,
53  InitialGuess initial_guess = InitialGuess::NOT_PROVIDED) = 0;
54  };
55 
57 
58 }
59 
60 #endif
Linear operator for the use in iterative linear solvers.
Definition: linear_operator.hpp:29
Linear solver interface.
Definition: linear_solver.hpp:42
Abstract base class for any vector storage.
Definition: vector_storage.hpp:41
InitialGuess
Behavior for the initial guess.
Definition: linear_solver.hpp:32
@ NOT_PROVIDED
Initialize with zero.
@ PROVIDED
Use the value from the solution vector.