Arcane  v3.16.9.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
core/materials/MeshMaterialVariableRef.h
Aller à la documentation de ce fichier.
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/* MeshMaterialVariableRef.h (C) 2000-2025 */
9/* */
10/* Référence à une variable sur un matériau du maillage. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MATERIALS_MESHMATERIALVARIABLEREF_H
13#define ARCANE_CORE_MATERIALS_MESHMATERIALVARIABLEREF_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
22#include "arcane/utils/NotImplementedException.h"
23#include "arcane/utils/Array2View.h"
24
25#include "arcane/core/Item.h"
26#include "arcane/core/VariableRef.h"
27
28#include "arcane/core/materials/IMeshMaterialVariable.h"
30#include "arcane/core/materials/MeshMaterialVariableComputeFunction.h"
31#include "arcane/core/materials/IScalarMeshMaterialVariable.h"
32#include "arcane/core/materials/IArrayMeshMaterialVariable.h"
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37namespace Arcane::Materials
38{
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
46class ARCANE_CORE_EXPORT MeshMaterialVariableRef
47{
48 public:
49 class Enumerator
50 {
51 public:
52
53 explicit Enumerator(const IMeshMaterialVariable* vp)
54 : m_vref(vp->firstReference())
55 {
56 }
57 void operator++()
58 {
59 m_vref = m_vref->nextReference();
60 }
61 MeshMaterialVariableRef* operator*() const
62 {
63 return m_vref;
64 }
65 bool hasNext() const
66 {
67 return m_vref;
68 }
69
70 private:
71
72 MeshMaterialVariableRef* m_vref = nullptr;
73 };
74
75 public:
76
77 MeshMaterialVariableRef();
78 virtual ~MeshMaterialVariableRef();
79
80 public:
81
83 MeshMaterialVariableRef* previousReference();
84
86 MeshMaterialVariableRef* nextReference();
87
94 void setPreviousReference(MeshMaterialVariableRef* v);
95
102 void setNextReference(MeshMaterialVariableRef* v);
103
105 void registerVariable();
106
108 void unregisterVariable();
109
110 virtual void updateFromInternal() =0;
111
114
116 void synchronize();
117
119 void synchronize(MeshMaterialVariableSynchronizerList& sync_list);
120
122 MatVarSpace space() const { return m_material_variable->space(); }
123
134 {
135 m_material_variable->fillPartialValuesWithSuperValues(level);
136 }
137
138 public:
139
140 // Fonctions issues de VariableRef. A terme, il faudra que la variable
141 // materiau dérive de la variable classique.
143 String name() const;
144 void setUpToDate();
145 bool isUsed() const;
146 void update();
147 void addDependCurrentTime(const VariableRef& var);
148 void addDependCurrentTime(const VariableRef& var,const TraceInfo& tinfo);
149 void addDependCurrentTime(const MeshMaterialVariableRef& var);
150 void addDependPreviousTime(const MeshMaterialVariableRef& var);
151 void removeDepend(const MeshMaterialVariableRef& var);
152 template<typename ClassType> void
153 setComputeFunction(ClassType* instance,void (ClassType::*func)())
154 { m_global_variable->setComputeFunction(new VariableComputeFunction(instance,func)); }
156
158
159 void setUpToDate(IMeshMaterial*);
160 void update(IMeshMaterial*);
161 void addMaterialDepend(const VariableRef& var);
162 void addMaterialDepend(const VariableRef& var,const TraceInfo& tinfo);
163 void addMaterialDepend(const MeshMaterialVariableRef& var);
164 void addMaterialDepend(const MeshMaterialVariableRef& var,const TraceInfo& tinfo);
165 template<typename ClassType> void
166 setMaterialComputeFunction(ClassType* instance,void (ClassType::*func)(IMeshMaterial*))
167 { m_material_variable->setComputeFunction(new MeshMaterialVariableComputeFunction(instance,func)); }
169
170 protected:
171
172 void _internalInit(IMeshMaterialVariable* mat_variable);
173 bool _isRegistered() const { return m_is_registered; }
174
175 private:
176
179
181 MeshMaterialVariableRef* m_previous_reference = nullptr;
182
184 MeshMaterialVariableRef* m_next_reference = nullptr;
185
188
189 bool m_is_registered = false;
190
191 private:
192 void _checkValid() const
193 {
194#ifdef ARCANE_CHECK
196 _throwInvalid();
197#endif
198 }
199 void _throwInvalid() const;
200};
201
202/*---------------------------------------------------------------------------*/
203/*---------------------------------------------------------------------------*/
210template<typename DataType_>
212: public MeshMaterialVariableRef
213{
214 public:
215
216 using DataType = DataType_;
217 using PrivatePartType = IScalarMeshMaterialVariable<Cell, DataType>;
218 using ItemType = Cell;
219 using GlobalVariableRefType = MeshVariableScalarRefT<ItemType, DataType>;
221
222 public:
223
225 explicit ARCANE_CORE_EXPORT CellMaterialVariableScalarRef(const VariableBuildInfo& vb);
227 explicit ARCANE_CORE_EXPORT CellMaterialVariableScalarRef(const MaterialVariableBuildInfo& vb);
234 explicit ARCANE_CORE_EXPORT CellMaterialVariableScalarRef(IMeshMaterialVariable* var);
235 ARCANE_CORE_EXPORT CellMaterialVariableScalarRef(const ThatClass& rhs);
236
237 public:
238
240 ARCANE_CORE_EXPORT ThatClass& operator=(const ThatClass& rhs) = delete;
243
244 public:
245
247 ARCANE_CORE_EXPORT virtual void refersTo(const ThatClass& rhs);
248
252 ARCANE_CORE_EXPORT void updateFromInternal() override;
253
254 protected:
255
256 DataType operator[](MatVarIndex mvi) const
257 {
258 return m_value[mvi.arrayIndex()][mvi.valueIndex()];
259 }
260 DataType& operator[](MatVarIndex mvi)
261 {
262 return m_value[mvi.arrayIndex()][mvi.valueIndex()];
263 }
264
265 public:
266
268 DataType operator[](ComponentItemLocalId mc) const
269 {
270 return this->operator[](mc.localId());
271 }
272
274 DataType& operator[](ComponentItemLocalId mc)
275 {
276 return this->operator[](mc.localId());
277 }
278
281 {
282 return this->operator[](mc._varIndex());
283 }
284
287 {
288 return this->operator[](mc._varIndex());
289 }
290
292 DataType operator[](CellLocalId c) const
293 {
294 return m_value[0][c.localId()];
295 }
296
298 DataType& operator[](CellLocalId c)
299 {
300 return m_value[0][c.localId()];
301 }
302
304 DataType operator[](PureMatVarIndex mvi) const
305 {
306 return m_value[0][mvi.valueIndex()];
307 }
308
311 {
312 return m_value[0][mvi.valueIndex()];
313 }
314
319 ARCANE_CORE_EXPORT DataType matValue(AllEnvCell c,Int32 mat_id) const;
320
325 ARCANE_CORE_EXPORT DataType envValue(AllEnvCell c,Int32 env_id) const;
326
327 public:
328
329 ARCANE_CORE_EXPORT void fillFromArray(IMeshMaterial* mat,ConstArrayView<DataType> values);
330 ARCANE_CORE_EXPORT void fillFromArray(IMeshMaterial* mat,ConstArrayView<DataType> values,Int32ConstArrayView indexes);
331 ARCANE_CORE_EXPORT void fillToArray(IMeshMaterial* mat,ArrayView<DataType> values);
332 ARCANE_CORE_EXPORT void fillToArray(IMeshMaterial* mat,ArrayView<DataType> values,Int32ConstArrayView indexes);
333 ARCANE_CORE_EXPORT void fillToArray(IMeshMaterial* mat,Array<DataType>& values);
334 ARCANE_CORE_EXPORT void fillToArray(IMeshMaterial* mat,Array<DataType>& values,Int32ConstArrayView indexes);
335 ARCANE_CORE_EXPORT void fill(const DataType& value);
336 ARCANE_CORE_EXPORT void fillPartialValues(const DataType& value);
337
338 public:
339
341 ARCANE_CORE_EXPORT GlobalVariableRefType& globalVariable();
343 ARCANE_CORE_EXPORT const GlobalVariableRefType& globalVariable() const;
344
345 private:
346
347 PrivatePartType* m_private_part = nullptr;
348 ArrayView<DataType>* m_value = nullptr;
349 ArrayView<ArrayView<DataType>> m_container_value;
350
351 private:
352
353 void _init();
354 void _setContainerView();
355
356 public:
357
358 // TODO: Temporaire. a supprimer.
359 ArrayView<DataType>* _internalValue() const { return m_value; }
360
361 public:
362
363#ifdef ARCANE_DOTNET
364 // Uniquement pour le wrapper C#
365 // TODO: a terme utiliser 'm_container_view' à la place
366 void* _internalValueAsPointerOfPointer() { return reinterpret_cast<void*>(&m_value); }
367#endif
368};
369
370/*---------------------------------------------------------------------------*/
371/*---------------------------------------------------------------------------*/
377template<typename DataType_>
379: public MeshMaterialVariableRef
380{
381 public:
382
383 using DataType = DataType_;
384 using PrivatePartType = IArrayMeshMaterialVariable<Cell, DataType>;
385 using ItemType = Cell;
386 using GlobalVariableRefType = MeshVariableArrayRefT<ItemType, DataType>;
388
389 public:
390
392 explicit ARCANE_CORE_EXPORT CellMaterialVariableArrayRef(const VariableBuildInfo& vb);
394 explicit ARCANE_CORE_EXPORT CellMaterialVariableArrayRef(const MaterialVariableBuildInfo& vb);
401 explicit ARCANE_CORE_EXPORT CellMaterialVariableArrayRef(IMeshMaterialVariable* var);
402 ARCANE_CORE_EXPORT CellMaterialVariableArrayRef(const ThatClass& rhs);
403
404 public:
405
407 ARCANE_CORE_EXPORT ThatClass& operator=(const ThatClass& rhs) = delete;
410
411 public:
412
414 ARCANE_CORE_EXPORT virtual void refersTo(const ThatClass& rhs);
415
419 ARCANE_CORE_EXPORT void updateFromInternal() override;
420
421 public:
422
424 ARCANE_CORE_EXPORT GlobalVariableRefType& globalVariable();
426 ARCANE_CORE_EXPORT const GlobalVariableRefType& globalVariable() const;
427
428 public:
429
436 ARCANE_CORE_EXPORT void resize(Integer dim2_size);
437
438 protected:
439
440 ConstArrayView<DataType> operator[](MatVarIndex mvi) const
441 {
442 return m_value[mvi.arrayIndex()][mvi.valueIndex()];
443 }
444 ArrayView<DataType> operator[](MatVarIndex mvi)
445 {
446 return m_value[mvi.arrayIndex()][mvi.valueIndex()];
447 }
448
449 public:
450
452 ConstArrayView<DataType> operator[](ComponentItemLocalId mc) const
453 {
454 return this->operator[](mc.localId());
455 }
456
458 ArrayView<DataType> operator[](ComponentItemLocalId mc)
459 {
460 return this->operator[](mc.localId());
461 }
462
465 {
466 return m_value[0][c.localId()];
467 }
468
471 {
472 return m_value[0][c.localId()];
473 }
474
477 {
478 return m_value[0][mvi.valueIndex()];
479 }
480
483 {
484 return m_value[0][mvi.valueIndex()];
485 }
486
487 private:
488
489 PrivatePartType* m_private_part = nullptr;
490 Array2View<DataType>* m_value = nullptr;
491 ArrayView<Array2View<DataType>> m_container_value;
492
493 private:
494
495 void _init();
496 void _setContainerView();
497};
498
499/*---------------------------------------------------------------------------*/
500/*---------------------------------------------------------------------------*/
501
520
521#ifdef ARCANE_64BIT
524#else
527#endif
528
529/*---------------------------------------------------------------------------*/
530/*---------------------------------------------------------------------------*/
531
550
551#ifdef ARCANE_64BIT
554#else
557#endif
558
559/*---------------------------------------------------------------------------*/
560/*---------------------------------------------------------------------------*/
561
562} // End namespace Arcane::Materials
563
564/*---------------------------------------------------------------------------*/
565/*---------------------------------------------------------------------------*/
566
567#endif
568
Vue modifiable pour un tableau 2D.
Vue modifiable d'un tableau d'un type T.
Tableau d'items de types quelconques.
Maille d'un maillage.
Definition Item.h:1205
Vue constante d'un tableau de type T.
Interface d'une variable.
Definition IVariable.h:39
Maille arcane avec info matériaux et milieux.
Enumérateur sur les constituants d'une maille.
Variable tableau sur les mailles d'un matériau du maillage. Pour l'instant, cette classe n'est instan...
ArrayView< DataType > operator[](CellLocalId c)
Valeur globale de la variable pour la maille c.
ConstArrayView< DataType > operator[](ComponentItemLocalId mc) const
Valeur partielle de la variable pour la maille matériau mc.
CellMaterialVariableArrayRef()=delete
Constructeur vide (interdit)
ArrayView< DataType > operator[](PureMatVarIndex mvi)
Valeur de la variable pour la maille matériau mvi.
CellMaterialVariableArrayRef(const VariableBuildInfo &vb)
Construit une référence à la variable spécifiée dans vb.
CellMaterialVariableArrayRef(IMeshMaterialVariable *var)
Construit une référence à la variable var.
ThatClass & operator=(const ThatClass &rhs)=delete
Opérateur de recopie (interdit)
ConstArrayView< DataType > operator[](CellLocalId c) const
Valeur globale de la variable pour la maille c.
CellMaterialVariableArrayRef(const MaterialVariableBuildInfo &vb)
Construit une référence à la variable spécifiée dans vb.
const GlobalVariableRefType & globalVariable() const
Variable globale associée à cette variable matériau.
GlobalVariableRefType & globalVariable()
Variable globale associée à cette variable matériau.
ArrayView< DataType > operator[](ComponentItemLocalId mc)
Valeur partielle de la variable pour la maille matériau mc.
virtual void refersTo(const ThatClass &rhs)
Positionne la référence de l'instance à la variable rhs.
void resize(Integer dim2_size)
Redimensionne le nombre d'éléments du tableau.
ConstArrayView< DataType > operator[](PureMatVarIndex mvi) const
Valeur de la variable pour la maille matériau mvi.
Variable scalaire sur les mailles d'un matériau du maillage.
DataType matValue(AllEnvCell c, Int32 mat_id) const
Valeur de la variable pour le matériau d'index mat_id de la maille ou 0 si absent de la maille.
DataType & operator[](ComponentItemLocalId mc)
Valeur partielle de la variable pour la maille matériau mc.
void fillToArray(IMeshMaterial *mat, Array< DataType > &values, Int32ConstArrayView indexes)
Remplit un tableau à partir des valeurs de la variable pour un matériau.
CellMaterialVariableScalarRef(const VariableBuildInfo &vb)
Construit une référence à la variable spécifiée dans vb.
DataType operator[](PureMatVarIndex mvi) const
Valeur de la variable pour la maille matériau mvi.
const GlobalVariableRefType & globalVariable() const
Variable globale associée à cette variable matériau.
DataType envValue(AllEnvCell c, Int32 env_id) const
Valeur de la variable pour le milieu d'index env_id de la maille ou 0 si absent de la maille.
DataType operator[](ComponentItemLocalId mc) const
Valeur partielle de la variable pour la maille matériau mc.
void fillFromArray(IMeshMaterial *mat, ConstArrayView< DataType > values, Int32ConstArrayView indexes)
Remplit les valeurs de la variable pour un matériau.
DataType & operator[](CellComponentCellEnumerator mc)
Valeur partielle de la variable pour l'itérateur mc.
void fill(const DataType &value)
Remplit les valeurs partielles et globales de la variable avec la valeur value.
CellMaterialVariableScalarRef(IMeshMaterialVariable *var)
Construit une référence à la variable var.
void fillPartialValues(const DataType &value)
Remplit les valeurs partielles de la variable avec la valeur value.
void fillToArray(IMeshMaterial *mat, ArrayView< DataType > values, Int32ConstArrayView indexes)
Remplit un tableau à partir des valeurs de la variable pour un matériau.
void fillToArray(IMeshMaterial *mat, Array< DataType > &values)
Remplit un tableau à partir des valeurs de la variable pour un matériau.
CellMaterialVariableScalarRef(const MaterialVariableBuildInfo &vb)
Construit une référence à la variable spécifiée dans vb.
void fillFromArray(IMeshMaterial *mat, ConstArrayView< DataType > values)
Remplit les valeurs de la variable pour un matériau.
GlobalVariableRefType & globalVariable()
Variable globale associée à cette variable matériau.
DataType operator[](CellComponentCellEnumerator mc) const
Valeur partielle de la variable pour l'itérateur mc.
DataType operator[](CellLocalId c) const
Valeur globale de la variable pour la maille c.
DataType & operator[](CellLocalId c)
Valeur globale de la variable pour la maille c.
virtual void refersTo(const ThatClass &rhs)
Positionne la référence de l'instance à la variable rhs.
CellMaterialVariableScalarRef()=delete
Constructeur vide (interdit)
ThatClass & operator=(const ThatClass &rhs)=delete
Opérateur de recopie (interdit)
void fillToArray(IMeshMaterial *mat, ArrayView< DataType > values)
Remplit un tableau à partir des valeurs de la variable pour un matériau.
DataType & operator[](PureMatVarIndex mvi)
Valeur de la variable pour la maille matériau mvi.
constexpr __host__ __device__ MatVarIndex localId() const
Index générique pour accéder aux valeurs d'une variable.
Interface d'accès pour CellMaterialVariableArrayRef.
Interface d'une variable matériau d'un maillage.
virtual MeshMaterialVariableRef * firstReference() const =0
Interface d'un matériau d'un maillage.
Interface d'accès pour CellMaterialVariableScalarRef.
Représente un index sur les variables matériaux et milieux.
constexpr __host__ __device__ Int32 arrayIndex() const
Retourne l'indice du tableau de valeur dans la liste des variables.
constexpr __host__ __device__ Int32 valueIndex() const
Retourne l'indice dans le tableau de valeur.
Classe de base des références aux variables matériaux.
MeshMaterialVariableRef * nextReference()
Référence suivante (ou null) sur variable()
IMeshMaterialVariable * materialVariable() const
Variable matériau associée.
MatVarSpace space() const
Espace de définition de la variable (matériau+milieu ou milieu uniquement)
void setNextReference(MeshMaterialVariableRef *v)
Positionne la référence suivante.
IMeshMaterialVariable * m_material_variable
Variable associée.
MeshMaterialVariableRef * previousReference()
Référence précédente (ou null) sur variable()
void unregisterVariable()
Supprime l'enregistrement de la variable (interne)
void fillPartialValuesWithSuperValues(Int32 level)
Remplit les valeurs partielles avec la valeur de la maille du dessus. Si level vaut LEVEL_MATERIAL,...
void registerVariable()
Enregistre la variable (interne)
MeshMaterialVariableRef * m_next_reference
Référence suivante sur m_variable.
MeshMaterialVariableRef * m_previous_reference
Référence précédente sur m_variable.
void setPreviousReference(MeshMaterialVariableRef *v)
Positionne la référence précédente.
Index d'un Item matériaux pure dans une variable.
Variable tableau sur un type d'entité du maillage.
Variable scalaire sur un type d'entité du maillage.
Chaîne de caractères unicode.
Paramètres nécessaires à la construction d'une variable.
Interface de la classe functor de re-calcul d'une variable.
Référence à une variable.
Definition VariableRef.h:56
Active toujours les traces dans les parties Arcane concernant les matériaux.
CellMaterialVariableArrayRef< Int32 > MaterialVariableCellArrayInt32
Variable matériau de type tableau de Int32
CellMaterialVariableScalarRef< Real2x2 > MaterialVariableCellReal2x2
Variable matériau de type Real2x2
MaterialVariableCellArrayInt32 MaterialVariableCellArrayInteger
Variable matériau de type tableau de Integer
MaterialVariableCellInt32 MaterialVariableCellInteger
Variable matériau de type Integer
CellMaterialVariableArrayRef< Real3 > MaterialVariableCellArrayReal3
Variable matériau de type tableau de Real3
CellMaterialVariableArrayRef< Int16 > MaterialVariableCellArrayInt16
Variable matériau de type tableau de Int16
CellMaterialVariableScalarRef< Int16 > MaterialVariableCellInt16
Variable matériau de type Int16
CellMaterialVariableScalarRef< Real2 > MaterialVariableCellReal2
Variable matériau de type Real2
CellMaterialVariableScalarRef< Real3x3 > MaterialVariableCellReal3x3
Variable matériau de type Real3x3
CellMaterialVariableArrayRef< Byte > MaterialVariableCellArrayByte
Variable matériau de type tableau de Byte
CellMaterialVariableArrayRef< Real2x2 > MaterialVariableCellArrayReal2x2
Variable matériau de type tableau de Real2x2
CellMaterialVariableScalarRef< Byte > MaterialVariableCellByte
Variable matériau de type Byte
CellMaterialVariableScalarRef< Int64 > MaterialVariableCellInt64
Variable matériau de type Int64
CellMaterialVariableArrayRef< Real2 > MaterialVariableCellArrayReal2
Variable matériau de type tableau de Real2
CellMaterialVariableScalarRef< Real3 > MaterialVariableCellReal3
Variable matériau de type Real3
CellMaterialVariableArrayRef< Int64 > MaterialVariableCellArrayInt64
Variable matériau de type tableau de Int64
CellMaterialVariableScalarRef< Real > MaterialVariableCellReal
Variable matériau de type Real
MatVarSpace
Espace de définition d'une variable matériau.
CellMaterialVariableScalarRef< Int32 > MaterialVariableCellInt32
Variable matériau de type Int32
CellMaterialVariableArrayRef< Real > MaterialVariableCellArrayReal
Variable matériau de type tableau de Real
CellMaterialVariableArrayRef< Real3x3 > MaterialVariableCellArrayReal3x3
Variable matériau de type tableau de Real3x3
Int32 Integer
Type représentant un entier.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:569
std::int32_t Int32
Type entier signé sur 32 bits.