Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
AMGPreconditioner.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{
12 template<typename AlgebraT,
13 typename MatrixT,
14 typename VectorT,
15 typename AMGSolverT>
16
17 class AMGPreconditioner
18 {
19 public:
20 using AlgebraType = AlgebraT;
21 using MatrixType = MatrixT;
22 using VectorType = VectorT;
23 using AMGSolverType = AMGSolverT;
24
25
26 AMGPreconditioner(AlgebraType& alg,
27 MatrixType const& matrix,
28 AMGSolverType* amg_solver,
29 ITraceMng* trace_mng = nullptr
30 )
31 : m_algebra(alg)
32 , m_matrix(matrix)
33 , m_amg_solver(amg_solver)
34 , m_trace_mng(trace_mng)
35 {
36 }
37
38 virtual ~AMGPreconditioner()
39 {
40 end() ;
41 }
42
43 void init()
44 {
45 if(m_amg_solver)
46 {
47 m_amg_solver->init() ;
48 m_amg_solver->init(m_matrix) ;
49 m_amg_solver->start() ;
50 }
51 }
52
53 void end()
54 {
55 if(m_amg_solver)
56 m_amg_solver->end() ;
57 }
58
59 void solve([[maybe_unused]] AlgebraType& alg,
60 VectorType const& y,
61 VectorType& x) const
62 {
63 // x input, y output
64 // solve A.Y=X
65 if(m_amg_solver)
66 {
67 // Solve A11.Y_Cpr = R_Cpr
68 m_amg_solver->solve(y,x);
69 }
70 }
71
72 private :
73 AlgebraType& m_algebra ;
74 MatrixType const& m_matrix ;
75
76 AMGSolverType* m_amg_solver = nullptr;
77
78 ITraceMng* m_trace_mng = nullptr ;
79 };
80
81}
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17