12#ifndef ARCANE_ACCELERATOR_MATERIALVARIABLEVIEWS_H
13#define ARCANE_ACCELERATOR_MATERIALVARIABLEVIEWS_H
17#include "arcane/core/materials/IMeshMaterialVariable.h"
21#include "arcane/accelerator/AcceleratorGlobal.h"
41class ARCANE_ACCELERATOR_EXPORT MatVariableViewBase
49 MatVariableViewBase() =
default;
57template <
typename ItemType,
typename DataType>
58class MatItemVariableScalarInViewT
59:
public MatVariableViewBase
70 : MatVariableViewBase(vbi, var)
73 MatItemVariableScalarInViewT() =
default;
76 ARCCORE_HOST_DEVICE
const DataType&
operator[](ComponentItemLocalId lid)
const
84 return this->m_value[0][pmvi.valueIndex()];
88 ARCCORE_HOST_DEVICE
const DataType&
operator[](ItemIndexType item)
const
90 return this->m_value[0][item.localId()];
94 ARCCORE_HOST_DEVICE
const DataType&
value(ComponentItemLocalId mvi)
const
101 return this->m_value[0][idx.valueIndex()];
114template <
typename ItemType,
typename Accessor>
115class MatItemVariableScalarOutViewT
116:
public MatVariableViewBase
120 using DataType =
typename Accessor::ValueType;
121 using DataTypeReturnType = DataType&;
131 : MatVariableViewBase(vbi, var)
134 MatItemVariableScalarOutViewT() =
default;
137 ARCCORE_HOST_DEVICE Accessor
operator[](ComponentItemLocalId lid)
const
144 return Accessor(this->m_value[0][pmvi.valueIndex()]);
148 ARCCORE_HOST_DEVICE Accessor
operator[](ItemIndexType item)
const
150 ARCANE_CHECK_AT(item.localId(), this->m_value[0].size());
151 return Accessor(this->m_value[0].data() + item.localId());
155 ARCCORE_HOST_DEVICE Accessor
value(ComponentItemLocalId lid)
const
161 ARCCORE_HOST_DEVICE
void setValue(ComponentItemLocalId lid,
const DataType& v)
const
168 return Accessor(this->m_value[0][idx.valueIndex()]);
181template <
typename ItemType,
typename DataType>
182class MatItemVariableArrayInViewT
183:
public MatVariableViewBase
196 const ContainerViewType& v)
197 : MatVariableViewBase(vbi, var)
200 MatItemVariableArrayInViewT() =
default;
211 return m_value[pmvi];
217 return m_value[item];
229 return m_value[item];
234 ContainerViewType m_value;
242template <
typename ItemType,
typename Accessor>
243class MatItemVariableArrayOutViewT
244:
public MatVariableViewBase
248 using DataType =
typename Accessor::ValueType;
249 using DataTypeReturnType = DataType&;
256 : MatVariableViewBase(vbi, var)
259 MatItemVariableArrayOutViewT() =
default;
262 ARCCORE_HOST_DEVICE Accessor
operator[](ComponentItemLocalId lid)
const
264 return Accessor(m_value[lid]);
269 return Accessor(m_value[pmvi]);
273 ARCCORE_HOST_DEVICE Accessor
operator[](ItemIndexType item)
const
275 return Accessor(m_value[item]);
279 ARCCORE_HOST_DEVICE Accessor
value(ComponentItemLocalId lid)
const
281 return Accessor(m_value[lid]);
286 ContainerViewType m_value;
294template <
typename DataType>
auto
297 using Accessor = DataViewSetter<DataType>;
306template <
typename DataType>
auto
319template <
typename DataType>
auto
322 using Accessor = DataViewSetter<DataType>;
331template <
typename DataType>
auto
347template <
typename DataType>
auto
350 using Accessor = DataViewGetterSetter<DataType>;
359template <
typename DataType>
auto
372template <
typename DataType>
auto
375 using Accessor = DataViewGetterSetter<DataType>;
384template <
typename DataType>
auto
400template <
typename DataType>
auto
411template <
typename DataType>
auto
422template <
typename DataType>
auto
433template <
typename DataType>
auto
Read-only view on a 1D Array constituent variable.
__host__ __device__ SmallSpan< const DataType > value(ComponentItemLocalId mvi) const
Access operator for entity item.
__host__ __device__ SmallSpan< const DataType > value(ItemIndexType item) const
Override to access the global value from the cell id.
__host__ __device__ SmallSpan< const DataType > operator[](ItemIndexType item) const
Override to access the global value from the cell id.
__host__ __device__ SmallSpan< const DataType > operator[](ComponentItemLocalId lid) const
Access operator for entity item.
__host__ __device__ SmallSpan< const DataType > operator[](PureMatVarIndex pmvi) const
Access operator for entity item.
Write view on a 1D Array constituent variable.
__host__ __device__ Accessor operator[](ComponentItemLocalId lid) const
Access operator for entity item.
__host__ __device__ Accessor value(ComponentItemLocalId lid) const
Access operator for entity item.
__host__ __device__ Accessor operator[](ItemIndexType item) const
Override to access the global value from the cell id.
Read view on a scalar constituent variable.
__host__ __device__ const DataType & operator[](ComponentItemLocalId lid) const
Access operator for entity item.
__host__ __device__ const DataType & value(ComponentItemLocalId mvi) const
Access operator for entity item.
__host__ __device__ const DataType & operator[](PureMatVarIndex pmvi) const
Access operator for entity item.
__host__ __device__ const DataType & operator[](ItemIndexType item) const
Override to access the global value from the cell id.
Write view on a scalar constituent variable.
__host__ __device__ Accessor operator[](ComponentItemLocalId lid) const
Access operator for entity item.
__host__ __device__ Accessor value(ComponentItemLocalId lid) const
Access operator for entity item.
__host__ __device__ void setValue(ComponentItemLocalId lid, const DataType &v) const
Positions the value for entity item at v.
__host__ __device__ Accessor operator[](ItemIndexType item) const
Override to access the global value from the cell id.
Class to access a 1D array of a read/write view.
Class to access a 1D array of a read/write view.
Information to build a view for accelerator data.
Modifiable view of an array of type T.
Characteristics of mesh elements.
Array variable on the cells of a mesh material. For now, this class is only instantiated for cells.
Scalar variable on the cells of a mesh environment.
Array variable over the cells of a material in the mesh. For now, this class is only instantiated for...
Scalar variable on the cells of a mesh material.
constexpr __host__ __device__ MatVarIndex localId() const
Generic index to access variable values.
Interface of a material variable on a mesh.
constexpr __host__ __device__ Int32 arrayIndex() const
Returns the index of the value array in the list of variables.
constexpr __host__ __device__ Int32 valueIndex() const
Returns the index in the value array.
View of the container for 1D array constituent variables.
IMeshMaterialVariable * materialVariable() const
Associated material variable.
Index of a pure material item in a variable.
View of an array of elements of type T.
Namespace for accelerator usage.
auto viewInOut(const ViewBuildInfo &vbi, CellMaterialVariableScalarRef< DataType > &var)
Read/write view for scalar material variables.
auto viewOut(const ViewBuildInfo &vbi, CellMaterialVariableScalarRef< DataType > &var)
Write view for scalar material variables.
auto viewIn(const ViewBuildInfo &vbi, const CellMaterialVariableScalarRef< DataType > &var)
Read view for scalar material variables.
Always enables tracing in Arcane parts concerning materials.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --