Arcane  v3.14.10.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-2023 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-2023 */
9/* */
10/* Interface des variables matériaux. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/materials/IMeshMaterialVariable.h"
15#include "arcane/core/materials/IScalarMeshMaterialVariable.h"
16#include "arcane/core/materials/IArrayMeshMaterialVariable.h"
17#include "arcane/core/materials/MaterialVariableTypeInfo.h"
18#include "arcane/core/materials/MaterialVariableBuildInfo.h"
19#include "arcane/core/materials/IMeshMaterialMng.h"
20#include "arcane/core/materials/IMeshMaterialVariableFactoryMng.h"
21#include "arcane/core/materials/internal/IMeshMaterialVariableInternal.h"
22
23#include "arcane/utils/FatalErrorException.h"
24
25#include "arcane/VariableDataTypeTraits.h"
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Arcane::Materials
31{
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36template<typename TrueType> MaterialVariableTypeInfo
37MeshMaterialVariableBuildTraits<TrueType>::
38_buildVarTypeInfo(MatVarSpace space)
39{
40 using ItemType = typename TrueType::ItemTypeType;
41 using DataType = typename TrueType::DataTypeType;
42 int dim = TrueType::dimension();
44 eDataType dt = VariableDataTypeTraitsT<DataType>::type();
45 return MaterialVariableTypeInfo(ik,dt,dim,space);
46}
47
48/*---------------------------------------------------------------------------*/
49/*---------------------------------------------------------------------------*/
50
51template<typename TrueType> TrueType*
52MeshMaterialVariableBuildTraits<TrueType>::
53getVariableReference(const MaterialVariableBuildInfo& v,MatVarSpace mvs)
54{
55 MaterialVariableTypeInfo x = _buildVarTypeInfo(mvs);
56
57 MeshHandle mesh_handle = v.meshHandle();
58 if (mesh_handle.isNull())
59 ARCANE_FATAL("No mesh handle for material variable");
60
61 IMeshMaterialMng* mat_mng = v.materialMng();
62
63 // TODO: regarder si verrou necessaire
64 if (!mat_mng)
65 mat_mng = IMeshMaterialMng::getReference(mesh_handle,true);
66
67 IMeshMaterialVariableFactoryMng* vm = mat_mng->variableFactoryMng();
68 IMeshMaterialVariable* var = vm->createVariable(x.fullName(),v);
69
70 auto* true_var = dynamic_cast<TrueType*>(var);
71 ARCANE_CHECK_POINTER(true_var);
72 return true_var;
73}
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
78#define ARCANE_INSTANTIATE_MAT(type) \
79 template class ARCANE_TEMPLATE_EXPORT MeshMaterialVariableBuildTraits<IScalarMeshMaterialVariable<Cell,type>>; \
80 template class ARCANE_TEMPLATE_EXPORT MeshMaterialVariableBuildTraits<IArrayMeshMaterialVariable<Cell,type>>
81
82ARCANE_INSTANTIATE_MAT(Byte);
83ARCANE_INSTANTIATE_MAT(Int16);
84ARCANE_INSTANTIATE_MAT(Int32);
85ARCANE_INSTANTIATE_MAT(Int64);
86ARCANE_INSTANTIATE_MAT(Real);
87ARCANE_INSTANTIATE_MAT(Real2);
88ARCANE_INSTANTIATE_MAT(Real3);
89ARCANE_INSTANTIATE_MAT(Real2x2);
90ARCANE_INSTANTIATE_MAT(Real3x3);
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95} // End namespace Arcane::Materials
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
#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
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
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.
eItemKind
Genre d'entité de maillage.
unsigned char Byte
Type d'un octet.
Definition UtilsTypes.h:142
eDataType
Type d'une donnée.
Definition DataTypes.h:39