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"
38template <
typename ItemType,
typename DataType,
int Size,
typename Extents>
39class MeshVectorMDVariableRefT
40:
public MeshMDVariableRefBaseT<ItemType, DataType, typename Extents::template AddedFirstLastExtentsType<DynExtent, Size>>
49 using AddedFirstLastExtentsType =
typename Extents::template AddedFirstLastExtentsType<DynExtent, Size>;
50 using AddedFirstExtentsType =
typename Extents::template AddedFirstExtentsType<DynExtent>;
51 using BaseClass = MeshMDVariableRefBaseT<ItemType, DataType, AddedFirstLastExtentsType>;
52 static_assert(Extents::rank() >= 0 && Extents::rank() <= 2,
"Only Extents of rank 0, 1 or 2 are implemented");
53 static_assert(std::is_same_v<DataType, BasicType>,
"DataType should be a basic type (Real, Int32, Int64, ... )");
57 using ItemLocalIdType =
typename ItemType::LocalIdType;
61 static constexpr int nb_dynamic = Extents::nb_dynamic;
75 requires(Extents::rank() == 0)
77 return ReferenceType(m_vector_mdspan.ptrAt(
id.localId()));
82 requires(Extents::rank() == 0)
84 return ConstReferenceType(m_vector_mdspan.ptrAt(
id.localId()));
92 requires(Extents::rank() == 1)
94 return ReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1));
99 requires(Extents::rank() == 1)
101 return ConstReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1));
109 requires(Extents::rank() == 2)
111 return ReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1, i2));
116 requires(Extents::rank() == 2)
118 return ConstReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1, i2));
128 void reshape(std::array<Int32, Extents::nb_dynamic> dims)
130 std::array<Int32, nb_dynamic + 1> full_dims;
132 for (
int i = 0; i < nb_dynamic; ++i)
133 full_dims[i] = dims[i];
134 full_dims[nb_dynamic] = Size;
136 this->m_underlying_var.resizeAndReshape(shape);
148 DataType* v = this->m_mdspan.to1DSpan().data();
149 NumVectorType* nv =
reinterpret_cast<NumVectorType*
>(v);
150 m_vector_mdspan = MDSpanType(nv, this->m_mdspan.extents().dynamicExtents());
155 MDSpanType m_vector_mdspan;
Class for accessing an element of a read/write view.
Class for accessing an element of a read view.
Base class for multidimensional views.
void updateFromInternal() override
void reshape(std::array< Int32, Extents::nb_dynamic > dims)
Changes the data shape.
ReferenceType operator()(ItemLocalIdType id, Int32 i1)
ConstReferenceType operator()(ItemLocalIdType id, Int32 i1, Int32 i2) const
Accesses the data for reading.
ConstReferenceType operator()(ItemLocalIdType id) const
Accesses the data for reading.
void updateFromInternal() override
Updates from the internal part.
ConstReferenceType operator()(ItemLocalIdType id, Int32 i1) const
Accesses the data for reading.
ReferenceType operator()(ItemLocalIdType id, Int32 i1, Int32 i2)
ReferenceType operator()(ItemLocalIdType id)
Small fixed-size vector of Size numerical data points.
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.