Arcane  v4.1.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
DummyPreconditioner.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/* DummyPreconditioner.h (C) 2000-2026 */
9/* */
10/* Dummy preconditioner using identity matrix. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_ALINA_DUMMYPRECONDITIONER_H
13#define ARCCORE_ALINA_DUMMYPRECONDITIONER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16/*
17 * This file is based on the work on AMGCL library (version march 2026)
18 * which can be found at https://github.com/ddemidov/amgcl.
19 *
20 * Copyright (c) 2012-2022 Denis Demidov <dennis.demidov@gmail.com>
21 * SPDX-License-Identifier: MIT
22 */
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26#include <memory>
27#include "arccore/alina/BuiltinBackend.h"
28#include "arccore/alina/AlinaUtils.h"
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33namespace Arcane::Alina::preconditioner
34{
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
41template <class Backend>
42class DummyPreconditioner
43{
44 public:
45
46 typedef Backend backend_type;
47
48 typedef typename Backend::matrix matrix;
49 typedef typename Backend::vector vector;
50 typedef typename Backend::value_type value_type;
51 typedef typename Backend::col_type col_type;
52 typedef typename Backend::ptr_type ptr_type;
53 typedef typename BuiltinBackend<value_type, col_type, ptr_type>::matrix build_matrix;
54
55 typedef Alina::detail::empty_params params;
56 typedef typename Backend::params backend_params;
57
58 template <class Matrix>
59 DummyPreconditioner(const Matrix& M,
60 const params& = params(),
61 const backend_params& bprm = backend_params())
62 : A(Backend::copy_matrix(std::make_shared<build_matrix>(M), bprm))
63 {
64 }
65
66 DummyPreconditioner(std::shared_ptr<build_matrix> M,
67 const params& = params(),
68 const backend_params& bprm = backend_params())
69 : A(Backend::copy_matrix(M, bprm))
70 {
71 }
72
73 template <class Vec1, class Vec2>
74 void apply(const Vec1& rhs, Vec2&& x) const
75 {
76 backend::copy(rhs, x);
77 }
78
79 std::shared_ptr<matrix> system_matrix_ptr() const
80 {
81 return A;
82 }
83
84 const matrix& system_matrix() const
85 {
86 return *A;
87 }
88
89 size_t bytes() const
90 {
91 return 0;
92 }
93
94 private:
95
96 std::shared_ptr<matrix> A;
97
98 friend std::ostream& operator<<(std::ostream& os, const DummyPreconditioner& p)
99 {
100 os << "identity matrix as preconditioner" << std::endl;
101 os << " unknowns: " << backend::nbRow(p.system_matrix()) << std::endl;
102 os << " nonzeros: " << backend::nonzeros(p.system_matrix()) << std::endl;
103
104 return os;
105 }
106};
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111} // namespace Arcane::Alina::preconditioner
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115#endif
Class to handle empty parameters list.
Definition AlinaUtils.h:90
Matrix class, to be used by user.