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"
41template <
typename ItemType,
typename DataType_,
int Row,
int Column,
typename Extents>
42class MeshMatrixMDVariableRefT
43:
public MeshMDVariableRefBaseT<ItemType, DataType_, typename Extents::template AddedFirstLastLastExtentsType<DynExtent, Row, Column>>
51 using DataType = DataType_;
57 using AddedFirstLastLastExtentsType =
typename Extents::template AddedFirstLastLastExtentsType<DynExtent, Row, Column>;
58 using AddedFirstExtentsType =
typename Extents::template AddedFirstExtentsType<DynExtent>;
59 using BaseClass = MeshMDVariableRefBaseT<ItemType, DataType, AddedFirstLastLastExtentsType>;
60 static_assert(Extents::rank() >= 0 && Extents::rank() <= 1,
"Only Extents of rank 0 or 1 are implemented");
61 static_assert(std::is_same_v<DataType, BasicType>,
"DataType should be a basic type (Real, Int32, Int64, ... )");
65 using ItemLocalIdType =
typename ItemType::LocalIdType;
69 static constexpr int nb_dynamic = Extents::nb_dynamic;
82 ReferenceType
operator()(ItemLocalIdType
id)
requires(Extents::rank() == 0)
84 return ReferenceType(m_matrix_mdspan.ptrAt(
id.localId()));
88 ConstReferenceType
operator()(ItemLocalIdType
id)
const requires(Extents::rank() == 0)
90 return ConstReferenceType(m_matrix_mdspan.ptrAt(
id.localId()));
96 return m_matrix_mdspan(
id.localId())(i, j);
102 return m_matrix_mdspan(
id.localId())(i, j);
110 requires(Extents::rank() == 1)
112 return ReferenceType(m_matrix_mdspan.ptrAt(
id.localId(), index));
117 requires(Extents::rank() == 1)
119 return ConstReferenceType(m_matrix_mdspan.ptrAt(
id.localId(), index));
124 requires(Extents::rank() == 1)
126 return m_matrix_mdspan(
id.localId(), index)(i, j);
131 requires(Extents::rank() == 1)
133 return m_matrix_mdspan(
id.localId(), index)(i, j);
143 void reshape(std::array<Int32, Extents::nb_dynamic> dims)
145 std::array<Int32, nb_dynamic + 2> full_dims;
147 for (
int i = 0; i < nb_dynamic; ++i)
148 full_dims[i] = dims[i];
149 full_dims[nb_dynamic] = Row;
150 full_dims[nb_dynamic + 1] = Column;
152 this->m_underlying_var.resizeAndReshape(shape);
164 DataType* v = this->m_mdspan.to1DSpan().data();
165 NumMatrixType* nv =
reinterpret_cast<NumMatrixType*
>(v);
166 m_matrix_mdspan = MDSpanType(nv, this->m_mdspan.extents().dynamicExtents());
171 MDSpanType m_matrix_mdspan;
Read-write view of multi-dimensional matrix variable over a mesh item.
Read-only view of multi-dimensional matrix variable over a mesh item.
Base class for multidimensional views.
void updateFromInternal() override
DataType & operator()(ItemLocalIdType id, Int32 index, Int32 i, Int32 j)
Mutable view of the element (i,j) of the matrix for item id and index index.
ReferenceType operator()(ItemLocalIdType id, Int32 index)
ConstReferenceType operator()(ItemLocalIdType id) const
Read-only view of the matrix for item id.
DataType & operator()(ItemLocalIdType id, Int32 i, Int32 j)
Mutable view of the element (i,j) of the matrix for item id.
DataType operator()(ItemLocalIdType id, Int32 index, Int32 i, Int32 j) const
Read-only view of the element (i,j) of the matrix for item id and index index.
void updateFromInternal() override
Updates from the internal part.
void reshape(std::array< Int32, Extents::nb_dynamic > dims)
Changes the data shape.
DataType operator()(ItemLocalIdType id, Int32 i, Int32 j) const
Read-only view of the element (i,j) of the matrix for item id.
ReferenceType operator()(ItemLocalIdType id)
ConstReferenceType operator()(ItemLocalIdType id, Int32 index) const
Read-only view of the matrix of index index for item id.
Mutable view for a NumMatrix<DataType_,Row,Column>.
Read-only view for a NumMatrix<DataType_,Row,Column>.
Small fixed-size matrix containing RowSize rows and ColumnSize columns.
Parameters necessary for building a variable.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int32_t Int32
Signed integer type of 32 bits.