Arcane  v3.16.0.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
IMeshMaterialVariable.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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-2024 */
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#include "arcane/core/materials/internal/IMeshMaterialVariableInternal.h"
25
26#include "arcane/core/VariableDataTypeTraits.h"
27
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane::Materials
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38template<typename TrueType> MaterialVariableTypeInfo
41{
42 using ItemType = typename TrueType::ItemTypeType;
43 using DataType = typename TrueType::DataTypeType;
44 int dim = TrueType::dimension();
46 eDataType dt = VariableDataTypeTraitsT<DataType>::type();
47 return MaterialVariableTypeInfo(ik,dt,dim,space);
48}
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/
52
53template<typename TrueType> TrueType*
56{
57 MaterialVariableTypeInfo x = _buildVarTypeInfo(mvs);
58
59 MeshHandle mesh_handle = v.meshHandle();
60 if (mesh_handle.isNull())
61 ARCANE_FATAL("No mesh handle for material variable");
62
63 IMeshMaterialMng* mat_mng = v.materialMng();
64
65 // TODO: regarder si verrou necessaire
66 if (!mat_mng)
67 mat_mng = IMeshMaterialMng::getReference(mesh_handle,true);
68
69 IMeshMaterialVariableFactoryMng* vm = mat_mng->variableFactoryMng();
70 IMeshMaterialVariable* var = vm->createVariable(x.fullName(),v);
71
72 auto* true_var = dynamic_cast<TrueType*>(var);
73 ARCANE_CHECK_POINTER(true_var);
74 return true_var;
75}
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
79
80#define ARCANE_INSTANTIATE_MAT(type) \
81 template class ARCANE_TEMPLATE_EXPORT MeshMaterialVariableBuildTraits<IScalarMeshMaterialVariable<Cell,type>>; \
82 template class ARCANE_TEMPLATE_EXPORT MeshMaterialVariableBuildTraits<IArrayMeshMaterialVariable<Cell,type>>
83
84ARCANE_INSTANTIATE_MAT(Byte);
85ARCANE_INSTANTIATE_MAT(Int8);
86ARCANE_INSTANTIATE_MAT(Int16);
87ARCANE_INSTANTIATE_MAT(Int32);
88ARCANE_INSTANTIATE_MAT(Int64);
89ARCANE_INSTANTIATE_MAT(BFloat16);
90ARCANE_INSTANTIATE_MAT(Float16);
91ARCANE_INSTANTIATE_MAT(Float32);
92ARCANE_INSTANTIATE_MAT(Real);
93ARCANE_INSTANTIATE_MAT(Real2);
94ARCANE_INSTANTIATE_MAT(Real3);
95ARCANE_INSTANTIATE_MAT(Real2x2);
96ARCANE_INSTANTIATE_MAT(Real3x3);
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101} // End namespace Arcane::Materials
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
#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.
static eItemKind kind()
Genre de l'entité
Definition ItemTypes.h:624
Interface du gestionnaire des matériaux et des milieux d'un maillage.
static IMeshMaterialMng * getReference(const MeshHandleOrMesh &mesh_handle, bool create=true)
Récupère ou créé la référence associée à mesh.
Interface d'une variable matériau d'un maillage.
Informations caractérisant le type d'une variable matériau.
Classe pour gérer la création du type concret de la variable matériaux.
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.