14#include "arcane/utils/NotImplementedException.h"
15#include "arcane/utils/TraceInfo.h"
16#include "arcane/utils/NumericTypes.h"
18#include "arcane/core/MeshVariableScalarRef.h"
19#include "arcane/core/VariableBuildInfo.h"
20#include "arcane/core/ArcaneException.h"
22#include "arcane/core/materials/IMeshMaterialMng.h"
23#include "arcane/core/materials/IMeshMaterial.h"
24#include "arcane/core/materials/MaterialVariableBuildInfo.h"
36MeshMaterialVariableRef::
37MeshMaterialVariableRef()
44MeshMaterialVariableRef::
45~MeshMaterialVariableRef()
58 m_material_variable->removeVariableRef(
this);
59 m_is_registered =
false;
69 m_material_variable->addVariableRef(
this);
70 m_is_registered =
true;
76void MeshMaterialVariableRef::
79 m_material_variable = mat_variable;
91 return m_previous_reference;
100 return m_next_reference;
106void MeshMaterialVariableRef::
109 m_previous_reference = v;
115void MeshMaterialVariableRef::
118 m_next_reference = v;
124void MeshMaterialVariableRef::
127 ARCANE_THROW(InternalErrorException,
"Trying to use uninitialized variable reference");
137 m_material_variable->synchronize();
147 m_material_variable->synchronize(sync_list);
153String MeshMaterialVariableRef::
156 return m_global_variable->
name();
158void MeshMaterialVariableRef::
163bool MeshMaterialVariableRef::
166 return m_global_variable->
isUsed();
168void MeshMaterialVariableRef::
171 m_global_variable->update();
174void MeshMaterialVariableRef::
175addDependCurrentTime(
const VariableRef& var)
177 m_global_variable->addDepend(var.variable(), IVariable::DPT_CurrentTime);
179void MeshMaterialVariableRef::
180addDependCurrentTime(
const VariableRef& var,
const TraceInfo& tinfo)
182 m_global_variable->addDepend(var.variable(), IVariable::DPT_CurrentTime, tinfo);
185void MeshMaterialVariableRef::
188 m_global_variable->addDepend(var.m_global_variable, IVariable::DPT_CurrentTime);
191void MeshMaterialVariableRef::
194 m_global_variable->addDepend(var.m_global_variable, IVariable::DPT_PreviousTime);
197void MeshMaterialVariableRef::
200 m_global_variable->removeDepend(var.m_global_variable);
206void MeshMaterialVariableRef::
209 m_material_variable->setUpToDate(mat);
212void MeshMaterialVariableRef::
215 m_material_variable->
update(mat);
218void MeshMaterialVariableRef::
224void MeshMaterialVariableRef::
225addMaterialDepend(
const VariableRef& var,
const TraceInfo& tinfo)
227 m_material_variable->
addDepend(var.variable(), tinfo);
230void MeshMaterialVariableRef::
233 m_material_variable->addDepend(var.materialVariable());
236void MeshMaterialVariableRef::
239 m_material_variable->addDepend(var.materialVariable(), tinfo);
269: m_private_part(rhs.m_private_part)
274 m_private_part->incrementReference();
284: m_private_part(PrivatePartType::BuilderType::getVariableReference(var))
288 m_private_part->incrementReference();
299template <
typename DataType>
void
303 if (m_private_part) {
305 _internalInit(m_private_part->toMeshMaterialVariable());
312template <
typename DataType>
void
316 if (rhs.m_private_part == m_private_part)
320 m_private_part = rhs.m_private_part;
321 m_container_value = {};
327 m_private_part->incrementReference();
334template <
typename DataType>
void
344template <
typename DataType> DataType
353 return this->operator[](imatcell);
362template <
typename DataType> DataType
370 return this->operator[](ienvcell);
390template <
typename DataType>
void
394 m_private_part->fillFromArray(mat, values);
412template <
typename DataType>
void
416 m_private_part->fillFromArray(mat, values, indexes);
434template <
typename DataType>
void
438 m_private_part->fillToArray(mat, values);
456template <
typename DataType>
void
460 m_private_part->fillToArray(mat, values, indexes);
471template <
typename DataType>
void
487template <
typename DataType>
void
501template <
typename DataType>
void
503fill(
const DataType& value)
515template <
typename DataType>
void
519 m_private_part->fillPartialValues(value);
532 GlobalVariableRefType* rt = m_private_part->globalVariableReference();
545 GlobalVariableRefType* rt = m_private_part->globalVariableReference();
554template <
typename DataType>
void
558 if (m_private_part) {
559 m_container_value = m_private_part->_internalFullValuesView();
560 m_value = m_container_value.data();
563 m_container_value = {};
597: m_private_part(PrivatePartType::BuilderType::getVariableReference(var))
601 m_private_part->incrementReference();
612: m_private_part(rhs.m_private_part)
618 m_private_part->incrementReference();
627template <
typename DataType>
void
631 if (m_private_part) {
633 _internalInit(m_private_part->toMeshMaterialVariable());
641template <
typename DataType>
void
645 if (rhs.m_private_part == m_private_part)
650 m_private_part = rhs.m_private_part;
652 m_container_value = {};
657 m_private_part->incrementReference();
665template <
typename DataType>
void
679 GlobalVariableRefType* rt = m_private_part->globalVariableReference();
692 GlobalVariableRefType* rt = m_private_part->globalVariableReference();
701template <
typename DataType>
void
705 m_private_part->resize(dim2_size);
711template <
typename DataType>
void
715 if (m_private_part) {
716 m_container_value = m_private_part->_internalFullValuesView();
717 m_value = m_container_value.data();
720 m_container_value = {};
731#define ARCANE_INSTANTIATE_MAT(type) \
732 template class ARCANE_TEMPLATE_EXPORT CellMaterialVariableScalarRef<type>; \
733 template class ARCANE_TEMPLATE_EXPORT CellMaterialVariableArrayRef<type>
735ARCANE_INSTANTIATE_MAT(
Byte);
736ARCANE_INSTANTIATE_MAT(
Int8);
737ARCANE_INSTANTIATE_MAT(
Int16);
738ARCANE_INSTANTIATE_MAT(
Int32);
739ARCANE_INSTANTIATE_MAT(
Int64);
740ARCANE_INSTANTIATE_MAT(BFloat16);
741ARCANE_INSTANTIATE_MAT(
Float16);
742ARCANE_INSTANTIATE_MAT(
Float32);
743ARCANE_INSTANTIATE_MAT(
Real);
744ARCANE_INSTANTIATE_MAT(Real2);
745ARCANE_INSTANTIATE_MAT(Real3);
746ARCANE_INSTANTIATE_MAT(Real2x2);
747ARCANE_INSTANTIATE_MAT(Real3x3);
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Modifiable view of an array of type T.
Base class for 1D data vectors.
void resize(Int64 s)
Changes the number of elements in the array to s.
ArrayView< T > view() const
Mutable view of this array.
Constant view of an array of type T.
virtual void setUpToDate()=0
Indicates that the variable has just been updated.
virtual bool isUsed() const =0
Usage state of the variable.
virtual String name() const =0
Variable name.
Integer size() const
Number of elements in the group.
Arcane cell with material and environment information.
Array variable over the cells of a material in the mesh. For now, this class is only instantiated for...
CellMaterialVariableArrayRef()=delete
Default constructor (deleted).
CellMaterialVariableArrayRef(const VariableBuildInfo &vb)
Constructs a reference to the variable specified in vb.
GlobalVariableRefType & globalVariable()
Global variable associated with this material variable.
virtual void refersTo(const ThatClass &rhs)
Positions the instance reference to the variable rhs.
void resize(Integer dim2_size)
Resizes the number of elements in the array.
Scalar variable on the cells of a mesh material.
DataType matValue(AllEnvCell c, Int32 mat_id) const
Value of the variable for the material with index mat_id of the cell, or 0 if absent from the cell.
CellMaterialVariableScalarRef(const VariableBuildInfo &vb)
Constructs a reference to the variable specified in vb.
DataType envValue(AllEnvCell c, Int32 env_id) const
Value of the variable for the environment with index env_id of the cell, or 0 if absent from the cell...
void fill(const DataType &value)
Fills the partial and global values of the variable with the value value.
void fillPartialValues(const DataType &value)
Fills the partial values of the variable with the value value.
void fillFromArray(IMeshMaterial *mat, ConstArrayView< DataType > values)
Fills the variable values for a material.
GlobalVariableRefType & globalVariable()
Global variable associated with this material variable.
virtual void refersTo(const ThatClass &rhs)
Positions the instance reference to the variable rhs.
CellMaterialVariableScalarRef()=delete
Default constructor (deleted).
void fillToArray(IMeshMaterial *mat, ArrayView< DataType > values)
Fills an array from the variable values for a material.
Arcane cell of an environment.
__host__ __device__ Int32 environmentId() const
Environment identifier.
virtual CellGroup cells() const =0
Group of cells for this material.
Interface of a material variable on a mesh.
virtual void addDepend(IMeshMaterialVariable *var)=0
Adds var to the dependency list.
virtual IVariable * globalVariable() const =0
Associated global variable on the mesh.
virtual void update(IMeshMaterial *mat)=0
Recalculates the variable for material mat if necessary.
Interface of a mesh material.
Represents a material in a multi-material cell.
__host__ __device__ Int32 materialId() const
Material identifier.
Base class for material variable references.
MeshMaterialVariableRef * nextReference()
Next reference (or null) on variable().
MeshMaterialVariableRef * previousReference()
Previous reference (or null) on variable().
void unregisterVariable()
Unregisters the variable (internal).
void registerVariable()
Registers the variable (internal).
void synchronize()
Synchronizes values between sub-domains.
Synchronizing a list of material variables.
Array variable on a mesh entity type.
Scalar variable on a mesh entity type.
Unicode character string.
Parameters necessary for building a variable.
IVariable * variable() const
Associated variable.
Always enables tracing in Arcane parts concerning materials.
MatVarSpace
Definition space for a material variable.
@ MaterialAndEnvironment
Variable having values on environments and materials.
std::int8_t Int8
Signed integer type of 8 bits.
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.
@ Float16
Float16 data type.
std::int16_t Int16
Signed integer type of 16 bits.
double Real
Type representing a real number.
unsigned char Byte
Type of a byte.
float Float32
IEEE-753 single-precision floating-point type.
std::int32_t Int32
Signed integer type of 32 bits.