Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::Variable Class Referenceabstract

Instance of a variable. More...

#include <arcane/core/Variable.h>

Inheritance diagram for Arcane::Variable:
Collaboration diagram for Arcane::Variable:

Public Member Functions

 ~Variable () override
 Frees resources.
 Variable (const Variable &from)=delete
 Copy constructor (do not use).
Variableoperator= (const Variable &from)=delete
 Copy assignment operator (do not use).
ISubDomainsubDomain () override
 Subdomain associated with the variable (TODO deprecate end of 2023).
IVariableMngvariableMng () const override
 Variable manager associated with the variable.
String fullName () const final
 Full variable name (with family prefix).
String name () const final
 Variable name.
String itemFamilyName () const final
 Name of the associated family (null if none).
String meshName () const final
 Name of the associated mesh (null if none).
String itemGroupName () const final
 Name of the associated entity group.
int property () const override
void notifyReferencePropertyChanged () override
void setUsed (bool v) override
 Sets the usage state of the variable.
bool isUsed () const override
 Usage state of the variable.
bool isPartial () const override
 Indicates if the variable is partial.
void setTraceInfo (Integer, eTraceType) override
void read (IDataReader *d) override
void write (IDataWriter *d) override
 Saves the variable.
void notifyEndRead () override
 Notifies of external modification of data().
void notifyBeginWrite () override
 Notifies of the start of writing data().
void addVariableRef (VariableRef *ref) override
 Adds a reference to this variable.
void removeVariableRef (VariableRef *ref) override
 Removes a reference to this variable.
VariableReffirstReference () const override
 First reference (or null) on this variable.
Integer nbReference () const override
 Number of references on this variable.
VariableMetaDatacreateMetaData () const override
 Creates an instance containing the variable's metadata.
Ref< VariableMetaDatacreateMetaDataRef () const override
 Creates an instance containing the variable's metadata.
void syncReferences () override
 Synchronizes references.
IMeshmesh () const final
 Mesh associated with the variable.
MeshHandle meshHandle () const final
 Mesh associated with the variable.
ItemGroup itemGroup () const final
 Associated mesh group.
IItemFamilyitemFamily () const final
 Associated entity family.
eItemKind itemKind () const override
 Kind of mesh entities on which the variable is based.
Integer dimension () const override
 Dimension of the variable.
Integer multiTag () const override
 Indicates if the variable is a multi-sized array.
Int32 checkIfSync (Integer max_print) final
 Checks if the variable is properly synchronized.
Int32 checkIfSameOnAllReplica (Integer max_print) final
 Checks if the variable has the same values on all replicas.
Int32 checkIfSame (IDataReader *reader, Integer max_print, bool compare_ghost) final
 Checks that the variable is identical to a reference value.
eDataType dataType () const override
 Data type managed by the variable (Real, Integer, ...).
bool initialize (const ItemGroup &, const String &) override
 Initializes the variable on a group.
IDataFactoryMngdataFactoryMng () const final
 Data factory associated with the variable.
void serialize (ISerializer *sbuffer, IDataOperation *operation) override
void serialize (ISerializer *sbuffer, Int32ConstArrayView ids, IDataOperation *operation) override
 Serializes the variable for identifiers ids.
void resize (Integer n) override
 Sets the number of elements for an array variable.
void resizeFromGroup () override
 Sets the number of elements for a mesh variable.
void setAllocationInfo (const DataAllocationInfo &v) override
 Sets allocation information.
DataAllocationInfo allocationInfo () const override
 Allocation information.
IObservablewriteObservable () override
 Write observable.
IObservablereadObservable () override
 Read observable.
IObservableonSizeChangedObservable () override
 Size change observable.
void addTag (const String &tagname, const String &tagvalue) override
 Adds the tag tagname with the value tagvalue.
void removeTag (const String &tagname) override
 Removes the tag tagname.
bool hasTag (const String &tagname) override
 true if the variable has the tag tagname
String tagValue (const String &tagname) override
 Value of the tag tagname. The string is null if the tag does not exist.
void update () override
 Recalculates the variable if necessary.
void setUpToDate () override
 Indicates that the variable has just been updated.
Int64 modifiedTime () override
 Time when the variable was updated.
void addDepend (IVariable *var, eDependType dt) override
 Adds var to the list of dependencies.
void addDepend (IVariable *var, eDependType dt, const TraceInfo &tinfo) override
 Adds var to the list of dependencies with trace info tinfo.
void removeDepend (IVariable *var) override
 Removes var from the list of dependencies.
void setComputeFunction (IVariableComputeFunction *v) override
 Sets the variable's recalculation function.
IVariableComputeFunctioncomputeFunction () override
 Function used to update the variable.
void dependInfos (Array< VariableDependInfo > &infos) override
 Dependency information.
void update (Real wanted_time) override
void changeGroupIds (Int32ConstArrayView old_to_new_ids) override
 pH: EXPERIMENTAL
IVariableInternal_internalApi () override
 Internal Arcane API.
IMemoryAccessTracememoryAccessTrace () const override
Public Member Functions inherited from Arcane::TraceAccessor
 TraceAccessor (ITraceMng *m)
 Constructs an accessor via the trace manager m.
 TraceAccessor (const TraceAccessor &rhs)
 Copy constructor.
TraceAccessoroperator= (const TraceAccessor &rhs)
 Copy assignment operator.
virtual ~TraceAccessor ()
 Frees resources.
ITraceMngtraceMng () const
 Trace manager.
TraceMessage info () const
 Flow for an information message.
TraceMessage pinfo () const
 Flow for a parallel information message.
TraceMessage info (char category) const
 Flow for an information message of a given category.
TraceMessage pinfo (char category) const
 Flow for a parallel information message of a given category.
TraceMessage info (bool v) const
 Flow for an information message.
TraceMessage warning () const
 Flow for a warning message.
TraceMessage pwarning () const
TraceMessage error () const
 Flow for an error message.
TraceMessage perror () const
TraceMessage log () const
 Flow for a log message.
TraceMessage plog () const
 Flow for a log message.
TraceMessage logdate () const
 Flow for a log message preceded by the date.
TraceMessage fatal () const
 Flow for a fatal error message.
TraceMessage pfatal () const
 Flow for a parallel fatal error message.
TraceMessageDbg debug (Trace::eDebugLevel=Trace::Medium) const
 Flow for a debug message.
Trace::eDebugLevel configDbgLevel () const
 Debug level of the configuration file.
TraceMessage info (Int32 verbose_level) const
 Flow for an information message of a given level.
TraceMessage linfo () const
 Flow for an information message with the local information level of this instance.
TraceMessage linfo (Int32 relative_level) const
 Flow for an information message with the local information level of this instance.
void fatalMessage (const StandaloneTraceMessage &o) const
Public Member Functions inherited from Arcane::IVariable
virtual ~IVariable ()=default
 Frees resources.
virtual Real allocatedMemory () const =0
 Memory size (in Bytes) used by the variable.
virtual Integer nbElement () const =0
 Number of elements of the variable.
virtual void shrinkMemory ()=0
 Frees any additional memory allocated for the data.
virtual void synchronize ()=0
 Synchronizes the variable.
virtual void synchronize (Int32ConstArrayView local_ids)
 Synchronizes the variable on a list of entities.
virtual void copyItemsValues (Int32ConstArrayView source, Int32ConstArrayView destination)=0
 Copies the values of entities numbered source into entities numbered destination.
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 destination.
virtual void compact (Int32ConstArrayView new_to_old_ids)=0
 Compresses the variable's values.
virtual IDatadata ()=0
 Data associated with the variable.
virtual const IDatadata () const =0
 Data associated with the variable.
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 void setIsSynchronized (const ItemGroup &item_group)=0
 Indicates that the variable is synchronized on the group item_group.

Protected Member Functions

 Variable (const VariableBuildInfo &v, const VariableInfo &vi)
 Creates a variable linked to the reference v.
void _setProperty (int property)
void _setData (const Ref< IData > &data)
 Positions the data.
void _setValidData (bool valid_data)
 Indicates if the variable data is valid.
bool _hasValidData () const
 Indicates if the variable data is valid.
virtual void _internalResize (const VariableResizeArgs &resize_args)=0
void _checkSwapIsValid (Variable *rhs)
 Checks if it is possible to swap the values of the instance with those of rhs.
bool _wantShrink () const
void _resize (const VariableResizeArgs &resize_args)
virtual VariableComparerResults _compareVariable (const VariableComparerArgs &compare_args)=0
 Comparison of values between variables.
Protected Member Functions inherited from Arcane::TraceAccessor
void _setLocalVerboseLevel (Int32 v)
Int32 _localVerboseLevel () const

Private Member Functions

void _checkSetItemFamily ()
void _checkSetItemGroup ()
void _checkSetProperty (VariableRef *)
bool _hasReference () const
void _removeMeshReference ()
VariableMetaData_createMetaData () const

Private Attributes

VariablePrivate * m_p
 Implementation.

Friends

class VariablePrivate

Additional Inherited Members

Public Types inherited from Arcane::IVariable
enum  eDependType { DPT_PreviousTime , DPT_CurrentTime }
 Dependency Type. More...
enum  {
  PNoDump = (1 << 0) , PNoNeedSync = (1 << 1) , PHasTrace = (1 << 2) , PSubDomainDepend = (1 << 3) ,
  PSubDomainPrivate = (1 << 4) , PExecutionDepend = (1 << 5) , PPrivate = (1 << 6) , PTemporary = (1 << 7) ,
  PNoRestore = (1 << 8) , PNoExchange = (1 << 9) , PPersistant = (1 << 10) , PNoReplicaSync = (1 << 11) ,
  PInShMem = (1 << 12) , PDumpNull = (1 << 13)
}
 Properties of a variable. More...
static Int64 incrementModifiedTime ()
 Increments the modification counter and returns its value before modification.
Static Public Attributes inherited from Arcane::IVariable
static const char * TAG_POST_PROCESSING = "PostProcessing"
 Tag used to indicate if a variable will be post-processed.
static const char * TAG_POST_PROCESSING_AT_THIS_ITERATION = "PostProcessingAtThisIteration"
 Tag used to indicate if a variable will be post-processed at this iteration.

Detailed Description

Instance of a variable.

This class manages the data of a variable. This instance should generally not be used by code developers.

Todo
explain better

A variable is characterized by:

  • its name,
  • its type: real, integer, tensor, ...,
  • its kind: scalar, array, nodal quantity, cell-center quantity ...

A variable based on a type of mesh entity is called a mesh variable.

The variable is generally used by a module (IModule) via a reference (VariableRef).

Variables are persistent and their reading/writing is done by the read() and write() methods.

Warning
This class is entirely managed by Arcane, and modules that use it should generally only use it to retrieve information. Operations that modify this instance (such as setItemGroup()) should only be used if the developer has a good understanding of their functioning.

This class must not be copied.

Definition at line 74 of file Variable.h.

Constructor & Destructor Documentation

◆ Variable()

Arcane::Variable::Variable ( const VariableBuildInfo & v,
const VariableInfo & vi )
protected

Creates a variable linked to the reference v.

Definition at line 343 of file Variable.cc.

References m_p, Arcane::TraceAccessor::TraceAccessor(), and Arcane::TraceAccessor::traceMng().

Referenced by _checkSwapIsValid(), Arcane::Array2VariableT< T >::Array2VariableT(), operator=(), Variable(), Arcane::VariableArrayT< T >::VariableArrayT(), and Arcane::VariableScalarT< T >::VariableScalarT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Variable()

Arcane::Variable::~Variable ( )
override

Frees resources.

Definition at line 353 of file Variable.cc.

References m_p.

Member Function Documentation

◆ _checkSetItemFamily()

void Arcane::Variable::_checkSetItemFamily ( )
private

Definition at line 1050 of file Variable.cc.

◆ _checkSetItemGroup()

void Arcane::Variable::_checkSetItemGroup ( )
private

Definition at line 1100 of file Variable.cc.

◆ _checkSetProperty()

void Arcane::Variable::_checkSetProperty ( VariableRef * ref)
private

Definition at line 440 of file Variable.cc.

◆ _checkSwapIsValid()

void Arcane::Variable::_checkSwapIsValid ( Variable * rhs)
protected

Checks if it is possible to swap the values of the instance with those of rhs.

Since this method is called by a derived class, we are sure that rhs is the same C++ type as the instance and therefore there is no need to check, for example, that the dimensions or the data type are the same. For the swap to be valid, the mesh, the family and the group must be the same. To do this, it is sufficient to check that the group is the same.

Definition at line 1394 of file Variable.cc.

References ARCANE_FATAL, isPartial(), itemGroup(), Arcane::VariablePrivate::m_is_used, m_p, and Variable().

Here is the call graph for this function:

◆ _compareVariable()

◆ _createMetaData()

VariableMetaData * Arcane::Variable::_createMetaData ( ) const
private

Definition at line 753 of file Variable.cc.

◆ _hasReference()

bool Arcane::Variable::_hasReference ( ) const
private

Definition at line 364 of file Variable.cc.

◆ _hasValidData()

bool Arcane::Variable::_hasValidData ( ) const
protected

Indicates if the variable data is valid.

The data is valid at the end of a call to setUsed().

Definition at line 941 of file Variable.cc.

References m_p.

◆ _internalApi()

IVariableInternal * Arcane::Variable::_internalApi ( )
overridevirtual

Internal Arcane API.

Implements Arcane::IVariable.

Definition at line 1440 of file Variable.cc.

References m_p.

◆ _removeMeshReference()

void Arcane::Variable::_removeMeshReference ( )
private

Definition at line 704 of file Variable.cc.

◆ _resize()

void Arcane::Variable::_resize ( const VariableResizeArgs & resize_args)
protected

Definition at line 997 of file Variable.cc.

◆ _setData()

void Arcane::Variable::_setData ( const Ref< IData > & data)
protected

Positions the data.

If data is null, a fatal error is sent

Definition at line 917 of file Variable.cc.

References ARCANE_FATAL, Arcane::IVariable::data(), and m_p.

Referenced by Arcane::Array2VariableT< T >::Array2VariableT(), Arcane::VariableArrayT< T >::VariableArrayT(), and Arcane::VariableScalarT< T >::VariableScalarT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _setProperty()

void Arcane::Variable::_setProperty ( int property)
protected

Definition at line 950 of file Variable.cc.

◆ _setValidData()

void Arcane::Variable::_setValidData ( bool valid_data)
protected

Indicates if the variable data is valid.

Definition at line 932 of file Variable.cc.

References m_p.

Referenced by notifyEndRead().

Here is the caller graph for this function:

◆ _wantShrink()

bool Arcane::Variable::_wantShrink ( ) const
protected

Definition at line 1410 of file Variable.cc.

◆ addDepend() [1/2]

void Arcane::Variable::addDepend ( IVariable * var,
eDependType dt )
overridevirtual

Adds var to the list of dependencies.

Implements Arcane::IVariable.

Definition at line 1233 of file Variable.cc.

References m_p.

◆ addDepend() [2/2]

void Arcane::Variable::addDepend ( IVariable * var,
eDependType dt,
const TraceInfo & tinfo )
overridevirtual

Adds var to the list of dependencies with trace info tinfo.

Implements Arcane::IVariable.

Definition at line 1242 of file Variable.cc.

References m_p.

◆ addTag()

void Arcane::Variable::addTag ( const String & tagname,
const String & tagvalue )
overridevirtual

Adds the tag tagname with the value tagvalue.

Implements Arcane::IVariable.

Definition at line 1294 of file Variable.cc.

References m_p.

◆ addVariableRef()

void Arcane::Variable::addVariableRef ( VariableRef * var_ref)
overridevirtual

Adds a reference to this variable.

Precondition
var_ref must not already reference a variable.

Implements Arcane::IVariable.

Definition at line 373 of file Variable.cc.

References m_p, Arcane::VariableRef::previousReference(), Arcane::VariableRef::setNextReference(), and Arcane::VariableRef::setPreviousReference().

Here is the call graph for this function:

◆ allocationInfo()

DataAllocationInfo Arcane::Variable::allocationInfo ( ) const
overridevirtual

Allocation information.

Implements Arcane::IVariable.

Definition at line 1431 of file Variable.cc.

References Arcane::IData::allocationInfo(), and Arcane::IVariable::data().

Here is the call graph for this function:

◆ changeGroupIds()

void Arcane::Variable::changeGroupIds ( Int32ConstArrayView old_to_new_ids)
overridevirtual

pH: EXPERIMENTAL

Implements Arcane::IVariable.

Definition at line 1374 of file Variable.cc.

◆ checkIfSame()

Int32 Arcane::Variable::checkIfSame ( IDataReader * reader,
Integer max_print,
bool compare_ghost )
finalvirtual

Checks that the variable is identical to a reference value.

This operation checks that the variable values are identical to a reference value read from the reader reader.

For each value different from the reference, a message is displayed.

Parameters
max_printmaximum number of messages to display. If 0, no element is displayed. If positive, display at most max_print elements. If negative, all elements are displayed.
compare_ghostif true, compares values both on owned entities and ghost entities. Otherwise, it only compares on owned entities.
Returns
the number of different reference values.

Implements Arcane::IVariable.

Definition at line 829 of file Variable.cc.

References _compareVariable(), Arcane::VariableComparerArgs::setCompareGhost(), and Arcane::VariableComparerArgs::setMaxPrint().

Here is the call graph for this function:

◆ checkIfSameOnAllReplica()

Int32 Arcane::Variable::checkIfSameOnAllReplica ( Integer max_print)
finalvirtual

Checks if the variable has the same values on all replicas.

Compare the variable's values with those of the same subdomain of other replicas. For each different element, a message is displayed.

This method is collective across the same subdomain as other replicas. Therefore, it should only be called if the variable exists on all subdomains otherwise it causes a blocking.

This method only works for variables of numeric types. In this case, it throws a NotSupportedException.

Parameters
max_printmaximum number of messages to display. If 0, no elements are displayed. If positive, displays at most max_print elements. If negative, all elements are displayed. For each different element, the minimum and maximum value is displayed.
Returns
the number of different values of the reference.

Implements Arcane::IVariable.

Definition at line 816 of file Variable.cc.

References _compareVariable(), Arcane::SameOnAllReplica, and Arcane::VariableComparerArgs::setMaxPrint().

Here is the call graph for this function:

◆ checkIfSync()

Int32 Arcane::Variable::checkIfSync ( Integer max_print)
finalvirtual

Checks if the variable is properly synchronized.

This operation only works for mesh variables.

A variable is synchronized when its values are the same across all subdomains, both on owned elements and ghost elements.

For each unsynchronized element, a message is displayed.

Parameters
max_printmaximum number of messages to display. If 0, no element is displayed. If positive, display at most max_print elements. If negative, all elements are displayed.
Returns
the number of different reference values.

Implements Arcane::IVariable.

Definition at line 802 of file Variable.cc.

References _compareVariable(), Arcane::VariableComparerArgs::setCompareGhost(), Arcane::VariableComparerArgs::setMaxPrint(), and Arcane::Sync.

Here is the call graph for this function:

◆ computeFunction()

IVariableComputeFunction * Arcane::Variable::computeFunction ( )
overridevirtual

Function used to update the variable.

Implements Arcane::IVariable.

Definition at line 1270 of file Variable.cc.

References m_p.

◆ createMetaData()

VariableMetaData * Arcane::Variable::createMetaData ( ) const
overridevirtual

Creates an instance containing the variable's metadata.

The returned instance must be destroyed by calling the delete operator.

Implements Arcane::IVariable.

Definition at line 767 of file Variable.cc.

◆ createMetaDataRef()

Ref< VariableMetaData > Arcane::Variable::createMetaDataRef ( ) const
overridevirtual

Creates an instance containing the variable's metadata.

Implements Arcane::IVariable.

Definition at line 776 of file Variable.cc.

References Arcane::makeRef().

Here is the call graph for this function:

◆ dataFactoryMng()

IDataFactoryMng * Arcane::Variable::dataFactoryMng ( ) const
finalvirtual

Data factory associated with the variable.

Implements Arcane::IVariable.

Definition at line 959 of file Variable.cc.

References m_p.

◆ dataType()

eDataType Arcane::Variable::dataType ( ) const
overridevirtual

Data type managed by the variable (Real, Integer, ...).

Implements Arcane::IVariable.

Definition at line 528 of file Variable.cc.

References m_p.

Referenced by Arcane::VariableArrayT< T >::initialize().

Here is the caller graph for this function:

◆ dependInfos()

void Arcane::Variable::dependInfos ( Array< VariableDependInfo > & infos)
overridevirtual

Dependency information.

Fills the array infos with dependency information.

Implements Arcane::IVariable.

Definition at line 1279 of file Variable.cc.

References Arcane::Array< T >::add(), and m_p.

Here is the call graph for this function:

◆ dimension()

Integer Arcane::Variable::dimension ( ) const
overridevirtual

Dimension of the variable.

The possible values are as follows:

  • 0 for a scalar variable.
  • 1 for a mono-dimensional array variable or a mesh scalar variable.
  • 2 for a bi-dimensional array variable or a mesh array variable.

Implements Arcane::IVariable.

Definition at line 881 of file Variable.cc.

References m_p.

◆ firstReference()

VariableRef * Arcane::Variable::firstReference ( ) const
overridevirtual

First reference (or null) on this variable.

Implements Arcane::IVariable.

Definition at line 431 of file Variable.cc.

References m_p.

◆ fullName()

String Arcane::Variable::fullName ( ) const
finalvirtual

Full variable name (with family prefix).

Implements Arcane::IVariable.

Definition at line 492 of file Variable.cc.

References m_p.

Referenced by operator=(), resizeFromGroup(), serialize(), serialize(), Arcane::Array2VariableT< T >::synchronize(), Arcane::Array2VariableT< T >::synchronize(), Arcane::VariableArrayT< T >::synchronize(), and Arcane::VariableArrayT< T >::synchronize().

Here is the caller graph for this function:

◆ hasTag()

bool Arcane::Variable::hasTag ( const String & tagname)
overridevirtual

true if the variable has the tag tagname

Implements Arcane::IVariable.

Definition at line 1312 of file Variable.cc.

References m_p.

◆ initialize()

bool Arcane::Variable::initialize ( const ItemGroup & group,
const String & value )
inlineoverridevirtual

Initializes the variable on a group.

Initializes the variable with the value value for all elements of the group group.

This operation is only usable with mesh variables.

Parameters
group_namegroup. It must correspond to an existing group of the variable's type (e.g., CellGroup for a cell variable).
valueinitialization value. The string must be convertible to the variable's type.
Return values
truein case of error or if the variable is not a mesh variable.
falseif the initialization is successful.

Implements Arcane::IVariable.

Reimplemented in Arcane::VariableArrayT< T >, Arcane::VariableArrayT< DataType >, Arcane::VariableArrayT< Int32 >, Arcane::VariableArrayT< Int64 >, Arcane::VariableArrayT< Real >, Arcane::VariableArrayT< Real2 >, Arcane::VariableArrayT< Real2x2 >, Arcane::VariableArrayT< Real3 >, and Arcane::VariableArrayT< Real3x3 >.

Definition at line 152 of file Variable.h.

References initialize().

Referenced by initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isPartial()

bool Arcane::Variable::isPartial ( ) const
overridevirtual

Indicates if the variable is partial.

A variable is partial when it is not defined on all entities of a family. In this case, group()!=itemFamily()->allItems().

Implements Arcane::IVariable.

Definition at line 899 of file Variable.cc.

References m_p.

Referenced by _checkSwapIsValid(), Arcane::Array2VariableT< T >::compact(), Arcane::VariableArrayT< T >::compact(), operator=(), Arcane::Array2VariableT< T >::synchronize(), Arcane::Array2VariableT< T >::synchronize(), Arcane::VariableArrayT< T >::synchronize(), and Arcane::VariableArrayT< T >::synchronize().

Here is the caller graph for this function:

◆ isUsed()

bool Arcane::Variable::isUsed ( ) const
overridevirtual

Usage state of the variable.

Implements Arcane::IVariable.

Definition at line 721 of file Variable.cc.

References m_p.

Referenced by operator=().

Here is the caller graph for this function:

◆ itemFamily()

IItemFamily * Arcane::Variable::itemFamily ( ) const
finalvirtual

Associated entity family.

Returns
the family associated with the variable or 0 if the variable has no family.

If a variable is not used or not yet allocated, the returned value is null. However, the variable can still be associated with a family. In this case, you must use the itemFamilyName() function to retrieve the name of this family.

Implements Arcane::IVariable.

Definition at line 908 of file Variable.cc.

References m_p.

Referenced by Arcane::VariableArrayT< T >::initialize().

Here is the caller graph for this function:

◆ itemFamilyName()

String Arcane::Variable::itemFamilyName ( ) const
finalvirtual

Name of the associated family (null if none).

Implements Arcane::IVariable.

Definition at line 501 of file Variable.cc.

References m_p.

Referenced by operator=().

Here is the caller graph for this function:

◆ itemGroup()

ItemGroup Arcane::Variable::itemGroup ( ) const
finalvirtual

Associated mesh group.

Returns
the associated mesh group if for a mesh variable or the null group if the variable is not a mesh variable.

If a variable is not used or not yet allocated, the returned value is the null group. However, the variable can still be associated with a group. In this case, you must use the itemGroupName() function to retrieve the name of this group.

Implements Arcane::IVariable.

Definition at line 863 of file Variable.cc.

References m_p.

Referenced by _checkSwapIsValid(), Arcane::Array2VariableT< T >::_compareVariable(), Arcane::VariableArrayT< T >::_compareVariable(), Arcane::VariableArrayT< T >::setIsSynchronized(), Arcane::Array2VariableT< T >::synchronize(), Arcane::Array2VariableT< T >::synchronize(), Arcane::VariableArrayT< T >::synchronize(), and Arcane::VariableArrayT< T >::synchronize().

Here is the caller graph for this function:

◆ itemGroupName()

String Arcane::Variable::itemGroupName ( ) const
finalvirtual

Name of the associated entity group.

Implements Arcane::IVariable.

Definition at line 510 of file Variable.cc.

References m_p.

Referenced by operator=().

Here is the caller graph for this function:

◆ itemKind()

eItemKind Arcane::Variable::itemKind ( ) const
overridevirtual

Kind of mesh entities on which the variable is based.

For scalar or array variables, there is no kind, and the method returns IK_Unknown. For other variables, it returns the kind of the mesh element (Node, Cell, ...), namely:

Implements Arcane::IVariable.

Definition at line 872 of file Variable.cc.

References m_p.

Referenced by Arcane::Array2VariableT< T >::_compareVariable(), Arcane::VariableArrayT< T >::_compareVariable(), Arcane::VariableScalarT< T >::_compareVariable(), Arcane::VariableArrayT< T >::initialize(), resizeFromGroup(), setUsed(), Arcane::Array2VariableT< T >::synchronize(), Arcane::Array2VariableT< T >::synchronize(), Arcane::VariableArrayT< T >::synchronize(), and Arcane::VariableArrayT< T >::synchronize().

Here is the caller graph for this function:

◆ memoryAccessTrace()

IMemoryAccessTrace * Arcane::Variable::memoryAccessTrace ( ) const
inlineoverridevirtual

Implements Arcane::IVariable.

Definition at line 197 of file Variable.h.

◆ mesh()

IMesh * Arcane::Variable::mesh ( ) const
finalvirtual

Mesh associated with the variable.

This operation is only meaningful for variables on mesh entities.

Implements Arcane::IVariable.

Definition at line 843 of file Variable.cc.

References m_p.

◆ meshHandle()

MeshHandle Arcane::Variable::meshHandle ( ) const
finalvirtual

Mesh associated with the variable.

This operation is only meaningful for variables on mesh entities.

Implements Arcane::IVariable.

Definition at line 854 of file Variable.cc.

References m_p.

◆ meshName()

String Arcane::Variable::meshName ( ) const
finalvirtual

Name of the associated mesh (null if none).

Implements Arcane::IVariable.

Definition at line 519 of file Variable.cc.

References m_p.

Referenced by operator=().

Here is the caller graph for this function:

◆ modifiedTime()

Int64 Arcane::Variable::modifiedTime ( )
overridevirtual

Time when the variable was updated.

Implements Arcane::IVariable.

Definition at line 1224 of file Variable.cc.

References m_p.

◆ multiTag()

Integer Arcane::Variable::multiTag ( ) const
overridevirtual

Indicates if the variable is a multi-sized array.

This value is only useful for 2D or higher arrays.

  • 0 for a scalar variable or standard 2D array.
  • 1 for a multi-sized 2D array variable.
  • 2 for an ancient format 2D array variable (obsolete).

Implements Arcane::IVariable.

Definition at line 890 of file Variable.cc.

References m_p.

◆ name()

String Arcane::Variable::name ( ) const
finalvirtual

Variable name.

Implements Arcane::IVariable.

Definition at line 483 of file Variable.cc.

References m_p.

Referenced by Arcane::Array2VariableT< T >::compact(), Arcane::VariableArrayT< T >::compact(), and operator=().

Here is the caller graph for this function:

◆ nbReference()

Integer Arcane::Variable::nbReference ( ) const
overridevirtual

Number of references on this variable.

Implements Arcane::IVariable.

Definition at line 456 of file Variable.cc.

References m_p.

◆ notifyBeginWrite()

void Arcane::Variable::notifyBeginWrite ( )
overridevirtual

Notifies of the start of writing data().

This method triggers the observables registered in writeObservable().

Implements Arcane::IVariable.

Definition at line 1345 of file Variable.cc.

References Arcane::IObservable::notifyAllObservers(), and writeObservable().

Referenced by write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notifyEndRead()

void Arcane::Variable::notifyEndRead ( )
overridevirtual

Notifies of external modification of data().

Signals to the instance the end of a read operation that modified data(). This method must therefore be called as soon as a modification of data() has been performed. This method triggers the observables registered in readObservable().

Implements Arcane::IVariable.

Definition at line 1333 of file Variable.cc.

References _setValidData(), Arcane::IObservable::notifyAllObservers(), readObservable(), setUpToDate(), and syncReferences().

Referenced by read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ notifyReferencePropertyChanged()

void Arcane::Variable::notifyReferencePropertyChanged ( )
overridevirtual

Indicates that the properties of one of the references to this variable have changed (internal)

Implements Arcane::IVariable.

Definition at line 627 of file Variable.cc.

References m_p.

Referenced by operator=().

Here is the caller graph for this function:

◆ onSizeChangedObservable()

IObservable * Arcane::Variable::onSizeChangedObservable ( )
overridevirtual

Size change observable.

The observers registered in this observable are called when the number of elements of the variable changes. This is the case, for example, after a remeshing for a cell variable

Implements Arcane::IVariable.

Definition at line 1148 of file Variable.cc.

References m_p.

Referenced by syncReferences().

Here is the caller graph for this function:

◆ property()

int Arcane::Variable::property ( ) const
overridevirtual
Todo
handle the PSubDomainPrivate case.

Implements Arcane::IVariable.

Definition at line 540 of file Variable.cc.

References m_p, Arcane::IVariable::PDumpNull, Arcane::IVariable::PExecutionDepend, Arcane::IVariable::PInShMem, Arcane::IVariable::PNoDump, Arcane::IVariable::PNoExchange, Arcane::IVariable::PNoNeedSync, Arcane::IVariable::PNoReplicaSync, Arcane::IVariable::PNoRestore, Arcane::IVariable::PPersistant, Arcane::IVariable::PPrivate, property(), Arcane::IVariable::PSubDomainDepend, Arcane::IVariable::PTemporary, and Arcane::VariableRef::referenceProperty().

Referenced by operator=(), property(), and removeVariableRef().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

void Arcane::Variable::read ( IDataReader * reader)
overridevirtual

Reads the variable.

Deprecated
Should be replaced by the following code:
IVariable* var;
reader->read(var,var->data());
Interface of a variable.
Definition IVariable.h:40
virtual void notifyEndRead()=0
Notifies of external modification of data().
virtual ARCANE_DEPRECATED_2018 void read(IDataReader *reader)=0
virtual IData * data()=0
Data associated with the variable.

Implements Arcane::IVariable.

Definition at line 1354 of file Variable.cc.

References Arcane::IVariable::data(), notifyEndRead(), and Arcane::IDataReader::read().

Here is the call graph for this function:

◆ readObservable()

IObservable * Arcane::Variable::readObservable ( )
overridevirtual

Read observable.

The observers registered in this observable are called after reading the variable (read operation).

Implements Arcane::IVariable.

Definition at line 1139 of file Variable.cc.

References m_p.

Referenced by notifyEndRead().

Here is the caller graph for this function:

◆ removeDepend()

void Arcane::Variable::removeDepend ( IVariable * var)
overridevirtual

Removes var from the list of dependencies.

Implements Arcane::IVariable.

Definition at line 1251 of file Variable.cc.

◆ removeTag()

void Arcane::Variable::removeTag ( const String & tagname)
overridevirtual

Removes the tag tagname.

If the tag tagname is not in the list, nothing happens.

Implements Arcane::IVariable.

Definition at line 1303 of file Variable.cc.

References m_p.

◆ removeVariableRef()

void Arcane::Variable::removeVariableRef ( VariableRef * var_ref)
overridevirtual

Removes a reference to this variable.

Precondition
var_ref must reference this variable (an call to addVariableRef() must have been made on this variable).

Implements Arcane::IVariable.

Definition at line 394 of file Variable.cc.

References Arcane::IVariableMng::_internalApi(), m_p, Arcane::VariableRef::nextReference(), Arcane::IVariable::PPersistant, Arcane::VariableRef::previousReference(), property(), Arcane::IVariableMngInternal::removeVariable(), Arcane::VariableRef::setNextReference(), Arcane::VariableRef::setPreviousReference(), and Arcane::ISubDomain::variableMng().

Here is the call graph for this function:

◆ resize()

void Arcane::Variable::resize ( Integer new_size)
overridevirtual

Sets the number of elements for an array variable.

When the variable is a 1D or 2D array type, it sets the number of array elements to new_size. For a 2D array, the number of elements in the first dimension is modified.

This operation must not be called for mesh variables because the number of elements is determined automatically based on the number of entities in the group it relies on. For this type of variable, resizeFromGroup() must be called.

This operation synchronizes the references (syncReferences()).

Implements Arcane::IVariable.

Definition at line 1011 of file Variable.cc.

Referenced by setUsed().

Here is the caller graph for this function:

◆ resizeFromGroup()

void Arcane::Variable::resizeFromGroup ( )
overridevirtual

Sets the number of elements for a mesh variable.

Reallocates the size of the mesh variable based on the group it relies on.

This operation only has an effect on mesh variables. For others, no action is performed.

This operation synchronizes the references (syncReferences()).

Implements Arcane::IVariable.

Definition at line 1020 of file Variable.cc.

References ARCANE_FATAL, Arcane::TraceAccessor::debug(), fullName(), Arcane::Trace::High, Arcane::IK_Unknown, itemKind(), m_p, Arcane::ItemGroup::null(), and syncReferences().

Referenced by setUsed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ serialize() [1/2]

void Arcane::Variable::serialize ( ISerializer * sbuffer,
IDataOperation * operation )
overridevirtual

Serializes the variable.

The operation is only meaningful in read mode (ISerializer::ModeGet)

Implements Arcane::IVariable.

Definition at line 982 of file Variable.cc.

References Arcane::TraceAccessor::debug(), fullName(), Arcane::Trace::High, m_p, Arcane::ISerializer::mode(), Arcane::ISerializer::ModeGet, and syncReferences().

Here is the call graph for this function:

◆ serialize() [2/2]

void Arcane::Variable::serialize ( ISerializer * sbuffer,
Int32ConstArrayView ids,
IDataOperation * operation )
overridevirtual

Serializes the variable for identifiers ids.

Serialization depends on the variable's dimension. For scalar variables (dimension=0), nothing is done. For array or mesh variables, ids corresponds to an array of first dimension indirection.

The operation is only meaningful in read mode (ISerializer::ModeGet)

Implements Arcane::IVariable.

Definition at line 968 of file Variable.cc.

References Arcane::TraceAccessor::debug(), fullName(), Arcane::Trace::High, m_p, Arcane::ISerializer::mode(), Arcane::ISerializer::ModeGet, and syncReferences().

Here is the call graph for this function:

◆ setAllocationInfo()

void Arcane::Variable::setAllocationInfo ( const DataAllocationInfo & v)
overridevirtual

Sets allocation information.

Implements Arcane::IVariable.

Definition at line 1419 of file Variable.cc.

References Arcane::IVariable::data(), Arcane::IData::setAllocationInfo(), and syncReferences().

Here is the call graph for this function:

◆ setComputeFunction()

void Arcane::Variable::setComputeFunction ( IVariableComputeFunction * v)
overridevirtual

Sets the variable's recalculation function.

The specified function v must be allocated via the new operator. If a recalculation function already existed, it is destroyed (via the delete operator) and replaced by this one.

Implements Arcane::IVariable.

Definition at line 1261 of file Variable.cc.

References m_p.

◆ setTraceInfo()

void Arcane::Variable::setTraceInfo ( Integer ,
eTraceType  )
inlineoverridevirtual

Implements Arcane::IVariable.

Definition at line 119 of file Variable.h.

◆ setUpToDate()

void Arcane::Variable::setUpToDate ( )
overridevirtual

Indicates that the variable has just been updated.

For correct dependency management, this property must be called every time a variable has been updated.

Implements Arcane::IVariable.

Definition at line 1214 of file Variable.cc.

References Arcane::ISubDomain::commonVariables(), Arcane::CommonVariables::globalTime(), Arcane::IVariable::incrementModifiedTime(), m_p, and subDomain().

Referenced by notifyEndRead().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUsed()

void Arcane::Variable::setUsed ( bool v)
overridevirtual

Sets the usage state of the variable.

Implements Arcane::IVariable.

Definition at line 636 of file Variable.cc.

References Arcane::IParallelMng::_internalApi(), ARCANE_FATAL, Arcane::DIP_Legacy, Arcane::getGlobalDataInitialisationPolicy(), Arcane::IK_Unknown, itemKind(), m_p, Arcane::IParallelMngInternal::machineShMemWinMemoryAllocator(), Arcane::ISubDomain::parallelMng(), Arcane::IVariable::PInShMem, Arcane::IVariable::PSubDomainPrivate, resize(), resizeFromGroup(), and subDomain().

Referenced by operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ subDomain()

ISubDomain * Arcane::Variable::subDomain ( )
overridevirtual

Subdomain associated with the variable (TODO deprecate end of 2023).

Implements Arcane::IVariable.

Definition at line 465 of file Variable.cc.

References m_p.

Referenced by operator=(), setUpToDate(), and setUsed().

Here is the caller graph for this function:

◆ syncReferences()

void Arcane::Variable::syncReferences ( )
overridevirtual

Synchronizes references.

Synchronizes the values of references (VariableRef) to this variable with the variable's current value. This method is called automatically when a scalar variable is modified or the number of elements of an array variable changes.

Implements Arcane::IVariable.

Definition at line 785 of file Variable.cc.

References Arcane::IObservable::notifyAllObservers(), onSizeChangedObservable(), and Arcane::VariableRef::updateFromInternal().

Referenced by Arcane::Array2VariableT< T >::compact(), Arcane::VariableArrayT< T >::compact(), Arcane::Array2VariableT< T >::copyItemsMeanValues(), Arcane::VariableArrayT< T >::copyItemsMeanValues(), Arcane::VariableArrayT< Real >::copyItemsMeanValues(), Arcane::Array2VariableT< T >::copyItemsValues(), Arcane::VariableArrayT< T >::copyItemsValues(), notifyEndRead(), resizeFromGroup(), serialize(), serialize(), setAllocationInfo(), Arcane::Array2VariableT< T >::shrinkMemory(), and Arcane::VariableArrayT< T >::shrinkMemory().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tagValue()

String Arcane::Variable::tagValue ( const String & tagname)
overridevirtual

Value of the tag tagname. The string is null if the tag does not exist.

Implements Arcane::IVariable.

Definition at line 1321 of file Variable.cc.

References m_p.

◆ update() [1/2]

void Arcane::Variable::update ( )
overridevirtual

Recalculates the variable if necessary.

Through the dependency mechanism, this operation is called recursively on all variables that the instance depends on. The recalculation function computeFunction() is then called if it turns out that one of the variables it depends on has been modified more recently.

Precondition
computeFunction() != 0

Implements Arcane::IVariable.

Definition at line 1160 of file Variable.cc.

References update().

Referenced by update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update() [2/2]

void Arcane::Variable::update ( Real wanted_time)
overridevirtual

Implements Arcane::IVariable.

Definition at line 1169 of file Variable.cc.

◆ variableMng()

IVariableMng * Arcane::Variable::variableMng ( ) const
overridevirtual

Variable manager associated with the variable.

Implements Arcane::IVariable.

Definition at line 474 of file Variable.cc.

References m_p.

Referenced by operator=().

Here is the caller graph for this function:

◆ write()

void Arcane::Variable::write ( IDataWriter * writer)
overridevirtual

Saves the variable.

Deprecated
Should be replaced by the following code:
IVariable* var;
writer->write(var,var->data());
virtual void notifyBeginWrite()=0
Notifies of the start of writing data().

Implements Arcane::IVariable.

Definition at line 1364 of file Variable.cc.

References Arcane::IVariable::data(), notifyBeginWrite(), and Arcane::IDataWriter::write().

Here is the call graph for this function:

◆ writeObservable()

IObservable * Arcane::Variable::writeObservable ( )
overridevirtual

Write observable.

The observers registered in this observable are called before writing the variable (write operation).

Implements Arcane::IVariable.

Definition at line 1130 of file Variable.cc.

References m_p.

Referenced by notifyBeginWrite().

Here is the caller graph for this function:

◆ VariablePrivate

friend class VariablePrivate
friend

Definition at line 229 of file Variable.h.

Member Data Documentation

◆ m_p


The documentation for this class was generated from the following files: