Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
DoKVector.h
1/*
2 * Copyright 2021 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
23
24#include <alien/kernels/dok/DoKDistributor.h>
25
26#include <alien/kernels/redistributor/Redistributor.h>
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Alien
32{
33
34class DoKDistributor;
36
42class ALIEN_EXPORT DoKVector : public IVectorImpl
43{
44 public:
45 typedef Real ValueType;
46
47 public:
48 explicit DoKVector(const MultiVectorImpl* multi_impl = nullptr)
49 : IVectorImpl(multi_impl, "DoK")
50 , m_data()
51 {}
52
53 DoKVector(const DoKVector&) = delete;
54
55 ~DoKVector() override = default;
56
57 void clear() override
58 {
59 m_data.clear();
60 }
61
66 std::optional<ValueType> contribute(Arccore::Int32 index, ValueType value)
67 {
68 m_data[index] += value;
69 return m_data[index];
70 }
71
76 std::optional<ValueType> set(Arccore::Int32 index, ValueType value)
77 {
78 // if (distribution().owner(index) != distribution().parallelMng()->commRank()) {
79 // return std::nullopt;
80 // }
81 m_data[index] = value;
82 return value;
83 }
84
86 void assemble() { _distribute(); }
87
88 void reserve(Arccore::Int32 size)
89 {
90 m_data.reserve(size);
91 }
92
93 private:
94 void _distribute();
95 friend DoKDistributor;
96 friend DoKToSimpleCSRVectorConverter;
97
98 private:
99 std::unordered_map<Arccore::Int32, DoKVector::ValueType> m_data;
100};
101
102} // namespace Alien
IVectorImpl.h.
MultiVectorImpl.h.
void assemble()
Dispatch matrix elements.
Definition DoKVector.h:86
std::optional< ValueType > set(Arccore::Int32 index, ValueType value)
Definition DoKVector.h:76
std::optional< ValueType > contribute(Arccore::Int32 index, ValueType value)
Definition DoKVector.h:66
void clear() override
Wipe out internal data.
Definition DoKVector.h:57
IVectorImpl(const MultiVectorImpl *multi_impl, BackEndId backend="")
Constructor.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17