12#ifndef ARCANE_CORE_MESHMATRIXMDVARIABLEREF_H
13#define ARCANE_CORE_MESHMATRIXMDVARIABLEREF_H
17#include "arcane/utils/NumMatrix.h"
18#include "arcane/utils/NumMatrixDataView.h"
20#include "arcane/core/MeshMDVariableRef.h"
39template <
typename ItemType,
typename DataType_,
int Row,
int Column,
typename Extents>
40class MeshMatrixMDVariableRefT
41:
public MeshMDVariableRefBaseT<ItemType, DataType_, typename Extents::template AddedFirstLastLastExtentsType<DynExtent, Row, Column>>
49 using DataType = DataType_;
55 using AddedFirstLastLastExtentsType =
typename Extents::template AddedFirstLastLastExtentsType<DynExtent, Row, Column>;
56 using AddedFirstExtentsType =
typename Extents::template AddedFirstExtentsType<DynExtent>;
57 using BaseClass = MeshMDVariableRefBaseT<ItemType, DataType, AddedFirstLastLastExtentsType>;
58 static_assert(Extents::rank() >= 0 && Extents::rank() <= 1,
"Only Extents of rank 0 or 1 are implemented");
59 static_assert(std::is_same_v<DataType, BasicType>,
"DataType should be a basic type (Real, Int32, Int64, ... )");
63 using ItemLocalIdType =
typename ItemType::LocalIdType;
67 static constexpr int nb_dynamic = Extents::nb_dynamic;
80 ReferenceType
operator()(ItemLocalIdType
id)
requires(Extents::rank() == 0)
82 return ReferenceType(m_matrix_mdspan.ptrAt(
id.localId()));
86 ConstReferenceType
operator()(ItemLocalIdType
id)
const requires(Extents::rank() == 0)
88 return ConstReferenceType(m_matrix_mdspan.ptrAt(
id.localId()));
94 return m_matrix_mdspan(
id.localId())(i, j);
100 return m_matrix_mdspan(
id.localId())(i, j);
108 requires(Extents::rank() == 1)
110 return ReferenceType(m_matrix_mdspan.ptrAt(
id.localId(), index));
115 requires(Extents::rank() == 1)
117 return ConstReferenceType(m_matrix_mdspan.ptrAt(
id.localId(), index));
122 requires(Extents::rank() == 1)
124 return m_matrix_mdspan(
id.localId(), index)(i, j);
129 requires(Extents::rank() == 1)
131 return m_matrix_mdspan(
id.localId(), index)(i, j);
141 void reshape(std::array<Int32, Extents::nb_dynamic> dims)
143 std::array<Int32, nb_dynamic + 2> full_dims;
145 for (
int i = 0; i < nb_dynamic; ++i)
146 full_dims[i] = dims[i];
147 full_dims[nb_dynamic] = Row;
148 full_dims[nb_dynamic + 1] = Column;
150 this->m_underlying_var.resizeAndReshape(shape);
162 DataType* v = this->m_mdspan.to1DSpan().data();
163 NumMatrixType* nv =
reinterpret_cast<NumMatrixType*
>(v);
164 m_matrix_mdspan = MDSpanType(nv, this->m_mdspan.extents().dynamicExtents());
169 MDSpanType m_matrix_mdspan;
Vue en lecture/écriture de variable matricielle multidimensionnelle sur un élément de maillage.
Vue en lecture seule de variable matricielle multidimensionnelle sur un élément de maillage.
Classe de base des vues multi-dimensionnelles.
void updateFromInternal() override
DataType & operator()(ItemLocalIdType id, Int32 index, Int32 i, Int32 j)
Vue mutable de l'élément (i,j) de la matrice pour l'élément id et l'indice index.
ReferenceType operator()(ItemLocalIdType id, Int32 index)
ConstReferenceType operator()(ItemLocalIdType id) const
Vue en lecture seule de la matrice pour l'élément id.
DataType & operator()(ItemLocalIdType id, Int32 i, Int32 j)
Vue mutable de l'élément (i,j) de la matrice pour l'élément id.
DataType operator()(ItemLocalIdType id, Int32 index, Int32 i, Int32 j) const
Vue en lecture seule de l'élément (i,j) de la matrice pour l'élément id et l'indice index.
void updateFromInternal() override
Mise à jour à partir de la partie interne.
void reshape(std::array< Int32, Extents::nb_dynamic > dims)
Modifie la forme des données.
DataType operator()(ItemLocalIdType id, Int32 i, Int32 j) const
Vue en lecture seule de l'élément (i,j) de la matrice pour l'élément id.
ReferenceType operator()(ItemLocalIdType id)
ConstReferenceType operator()(ItemLocalIdType id, Int32 index) const
Vue en lecture seule de la matrice de l'indice index pour l'élément id.
Vue modifiable pour un NumMatrix<DataType_,Row,Column>.
Vue en lecture seule pour un NumMatrix<DataType_,Row,Column>.
Petite matrice de taille fixe contenant RowSize lignes et ColumnSize colonnes.
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.