Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
AbstractItemFamily.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 <unordered_map>
22
23#include <alien/index_manager/IAbstractFamily.h>
24#include <alien/index_manager/IIndexManager.h>
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Alien
30{
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
35/* This module relies on the fact that local_id of the item i is also i.
36 */
37class ALIEN_EXPORT AbstractItemFamily : public IAbstractFamily
38{
39 public:
40 AbstractItemFamily(const AbstractItemFamily& family);
41
42 /*! Build a family for locally known unique ids.
43 *
44 * @param uniqueIds Array of locally known uniqueIds.
45 * @param owners Array of item owners
46 * @param parallel_mng Parallel Manager.
47 */
48 AbstractItemFamily(ConstArrayView<Int64> uniqueIds,
49 ConstArrayView<Integer> owners,
50 IMessagePassingMng* parallel_mng,
51 ITraceMng* trace_mng = nullptr);
52
53 /*! Build a family for locally known unique ids.
54 *
55 * @param uniqueIds Array of locally known uniqueIds.
56 * @param ghost_uniqueIds Array of ghost known uniqueIds.
57 * @param ghost_owners Array of ghost item owners
58 * @param parallel_mng Parallel Manager.
59 */
60 AbstractItemFamily(ConstArrayView<Int64> uniqueIds,
61 ConstArrayView<Int64> ghost_uniqueIds,
62 ConstArrayView<Integer> ghost_owners,
63 IMessagePassingMng* parallel_mng,
64 ITraceMng* trace_mng = nullptr);
65
66 /*! Build a family for locally owned unique ids.
67 *
68 * @param uniqueIds Array of locally owned uniqueIds.
69 * @param parallel_mng Parallel Manager.
70 */
71 AbstractItemFamily(ConstArrayView<Int64> uniqueIds,
72 IMessagePassingMng* parallel_mng,
73 [[maybe_unused]] ITraceMng* trace_mng = nullptr);
74
75 ~AbstractItemFamily() override = default;
76
77 public:
78 IAbstractFamily* clone() const override { return new AbstractItemFamily(*this); }
79
80 public:
81 Int32 maxLocalId() const override { return m_unique_ids.size(); }
82
83 void uniqueIdToLocalId(
84 ArrayView<Int32> localIds, ConstArrayView<Int64> uniqueIds) const override;
85
86 IAbstractFamily::Item item(Int32 localId) const override;
87
88 SafeConstArrayView<Integer> owners(ConstArrayView<Int32> localIds) const override;
89
90 SafeConstArrayView<Int64> uids(ConstArrayView<Int32> localIds) const override;
91
92 SafeConstArrayView<Int32> allLocalIds() const override;
93
94 private:
95 IMessagePassingMng* m_parallel_mng = nullptr;
96 ITraceMng* m_trace_mng = nullptr;
97 UniqueArray<Int64> m_unique_ids;
98 UniqueArray<Integer> m_owners;
99 std::unordered_map<Int64, Integer> m_uid2lid;
100};
101
102class ALIEN_EXPORT AbstractFamily : public IIndexManager::IAbstractFamily
103{
104 public:
105 AbstractFamily(const AbstractFamily& family);
106
107 /*! Build a family for locally known unique ids.
108 *
109 * @param uniqueIds Array of locally known uniqueIds.
110 * @param owners Array of item owners
111 * @param parallel_mng Parallel Manager.
112 */
113 AbstractFamily(ConstArrayView<Int64> uniqueIds,
114 ConstArrayView<Integer> owners,
115 IMessagePassingMng* parallel_mng,
116 ITraceMng* trace_mng = nullptr);
117
118 /*! Build a family for locally known unique ids.
119 *
120 * @param uniqueIds Array of locally known uniqueIds.
121 * @param ghost_uniqueIds Array of ghost known uniqueIds.
122 * @param ghost_owners Array of ghost item owners
123 * @param parallel_mng Parallel Manager.
124 */
125 AbstractFamily(ConstArrayView<Int64> uniqueIds,
126 ConstArrayView<Int64> ghost_uniqueIds,
127 ConstArrayView<Integer> ghost_owners,
128 IMessagePassingMng* parallel_mng,
129 ITraceMng* trace_mng = nullptr);
130
131 /*! Build a family for locally owned unique ids.
132 *
133 * @param uniqueIds Array of locally owned uniqueIds.
134 * @param parallel_mng Parallel Manager.
135 */
136
137 AbstractFamily(ConstArrayView<Int64> uniqueIds,
138 IMessagePassingMng* parallel_mng,
139 ITraceMng* trace_mng = nullptr);
140
141 ~AbstractFamily() override = default;
142
143 public:
144 IAbstractFamily* clone() const override { return new AbstractFamily(*this); }
145
146 public:
147 Int32 maxLocalId() const override { return m_unique_ids.size(); }
148
149 void uniqueIdToLocalId(
150 ArrayView<Int32> localIds, ConstArrayView<Int64> uniqueIds) const override;
151
152 IAbstractFamily::Item item(Int32 localId) const override;
153
154 Arccore::SharedArray<Arccore::Integer> owners(
155 ConstArrayView<Int32> localIds) const override;
156
157 Arccore::SharedArray<Arccore::Int64> uids(
158 ConstArrayView<Int32> localIds) const override;
159
160 Arccore::SharedArray<Arccore::Int32> allLocalIds() const override;
161
162 private:
163 IMessagePassingMng* m_parallel_mng = nullptr;
164 ITraceMng* m_trace_mng = nullptr;
165 UniqueArray<Int64> m_unique_ids;
166 UniqueArray<Integer> m_owners;
167 std::unordered_map<Int64, Integer> m_uid2lid;
168};
169/*---------------------------------------------------------------------------*/
170/*---------------------------------------------------------------------------*/
171
172} // namespace Alien
173
174/*---------------------------------------------------------------------------*/
175/*---------------------------------------------------------------------------*/
Int32 maxLocalId() const override
Identifiant maximal des localIds pour cette famille.
IAbstractFamily * clone() const override
Construit un clone de cet objet.
Int32 maxLocalId() const override
Max local Id for this family.
Interface for abstract families of items.
Interface des familles abstraites pour l'indexation de items.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17