Arcane  v3.15.3.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ItemMaterialVariableBaseT.H
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/* ItemMaterialVariableBaseT.h (C) 2000-2024 */
9/* */
10/* Implémentation de la classe de base des variables matériaux. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/Mutex.h"
15#include "arcane/utils/ArgumentException.h"
16#include "arcane/utils/FatalErrorException.h"
18
19#include "arcane/core/Observer.h"
20#include "arcane/core/IMesh.h"
21#include "arcane/core/IVariable.h"
22#include "arcane/core/IItemFamily.h"
23#include "arcane/core/VariableInfo.h"
24#include "arcane/core/internal/IDataInternal.h"
25#include "arcane/core/materials/MaterialVariableBuildInfo.h"
26#include "arcane/core/materials/IMeshMaterialMng.h"
27#include "arcane/core/materials/IMeshMaterialVariableFactoryMng.h"
28#include "arcane/core/materials/internal/IMeshMaterialMngInternal.h"
29
30#include "arcane/materials/MeshMaterialVariableRef.h"
31#include "arcane/materials/internal/ComponentItemListBuilder.h"
32#include "arcane/materials/internal/MeshMaterialVariablePrivate.h"
33#include "arcane/materials/internal/MeshMaterialVariableIndexer.h"
34
35#include "arcane/accelerator/core/RunQueue.h"
36#include "arcane/accelerator/core/Memory.h"
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
42namespace Arcane::Materials
43{
44
45namespace
46{
47
48// Allocateur utilisé pour les vues
49// On utilise la mémoire de l'accélérateur si l'exécution se fait sur accélérateur
50MemoryAllocationOptions
51_getViewAllocator(IMeshMaterialMng* mm)
52{
53 eMemoryRessource r = eMemoryRessource::Host;
54 if (mm->_internalApi()->runQueue().isAcceleratorPolicy())
55 r = eMemoryRessource::Device;
57}
58
59}
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
64template<typename Traits>
65ItemMaterialVariableBase<Traits>::
66ItemMaterialVariableBase(const MaterialVariableBuildInfo& v,
67 PrivatePartType* global_var,
68 VariableRef* global_var_ref,MatVarSpace mvs)
69: MeshMaterialVariable(v,mvs)
70, m_global_variable(global_var)
71, m_global_variable_ref(global_var_ref)
72, m_device_views(_getViewAllocator(m_p->materialMng()))
73, m_host_views(MemoryUtils::getAllocationOptions(eMemoryRessource::HostPinned))
74{
75 m_device_views.setDebugName(String("ItemMaterialVariableViews") + v.name());
76}
77
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81
82template<typename Traits>
83ItemMaterialVariableBase<Traits>::
84~ItemMaterialVariableBase()
85{
86 Integer nb_var = m_p->m_refs.size();
87 delete m_global_variable_ref;
88 for( Integer i=1; i<nb_var; ++i ){
89 delete m_p->m_refs[i];
90 }
91 m_p->m_refs.clear();
92 m_vars.clear();
93}
94
95/*---------------------------------------------------------------------------*/
96/*---------------------------------------------------------------------------*/
97
98template<typename Traits> IVariable*
100globalVariable() const
101{
102 return m_global_variable;
103}
104
105/*---------------------------------------------------------------------------*/
106/*---------------------------------------------------------------------------*/
107
108template<typename Traits> void
111{
112 if (!m_vars.empty())
113 ARCANE_FATAL("Internal error: _init() already called");
114 m_vars.addRange(vars);
115 Integer nb_var = m_vars.size();
116 m_device_views.resizeNoInit(nb_var);
117 m_host_views.resize(nb_var);
118 m_views_as_bytes.resize(nb_var);
119 // Il faut maintenir une référence sur les variables qu'on possède pour
120 // être sur qu'elles sont bien initialisées et qu'elles ne seront pas détruites
121 // tant que cette instance existe.
122 m_p->m_refs.resize(nb_var);
123 for( Integer i=0; i<nb_var; ++i ){
124 // m_vars[i] peut être nul si notre variable est une variable uniquement milieu.
125 m_p->m_refs[i] = nullptr;
126 if (i==0){
127 // Pour la variable globale, il s'agit d'une variable maillage.
128 m_p->m_refs[i] = m_global_variable_ref;
129 }
130 else{
131 // Pour les autres, il s'agit d'une variable tableau.
132 if (m_vars[i])
133 m_p->m_refs[i] = new VariableRefType(m_vars[i]);
134 }
135 // TODO: il faut pouvoir être notifié du changement de cette variable.
136 // pour ensuite mettre à jour les vues (peut-être aussi faire un MyVariableRef).
137 _setView(i);
138 //std::cout << "INIT_VIEW: " << i << " v=" << m_views[i].size() << '\n';
139 }
140 _copyHostViewsToViews(nullptr);
141}
142
143/*---------------------------------------------------------------------------*/
144/*---------------------------------------------------------------------------*/
145
146template<typename Traits> void
147ItemMaterialVariableBase<Traits>::
148buildFromManager(bool is_continue)
149{
150 IMeshMaterialMng* mat_mng = m_p->materialMng();
151
152 // Il faut récupérer (ou créér) les autres variables.
153 //ConstArrayView<IMeshMaterial*> materials = mat_mng->materials();
154 IMeshMaterialMngInternal* mm_api = mat_mng->_internalApi();
155 const Real reserve_ratio = mm_api->additionalCapacityRatio();
156 ConstArrayView<MeshMaterialVariableIndexer*> indexers = mm_api->variablesIndexer();
157 Integer nb_indexer = indexers.size();
158 UniqueArray<PrivatePartType*> all_vars(nb_indexer+1);
159 all_vars[0] = m_global_variable;
160 IMesh* mesh = m_global_variable->mesh();
161
162 if (!m_global_variable->isUsed())
163 m_global_variable->setUsed(true);
164
165 // Il faut attacher un observer sur la variable globale pour savoir quand elle change.
166 // Pour les variables partielles, cela se fait automatiquement lorsque le matériau associé change.
167 m_p->m_global_variable_changed_observer = new ObserverT<ThatClass>(this,&ThatClass::_syncFromGlobalVariable);
168 m_global_variable->onSizeChangedObservable()->attachObserver(m_p->m_global_variable_changed_observer);
169
170 m_p->m_modified_times.resize(nb_indexer);
171 m_p->m_modified_times.fill(0);
172
173 bool is_env_only = m_p->space()==MatVarSpace::Environment;
174 //TODO: regarder s'il faut stocker les propriétés de cette variable
175 // avant sa création
176 int property = m_global_variable->property();
177 for( Integer i=0; i<nb_indexer; ++i ){
178 MeshMaterialVariableIndexer* indexer = indexers[i];
179 // Ne fait rien si on est uniquement une variable milieu et que l'indexeur
180 // n'est pas associé à un milieu.
181 if (is_env_only && !indexer->isEnvironment()){
182 all_vars[i+1] = nullptr;
183 continue;
184 }
185
186 // Si un nom est spécifié, il s'agit du mode de compatibilité
187 // avec Troll et dans ce cas la variable n'est pas associée
188 // au maillage.
189 String var_name = String("Mat")+indexer->name()+"_"+this->name();
190
191 // Note: Ces variables ne sont pas associées au maillage.
192 // Il s'agit juste de variables tableau.
193 IVariable* var = nullptr;
194 {
195 VariableBuildInfo vbi2(mesh,var_name,property);
196 VariableInfo vi = VariableRefType::_internalVariableInfo(vbi2);
197 var = PrivatePartType::getReference(vbi2,vi);
198 }
199 // Tag la variable pour les codes qui voudraient savoir qu'il
200 // s'agit d'une variable matériau.
201 var->addTag("Material","1");
202 PrivatePartType* true_ptr = dynamic_cast<PrivatePartType*>(var);
203 ARCANE_CHECK_POINTER(true_ptr);
204 all_vars[i+1] = true_ptr;
205 if (!is_continue){
206 // TODO: regarder si setUsed() est nécessaire.
207 true_ptr->setUsed(true);
208 // Dimensionne la variable à la taille du tableau des valeurs mixtes.
209 Traits::resizeWithReserve(true_ptr, indexer->maxIndexInMultipleArray(), reserve_ratio);
210 }
211 }
212 this->_init(all_vars);
213}
214
215/*---------------------------------------------------------------------------*/
216/*---------------------------------------------------------------------------*/
217
218template<typename Traits> void
219ItemMaterialVariableBase<Traits>::
220_syncFromGlobalVariable()
221{
222 // Cette méthode est appelée lorsque la variable globale voit sa taille
223 // modifiée. Dans ce cas seule la vue de la variable globale doit être modifiée.
224 // Mais cette méthode peut aussi être applelée lorsque la méthode setUsed()
225 // de la variable globale est appelée et dans ce cas il faut mettre à jour
226 // toutes les vues. Comme actuellement on ne peut pas distinguer les deux
227 // appels on fait la mise à jour complète dans tous les cas.
228 const bool do_complete_sync = true;
229 if (do_complete_sync){
230 syncReferences();
231 return;
232 }
233
234 // Cette méthode est appelée lorsque la taille de la variable globale
235 // change. Cette variable est la première variable de la liste.
236 // Il faut ensuite notifier toutes les références de ce changement.
237 _setView(0);
238 _copyHostViewsToViews(nullptr);
239
240 for( MeshMaterialVariableRef::Enumerator i(this); i.hasNext(); ++i ){
241 MeshMaterialVariableRef* ref = *i;
242 ref->updateFromInternal();
243 }
244}
245
246/*---------------------------------------------------------------------------*/
247/*---------------------------------------------------------------------------*/
248
249template<typename Traits> void
252{
253 _syncReferences(true);
254}
255
256/*---------------------------------------------------------------------------*/
257/*---------------------------------------------------------------------------*/
258
259template <typename Traits> void
262{
263 if (check_resize) {
264 IMeshMaterialMngInternal* api = m_p->materialMng()->_internalApi();
266 Real ratio = api->additionalCapacityRatio();
267 Integer nb_indexer = indexers.size();
268 for (Integer i = 0; i < nb_indexer; ++i) {
270 PrivatePartType* true_ptr = m_vars[i + 1];
271 if (true_ptr) {
272 Traits::resizeWithReserve(true_ptr, indexer->maxIndexInMultipleArray(), ratio);
273 _setView(i + 1);
274 }
275 }
276 _setView(0);
277 _copyHostViewsToViews(nullptr);
278 }
279
280 for( MeshMaterialVariableRef::Enumerator i(this); i.hasNext(); ++i ){
281 MeshMaterialVariableRef* ref = *i;
282 ref->updateFromInternal();
283 }
284}
285
286/*---------------------------------------------------------------------------*/
287/*---------------------------------------------------------------------------*/
288
289template<typename Traits> Ref<IData>
290ItemMaterialVariableBase<Traits>::
291_internalCreateSaveDataRef(Integer nb_value)
292{
293 Ref<IData> data = m_global_variable->data()->cloneEmptyRef();
294 auto* true_data = dynamic_cast<ValueDataType*>(data.get());
295 ARCANE_CHECK_POINTER(true_data);
296 true_data->_internal()->reserve(nb_value);
297 return data;
298}
299
300/*---------------------------------------------------------------------------*/
301/*---------------------------------------------------------------------------*/
302
303template<typename Traits> void
304ItemMaterialVariableBase<Traits>::
305_saveData(IMeshComponent* component,IData* data)
306{
307 if (m_p->space()==MatVarSpace::Environment && !component->isEnvironment())
308 ARCANE_FATAL("Can not save data on material for environment only variable");
309 Traits::saveData(component,data,m_host_views);
310}
311
312/*---------------------------------------------------------------------------*/
313/*---------------------------------------------------------------------------*/
314
315template<typename Traits> void
317_restoreData(IMeshComponent* component,IData* data,Integer data_index,
319{
320 if (m_p->space()==MatVarSpace::Environment && !component->isEnvironment())
321 ARCANE_FATAL("Can not restore data on material for environment only variable");
322
323 auto* true_data = dynamic_cast<ValueDataType*>(data);
325 auto values = true_data->view();
326
327 PrivatePartType* global_var = this->_trueGlobalVariable();
328
329 // Tableau pour initialiser les valeurs soit à zéro, soit avec
330 // la valeur de la variable globale.
331 UniqueContainerType tmp_values;
332 if (component->materialMng()->isDataInitialisationWithZero()){
333 Integer max_id = m_global_variable->itemFamily()->maxLocalId();
334 Traits::resizeAndFillWithDefault(true_data,tmp_values,max_id);
335 }
336 else
337 tmp_values = global_var->constValueView();
338
339 if (allow_null_id){
340 for( Integer i=0, n=ids.size(); i<n; ++i ){
341 if (ids[i]!=NULL_ITEM_ID){
342 Traits::setValue(tmp_values[ids[i]],values[data_index+i]);
343 }
344 }
345 }
346 else{
347 for( Integer i=0, n=ids.size(); i<n; ++i ){
348 Traits::setValue(tmp_values[ids[i]] , values[data_index+i] );
349 }
350 }
351
352 ENUMERATE_COMPONENTCELL(icell,component){
353 ComponentCell ec = *icell;
354 setValue(ec._varIndex(),tmp_values[ec.globalCell().localId()]);
355 }
356}
357
358/*---------------------------------------------------------------------------*/
359/*---------------------------------------------------------------------------*/
360
361template<typename Traits> bool
362ItemMaterialVariableBase<Traits>::
363_isValidAndUsedAndGlobalUsed(PrivatePartType* partial_var)
364{
365 if (!partial_var)
366 return false;
367 if (!m_global_variable->isUsed() || !partial_var->isUsed())
368 return false;
369 return true;
370}
371
372/*---------------------------------------------------------------------------*/
373/*---------------------------------------------------------------------------*/
374
375template <typename Traits> void
376ItemMaterialVariableBase<Traits>::
377_resizeForIndexer(ResizeVariableIndexerArgs& args)
378{
379 Int32 index = args.m_var_index;
380 RunQueue& queue = args.m_queue;
381 _setView(0);
382 PrivatePartType* partial_var = m_vars[index + 1];
383 if (_isValidAndUsedAndGlobalUsed(partial_var)) {
384 // Redimensionne le tableau des valeurs multiples si besoin.
385 // TODO: Faire sur le device pour la mise à jour de view
386 // TODO: Utiliser allocation asynchrone si possible (si pas d'initialisation)
387 // TODO: Pouvoir indiquer qu'on ne souhaite pas initialiser la variable
388 // quelle que soit la valeur de eDataInitialisationPolicy
389 IMeshMaterialMngInternal* api = m_p->materialMng()->_internalApi();
390 ConstArrayView<MeshMaterialVariableIndexer*> indexers = api->variablesIndexer();
391 Real ratio = api->additionalCapacityRatio();
392 Traits::resizeWithReserve(partial_var, indexers[index]->maxIndexInMultipleArray(), ratio);
393 this->_setView(index + 1);
394 }
395 if (args.isUseOneCommand()) {
396 auto dest = asWritableBytes(m_device_views.view());
397 auto source = asBytes(m_host_views.view());
398 args.addOneCopyData(source,dest,1);
399 }
400 else
401 _copyHostViewsToViews(&queue);
402}
403
404/*---------------------------------------------------------------------------*/
405/*---------------------------------------------------------------------------*/
406
407template <typename Traits> void
408ItemMaterialVariableBase<Traits>::
409_copyHostViewsToViews(RunQueue* queue)
410{
411 auto dest = asWritableBytes(m_device_views);
412 auto source = asBytes(m_host_views);
413 if (queue) {
414 Accelerator::MemoryCopyArgs copy_args(dest,source);
415 copy_args.addAsync(true);
416 queue->copyMemory(copy_args);
417 }
418 else
419 MemoryUtils::copy(dest,source);
420}
421
422/*---------------------------------------------------------------------------*/
423/*---------------------------------------------------------------------------*/
424
425template <typename Traits> void
426ItemMaterialVariableBase<Traits>::
427_copyBetweenPartialAndGlobal(const CopyBetweenPartialAndGlobalArgs& args)
428{
429 Int32 var_index = args.m_var_index + 1;
430 PrivatePartType* partial_var = m_vars[var_index];
431 if (!_isValidAndUsedAndGlobalUsed(partial_var))
432 return;
433 const bool is_global_to_partial = args.m_is_global_to_partial;
434 const bool use_generic = args.m_use_generic_copy;
435 const RunQueue& queue = args.m_queue;
436
437 auto input = m_host_views[var_index];
438 auto output = m_host_views[0];
439 auto output_indexes = args.m_local_ids;
440 auto input_indexes = args.m_indexes_in_multiple;
441
442 if (is_global_to_partial) {
443 std::swap(input, output);
444 std::swap(output_indexes, input_indexes);
445 }
446 if (use_generic) {
447 Int32 data_type_size = dataTypeSize();
448 SmallSpan<const std::byte> input_bytes(Traits::toBytes(input));
449 SmallSpan<std::byte> output_bytes(Traits::toBytes(output));
450 if (args.isUseOneCommand())
451 args.addOneCopyData(input_bytes, output_bytes, data_type_size);
452 else
453 _genericCopyTo(input_bytes, input_indexes,
454 output_bytes, output_indexes, queue, data_type_size);
455 }
456 else {
457 Traits::copyTo(input, input_indexes, output, output_indexes, queue);
458 }
459}
460
461/*---------------------------------------------------------------------------*/
462/*---------------------------------------------------------------------------*/
463
464template <typename Traits> void
465ItemMaterialVariableBase<Traits>::
466_initializeNewItemsWithZero(InitializeWithZeroArgs& args)
467{
468 const Int32 var_index = args.m_var_index + 1;
469 RunQueue& queue = args.m_queue;
470 PrivatePartType* partial_var = m_vars[var_index];
471 if (!_isValidAndUsedAndGlobalUsed(partial_var))
472 return;
473
474 SmallSpan<const Int32> partial_indexes = args.m_indexes_in_multiple;
475
476
477 ARCANE_CHECK_ACCESSIBLE_POINTER(queue, partial_indexes.data());
478
479 if (args.isUseOneCommand()){
480 Int32 data_type_size = dataTypeSize();
481 auto output = m_host_views[var_index];
482 SmallSpan<std::byte> output_bytes(Traits::toBytes(output));
483 args.addOneCopyData({}, output_bytes, data_type_size);
484 }
485 else{
486 ContainerSpanType partial_view = m_host_views[var_index];
487 Int32 nb_partial = partial_indexes.size();
488 DataType zero = DataType();
489 auto command = makeCommand(queue);
490 command << RUNCOMMAND_LOOP1(iter, nb_partial)
491 {
492 auto [i] = iter();
493 Int32 index = partial_indexes[i];
494 Traits::setValue(partial_view[index], zero);
495 };
496 }
497}
498
499/*---------------------------------------------------------------------------*/
500/*---------------------------------------------------------------------------*/
501
502template<typename Traits> void
505{
506 fillPartialValuesWithSuperValues(LEVEL_ALLENVIRONMENT);
507}
508
509/*---------------------------------------------------------------------------*/
510/*---------------------------------------------------------------------------*/
511
512template<typename Traits> void
515{
516 IMeshMaterialMng* mm = m_p->materialMng();
517 if (level==LEVEL_MATERIAL)
518 _fillPartialValuesWithSuperValues(mm->materialsAsComponents());
519 else if (level==LEVEL_ENVIRONMENT){
520 _fillPartialValuesWithSuperValues(mm->environmentsAsComponents());
521 }
522 else if (level==LEVEL_ALLENVIRONMENT){
523 _fillPartialValuesWithSuperValues(mm->environmentsAsComponents());
524 _fillPartialValuesWithSuperValues(mm->materialsAsComponents());
525 }
526 else
527 throw ArgumentException(A_FUNCINFO,String::format("Invalid level={0}",level));
528}
529
530/*---------------------------------------------------------------------------*/
531/*---------------------------------------------------------------------------*/
532
533template<typename Traits> void
536{
537 MatVarSpace s = this->space();
538 ENUMERATE_COMPONENT(ic,components){
539 IMeshComponent* c = *ic;
540 if (!c->hasSpace(s))
541 continue;
543 ComponentCell c = (*iccell).superCell();
544 setValue(iccell._varIndex(),value(c._varIndex()));
545 }
546 }
547}
548
549/*---------------------------------------------------------------------------*/
550/*---------------------------------------------------------------------------*/
551
552/*---------------------------------------------------------------------------*/
553/*---------------------------------------------------------------------------*/
554/*!
555 * \brief Récupère ou construit une variable.
556 *
557 * Récupère ou construit une variable de type \a VariableTrueType dont
558 * les caractéristiques sont données dans \a v.
559 */
560template<typename VariableTrueType> IMeshMaterialVariable*
563{
564 typedef typename VariableTrueType::PrivatePartType PrivatePartType;
565 typedef typename VariableTrueType::VariableRefType VariableRefType;
566
567 MeshHandle mesh_handle = v.meshHandle();
568 if (mesh_handle.isNull())
569 ARCANE_FATAL("No mesh handle for material variable");
570
571 IMeshMaterialMng* mat_mng = v.materialMng();
572
573 //TODO: regarder si verrou necessaire
574 if (!mat_mng)
575 mat_mng = IMeshMaterialMng::getReference(mesh_handle,true);
576
577 if (!mat_mng)
578 ARCANE_FATAL("No IMaterialMng for mesh");
579
580 if (!v.itemFamilyName().null())
581 ARCANE_FATAL("Can not declare material variable for specific family");
582
583 if (!v.itemGroupName().null())
584 ARCANE_FATAL("Can not declare partial material variable");
585
586 // Regarde si l'option qui force la création des variables matériaux
587 // même si on est une variable milieu est active.
588
589 if (VariableTrueType::TraitsType::dimension()==0)
590 if (mat_mng->isAllocateScalarEnvironmentVariableAsMaterial())
591 mvs = MatVarSpace::MaterialAndEnvironment;
592
594
595 {
596 Mutex::ScopedLock sl(mat_mng->variableLock());
597
598 //! Récupère (ou créé) la variable globale associée.
599 VariableInfo gvar_vi = VariableRefType::_internalVariableInfo(gvar_bi);
600 IVariable* g_var = PrivatePartType::getReference(gvar_bi,gvar_vi);
601
602 PrivatePartType* true_ptr = dynamic_cast<PrivatePartType*>(g_var);
603
604 // TODO: regarder s'il faut mettre aussi le nom du m_material_mng.
605 // Si on le fait, cela pose un problème avec la variable globale
606 // associée. Si on ne le fait pas, on ne peut à priori n'avoir
607 // qu'un seul IMeshMaterialMng.
608 IMeshMaterialVariable* mat_var = mat_mng->checkVariable(g_var);
610 // \a mat_var est non nul si la variable associée existe déjà.
611 if (mat_var)
612 true_mat_var = dynamic_cast<VariableTrueType*>(mat_var);
613 else{
614 VariableRefType* var_ref = new VariableRefType(gvar_bi);
617 mat_mng->_internalApi()->addVariable(true_mat_var);
618 // Le gestionnaire est déjà créé, on peut allouer toutes les infos
619 if (!mat_mng->_internalApi()->variablesIndexer().empty())
620 true_mat_var->buildFromManager(false);
621 }
623 if (mvs!=true_mat_var->space())
624 ARCANE_FATAL("Incoherent space for variable '{0}' wanted_space={1} existing_space={2}.\n"
625 " Check all instances of the variables are of the same space\n"
626 " (i.e. all variables are MaterialVariable or EnvironmentVariable)",
627 true_mat_var->name(),(int)mvs,(int)true_mat_var->space());
628 // Incrémente le compteur de référence.
629 // Il faut le faire ici et pas dans addVariableRef() car en multithreading
630 // il est possible de créer plusieurs références sur la même variable en même
631 // temps et de détruire une des références avant que le addVariableRef() de l'autre
632 // référence ne soit appelé ce qui provoque la destruction de true_mat_var.
633 ++true_mat_var->m_p->m_nb_reference;
634 return true_mat_var;
635 }
636}
637
638/*---------------------------------------------------------------------------*/
639/*---------------------------------------------------------------------------*/
640
641template<typename TrueType> MeshMaterialVariableFactoryRegisterer
643m_auto_registerer1(_autoCreate1,TrueType::BuilderType::_buildVarTypeInfo(MatVarSpace::Environment));
644
645template<typename TrueType> MeshMaterialVariableFactoryRegisterer
647m_auto_registerer2(_autoCreate2,TrueType::BuilderType::_buildVarTypeInfo(MatVarSpace::MaterialAndEnvironment));
648
649template<typename TrueType> IMeshMaterialVariable*
652{
653 return getReference(v,MatVarSpace::Environment);
654}
655
656template<typename TrueType> IMeshMaterialVariable*
659{
660 return getReference(v,MatVarSpace::MaterialAndEnvironment);
661}
662
663/*---------------------------------------------------------------------------*/
664/*---------------------------------------------------------------------------*/
665
666} // End namespace Arcane::Materials
667
668/*---------------------------------------------------------------------------*/
669/*---------------------------------------------------------------------------*/
#define ARCANE_CHECK_ACCESSIBLE_POINTER(queue_or_runner_or_policy, ptr)
Macro qui vérifie en mode check si ptr est accessible pour une RunQueue ou un Runner.
#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.
Fonctions de gestion mémoire et des allocateurs.
Types et macros pour gérer les boucles sur les accélérateurs.
#define RUNCOMMAND_LOOP1(iter_name, x1,...)
Boucle sur accélérateur avec arguments supplémentaires pour les réductions.
Interface d'une donnée.
Definition IData.h:33
Représente un composant d'une maille multi-matériau.
Interface d'un composant (matériau ou milieu) d'un maillage.
virtual bool isEnvironment() const =0
Vrai si le composant est un milieu.
virtual IMeshMaterialMng * materialMng()=0
Gestionnaire associé.
Interface du gestionnaire des matériaux et des milieux d'un maillage.
Interface d'une variable matériau d'un maillage.
Handle sur un maillage.
Definition MeshHandle.h:47
Paramètres nécessaires à la construction d'une variable.
Infos caractérisant une variable.
Exception lorsqu'un argument est invalide.
Vue constante d'un tableau de type T.
Référence à une instance.
bool isNull() const
Indique si le compteur référence une instance non nulle.
#define ENUMERATE_COMPONENT(icomponent, container)
Macro pour itérer sur une liste de composants.
#define ENUMERATE_COMPONENTCELL(iname, component)
Macro pour itérer sur toutes les mailles d'un composant.
RunCommand makeCommand(const RunQueue &run_queue)
Créé une commande associée à la file run_queue.
Active toujours les traces dans les parties Arcane concernant les matériaux.
MatVarSpace
Espace de définition d'une variable matériau.
MemoryAllocationOptions getAllocationOptions(eMemoryResource mem_resource)
Allocation par défaut pour la ressource mem_resource.
Arccore::eMemoryResource eMemoryRessource
Typedef pour la version Arcane historique (avec 2's')
ARCANE_DATATYPE_EXPORT Integer dataTypeSize(eDataType type)
Taille du type de donnée type (qui doit être différent de DT_String)
Definition DataTypes.cc:109
double Real
Type représentant un réel.
Int32 Integer
Type représentant un entier.
detail::SpanTypeFromSize< conststd::byte, SizeType >::SpanType asBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converti la vue en un tableau d'octets non modifiables.
Definition Span.h:881
detail::SpanTypeFromSize< std::byte, SizeType >::SpanType asWritableBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converti la vue en un tableau d'octets modifiables.
Definition Span.h:916
@ HostPinned
Alloue sur l'hôte.