Arcane  4.2.3.0
User documentation
Loading...
Searching...
No Matches
NumVectorDataView.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* NumVectorDataView.h (C) 2000-2026 */
9/* */
10/* Specific implementation of DataView(Setter/Getter) for NumVector. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_COMMON_NUMVECTORDATAVIEW_H
13#define ARCCORE_COMMON_NUMVECTORDATAVIEW_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/NumVector.h"
18
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29/*!
30 * \brief Read-only view for a NumVector<DataType_, Size_>.
31 */
32template <typename DataType_, int Size_>
33class NumVectorDataViewGetter
34{
35 public:
36
37 //! Number of elements of the vector
38 static constexpr int Size = Size_;
39 //! Type of the vector
41 //! Accessor for the vector
43 //! Accessor for one element of the vector
45
46 public:
47
48 explicit ARCCORE_HOST_DEVICE NumVectorDataViewGetter(const NumVectorType* ptr)
49 : m_ptr(ptr)
50 {}
51
52 public:
53
54 static constexpr ARCCORE_HOST_DEVICE AccessorReturnType build(const NumVectorType* ptr)
55 {
56 return { *ptr };
57 }
58
59 public:
60
61 constexpr operator AccessorReturnType() const noexcept { return *m_ptr; }
62
63 private:
64
65 const NumVectorType* m_ptr = nullptr;
66};
67
68/*---------------------------------------------------------------------------*/
69/*---------------------------------------------------------------------------*/
70/*!
71 * \brief Mutable view for a NumVector<DataType_,Size>.
72 */
73template <typename DataType_, int Size_>
74class NumVectorDataViewGetterSetter
75: public DataViewGetterSetter<NumVector<DataType_, Size_>>
76{
77 using BaseClass = DataViewGetterSetter<NumVector<DataType_, Size_>>;
78
79 public:
80
81 //! Number of elements of the vector
82 static constexpr int Size = Size_;
83 //! Type of the vector
85 //! Accessor for one element of the vector
86 using VectorElemenAccessor = DataViewGetterSetter<DataType_>;
87
88 public:
89
90 explicit ARCCORE_HOST_DEVICE NumVectorDataViewGetterSetter(NumVectorType* ptr)
91 : BaseClass(ptr)
92 {}
93
94 public:
95
97 {
98 BaseClass::operator=(v);
99 return (*this);
100 }
101
102 void fill(const DataType_& v)
103 {
104 this->m_ptr->fill(v);
105 }
106};
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111} // End namespace Arcane
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116#endif
Class for accessing an element of a read view.
Mutable view for a NumVector<DataType_,Size>.
DataViewGetterSetter< DataType_ > VectorElemenAccessor
Accessor for one element of the vector.
NumVector< DataType_, Size > NumVectorType
Type of the vector.
static constexpr int Size
Number of elements of the vector.
Small fixed-size vector of Size numerical data points.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --