Arcane  4.2.1.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
LimaUtils.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* LimaUtils.cc (C) 2000-2026 */
9/* */
10/* Fonctions utilitaires pour Lima. */
11/*---------------------------------------------------------------------------*/
12
13#include "arcane/lima/internal/LimaUtils.h"
14
15#include "arcane/utils/CheckedConvert.h"
16#include "arcane/utils/ITraceMng.h"
17
18#include "arcane/core/IItemFamily.h"
19#include "arcane/core/IMeshReader.h"
20#include "arcane/core/ItemGroup.h"
21
22//#include "arcane/lima/internal/LimaMalippT.h"
23
24#include <algorithm>
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Arcane
30{
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
36createGroup(IItemFamily* family, const String& name, Int32ArrayView local_ids)
37{
38 ITraceMng* tm = family->traceMng();
39 if (!local_ids.empty())
40 std::sort(std::begin(local_ids), std::end(local_ids));
41 Integer nb_item = local_ids.size();
42 Integer nb_duplicated = 0;
43 // Détecte les doublons
44 for (Integer i = 1; i < nb_item; ++i)
45 if (local_ids[i] == local_ids[i - 1]) {
46 ++nb_duplicated;
47 }
48 if (nb_duplicated != 0) {
49 tm->warning() << "Duplicated items in group name=" << name
50 << " nb_duplicated=" << nb_duplicated;
51 auto xbegin = std::begin(local_ids);
52 auto xend = std::end(local_ids);
53 Integer new_size = CheckedConvert::toInteger(std::unique(xbegin, xend) - xbegin);
54 tm->info() << "NEW_SIZE=" << new_size << " old=" << nb_item;
55 local_ids = local_ids.subView(0, new_size);
56 }
57
58 family->createGroup(name, local_ids, true);
59}
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64} // namespace Arcane
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
constexpr ArrayView< T > subView(Integer abegin, Integer asize) noexcept
Sous-vue à partir de l'élément abegin et contenant asize éléments.
constexpr Integer size() const noexcept
Retourne la taille du tableau.
constexpr bool empty() const noexcept
Retourne true si le tableau est vide (dimension nulle).
Interface d'une famille d'entités.
Definition IItemFamily.h:84
virtual ItemGroup createGroup(const String &name, Int32ConstArrayView local_ids, bool do_override=false)=0
Créé un groupe d'entités de nom name contenant les entités local_ids.
virtual ITraceMng * traceMng() const =0
Gestionnaire de trace associé
Interface du gestionnaire de traces.
virtual TraceMessage warning()=0
Flot pour un message d'avertissement.
virtual TraceMessage info()=0
Flot pour un message d'information.
static void createGroup(IItemFamily *family, const String &name, Int32ArrayView local_ids)
Créé un groupe d'entités.
Definition LimaUtils.cc:36
Chaîne de caractères unicode.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type représentant un entier.
ArrayView< Int32 > Int32ArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:451