12#ifndef ARCANE_CORE_MESHMDVARIABLEREF_H
13#define ARCANE_CORE_MESHMDVARIABLEREF_H
17#include "arcane/utils/ArrayLayout.h"
18#include "arcane/utils/ArrayShape.h"
19#include "arcane/utils/MDSpan.h"
21#include "arcane/core/DataView.h"
23#include "arcane/core/MeshVariableArrayRef.h"
24#include "arcane/core/datatype/DataTypeTraits.h"
35template <
typename ItemType,
typename DataType>
36class MeshMDVariableRefWrapperT
39 template <
typename _ItemType,
typename _DataType,
typename _Extents>
45 using VariableType =
typename BaseClass::PrivatePartType;
46 using ValueDataType =
typename VariableType::ValueDataType;
57 ValueDataType* trueData() {
return this->m_private_part->trueData(); }
58 const ValueDataType* trueData()
const {
return this->m_private_part->trueData(); }
62 this->m_private_part->fillShape(shape_with_item);
82template <
typename ItemType,
typename DataType,
typename Extents>
83class MeshMDVariableRefBaseT
90 using ItemLocalIdType =
typename ItemType::LocalIdType;
91 using FullExtentsType = Extents;
99 _internalInit(m_underlying_var.variable());
115 const Int32 nb_rank = Extents::rank();
118 m_underlying_var.fillShape(shape_with_item);
121 m_mdspan = MDSpanType(m_underlying_var.trueData()->view().data(), new_extents);
139template <
typename ItemType,
typename DataType,
typename Extents>
140class MeshMDVariableRefT
141:
public MeshMDVariableRefBaseT<ItemType, DataType, typename Extents::template AddedFirstExtentsType<DynExtent>>
147 using AddedFirstExtentsType =
typename Extents::template AddedFirstExtentsType<DynExtent>;
149 static_assert(Extents::rank() >= 0 && Extents::rank() <= 3,
"Only Extents of rank 0, 1, 2 or 3 are implemented");
150 static_assert(std::is_same_v<DataType, BasicType>,
"DataType should be a basic type (Real, Int32, Int64, ... )");
154 using BaseClass = MeshMDVariableRefBaseT<ItemType, DataType, AddedFirstExtentsType>;
155 using ItemLocalIdType =
typename ItemType::LocalIdType;
156 static constexpr int nb_dynamic = Extents::nb_dynamic;
166 DataType& operator()(ItemLocalIdType
id)
requires(Extents::rank() == 0)
168 return this->m_mdspan(
id.localId());
171 const DataType& operator()(ItemLocalIdType
id)
const requires(Extents::rank() == 0)
173 return this->m_mdspan(
id.localId());
176 DataType& operator()(ItemLocalIdType
id,
Int32 i1)
requires(Extents::rank() == 1)
178 return this->m_mdspan(
id.localId(), i1);
181 const DataType& operator()(ItemLocalIdType
id,
Int32 i1)
const requires(Extents::rank() == 1)
183 return this->m_mdspan(
id.localId(), i1);
186 DataType& operator()(ItemLocalIdType
id,
Int32 i1,
Int32 i2)
187 requires(Extents::rank() == 2)
189 return this->m_mdspan(
id.localId(), i1, i2);
192 const DataType& operator()(ItemLocalIdType
id,
Int32 i1,
Int32 i2)
const
193 requires(Extents::rank() == 2)
195 return this->m_mdspan(
id.localId(), i1, i2);
199 requires(Extents::rank() == 3)
201 return this->m_mdspan(
id.localId(), i, j, k);
204 const DataType& operator()(ItemLocalIdType
id,
Int32 i,
Int32 j,
Int32 k)
const
205 requires(Extents::rank() == 3)
207 return this->m_mdspan(
id.localId(), i, j, k);
216 void reshape(std::array<Int32, Extents::nb_dynamic> dims)
219 this->m_underlying_var.resizeAndReshape(shape);
Vue en lecture/écriture de variable multidimensionnelle sur un élément de maillage.
Vue en lecture seule de variable multidimensionnelle sur un élément de maillage.
__host__ static __device__ ArrayExtentsBase fromSpan(SmallSpan< const ExtentIndexType > extents)
Construit une instance à partir des valeurs données dans extents.
void setNbDimension(Int32 nb_value)
Positionne le rang de la forme.
SmallSpan< const Int32 > dimensions() const
Valeurs de chaque dimension.
Classe de base des vues multi-dimensionnelles.
Classe de base gérant une variable multi-dimension sur une entité du maillage.
const UnderlyingVariableType & underlyingVariable() const
Variable sous-jacente associée.
UnderlyingVariableType & underlyingVariable()
Variable sous-jacente associée.
void updateFromInternal() override
Mise à jour à partir de la partie interne.
ArrayShape fullShape() const
Forme complète (statique + dynamique) de la variable.
void reshape(std::array< Int32, Extents::nb_dynamic > dims)
Change la forme de la donnée.
Variable tableau sur un type d'entité du maillage.
MeshVariableArrayRefT(const VariableBuildInfo &b)
MeshVariableRef(const VariableBuildInfo &vb)
Construit une référence liée au module module.
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.