12#ifndef ARCANE_CORE_MESHVARIABLESCALARREF_H
13#define ARCANE_CORE_MESHVARIABLESCALARREF_H
17#include "arcane/utils/FatalErrorException.h"
19#include "arcane/core/MeshVariableRef.h"
20#include "arcane/core/PrivateVariableScalar.h"
22#include "arcane/core/ItemGroupRangeIterator.h"
23#include "arcane/core/ItemPairEnumerator.h"
34template <
typename DataTypeT>
43 static void add(VarType&,
const VarType&,
const ItemGroup&) { _notSupported(); }
44 static void sub(VarType&,
const VarType&,
const ItemGroup&) { _notSupported(); }
45 static void mult(VarType&,
const VarType&,
const ItemGroup&) { _notSupported(); }
46 static void mult(VarType&,
const DataTypeT&,
const ItemGroup&) { _notSupported(); }
47 static void power(VarType&,
const DataTypeT&,
const ItemGroup&) { _notSupported(); }
48 static void _notSupported()
50 ARCANE_FATAL(
"ItemNumeraticOperation: operation not supported");
66 static ARCANE_CORE_EXPORT
void add(VarType& out,
const VarType& v,
const ItemGroup& group);
67 static ARCANE_CORE_EXPORT
void sub(VarType& out,
const VarType& v,
const ItemGroup& group);
68 static ARCANE_CORE_EXPORT
void mult(VarType& out,
const VarType& v,
const ItemGroup& group);
69 static ARCANE_CORE_EXPORT
void mult(VarType& out,
Real v,
const ItemGroup& group);
70 static ARCANE_CORE_EXPORT
void power(VarType& out,
Real v,
const ItemGroup& group);
80template <
typename DataTypeT>
86 typedef DataTypeT DataType;
88 typedef const DataTypeT& ConstReturnReferenceType;
89 typedef DataTypeT& ReturnReferenceType;
93 typedef typename BaseClass::PrivatePartType PrivatePartType;
94 typedef typename BaseClass::DataTypeReturnReference DataTypeReturnReference;
126 add(v, this->itemGroup());
130 sub(v, this->itemGroup());
134 mult(v, this->itemGroup());
136 void mult(
const DataTypeT& v)
138 mult(v, this->itemGroup());
142 copy(v, this->itemGroup());
144 void power(
const DataTypeT& v)
146 power(v, this->itemGroup());
151 ItemNumericOperation<DataTypeT>::add(*
this, v, group);
155 ItemNumericOperation<DataTypeT>::sub(*
this, v, group);
159 ItemNumericOperation<DataTypeT>::mult(*
this, v, group);
161 void mult(
const DataTypeT& v,
const ItemGroup& group)
163 ItemNumericOperation<DataTypeT>::mult(*
this, v, group);
165 void power(
const DataTypeT& v,
const ItemGroup& group)
167 ItemNumericOperation<DataTypeT>::power(*
this, v, group);
172 ARCANE_CORE_EXPORT
void fill(
const DataTypeT& value);
173 ARCANE_CORE_EXPORT
void fill(
const DataTypeT& value,
const ItemGroup& group);
215template <
typename ItemTypeT,
typename DataTypeT>
221 typedef DataTypeT DataType;
222 typedef ItemTypeT ItemType;
224 typedef const DataTypeT& ConstReturnReferenceType;
225 typedef DataTypeT& ReturnReferenceType;
229 typedef typename ItemType::LocalIdType ItemLocalIdType;
234 typedef typename BaseClass::DataTypeReturnReference DataTypeReturnReference;
248 ThatClass& operator=(
const ThatClass& rhs) =
delete;
259 ThatClass& _Internal() {
return *
this; }
263 void fill(
const DataTypeT& value) { BaseClass::fill(value); }
264 void fill(
const DataTypeT& value, RunQueue* queue) { BaseClass::fill(value, queue); }
265 void fill(
const DataTypeT& value,
const GroupType& group) { BaseClass::fill(value, group); }
272 ARCANE_CORE_EXPORT
void setIsSynchronized();
273 ARCANE_CORE_EXPORT
void setIsSynchronized(
const GroupType& group);
278 const DataTypeT&
operator[](ItemLocalIdType i)
const {
return this->_value(i.localId()); }
281 DataTypeReturnReference
operator[](ItemLocalIdType i) {
return this->_value(i.localId()); }
284 const DataTypeT&
operator()(ItemLocalIdType i)
const {
return this->_value(i.localId()); }
287 DataTypeReturnReference
operator()(ItemLocalIdType i) {
return this->_value(i.localId()); }
292 return this->_value(item.localId());
295 const DataTypeT& item(ItemLocalIdType i)
const
297 return this->_value(i.localId());
299 void setItem(ItemLocalIdType i,
const DataTypeT& v)
301 this->_value(i.localId()) = v;
303#ifdef ARCANE_DOTNET_WRAPPER
304 const DataTypeT& item(
Int32 i)
const
306 return this->_value(i);
308 void setItem(
Int32 i,
const DataTypeT& v)
316 static ARCANE_CORE_EXPORT VariableTypeInfo _internalVariableTypeInfo();
317 static ARCANE_CORE_EXPORT VariableInfo _internalVariableInfo(
const VariableBuildInfo& vbi);
321 static VariableFactoryRegisterer m_auto_registerer;
322 static VariableRef* _autoCreate(
const VariableBuildInfo& vb);
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Execution queue for an accelerator.
Modifiable view of an array of type T.
Index of an Item in a variable.
Characteristics of mesh elements.
Scalar variable on a mesh entity type.
ItemVariableScalarRefT(IVariable *var)
Constructs a reference from var.
void operator=(const ItemVariableScalarRefT< DataTypeT > &rhs)
Positions the instance reference to the variable rhs.
ItemVariableScalarRefT()
Default constructor.
ItemVariableScalarRefT(const ItemVariableScalarRefT< DataTypeT > &rhs)
Constructs a reference from rhs.
const DataType & operator[](ItemLocalId item) const
Read-only value of entity item.
DataTypeReturnReference operator[](ItemLocalId item)
Read/write value of entity item.
void fill(const DataTypeT &value, RunQueue *queue)
Fills the instance values with value via the queue.
DataTypeReturnReference operator()(ItemLocalId item)
Read/write value of entity item.
void copy(const ItemVariableScalarRefT< DataTypeT > &v, RunQueue *queue)
Copies the values of v into this variable via the queue.
ItemVariableScalarRefT(const VariableBuildInfo &b, eItemKind ik)
Constructs a reference to the variable specified in vb.
const DataType & operator()(ItemLocalId item) const
Read-only value of entity item.
void copy(const ItemVariableScalarRefT< DataTypeT > &v, const ItemGroup &group)
Copies the values of v into this variable for the entities in group.
DataTypeReturnReference operator[](ItemLocalIdType i)
Read/write value of entity item.
MeshVariableScalarRefT()
Default constructor.
GroupType itemGroup() const
Group associated with the quantity.
DataTypeReturnReference operator()(ItemLocalIdType i)
Read/write value of entity item.
MeshVariableScalarRefT(const VariableBuildInfo &vb)
Constructs a reference to the variable specified in vb.
DataTypeT & getReference(ItemLocalIdType item)
Read/write value of entity item.
void refersTo(const MeshVariableScalarRefT< ItemType, DataTypeT > &rhs)
Positions the instance reference to the variable rhs.
void swapValues(MeshVariableScalarRefT< ItemType, DataType > &rhs)
Swaps the values of the variable rhs with those of the instance.
MeshVariableScalarRefT(const MeshVariableScalarRefT< ItemType, DataTypeT > &rhs)
Constructs a reference from rhs.
const DataTypeT & operator[](ItemLocalIdType i) const
Read-only value of entity item.
MeshVariableScalarRefT(IVariable *var)
Constructs a reference from var.
const DataTypeT & operator()(ItemLocalIdType i) const
Read-only value of entity item.
PrivateVariableScalarT(const VariableBuildInfo &vb, const VariableInfo &vi)
1D data vector with value semantics (STL style).
Parameters necessary for building a variable.
Information characterizing a variable.
VariableRef(const VariableBuildInfo &vbi)
Constructs a reference to a variable with the infos vbi.
Information characterizing the type of a variable.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
eItemKind
Mesh entity type.
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.