Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
data/CompositeMatrix.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 IFPEN-CEA
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
19/*!
20 * \file alien/data/CompositeMatrix.h
21 * \brief CompositeMatrix.h
22 */
23
24#pragma once
25
26#include <alien/data/IMatrix.h>
27#include <alien/kernels/composite/CompositeMatrixElement.h>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Alien
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38namespace CompositeKernel
39{
40
41 /*---------------------------------------------------------------------------*/
42 /*---------------------------------------------------------------------------*/
43
44 class Matrix;
45 class MultiMatrixImpl;
46
47 /*---------------------------------------------------------------------------*/
48 /*---------------------------------------------------------------------------*/
49
50} // namespace CompositeKernel
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
54
55/*!
56 * \ingroup data
57 * \brief Composite matrix for heterogenous matrices
58 *
59 * This class allow to handle matrices made of several matrices. It allows to deal with a
60 * single matrix composed of severals submatrices. This is especially usefull to apply
61 * different solvers on a linear system, or to build more efficiently submatrices due to
62 * specific problems implying different matrices data structure.
63 */
64class ALIEN_EXPORT CompositeMatrix : public IMatrix
65{
66 public:
67 //! Type of submatrix element
69
70 public:
71 //! Constructor
73
74 /*!
75 * \brief Constructor
76 * \param[in] nc The number of submatrices
77 */
78 CompositeMatrix(Arccore::Integer nc);
79
80 //! Free resources
81 virtual ~CompositeMatrix() {}
82
83 /*!
84 * \brief Visit method
85 * \param[in] visit Visit matrix method
86 */
87 void visit(ICopyOnWriteMatrix& visit) const;
88
89 /*!
90 * \brief Resize the number of submatrices
91 * \param[in] nc The number of submatrices
92 */
93 void resize(Arccore::Integer nc);
94
95 /*!
96 * \brief Get the number of submatrices
97 * \returns The number of submatrices
98 */
99 Arccore::Integer size() const;
100
101 /*!
102 * \brief Get the row space of the global matrix
103 * \returns The row space
104 */
105 const ISpace& rowSpace() const;
106
107 /*!
108 * \brief Get the col space of the global matrix
109 * \returns The col space
110 */
111 const ISpace& colSpace() const;
112
113 /*!
114 * \brief Get the (i,j) element
115 * \param[in] i The row index of the element
116 * \param[in] j The col index of the element
117 * \returns The (i,j) element
118 */
119 Element composite(Arccore::Integer i, Arccore::Integer j);
120
121 /*!
122 * \brief Get the (i,j) submatrix
123 * \param[in] i The row index of the submatrix
124 * \param[in] j The col index of the submatrix
125 * \returns The (i,j) submatrix
126 */
127 IMatrix& operator()(Arccore::Integer i, Arccore::Integer j);
128
129 /*!
130 * \brief Get the (i,j) submatrix
131 * \param[in] i The row index of the submatrix
132 * \param[in] j The col index of the submatrix
133 * \returns The (i,j) submatrix
134 */
135 const IMatrix& operator()(Arccore::Integer i, Arccore::Integer j) const;
136
137 /*!
138 * \brief Add a feature to the composite matrix
139 * \param[in] feature The feature to add
140 */
141 void setUserFeature(Arccore::String feature);
142
143 /*!
144 * \brief Check if the composite matrix has a feature
145 * \returns Wheteher or not the composite matrix has the feature
146 */
147 bool hasUserFeature(Arccore::String feature) const;
148
149 public:
150 /*!
151 * \brief Get the multimatrix implementation
152 * \returns The multimatrix implementation
153 */
155
156 /*!
157 * \brief Get the multimatrix implementation
158 * \returns The multimatrix implementation
159 */
160 const MultiMatrixImpl* impl() const;
161
162 //! Free the composite matrix
163 void free();
164
165 //! Clear the composite matrix
166 void clear();
167
168 private:
169 //! The multimatrix implementation
170 std::shared_ptr<CompositeKernel::MultiMatrixImpl> m_impl;
171 //! The composite matrix
172 CompositeKernel::Matrix& m_composite_matrix;
173};
174
175/*---------------------------------------------------------------------------*/
176/*---------------------------------------------------------------------------*/
177
178extern ALIEN_EXPORT CompositeMatrix::Element CompositeElement(
179CompositeMatrix& m, Arccore::Integer i, Arccore::Integer j);
180
181/*---------------------------------------------------------------------------*/
182/*---------------------------------------------------------------------------*/
183
184} // namespace Alien
185
186/*---------------------------------------------------------------------------*/
187/*---------------------------------------------------------------------------*/
IMatrix.h.
Composite matrix for heterogenous matrices.
CompositeMatrix(Arccore::Integer nc)
Constructor.
MultiMatrixImpl * impl()
Get the multimatrix implementation.
void free()
Free the composite matrix.
void clear()
Clear the composite matrix.
void setUserFeature(Arccore::String feature)
Add a feature to the composite matrix.
CompositeKernel::MatrixElement Element
Type of submatrix element.
virtual ~CompositeMatrix()
Free resources.
const IMatrix & operator()(Arccore::Integer i, Arccore::Integer j) const
Get the (i,j) submatrix.
IMatrix & operator()(Arccore::Integer i, Arccore::Integer j)
Get the (i,j) submatrix.
bool hasUserFeature(Arccore::String feature) const
Check if the composite matrix has a feature.
IMatrix()
Constructor.
Definition IMatrix.h:54
Interface for algebraic space objects.
Definition ISpace.h:44
Multi matrices representation container.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17