332 if (component->
materialMng()->isDataInitialisationWithZero()){
333 Integer
max_id = m_global_variable->itemFamily()->maxLocalId();
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]);
347 for( Integer i=0, n=ids.size(); i<n; ++i ){
348 Traits::setValue(tmp_values[ids[i]] , values[data_index+i] );
353 ComponentCell ec = *icell;
354 setValue(ec._varIndex(),tmp_values[ec.globalCell().localId()]);
361template<
typename Traits>
bool
362ItemMaterialVariableBase<Traits>::
363_isValidAndUsedAndGlobalUsed(PrivatePartType* partial_var)
367 if (!m_global_variable->isUsed() || !partial_var->isUsed())
375template <
typename Traits>
void
376ItemMaterialVariableBase<Traits>::
377_resizeForIndexer(ResizeVariableIndexerArgs& args)
379 Int32 index = args.m_var_index;
380 RunQueue& queue = args.m_queue;
382 PrivatePartType* partial_var = m_vars[index + 1];
383 if (_isValidAndUsedAndGlobalUsed(partial_var)) {
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);
395 if (args.isUseOneCommand()) {
397 auto source =
asBytes(m_host_views.view());
398 args.addOneCopyData(source,dest,1);
401 _copyHostViewsToViews(&queue);
407template <
typename Traits>
void
408ItemMaterialVariableBase<Traits>::
409_copyHostViewsToViews(RunQueue* queue)
412 auto source =
asBytes(m_host_views);
414 Accelerator::MemoryCopyArgs copy_args(dest,source);
415 copy_args.addAsync(
true);
416 queue->copyMemory(copy_args);
419 MemoryUtils::copy(dest,source);
425template <
typename Traits>
void
426ItemMaterialVariableBase<Traits>::
427_copyBetweenPartialAndGlobal(
const CopyBetweenPartialAndGlobalArgs& args)
429 Int32 var_index = args.m_var_index + 1;
430 PrivatePartType* partial_var = m_vars[var_index];
431 if (!_isValidAndUsedAndGlobalUsed(partial_var))
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;
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;
442 if (is_global_to_partial) {
443 std::swap(input, output);
444 std::swap(output_indexes, input_indexes);
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);
453 _genericCopyTo(input_bytes, input_indexes,
454 output_bytes, output_indexes, queue, data_type_size);
457 Traits::copyTo(input, input_indexes, output, output_indexes, queue);
464template <
typename Traits>
void
465ItemMaterialVariableBase<Traits>::
466_initializeNewItemsWithZero(InitializeWithZeroArgs& args)
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))
474 SmallSpan<const Int32> partial_indexes = args.m_indexes_in_multiple;
479 if (args.isUseOneCommand()){
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);
486 ContainerSpanType partial_view = m_host_views[var_index];
487 Int32 nb_partial = partial_indexes.size();
488 DataType zero = DataType();
493 Int32 index = partial_indexes[i];
494 Traits::setValue(partial_view[index], zero);
502template<
typename Traits>
void
506 fillPartialValuesWithSuperValues(LEVEL_ALLENVIRONMENT);
512template<
typename Traits>
void
517 if (level==LEVEL_MATERIAL)
518 _fillPartialValuesWithSuperValues(
mm->materialsAsComponents());
519 else if (level==LEVEL_ENVIRONMENT){
520 _fillPartialValuesWithSuperValues(
mm->environmentsAsComponents());
522 else if (level==LEVEL_ALLENVIRONMENT){
523 _fillPartialValuesWithSuperValues(
mm->environmentsAsComponents());
524 _fillPartialValuesWithSuperValues(
mm->materialsAsComponents());