Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
MatrixData.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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#pragma once
8
9#include <memory>
10
11#include <arccore/base/String.h>
12
13#include <alien/data/IMatrix.h>
14
15#include <alien/move/AlienMoveSemanticPrecomp.h>
16#include <arccore/message_passing/MessagePassingGlobal.h>
17
18/*---------------------------------------------------------------------------*/
19/*---------------------------------------------------------------------------*/
20
21namespace Alien
22{
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27class Block;
28class VBlock;
29class Space;
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
35namespace Move
36{
37
38 //! Algebraic Matrix with internal multi-representation object.
39 class ALIEN_MOVESEMANTIC_EXPORT MatrixData : public IMatrix
40 {
41 public:
42 typedef Real ValueType;
43
44 /*! @defgroup constructor Matrix Constructor
45 * @{
46 */
47 /*! Empty constructor
48 *
49 * This matrix must be associated with a \r Space before use.
50 */
51 MatrixData();
52
53 /*! Build a new matrix from a Space
54 *
55 * \param space Domain (and Codomain) Space of the matrix.
56 * \param dist Parallel distribution.
57 *
58 * This matrix is directly ready to use. */
59 [[deprecated]] MatrixData(const Space& space, const MatrixDistribution& dist);
60
61 /*! Build a new matrix from two Spaces
62 *
63 * \param row_space Domain Space of the matrix.
64 * \param col_space Codomain Space of the matrix.
65 * \param dist Parallel distribution.
66 *
67 * This matrix is directly ready to use. */
68 [[deprecated]] MatrixData(
69 const Space& row_space, const Space& col_space, const MatrixDistribution& dist);
70
71 /*! Build a new matrix from a size.
72 *
73 * Matlab-like interface, matrix is defined as a [0, n-1]x[0, n-1] array.
74 * \param size Number of rows and columns of the matrix.
75 * \param dist Parallel distribution.
76 *
77 * This matrix is ready to use on an anonymous Space.
78 */
79 [[deprecated]] MatrixData(Integer size, const MatrixDistribution& dist);
80
81 /*! Build a new matrix from two sizes.
82 *
83 * Matlab-like interface, matrix is defined as a [0, n-1]x[0, m-1] array.
84 * \param row_size Number of rows of the matrix.
85 * \param col_size Number of rows of the matrix.
86 * \param dist Parallel distribution.
87 *
88 * This matrix is ready to use on an anonymous Space.
89 */
90 [[deprecated]] MatrixData(Integer row_size, Integer col_size, const MatrixDistribution& dist);
91
92 /*! Build a new matrix on `MatrixDistribution`
93 *
94 * \param dist Parallel distribution.
95 *
96 * This matrix is directly ready to use. */
97 explicit MatrixData(const MatrixDistribution& dist);
98
99 /*! Move constructor for Matrix
100 *
101 * @param matrix Matrix to move from.
102 */
103 MatrixData(MatrixData&& matrix);
104 //! }@
105
106 /*! Destructor
107 * All internal data structures will be deleted.
108 */
109 virtual ~MatrixData() = default;
110
111 /*! Move assignment
112 * \brief Move from Matrix
113 *
114 * @param matrix Matrix to move from.
115 */
117
118 /*! Initialize a Matrix with a Space.
119 *
120 * @param space Domain and Codomain Space for the Matrix.
121 * @param dist Parallel Distribution.
122 */
123 void init(const Space& space, const MatrixDistribution& dist);
124
125 /*! Only support move semantic */
126 MatrixData(const MatrixData&) = delete;
127 /*! Only support move semantic */
128 void operator=(const MatrixData&) = delete;
129
130 MatrixData clone() const;
131
132 /*! @defgroup block Block related API
133 * @{ */
134
135 void setBlockInfos(const Integer block_size);
136
137 void setBlockInfos(const Block* block);
138
139 void setBlockInfos(const VBlock* block);
140
141 Block const* block() const;
142
143 VBlock const* vblock() const;
144 /*! }@ */
145
146 /*! Delete all internal data structures */
147 void free();
148
149 /*! Clean all internal data structures.
150 *
151 * Internal data are cleared, not deleted.
152 */
153 void clear();
154
155 /*! Handle for visitor pattern */
156 void visit(ICopyOnWriteMatrix&) const;
157
158 /*! @defgroup space Space related functions.
159 * @{
160 */
161 /*! Domain Space of the current matrix
162 * @return Domain Space.
163 * @throw FatalException if uninitialized.
164 * Call isNull before to avoid any problem.
165 */
166 const ISpace& rowSpace() const;
167
168 /*! CoDomain Space of the current matrix
169 * @return CoDomain Space.
170 * @throw FatalException if uninitialized.
171 * Call isNull before to avoid any problem.
172 */
173 const ISpace& colSpace() const;
174 /*! }@ */
175
176 /*! Parallel distribution of the Matrix.
177 *
178 * @return Parallel distribution of the Matrix.
179 */
180 const MatrixDistribution& distribution() const;
181
182 /*! @defgroup lock Protection functions.
183 * @{
184 */
185 /*! Lock Matrix with the caller. */
186 void lock() {}
187
188 /*! Unlock Matrix, making it available for others. */
189 void unlock() {}
190
191 /*! Test if a Matrix is locked.
192 *
193 * @return whether of not a matrix is already locked by someone.
194 */
195 bool isLocked() const { return false; }
196 /*! }@ */
197
198 /*! @defgroup properties Algebraic properties management.
199 *
200 * Algebraic properties are designed to propagate high level information of matrix
201 * object. These properties can be passed to external solvers but are not designed to
202 * overload Alien's solver parameters.
203 * @{ */
204 /*! Add a new property on this matrix */
205 void setUserFeature(String feature);
206
207 /*! Check if a property is set. */
208 bool hasUserFeature(String feature) const;
209
210 /*! Alias on property "transposed" */
211 bool isTransposed() const { return hasUserFeature("transposed"); }
212
213 /*! Is this matrix composite ? */
214 bool isComposite() const;
215 /* }@ */
216
217 /*! @defgroup impl Internal data structure access.
218 *
219 * Access multi-representation object.
220 * @{
221 */
222 MultiMatrixImpl* impl();
223
224 const MultiMatrixImpl* impl() const;
225 /*! } @ */
226
227 friend MatrixData createMatrixData(std::shared_ptr<MultiMatrixImpl> multi);
228
229 private:
230 std::shared_ptr<MultiMatrixImpl> m_impl;
231 };
232
233 MatrixData ALIEN_MOVESEMANTIC_EXPORT
234 readFromMatrixMarket(Arccore::MessagePassing::IMessagePassingMng* pm, const std::string& filename);
235
236 MatrixData createMatrixData(std::shared_ptr<MultiMatrixImpl> multi);
237} // namespace Move
238/*---------------------------------------------------------------------------*/
239/*---------------------------------------------------------------------------*/
240
241} // namespace Alien
242
243/*---------------------------------------------------------------------------*/
244/*---------------------------------------------------------------------------*/
IMatrix.h.
Block elements for block matrices.
Definition Block.h:45
IMatrix()
Constructor.
Definition IMatrix.h:54
Interface for algebraic space objects.
Definition ISpace.h:44
Computes a matrix distribution.
Algebraic Matrix with internal multi-representation object.
Definition MatrixData.h:40
Multi matrices representation container.
Implementation of an algebraic space.
Definition Space.h:47
Variable size block elements for block matrices.
Definition VBlock.h:46
void visit(ICopyOnWriteMatrix &) const
MatrixData(const MatrixData &)=delete
void init(const Space &space, const MatrixDistribution &dist)
Definition MatrixData.cc:96
virtual ~MatrixData()=default
}@
MatrixData & operator=(MatrixData &&matrix)
Move from Matrix.
Definition MatrixData.cc:88
void operator=(const MatrixData &)=delete
bool hasUserFeature(String feature) const
bool isTransposed() const
Definition MatrixData.h:211
const MatrixDistribution & distribution() const
const ISpace & rowSpace() const
const ISpace & colSpace() const
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17