Debian Codegraph @

include/deal.II/multigrid/mg_transfer_matrix_free.templates.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2022 - 2025 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // Part of the source code is dual licensed under Apache-2.0 WITH
9 // LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10 // governing the source code and code contributions can be found in
11 // LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12 //
13 // ------------------------------------------------------------------------
14
15 #ifndef dealii_mg_transfer_matrix_free_templates_h
16 #define dealii_mg_transfer_matrix_free_templates_h
17
18 #include <deal.II/base/config.h>
19
20 #include <deal.II/multigrid/mg_transfer_matrix_free.h>
21
22 #include <type_traits>
23
24
25 DEAL_II_NAMESPACE_OPEN
26
27 template <int dim, typename Number, typename TransferType>
28 void
29 MGTransferBlockMatrixFreeBase<dim, Number, TransferType>::prolongate(
30 const unsigned int to_level,
31 LinearAlgebra::distributed::BlockVector<Number> &dst,
32 const LinearAlgebra::distributed::BlockVector<Number> &src) const
33 {
34 const unsigned int n_blocks = src.n_blocks();
35 AssertDimension(dst.n_blocks(), n_blocks);
36
37 for (unsigned int b = 0; b < n_blocks; ++b)
38 {
39 const unsigned int data_block = same_for_all ? 0 : b;
40 get_matrix_free_transfer(data_block)
41 .prolongate(to_level, dst.block(b), src.block(b));
42 }
43 }
44
45
46
47 template <int dim, typename Number, typename TransferType>
48 void
49 MGTransferBlockMatrixFreeBase<dim, Number, TransferType>::prolongate_and_add(
50 const unsigned int to_level,
51 LinearAlgebra::distributed::BlockVector<Number> &dst,
52 const LinearAlgebra::distributed::BlockVector<Number> &src) const
53 {
54 const unsigned int n_blocks = src.n_blocks();
55 AssertDimension(dst.n_blocks(), n_blocks);
56
57 for (unsigned int b = 0; b < n_blocks; ++b)
58 {
59 const unsigned int data_block = same_for_all ? 0 : b;
60 get_matrix_free_transfer(data_block)
61 .prolongate_and_add(to_level, dst.block(b), src.block(b));
62 }
63 }
64
65
66
67 template <int dim, typename Number, typename TransferType>
68 void
69 MGTransferBlockMatrixFreeBase<dim, Number, TransferType>::restrict_and_add(
70 const unsigned int from_level,
71 LinearAlgebra::distributed::BlockVector<Number> &dst,
72 const LinearAlgebra::distributed::BlockVector<Number> &src) const
73 {
74 const unsigned int n_blocks = src.n_blocks();
75 AssertDimension(dst.n_blocks(), n_blocks);
76
77 for (unsigned int b = 0; b < n_blocks; ++b)
78 {
79 const unsigned int data_block = same_for_all ? 0 : b;
80 get_matrix_free_transfer(data_block)
81 .restrict_and_add(from_level, dst.block(b), src.block(b));
82 }
83 }
84
85 DEAL_II_NAMESPACE_CLOSE
86
87 #endif