Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
VectorData.cc
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#include "VectorData.h"
20
24#include <alien/utils/ICopyOnWriteObject.h>
25#include <alien/data/ISpace.h>
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Alien::Move
31{
32using namespace Arccore;
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
38: m_impl(new MultiVectorImpl(std::make_shared<Space>(0),
39 std::make_shared<VectorDistribution>(VectorDistribution())))
40{}
41
42/*---------------------------------------------------------------------------*/
43
45: m_impl(new MultiVectorImpl(space.clone(), dist.clone()))
46{}
47
48/*---------------------------------------------------------------------------*/
49
51: m_impl(new MultiVectorImpl(std::make_shared<Space>(size), dist.clone()))
52{}
53
54/*---------------------------------------------------------------------------*/
55
57: m_impl(new MultiVectorImpl(dist.space().clone(), dist.clone()))
58{}
59
60/*---------------------------------------------------------------------------*/
61
63: m_impl(std::move(vector.m_impl))
64{}
65
66/*---------------------------------------------------------------------------*/
67
69{
70 m_impl = std::move(vector.m_impl);
71 return *this;
72}
73
74/*---------------------------------------------------------------------------*/
75
77{
78 m_impl.reset(new MultiVectorImpl(space.clone(), dist.clone()));
79}
80
81/*---------------------------------------------------------------------------*/
82
83void VectorData::setBlockInfos(const Integer block_size)
84{
85 impl()->setBlockInfos(block_size);
86}
87
88/*---------------------------------------------------------------------------*/
89/*
90void
91VectorData::
92setBlockInfos(const IBlockBuilder& builder)
93{
94 std::unique_ptr<Block> block(new Block(m_impl->distribution(), builder.blockSizes()));
95 impl()->setBlockInfos(std::move(block));
96}*/
97
98/*---------------------------------------------------------------------------*/
99
100void VectorData::setBlockInfos(const Block* block)
101{
102 if (block) {
103 impl()->setBlockInfos(block);
104 }
105}
106
107/*---------------------------------------------------------------------------*/
108
109void VectorData::setBlockInfos(const VBlock* block)
110{
111 if (block) {
112 impl()->setBlockInfos(block);
113 }
114}
115
116/*---------------------------------------------------------------------------*/
117
119{
120 impl()->free();
121}
122
123/*---------------------------------------------------------------------------*/
124
126{
127 impl()->clear();
128}
129
130/*---------------------------------------------------------------------------*/
131
133{
134 v.accept(m_impl);
135}
136
137/*---------------------------------------------------------------------------*/
138
139const ISpace&
141{
142 return impl()->space();
143}
144
145/*---------------------------------------------------------------------------*/
146
149{
150 return m_impl->distribution();
151}
152
153/*---------------------------------------------------------------------------*/
154
155const Block*
156VectorData::block() const
157{
158 return m_impl->block();
159}
160
161/*---------------------------------------------------------------------------*/
162
163const VBlock*
164VectorData::vblock() const
165{
166 return m_impl->vblock();
167}
168
169/*---------------------------------------------------------------------------*/
170
171void VectorData::setUserFeature(String feature)
172{
173 impl()->setFeature(feature);
174}
175
176/*---------------------------------------------------------------------------*/
177
178bool VectorData::hasUserFeature(String feature) const
179{
180 return impl()->hasFeature(feature);
181}
182
183/*---------------------------------------------------------------------------*/
184
187{
188 if (!m_impl) {
189 m_impl.reset(new MultiVectorImpl());
190 }
191 /* JMG ????
192 else if (!m_impl.unique()) { // Need to clone due to other references.
193 m_impl.reset(m_impl->clone());
194 } */
195 return m_impl.get();
196}
197
198/*---------------------------------------------------------------------------*/
199
200const MultiVectorImpl*
202{
203 return m_impl.get();
204}
205
206/*---------------------------------------------------------------------------*/
207
209VectorData::clone() const
210{
211 VectorData out;
212 out.m_impl.reset(m_impl->clone());
213 return out;
214}
215
216VectorData createVectorData(std::shared_ptr<MultiVectorImpl> multi)
217{
218 VectorData out;
219 out.m_impl = multi;
220 return out;
221}
222/*---------------------------------------------------------------------------*/
223/*---------------------------------------------------------------------------*/
224
225} // namespace Alien::Move
226
227/*---------------------------------------------------------------------------*/
228/*---------------------------------------------------------------------------*/
Block.h.
ISpace.h.
MultiVectorImpl.h.
VBlock.h.
Block elements for block matrices.
Definition Block.h:45
Interface for algebraic space objects.
Definition ISpace.h:44
Algebraic Vector with internal multi-representation object.
Definition VectorData.h:48
void free()
Free resources.
void clear()
Clear resources.
const AlgebraTraits< tag >::vector_type & get() const
Get a specific vector implementation.
void setBlockInfos(const Block *blocks)
Set uniform block information.
const ISpace & space() const
Get the space associated with the vector.
Implementation of an algebraic space.
Definition Space.h:47
Variable size block elements for block matrices.
Definition VBlock.h:46
Computes a vector distribution.
std::shared_ptr< VectorDistribution > clone() const
Clone the distribution.
void visit(ICopyOnWriteVector &) const
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