Arcane  v3.16.0.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ItemInternal.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* ItemInternal.cc (C) 2000-2025 */
9/* */
10/* Partie interne d'une entité. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/ItemInternal.h"
15
16#include "arcane/utils/NotImplementedException.h"
17#include "arcane/utils/FatalErrorException.h"
18#include "arcane/utils/Iostream.h"
19#include "arcane/utils/TraceInfo.h"
20#include "arcane/utils/CheckedConvert.h"
21
22#include "arcane/core/IItemFamily.h"
23#include "arcane/core/IItemFamilyTopologyModifier.h"
24#include "arcane/core/ItemPrinter.h"
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Arcane
30{
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
35ItemInternalConnectivityList ItemInternalConnectivityList::nullInstance;
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
40void impl::MutableItemBase::
41_checkUniqueId(Int64 new_uid) const
42{
43 if (new_uid<0){
44 ARCANE_FATAL("Bad unique id - new_uid={0} local_id={1} current={2}",
45 new_uid,m_local_id,uniqueId().asInt64());
46 }
47}
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
51
54{
55#ifdef ARCANE_CHECK
56 _checkUniqueId(m_shared_info->m_unique_ids[m_local_id]);
57#endif
58 m_shared_info->m_unique_ids[m_local_id] = NULL_ITEM_UNIQUE_ID;
59}
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64Int32 ItemUniqueId::
65asInt32() const
66{
67 if (m_unique_id>2147483647)
68 ARCANE_FATAL("Unique id is too big to be converted to a Int32");
69 return (Int32)(m_unique_id);
70}
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
75ItemTypeId ItemTypeId::
77{
79 return ItemTypeId{x};
80}
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
85Int32 impl::ItemBase::
86_nbLinearNode() const
87{
88 ItemTypeInfo* iti = typeInfo();
89 Int16 linear_type_id = iti->linearTypeId();
90 ItemTypeInfo* linear_iti = m_shared_info->typeInfoFromId(linear_type_id);
91 Int32 nb_linear_node = linear_iti->nbLocalNode();
92 return std::min(nbNode(), nb_linear_node);
93}
94
95/*---------------------------------------------------------------------------*/
96/*---------------------------------------------------------------------------*/
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101std::ostream&
102operator<<(std::ostream& o,const ItemUniqueId& id)
103{
104 o << id.asInt64();
105 return o;
106}
107
108//! AMR
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
113topHParent() const
114{
115 const ItemInternal* top_it = this;
116 while (top_it->nbHParent())
117 top_it = top_it->_internalHParent(0);
118 ARCANE_ASSERT((!top_it->null()),("topHParent Problem!"));
119 ARCANE_ASSERT((top_it->level() == 0),("topHParent Problem"));
120 return top_it;
121}
122
123/*---------------------------------------------------------------------------*/
124/*---------------------------------------------------------------------------*/
125
126impl::ItemBase impl::ItemBase::
127topHParentBase() const
128{
129 ItemBase top_it = *this;
130 while (top_it.nbHParent())
131 top_it = top_it.hParentBase(0);
132 ARCANE_ASSERT((!top_it.null()),("topHParent Problem!"));
133 ARCANE_ASSERT((top_it.level() == 0),("topHParent Problem"));
134 return top_it;
135}
136
137/*---------------------------------------------------------------------------*/
138/*---------------------------------------------------------------------------*/
139
140ItemInternal* ItemInternal::
142{
143 ItemInternal* top_it = this;
144 while (top_it->nbHParent())
145 top_it = top_it->_internalHParent(0);
146 ARCANE_ASSERT((!top_it->null()),("topHParent Problem!"));
147 ARCANE_ASSERT((top_it->level() == 0),("topHParent Problem"));
148 return top_it;
149}
150
151/*---------------------------------------------------------------------------*/
152/*---------------------------------------------------------------------------*/
153
155whichChildAmI(Int32 local_id) const
156{
157 ARCANE_ASSERT((this->hasHChildren()), ("item has non-child!"));
158 for (Integer c=0; c<this->nbHChildren(); c++)
159 if (this->hChildId(c) == local_id)
160 return c;
161 return -1;
162}
163
164/*---------------------------------------------------------------------------*/
165/*---------------------------------------------------------------------------*/
166
168whichChildAmI(const ItemInternal *iitem) const
169{
170 ARCANE_ASSERT((this->hasHChildren()), ("item has non-child!"));
171 for (Integer c=0; c<this->nbHChildren(); c++)
172 if (this->_internalHChild(c) == iitem)
173 return c;
174 return -1;
175}
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
179
180ItemInternalVectorView impl::ItemBase::
181_internalActiveCells2(Int32Array& local_ids) const
182{
183 const Integer nbcell = this->nbCell();
184 for(Integer icell = 0 ; icell < nbcell ; ++icell) {
185 ItemBase cell = this->cellBase(icell);
186 if (cell.isActive()){
187 const Int32 local_id = cell.localId();
188 local_ids.add(local_id);
189 }
190 }
191 return ItemInternalVectorView(m_shared_info->m_items->m_cell_shared_info,local_ids,0);
192}
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
196
197void impl::MutableItemBase::
198_setFaceInfos(Int32 mod_flags)
199{
200 Int32 face_flags = flags();
201 face_flags &= ~II_InterfaceFlags;
202 face_flags |= mod_flags;
203 setFlags(face_flags);
204}
205
206/*---------------------------------------------------------------------------*/
207/*---------------------------------------------------------------------------*/
208/*!
209 * \brief Pour une face, positionne à la fois la back cell et la front cell.
210 *
211 * \a back_cell_lid et/ou \a front_cell_lid peuvent valoir NULL_ITEM_LOCAL_ID
212 * ce qui signifie que l'entité n'a pas de back cell ou front cell. Si les
213 * deux valeurs sont nulles, alors la face est considérée comme n'ayant
214 * plus de mailles connectées.
215 *
216 * \note Cette méthode est utilisée uniquement par FaceFamily.
217 */
218void impl::MutableItemBase::
219_setFaceBackAndFrontCells(Int32 back_cell_lid,Int32 front_cell_lid)
220{
221 if (front_cell_lid==NULL_ITEM_LOCAL_ID){
222 // Reste uniquement la back_cell ou aucune maille.
223 Int32 mod_flags = (back_cell_lid!=NULL_ITEM_LOCAL_ID) ? (II_Boundary | II_HasBackCell | II_BackCellIsFirst) : 0;
224 _setFaceInfos(mod_flags);
225 }
226 else if (back_cell_lid==NULL_ITEM_LOCAL_ID){
227 // Reste uniquement la front cell
229 }
230 else{
231 // Il y a deux mailles connectées.
233 }
234}
235
236/*---------------------------------------------------------------------------*/
237/*---------------------------------------------------------------------------*/
238
239void ItemInternal::
240setDataIndex(Integer)
241{
242 ARCANE_FATAL("This method is no longer valid");
243}
244
245/*---------------------------------------------------------------------------*/
246/*---------------------------------------------------------------------------*/
247
248/*---------------------------------------------------------------------------*/
249/*---------------------------------------------------------------------------*/
250
251bool ItemInternalVectorView::
252_isValid()
253{
254 if (!m_shared_info)
255 ARCANE_FATAL("Null ItemSharedInfo");
256 if (!m_local_ids.empty()){
257 auto* items_data = _items().data();
258 if (!items_data)
259 ARCANE_FATAL("Null ItemsInternal list");
260 }
261 return true;
262}
263
264/*---------------------------------------------------------------------------*/
265/*---------------------------------------------------------------------------*/
266
267} // End namespace Arcane
268
269/*---------------------------------------------------------------------------*/
270/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Classe de base pour les entités du maillage.
ItemUniqueId uniqueId() const
Numéro unique de l'entité
Integer nbCell() const
Nombre de mailles connectées à l'entité (pour les noeuds, arêtes et faces)
bool isActive() const
Int32 level() const
Int32 flags() const
Flags de l'entité
ItemTypeInfo * typeInfo() const
Type de l'entité.
Int32 nbHParent() const
Nombre de parents pour l'AMR.
bool hasHChildren() const
Int32 whichChildAmI(Int32 local_id) const
Int32 nbHChildren() const
Nombre d'enfants pour l'AMR.
Integer nbNode() const
Nombre de noeuds de l'entité
bool null() const
Vrai si l'entité est l'entité nulle.
Int32 localId() const
Numéro local (au sous-domaine) de l'entité
@ II_FrontCellIsFirst
La première maille de l'entité est la maille devant.
Definition ItemFlags.h:46
@ II_HasBackCell
L'entité a une maille derrière.
Definition ItemFlags.h:45
@ II_Boundary
L'entité est sur la frontière.
Definition ItemFlags.h:43
@ II_HasFrontCell
L'entité a une maille devant.
Definition ItemFlags.h:44
@ II_BackCellIsFirst
La première maille de l'entité est la maille derrière.
Definition ItemFlags.h:47
Int32 whichChildAmI(const ItemInternal *iitem) const
const ItemInternal * topHParent() const
AMR.
static ItemTypeId fromInteger(Int64 v)
Créé une instance à partir d'un entier.
Infos sur un type d'entité du maillage.
Integer nbLocalNode() const
Nombre de noeuds de l'entité
Int16 linearTypeId() const
Type de l'élément linéaire correspondant.
void setFlags(Int32 f)
Positionne les flags de l'entité
void unsetUniqueId()
Annule l'uniqueId a la valeur NULL_ITEM_UNIQUE_ID.
Int16 toInt16(Int64 v)
Converti un Int64 en un Int16.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
std::int16_t Int16
Type entier signé sur 16 bits.
Array< Int32 > Int32Array
Tableau dynamique à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:214
std::ostream & operator<<(std::ostream &ostr, eItemKind item_kind)
Opérateur de sortie sur un flot.
std::int32_t Int32
Type entier signé sur 32 bits.