This page groups information on the developments made in Arcane for managing new connectivities. It is based on the CEA version from February 2017, which corresponds to Arcane versions 2.5.0 and later.
To meet new needs, the entity connectivity management mechanism in Arcane evolved starting in 2017.
The historical mechanism's primary goal was to save memory and stored all of an entity's connectivities consecutively in memory. However, this presents two drawbacks:
The new mechanism allows for the complete separation of each connectivity type and potentially the specialization of a connectivity type based on certain needs (for example, depending on the mesh type).
It resolves the two previous drawbacks, but in return, it results in an increase in memory usage for unstructured meshes. With the old mechanism, 1 index (of type Arcane::Int32) was sufficient for each entity to access connectivity information, whereas with the new mechanism, 2 indices (position + number of connectivities) are required per connectivity. For example, in the case of classic mesh entities (node, edge, face, or cell), 8 indices are therefore required instead of 1.
The historical mechanism allows access to connectivity information directly via the entity. For example, to access the 4th node of a cell:
In the long term, access to connectivities might be available in another form, but for now, this mechanism must be usable to avoid making all current codes incompatible.
To transition between the old and new connectivity management, compatibility mechanisms have been implemented. The goal of these mechanisms is to ensure compatibility at the source level of codes using Arcane: these codes must be able to compile without modification with Arcane versions that integrate the new connectivities.
To ensure this compatibility, the access mechanism for methods such as Arcane::Cell::node() is modified and now uses an object of type Arcane::ItemInternalConnectivityList. The Arcane::ItemInternal class contains a field Arcane::ItemInternal::m_connectivity which is a pointer to an Arcane::ItemInternalConnectivityList. All entities of the same family point to the same value, which is Arcane::ItemFamily::m_item_connectivity_list.
In order not to modify the existing API, the ItemInternal methods for accessing connectivity have not been modified, and new ones have been added. They use the V2 suffix. For example, Arcane::ItemInternal::nodesV2() instead of Arcane::ItemInternal::nodes().
The macro ARCANE_USE_LEGACY_ITEMINTERNAL_CONNECTIVITY allows you to choose at compile time whether the accessors via Arcane::Item, Arcane::Edge, Arcane::Face, Arcane::Cell, ... use the old or new mechanisms. If this macro is defined, then:
This macro is defined only if Arcane is compiled with the –with-legacy-connectivity option in the configure script. If this option is active, it is impossible to access the new connectivities via Item. The only purpose of this option is to check if the new mechanism contains bugs and to validate new Arcane versions on old user codes. We will assume later that this option is not used and therefore that connectivities are accessed via the V2 methods. To do this, you must use the configuration option –without-legacy-connectiviy in the configure script.
When using the V2 methods, access to each connectivity is done via the Arcane::ItemInternalConnectivityList class. For each connectivity, there are three arrays:
The list of entities connected to an entity is stored consecutively in memory, so the index in the first array allows the others to be retrieved. nb_item and index are indexed by the localId() of the entity whose connectivities you want to access. For example:
All connectivities of classic entities (Arcane::Node, Arcane::Edge, Arcane::Face, and Arcane::Cell) now use this type of access. It is possible to choose at runtime whether the access is done via historical connectivities or new connectivities. This is done via the environment variable ARCANE_CONNECTIVITY_POLICY, which allows associating one of the enumerated values Arcane::InternalConnectivityPolicy. This association is made in the DynamicMesh constructor. The Arcane::IMesh::_connectivityPolicy() method allows retrieving the chosen policy. There are currently 4 possible values:
In the long term, there will be a 5th value corresponding to the definitive mode where only the new connectivities are allocated. This will be implemented when all codes using Arcane have been validated with the new connectivities.
Depending on how Arcane is configured, certain values are not possible. If the configuration is done with –with-legacy-connectivity, then the Arcane::InternalConnectivityPolicy::NewAndLegacy mode is not possible. If Arcane is configured with –without-legacy-connectivity, then the Arcane::InternalConnectivityPolicy::Legacy mode is not possible.