Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/* IIndexMng (C) 2000-2026 */

Check warning on line 7 in alien/ArcaneInterface/modules/arcane_tools/src/alien/arcane_tools/IIndexManager.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove the commented out code.

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AZ7WuX0DthiTA8tBEatq&open=AZ7WuX0DthiTA8tBEatq&pullRequest=2650
/* */
/* Interface for Alien IndexMng */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
#ifndef ALIEN_IINDEX_MANAGER_H
#define ALIEN_IINDEX_MANAGER_H

Expand Down Expand Up @@ -329,6 +334,13 @@
/*! Uniquement valide après \a prepare */
virtual Arccore::Integer localSize() const = 0;

//! Mode de tri pour les entrées
enum class EntrySortMode
{
KindUidsCreationIndex, //!< Tri par type, puis par UID, puis par index de création
KindCreationIndex //!< Tri par type, puis par index de création
};

//! Construction d'un enumerateur sur les \a Entry
virtual EntryEnumerator enumerateEntry() const = 0;

Expand Down Expand Up @@ -363,18 +375,34 @@
// virtual VectorIndexSet buildVectorIndexSet(const String name, const
// Arcane::ItemGroup
// & itemGroup, const Integer n) = 0;
//! Construit une nouvelle entrée vectoriellesur un ensemble d'entités abstraites
//! Construit une nouvelle entrée vectorielle sur un ensemble d'entités abstraites
/*! L'implémentation actuelle considére le multi-scalaire comme du vectoriel */
virtual VectorIndexSet buildVectorIndexSet(const Arccore::String name,
const Arccore::ConstArrayView<Arccore::Integer> localIds,
const IAbstractFamily& family, const Arccore::Integer n) = 0;

//! Construit une nouvelle entrée scalaire sur l'ensemble des entités d'une familles
//! abstraite
//! Construit une nouvelle entrée vectorielle sur un ensemble d'entités abstraites
/*! L'implémentation actuelle considére le multi-scalaire comme du vectoriel
* \param sort mode de tri des entrées
*/
virtual VectorIndexSet buildVectorIndexSet(const Arccore::String name,
const Arccore::ConstArrayView<Arccore::Integer> localIds,
const IAbstractFamily& family, const Arccore::Integer n,
const EntrySortMode sort) = 0;

//! Construit une nouvelle entrée vectorielle sur l'ensemble des entités d'une famille abstraite
/*! L'implémentation actuelle considére le multi-scalaire comme du vectoriel */
virtual VectorIndexSet buildVectorIndexSet(const Arccore::String name,
const IAbstractFamily& family, const Arccore::Integer n) = 0;

//! Construit une nouvelle entrée vectorielle sur l'ensemble des entités d'une famille abstraite
/*! L'implémentation actuelle considére le multi-scalaire comme du vectoriel
* \param sort mode de tri des entrées
*/
virtual VectorIndexSet buildVectorIndexSet(const Arccore::String name,
const IAbstractFamily& family, const Arccore::Integer n,
const EntrySortMode sort) = 0;

//! Demande de dé-indexation d'une partie d'une entrée
/*! Utilisable uniquement avant prepare */
virtual void removeIndex(const ScalarIndexSet & entry,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* BasicIndexManager (C) 2000-2025 */
/* BasicIndexManager (C) 2000-2026 */
/* */
/* Basic indexing between algebra and mesh worlds. Depends on Arcane */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

#include "alien/arcane_tools/indexManager/BasicIndexManager.h"

#include "alien/arcane_tools/IIndexManager.h"

#include <list>
#include <vector>

Expand Down Expand Up @@ -611,7 +613,7 @@
entry->freeDefinedLids();
}

std::sort(entry_index.begin(), entry_index.end(), EntryIndexComparator());
std::sort(entry_index.begin(), entry_index.end(), EntryIndexComparator(m_sort_mode));

Check warning on line 616 in alien/ArcaneInterface/modules/arcane_tools/src/alien/arcane_tools/indexManager/BasicIndexManager.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace with the version of "std::ranges::sort" that takes a range.

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AZ7WuXzrthiTA8tBEato&open=AZ7WuXzrthiTA8tBEato&pullRequest=2650

ALIEN_ASSERT(
((Integer)entry_index.size() == m_local_entry_count + m_global_entry_count),
Expand Down Expand Up @@ -1214,11 +1216,10 @@
const MyEntryImpl* bEntry = b.m_entry;
if (a.m_kind != b.m_kind)
return a.m_kind < b.m_kind;
else if (a.m_uid != b.m_uid)
else if (m_sort == IIndexManager::EntrySortMode::KindUidsCreationIndex && a.m_uid != b.m_uid)
return a.m_uid < b.m_uid;
else
return aEntry->getCreationIndex() < bEntry->getCreationIndex();
// return a.m_creation_index < b.m_creation_index;
}

/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -1279,6 +1280,26 @@
IIndexManager::VectorIndexSet BasicIndexManager::buildVectorIndexSet(
const String name, const Arcane::ItemGroup& itemGroup, const Integer n)
{
m_sort_mode = IIndexManager::EntrySortMode::KindUidsCreationIndex;
VectorIndexSet ens(n);
const ConstArrayView<Integer> localIds = itemGroup.view().localIds();
Arcane::IItemFamily* item_family = itemGroup.itemFamily();
Integer kind = kindFromItemFamily(item_family);
std::shared_ptr<IAbstractFamily>& family = m_abstract_families[kind];
if (!family)
family.reset(new ItemAbstractFamily(item_family));
for (Integer i = 0; i < n; ++i) {
ens[i] = buildEntry(
String::format("{0}[{1}]", name, i), family.get(), kind);
defineIndex(ens[i], localIds);
}
return ens;
}

IIndexManager::VectorIndexSet BasicIndexManager::buildVectorIndexSet(
const String name, const Arcane::ItemGroup& itemGroup, const Integer n, const EntrySortMode sort)
{
m_sort_mode = sort;
VectorIndexSet ens(n);
const ConstArrayView<Integer> localIds = itemGroup.view().localIds();
Arcane::IItemFamily* item_family = itemGroup.itemFamily();
Expand All @@ -1300,6 +1321,21 @@
const ConstArrayView<Integer> localIds, const IAbstractFamily& family,
const Integer n)
{
m_sort_mode = IIndexManager::EntrySortMode::KindUidsCreationIndex;
VectorIndexSet ens(n);
for (Integer i = 0; i < n; ++i) {
ens[i] = buildEntry(
String::format("{0}[{1}]", name, i), &family, addNewAbstractFamily(&family));
defineIndex(ens[i], localIds);
}
return ens;
}

IIndexManager::VectorIndexSet BasicIndexManager::buildVectorIndexSet(const String name,
const ConstArrayView<Integer> localIds, const IAbstractFamily& family,
const Integer n, const EntrySortMode sort)
{
m_sort_mode = sort;
VectorIndexSet ens(n);
for (Integer i = 0; i < n; ++i) {
ens[i] = buildEntry(
Expand All @@ -1314,6 +1350,22 @@
IIndexManager::VectorIndexSet BasicIndexManager::buildVectorIndexSet(
const String name, const IAbstractFamily& family, const Integer n)
{
m_sort_mode = IIndexManager::EntrySortMode::KindUidsCreationIndex;
UniqueArray<Int32> localIds = family.allLocalIds();

Check warning on line 1354 in alien/ArcaneInterface/modules/arcane_tools/src/alien/arcane_tools/indexManager/BasicIndexManager.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Avoid explicitly specifying the template arguments by relying on the class template argument deduction.

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AZ7WuXzrthiTA8tBEatp&open=AZ7WuXzrthiTA8tBEatp&pullRequest=2650

VectorIndexSet ens(n);
for (Integer i = 0; i < n; ++i) {
ens[i] = buildEntry(
String::format("{0}[{1}]", name, i), &family, addNewAbstractFamily(&family));
defineIndex(ens[i], localIds.view());
}
return ens;
}

IIndexManager::VectorIndexSet BasicIndexManager::buildVectorIndexSet(
const String name, const IAbstractFamily& family, const Integer n, const EntrySortMode sort)
{
m_sort_mode = sort;
UniqueArray<Int32> localIds = family.allLocalIds();

VectorIndexSet ens(n);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* BasicIndexManager (C) 2000-2024 */
/* BasicIndexManager (C) 2000-2026 */
/* */
/* Basic indexing between algebra and mesh worlds. Depends on Arcane */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -128,18 +128,28 @@
/*! L'implémentation actuelle considére le multi-scalaire comme du vectoriel */
VectorIndexSet buildVectorIndexSet(const Arccore::String name,
const Arcane::ItemGroup& itemGroup, const Arccore::Integer n);
VectorIndexSet buildVectorIndexSet(const Arccore::String name,
const Arcane::ItemGroup& itemGroup, const Arccore::Integer n,
const EntrySortMode sort);

//! Construit une nouvelle entrée vectoriellesur un ensemble d'entités abstraites
/*! L'implémentation actuelle considére le multi-scalaire comme du vectoriel */
VectorIndexSet buildVectorIndexSet(const Arccore::String name,
const Arccore::IntegerConstArrayView localIds, const IAbstractFamily& family,
const Arccore::Integer n);
VectorIndexSet buildVectorIndexSet(const Arccore::String name,

Check warning on line 140 in alien/ArcaneInterface/modules/arcane_tools/src/alien/arcane_tools/indexManager/BasicIndexManager.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Annotate this function with "override" or "final".

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AZ7WuXpUthiTA8tBEatk&open=AZ7WuXpUthiTA8tBEatk&pullRequest=2650
const Arccore::IntegerConstArrayView localIds, const IAbstractFamily& family,
const Arccore::Integer n,
const EntrySortMode sort);

//! Construit une nouvelle entrée scalaire sur l'ensemble des entités d'une familles
//! abstraite
/*! L'implémentation actuelle considére le multi-scalaire comme du vectoriel */
VectorIndexSet buildVectorIndexSet(const Arccore::String name,
const IAbstractFamily& family, const Arccore::Integer n);
VectorIndexSet buildVectorIndexSet(const Arccore::String name,

Check warning on line 150 in alien/ArcaneInterface/modules/arcane_tools/src/alien/arcane_tools/indexManager/BasicIndexManager.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Annotate this function with "override" or "final".

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AZ7WuXpUthiTA8tBEatl&open=AZ7WuXpUthiTA8tBEatl&pullRequest=2650
const IAbstractFamily& family, const Arccore::Integer n,
const EntrySortMode sort);

//! Demande de dé-indexation d'une partie d'une entrée
/*! Utilisable uniquement avant prepare */
Expand Down Expand Up @@ -236,8 +246,10 @@

struct EntryIndexComparator
{
inline bool operator()(
const InternalEntryIndex& a, const InternalEntryIndex& b) const;
IIndexManager::EntrySortMode m_sort = IIndexManager::EntrySortMode::KindUidsCreationIndex;
EntryIndexComparator(IIndexManager::EntrySortMode sort) : m_sort(sort) {}

Check failure on line 250 in alien/ArcaneInterface/modules/arcane_tools/src/alien/arcane_tools/indexManager/BasicIndexManager.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add the "explicit" keyword to this constructor.

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AZ7WuXpUthiTA8tBEatm&open=AZ7WuXpUthiTA8tBEatm&pullRequest=2650
explicit EntryIndexComparator() = default;
inline bool operator()(const InternalEntryIndex& a, const InternalEntryIndex& b) const;

Check warning on line 252 in alien/ArcaneInterface/modules/arcane_tools/src/alien/arcane_tools/indexManager/BasicIndexManager.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Move the "inline" specifier to the definition of the function.

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AZ7WuXpUthiTA8tBEatn&open=AZ7WuXpUthiTA8tBEatn&pullRequest=2650
};

//! Table des Entry connues localement
Expand All @@ -246,6 +258,7 @@

//! Index de creation des entrées
Arccore::Integer m_creation_index = 0;
IIndexManager::EntrySortMode m_sort_mode = IIndexManager::EntrySortMode::KindUidsCreationIndex;

//! Famille des familles abstraites associées aux familles du maillage

Expand Down
Loading