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>>
48 using DataType = DataType_;
54 using AddedFirstLastExtentsType =
typename Extents::template AddedFirstLastExtentsType<DynExtent, Size>;
55 using AddedFirstExtentsType =
typename Extents::template AddedFirstExtentsType<DynExtent>;
56 using BaseClass = MeshMDVariableRefBaseT<ItemType, DataType, AddedFirstLastExtentsType>;
57 static_assert(Extents::rank() >= 0 && Extents::rank() <= 2,
"Only Extents of rank 0, 1 or 2 are implemented");
58 static_assert(std::is_same_v<DataType, BasicType>,
"DataType should be a basic type (Real, Int32, Int64, ... )");
62 using ItemLocalIdType =
typename ItemType::LocalIdType;
66 static constexpr int nb_dynamic = Extents::nb_dynamic;
80 requires(Extents::rank() == 0)
82 return ReferenceType(m_vector_mdspan.ptrAt(
id.localId()));
87 requires(Extents::rank() == 0)
89 return ConstReferenceType(m_vector_mdspan.ptrAt(
id.localId()));
97 requires(Extents::rank() == 1)
99 return ReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1));
104 requires(Extents::rank() == 1)
106 return ConstReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1));
114 requires(Extents::rank() == 2)
116 return ReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1, i2));
121 requires(Extents::rank() == 2)
123 return ConstReferenceType(m_vector_mdspan.ptrAt(
id.localId(), i1, i2));
133 void reshape(std::array<Int32, Extents::nb_dynamic> dims)
135 std::array<Int32, nb_dynamic + 1> full_dims;
137 for (
int i = 0; i < nb_dynamic; ++i)
138 full_dims[i] = dims[i];
139 full_dims[nb_dynamic] = Size;
141 this->m_underlying_var.resizeAndReshape(shape);
153 DataType* v = this->m_mdspan.to1DSpan().data();
154 NumVectorType* nv =
reinterpret_cast<NumVectorType*
>(v);
155 m_vector_mdspan = MDSpanType(nv, this->m_mdspan.extents().dynamicExtents());
160 MDSpanType m_vector_mdspan;
Read-write view of multi-dimensional vector variable over a mesh item.
Read-only view of multi-dimensional vector variable over a mesh item.
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
ReferenceType operator()(ItemLocalIdType id, Int32 i1)
ConstReferenceType operator()(ItemLocalIdType id) const
Accesses the data for reading.
ReferenceType operator()(ItemLocalIdType id, Int32 i1, Int32 i2)
void updateFromInternal() override
Updates from the internal part.
void reshape(std::array< Int32, Extents::nb_dynamic > dims)
Changes the data shape.
ConstReferenceType operator()(ItemLocalIdType id, Int32 i1, Int32 i2) const
Accesses the data for reading.
ReferenceType operator()(ItemLocalIdType id)
ConstReferenceType operator()(ItemLocalIdType id, Int32 i1) const
Accesses the data for reading.
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.