Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
VBlockVector.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 <alien/ref/data/block/VBlockVector.h>
20
21#include <alien/ref/AlienRefSemantic.h>
22#include <alien/utils/ICopyOnWriteObject.h>
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Alien
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33VBlockVector::VBlockVector()
34: m_impl(new MultiVectorImpl(std::make_shared<Space>(0),
35 std::make_shared<VectorDistribution>(VectorDistribution())))
36{}
37
38/*---------------------------------------------------------------------------*/
39
40VBlockVector::VBlockVector(const VBlock& block, const VectorDistribution& dist)
41: m_impl(new MultiVectorImpl(dist.space().clone(), dist.clone()))
42{
43 m_impl->setBlockInfos(&block);
44}
45
46/*---------------------------------------------------------------------------*/
47
48VBlockVector::VBlockVector(Integer nrows, Integer nrows_local, const VBlock& block,
49 IMessagePassingMng* parallel_mng)
50: m_impl(new MultiVectorImpl(std::make_shared<Space>(nrows),
51 std::make_shared<VectorDistribution>(
52 VectorDistribution(nrows, nrows_local, parallel_mng))))
53{
54 m_impl->setBlockInfos(&block);
55}
56
57/*---------------------------------------------------------------------------*/
58
59VBlockVector::VBlockVector(
60Integer nrows, const VBlock& block, IMessagePassingMng* parallel_mng)
61: m_impl(new MultiVectorImpl(std::make_shared<Space>(nrows),
62 std::make_shared<VectorDistribution>(VectorDistribution(nrows, parallel_mng))))
63{
64 m_impl->setBlockInfos(&block);
65}
66
67/*---------------------------------------------------------------------------*/
68
69VBlockVector::VBlockVector(VBlockVector&& vector)
70: m_impl(std::move(vector.m_impl))
71{}
72
73/*---------------------------------------------------------------------------*/
74
75VBlockVector&
76VBlockVector::operator=(VBlockVector&& vector)
77{
78 m_impl = std::move(vector.m_impl);
79 return *this;
80}
81
82/*---------------------------------------------------------------------------*/
83
84void VBlockVector::init(const VBlock& block, const VectorDistribution& dist)
85{
86 m_impl.reset(new MultiVectorImpl(dist.space().clone(), dist.clone()));
87 m_impl->setBlockInfos(&block);
88}
89
90/*---------------------------------------------------------------------------*/
91
92void VBlockVector::free()
93{
94 m_impl->free();
95}
96
97/*---------------------------------------------------------------------------*/
98
99void VBlockVector::clear()
100{
101 m_impl->clear();
102}
103
104/*---------------------------------------------------------------------------*/
105
106const ISpace&
108{
109 return m_impl->space();
110}
111
112/*---------------------------------------------------------------------------*/
113
115{
116 v.accept(m_impl);
117}
118
119/*---------------------------------------------------------------------------*/
120
122VBlockVector::distribution() const
123{
124 return m_impl->distribution();
125}
126
127/*---------------------------------------------------------------------------*/
128
129void VBlockVector::setUserFeature(String feature)
130{
131 m_impl->setFeature(feature);
132}
133
134/*---------------------------------------------------------------------------*/
135
136bool VBlockVector::hasUserFeature(String feature) const
137{
138 return m_impl->hasFeature(feature);
139}
140
141/*---------------------------------------------------------------------------*/
142
143const VBlock&
144VBlockVector::vblock() const
145{
146 const VBlock* block = m_impl->vblock();
147 if (block)
148 return *block;
149 else
150 throw FatalErrorException(
151 A_FUNCINFO, "Requesting for block information but none was provided");
152}
153
154/*---------------------------------------------------------------------------*/
155
156MultiVectorImpl*
158{
159 if (!m_impl) {
160 m_impl.reset(new MultiVectorImpl());
161 }
162 /* JMG ????
163 else if (!m_impl.unique()) { // Need to clone due to other references.
164 m_impl.reset(m_impl->clone());
165 } */
166 return m_impl.get();
167}
168
169/*---------------------------------------------------------------------------*/
170
171const MultiVectorImpl*
173{
174 return m_impl.get();
175}
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
179
180} // namespace Alien
181
182/*---------------------------------------------------------------------------*/
183/*---------------------------------------------------------------------------*/
Implementation of an algebraic space.
Definition Space.h:47
void visit(ICopyOnWriteVector &) const
Visit method.
const ISpace & space() const
Get the space associated to the vector.
MultiVectorImpl * impl()
Get the multivector implementation.
Computes a vector distribution.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17