Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
IMeshMaterialVariableInternal.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/* IMeshMaterialVariableInternal.h (C) 2000-2024 */
9/* */
10/* Arcane internal API for 'IMeshMaterialVariable'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MATERIALS_INTERNAL_IMESHMATERIALVARIABLEINTERNAL_H
13#define ARCANE_CORE_MATERIALS_INTERNAL_IMESHMATERIALVARIABLEINTERNAL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18#include "arcane/core/materials/MaterialsCoreGlobal.h"
19#include "arcane/accelerator/core/RunQueue.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::Materials
25{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
34struct ARCANE_CORE_EXPORT CopyBetweenDataInfo
35{
36 public:
37
38 CopyBetweenDataInfo(SmallSpan<const std::byte> input, SmallSpan<std::byte> output, Int32 data_size)
39 : m_input(input)
40 , m_output(output)
41 , m_data_size(data_size)
42 {}
43
44 public:
45
47 SmallSpan<std::byte> m_output;
48 Int32 m_data_size = 0;
49};
50
54class ARCANE_CORE_EXPORT VariableIndexerCommonArgs
55{
56 public:
57
58 VariableIndexerCommonArgs(Int32 var_index, const RunQueue& queue)
59 : m_var_index(var_index)
60 , m_queue(queue)
61 {}
62
63 public:
64
65 void addOneCopyData(SmallSpan<const std::byte> input,
67 Int32 data_size) const
68 {
69 if (m_copy_data) {
70 CopyBetweenDataInfo x(input, output, data_size);
71 m_copy_data->add(x);
72 }
73 }
74
75 bool isUseOneCommand() const { return m_copy_data; }
76
77 public:
78
79 Int32 m_var_index = -1;
80 RunQueue m_queue;
83};
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
91class ARCANE_CORE_EXPORT CopyBetweenPartialAndGlobalArgs
92: public VariableIndexerCommonArgs
93{
94 public:
95
96 CopyBetweenPartialAndGlobalArgs(Int32 var_index,
97 SmallSpan<const Int32> local_ids,
98 SmallSpan<const Int32> indexes_in_multiple,
99 bool do_copy,
100 bool is_global_to_partial,
101 const RunQueue& queue)
102 : VariableIndexerCommonArgs(var_index, queue)
103 , m_local_ids(local_ids)
104 , m_indexes_in_multiple(indexes_in_multiple)
105 , m_do_copy_between_partial_and_pure(do_copy)
106 , m_is_global_to_partial(is_global_to_partial)
107 {}
108
109 public:
110
111 SmallSpan<const Int32> m_local_ids;
112 SmallSpan<const Int32> m_indexes_in_multiple;
113 bool m_do_copy_between_partial_and_pure = true;
114 bool m_is_global_to_partial = false;
115 bool m_use_generic_copy = false;
116};
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
124class ARCANE_CORE_EXPORT InitializeWithZeroArgs
125: public VariableIndexerCommonArgs
126{
127 public:
128
129 InitializeWithZeroArgs(Int32 var_index, SmallSpan<const Int32> indexes_in_multiple,
130 const RunQueue& queue)
131 : VariableIndexerCommonArgs(var_index, queue)
132 , m_indexes_in_multiple(indexes_in_multiple)
133 {}
134
135 public:
136
137 SmallSpan<const Int32> m_indexes_in_multiple;
138};
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
146class ARCANE_CORE_EXPORT ResizeVariableIndexerArgs
147: public VariableIndexerCommonArgs
148{
149 public:
150
151 ResizeVariableIndexerArgs(Int32 var_index, const RunQueue& queue)
152 : VariableIndexerCommonArgs(var_index, queue)
153 {}
154
155 public:
156};
157
158/*---------------------------------------------------------------------------*/
159/*---------------------------------------------------------------------------*/
160
164class ARCANE_CORE_EXPORT IMeshMaterialVariableInternal
165{
166 public:
167
168 virtual ~IMeshMaterialVariableInternal() = default;
169
170 public:
171
179 virtual Int32 dataTypeSize() const = 0;
180
186 virtual void copyToBuffer(SmallSpan<const MatVarIndex> matvar_indexes,
187 Span<std::byte> bytes, RunQueue* queue) const = 0;
188
194 virtual void copyFromBuffer(SmallSpan<const MatVarIndex> matvar_indexes,
195 Span<const std::byte> bytes, RunQueue* queue) = 0;
196
199
201 virtual void saveData(IMeshComponent* component, IData* data) = 0;
202
204 virtual void restoreData(IMeshComponent* component, IData* data,
205 Integer data_index, Int32ConstArrayView ids, bool allow_null_id) = 0;
206
209
212
215
217 virtual void syncReferences(bool check_resize) = 0;
218
221};
222
223/*---------------------------------------------------------------------------*/
224/*---------------------------------------------------------------------------*/
225
226} // namespace Arcane::Materials
227
228/*---------------------------------------------------------------------------*/
229/*---------------------------------------------------------------------------*/
230
231#endif
Declarations of types on entities.
Constant view of an array of type T.
Interface of a data item.
Definition IData.h:34
Helper class for building a list of ComponentItems for a MeshMaterialVariableIndexer.
Arguments for methods copying between partial and global values.
Interface of a component (material or environment) of a mesh.
Arcane internal API for 'IMeshMaterialVariable'.
virtual void syncReferences(bool check_resize)=0
Synchronizes references.
virtual ConstArrayView< VariableRef * > variableReferenceList() const =0
List of 'VariableRef' associated with this variable.
virtual void copyFromBuffer(SmallSpan< const MatVarIndex > matvar_indexes, Span< const std::byte > bytes, RunQueue *queue)=0
Copies the variable values from a buffer.
virtual Int32 dataTypeSize() const =0
Byte size to save a variable value.
virtual void restoreData(IMeshComponent *component, IData *data, Integer data_index, Int32ConstArrayView ids, bool allow_null_id)=0
virtual void resizeForIndexer(ResizeVariableIndexerArgs &args)=0
Resizes the partial value associated with index index.
virtual void saveData(IMeshComponent *component, IData *data)=0
virtual void copyToBuffer(SmallSpan< const MatVarIndex > matvar_indexes, Span< std::byte > bytes, RunQueue *queue) const =0
Copies the variable values into a buffer.
virtual void copyBetweenPartialAndGlobal(const CopyBetweenPartialAndGlobalArgs &args)=0
virtual void initializeNewItemsWithZero(InitializeWithZeroArgs &args)=0
Initialize the values of new components with zero.
virtual Ref< IData > internalCreateSaveDataRef(Integer nb_value)=0
Arguments for methods copying between partial and global values.
Arguments for methods copying between partial and global values.
UniqueArray< CopyBetweenDataInfo > * m_copy_data
Copy information if only one command is used.
Reference to an instance.
View of an array of elements of type T.
Definition Span.h:805
View of an array of elements of type T.
Definition Span.h:635
1D data vector with value semantics (STL style).
Always enables tracing in Arcane parts concerning materials.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
std::int32_t Int32
Signed integer type of 32 bits.
Information for copying between two memory regions.