14#include "arcane/utils/NotSupportedException.h"
15#include "arcane/utils/ArgumentException.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/TraceInfo.h"
18#include "arcane/utils/Ref.h"
19#include "arcane/utils/MemoryAccessInfo.h"
20#include "arcane/utils/MemoryAllocator.h"
22#include "arcane/core/VariableDiff.h"
23#include "arcane/core/VariableBuildInfo.h"
24#include "arcane/core/VariableInfo.h"
25#include "arcane/core/IApplication.h"
26#include "arcane/core/IVariableMng.h"
27#include "arcane/core/IItemFamily.h"
28#include "arcane/core/IVariableSynchronizer.h"
29#include "arcane/core/IDataReader.h"
30#include "arcane/core/ItemGroup.h"
31#include "arcane/core/IDataFactoryMng.h"
32#include "arcane/core/IParallelMng.h"
33#include "arcane/core/IMesh.h"
35#include "arcane/core/datatype/DataTracer.h"
36#include "arcane/core/datatype/DataTypeTraits.h"
37#include "arcane/core/datatype/DataStorageBuildInfo.h"
39#include "arcane/core/VariableArray.h"
40#include "arcane/core/RawCopy.h"
42#include "arcane/core/internal/IDataInternal.h"
43#include "arcane/core/internal/IVariableMngInternal.h"
44#include "arcane/core/internal/IVariableInternal.h"
55template<
class DataType>
91 index = (*group_index_table)[index];
95 DataType
diff = DataType();
110 Int32
sid =
pm->commRank();
112 msg->pinfo() <<
"Processor " <<
sid <<
" : "
113 <<
"comparison impossible because the number of the elements is different "
129 if constexpr(std::is_same<TrueType,ReduceType>::value)
152 DataType
diff = DataType();
167 Int32
sid =
pm->commRank();
169 msg->pinfo() <<
"Processor " <<
sid <<
" : "
170 <<
" comparaison impossible car nombre d'éléments différents"
186 Integer max_size =
pm->reduce(Parallel::ReduceMax,size);
187 Integer
min_size =
pm->reduce(Parallel::ReduceMin,size);
188 msg->info(5) <<
"CheckReplica2 rep_size=" <<
pm->commSize() <<
" rank=" <<
pm->commRank();
191 msg->info() <<
"Can not compare values on replica for variable '" <<
var_name <<
"'"
192 <<
" because the number of elements is not the same on all the replica "
193 <<
" min=" <<
min_size <<
" max="<< max_size;
202 for( Integer index=0; index<size; ++index ){
203 DataType
diff = DataType();
249template<
typename T> VariableArrayT<T>* VariableArrayT<T>::
250getReference(
const VariableBuildInfo& vb,
const VariableInfo& vi)
254 ThatClass* true_ptr =
nullptr;
255 IVariableMng* vm = vb.variableMng();
256 IVariable* var = vm->checkVariable(vi);
258 true_ptr =
dynamic_cast<ThatClass*
>(var);
260 true_ptr =
new ThatClass(vb,vi);
261 vm->_internalApi()->addVariable(true_ptr);
263 ARCANE_CHECK_PTR(true_ptr);
270template<
typename T> VariableArrayT<T>* VariableArrayT<T>::
271getReference(IVariable* var)
274 throw ArgumentException(A_FUNCINFO,
"null variable");
275 auto* true_ptr =
dynamic_cast<ThatClass*
>(var);
277 ARCANE_FATAL(
"Can not build a reference from variable {0}",var->name());
285print(std::ostream&
o)
const
289 o <<
"(dimension=" << size <<
") ";
307 ARCANE_FATAL(
"variable '{0}' without family",fullName());
309 itemGroup().synchronizer()->synchronize(
this);
324 ARCANE_FATAL(
"variable '{0}' without family",fullName());
326 itemGroup().synchronizer()->synchronize(
this,
local_ids);
338 Real v2 = (
Real)(m_value->view().size());
350 ValueType&
data_values = m_value->_internal()->_internalDeprecatedValue();
365template<
typename T>
Integer VariableArrayT<T>::
366checkIfSame(IDataReader* reader,
Integer max_print,
bool compare_ghost)
368 if (itemKind()==IK_Particle)
370 ArrayView<T> from_array(valueView());
372 Ref< IArrayDataT<T> > ref_data(m_value->cloneTrueEmptyRef());
373 reader->read(
this,ref_data.get());
375 ArrayVariableDiff<T> csa;
376 return csa.check(
this,ref_data->view(),from_array,max_print,compare_ghost);
387 _checkIfSameOnAllReplicaHelper(IParallelMng* pm,IVariable* var,
388 ConstArrayView<T> values,
Integer max_print)
390 ArrayVariableDiff<T> csa;
391 return csa.checkReplica(pm,var,values,max_print);
396 _checkIfSameOnAllReplicaHelper(IParallelMng* pm,IVariable* var,
397 ConstArrayView<Byte> values,
Integer max_print)
400 UniqueArray<Integer> int_values(size);
401 for(
Integer i=0; i<size; ++i )
402 int_values[i] = values[i];
403 ArrayVariableDiff<Integer> csa;
404 return csa.checkReplica(pm,var,int_values,max_print);
408template<
typename T>
Integer VariableArrayT<T>::
409_checkIfSameOnAllReplica(IParallelMng* replica_pm,
Integer max_print)
411 return _checkIfSameOnAllReplicaHelper(replica_pm,
this,constValueView(),max_print);
439 error() << String::format(
"Can not convert the string '{0}' to type '{1}'",
455 values[
elem.localId()] = v;
465 <<
") of the group `" << group.
name() <<
"' does not match \n"
466 <<
"the type of the variable (" <<
itemKindName(this->itemKind()) <<
").";
476 ARCANE_ASSERT(source.
size()==destination.
size(),
477 (
"Impossible to copy: source and destination of different sizes !"));
481 value[destination[i]] = value[source[i]];
494 (
"Impossible to copy: source and destination of different sizes !"));
497 for(
Integer i=0; i<size; ++i ) {
518 debug(
Trace::High) <<
"Skip compact for partial variable " << name();
543 setIsSynchronized(itemGroup());
552 ARCANE_UNUSED(group);
572 eDataInitialisationPolicy init_policy = getGlobalDataInitialisationPolicy();
576 Integer current_size = m_value->view().size();
580 value_internal->dispose();
583 value_internal->_internalDeprecatedValue().resizeNoInit(new_size);
585 value_internal->resize(new_size);
586 if (new_size>current_size){
587 if (init_policy==DIP_InitWithDefault){
588 ArrayView<T> values = this->valueView();
589 for(
Integer i=current_size; i<new_size; ++i)
595 if (use_nan || use_nan2){
596 ArrayView<T> view = this->valueView();
597 DataTypeTraitsT<T>::fillNan(view.subView(current_size,new_size-current_size));
604 if (m_value->view().size() < value_internal->capacity()){
605 value_internal->shrink();
615 Int64 capacity = value_internal->capacity();
623template<
typename DataType>
void VariableArrayT<DataType>::
626 _resize(VariableResizeArgs(n,nb_additional));
635 m_value->_internal()->shrink();
645 return m_value->_internal()->capacity();
651template<
typename DataType>
void VariableArrayT<DataType>::
652fill(
const DataType& value)
654 m_value->view().fill(value);
660template<
typename DataType>
void VariableArrayT<DataType>::
661fill(
const DataType& value,
const ItemGroup& group)
663 ARCANE_UNUSED(group);
670template<
typename DataType>
void
671VariableArrayT<DataType>::
672swapValues(ThatClass& rhs)
674 _checkSwapIsValid(&rhs);
677 m_value->swapValues(rhs.m_value);
680 rhs.syncReferences();
695 ARCANE_FATAL(
"Unable to copy: source and destination of different sizes !");
710 return m_value->_internal()->_internalDeprecatedValue();
716ARCANE_INTERNAL_INSTANTIATE_TEMPLATE_FOR_NUMERIC_DATATYPE(VariableArrayT);
717template class VariableArrayT<String>;
#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_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Informations pour construire une instance de 'IData'.
Interface d'une famille d'entités.
virtual IVariableSynchronizer * allItemsSynchronizer()=0
Synchroniseur sur toutes les entités de la famille.
virtual ITraceMng * traceMng()=0
Gestionnaire de message associé
virtual IParallelMng * parallelMng()=0
Gestionnaire de parallèlisme.
Interface du gestionnaire de parallélisme pour un sous-domaine.
Groupe d'entités de maillage.
const String & name() const
Nom du groupe.
SharedPtrT< GroupIndexTable > localIdToIndex() const
Table des local ids vers une position pour toutes les entités du groupe.
IItemFamily * itemFamily() const
Famille d'entité à laquelle appartient ce groupe (0 pour le group nul)
eItemKind itemKind() const
Genre du groupe. Il s'agit du genre de ses éléments.
bool null() const
true is le groupe est le groupe nul
IMesh * mesh() const
Maillage auquel appartient ce groupe (0 pour le group nul)
Classe de base d'un élément de maillage.
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
bool isOwn() const
true si l'entité est appartient au sous-domaine
VariableArrayT(const VariableBuildInfo &v, const VariableInfo &vi)
Construit une variable basée sur la référence v.
IData * data() override
Données associées à la variable.
Paramètres nécessaires à la construction d'une variable.
Infos caractérisant une variable.
DataStorageTypeInfo storageTypeInfo() const
Informations sur le type de conteneur de la variable.
void _setData(const Ref< IData > &data)
Positionne la donnée.
static constexpr Integer simdAlignment()
Alignement pour les structures utilisant la vectorisation.
Vue constante d'un tableau de type T.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
Interface du gestionnaire de traces.
Référence à une instance.
InstanceType * get() const
Instance associée ou nullptr si aucune.
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
bool arcaneIsCheck()
Vrai si on est en mode vérification.
@ DIP_InitInitialWithNanResizeWithDefault
Initialisation avec des NaN pour à la création et le constructeur par défaut ensuite.
@ DIP_InitWithNan
Initialisation avec des NaN (Not a Number)
eItemKind
Genre d'entité de maillage.
@ IK_Unknown
Entité de maillage de genre inconnu ou non initialisé
const char * itemKindName(eItemKind kind)
Nom du genre d'entité.
double Real
Type représentant un réel.
Int32 Integer
Type représentant un entier.
std::int32_t Int32
Type entier signé sur 32 bits.