13#ifndef ARCANE_VARIABLE_CC
14#define ARCANE_VARIABLE_CC
18#include "arcane/utils/List.h"
19#include "arcane/utils/FatalErrorException.h"
20#include "arcane/utils/OStringStream.h"
21#include "arcane/utils/Iterator.h"
22#include "arcane/utils/Iostream.h"
23#include "arcane/utils/String.h"
24#include "arcane/utils/ITraceMng.h"
25#include "arcane/utils/PlatformUtils.h"
26#include "arcane/utils/IStackTraceService.h"
27#include "arcane/utils/MemoryAccessInfo.h"
28#include "arcane/utils/NotImplementedException.h"
29#include "arcane/utils/ScopedPtr.h"
30#include "arcane/utils/StringBuilder.h"
31#include "arcane/utils/MemoryView.h"
32#include "arcane/utils/Convert.h"
34#include "arcane/core/ItemGroupObserver.h"
35#include "arcane/core/Variable.h"
36#include "arcane/core/VarRefEnumerator.h"
37#include "arcane/core/IVariableAccessor.h"
38#include "arcane/core/ItemGroup.h"
39#include "arcane/core/IMesh.h"
40#include "arcane/core/IItemFamily.h"
41#include "arcane/core/ISubDomain.h"
42#include "arcane/core/VariableInfo.h"
43#include "arcane/core/ISerializer.h"
44#include "arcane/core/VariableBuildInfo.h"
45#include "arcane/core/VariableComputeFunction.h"
46#include "arcane/core/CommonVariables.h"
47#include "arcane/core/Observable.h"
48#include "arcane/core/IVariableMng.h"
49#include "arcane/core/IDataReader.h"
50#include "arcane/core/IDataWriter.h"
51#include "arcane/core/IParallelMng.h"
52#include "arcane/core/VariableDependInfo.h"
53#include "arcane/core/IParallelReplication.h"
54#include "arcane/core/VariableMetaData.h"
55#include "arcane/core/IMeshMng.h"
56#include "arcane/core/MeshHandle.h"
57#include "arcane/core/VariableComparer.h"
58#include "arcane/core/datatype/DataAllocationInfo.h"
59#include "arcane/core/internal/IItemFamilyInternal.h"
60#include "arcane/core/internal/IVariableMngInternal.h"
61#include "arcane/core/internal/IVariableInternal.h"
62#include "arcane/core/internal/IDataInternal.h"
63#include "arcane/core/internal/IParallelMngInternal.h"
96 static std::atomic<Int64> modified_time_global_value;
109 bool m_need_property_update =
false;
123 bool m_want_shrink =
false;
136 switch (sbuf->
mode()) {
137 case ISerializer::ModeReserve:
144 Byte read_hash_id_buf[HASHID_SIZE];
145 Span<Byte> read_span(read_hash_id_buf, HASHID_SIZE);
150 " expected_hash_id='{1}'\n"
152 " This may be due to incoherence in variable list (order) between ranks"
153 " during serialization",
171 static const int HASHID_SIZE = 64;
183 constexpr Int64 hashid_hexa_length = 16;
184 constexpr Int64 name_length = HASHID_SIZE - hashid_hexa_length;
191 if (bytes.size() > name_length)
192 bytes = bytes.subspan(0, name_length);
193 auto hash_id2 = hash_id.
subspan(hashid_hexa_length, name_length);
194 hash_id2.copy(bytes);
201std::atomic<Int64> VariablePrivate::modified_time_global_value = 1;
209 Int64 v = VariablePrivate::modified_time_global_value;
210 ++VariablePrivate::modified_time_global_value;
219: m_sub_domain(v._subDomain())
220, m_data_factory_mng(v.dataFactoryMng())
221, m_mesh_handle(v.meshHandle())
223, m_property(v.property())
224, m_is_partial(vi.isPartial())
228 m_infos.setDefaultItemGroupName();
232 m_has_recursive_depend =
false;
238 m_want_shrink =
true;
246class ItemGroupPartialVariableObserver
251 explicit ItemGroupPartialVariableObserver(
IVariable* var)
254 ARCANE_ASSERT((m_var), (
"Variable pointer null"));
257 ARCANE_FATAL(
"No observer should be attached on all items group");
268 const Integer old_size = id_to_index->size();
270 if (group_size != (old_size + new_ids.
size()))
272 m_var->resizeFromGroup();
280 if (removed_lids.
empty())
285 const Integer old_size = id_to_index->size();
288 if (group_size != (old_size - removed_lids.
size()))
289 ARCANE_FATAL(
"Inconsistent reduced size {0} vs {1}", group_size, old_size);
293 source.reserve(group_size);
294 destination.
reserve(group_size);
295 for (
Integer i = 0, index = 0, removed_index = 0; i < old_size; ++i) {
296 if (removed_index < removed_lids.
size() &&
297 id_to_index->keyLocalId(i) == removed_lids[removed_index]) {
301 ARCANE_ASSERT((id_to_index->keyLocalId(i) == view[index].localId()),
302 (
"Inconsistent key (pos=%d,key=%d) vs (pos=%d,key=%d)",
303 i, id_to_index->keyLocalId(i), index, view[index].localId()));
305 destination.
add(index);
311 m_var->copyItemsValues(source, destination);
312 m_var->resizeFromGroup();
322 m_var->compact(*info);
330 m_var->resizeFromGroup();
347,
m_p(new VariablePrivate(v, vi, this))
368 return m_p->m_first_reference;
377 _checkSetProperty(ref);
378 ++
m_p->m_nb_reference;
380 if (
m_p->m_first_reference) {
389 m_p->m_first_reference = ref;
404 if (
m_p->m_first_reference == tmp)
405 m_p->m_first_reference =
m_p->m_first_reference->nextReference();
412 --
m_p->m_nb_reference;
413 _checkSetProperty(ref);
417 if (!_hasReference()) {
419 if (!is_persistant) {
421 _removeMeshReference();
435 return m_p->m_first_reference;
446 if (!_hasReference()) {
448 m_p->m_need_property_update =
false;
451 m_p->m_need_property_update =
true;
460 return m_p->m_nb_reference;
469 return m_p->m_sub_domain;
478 return m_p->m_sub_domain->variableMng();
487 return m_p->m_infos.localName();
496 return m_p->m_infos.fullName();
505 return m_p->m_infos.itemFamilyName();
514 return m_p->m_infos.itemGroupName();
523 return m_p->m_infos.meshName();
532 return m_p->m_infos.dataType();
544 if (!
m_p->m_need_property_update)
545 return m_p->m_property;
551 m_p->m_need_property_update =
false;
553 bool want_dump =
false;
554 bool want_sync =
false;
555 bool want_replica_sync =
false;
556 bool sub_domain_depend =
false;
557 bool execution_depend =
false;
558 bool want_private =
false;
559 bool want_restore =
false;
560 bool want_notemporary =
false;
561 bool want_exchange =
false;
562 bool want_persistant =
false;
563 bool want_shmem =
false;
564 bool want_dumpnull =
false;
575 want_replica_sync =
true;
577 sub_domain_depend =
true;
579 execution_depend =
true;
581 want_persistant =
true;
587 want_exchange =
true;
589 want_notemporary =
true;
593 want_dumpnull =
true;
600 if (!want_replica_sync)
602 if (sub_domain_depend)
604 if (execution_depend)
614 if (!want_notemporary)
622 return m_p->m_property;
631 m_p->m_need_property_update =
true;
640 if (
m_p->m_is_used == is_used)
643 m_p->m_is_used = is_used;
647 if (
m_p->m_is_used) {
650 ARCANE_FATAL(
"Variable with PInShMem property must be in all sub-domains (PSubDomainPrivate property cannot be set with PInShMem)");
652 if (
m_p->m_data->_commonInternal()->numericData() ==
nullptr) {
653 ARCANE_FATAL(
"Variable without NumericData cannot change allocator");
658 if (
m_p->m_mesh_handle.hasMesh()) {
659 pm =
m_p->m_mesh_handle.mesh()->parallelMng();
668 _checkSetItemFamily();
669 _checkSetItemGroup();
672 if (!
m_p->m_has_valid_data) {
681 m_p->m_data->fillDefault();
682 m_p->m_has_valid_data =
true;
687 _removeMeshReference();
693 m_p->m_has_valid_data =
false;
698 ref->internalSetUsed(
m_p->m_is_used);
706_removeMeshReference()
725 return m_p->m_is_used;
745 full_type_b +=
".Partial";
755_createMetaData()
const
759 vmd->setFullType(_buildVariableFullType(
this));
760 vmd->setMultiTag(String::fromNumber(
multiTag()));
771 return _createMetaData();
780 return makeRef(_createMetaData());
811 return results.nbDifference();
824 return r.nbDifference();
836 compare_args.setDataReader(reader);
838 return r.nbDifference();
847 if (
m_p->m_mesh_handle.hasMesh())
848 return m_p->m_mesh_handle.mesh();
858 return m_p->m_mesh_handle;
867 return m_p->m_item_group;
876 return m_p->m_infos.itemKind();
885 return m_p->m_infos.dimension();
894 return m_p->m_infos.multiTag();
903 return m_p->m_is_partial;
912 return m_p->m_item_family;
923 ARCANE_FATAL(
"Invalid data: name={0} datatype={1} dimension={2} multitag={3}",
924 m_p->m_infos.fullName(),
m_p->m_infos.dataType(),
925 m_p->m_infos.dimension(),
m_p->m_infos.multiTag());
927 data->setName(
m_p->m_infos.fullName());
936 m_p->m_has_valid_data = valid_data;
945 return m_p->m_has_valid_data;
952_setProperty(
int property)
963 return m_p->m_data_factory_mng;
973 m_p->serializeHashId(sbuffer);
974 m_p->m_data->serialize(sbuffer, ids, operation);
988 m_p->serializeHashId(sbuffer);
989 m_p->m_data->serialize(sbuffer, operation);
1003 ARCANE_FATAL(
"This call is invalid for item variable. Use resizeFromGroup() instead");
1005 _internalResize(resize_args);
1030 if (
m_p->m_item_group.isAllItems())
1031 new_size =
m_p->m_item_family->maxLocalId();
1033 new_size =
m_p->m_item_group.size();
1037 if (!group.
null()) {
1042 <<
"' with " << new_size <<
" items "
1043 <<
" this=" <<
this;
1052_checkSetItemFamily()
1069 if (family_name.
null()) {
1075 family =
mesh->itemFamily(ik);
1082 ARCANE_FATAL(
"Incoherent family name. var={0} from_type={1} given={2}",
1089 ARCANE_FATAL(
"Cannot have partial variable for a family without unique id map");
1091 m_p->m_item_family = family;
1093 <<
" family=" << family
1094 <<
" familyname='" << family_name <<
"'";
1104 if (!
m_p->m_item_group.null())
1106 const String& group_name =
m_p->m_infos.itemGroupName();
1108 if (group_name.null()) {
1109 m_p->m_item_group =
m_p->m_item_family->allItems();
1112 m_p->m_item_group =
m_p->m_item_family->findGroup(group_name,
true);
1114 ItemGroupImpl* internal =
m_p->m_item_group.internal();
1116 if (internal->parent() && (
mesh()->parallelMng()->isParallel() && internal->isOwn()))
1117 ARCANE_FATAL(
"Cannot add variable ({0}) on a own group (name={1})",
1120 if (group_name.empty())
1121 ARCANE_FATAL(
"Cannot create a partial variable with an empty item_group_name");
1123 <<
" to " <<
m_p->m_item_group.name();
1124 internal->attachObserver(
this,
new ItemGroupPartialVariableObserver(
this));
1134 return &(
m_p->m_write_observable);
1143 return &(
m_p->m_read_observable);
1152 return &(
m_p->m_on_size_changed_observable);
1164 update(DPT_PreviousTime);
1181 if (
m_p->m_has_recursive_depend) {
1182 for (
Integer k = 0, n =
m_p->m_depends.size(); k < n; ++k) {
1183 VariableDependInfo& vdi =
m_p->m_depends[k];
1184 if (vdi.dependType() == DPT_CurrentTime)
1185 vdi.variable()->update(
m_p->m_last_update_time);
1189 bool need_update =
false;
1190 Int64 modified_time =
m_p->m_modified_time;
1191 for (
Integer k = 0, n =
m_p->m_depends.size(); k < n; ++k) {
1192 VariableDependInfo& vdi =
m_p->m_depends[k];
1193 Int64 mt = vdi.variable()->modifiedTime();
1194 if (mt > modified_time) {
1200 IVariableComputeFunction* cf =
m_p->m_compute_function.get();
1228 return m_p->m_modified_time;
1265 m_p->m_compute_function = v;
1274 return m_p->m_compute_function.get();
1283 for (
Integer k = 0, n =
m_p->m_depends.size(); k < n; ++k) {
1298 m_p->m_tags[tagname] = tagvalue;
1307 m_p->m_tags.erase(tagname);
1316 return m_p->m_tags.find(tagname) !=
m_p->m_tags.end();
1325 std::map<String, String>::const_iterator i =
m_p->m_tags.find(tagname);
1326 if (i ==
m_p->m_tags.end())
1378 ARCANE_UNUSED(old_to_new_ids);
1398 if (!
m_p->m_is_used)
1399 ARCANE_FATAL(
"Can not swap variable values for unused variable (instance)");
1401 ARCANE_FATAL(
"Can not swap variable values for unused variable (argument)");
1403 ARCANE_FATAL(
"Can not swap variable values for partial variables");
1405 ARCANE_FATAL(
"Can not swap variable values for variables from different groups");
1414 return m_p->m_want_shrink;
1476 if (my_rank == master_rank) {
1512 return m_variable->_compareVariable(compare_args);
#define ARCANE_CHECK_POINTER(ptr)
Macro returning the pointer ptr if it is not null or throwing an exception if it is null.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Base class for 1D data vectors.
void add(ConstReferenceType val)
Adds element val to the end of the array.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
Observable that automatically calls IObservable::detachAllObservers() in the destructor.
Real globalTime() const
Current time.
constexpr Integer size() const noexcept
Number of elements in the array.
constexpr bool empty() const noexcept
true if the array is empty (size()==0)
Constant view on a contiguous memory region containing fixed-size elements.
constexpr SpanType bytes() const
View in byte form.
Information on data allocation.
Hash algorithm return value.
Interface of the data factory manager.
virtual INumericDataInternal * numericData()
Generic interface for numeric data (nullptr if the data is not numeric).
Interface of an operation on a data.
Interface for reading variable data.
virtual void read(IVariable *var, IData *data)=0
Reads the data data of the variable var.
Interface for writing variable data.
virtual void write(IVariable *var, IData *data)=0
Writes the data data of the variable var.
Interface of a data item.
virtual DataAllocationInfo allocationInfo() const =0
Allocation information.
virtual IDataInternal * _commonInternal()=0
virtual void setAllocationInfo(const DataAllocationInfo &v)=0
Sets the allocation information.
Interface of a hashing algorithm.
virtual void computeHash(Span< const std::byte > input, HashAlgorithmValue &value)
Calculates the hash value for the array input.
virtual void addVariable(IVariable *var)=0
Adds a variable to this family.
virtual void removeVariable(IVariable *var)=0
Removes a variable from this family.
Interface of an entity family.
virtual bool hasUniqueIdMap() const =0
Indicates if the family has a uniqueId to localId conversion table.
virtual String name() const =0
Family name.
virtual eItemKind itemKind() const =0
Entity kind.
virtual IItemFamilyInternal * _internalApi()=0
Internal Arcane API.
virtual IItemFamily * findItemFamily(eItemKind ik, const String &name, bool create_if_needed=false, bool register_modifier_if_created=false)=0
Returns the family named name.
virtual MeshHandle * findMeshHandle(const String &name, bool throw_exception)=0
Searches for the mesh with name name.
Interface for an 'IData' of a numeric type.
virtual void changeAllocator(const MemoryAllocationOptions &alloc_info)=0
Changes the variable's allocator.
virtual MutableMemoryView memoryView()=0
Memory view of the data.
Interface of an observable.
virtual void notifyAllObservers()=0
Notifies all observers.
virtual MemoryAllocationOptions machineShMemWinMemoryAllocator()=0
Method allowing retrieval of a shared memory allocator.
Interface of the parallelism manager for a subdomain.
virtual void gatherVariable(ConstArrayView< char > send_buf, Array< char > &recv_buf, Int32 rank)=0
Performs an all-gather operation across all processors.
virtual Int32 commRank() const =0
Rank of this instance in the communicator.
virtual IParallelReplication * replication() const =0
Replication information.
virtual Integer masterIORank() const =0
Rank of the instance managing I/O (for which isMasterIO() is true).
virtual IParallelMngInternal * _internalApi()=0
Internal Arcane API.
Brief information on parallel subdomain replication.
virtual bool hasReplication() const =0
Indicates if replication is active.
virtual IParallelMng * replicaParallelMng() const =0
Communicator associated with all replicas representing the same subdomain.
@ ModePut
The serializer expects reserve().
@ ModeGet
The serializer expects get().
virtual void putSpan(Span< const Real > values)
Add the array values.
virtual eMode mode() const =0
Current operating mode.
virtual void getSpan(Span< Real > values)
Retrieve the array values.
virtual void reserveSpan(eBasicDataType dt, Int64 n)=0
Reserves memory for n values of dt.
Interface of the subdomain manager.
virtual const CommonVariables & commonVariables() const =0
Information on standard variables.
virtual IParallelMng * parallelMng()=0
Returns the parallelism manager.
virtual IMeshMng * meshMng() const =0
Returns the mesh manager.
virtual IVariableMng * variableMng()=0
Returns the variable manager.
Interface of the functor class for recalculating a variable.
Internal part of Ivariable.
virtual void removeVariable(IVariable *var)=0
Removes a variable.
Variable manager interface.
virtual IVariableMngInternal * _internalApi()=0
Internal Arcane API.
virtual eDataType dataType() const =0
Data type managed by the variable (Real, Integer, ...).
eDependType
Dependency Type.
@ PSubDomainDepend
Indicates that the variable value is dependent on the subdomain.
@ PNoExchange
Indicates that the variable should not be exchanged.
@ PNoReplicaSync
Indicates that the variable does not necessarily have the same value across replicas.
@ PTemporary
Indicates that the variable is temporary.
@ PInShMem
Indicates that the variable must be allocated in shared memory.
@ PExecutionDepend
Indicates that the variable value is dependent on the execution.
@ PPrivate
Indicates that the variable is private.
@ PPersistant
Indicates that the variable is persistent.
@ PNoRestore
Indicates that the variable should not be restored.
@ PSubDomainPrivate
Indicates that the variable is private to the subdomain.
@ PNoNeedSync
Indicates that the variable is not necessarily synchronized.
@ PNoDump
Indicates that the variable should not be saved.
@ PDumpNull
Indicates that the save will be null for this variable and for this subdomain.
virtual eItemKind itemKind() const =0
Kind of mesh entities on which the variable is based.
virtual bool isPartial() const =0
Indicates if the variable is partial.
virtual Integer dimension() const =0
Dimension of the variable.
virtual IData * data()=0
Data associated with the variable.
virtual ItemGroup itemGroup() const =0
Associated mesh group.
static Int64 incrementModifiedTime()
Increments the modification counter and returns its value before modification.
virtual Integer multiTag() const =0
Indicates if the variable is a multi-sized array.
virtual void update()=0
Recalculates the variable if necessary.
static const char * TAG_POST_PROCESSING
Tag used to indicate if a variable will be post-processed.
static const char * TAG_POST_PROCESSING_AT_THIS_ITERATION
Tag used to indicate if a variable will be post-processed at this iteration.
Functor for a hash function.
void detachObserver(const void *ref)
Detaches an observer.
void executeExtend(const Int32ConstArrayView *info) override
Execute the action associated with the extension.
void executeReduce(const Int32ConstArrayView *info) override
Execute the action associated with the extension.
void executeInvalidate() override
Execute the action associated with invalidation.
void executeCompact(const Int32ConstArrayView *info) override
Executes the action associated with compaction.
bool needInfo() const override
Indicates whether the observer will need transition information.
ItemGroupImpl * internal() const
Returns the group implementation.
SharedPtrT< GroupIndexTable > localIdToIndex() const
Table of local ids to a position for all entities in the group.
ItemVectorView view() const
View of the group entities.
Integer size() const
Number of elements in the group.
bool isAllItems() const
Indicates if the group is that of all entities.
bool null() const
true means the group is the null group
View on a vector of entities.
Options to configure allocations.
bool isNull() const
Indicates if the handle is null (it does not reference any existing mesh or not).
IMesh * mesh() const
Associated mesh.
Exception when a function is not implemented.
Reference to an instance.
Encapsulation of an automatically destructing pointer.
__host__ __device__ void fill(T o)
Fills the array with the value o.
View of an array of elements of type T.
constexpr __host__ __device__ Span< T, DynExtent > subspan(Int64 abegin, Int64 asize) const
Sub-view starting from element abegin and containing asize elements.
Unicode character string constructor.
String toString() const
Returns the constructed character string.
Unicode character string.
bool null() const
Returns true if the string is null.
Span< const Byte > bytes() const
Returns the conversion of the instance into UTF-8 encoding.
StringView view() const
Returns a view of the current string.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flow for a debug message.
ITraceMng * traceMng() const
Trace manager.
1D data vector with value semantics (STL style).
Parameters necessary for building a variable.
Arguments for VariableComparer methods.
void setMaxPrint(Int32 v)
Sets the number of errors to display in the listing.
void setCompareGhost(bool v)
Indicates on which entities the comparison is performed.
Results of a comparison operation.
Information about a variable dependency.
IVariable::eDependType dependType() const
Dependency type.
IVariable * variable() const
Variable.
Information characterizing a variable.
const String & itemFamilyName() const
Name of the entity family to which the variable is associated.
const String & meshName() const
Name of the mesh to which the variable is associated.
void resize(const VariableResizeArgs &resize_args) override
Resizes the variable by adding additional capacity.
void changeAllocator(const MemoryAllocationOptions &alloc_info) override
Changes the variable's allocator.
VariableComparerResults compareVariable(const VariableComparerArgs &compare_args) override
Applies the comparison method specified by compare_args.
bool m_has_recursive_depend
True if dependencies are recursive.
IParallelMng * replicaParallelMng() const
Returns the IParallelMng of the mesh replica associated with the variable.
VariableInfo m_infos
Characteristic information of the variable.
IItemFamily * m_item_family
Entity family (can be null).
Integer m_nb_reference
First reference on the variable.
UniqueArray< VariableDependInfo > m_depends
List of dependencies for this variable.
int m_property
Properties of the variable.
AutoDetachObservable m_on_size_changed_observable
Resize observable.
Byte m_hash_id[HASHID_SIZE]
Hash of the variable to check serialization consistency.
Real m_last_update_time
Physical time of the last update.
Int64 m_modified_time
Tag of the last modification.
MeshHandle m_mesh_handle
Mesh (can be null).
String computeComparisonHashCollective(IHashAlgorithm *hash_algo, IData *sorted_data) override
Calculates the comparison hash for the variable.
std::map< String, String > m_tags
List of tags.
ItemGroup m_item_group
Entity group to which the variable is associated.
bool m_is_used
Usage status of the variable.
void serializeHashId(ISerializer *sbuf)
Serializes the hashid.
ScopedPtrT< IVariableComputeFunction > m_compute_function
Calculation function.
AutoDetachObservable m_read_observable
Read observable.
AutoDetachObservable m_write_observable
Write observable.
bool m_has_valid_data
True if the data is valid.
bool m_is_partial
True if the variable is partial.
Variable * m_variable
Associated variable.
Ref< IData > m_data
Variable data.
virtual void updateFromInternal()
Updates from the internal part.
void setPreviousReference(VariableRef *v)
Sets the previous reference.
VariableRef * previousReference()
Previous reference (or null) to variable().
virtual int referenceProperty() const
Reference properties (internal).
void setNextReference(VariableRef *v)
Sets the next reference.
VariableRef * nextReference()
Next reference (or null) to variable().
Arguments for resizing a variable.
void resizeFromGroup() override
Sets the number of elements for a mesh variable.
String itemGroupName() const final
Name of the associated entity group.
IMesh * mesh() const final
Mesh associated with the variable.
void notifyBeginWrite() override
Notifies of the start of writing data().
Integer nbReference() const override
Number of references on this variable.
void removeVariableRef(VariableRef *ref) override
Removes a reference to this variable.
void _checkSwapIsValid(Variable *rhs)
Checks if it is possible to swap the values of the instance with those of rhs.
bool isUsed() const override
Usage state of the variable.
Variable(const VariableBuildInfo &v, const VariableInfo &vi)
Creates a variable linked to the reference v.
void _setData(const Ref< IData > &data)
Positions the data.
void _setValidData(bool valid_data)
Indicates if the variable data is valid.
VariableMetaData * createMetaData() const override
Creates an instance containing the variable's metadata.
IVariableComputeFunction * computeFunction() override
Function used to update the variable.
Ref< VariableMetaData > createMetaDataRef() const override
Creates an instance containing the variable's metadata.
bool isPartial() const override
Indicates if the variable is partial.
String tagValue(const String &tagname) override
Value of the tag tagname. The string is null if the tag does not exist.
void notifyReferencePropertyChanged() override
IVariableMng * variableMng() const override
Variable manager associated with the variable.
void removeTag(const String &tagname) override
Removes the tag tagname.
void addDepend(IVariable *var, eDependType dt) override
Adds var to the list of dependencies.
String name() const final
Variable name.
IObservable * readObservable() override
Read observable.
virtual VariableComparerResults _compareVariable(const VariableComparerArgs &compare_args)=0
Comparison of values between variables.
void serialize(ISerializer *sbuffer, IDataOperation *operation) override
ItemGroup itemGroup() const final
Associated mesh group.
IObservable * onSizeChangedObservable() override
Size change observable.
void notifyEndRead() override
Notifies of external modification of data().
void read(IDataReader *d) override
void syncReferences() override
Synchronizes references.
void setUsed(bool v) override
Sets the usage state of the variable.
VariableRef * firstReference() const override
First reference (or null) on this variable.
String fullName() const final
Full variable name (with family prefix).
eItemKind itemKind() const override
Kind of mesh entities on which the variable is based.
ISubDomain * subDomain() override
Subdomain associated with the variable (TODO deprecate end of 2023).
void update() override
Recalculates the variable if necessary.
Integer dimension() const override
Dimension of the variable.
Int64 modifiedTime() override
Time when the variable was updated.
void setUpToDate() override
Indicates that the variable has just been updated.
void addTag(const String &tagname, const String &tagvalue) override
Adds the tag tagname with the value tagvalue.
Int32 checkIfSame(IDataReader *reader, Integer max_print, bool compare_ghost) final
Checks that the variable is identical to a reference value.
~Variable() override
Frees resources.
bool _hasValidData() const
Indicates if the variable data is valid.
IObservable * writeObservable() override
Write observable.
void addVariableRef(VariableRef *ref) override
Adds a reference to this variable.
Integer multiTag() const override
Indicates if the variable is a multi-sized array.
void setComputeFunction(IVariableComputeFunction *v) override
Sets the variable's recalculation function.
void resize(Integer n) override
Sets the number of elements for an array variable.
IVariableInternal * _internalApi() override
Internal Arcane API.
IItemFamily * itemFamily() const final
Associated entity family.
eDataType dataType() const override
Data type managed by the variable (Real, Integer, ...).
void write(IDataWriter *d) override
Saves the variable.
IDataFactoryMng * dataFactoryMng() const final
Data factory associated with the variable.
void changeGroupIds(Int32ConstArrayView old_to_new_ids) override
pH: EXPERIMENTAL
void removeDepend(IVariable *var) override
Removes var from the list of dependencies.
VariablePrivate * m_p
Implementation.
String itemFamilyName() const final
Name of the associated family (null if none).
Int32 checkIfSync(Integer max_print) final
Checks if the variable is properly synchronized.
DataAllocationInfo allocationInfo() const override
Allocation information.
int property() const override
Int32 checkIfSameOnAllReplica(Integer max_print) final
Checks if the variable has the same values on all replicas.
void dependInfos(Array< VariableDependInfo > &infos) override
Dependency information.
bool hasTag(const String &tagname) override
true if the variable has the tag tagname
void setAllocationInfo(const DataAllocationInfo &v) override
Sets allocation information.
MeshHandle meshHandle() const final
Mesh associated with the variable.
String meshName() const final
Name of the associated mesh (null if none).
String toHexaString(ByteConstArrayView input)
Converts a byte array to its hexadecimal representation.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
@ DIP_Legacy
Initialization in historical mode.
std::int64_t Int64
Signed integer type of 64 bits.
eDataInitialisationPolicy getGlobalDataInitialisationPolicy()
Gets the initialization policy for variables.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
@ SameOnAllReplica
Checks that the variable values are the same on all replicas.
@ Sync
Checks that the variable is synchronized.
eItemKind
Mesh entity type.
@ IK_Particle
Particle mesh entity.
@ IK_Unknown
Unknown or uninitialized mesh entity.
@ IK_DoF
Degree of Freedom mesh entity.
const char * itemKindName(eItemKind kind)
Entity kind name.
double Real
Type representing a real number.
Impl::SpanTypeFromSize< conststd::byte, SizeType >::SpanType asBytes(const SpanImpl< DataType, SizeType, Extent > &s)
Converts the view into an array of non-modifiable bytes.
unsigned char Byte
Type of a byte.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
const char * dataTypeName(eDataType type)
Data type name.
std::int32_t Int32
Signed integer type of 32 bits.
Span< DataType > asSpan(Span< std::byte, Extent > bytes)
Converts a Span<std::byte> into a Span<DataType>.