Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
Vector.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/scalar/Vector.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
33Vector::Vector()
34: m_impl(new MultiVectorImpl(std::make_shared<Space>(0),
35 std::make_shared<VectorDistribution>(VectorDistribution())))
36{}
37
38/*---------------------------------------------------------------------------*/
39
40Vector::Vector(const VectorDistribution& dist)
41: m_impl(new MultiVectorImpl(dist.space().clone(), dist.clone()))
42{}
43
44/*---------------------------------------------------------------------------*/
45
46Vector::Vector(Integer nrows, Integer nrows_local, IMessagePassingMng* parallel_mng)
47: m_impl(new MultiVectorImpl(std::make_shared<Space>(nrows),
48 std::make_shared<VectorDistribution>(
49 VectorDistribution(nrows, nrows_local, parallel_mng))))
50{}
51
52/*---------------------------------------------------------------------------*/
53
54Vector::Vector(Integer nrows, IMessagePassingMng* parallel_mng)
55: m_impl(new MultiVectorImpl(std::make_shared<Space>(nrows),
56 std::make_shared<VectorDistribution>(VectorDistribution(nrows, parallel_mng))))
57{}
58
59/*---------------------------------------------------------------------------*/
60
61Vector::Vector(Vector&& vector)
62: m_impl(std::move(vector.m_impl))
63{}
64
65/*---------------------------------------------------------------------------*/
66
67Vector&
68Vector::operator=(Vector&& vector)
69{
70 m_impl = std::move(vector.m_impl);
71 return *this;
72}
73
74/*---------------------------------------------------------------------------*/
75
77{
78 v.accept(m_impl);
79}
80
81/*---------------------------------------------------------------------------*/
82
83const ISpace&
85{
86 return m_impl->space();
87}
88
89/*---------------------------------------------------------------------------*/
90
92Vector::distribution() const
93{
94 return m_impl->distribution();
95}
96
97/*---------------------------------------------------------------------------*/
98
99void Vector::setUserFeature(String feature)
100{
101 m_impl->setFeature(feature);
102}
103
104/*---------------------------------------------------------------------------*/
105
106bool Vector::hasUserFeature(String feature) const
107{
108 return m_impl->hasFeature(feature);
109}
110
111/*---------------------------------------------------------------------------*/
112
113MultiVectorImpl*
115{
116 if (!m_impl) {
117 m_impl.reset(new MultiVectorImpl());
118 }
119 /* JMG ????
120 else if (!m_impl.unique()) { // Need to clone due to other references.
121 m_impl.reset(m_impl->clone());
122 } */
123 return m_impl.get();
124}
125
126/*---------------------------------------------------------------------------*/
127
128const MultiVectorImpl*
130{
131 return m_impl.get();
132}
133
134/*---------------------------------------------------------------------------*/
135/*---------------------------------------------------------------------------*/
136
137} // namespace Alien
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
Interface for algebraic space objects.
Definition ISpace.h:44
Implementation of an algebraic space.
Definition Space.h:47
Computes a vector distribution.
void visit(ICopyOnWriteVector &) const
Visit method.
Definition Vector.cc:76
const ISpace & space() const
Get the space associated to the vector.
Definition Vector.cc:84
MultiVectorImpl * impl()
Get the multivector implementation.
Definition Vector.cc:114
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17