Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
VectorData.h
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#pragma once
20
21#include <memory>
22
23#include <alien/data/IVector.h>
24#include <alien/move/AlienMoveSemanticPrecomp.h>
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Alien
30{
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
35class Block;
36class VBlock;
37class Space;
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
42
43namespace Move
44{
45
46 //! Algebraic Vector with internal multi-representation object.
47 class ALIEN_MOVESEMANTIC_EXPORT VectorData : public IVector
48 {
49 public:
50 typedef Real ValueType;
51
52 /*! @defgroup constructor Vector Constructor
53 * @{
54 */
55 /*! Empty constructor
56 *
57 * This vector must be associated with a Space before use.
58 */
59 VectorData();
60
61 /*! Build a new Vector from a Space
62 *
63 * \param space Definition Space of the Vector.
64 * \param dist Parallel distribution.
65 *
66 * This vector is directly ready to use.
67 *
68 * \see VectorData::VectorData(const VectorDistribution&).
69 * */
70 [[deprecated]] VectorData(const ISpace& space, const VectorDistribution& dist);
71
72 /*! Build a new Vector from a size.
73 *
74 * Matlab-like interface, Vector is defined as a [0, n-1] array.
75 * \param size Number of elements of the vector.
76 * \param dist Parallel distribution.
77 *
78 * This vector is ready to use on an anonymous Space.
79 *
80 * \see VectorData::VectorData(const VectorDistribution&).
81 */
82 [[deprecated]] VectorData(Integer size, const VectorDistribution& dist);
83
84 /*! Build a new Vector from a Space
85 *
86 * \param space Definition Space of the Vector.
87 * \param dist Parallel distribution.
88 *
89 * This vector is directly ready to use. */
90 explicit VectorData(const VectorDistribution& dist);
91
92 /*! Move constructor for Vector
93 *
94 * @param vector Vector to move from.
95 */
96 VectorData(VectorData&& vector);
97 /*! }@ */
98
99 /*! Destructor
100 * All internal data structures will be deleted.
101 */
102 virtual ~VectorData() = default;
103
104 /*! Move assignment
105 * \brief Move from Vector
106 *
107 * @param matrix Vector to move from.
108 */
110
111 /*! Initialize a Vector with a Space.
112 *
113 * @param space Definition Space.
114 * @param dist Parallel Distribution.
115 */
116 void init(const ISpace& space, const VectorDistribution& dist);
117
118 /*! Only support move semantic */
119 VectorData(const VectorData&) = delete;
120 /*! Only support move semantic */
121 VectorData& operator=(const VectorData&) = delete;
122
123 VectorData clone() const;
124
125 /*! @defgroup block Block related API
126 * @{ */
127 void setBlockInfos(const Integer block_size);
128
129 void setBlockInfos(const Block* block);
130
131 void setBlockInfos(const VBlock* block);
132
133 const Block* block() const;
134
135 const VBlock* vblock() const;
136 /*! }@ */
137
138 /*! Delete all internal data structures */
139 void free();
140
141 /*! Clean all internal data structures.
142 *
143 * Internal data are cleared, not deleted.
144 */
145 void clear();
146
147 /*! Handle for visitor pattern */
148 void visit(ICopyOnWriteVector&) const;
149
150 /*! @defgroup space Space related functions.
151 * @{
152 */
153 /*! Domain Space of the current vector
154 * @return Definition Space.
155 * @throw FatalException if uninitialized.
156 * Call isNull before to avoid any problem.
157 */
158 const ISpace& space() const;
159
160 /*! Parallel distribution of the Vector.
161 *
162 * @return Parallel distribution of the Vector.
163 */
164 const VectorDistribution& distribution() const;
165
166 /*! @defgroup properties Algebraic properties management.
167 *
168 * Algebraic properties are designed to propagate high level information of matrix
169 * object. These properties can be passed to external solvers but are not designed to
170 * overload Alien's solver parameters.
171 * @{ */
172 /*! Add a new property on this vector */
173 void setUserFeature(String feature);
174
175 /*! Check if a property is set. */
176 bool hasUserFeature(String feature) const;
177 /*! }@ */
178
179 /*! @defgroup impl Internal data structure access.
180 *
181 * Access multi-representation object.
182 * @{
183 */
185
186 const MultiVectorImpl* impl() const;
187 /*! }@ */
188
189 friend VectorData createVectorData(std::shared_ptr<MultiVectorImpl> multi);
190
191 private:
192 std::shared_ptr<MultiVectorImpl> m_impl;
193 };
194
195 VectorData ALIEN_MOVESEMANTIC_EXPORT
196 readFromMatrixMarket(const VectorDistribution& distribution, const std::string& filename);
197
198 // Do not export this factory.
199 VectorData createVectorData(std::shared_ptr<MultiVectorImpl> multi);
200} // namespace Move
201
202/*---------------------------------------------------------------------------*/
203/*---------------------------------------------------------------------------*/
204
205} // namespace Alien
206
207/*---------------------------------------------------------------------------*/
208/*---------------------------------------------------------------------------*/
IVector.h.
Block elements for block matrices.
Definition Block.h:45
Interface for algebraic space objects.
Definition ISpace.h:44
IVector()
Constructor.
Definition IVector.h:54
Algebraic Vector with internal multi-representation object.
Definition VectorData.h:48
Implementation of an algebraic space.
Definition Space.h:47
Variable size block elements for block matrices.
Definition VBlock.h:46
Computes a vector distribution.
void visit(ICopyOnWriteVector &) const
VectorData(const VectorData &)=delete
virtual ~VectorData()=default
VectorData & operator=(const VectorData &)=delete
VectorData & operator=(VectorData &&vector)
Move from Vector.
Definition VectorData.cc:68
void init(const ISpace &space, const VectorDistribution &dist)
Definition VectorData.cc:76
friend VectorData createVectorData(std::shared_ptr< MultiVectorImpl > multi)
MultiVectorImpl * impl()
Get the multivector implementation.
void setUserFeature(String feature)
bool hasUserFeature(String feature) const
const VectorDistribution & distribution() const
const ISpace & space() const
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17