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"
33#include "arcane/core/ItemGroupObserver.h"
34#include "arcane/core/Variable.h"
35#include "arcane/core/VarRefEnumerator.h"
36#include "arcane/core/IVariableAccessor.h"
37#include "arcane/core/ItemGroup.h"
38#include "arcane/core/IMesh.h"
39#include "arcane/core/IItemFamily.h"
40#include "arcane/core/ISubDomain.h"
41#include "arcane/core/VariableInfo.h"
42#include "arcane/core/ISerializer.h"
43#include "arcane/core/VariableBuildInfo.h"
44#include "arcane/core/VariableComputeFunction.h"
45#include "arcane/core/CommonVariables.h"
46#include "arcane/core/Observable.h"
47#include "arcane/core/IVariableMng.h"
48#include "arcane/core/IDataReader.h"
49#include "arcane/core/IDataWriter.h"
50#include "arcane/core/IParallelMng.h"
51#include "arcane/core/VariableDependInfo.h"
52#include "arcane/core/IParallelReplication.h"
53#include "arcane/core/VariableMetaData.h"
54#include "arcane/core/IMeshMng.h"
55#include "arcane/core/MeshHandle.h"
56#include "arcane/core/VariableComparer.h"
57#include "arcane/core/datatype/DataAllocationInfo.h"
58#include "arcane/core/internal/IItemFamilyInternal.h"
59#include "arcane/core/internal/IVariableMngInternal.h"
60#include "arcane/core/internal/IVariableInternal.h"
61#include "arcane/core/internal/IDataInternal.h"
62#include "arcane/core/internal/IParallelMngInternal.h"
95 static std::atomic<Int64> modified_time_global_value;
108 bool m_need_property_update =
false;
122 bool m_want_shrink =
false;
135 switch (sbuf->
mode()) {
136 case ISerializer::ModeReserve:
143 Byte read_hash_id_buf[HASHID_SIZE];
144 Span<Byte> read_span(read_hash_id_buf, HASHID_SIZE);
149 " expected_hash_id='{1}'\n"
151 " This may be due to incoherence in variable list (order) between ranks"
152 " during serialization",
170 static const int HASHID_SIZE = 64;
182 constexpr Int64 hashid_hexa_length = 16;
183 constexpr Int64 name_length = HASHID_SIZE - hashid_hexa_length;
190 if (bytes.size() > name_length)
191 bytes = bytes.subspan(0, name_length);
192 auto hash_id2 = hash_id.
subspan(hashid_hexa_length, name_length);
193 hash_id2.copy(bytes);
200std::atomic<Int64> VariablePrivate::modified_time_global_value = 1;
208 Int64 v = VariablePrivate::modified_time_global_value;
209 ++VariablePrivate::modified_time_global_value;
218: m_sub_domain(v._subDomain())
219, m_data_factory_mng(v.dataFactoryMng())
220, m_mesh_handle(v.meshHandle())
222, m_property(v.property())
223, m_is_partial(vi.isPartial())
227 m_infos.setDefaultItemGroupName();
231 m_has_recursive_depend =
false;
237 m_want_shrink =
true;
245class ItemGroupPartialVariableObserver
250 explicit ItemGroupPartialVariableObserver(
IVariable* var)
253 ARCANE_ASSERT((m_var), (
"Variable pointer null"));
256 ARCANE_FATAL(
"No observer should be attached on all items group");
267 const Integer old_size = id_to_index->size();
269 if (group_size != (old_size + new_ids.
size()))
271 m_var->resizeFromGroup();
279 if (removed_lids.
empty())
284 const Integer old_size = id_to_index->size();
287 if (group_size != (old_size - removed_lids.
size()))
288 ARCANE_FATAL(
"Inconsistent reduced size {0} vs {1}", group_size, old_size);
292 source.reserve(group_size);
293 destination.
reserve(group_size);
294 for (
Integer i = 0, index = 0, removed_index = 0; i < old_size; ++i) {
295 if (removed_index < removed_lids.
size() &&
296 id_to_index->keyLocalId(i) == removed_lids[removed_index]) {
300 ARCANE_ASSERT((id_to_index->keyLocalId(i) == view[index].localId()),
301 (
"Inconsistent key (pos=%d,key=%d) vs (pos=%d,key=%d)",
302 i, id_to_index->keyLocalId(i), index, view[index].localId()));
304 destination.
add(index);
310 m_var->copyItemsValues(source, destination);
311 m_var->resizeFromGroup();
321 m_var->compact(*info);
329 m_var->resizeFromGroup();
346,
m_p(new VariablePrivate(v, vi, this))
367 return m_p->m_first_reference;
376 _checkSetProperty(ref);
377 ++
m_p->m_nb_reference;
379 if (
m_p->m_first_reference) {
388 m_p->m_first_reference = ref;
403 if (
m_p->m_first_reference == tmp)
404 m_p->m_first_reference =
m_p->m_first_reference->nextReference();
411 --
m_p->m_nb_reference;
412 _checkSetProperty(ref);
416 if (!_hasReference()) {
418 if (!is_persistant) {
420 _removeMeshReference();
434 return m_p->m_first_reference;
445 if (!_hasReference()) {
447 m_p->m_need_property_update =
false;
450 m_p->m_need_property_update =
true;
459 return m_p->m_nb_reference;
468 return m_p->m_sub_domain;
477 return m_p->m_sub_domain->variableMng();
486 return m_p->m_infos.localName();
495 return m_p->m_infos.fullName();
504 return m_p->m_infos.itemFamilyName();
513 return m_p->m_infos.itemGroupName();
522 return m_p->m_infos.meshName();
531 return m_p->m_infos.dataType();
543 if (!
m_p->m_need_property_update)
544 return m_p->m_property;
550 m_p->m_need_property_update =
false;
552 bool want_dump =
false;
553 bool want_sync =
false;
554 bool want_replica_sync =
false;
555 bool sub_domain_depend =
false;
556 bool execution_depend =
false;
557 bool want_private =
false;
558 bool want_restore =
false;
559 bool want_notemporary =
false;
560 bool want_exchange =
false;
561 bool want_persistant =
false;
562 bool want_shmem =
false;
563 bool want_dumpnull =
false;
574 want_replica_sync =
true;
576 sub_domain_depend =
true;
578 execution_depend =
true;
580 want_persistant =
true;
586 want_exchange =
true;
588 want_notemporary =
true;
592 want_dumpnull =
true;
599 if (!want_replica_sync)
601 if (sub_domain_depend)
603 if (execution_depend)
613 if (!want_notemporary)
621 return m_p->m_property;
630 m_p->m_need_property_update =
true;
639 if (
m_p->m_is_used == is_used)
642 m_p->m_is_used = is_used;
646 if (
m_p->m_is_used) {
649 ARCANE_FATAL(
"Variable with PInShMem property must be in all sub-domains (PSubDomainPrivate property cannot be set with PInShMem)");
651 if (
m_p->m_data->_commonInternal()->numericData() ==
nullptr) {
652 ARCANE_FATAL(
"Variable without NumericData cannot change allocator");
657 if (
m_p->m_mesh_handle.hasMesh()) {
658 pm =
m_p->m_mesh_handle.mesh()->parallelMng();
667 _checkSetItemFamily();
668 _checkSetItemGroup();
671 if (!
m_p->m_has_valid_data) {
680 m_p->m_data->fillDefault();
681 m_p->m_has_valid_data =
true;
686 _removeMeshReference();
692 m_p->m_has_valid_data =
false;
697 ref->internalSetUsed(
m_p->m_is_used);
705_removeMeshReference()
724 return m_p->m_is_used;
744 full_type_b +=
".Partial";
754_createMetaData()
const
758 vmd->setFullType(_buildVariableFullType(
this));
759 vmd->setMultiTag(String::fromNumber(
multiTag()));
770 return _createMetaData();
779 return makeRef(_createMetaData());
810 return results.nbDifference();
823 return r.nbDifference();
835 compare_args.setDataReader(reader);
837 return r.nbDifference();
846 if (
m_p->m_mesh_handle.hasMesh())
847 return m_p->m_mesh_handle.mesh();
857 return m_p->m_mesh_handle;
866 return m_p->m_item_group;
875 return m_p->m_infos.itemKind();
884 return m_p->m_infos.dimension();
893 return m_p->m_infos.multiTag();
902 return m_p->m_is_partial;
911 return m_p->m_item_family;
922 ARCANE_FATAL(
"Invalid data: name={0} datatype={1} dimension={2} multitag={3}",
923 m_p->m_infos.fullName(),
m_p->m_infos.dataType(),
924 m_p->m_infos.dimension(),
m_p->m_infos.multiTag());
926 data->setName(
m_p->m_infos.fullName());
935 m_p->m_has_valid_data = valid_data;
944 return m_p->m_has_valid_data;
951_setProperty(
int property)
962 return m_p->m_data_factory_mng;
972 m_p->serializeHashId(sbuffer);
973 m_p->m_data->serialize(sbuffer, ids, operation);
987 m_p->serializeHashId(sbuffer);
988 m_p->m_data->serialize(sbuffer, operation);
1002 ARCANE_FATAL(
"This call is invalid for item variable. Use resizeFromGroup() instead");
1004 _internalResize(resize_args);
1029 if (
m_p->m_item_group.isAllItems())
1030 new_size =
m_p->m_item_family->maxLocalId();
1032 new_size =
m_p->m_item_group.size();
1036 if (!group.
null()) {
1041 <<
"' with " << new_size <<
" items "
1042 <<
" this=" <<
this;
1051_checkSetItemFamily()
1068 if (family_name.
null()) {
1074 family =
mesh->itemFamily(ik);
1081 ARCANE_FATAL(
"Incoherent family name. var={0} from_type={1} given={2}",
1088 ARCANE_FATAL(
"Cannot have partial variable for a family without unique id map");
1090 m_p->m_item_family = family;
1092 <<
" family=" << family
1093 <<
" familyname='" << family_name <<
"'";
1103 if (!
m_p->m_item_group.null())
1105 const String& group_name =
m_p->m_infos.itemGroupName();
1107 if (group_name.null()) {
1108 m_p->m_item_group =
m_p->m_item_family->allItems();
1111 m_p->m_item_group =
m_p->m_item_family->findGroup(group_name,
true);
1113 ItemGroupImpl* internal =
m_p->m_item_group.internal();
1115 if (internal->parent() && (
mesh()->parallelMng()->isParallel() && internal->isOwn()))
1116 ARCANE_FATAL(
"Cannot add variable ({0}) on a own group (name={1})",
1119 if (group_name.empty())
1120 ARCANE_FATAL(
"Cannot create a partial variable with an empty item_group_name");
1122 <<
" to " <<
m_p->m_item_group.name();
1123 internal->attachObserver(
this,
new ItemGroupPartialVariableObserver(
this));
1133 return &(
m_p->m_write_observable);
1142 return &(
m_p->m_read_observable);
1151 return &(
m_p->m_on_size_changed_observable);
1163 update(DPT_PreviousTime);
1180 if (
m_p->m_has_recursive_depend) {
1181 for (
Integer k = 0, n =
m_p->m_depends.size(); k < n; ++k) {
1182 VariableDependInfo& vdi =
m_p->m_depends[k];
1183 if (vdi.dependType() == DPT_CurrentTime)
1184 vdi.variable()->update(
m_p->m_last_update_time);
1188 bool need_update =
false;
1189 Int64 modified_time =
m_p->m_modified_time;
1190 for (
Integer k = 0, n =
m_p->m_depends.size(); k < n; ++k) {
1191 VariableDependInfo& vdi =
m_p->m_depends[k];
1192 Int64 mt = vdi.variable()->modifiedTime();
1193 if (mt > modified_time) {
1199 IVariableComputeFunction* cf =
m_p->m_compute_function.get();
1227 return m_p->m_modified_time;
1264 m_p->m_compute_function = v;
1273 return m_p->m_compute_function.get();
1282 for (
Integer k = 0, n =
m_p->m_depends.size(); k < n; ++k) {
1297 m_p->m_tags[tagname] = tagvalue;
1306 m_p->m_tags.erase(tagname);
1315 return m_p->m_tags.find(tagname) !=
m_p->m_tags.end();
1324 std::map<String, String>::const_iterator i =
m_p->m_tags.find(tagname);
1325 if (i ==
m_p->m_tags.end())
1377 ARCANE_UNUSED(old_to_new_ids);
1397 if (!
m_p->m_is_used)
1398 ARCANE_FATAL(
"Can not swap variable values for unused variable (instance)");
1400 ARCANE_FATAL(
"Can not swap variable values for unused variable (argument)");
1402 ARCANE_FATAL(
"Can not swap variable values for partial variables");
1404 ARCANE_FATAL(
"Can not swap variable values for variables from different groups");
1413 return m_p->m_want_shrink;
1475 if (my_rank == master_rank) {
1511 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>.