14#include "arcane/utils/FatalErrorException.h"
15#include "arcane/utils/ValueChecker.h"
16#include "arcane/utils/PlatformUtils.h"
17#include "arcane/utils/ArraySimdPadder.h"
18#include "arcane/utils/IFunctor.h"
20#include "arcane/core/IItemFamily.h"
22#include "arcane/core/materials/IMeshComponent.h"
23#include "arcane/core/materials/ComponentItemInternal.h"
24#include "arcane/core/materials/ComponentPartItemVectorView.h"
25#include "arcane/core/materials/internal/IMeshComponentInternal.h"
27#include "arcane/materials/internal/MeshComponentPartData.h"
29#include "arcane/accelerator/Filter.h"
41MeshComponentPartData::
42MeshComponentPartData(IMeshComponent* component,
const String& debug_name)
43: TraceAccessor(component->traceMng())
44, m_component(component)
45, m_impure_var_idx(component->_internalApi()->variableIndexerIndex() + 1)
49 IMemoryAllocator* allocator = platform::getDefaultDataAllocator();
50 for (Integer i = 0; i < 2; ++i) {
51 m_value_indexes[i] = UniqueArray<Int32>(allocator);
52 m_items_internal_indexes[i] = UniqueArray<Int32>(allocator);
54 if (!debug_name.empty()) {
55 String base_name = String(
"MeshComponentPartData") + debug_name;
56 for (Integer i = 0; i < 2; ++i) {
57 m_value_indexes[i].setDebugName(base_name +
"ValueIndexes" + String::fromNumber(i));
58 m_items_internal_indexes[i].setDebugName(base_name +
"ValueIndexes" + String::fromNumber(i));
74void MeshComponentPartData::
75_notifyValueIndexesChanged(
RunQueue* queue)
78 indexes[0] = m_value_indexes[0].span();
79 indexes[1] = m_value_indexes[1].span();
82 for (Int32 i = 0; i < 2; ++i)
93 ArraySimdPadder::applySimdPaddingView(indexes[i]);
97 ArraySimdPadder::applySimdPaddingView(indexes[0]);
98 ArraySimdPadder::applySimdPaddingView(indexes[1]);
105void MeshComponentPartData::
121 info(4) <<
"BEGIN_BUILD_PART_DATA_FOR_COMPONENT c=" << m_component->name();
136 filterer.applyWithIndex(nb_index, is_pure_lambda, setter_lambda, A_FUNCINFO);
137 Int32 nb_out = filterer.nbOutputElement();
138 pure_indexes.resize(nb_out);
139 pure_internal_indexes.resize(nb_out);
140 nb_impure = nb_index - nb_out;
143 impure_indexes.resize(nb_impure);
144 impure_internal_indexes.resize(nb_impure);
147 SmallSpan<Int32> impure_indexes_view(impure_indexes.view());
148 SmallSpan<Int32> impure_internal_indexes_view(impure_internal_indexes.view());
149 auto is_impure_lambda = [=] ARCCORE_HOST_DEVICE(
Int32 i) ->
bool {
150 return matvar_indexes[i].arrayIndex() != 0;
152 auto setter_lambda = [=] ARCCORE_HOST_DEVICE(
Int32 i,
Int32 output_index) {
153 impure_indexes_view[output_index] = matvar_indexes[i].valueIndex();
154 impure_internal_indexes_view[output_index] = i;
156 filterer.applyWithIndex(nb_index, is_impure_lambda, setter_lambda, A_FUNCINFO);
157 filterer.nbOutputElement();
160 info(4) <<
"BUILD_PART_DATA_FOR_COMPONENT c=" << m_component->name()
161 <<
" nb_pure=" << pure_indexes.size()
162 <<
" nb_impure=" << impure_indexes.size();
164 _notifyValueIndexesChanged(&queue);
170void MeshComponentPartData::
171_setFromMatVarIndexes(ConstArrayView<MatVarIndex> globals,
172 ConstArrayView<MatVarIndex> multiples)
174 Integer nb_global = globals.size();
175 Integer nb_multiple = multiples.size();
178 const auto mat_part =
static_cast<Int32>(eMatPart::Pure);
181 for (Integer i = 0; i < nb_global; ++i)
182 idx[i] = globals[i].valueIndex();
186 const auto mat_part =
static_cast<Int32>(eMatPart::Impure);
189 for (Integer i = 0; i < nb_multiple; ++i)
190 idx[i] = multiples[i].valueIndex();
193 _notifyValueIndexesChanged(
nullptr);
199void MeshComponentPartData::
200_setConstituentListView(
const ConstituentItemLocalIdListView& v)
202 m_constituent_list_view = v;
208void MeshComponentPartData::
211 info(4) <<
"CHECK_VALID_COMPONENT_PART_DATA c=" << m_component->name();
212 _checkNeedRecompute();
213 ValueChecker vc(A_FUNCINFO);
215 for (Integer i = 0; i < 2; ++i) {
216 Int32 var_idx = (i == 0) ? 0 : m_impure_var_idx;
219 Integer nb_item = indexes.size();
220 vc.areEqual(nb_item, item_indexes.size(),
"Indexes size");
221 for (Integer k = 0; k < nb_item; ++k) {
222 MatVarIndex mvi(var_idx, indexes[k]);
223 MatVarIndex component_mvi = m_constituent_list_view._matVarIndex(item_indexes[k]);
224 if (mvi != component_mvi) {
225 info() <<
"Bad MatVarIndex i=" << i <<
" k=" << k
226 <<
" mvi=" << mvi <<
" component_mvi=" << component_mvi;
232 ARCANE_FATAL(
"Bad component part data nb_error={0}", nb_error);
238void MeshComponentPartData::
241 if (!m_is_need_recompute)
243 if (!m_compute_functor)
245 m_compute_functor->executeFunctor();
246 m_is_need_recompute =
false;
255 _checkNeedRecompute();
256 const auto mat_part =
static_cast<Int32
>(part);
259 Int32
var_idx = (part == eMatPart::Pure) ? 0 : impureVarIdx();
270 _checkNeedRecompute();
271 const auto mat_part =
static_cast<Int32
>(eMatPart::Pure);
284 _checkNeedRecompute();
285 const auto mat_part =
static_cast<Int32
>(eMatPart::Impure);
288 const Int32
var_idx = impureVarIdx();
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
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.
Algorithme générique de filtrage sur accélérateur.
File d'exécution pour un accélérateur.
Tableau d'items de types quelconques.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Vue sur la partie impure d'un composant.
Vue sur une partie pure ou partielles des entités d'un composant.
Vue sur la partie pure d'un composant.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
Vue constante d'un tableau de type T.
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.
eMatPart
Partie d'un composant.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Array< Int32 > Int32Array
Tableau dynamique à une dimension d'entiers 32 bits.
Int32 Integer
Type représentant un entier.