Arcane  v3.15.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
39MeshMaterialVariableBuildTraits<TrueType>::
40_buildVarTypeInfo(MatVarSpace space)
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*
54MeshMaterialVariableBuildTraits<TrueType>::
55getVariableReference(const MaterialVariableBuildInfo& v,MatVarSpace mvs)
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
static IMeshMaterialMng * getReference(const MeshHandleOrMesh &mesh_handle, bool create=true)
Récupère ou créé la référence associée à mesh.
Active toujours les traces dans les parties Arcane concernant les matériaux.
MatVarSpace
Espace de définition d'une variable matériau.
Arccore::Float16 Float16
Type 'Float16' (binary16)
Arccore::Int8 Int8
Type représentant un entier sur 8 bits.
Arccore::BFloat16 BFloat16
Type 'Brain Float16'.
eItemKind
Genre d'entité de maillage.
float Float32
Type flottant IEEE-753 simple précision (binary32)
unsigned char Byte
Type d'un octet.
Definition UtilsTypes.h:148
eDataType
Type d'une donnée.
Definition DataTypes.h:39