Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
DiagPreconditioner.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7
8#pragma once
9
10namespace Alien
11{
12template <typename AlgebraT>
13class DiagPreconditioner
14{
15 public:
16 // clang-format off
17 typedef AlgebraT AlgebraType ;
18 typedef typename AlgebraType::Matrix MatrixType;
19 typedef typename AlgebraType::Vector VectorType;
20 typedef typename MatrixType::ValueType ValueType;
21 // clang-format on
22
23 DiagPreconditioner(AlgebraType& algebra,
24 MatrixType const& matrix)
25 : m_algebra(algebra)
26 , m_matrix(matrix)
27 {}
28
29 virtual ~DiagPreconditioner(){};
30
32 void init()
33 {
34 m_algebra.allocate(AlgebraType::resource(m_matrix), m_inv_diag);
35 m_algebra.assign(m_inv_diag, 1.);
36 m_algebra.computeInvDiag(m_matrix, m_inv_diag);
37 }
38
39 void update()
40 {
41 // update value from m_matrix
42 }
43
44 template <typename AlgebraType>
45 void solve(AlgebraType& algebra,
46 VectorType const& x,
47 VectorType& y) const
48 {
49 algebra.pointwiseMult(m_inv_diag, x, y);
50 }
51
52 private:
53 AlgebraType& m_algebra;
54 MatrixType const& m_matrix;
55 VectorType m_inv_diag;
56};
57
58} // namespace Alien
void init()
operator preparation
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17