Skip to content

Commit 04be222

Browse files
[arcane,materials] Conserve le localId() de l'entité globale et de l'entité consituante parente dans 'ComponenItemSharedInfo'.
1 parent b79acee commit 04be222

File tree

6 files changed

+80
-30
lines changed

6 files changed

+80
-30
lines changed

arcane/src/arcane/core/ItemInternal.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* ItemInternal.h (C) 2000-2023 */
8+
/* ItemInternal.h (C) 2000-2024 */
99
/* */
1010
/* Partie interne d'une entité. */
1111
/*---------------------------------------------------------------------------*/
@@ -58,6 +58,7 @@ class PolyhedralMeshImpl;
5858
namespace Arcane::Materials
5959
{
6060
class ComponentItemInternal;
61+
class ComponentItemSharedInfo;
6162
}
6263
namespace Arcane
6364
{
@@ -481,6 +482,7 @@ class ARCANE_CORE_EXPORT ItemBase
481482
friend class ::Arcane::Item;
482483
friend class ::Arcane::ItemInternalCompatibility;
483484
friend class ::Arcane::Materials::ComponentItemInternal;
485+
friend class ::Arcane::Materials::ComponentItemSharedInfo;
484486
friend MutableItemBase;
485487

486488
private:

arcane/src/arcane/core/materials/ComponentItemInternal.h

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ class ARCANE_CORE_EXPORT ComponentItemSharedInfoStorageView
9292
Int16* m_component_id_data = nullptr;
9393
//! Nombre d'entités sous-constituant
9494
Int16* m_nb_sub_constituent_item_data = nullptr;
95+
//! localId() de l'entité globale associée
96+
Int32* m_global_item_local_id_data = nullptr;
97+
//! Id de l'entité sous-constituant parente
98+
ComponentItemInternalLocalId* m_super_component_item_local_id_data = nullptr;
9599
};
96100

97101
/*---------------------------------------------------------------------------*/
@@ -132,6 +136,12 @@ class ARCANE_CORE_EXPORT ComponentItemSharedInfo
132136
ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
133137
return m_first_sub_constituent_item_id_data[id.localId()];
134138
}
139+
inline ARCCORE_HOST_DEVICE void
140+
_setFirstSubConstituentLocalId(ComponentItemInternalLocalId id, ComponentItemInternalLocalId first_id)
141+
{
142+
ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
143+
m_first_sub_constituent_item_id_data[id.localId()] = first_id;
144+
}
135145
inline ARCCORE_HOST_DEVICE Int16 _nbSubConstituent(ComponentItemInternalLocalId id) const
136146
{
137147
ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
@@ -152,17 +162,26 @@ class ARCANE_CORE_EXPORT ComponentItemSharedInfo
152162
ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
153163
m_component_id_data[id.localId()] = component_id;
154164
}
155-
156-
inline ARCCORE_HOST_DEVICE void
157-
_setFirstSubConstituentLocalId(ComponentItemInternalLocalId id, ComponentItemInternalLocalId first_id)
165+
IMeshComponent* _component(ComponentItemInternalLocalId id) const
166+
{
167+
return m_components[_componentId(id)];
168+
}
169+
impl::ItemBase _globalItemBase(ComponentItemInternalLocalId id) const
158170
{
159171
ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
160-
m_first_sub_constituent_item_id_data[id.localId()] = first_id;
172+
return impl::ItemBase(m_global_item_local_id_data[id.localId()], m_item_shared_info);
173+
}
174+
void _setGlobalItem(ComponentItemInternalLocalId id, ItemLocalId global_item_lid)
175+
{
176+
ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
177+
m_global_item_local_id_data[id.localId()] = global_item_lid.localId();
161178
}
179+
matimpl::ConstituentItemBase _superItemBase(ComponentItemInternalLocalId id) const;
162180

163-
IMeshComponent* _component(ComponentItemInternalLocalId id) const
181+
ARCCORE_HOST_DEVICE void _setSuperItem(ComponentItemInternalLocalId id, ComponentItemInternalLocalId super_id)
164182
{
165-
return m_components[_componentId(id)];
183+
ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
184+
m_super_component_item_local_id_data[id.localId()] = super_id;
166185
}
167186

168187
inline void _reset(ComponentItemInternalLocalId id)
@@ -173,6 +192,8 @@ class ARCANE_CORE_EXPORT ComponentItemSharedInfo
173192
m_first_sub_constituent_item_id_data[local_id] = {};
174193
m_nb_sub_constituent_item_data[local_id] = 0;
175194
m_component_id_data[local_id] = -1;
195+
m_global_item_local_id_data[local_id] = NULL_ITEM_LOCAL_ID;
196+
m_super_component_item_local_id_data[local_id] = {};
176197
}
177198

178199
private:
@@ -398,7 +419,7 @@ class ARCANE_CORE_EXPORT ComponentItemInternal
398419
//! Entité globale correspondante.
399420
impl::ItemBase globalItemBase() const
400421
{
401-
return impl::ItemBase(m_global_item_local_id, m_shared_info->m_item_shared_info);
422+
return m_shared_info->_globalItemBase(m_component_item_internal_local_id);
402423
}
403424

404425
ARCCORE_HOST_DEVICE constexpr Int32 level() const { return m_shared_info->m_level; }
@@ -417,9 +438,7 @@ class ARCANE_CORE_EXPORT ComponentItemInternal
417438
// Toute modification de la structure interne doit être reportée
418439
// dans la structure C# correspondante
419440
MatVarIndex m_var_index;
420-
Int32 m_global_item_local_id = NULL_ITEM_LOCAL_ID;
421441
ComponentItemInternalLocalId m_component_item_internal_local_id;
422-
ComponentItemInternalLocalId m_super_component_item_local_id;
423442
ComponentItemSharedInfo* m_shared_info = nullptr;
424443

425444
private:
@@ -448,11 +467,10 @@ class ARCANE_CORE_EXPORT ComponentItemInternal
448467

449468
void _reset(ComponentItemInternalLocalId id, ComponentItemSharedInfo* shared_info)
450469
{
451-
m_var_index.reset();
452-
m_super_component_item_local_id = {};
453470
m_component_item_internal_local_id = id;
454-
m_global_item_local_id = NULL_ITEM_LOCAL_ID;
455471
m_shared_info = shared_info;
472+
473+
m_var_index.reset();
456474
m_shared_info->_reset(id);
457475
}
458476
};
@@ -466,12 +484,6 @@ _itemInternal(ComponentItemInternalLocalId id)
466484
return m_component_item_internal_view.ptrAt(id.localId());
467485
}
468486

469-
inline constexpr matimpl::ConstituentItemBase ComponentItemSharedInfo::
470-
_item(ComponentItemInternalLocalId id)
471-
{
472-
return matimpl::ConstituentItemBase(m_component_item_internal_view.ptrAt(id.localId()));
473-
}
474-
475487
/*---------------------------------------------------------------------------*/
476488
/*---------------------------------------------------------------------------*/
477489

@@ -496,6 +508,23 @@ _localId() const
496508
/*---------------------------------------------------------------------------*/
497509
/*---------------------------------------------------------------------------*/
498510

511+
inline constexpr matimpl::ConstituentItemBase ComponentItemSharedInfo::
512+
_item(ComponentItemInternalLocalId id)
513+
{
514+
return matimpl::ConstituentItemBase(m_component_item_internal_view.ptrAt(id.localId()));
515+
}
516+
517+
inline matimpl::ConstituentItemBase ComponentItemSharedInfo::
518+
_superItemBase(ComponentItemInternalLocalId id) const
519+
{
520+
ARCCORE_CHECK_RANGE(id.localId(), -1, m_storage_size);
521+
ComponentItemInternalLocalId super_local_id(m_super_component_item_local_id_data[id.localId()]);
522+
return m_super_component_item_shared_info->_item(super_local_id);
523+
}
524+
525+
/*---------------------------------------------------------------------------*/
526+
/*---------------------------------------------------------------------------*/
527+
499528
inline ARCCORE_HOST_DEVICE matimpl::ConstituentItemBase ComponentItemInternal::
500529
_subItemBase(Int32 i) const
501530
{
@@ -506,8 +535,7 @@ _subItemBase(Int32 i) const
506535
matimpl::ConstituentItemBase ComponentItemInternal::
507536
_superItemBase() const
508537
{
509-
ComponentItemInternalLocalId lid(m_super_component_item_local_id.localId());
510-
return m_shared_info->m_super_component_item_shared_info->_item(lid);
538+
return m_shared_info->_superItemBase(m_component_item_internal_local_id);
511539
}
512540

513541
/*---------------------------------------------------------------------------*/
@@ -576,14 +604,14 @@ _superItemBase() const
576604
inline void matimpl::ConstituentItemBase::
577605
_setSuperAndGlobalItem(ComponentItemInternalLocalId cii, ItemLocalId ii)
578606
{
579-
m_component_item->m_super_component_item_local_id = cii;
580-
m_component_item->m_global_item_local_id = ii.localId();
607+
_sharedInfo()->_setSuperItem(_localId(), cii);
608+
_sharedInfo()->_setGlobalItem(_localId(), ii);
581609
}
582610

583611
inline void matimpl::ConstituentItemBase::
584612
_setGlobalItem(ItemLocalId ii)
585613
{
586-
m_component_item->m_global_item_local_id = ii.localId();
614+
_sharedInfo()->_setGlobalItem(_localId(), ii);
587615
}
588616

589617
//! Première entité sous-composant.

arcane/src/arcane/materials/ComponentItemInternalData.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ namespace Arcane::Materials
3232
ComponentItemInternalData::Storage::
3333
Storage(const MemoryAllocationOptions& alloc_info)
3434
: m_first_sub_constituent_item_id_list(alloc_info)
35+
, m_super_component_item_local_id_list(alloc_info)
3536
, m_component_id_list(alloc_info)
3637
, m_nb_sub_constituent_item_list(alloc_info)
38+
, m_global_item_local_id_list(alloc_info)
3739
{
3840
}
3941

@@ -50,16 +52,24 @@ resize(Int32 new_size, ComponentItemSharedInfo* shared_info)
5052
m_first_sub_constituent_item_id_list.resize(true_size);
5153
m_first_sub_constituent_item_id_list[0] = {};
5254

55+
m_super_component_item_local_id_list.resize(true_size);
56+
m_super_component_item_local_id_list[0] = {};
57+
5358
m_component_id_list.resize(true_size);
5459
m_component_id_list[0] = -1;
5560

5661
m_nb_sub_constituent_item_list.resize(true_size);
5762
m_nb_sub_constituent_item_list[0] = 0;
5863

64+
m_global_item_local_id_list.resize(true_size);
65+
m_global_item_local_id_list[0] = NULL_ITEM_LOCAL_ID;
66+
5967
shared_info->m_storage_size = new_size;
6068
shared_info->m_first_sub_constituent_item_id_data = m_first_sub_constituent_item_id_list.data() + 1;
69+
shared_info->m_super_component_item_local_id_data = m_super_component_item_local_id_list.data() + 1;
6170
shared_info->m_component_id_data = m_component_id_list.data() + 1;
6271
shared_info->m_nb_sub_constituent_item_data = m_nb_sub_constituent_item_list.data() + 1;
72+
shared_info->m_global_item_local_id_data = m_global_item_local_id_list.data() + 1;
6373
}
6474

6575
/*---------------------------------------------------------------------------*/

arcane/src/arcane/materials/internal/ComponentItemInternalData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ class ComponentItemInternalData
128128
private:
129129

130130
UniqueArray<ComponentItemInternalLocalId> m_first_sub_constituent_item_id_list;
131+
UniqueArray<ComponentItemInternalLocalId> m_super_component_item_local_id_list;
131132
UniqueArray<Int16> m_component_id_list;
132133
UniqueArray<Int16> m_nb_sub_constituent_item_list;
134+
UniqueArray<Int32> m_global_item_local_id_list;
133135
};
134136

135137
public:

arcane/tools/wrapper/materials/csharp/ComponentItem.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public ComponentItemInternal* Internal
2222
set { m_internal = value; }
2323
}
2424

25-
public Cell GlobalCell { get { return new Cell(m_internal->m_shared_info->m_item_shared_info->m_items_internal[m_internal->m_global_item_local_id]); } }
25+
public Cell GlobalCell { get { return m_internal->m_shared_info->GlobalCell(m_internal->m_component_item_internal_local_id); } }
2626
public MatVarIndex MatVarIndex { get { return m_internal->m_var_index; } }
2727
internal int _matvarArrayIndex { get { return m_internal->m_var_index.ArrayIndex; } }
2828
internal int _matvarValueIndex { get { return m_internal->m_var_index.ValueIndex; } }
@@ -45,7 +45,7 @@ public ComponentItemInternal* Internal
4545
get { return m_internal; }
4646
set { m_internal = value; }
4747
}
48-
public Cell GlobalCell { get { return new Cell(m_internal->m_shared_info->m_item_shared_info->m_items_internal[m_internal->m_global_item_local_id]); } }
48+
public Cell GlobalCell { get { return m_internal->m_shared_info->GlobalCell(m_internal->m_component_item_internal_local_id); } }
4949
public MatVarIndex MatVarIndex { get { return m_internal->m_var_index; } }
5050
internal int _matvarArrayIndex { get { return m_internal->m_var_index.ArrayIndex; } }
5151
internal int _matvarValueIndex { get { return m_internal->m_var_index.ValueIndex; } }
@@ -66,7 +66,7 @@ public ComponentItemInternal* Internal
6666
set { m_internal = value; }
6767
}
6868

69-
public Cell GlobalCell { get { return new Cell(m_internal->m_shared_info->m_item_shared_info->m_items_internal[m_internal->m_global_item_local_id]); } }
69+
public Cell GlobalCell { get { return m_internal->m_shared_info->GlobalCell(m_internal->m_component_item_internal_local_id); } }
7070
public MatVarIndex MatVarIndex { get { return m_internal->m_var_index; } }
7171
internal int _matvarArrayIndex { get { return m_internal->m_var_index.ArrayIndex; } }
7272
internal int _matvarValueIndex { get { return m_internal->m_var_index.ValueIndex; } }

arcane/tools/wrapper/materials/csharp/ComponentItemInternal.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public unsafe struct ComponentItemSharedInfo
1111
Int32* m_first_sub_constituent_item_id_data;
1212
Int16* m_component_id_data;
1313
Int16* m_nb_sub_constituent_item_data;
14+
Int32* m_global_item_local_id_data;
15+
Int32* m_super_component_item_local_id_data;
1416

1517
// Structure de la classe C++ ComponentItemSharedInfo
1618
internal ItemSharedInfo* m_item_shared_info;
@@ -19,6 +21,12 @@ public unsafe struct ComponentItemSharedInfo
1921
internal ComponentItemSharedInfo* m_super_component_item_shared_info;
2022
internal ComponentItemSharedInfo* m_sub_component_item_shared_info;
2123
internal ComponentItemInternalConstArrayView m_component_item_internal_view;
24+
25+
internal Cell GlobalCell(Int32 constituent_local_id)
26+
{
27+
Int32 global_local_id = m_global_item_local_id_data[constituent_local_id];
28+
return new Cell(m_item_shared_info->m_items_internal[global_local_id]);
29+
}
2230
}
2331

2432
[StructLayout(LayoutKind.Sequential)]
@@ -27,9 +35,9 @@ public unsafe struct ComponentItemInternal
2735
internal MatVarIndex m_var_index;
2836
//internal Int16 m_component_id;
2937
//internal Int16 m_nb_sub_component_item;
30-
internal Int32 m_global_item_local_id;
38+
//internal Int32 m_global_item_local_id;
3139
internal Int32 m_component_item_internal_local_id;
32-
internal Int32 m_super_component_item_local_id;
40+
//internal Int32 m_super_component_item_local_id;
3341
//internal Int32 m_first_sub_component_item_local_id;
3442
internal ComponentItemSharedInfo* m_shared_info;
3543
}

0 commit comments

Comments
 (0)