Arcane  v3.16.9.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
IMeshMaterialVariable.cc
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/* IMeshMaterialVariable.cc (C) 2000-2025 */
9/* */
10/* Interface des variables matériaux. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/materials/IMeshMaterialVariable.h"
15
16#include "arcane/utils/FatalErrorException.h"
17
18#include "arcane/core/materials/IScalarMeshMaterialVariable.h"
19#include "arcane/core/materials/IArrayMeshMaterialVariable.h"
20#include "arcane/core/materials/MaterialVariableTypeInfo.h"
21#include "arcane/core/materials/MaterialVariableBuildInfo.h"
22#include "arcane/core/materials/IMeshMaterialMng.h"
23#include "arcane/core/materials/IMeshMaterialVariableFactoryMng.h"
24
25#include "arcane/core/VariableDataTypeTraits.h"
26#include "arcane/core/IVariable.h"
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane::Materials
32{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37template<typename TrueType> MaterialVariableTypeInfo
40{
41 using ItemType = typename TrueType::ItemTypeType;
42 using DataType = typename TrueType::DataTypeType;
43 int dim = TrueType::dimension();
45 eDataType dt = VariableDataTypeTraitsT<DataType>::type();
46 return MaterialVariableTypeInfo(ik,dt,dim,space);
47}
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
57template <typename TrueType> TrueType*
60{
61 MaterialVariableTypeInfo x = _buildVarTypeInfo(mvs);
62
63 MeshHandle mesh_handle = v.meshHandle();
64 if (mesh_handle.isNull())
65 ARCANE_FATAL("No mesh handle for material variable");
66
67 // Si le gestionnaire de matériaux n'existe pas encore, on le créé.
68 IMeshMaterialMng* mat_mng = v.materialMng();
69 // TODO: regarder si verrou necessaire
70 if (!mat_mng)
71 mat_mng = IMeshMaterialMng::getReference(mesh_handle,true);
72
75
76 auto* true_var = dynamic_cast<TrueType*>(var);
77 ARCANE_CHECK_POINTER(true_var);
78 return true_var;
79}
80
81/*---------------------------------------------------------------------------*/
82/*---------------------------------------------------------------------------*/
89template <typename TrueType> TrueType*
92{
94 auto* true_var = dynamic_cast<TrueType*>(var);
95 if (!true_var)
96 ARCANE_FATAL("Can not convert variable '{0}' in the template type of this class", var->globalVariable()->fullName());
97 return true_var;
98}
99
100/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/
102
103#define ARCANE_INSTANTIATE_MAT(type) \
104 template class ARCANE_TEMPLATE_EXPORT MeshMaterialVariableBuildTraits<IScalarMeshMaterialVariable<Cell,type>>; \
105 template class ARCANE_TEMPLATE_EXPORT MeshMaterialVariableBuildTraits<IArrayMeshMaterialVariable<Cell,type>>
106
107ARCANE_INSTANTIATE_MAT(Byte);
108ARCANE_INSTANTIATE_MAT(Int8);
109ARCANE_INSTANTIATE_MAT(Int16);
110ARCANE_INSTANTIATE_MAT(Int32);
111ARCANE_INSTANTIATE_MAT(Int64);
112ARCANE_INSTANTIATE_MAT(BFloat16);
113ARCANE_INSTANTIATE_MAT(Float16);
114ARCANE_INSTANTIATE_MAT(Float32);
115ARCANE_INSTANTIATE_MAT(Real);
116ARCANE_INSTANTIATE_MAT(Real2);
117ARCANE_INSTANTIATE_MAT(Real3);
118ARCANE_INSTANTIATE_MAT(Real2x2);
119ARCANE_INSTANTIATE_MAT(Real3x3);
120
121/*---------------------------------------------------------------------------*/
122/*---------------------------------------------------------------------------*/
123
124} // End namespace Arcane::Materials
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Type flottant demi-précision.
virtual String fullName() const =0
Nom complet de la variable (avec le préfixe de la famille)
static eItemKind kind()
Genre de l'entité
Definition ItemTypes.h:624
Interface du gestionnaire des matériaux et des milieux d'un maillage.
virtual IMeshMaterialVariableFactoryMng * variableFactoryMng() const =0
Interface de la fabrique de variables.
static IMeshMaterialMng * getReference(const MeshHandleOrMesh &mesh_handle, bool create=true)
Récupère ou créé la référence associée à mesh.
Interface du gestionnaire de fabrique de variables matériaux.
virtual IMeshMaterialVariable * createVariable(const String &storage_type, const MaterialVariableBuildInfo &build_info)=0
Créé une variable matériau.
Interface d'une variable matériau d'un maillage.
virtual IVariable * globalVariable() const =0
Variable globale sur le maillage associée.
Informations caractérisant le type d'une variable matériau.
String fullName() const
Nom complet du type de la variable.
Classe pour gérer la création du type concret de la variable matériaux.
static TrueType * getVariableReference(const MaterialVariableBuildInfo &v, MatVarSpace mvs)
Retourne une variable associée à un constituant.
Handle sur un maillage.
Definition MeshHandle.h:47
bool isNull() const
Indique si le handle est nul (il ne référence aucun maillage existant ou non)
Definition MeshHandle.h:162
Classe gérant un vecteur de réel de dimension 2.
Definition Real2.h:121
Classe gérant une matrice de réel de dimension 2x2.
Definition Real2x2.h:53
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Classe gérant une matrice de réel de dimension 3x3.
Definition Real3x3.h:66
Active toujours les traces dans les parties Arcane concernant les matériaux.
MatVarSpace
Espace de définition d'une variable matériau.
std::int8_t Int8
Type entier signé sur 8 bits.
std::int64_t Int64
Type entier signé sur 64 bits.
eItemKind
Genre d'entité de maillage.
std::int16_t Int16
Type entier signé sur 16 bits.
double Real
Type représentant un réel.
unsigned char Byte
Type d'un octet.
Definition BaseTypes.h:43
float Float32
Type flottant IEEE-753 simple précision.
eDataType
Type d'une donnée.
Definition DataTypes.h:39
std::int32_t Int32
Type entier signé sur 32 bits.
Structure équivalente à la valeur booléenne vrai.