Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
AbstractItemFamilyTopologyModifier.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/* AbstractItemFamilyTopologyModifier.cc (C) 2000-2023 */
9/* */
10/* Modification of the topology of entities in a family. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/NotSupportedException.h"
15#include "arcane/utils/FatalErrorException.h"
16
17#include "arcane/core/IItemFamily.h"
18#include "arcane/core/Item.h"
19#include "arcane/core/ItemInfoListView.h"
20
21#include "arcane/mesh/AbstractItemFamilyTopologyModifier.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::mesh
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32AbstractItemFamilyTopologyModifier::
33AbstractItemFamilyTopologyModifier(IItemFamily* afamily)
34: TraceAccessor(afamily->traceMng())
35, m_family(afamily)
36{
37}
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
42IItemFamily* AbstractItemFamilyTopologyModifier::
43family() const
44{
45 return m_family;
46}
47
48/*---------------------------------------------------------------------------*/
49/*---------------------------------------------------------------------------*/
54inline Integer AbstractItemFamilyTopologyModifier::
55_getItemIndex(const Int32* items, Integer nb_item, Int32 local_id)
56{
57 for (Integer i = 0; i < nb_item; ++i)
58 if (items[i] == local_id)
59 return i;
60 ARCANE_FATAL("Can not find item to replace local_id={0}", local_id);
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66inline Integer AbstractItemFamilyTopologyModifier::
67_getItemIndex(ItemVectorView items, Int32 local_id)
68{
69 return _getItemIndex(items.localIds().data(), items.size(), local_id);
70}
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
75void AbstractItemFamilyTopologyModifier::
76_throwNotSupported()
77{
78 ARCANE_THROW(NotSupportedException, "Connectivity modification not supported for family name={0}",
79 m_family->name());
80}
81
82/*---------------------------------------------------------------------------*/
83/*---------------------------------------------------------------------------*/
84
85void AbstractItemFamilyTopologyModifier::
86replaceNode(ItemLocalId item_lid, Integer index, ItemLocalId new_node_lid)
87{
88 ARCANE_UNUSED(item_lid);
89 ARCANE_UNUSED(index);
90 ARCANE_UNUSED(new_node_lid);
91 _throwNotSupported();
92}
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97void AbstractItemFamilyTopologyModifier::
98replaceEdge(ItemLocalId item_lid, Integer index, ItemLocalId new_edge_lid)
99{
100 ARCANE_UNUSED(item_lid);
101 ARCANE_UNUSED(index);
102 ARCANE_UNUSED(new_edge_lid);
103 _throwNotSupported();
104}
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
109void AbstractItemFamilyTopologyModifier::
110replaceFace(ItemLocalId item_lid, Integer index, ItemLocalId new_face_lid)
111{
112 ARCANE_UNUSED(item_lid);
113 ARCANE_UNUSED(index);
114 ARCANE_UNUSED(new_face_lid);
115 _throwNotSupported();
116}
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
121void AbstractItemFamilyTopologyModifier::
122replaceCell(ItemLocalId item_lid, Integer index, ItemLocalId new_cell_lid)
123{
124 ARCANE_UNUSED(item_lid);
125 ARCANE_UNUSED(index);
126 ARCANE_UNUSED(new_cell_lid);
127 _throwNotSupported();
128}
129
130/*---------------------------------------------------------------------------*/
131/*---------------------------------------------------------------------------*/
132
133void AbstractItemFamilyTopologyModifier::
134replaceHParent(ItemLocalId item_lid, Integer index, ItemLocalId new_hparent_lid)
135{
136 ARCANE_UNUSED(item_lid);
137 ARCANE_UNUSED(index);
138 ARCANE_UNUSED(new_hparent_lid);
139 _throwNotSupported();
140}
141
142/*---------------------------------------------------------------------------*/
143/*---------------------------------------------------------------------------*/
144
145void AbstractItemFamilyTopologyModifier::
146replaceHChild(ItemLocalId item_lid, Integer index, ItemLocalId new_hchild_lid)
147{
148 ARCANE_UNUSED(item_lid);
149 ARCANE_UNUSED(index);
150 ARCANE_UNUSED(new_hchild_lid);
151 _throwNotSupported();
152}
153
154/*---------------------------------------------------------------------------*/
155/*---------------------------------------------------------------------------*/
156
157void AbstractItemFamilyTopologyModifier::
158findAndReplaceNode(ItemLocalId item_lid, ItemLocalId old_node_lid,
159 ItemLocalId new_node_lid)
160{
161 impl::ItemBase ii = m_family->itemInfoListView()[item_lid].itemBase();
162 Int32 index = _getItemIndex(ii.nodeList(), old_node_lid);
163 this->replaceNode(ii.itemLocalId(), index, new_node_lid);
164}
165
166/*---------------------------------------------------------------------------*/
167/*---------------------------------------------------------------------------*/
168
169void AbstractItemFamilyTopologyModifier::
170findAndReplaceEdge(ItemLocalId item_lid, ItemLocalId old_edge_lid,
171 ItemLocalId new_edge_lid)
172{
173 impl::ItemBase ii = m_family->itemInfoListView()[item_lid].itemBase();
174 Int32 index = _getItemIndex(ii.edgeList(), old_edge_lid);
175 this->replaceEdge(ii.itemLocalId(), index, new_edge_lid);
176}
177
178/*---------------------------------------------------------------------------*/
179/*---------------------------------------------------------------------------*/
180
181void AbstractItemFamilyTopologyModifier::
182findAndReplaceFace(ItemLocalId item_lid, ItemLocalId old_face_lid,
183 ItemLocalId new_face_lid)
184{
185 impl::ItemBase ii = m_family->itemInfoListView()[item_lid].itemBase();
186 Int32 index = _getItemIndex(ii.faceList(), old_face_lid);
187 this->replaceFace(ii.itemLocalId(), index, new_face_lid);
188}
189
190/*---------------------------------------------------------------------------*/
191/*---------------------------------------------------------------------------*/
192
193void AbstractItemFamilyTopologyModifier::
194findAndReplaceCell(ItemLocalId item_lid, ItemLocalId old_cell_lid,
195 ItemLocalId new_cell_lid)
196{
197 impl::ItemBase ii = m_family->itemInfoListView()[item_lid].itemBase();
198 Int32 index = _getItemIndex(ii.cellList(), old_cell_lid);
199 this->replaceCell(ii.itemLocalId(), index, new_cell_lid);
200}
201
202/*---------------------------------------------------------------------------*/
203/*---------------------------------------------------------------------------*/
204
205} // namespace Arcane::mesh
206
207/*---------------------------------------------------------------------------*/
208/*---------------------------------------------------------------------------*/
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
constexpr const_pointer data() const noexcept
Pointer to the allocated memory.
const String & name() const
Name of the exception.
Interface of an entity family.
Definition IItemFamily.h:83
ItemLocalId itemLocalId() const
Local number (in the subdomain) of the entity.
impl::ItemIndexedListView< DynExtent > nodeList() const
Methods using the new connectivities to access connectivity information. Should not be used outside o...
Index of an Item in a variable.
Definition ItemLocalId.h:42
View on a vector of entities.
Int32 size() const
Number of elements in the vector.
Int32ConstArrayView localIds() const
Array of local IDs of entities.
void replaceNode(ItemLocalId item_lid, Integer index, ItemLocalId new_node_lid) override
Replaces a node of an entity.
Int32 _getItemIndex(const Int32 *items, Integer nb_item, Int32 local_id)
Searches for the index of the entity with localid() local_id in the list items.
void replaceEdge(ItemLocalId item_lid, Integer index, ItemLocalId new_edge_lid) override
Replaces an edge of an entity.
void replaceCell(ItemLocalId item_lid, Integer index, ItemLocalId new_cell_lid) override
Replaces a cell of an entity.
void replaceFace(ItemLocalId item_lid, Integer index, ItemLocalId new_face_lid) override
Replaces a face of an entity.
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.