Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
Partition.cc
Go to the documentation of this file.
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
23
24#include "Partition.h"
25
26#include <arccore/base/FatalErrorException.h>
27#include <arccore/base/TraceInfo.h>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Alien
33{
34
35using namespace Arccore;
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
40Partition::Partition(const ISpace& space, const MatrixDistribution& distribution)
41: m_space(space)
42, m_distribution(distribution)
43{}
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48void Partition::create(const UniqueArray<String>& tags)
49{
50 m_tags.clear();
51 m_tags.copy(tags);
52
53 m_tagged_parts.clear();
54 m_tagged_parts.resize(m_tags.size());
55
56 Integer offset = m_distribution.rowOffset();
57 UniqueArray<bool> tagged(m_distribution.localRowSize(), false);
58 Integer size = m_tags.size();
59 for (Integer i = 0; i < size; ++i) {
60 auto tag = m_tags[i];
61
62 // tableau d'indices globaux
63 const auto& indices = m_space.field(tag);
64 for (auto gid : indices) {
65 Integer lid = gid - offset;
66 if (tagged[lid])
67 throw FatalErrorException(A_FUNCINFO, "index defined in multiple field");
68 tagged[lid] = true;
69 }
70 m_tagged_parts[i] = indices;
71 }
72 // non taggés
73 Integer nb_untagged = 0;
74 for (auto i : tagged) {
75 if (not i)
76 nb_untagged++;
77 }
78 m_untagged_part.resize(nb_untagged);
79 Integer index = 0;
80 Integer taggedsize = tagged.size();
81 for (Integer i = 0; i < taggedsize; ++i) {
82 if (not tagged[i]) {
83 m_untagged_part[index] = i + offset;
84 index++;
85 }
86 }
87}
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
92} // namespace Alien
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
Partition.h.
Interface for algebraic space objects.
Definition ISpace.h:44
Computes a matrix distribution.
const ISpace & m_space
The matrix space.
Definition Partition.h:105
const MatrixDistribution & m_distribution
The matrix distribution.
Definition Partition.h:107
void create(const Arccore::UniqueArray< Arccore::String > &tags)
Create the tags of the matrix.
Definition Partition.cc:48
Partition(const ISpace &space, const MatrixDistribution &distribution)
Constructor.
Definition Partition.cc:40
Arccore::UniqueArray< Arccore::String > m_tags
The array of tags.
Definition Partition.h:109
Arccore::String tag(Arccore::Integer i) const
Get the i-th tag.
Definition Partition.h:76
Arccore::UniqueArray< Arccore::UniqueArray< Arccore::Integer > > m_tagged_parts
The arrays of local ids for each tag.
Definition Partition.h:111
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17