12#ifndef ARCANE_CORE_MESHVECTORMDVARIABLEREF_H
13#define ARCANE_CORE_MESHVECTORMDVARIABLEREF_H
17#include "arcane/utils/NumVector.h"
19#include "arcane/core/DataView.h"
20#include "arcane/core/MeshMDVariableRef.h"
37template <
typename ItemType,
typename DataType,
int Size,
typename Extents>
38class MeshVectorMDVariableRefT
39:
public MeshMDVariableRefBaseT<ItemType, DataType, typename Extents::template AddedFirstLastExtentsType<DynExtent, Size>>
48 using AddedFirstLastExtentsType =
typename Extents::template AddedFirstLastExtentsType<DynExtent, Size>;
49 using AddedFirstExtentsType =
typename Extents::template AddedFirstExtentsType<DynExtent>;
50 using BaseClass = MeshMDVariableRefBaseT<ItemType, DataType, AddedFirstLastExtentsType>;
51 static_assert(Extents::rank() >= 0 && Extents::rank() <= 2,
"Only Extents of rank 0, 1 or 2 are implemented");
52 static_assert(std::is_same_v<DataType, BasicType>,
"DataType should be a basic type (Real, Int32, Int64, ... )");
56 using ItemLocalIdType =
typename ItemType::LocalIdType;
60 static constexpr int nb_dynamic = Extents::nb_dynamic;
74 requires(Extents::rank() == 0)
76 return ReferenceType(m_vector_mdspan.ptrAt(
id.localId()));
81 requires(Extents::rank() == 0)
83 return ConstReferenceType(m_vector_mdspan.ptrAt(
id.localId()));
91 requires(Extents::rank() == 1)
93 return ReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1));
98 requires(Extents::rank() == 1)
100 return ConstReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1));
108 requires(Extents::rank() == 2)
110 return ReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1, i2));
115 requires(Extents::rank() == 2)
117 return ConstReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1, i2));
127 void reshape(std::array<Int32, Extents::nb_dynamic> dims)
129 std::array<Int32, nb_dynamic + 1> full_dims;
131 for (
int i = 0; i < nb_dynamic; ++i)
132 full_dims[i] = dims[i];
133 full_dims[nb_dynamic] = Size;
135 this->m_underlying_var.resizeAndReshape(shape);
147 DataType* v = this->m_mdspan.to1DSpan().data();
148 NumVectorType* nv =
reinterpret_cast<NumVectorType*
>(v);
149 m_vector_mdspan = MDSpanType(nv, this->m_mdspan.extents().dynamicExtents());
154 MDSpanType m_vector_mdspan;
Classe pour accéder à un élément d'une vue en lecture/écriture.
Classe pour accéder à un élément d'une vue en lecture.
Classe de base des vues multi-dimensionnelles.
void updateFromInternal() override
void reshape(std::array< Int32, Extents::nb_dynamic > dims)
Change la forme des données.
ReferenceType operator()(ItemLocalIdType id, Int32 i1)
ConstReferenceType operator()(ItemLocalIdType id, Int32 i1, Int32 i2) const
Accède aux données en lecture.
ConstReferenceType operator()(ItemLocalIdType id) const
Accède aux données en lecture.
void updateFromInternal() override
Mise à jour à partir de la partie interne.
ConstReferenceType operator()(ItemLocalIdType id, Int32 i1) const
Accède aux données en lecture.
ReferenceType operator()(ItemLocalIdType id, Int32 i1, Int32 i2)
ReferenceType operator()(ItemLocalIdType id)
Petit vecteur de taille fixe de points de données numériques de taille Size.
Paramètres nécessaires à la construction d'une variable.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int32_t Int32
Type entier signé sur 32 bits.