12#ifndef ARCANE_MESH_ITEMCONNECTIVITY_H
13#define ARCANE_MESH_ITEMCONNECTIVITY_H
17#include "arcane/utils/FatalErrorException.h"
18#include "arcane/utils/ITraceMng.h"
20#include "arcane/core/IItemFamily.h"
21#include "arcane/core/ItemVector.h"
22#include "arcane/core/VariableTypes.h"
23#include "arcane/core/ItemInternal.h"
24#include "arcane/core/IItemConnectivity.h"
25#include "arcane/core/ConnectivityItemVector.h"
27#include "arcane/mesh/DoFFamily.h"
28#include "arcane/mesh/ItemProperty.h"
44class ARCANE_MESH_EXPORT AbstractConnectivity
50 : m_source_family(source_family)
51 , m_target_family(target_family)
52 , m_name(connectivity_name)
54 m_families.add(m_source_family);
55 m_families.add(m_target_family);
80 IItemFamily* _sourceFamily()
const {
return m_source_family; }
81 IItemFamily* _targetFamily()
const {
return m_target_family; }
85 IItemFamily* m_source_family;
86 IItemFamily* m_target_family;
87 SharedArray<IItemFamily*> m_families;
96class ARCANE_MESH_EXPORT ItemConnectivity
97:
public AbstractConnectivity
106 : AbstractConnectivity(source_family, target_family, aname)
112 : AbstractConnectivity(source_family, target_family, aname)
114 m_item_property.copy(item_property);
121 ARCANE_ASSERT((con_items.
accessor() ==
this), (
"Bad connectivity"));
122 return con_items.
setItem(m_item_property[item]);
128 auto apply = [
this, item](ConnectivityItemVector& civ) { this->_connectedItems(item, civ); };
129 return { set, apply };
132 virtual void updateConnectivity(Int32ConstArrayView from_items, Int32ConstArrayView to_items);
136 const Item operator()(ItemLocalId item)
const
145 if (m_item_property[item] != NULL_ITEM_LOCAL_ID)
146 return _targetFamily()->itemInfoListView()[m_item_property[item]];
150 ItemScalarProperty<Int32>& itemProperty() {
return m_item_property; }
152 void updateItemProperty(
const ItemScalarProperty<Int32>& item_property) { m_item_property.copy(item_property); }
162 ARCANE_ASSERT((index == 0), (
"Invalid value for index"))
163 return m_item_property[lid];
169 m_item_property.updateSupport(new_to_old_ids);
188template <
class FromItemType,
class ToItemType>
189class ItemConnectivityT
190:
public ItemConnectivity
194 typedef typename FromItemType::LocalIdType FromLocalIdType;
199 : ItemConnectivity(source_family, target_family, connectivity_name)
202 ItemConnectivityT(
IItemFamily* source_family,
IItemFamily* target_family,
const ItemPropertyType& item_property,
const String& connectivity_name)
203 : ItemConnectivity(source_family, target_family, item_property, connectivity_name)
208 const ToItemType operator()(FromLocalIdType item)
const
210 return ItemConnectivity::operator()(item).itemBase();
217class ARCANE_MESH_EXPORT ItemArrayConnectivity
218:
public AbstractConnectivity
227 : AbstractConnectivity(source_family, target_family,
name)
228 , m_nb_dof_per_item(nb_dof_per_item)
234 : AbstractConnectivity(source_family, target_family,
name)
235 , m_nb_dof_per_item(item_property.dim2Size())
237 m_item_property.copy(item_property);
244 return this->operator()(item, con_items);
249 return this->operator()(item);
252 virtual void updateConnectivity(Int32ConstArrayView from_items, Int32ConstArrayView to_items);
256 ItemArrayProperty<Int32>& itemProperty() {
return m_item_property; }
258 void updateItemProperty(
const ItemArrayProperty<Int32>& item_property) { m_item_property.copy(item_property); }
260 ItemVectorView operator()(ItemLocalId item, ConnectivityItemVector& con_items)
const
262 ARCANE_ASSERT((con_items.accessor() ==
this), (
"Bad connectivity"));
263 return con_items.resizeAndCopy(m_item_property[item]);
266 ConnectivityItemVectorCatalyst operator()(ItemLocalId item)
const
268 auto set = [
this](ConnectivityItemVector& civ)
mutable { civ = ConnectivityItemVector((ItemConnectivity*)
this); };
269 auto apply = [
this, item](ConnectivityItemVector& civ) { this->operator()(item, civ); };
270 return { set, apply };
276 return m_nb_dof_per_item;
281 return m_item_property[lid][index];
287 m_item_property.updateSupport(new_to_old_ids);
306template <
class FromItemType,
class ToItemType>
307class ItemArrayConnectivityT
308:
public ItemArrayConnectivity
312 typedef typename FromItemType::LocalIdType FromLocalIdType;
317 : ItemArrayConnectivity(source_family, target_family, nb_dof_per_item, connectivity_name)
320 ItemArrayConnectivityT(
IItemFamily* source_family,
IItemFamily* target_family,
const ItemPropertyType& item_property,
const String& connectivity_name)
321 : ItemArrayConnectivity(source_family, target_family, item_property, connectivity_name)
326 return ItemArrayConnectivity::operator()(item, con_items);
331 return ItemArrayConnectivity::operator()(item);
338class ARCANE_MESH_EXPORT ItemMultiArrayConnectivity
339:
public AbstractConnectivity
348 : AbstractConnectivity(source_family, target_family,
name)
350 compute(nb_dof_per_item);
354 : AbstractConnectivity(source_family, target_family,
name)
356 m_item_property.copy(item_property);
363 return this->operator()(item, con_items);
368 return this->operator()(item);
371 virtual void updateConnectivity(Int32ConstArrayView from_items, Int32ConstArrayView to_items);
375 ItemMultiArrayProperty<Int32>& itemProperty() {
return m_item_property; }
377 void updateItemProperty(ItemMultiArrayProperty<Int32>& item_property) { m_item_property.copy(item_property); }
379 ItemVectorView operator()(ItemLocalId item, ConnectivityItemVector& con_items)
const
381 ARCANE_ASSERT((con_items.accessor() ==
this), (
"Bad connectivity"));
382 return con_items.resizeAndCopy(m_item_property[item]);
385 ConnectivityItemVectorCatalyst operator()(ItemLocalId item)
const
387 auto set = [
this](ConnectivityItemVector& civ)
mutable { civ = ConnectivityItemVector((ItemConnectivity*)
this); };
388 auto apply = [
this, item](ConnectivityItemVector& civ) { this->operator()(item, civ); };
389 return { set, apply };
394 return m_item_property[lid].size();
399 return m_item_property[lid][index];
405 m_item_property.updateSupport(new_to_old_ids);
423template <
class FromItemType,
class ToItemType>
424class ItemMultiArrayConnectivityT
425:
public ItemMultiArrayConnectivity
429 typedef typename FromItemType::LocalIdType FromLocalIdType;
434 : ItemMultiArrayConnectivity(source_family, target_family, nb_dof_per_item, connectivity_name)
437 ItemMultiArrayConnectivityT(
IItemFamily* source_family,
IItemFamily* target_family,
const ItemPropertyType& item_property,
const String& connectivity_name)
438 : ItemMultiArrayConnectivity(source_family, target_family, item_property, connectivity_name)
445 return ItemMultiArrayConnectivity::operator()(item, con_items);
450 return ItemMultiArrayConnectivity::operator()(item);
virtual ConstArrayView< IItemFamily * > families() const
List of families (sourceFamily() + targetFamily()).
virtual void _initializeStorage(ConnectivityItemVector *)
Implements the initialization of civ for this connectivity.
virtual IItemFamily * sourceFamily() const
Source family.
virtual const String & name() const
Name of the connectivity.
virtual IItemFamily * targetFamily() const
Target family.
Manages the retrieval of connectivity information.
ItemVectorView setItem(Int32 id)
Positions the connectivity list with the entity of localId() id.
IItemConnectivityAccessor * accessor() const
Associated connectivity.
Constant view of an array of type T.
Interface to manage connectivity.
Interface of an entity family.
virtual void notifySourceFamilyLocalIdChanged(Int32ConstArrayView new_to_old_ids)
Notifies the connectivity that the source family has been compacted.
virtual Int32 connectedItemLocalId(ItemLocalId lid, Integer index) const
localId() of the index-th entity connected to the source entity with local ID lid
virtual Integer nbConnectedItem(ItemLocalId lid) const
Number of entities connected to the source entity with local ID lid.
virtual ItemVectorView _connectedItems(ItemLocalId item, ConnectivityItemVector &con_items) const
Fills con_items with the entities connected to item.
Item->item connectivity, exactly 1 item connected per item (0 not allowed).
virtual void notifySourceFamilyLocalIdChanged(Int32ConstArrayView new_to_old_ids)
Notifies the connectivity that the source family has been compacted.
virtual Integer nbConnectedItem(ItemLocalId lid) const
Number of entities connected to the source entity with local ID lid.
virtual Int32 connectedItemLocalId(ItemLocalId lid, Integer index) const
localId() of the index-th entity connected to the source entity with local ID lid
virtual ItemVectorView _connectedItems(ItemLocalId item, ConnectivityItemVector &con_items) const
Fills con_items with the entities connected to item.
Index of an Item in a variable.
virtual Int32 connectedItemLocalId(ItemLocalId lid, Integer index) const
localId() of the index-th entity connected to the source entity with local ID lid
virtual ItemVectorView _connectedItems(ItemLocalId item, ConnectivityItemVector &con_items) const
Fills con_items with the entities connected to item.
virtual Integer nbConnectedItem(ItemLocalId lid) const
Number of entities connected to the source entity with local ID lid.
virtual void notifySourceFamilyLocalIdChanged(Int32ConstArrayView new_to_old_ids)
Notifies the connectivity that the source family has been compacted.
View on a typed array of entities.
View on a vector of entities.
1D vector of data with reference semantics.
Unicode character string.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
ConstArrayView< Integer > IntegerConstArrayView
C equivalent of a 1D array of integers.
std::int32_t Int32
Signed integer type of 32 bits.
Temporary type automatically cast to ConnectivityItemVector.