Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
MeshMaterialVariable.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* MeshMaterialVariable.h (C) 2000-2024 */
9/* */
10/* Variable on a mesh material. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MATERIALS_MESHMATERIALVARIABLE_H
13#define ARCANE_MATERIALS_MESHMATERIALVARIABLE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/NotImplementedException.h"
18#include "arcane/utils/Array.h"
19#include "arcane/utils/MemoryView.h"
20
21#include "arcane/core/materials/IMeshMaterialVariable.h"
22#include "arcane/core/materials/MatVarIndex.h"
23
25
26#include "arcane/materials/MeshMaterialVariableFactoryRegisterer.h"
27
28#include "arcane/core/materials/IScalarMeshMaterialVariable.h"
29#include "arcane/core/materials/IArrayMeshMaterialVariable.h"
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34namespace Arcane
35{
36class VariableInfo;
37class VariableRef;
39template <typename ItemType, typename DataTypeT> class MeshVariableScalarRefT;
40} // namespace Arcane
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
45namespace Arcane::Materials
46{
47
48/*---------------------------------------------------------------------------*/
49/*---------------------------------------------------------------------------*/
50
52class MeshMaterialVariablePrivate;
54class CopyBetweenPartialAndGlobalArgs;
55class ResizeVariableIndexerArgs;
56class InitializeWithZeroArgs;
57
58/*---------------------------------------------------------------------------*/
59/*---------------------------------------------------------------------------*/
60
61/*!
62 * \internal
63 * \ingroup ArcaneMaterials
64 * \brief Base class for material variables.
65 *
66 * This class contains the implementation of material variables. It
67 * is internal to Arcane. Generally, IMeshMaterialVariable should be used.
68 */
69class ARCANE_MATERIALS_EXPORT MeshMaterialVariable
71{
72 friend MeshMaterialVariablePrivate;
73 // For access to 'copyToBuffer', 'copyFromBuffer'. To be removed later
74 friend MeshMaterialVariableSynchronizerList;
75
76 public:
77
78 MeshMaterialVariable(const MaterialVariableBuildInfo& v, MatVarSpace mvs);
79 ~MeshMaterialVariable() override;
80
81 public:
82
83 String name() const override;
84 void addVariableRef(MeshMaterialVariableRef* var_ref) override;
85 void removeVariableRef(MeshMaterialVariableRef* var_ref) override;
86 MeshMaterialVariableRef* firstReference() const override;
87 IVariable* materialVariable(IMeshMaterial* mat) override;
88
89 void setKeepOnChange(bool v) override;
90 bool keepOnChange() const override;
91
92 MatVarSpace space() const override;
93
94 public:
95
96 //! @name Dependency Management
97 //@{
98 void update(IMeshMaterial* mat) override;
99 void setUpToDate(IMeshMaterial* mat) override;
100 Int64 modifiedTime(IMeshMaterial* mat) override;
101 void addDepend(IMeshMaterialVariable* var) override;
102 void addDepend(IMeshMaterialVariable* var, const TraceInfo& tinfo) override;
103 void addDepend(IVariable* var) override;
104 void addDepend(IVariable* var, const TraceInfo& tinfo) override;
105 void removeDepend(IMeshMaterialVariable* var) override;
106 void removeDepend(IVariable* var) override;
110 Array<MeshMaterialVariableDependInfo>& mat_infos) override;
111 //@}
112
113 IMeshMaterialVariableInternal* _internalApi() override;
114
115 public:
116
117 //! @name Public functions reserved for Arcane to manage synchronizations
118 //@{
119 virtual Int32 dataTypeSize() const = 0;
120
121 protected:
122
123 // TODO: obsolete interface to remove
124 virtual void copyToBuffer(ConstArrayView<MatVarIndex> matvar_indexes, ByteArrayView bytes) const = 0;
125 // TODO: obsolete interface to remove
126 virtual void copyFromBuffer(ConstArrayView<MatVarIndex> matvar_indexes, ByteConstArrayView bytes) = 0;
127 //@}
128
129 public:
130
131 /*!
132 * \internal
133 * Increments the reference counter.
134 */
135 void incrementReference();
136
137 protected:
138
139 ITraceMng* _traceMng() const;
140
141 protected:
142
143 MeshMaterialVariablePrivate* m_p = nullptr;
144 UniqueArray<Span<std::byte>> m_views_as_bytes;
145
146 protected:
147
148 void _copyToBuffer(SmallSpan<const MatVarIndex> matvar_indexes, Span<std::byte> bytes, RunQueue* queue) const;
149 void _copyFromBuffer(SmallSpan<const MatVarIndex> matvar_indexes, Span<const std::byte> bytes, RunQueue* queue);
150
151 virtual Ref<IData> _internalCreateSaveDataRef(Integer nb_value) = 0;
152 virtual void _saveData(IMeshComponent* component, IData* data) = 0;
153 virtual void _restoreData(IMeshComponent* component, IData* data, Integer data_index,
154 Int32ConstArrayView ids, bool allow_null_id) = 0;
155 virtual void _copyBetweenPartialAndGlobal(const CopyBetweenPartialAndGlobalArgs& args) = 0;
156 virtual void _initializeNewItemsWithZero(InitializeWithZeroArgs& args) = 0;
157 virtual void _syncReferences(bool update_views) = 0;
158 virtual void _resizeForIndexer(ResizeVariableIndexerArgs& args) = 0;
159
160 private:
161
162 static SmallSpan<const Int32> _toInt32Indexes(SmallSpan<const MatVarIndex> indexes);
163
164 public:
165
166 static void _genericCopyTo(Span<const std::byte> input,
167 SmallSpan<const Int32> input_indexes,
168 Span<std::byte> output,
169 SmallSpan<const Int32> output_indexes,
170 const RunQueue& queue, Int32 data_type_size);
171};
172
173/*---------------------------------------------------------------------------*/
174/*---------------------------------------------------------------------------*/
175
176//! Characteristics for a scalar material variable.
177template <typename DataType>
179{
180 public:
181
182 using ValueType = DataType;
183
184 using SubViewType = DataType;
185 using SubConstViewType = DataType;
186 using SubInputViewType = DataType;
187 using ContainerSpanType = SmallSpan<DataType>;
188 using ContainerViewType = ArrayView<DataType>;
189 using ContainerConstViewType = ConstArrayView<DataType>;
190 using PrivatePartType = VariableArrayT<DataType>;
191 using ValueDataType = IArrayDataT<DataType>;
192 using ContainerType = Array<DataType>;
193 using UniqueContainerType = UniqueArray<DataType>;
194 using VariableRefType = VariableRefArrayT<DataType>;
195
196 public:
197
198 ARCANE_MATERIALS_EXPORT static void
199 saveData(IMeshComponent* component, IData* data, Array<ContainerViewType>& cviews);
200 ARCANE_MATERIALS_EXPORT static void
201 copyTo(SmallSpan<const DataType> input, SmallSpan<const Int32> input_indexes,
202 SmallSpan<DataType> output, SmallSpan<const Int32> output_indexes,
203 const RunQueue& queue);
204 ARCANE_MATERIALS_EXPORT static void
205 resizeAndFillWithDefault(ValueDataType* data, ContainerType& container, Integer dim1_size);
206
207 static ARCCORE_HOST_DEVICE void setValue(DataType& view, const DataType& v)
208 {
209 view = v;
210 }
211 ARCANE_MATERIALS_EXPORT static void
212 resizeWithReserve(PrivatePartType* var, Int32 new_size, Real reserve_ratio);
213 static Integer dimension() { return 0; }
214 static SmallSpan<std::byte> toBytes(ArrayView<DataType> view)
215 {
216 //SmallSpan<DataType> s(view);
217 return asWritableBytes(view);
218 }
219};
220
221/*---------------------------------------------------------------------------*/
222/*---------------------------------------------------------------------------*/
223
224//! Characteristics for an array material variable.
225template <typename DataType>
227{
228 public:
229
230 using ValueType = DataType;
231
232 using SubViewType = ArrayView<DataType>;
233 using SubConstViewType = ConstArrayView<DataType>;
234 using SubInputViewType = SmallSpan<const DataType>;
235 using ContainerViewType = Array2View<DataType>;
236 using ContainerSpanType = SmallSpan2<DataType>;
237 using ContainerConstViewType = ConstArray2View<DataType>;
238 using PrivatePartType = Array2VariableT<DataType>;
239 using ValueDataType = IArray2DataT<DataType>;
240 using ContainerType = Array2<DataType>;
241 using UniqueContainerType = UniqueArray2<DataType>;
242 using VariableRefType = VariableRefArray2T<DataType>;
243
244 public:
245
247 static void saveData(IMeshComponent* component, IData* data,
250 static void copyTo(SmallSpan2<const DataType> input, SmallSpan<const Int32> input_indexes,
251 SmallSpan2<DataType> output, SmallSpan<const Int32> output_indexes,
252 const RunQueue& queue);
254 static void resizeAndFillWithDefault(ValueDataType* data, ContainerType& container,
255 Integer dim1_size);
256 static ARCCORE_HOST_DEVICE void setValue(SmallSpan<DataType> view, const DataType& v)
257 {
258 view.fill(v);
259 }
260 static ARCCORE_HOST_DEVICE void setValue(SmallSpan<DataType> view, SmallSpan<const DataType> v)
261 {
262 view.copy(v);
263 }
265 static void resizeWithReserve(PrivatePartType* var, Integer new_size, Real resize_ratio);
266 static SmallSpan<std::byte> toBytes(Array2View<DataType> view)
267 {
268 SmallSpan<DataType> s(view.data(), view.totalNbElement());
269 return asWritableBytes(s);
270 }
271
272 static Integer dimension() { return 0; }
273};
274
275/*---------------------------------------------------------------------------*/
276/*---------------------------------------------------------------------------*/
277
278/*!
279 * \internal
280 * \brief Base class for material variables with the characteristics specified by \a Traits.
281 */
282template <typename Traits>
283class ItemMaterialVariableBase
284: public MeshMaterialVariable
285{
286 public:
287
288 using TraitsType = Traits;
289 using ValueType = typename Traits::ValueType;
290 using DataType = typename Traits::ValueType;
291 using ThatClass = ItemMaterialVariableBase<Traits>;
292
293 using SubViewType = typename Traits::SubViewType;
294 using SubConstViewType = typename Traits::SubConstViewType;
295 using SubInputViewType = typename Traits::SubInputViewType;
296 using ContainerSpanType = typename Traits::ContainerSpanType;
297 using ContainerViewType = typename Traits::ContainerViewType;
298 using ContainerConstViewType = typename Traits::ContainerConstViewType;
299 using PrivatePartType = typename Traits::PrivatePartType;
300 using ValueDataType = typename Traits::ValueDataType;
301 using ContainerType = typename Traits::ContainerType;
302 using UniqueContainerType = typename Traits::UniqueContainerType;
303 using VariableRefType = typename Traits::VariableRefType;
304
305 public:
306
308 ItemMaterialVariableBase(const MaterialVariableBuildInfo& v,
309 PrivatePartType* global_var,
310 VariableRef* global_var_ref, MatVarSpace mvs);
311 ARCANE_MATERIALS_EXPORT ~ItemMaterialVariableBase() override;
312
313 public:
314
317 ARCANE_MATERIALS_EXPORT void buildFromManager(bool is_continue) override;
318
319 ARCANE_MATERIALS_EXPORT Ref<IData> _internalCreateSaveDataRef(Integer nb_value) override;
320 ARCANE_MATERIALS_EXPORT void _saveData(IMeshComponent* env, IData* data) override;
322 void _restoreData(IMeshComponent* component, IData* data, Integer data_index,
323 Int32ConstArrayView ids, bool allow_null_id) override;
325 void _copyBetweenPartialAndGlobal(const CopyBetweenPartialAndGlobalArgs& args) override;
327 void _initializeNewItemsWithZero(InitializeWithZeroArgs& args) override;
328
332
333 public:
334
335 void setValue(MatVarIndex mvi, SubInputViewType v)
336 {
337 Traits::setValue(m_host_views[mvi.arrayIndex()][mvi.valueIndex()], v);
338 }
339
340 void setFillValue(MatVarIndex mvi, const DataType& v)
341 {
342 Traits::setValue(m_host_views[mvi.arrayIndex()][mvi.valueIndex()], v);
343 }
344
345 SubConstViewType value(MatVarIndex mvi) const
346 {
347 return m_host_views[mvi.arrayIndex()][mvi.valueIndex()];
348 }
349
350 protected:
351
352 void _syncFromGlobalVariable();
353 PrivatePartType* _trueGlobalVariable()
354 {
355 return m_global_variable;
356 }
357
358 void _init(ArrayView<PrivatePartType*> vars);
360 _fillPartialValuesWithSuperValues(MeshComponentList components);
361 ARCANE_MATERIALS_EXPORT void _syncReferences(bool check_resize) override;
362 ARCANE_MATERIALS_EXPORT void _resizeForIndexer(ResizeVariableIndexerArgs& args) override;
363 ARCANE_MATERIALS_EXPORT void _copyHostViewsToViews(RunQueue* queue);
364
365 public:
366 protected:
367
368 PrivatePartType* m_global_variable = nullptr;
369 VariableRef* m_global_variable_ref = nullptr;
370 //! Variables for different materials.
372 //! List of views visible only from the accelerator
374 //! List of views visible only from the host
376
377 protected:
378
379 /*!
380 * \brief Positions the views from the container
381 *
382 * The accelerator view is not updated here but when calling
383 * _copyHostViewsToViews().
384 */
385 void _setView(Int32 index)
386 {
387 ContainerViewType view;
388 if (m_vars[index])
389 view = m_vars[index]->valueView();
390 m_host_views[index] = view;
391 m_views_as_bytes[index] = TraitsType::toBytes(view);
392 }
393
394 private:
395
396 bool _isValidAndUsedAndGlobalUsed(PrivatePartType* partial_var);
397};
398
399/*---------------------------------------------------------------------------*/
400/*---------------------------------------------------------------------------*/
401
402template <typename TrueType>
417
418/*---------------------------------------------------------------------------*/
419/*---------------------------------------------------------------------------*/
420
421/*!
422 * \internal
423 * \ingroup ArcaneMaterials
424 * \brief Scalar variable on a mesh material.
425 */
426template <typename DataType>
427class ItemMaterialVariableScalar
428: public ItemMaterialVariableBase<MaterialVariableScalarTraits<DataType>>
429{
430 public:
431
432 using BaseClass = ItemMaterialVariableBase<MaterialVariableScalarTraits<DataType>>;
434 using ThatClass = ItemMaterialVariableScalar<DataType>;
435
436 using ContainerViewType = typename Traits::ContainerViewType;
437 using PrivatePartType = typename Traits::PrivatePartType;
438 using ValueDataType = typename Traits::ValueDataType;
439 using ContainerType = typename Traits::ContainerType;
440 using VariableRefType = typename Traits::VariableRefType;
441
442 protected:
443
445 ItemMaterialVariableScalar(const MaterialVariableBuildInfo& v,
446 PrivatePartType* global_var,
447 VariableRef* global_var_ref, MatVarSpace mvs);
448
449 public:
450
451 ArrayView<DataType>* views() { return this->m_host_views.data(); }
452
453 protected:
454
455 ArrayView<ArrayView<DataType>> _containerView() { return this->m_host_views; }
456
457 public:
458
459 DataType operator[](MatVarIndex mvi) const
460 {
461 return this->m_host_views[mvi.arrayIndex()][mvi.valueIndex()];
462 }
463
464 using BaseClass::setValue;
465 using BaseClass::value;
466
467 ARCANE_MATERIALS_EXPORT void synchronize() override;
469 ARCANE_MATERIALS_EXPORT void dumpValues(std::ostream& ostr) override;
470 ARCANE_MATERIALS_EXPORT void dumpValues(std::ostream& ostr, AllEnvCellVectorView view) override;
472
473 public:
474
479 Int32ConstArrayView indexes);
482 Int32ConstArrayView indexes);
483 ARCANE_MATERIALS_EXPORT void fillPartialValues(const DataType& value);
484
485 private:
486
487 ARCANE_MATERIALS_EXPORT Int32 dataTypeSize() const override;
489 void copyToBuffer(ConstArrayView<MatVarIndex> matvar_indexes,
490 ByteArrayView bytes) const override;
492 void copyFromBuffer(ConstArrayView<MatVarIndex> matvar_indexes,
493 ByteConstArrayView bytes) override;
494
495 protected:
496
497 using BaseClass::m_p;
498
499 private:
500
501 using BaseClass::m_global_variable;
502 using BaseClass::m_global_variable_ref;
504 using BaseClass::m_vars;
505
506 private:
507
508 void _synchronizeV1();
509 void _synchronizeV2();
510 void _synchronizeV5();
511 Int64 _synchronize2();
512
513 private:
514
515 void _copyToBufferLegacy(SmallSpan<const MatVarIndex> matvar_indexes,
516 Span<std::byte> bytes) const;
517 void _copyFromBufferLegacy(SmallSpan<const MatVarIndex> matvar_indexes,
519};
520
521/*---------------------------------------------------------------------------*/
522/*---------------------------------------------------------------------------*/
523
524/*!
525 * \internal
526 * \ingroup ArcaneMaterials
527 * \brief Scalar variable on a mesh material.
528 */
529template <typename ItemType, typename DataType>
530class MeshMaterialVariableScalar
531: public ItemMaterialVariableScalar<DataType>
532, public IScalarMeshMaterialVariable<ItemType, DataType>
533{
534 public:
535
536 using ThatClass = MeshMaterialVariableScalar<ItemType, DataType>;
538 using BuilderType = typename ThatInterface::BuilderType;
540 using ItemTypeTemplate = ItemType;
541
542 using BaseClass = ItemMaterialVariableScalar<DataType>;
543 using VariableRefType = MeshVariableScalarRefT<ItemType, DataType>;
544 using PrivatePartType = typename BaseClass::PrivatePartType;
545
546 friend StaticImpl;
547
548 protected:
549
551 MeshMaterialVariableScalar(const MaterialVariableBuildInfo& v,
552 PrivatePartType* global_var,
553 VariableRefType* global_var_ref, MatVarSpace mvs);
555 ~MeshMaterialVariableScalar();
556
557 public:
558
559 VariableRefType* globalVariableReference() const final { return m_true_global_variable_ref; }
560 void incrementReference() final { BaseClass::incrementReference(); }
561 ArrayView<ArrayView<DataType>> _internalFullValuesView() final { return BaseClass::_containerView(); }
562 void fillFromArray(IMeshMaterial* mat, ConstArrayView<DataType> values) final
563 {
564 return BaseClass::fillFromArray(mat, values);
565 }
566 void fillFromArray(IMeshMaterial* mat, ConstArrayView<DataType> values, Int32ConstArrayView indexes) final
567 {
568 BaseClass::fillFromArray(mat, values, indexes);
569 }
570 void fillToArray(IMeshMaterial* mat, ArrayView<DataType> values) final
571 {
572 BaseClass::fillToArray(mat, values);
573 }
574 void fillToArray(IMeshMaterial* mat, ArrayView<DataType> values, Int32ConstArrayView indexes) final
575 {
576 BaseClass::fillToArray(mat, values, indexes);
577 }
578 void fillPartialValues(const DataType& value) final { BaseClass::fillPartialValues(value); }
579 IMeshMaterialVariable* toMeshMaterialVariable() final { return this; }
580
581 private:
582
583 VariableRefType* m_true_global_variable_ref = nullptr;
584};
585
586/*---------------------------------------------------------------------------*/
587/*---------------------------------------------------------------------------*/
588
589/*!
590 * \internal
591 * \ingroup ArcaneMaterials
592 * \brief Array variable on a mesh material.
593 */
594template <typename DataType>
595class ItemMaterialVariableArray
596: public ItemMaterialVariableBase<MaterialVariableArrayTraits<DataType>>
597{
598 public:
599
600 using BaseClass = ItemMaterialVariableBase<MaterialVariableArrayTraits<DataType>>;
602
603 using ThatClass = ItemMaterialVariableArray<DataType>;
604
605 using ContainerViewType = typename Traits::ContainerViewType;
606 using PrivatePartType = typename Traits::PrivatePartType;
607 using ValueDataType = typename Traits::ValueDataType;
608 using ContainerType = typename Traits::ContainerType;
609 using VariableRefType = typename Traits::VariableRefType;
610
611 protected:
612
614 ItemMaterialVariableArray(const MaterialVariableBuildInfo& v,
615 PrivatePartType* global_var,
616 VariableRef* global_var_ref, MatVarSpace mvs);
617
618 public:
619
620 ARCANE_DEPRECATED_REASON("Y2022: Do not use internal storage accessor")
621 Array2View<DataType>* views() { return m_host_views.data(); }
622
623 public:
624
625 ARCANE_MATERIALS_EXPORT void synchronize() override;
627 ARCANE_MATERIALS_EXPORT void dumpValues(std::ostream& ostr) override;
628 ARCANE_MATERIALS_EXPORT void dumpValues(std::ostream& ostr, AllEnvCellVectorView view) override;
630
631 private:
632
633 ARCANE_MATERIALS_EXPORT Int32 dataTypeSize() const override;
634
636 void copyToBuffer(ConstArrayView<MatVarIndex> matvar_indexes,
637 ByteArrayView bytes) const override;
638
640 void copyFromBuffer(ConstArrayView<MatVarIndex> matvar_indexes,
641 ByteConstArrayView bytes) override;
642
643 public:
644
645 ARCANE_MATERIALS_EXPORT void resize(Integer dim2_size);
646
647 public:
648
649 ConstArrayView<DataType> operator[](MatVarIndex mvi) const
650 {
651 return m_host_views[mvi.arrayIndex()][mvi.valueIndex()];
652 }
653
654 using BaseClass::setValue;
655 using BaseClass::value;
656
657 protected:
658
659 using BaseClass::m_p;
660 ArrayView<Array2View<DataType>> _containerView() { return m_host_views; }
661
662 private:
663
664 using BaseClass::m_global_variable;
665 using BaseClass::m_global_variable_ref;
667 using BaseClass::m_vars;
668
669 void _copyToBufferLegacy(SmallSpan<const MatVarIndex> matvar_indexes,
670 Span<std::byte> bytes) const;
671 void _copyFromBufferLegacy(SmallSpan<const MatVarIndex> matvar_indexes,
673};
674
675/*---------------------------------------------------------------------------*/
676/*---------------------------------------------------------------------------*/
677
678/*!
679 * \internal
680 * \ingroup ArcaneMaterials
681 * \brief Array variable on a mesh material.
682 */
683template <typename ItemType, typename DataType>
684class MeshMaterialVariableArray
685: public ItemMaterialVariableArray<DataType>
686, public IArrayMeshMaterialVariable<ItemType, DataType>
687{
688 public:
689
690 using ThatClass = MeshMaterialVariableArray<ItemType, DataType>;
692 using BuilderType = typename ThatInterface::BuilderType;
694 using ItemTypeTemplate = ItemType;
695
696 using BaseClass = ItemMaterialVariableArray<DataType>;
697 using VariableRefType = MeshVariableArrayRefT<ItemType, DataType>;
698 using PrivatePartType = typename BaseClass::PrivatePartType;
699
700 friend StaticImpl;
701
702 protected:
703
705 MeshMaterialVariableArray(const MaterialVariableBuildInfo& v,
706 PrivatePartType* global_var,
707 VariableRefType* global_var_ref, MatVarSpace mvs);
708
709 public:
710
711 void incrementReference() final { BaseClass::incrementReference(); }
712 ArrayView<Array2View<DataType>> _internalFullValuesView() final { return BaseClass::_containerView(); }
713 void resize(Int32 dim2_size) final { BaseClass::resize(dim2_size); }
714 VariableRefType* globalVariableReference() const final { return m_true_global_variable_ref; }
715 IMeshMaterialVariable* toMeshMaterialVariable() final { return this; }
716
717 private:
718
719 VariableRefType* m_true_global_variable_ref = nullptr;
720};
721
722/*---------------------------------------------------------------------------*/
723/*---------------------------------------------------------------------------*/
724
725} // End namespace Arcane::Materials
726
727/*---------------------------------------------------------------------------*/
728/*---------------------------------------------------------------------------*/
729
730#endif
constexpr DataType * data()
Pointer to the allocated memory.
constexpr Integer totalNbElement() const
Total number of elements.
Class representing a classic 2D array.
Modifiable view of an array of type T.
constexpr const_pointer data() const noexcept
Pointer to the start of the view.
Base class for 1D data vectors.
Constant view of an array of type T.
Interface of a data item.
Definition IData.h:34
Interface of a variable.
Definition IVariable.h:40
Interface of a component (material or environment) of a mesh.
Interface of a material variable on a mesh.
ARCANE_MATERIALS_EXPORT void synchronize() override
Synchronizes the variable.
ARCANE_MATERIALS_EXPORT void serialize(ISerializer *sbuffer, Int32ConstArrayView ids) override
Serializes the variable for local ID entities ids.
ARCANE_MATERIALS_EXPORT void dumpValues(std::ostream &ostr) override
Dumps the variable values to the stream ostr.
ARCANE_MATERIALS_EXPORT void syncReferences() override
Synchronizes references.
ARCANE_MATERIALS_EXPORT IVariable * globalVariable() const override
Associated global variable on the mesh.
ARCANE_MATERIALS_EXPORT void fillPartialValuesWithGlobalValues() override
Fills partial values with the value of the associated global cell.
void _setView(Int32 index)
Positions the views from the container.
ARCANE_MATERIALS_EXPORT void fillPartialValuesWithSuperValues(Int32 level) override
Fills partial values with the value of the super cell. If level equals LEVEL_MATERIAL,...
ARCANE_MATERIALS_EXPORT void fillPartialValues(const DataType &value)
Fills the partial values with the value value.
ARCANE_MATERIALS_EXPORT void synchronize() override
Synchronizes the variable.
ARCANE_MATERIALS_EXPORT void fillToArray(IMeshMaterial *mat, ArrayView< DataType > values)
Fills an array from the variable values for a material.
ARCANE_MATERIALS_EXPORT void serialize(ISerializer *sbuffer, Int32ConstArrayView ids) override
Serializes the variable for local ID entities ids.
ARCANE_MATERIALS_EXPORT void dumpValues(std::ostream &ostr) override
Dumps the variable values to the stream ostr.
ARCANE_MATERIALS_EXPORT void fillFromArray(IMeshMaterial *mat, ConstArrayView< DataType > values)
Fills the variable values for a material from an array.
Represents an index on material and environment variables.
constexpr __host__ __device__ Int32 arrayIndex() const
Returns the index of the value array in the list of variables.
constexpr __host__ __device__ Int32 valueIndex() const
Returns the index in the value array.
Characteristics for an array material variable.
Characteristics for a scalar material variable.
static ARCANE_MATERIALS_EXPORT IMeshMaterialVariable * getReference(const MaterialVariableBuildInfo &v, MatVarSpace mvs)
Retrieves or constructs a variable.
void setUpToDate(IMeshMaterial *mat) override
Indicates that the variable has just been updated.
Int64 modifiedTime(IMeshMaterial *mat) override
Time when the variable was updated.
void removeVariableRef(MeshMaterialVariableRef *var_ref) override
Removes a reference to this variable.
void update(IMeshMaterial *mat) override
Recalculates the variable for material mat if necessary.
void dependInfos(Array< VariableDependInfo > &infos, Array< MeshMaterialVariableDependInfo > &mat_infos) override
Dependency information.
void addVariableRef(MeshMaterialVariableRef *var_ref) override
Adds a reference to this variable.
IMeshMaterialVariableComputeFunction * computeFunction() override
Function used to update the variable.
void setKeepOnChange(bool v) override
Indicates whether the variable value should be kept after a change in the list of materials.
void addDepend(IMeshMaterialVariable *var) override
Adds var to the dependency list.
void removeDepend(IMeshMaterialVariable *var) override
Removes var from the dependency list.
void setComputeFunction(IMeshMaterialVariableComputeFunction *v) override
Sets the variable's recalculation function.
String name() const override
Name of the variable.
MatVarSpace space() const override
Variable definition space (material+environment or environment only).
bool keepOnChange() const override
Indicates whether the variable value should be kept after a change in the list of materials.
Array variable on a mesh entity type.
Scalar variable on a mesh entity type.
Reference to an instance.
View for a 2D array whose size is an 'Int32'.
Definition Span2.h:249
View of an array of elements of type T.
Definition Span.h:805
__host__ __device__ void copy(const U &copy_array)
Copies the array copy_array into the instance.
Definition Span.h:477
__host__ __device__ void fill(T o)
Fills the array with the value o.
Definition Span.h:383
View of an array of elements of type T.
Definition Span.h:635
2D data vector with value semantics (STL style).
1D data vector with value semantics (STL style).
Parameters necessary for building a variable.
Information characterizing a variable.
Two-dimensional array variable.
Reference to a variable.
Definition VariableRef.h:56
Always enables tracing in Arcane parts concerning materials.
ConstArrayView< IMeshComponent * > MeshComponentList
List of multi-material components of the mesh.
MatVarSpace
Definition space for a material variable.
class ARCANE_MATERIALS_EXPORT(64) SimdMatVarIndex
SIMD indexer on a component.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ARCANE_DATATYPE_EXPORT Integer dataTypeSize(eDataType type)
Size of data type type (which must be different from DT_String).
Definition DataTypes.cc:111
ArrayView< Byte > ByteArrayView
C equivalent of a 1D array of characters.
Definition UtilsTypes.h:447
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
double Real
Type representing a real number.
ConstArrayView< Byte > ByteConstArrayView
C equivalent of a 1D array of characters.
Definition UtilsTypes.h:476
Impl::SpanTypeFromSize< std::byte, SizeType >::SpanType asWritableBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converts the view into an array of modifiable bytes.
Definition Span.h:1068
std::int32_t Int32
Signed integer type of 32 bits.