Arcane  v3.15.3.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-2024 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-2024 */
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
76fromInteger(Int64 v)
77{
78 Int16 x = CheckedConvert::toInt16(v);
79 return ItemTypeId{x};
80}
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
85std::ostream&
86operator<<(std::ostream& o,const ItemUniqueId& id)
87{
88 o << id.asInt64();
89 return o;
90}
91
92//! AMR
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
95
97topHParent() const
98{
99 const ItemInternal* top_it = this;
100 while (top_it->nbHParent())
101 top_it = top_it->_internalHParent(0);
102 ARCANE_ASSERT((!top_it->null()),("topHParent Problem!"));
103 ARCANE_ASSERT((top_it->level() == 0),("topHParent Problem"));
104 return top_it;
105}
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
109
110impl::ItemBase impl::ItemBase::
111topHParentBase() const
112{
113 ItemBase top_it = *this;
114 while (top_it.nbHParent())
115 top_it = top_it.hParentBase(0);
116 ARCANE_ASSERT((!top_it.null()),("topHParent Problem!"));
117 ARCANE_ASSERT((top_it.level() == 0),("topHParent Problem"));
118 return top_it;
119}
120
121/*---------------------------------------------------------------------------*/
122/*---------------------------------------------------------------------------*/
123
124ItemInternal* ItemInternal::
126{
127 ItemInternal* top_it = this;
128 while (top_it->nbHParent())
129 top_it = top_it->_internalHParent(0);
130 ARCANE_ASSERT((!top_it->null()),("topHParent Problem!"));
131 ARCANE_ASSERT((top_it->level() == 0),("topHParent Problem"));
132 return top_it;
133}
134
135/*---------------------------------------------------------------------------*/
136/*---------------------------------------------------------------------------*/
137
139whichChildAmI(Int32 local_id) const
140{
141 ARCANE_ASSERT((this->hasHChildren()), ("item has non-child!"));
142 for (Integer c=0; c<this->nbHChildren(); c++)
143 if (this->hChildId(c) == local_id)
144 return c;
145 return -1;
146}
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
150
152whichChildAmI(const ItemInternal *iitem) const
153{
154 ARCANE_ASSERT((this->hasHChildren()), ("item has non-child!"));
155 for (Integer c=0; c<this->nbHChildren(); c++)
156 if (this->_internalHChild(c) == iitem)
157 return c;
158 return -1;
159}
160
161/*---------------------------------------------------------------------------*/
162/*---------------------------------------------------------------------------*/
163
164ItemInternalVectorView impl::ItemBase::
165_internalActiveCells2(Int32Array& local_ids) const
166{
167 const Integer nbcell = this->nbCell();
168 for(Integer icell = 0 ; icell < nbcell ; ++icell) {
169 ItemBase cell = this->cellBase(icell);
170 if (cell.isActive()){
171 const Int32 local_id = cell.localId();
172 local_ids.add(local_id);
173 }
174 }
175 return ItemInternalVectorView(m_shared_info->m_items->m_cell_shared_info,local_ids,0);
176}
177
178/*---------------------------------------------------------------------------*/
179/*---------------------------------------------------------------------------*/
180
181void impl::MutableItemBase::
182_setFaceInfos(Int32 mod_flags)
183{
184 Int32 face_flags = flags();
185 face_flags &= ~II_InterfaceFlags;
186 face_flags |= mod_flags;
187 setFlags(face_flags);
188}
189
190/*---------------------------------------------------------------------------*/
191/*---------------------------------------------------------------------------*/
192/*!
193 * \brief Pour une face, positionne à la fois la back cell et la front cell.
194 *
195 * \a back_cell_lid et/ou \a front_cell_lid peuvent valoir NULL_ITEM_LOCAL_ID
196 * ce qui signifie que l'entité n'a pas de back cell ou front cell. Si les
197 * deux valeurs sont nulles, alors la face est considérée comme n'ayant
198 * plus de mailles connectées.
199 *
200 * \note Cette méthode est utilisée uniquement par FaceFamily.
201 */
202void impl::MutableItemBase::
203_setFaceBackAndFrontCells(Int32 back_cell_lid,Int32 front_cell_lid)
204{
205 if (front_cell_lid==NULL_ITEM_LOCAL_ID){
206 // Reste uniquement la back_cell ou aucune maille.
207 Int32 mod_flags = (back_cell_lid!=NULL_ITEM_LOCAL_ID) ? (II_Boundary | II_HasBackCell | II_BackCellIsFirst) : 0;
208 _setFaceInfos(mod_flags);
209 }
210 else if (back_cell_lid==NULL_ITEM_LOCAL_ID){
211 // Reste uniquement la front cell
213 }
214 else{
215 // Il y a deux mailles connectées.
217 }
218}
219
220/*---------------------------------------------------------------------------*/
221/*---------------------------------------------------------------------------*/
222
223void ItemInternal::
224setDataIndex(Integer)
225{
226 ARCANE_FATAL("This method is no longer valid");
227}
228
229/*---------------------------------------------------------------------------*/
230/*---------------------------------------------------------------------------*/
231
232/*---------------------------------------------------------------------------*/
233/*---------------------------------------------------------------------------*/
234
235bool ItemInternalVectorView::
236_isValid()
237{
238 if (!m_shared_info)
239 ARCANE_FATAL("Null ItemSharedInfo");
240 if (!m_local_ids.empty()){
241 auto* items_data = _items().data();
242 if (!items_data)
243 ARCANE_FATAL("Null ItemsInternal list");
244 }
245 return true;
246}
247
248/*---------------------------------------------------------------------------*/
249/*---------------------------------------------------------------------------*/
250
251} // End namespace Arcane
252
253/*---------------------------------------------------------------------------*/
254/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
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 flags() const
Flags de l'entité
bool hasHChildren() const
Int32 whichChildAmI(Int32 local_id) const
Int32 nbHChildren() const
Nombre d'enfants pour l'AMR.
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.
Type d'une entité (Item).
Definition ItemTypeId.h:32
static ItemTypeId fromInteger(Int64 v)
Créé une instance à partir d'un entier.
Identifiant unique d'une entité.
void setFlags(Int32 f)
Positionne les flags de l'entité
void unsetUniqueId()
Annule l'uniqueId a la valeur NULL_ITEM_UNIQUE_ID.
Classe de base des vecteurs 1D de données.
constexpr bool empty() const noexcept
true si le tableau est vide (size()==0)
constexpr const_pointer data() const noexcept
Pointeur sur la mémoire allouée.
Référence à une instance.
Int16 toInt16(Int64 v)
Converti un Int64 en un Int16.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::ostream & operator<<(std::ostream &ostr, eItemKind item_kind)
Opérateur de sortie sur un flot.