Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
IVariable.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* IVariable.h (C) 2000-2026 */
9/* */
10/* Interface of the Variable class. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IVARIABLE_H
13#define ARCANE_CORE_IVARIABLE_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/serialize/SerializeGlobal.h"
18
19#include "arcane/utils/Ref.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
39class ARCANE_CORE_EXPORT IVariable
40{
41 public:
42
45 {
46 DPT_PreviousTime,
47 DPT_CurrentTime
48 };
49
50 public:
51
55 enum
56 {
62 PNoDump = (1 << 0),
63
70 PNoNeedSync = (1 << 1),
71
73 PHasTrace = (1 << 2),
74
81 PSubDomainDepend = (1 << 3),
82
90
96 PExecutionDepend = (1 << 5),
97
103 PPrivate = (1 << 6),
104
114 PTemporary = (1 << 7),
115
120 PNoRestore = (1 << 8),
121
130 PNoExchange = (1 << 9),
131
138 PPersistant = (1 << 10),
139
147 PNoReplicaSync = (1 << 11),
148
156 PInShMem = (1 << 12),
157
167 PDumpNull = (1 << 13)
168 };
169
170 public:
171
173 static const char* TAG_POST_PROCESSING;
174
177
178 public:
179
180 friend class VariableMng;
181
182 public:
183
184 virtual ~IVariable() = default;
185
186 public:
187
189 virtual ISubDomain* subDomain() = 0;
190
191 public:
192
194 virtual IVariableMng* variableMng() const = 0;
195
197 virtual Real allocatedMemory() const = 0;
198
200 virtual String name() const = 0;
201
203 virtual String fullName() const = 0;
204
206 virtual eDataType dataType() const = 0;
207
221 virtual eItemKind itemKind() const = 0;
222
231 virtual Integer dimension() const = 0;
232
241 virtual Integer multiTag() const = 0;
242
252 virtual Integer nbElement() const = 0;
253
255 virtual int property() const = 0;
256
260
266 virtual void addVariableRef(VariableRef* var_ref) = 0;
267
274 virtual void removeVariableRef(VariableRef* var_ref) = 0;
275
277 virtual VariableRef* firstReference() const = 0;
278
280 virtual Integer nbReference() const = 0;
281
282 public:
283
284 ARCANE_DEPRECATED_REASON("Y2021: This method is a noop")
285 virtual void setTraceInfo(Integer id, eTraceType tt) = 0;
286
287 public:
288
303 virtual void resize(Integer new_size) = 0;
304
316 virtual void resizeFromGroup() = 0;
317
323 virtual void shrinkMemory() = 0;
324
326 virtual void setAllocationInfo(const DataAllocationInfo& v) = 0;
327
330
331 public:
332
349 virtual bool initialize(const ItemGroup& group, const String& value) = 0;
350
352
353
368 virtual Int32 checkIfSync(Integer max_print = 0) = 0;
369
385 virtual Int32 checkIfSame(IDataReader* reader, Integer max_print, bool compare_ghost) = 0;
386
410 virtual Int32 checkIfSameOnAllReplica(Integer max_print = 0) = 0;
412
418 virtual void synchronize() = 0;
419
420 // TODO: à rendre virtuelle pure (décembre 2024)
429 virtual void synchronize(Int32ConstArrayView local_ids);
430
437 ARCCORE_DEPRECATED_2020("Use meshHandle() instead")
438 virtual IMesh* mesh() const = 0;
439
446 virtual MeshHandle meshHandle() const = 0;
447
460 virtual ItemGroup itemGroup() const = 0;
461
463 virtual String itemGroupName() const = 0;
464
477 virtual IItemFamily* itemFamily() const = 0;
478
480 virtual String itemFamilyName() const = 0;
481
483 virtual String meshName() const = 0;
484
490 ARCANE_DEPRECATED_REASON("Y2024: Use createMetaDataRef() instead")
491 virtual VariableMetaData* createMetaData() const = 0;
492
495
504 virtual void syncReferences() = 0;
505
506 public:
507
518 virtual void setUsed(bool v) = 0;
519
521 virtual bool isUsed() const = 0;
522
529 virtual bool isPartial() const = 0;
530
531 public:
532
544 virtual void copyItemsValues(Int32ConstArrayView source, Int32ConstArrayView destination) = 0;
545
555 virtual void copyItemsMeanValues(Int32ConstArrayView first_source,
556 Int32ConstArrayView second_source,
557 Int32ConstArrayView destination) = 0;
558
566 virtual void compact(Int32ConstArrayView new_to_old_ids) = 0;
567
569 virtual void changeGroupIds(Int32ConstArrayView old_to_new_ids) = 0;
570
571 public:
572
574 virtual IData* data() = 0;
575
577 virtual const IData* data() const = 0;
578
580 virtual IDataFactoryMng* dataFactoryMng() const = 0;
581
583
584
588 virtual void serialize(ISerializer* sbuffer, IDataOperation* operation = 0) = 0;
589
600 virtual void serialize(ISerializer* sbuffer, Int32ConstArrayView ids, IDataOperation* operation = 0) = 0;
601
612 virtual ARCANE_DEPRECATED_2018 void write(IDataWriter* writer) = 0;
613
624 virtual ARCANE_DEPRECATED_2018 void read(IDataReader* reader) = 0;
625
634 virtual void notifyEndRead() = 0;
635
642 virtual void notifyBeginWrite() = 0;
643
651
658
667
669
670 virtual void addTag(const String& tagname, const String& tagvalue) = 0;
675 virtual void removeTag(const String& tagname) = 0;
677 virtual bool hasTag(const String& tagname) = 0;
679 virtual String tagValue(const String& tagname) = 0;
681
682 public:
683
685 virtual void print(std::ostream& o) const = 0;
686
687 public:
688
690
691
701 virtual void update() = 0;
702
703 virtual void update(Real wanted_time) = 0;
704
710 virtual void setUpToDate() = 0;
711
713 virtual Int64 modifiedTime() = 0;
714
716 virtual void addDepend(IVariable* var, eDependType dt) = 0;
717
719 virtual void addDepend(IVariable* var, eDependType dt, const TraceInfo& tinfo) = 0;
720
723 virtual void removeDepend(IVariable* var) = 0;
724
733
736
742 virtual void dependInfos(Array<VariableDependInfo>& infos) = 0;
744
745 public:
746
747 ARCANE_DEPRECATED_REASON("Y2021: This method is a noop")
748 virtual IMemoryAccessTrace* memoryAccessTrace() const = 0;
749
755 virtual void setIsSynchronized() = 0;
756
762 virtual void setIsSynchronized(const ItemGroup& item_group) = 0;
763
764 public:
765
768
769 public:
770
773};
774
775/*---------------------------------------------------------------------------*/
776/*---------------------------------------------------------------------------*/
777
778} // End namespace Arcane
779
780/*---------------------------------------------------------------------------*/
781/*---------------------------------------------------------------------------*/
782
783#endif
Declarations of types on entities.
Base class for 1D data vectors.
Information on data allocation.
Interface of the data factory manager.
Interface of an operation on a data.
Interface for reading variable data.
Definition IDataReader.h:35
Interface for writing variable data.
Definition IDataWriter.h:45
Interface of a data item.
Definition IData.h:34
Interface of an entity family.
Definition IItemFamily.h:83
Interface of the subdomain manager.
Definition ISubDomain.h:75
Interface of the functor class for recalculating a variable.
Internal part of Ivariable.
Variable manager interface.
Interface of a variable.
Definition IVariable.h:40
virtual Real allocatedMemory() const =0
Memory size (in Bytes) used by the variable.
virtual void changeGroupIds(Int32ConstArrayView old_to_new_ids)=0
pH: EXPERIMENTAL
virtual eDataType dataType() const =0
Data type managed by the variable (Real, Integer, ...).
virtual void addTag(const String &tagname, const String &tagvalue)=0
Adds the tag tagname with the value tagvalue.
eDependType
Dependency Type.
Definition IVariable.h:45
virtual String meshName() const =0
Name of the associated mesh (null if none).
virtual void print(std::ostream &o) const =0
Prints the variable's values to the stream o.
virtual void setIsSynchronized()=0
Indicates that the variable is synchronized.
virtual bool hasTag(const String &tagname)=0
true if the variable has the tag tagname
virtual void setUsed(bool v)=0
Sets the usage state of the variable.
virtual String itemFamilyName() const =0
Name of the associated family (null if none).
virtual VariableMetaData * createMetaData() const =0
Creates an instance containing the variable's metadata.
virtual void notifyEndRead()=0
Notifies of external modification of data().
virtual void setUpToDate()=0
Indicates that the variable has just been updated.
virtual String fullName() const =0
Full variable name (with family prefix).
@ PSubDomainDepend
Indicates that the variable value is dependent on the subdomain.
Definition IVariable.h:81
@ PNoExchange
Indicates that the variable should not be exchanged.
Definition IVariable.h:130
@ PNoReplicaSync
Indicates that the variable does not necessarily have the same value across replicas.
Definition IVariable.h:147
@ PTemporary
Indicates that the variable is temporary.
Definition IVariable.h:114
@ PInShMem
Indicates that the variable must be allocated in shared memory.
Definition IVariable.h:156
@ PExecutionDepend
Indicates that the variable value is dependent on the execution.
Definition IVariable.h:96
@ PHasTrace
Indicates that the variable is traced (only in trace mode).
Definition IVariable.h:73
@ PPrivate
Indicates that the variable is private.
Definition IVariable.h:103
@ PPersistant
Indicates that the variable is persistent.
Definition IVariable.h:138
@ PNoRestore
Indicates that the variable should not be restored.
Definition IVariable.h:120
@ PSubDomainPrivate
Indicates that the variable is private to the subdomain.
Definition IVariable.h:89
@ PNoNeedSync
Indicates that the variable is not necessarily synchronized.
Definition IVariable.h:70
@ PNoDump
Indicates that the variable should not be saved.
Definition IVariable.h:62
@ PDumpNull
Indicates that the save will be null for this variable and for this subdomain.
Definition IVariable.h:167
virtual ARCANE_DEPRECATED_2018 void read(IDataReader *reader)=0
virtual bool initialize(const ItemGroup &group, const String &value)=0
Initializes the variable on a group.
virtual int property() const =0
Returns the properties of the variable.
virtual Ref< VariableMetaData > createMetaDataRef() const =0
Creates an instance containing the variable's metadata.
virtual eItemKind itemKind() const =0
Kind of mesh entities on which the variable is based.
virtual Int64 modifiedTime()=0
Time when the variable was updated.
virtual Integer nbReference() const =0
Number of references on this variable.
virtual String tagValue(const String &tagname)=0
Value of the tag tagname. The string is null if the tag does not exist.
virtual void synchronize()=0
Synchronizes the variable.
virtual IDataFactoryMng * dataFactoryMng() const =0
Data factory associated with the variable.
virtual ~IVariable()=default
Frees resources.
virtual bool isPartial() const =0
Indicates if the variable is partial.
virtual Integer dimension() const =0
Dimension of the variable.
virtual void resizeFromGroup()=0
Sets the number of elements for a mesh variable.
virtual void notifyReferencePropertyChanged()=0
virtual void removeDepend(IVariable *var)=0
Removes var from the list of dependencies.
virtual IData * data()=0
Data associated with the variable.
virtual void syncReferences()=0
Synchronizes references.
virtual Int32 checkIfSync(Integer max_print=0)=0
Checks if the variable is properly synchronized.
virtual VariableRef * firstReference() const =0
First reference (or null) on this variable.
virtual bool isUsed() const =0
Usage state of the variable.
virtual void dependInfos(Array< VariableDependInfo > &infos)=0
Dependency information.
virtual ItemGroup itemGroup() const =0
Associated mesh group.
static Int64 incrementModifiedTime()
Increments the modification counter and returns its value before modification.
Definition Variable.cc:206
virtual Integer multiTag() const =0
Indicates if the variable is a multi-sized array.
virtual ARCANE_DEPRECATED_2018 void write(IDataWriter *writer)=0
Saves the variable.
virtual IVariableComputeFunction * computeFunction()=0
Function used to update the variable.
virtual Int32 checkIfSame(IDataReader *reader, Integer max_print, bool compare_ghost)=0
Checks that the variable is identical to a reference value.
virtual IMesh * mesh() const =0
Mesh associated with the variable.
virtual DataAllocationInfo allocationInfo() const =0
Allocation information.
virtual ISubDomain * subDomain()=0
Subdomain associated with the variable (TODO deprecate end of 2023).
virtual IObservable * readObservable()=0
Read observable.
virtual IObservable * onSizeChangedObservable()=0
Size change observable.
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.
Definition IVariable.h:173
virtual void compact(Int32ConstArrayView new_to_old_ids)=0
Compresses the variable's values.
virtual void addDepend(IVariable *var, eDependType dt)=0
Adds var to the list of dependencies.
virtual void notifyBeginWrite()=0
Notifies of the start of writing data().
virtual Int32 checkIfSameOnAllReplica(Integer max_print=0)=0
Checks if the variable has the same values on all replicas.
virtual void setComputeFunction(IVariableComputeFunction *v)=0
Sets the variable's recalculation function.
virtual IObservable * writeObservable()=0
Write observable.
virtual void copyItemsMeanValues(Int32ConstArrayView first_source, Int32ConstArrayView second_source, Int32ConstArrayView destination)=0
Copies the mean values of entities numbered first_source and second_source into entities numbered des...
virtual void removeTag(const String &tagname)=0
Removes the tag tagname.
virtual void serialize(ISerializer *sbuffer, IDataOperation *operation=0)=0
virtual void setAllocationInfo(const DataAllocationInfo &v)=0
Sets allocation information.
virtual Integer nbElement() const =0
Number of elements of the variable.
virtual IItemFamily * itemFamily() const =0
Associated entity family.
virtual String itemGroupName() const =0
Name of the associated entity group.
virtual MeshHandle meshHandle() const =0
Mesh associated with the variable.
static const char * TAG_POST_PROCESSING_AT_THIS_ITERATION
Tag used to indicate if a variable will be post-processed at this iteration.
Definition IVariable.h:176
virtual void addVariableRef(VariableRef *var_ref)=0
Adds a reference to this variable.
virtual String name() const =0
Variable name.
virtual void removeVariableRef(VariableRef *var_ref)=0
Removes a reference to this variable.
virtual void copyItemsValues(Int32ConstArrayView source, Int32ConstArrayView destination)=0
Copies the values of entities numbered source into entities numbered destination.
virtual IVariableInternal * _internalApi()=0
Internal Arcane API.
virtual void shrinkMemory()=0
Frees any additional memory allocated for the data.
virtual IVariableMng * variableMng() const =0
Variable manager associated with the variable.
virtual void resize(Integer new_size)=0
Sets the number of elements for an array variable.
Mesh entity group.
Definition ItemGroup.h:51
Handle on a mesh.
Definition MeshHandle.h:48
Reference to an instance.
Information about a variable dependency.
Metadata on a variable.
Reference to a variable.
Definition VariableRef.h:56
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
eTraceType
Possible trace type.
Definition DataTypes.h:194
eItemKind
Mesh entity type.
double Real
Type representing a real number.
eDataType
Data type.
Definition DataTypes.h:41
std::int32_t Int32
Signed integer type of 32 bits.