12#ifndef ARCANE_ACCELERATOR_MATERIALVARIABLEVIEWS_H
13#define ARCANE_ACCELERATOR_MATERIALVARIABLEVIEWS_H
17#include "arcane/core/materials/IMeshMaterialVariable.h"
20#include "arcane/core/materials/MatItem.h"
22#include "arcane/accelerator/AcceleratorGlobal.h"
42class ARCANE_ACCELERATOR_EXPORT MatVariableViewBase
50 MatVariableViewBase() =
default;
59template <
typename ItemType,
typename DataType>
60class MatItemVariableScalarInViewT
61:
public MatVariableViewBase
72 : MatVariableViewBase(vbi, var)
75 MatItemVariableScalarInViewT() =
default;
78 ARCCORE_HOST_DEVICE
const DataType&
operator[](ComponentItemLocalId lid)
const
86 return this->m_value[0][pmvi.valueIndex()];
90 ARCCORE_HOST_DEVICE
const DataType&
operator[](ItemIndexType item)
const
92 return this->m_value[0][item.localId()];
96 ARCCORE_HOST_DEVICE
const DataType&
value(ComponentItemLocalId mvi)
const
103 return this->m_value[0][idx.valueIndex()];
117template <
typename ItemType,
typename Accessor>
118class MatItemVariableScalarOutViewT
119:
public MatVariableViewBase
123 using DataType =
typename Accessor::ValueType;
124 using DataTypeReturnType = DataType&;
134 : MatVariableViewBase(vbi, var)
137 MatItemVariableScalarOutViewT() =
default;
140 ARCCORE_HOST_DEVICE Accessor
operator[](ComponentItemLocalId lid)
const
147 return Accessor(this->m_value[0][pmvi.valueIndex()]);
151 ARCCORE_HOST_DEVICE Accessor
operator[](ItemIndexType item)
const
153 ARCANE_CHECK_AT(item.localId(), this->m_value[0].size());
154 return Accessor(this->m_value[0].data() + item.localId());
158 ARCCORE_HOST_DEVICE Accessor
value(ComponentItemLocalId lid)
const
164 ARCCORE_HOST_DEVICE
void setValue(ComponentItemLocalId lid,
const DataType& v)
const
171 return Accessor(this->m_value[0][idx.valueIndex()]);
185template <
typename DataType>
auto
188 using Accessor = DataViewSetter<DataType>;
198template <
typename DataType>
auto
201 using Accessor = DataViewSetter<DataType>;
211template <
typename DataType>
auto
214 using Accessor = DataViewGetterSetter<DataType>;
224template <
typename DataType>
auto
227 using Accessor = DataViewGetterSetter<DataType>;
237template <
typename DataType>
auto
249template <
typename DataType>
auto
Read view on a scalar mesh 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 mesh 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.
Information to build a view for accelerator data.
Modifiable view of an array of type T.
Characteristics of mesh elements.
Scalar variable on the cells of a mesh environment.
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.
IMeshMaterialVariable * materialVariable() const
Associated material variable.
Index of a pure material item in a variable.
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 --