Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MeshEnvironment.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/* MeshEnvironment.h (C) 2000-2025 */
9/* */
10/* Mesh environment. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MATERIALS_INTERNAL_MESHENVIRONMENT_H
13#define ARCANE_MATERIALS_INTERNAL_MESHENVIRONMENT_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18
19#include "arcane/core/ItemGroup.h"
20#include "arcane/core/MeshVariableScalarRef.h"
22#include "arcane/core/materials/IMeshEnvironment.h"
23#include "arcane/core/materials/ComponentItemInternal.h"
24#include "arcane/core/materials/internal/IMeshComponentInternal.h"
25
26#include "arcane/materials/internal/ComponentItemInternalData.h"
27#include "arcane/materials/internal/MeshComponentData.h"
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane::Materials
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
39class MeshMaterial;
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
52class MeshEnvironment
53: public TraceAccessor
54, public IMeshEnvironment
55{
56 class InternalApi
58 {
59 public:
60
61 InternalApi(MeshEnvironment* env)
62 : m_environment(env)
63 {}
64
65 public:
66
68 {
69 return m_environment->variableIndexer();
70 }
72 {
73 return m_environment->constituentItemListView();
74 }
75 Int32 variableIndexerIndex() const override;
78
79 private:
80
81 MeshEnvironment* m_environment;
82 };
83
84 public:
85
87
88 public:
89
91 ITraceMng* traceMng() override { return TraceAccessor::traceMng(); }
92 String name() const override { return m_data.name(); }
93 CellGroup cells() const override { return m_data.items(); }
95 {
96 return m_materials;
97 }
98 Integer nbMaterial() const override
99 {
100 return m_materials.size();
101 }
102 MeshMaterialVariableIndexer* variableIndexer() const
103 {
104 return m_data.variableIndexer();
105 }
106 ConstituentItemLocalIdListView constituentItemListView() const
107 {
108 return m_data.constituentItemListView();
109 }
110 Int32 id() const override
111 {
112 return m_data.componentId();
113 }
114
115 IUserMeshEnvironment* userEnvironment() const override { return m_user_environment; }
116 void setUserEnvironment(IUserMeshEnvironment* umm) override { m_user_environment = umm; }
117
118 ComponentCell findComponentCell(AllEnvCell c) const override;
119 EnvCell findEnvCell(AllEnvCell c) const override;
120
121 ComponentItemVectorView view() const override;
122 EnvItemVectorView envView() const override;
123
124 void checkValid() override;
125
126 bool isMaterial() const override { return false; }
127 bool isEnvironment() const override { return true; }
128 bool hasSpace(MatVarSpace space) const override
129 {
131 }
132 IMeshMaterial* asMaterial() override { return nullptr; }
133 IMeshEnvironment* asEnvironment() override { return this; }
134
138
141 EnvPartItemVectorView partEnvItems(eMatPart part) const override;
142
144 bool isMonoMaterial() const;
145
147 {
148 m_data.setSpecificExecutionPolicy(policy);
149 }
151 {
152 return m_data.specificExecutionPolicy();
153 }
154
155 public:
156
157 IMeshComponentInternal* _internalApi() override { return &m_internal_api; }
158
159 public:
160
161 void setConstituentItem(Int32 index, ConstituentItemIndex id)
162 {
163 m_data._setConstituentItem(index, id);
164 }
165 Int16 componentId() const { return m_data.componentId(); }
166
167 public:
168
170
171 void build();
172 void addMaterial(MeshMaterial* mm);
173 void setVariableIndexer(MeshMaterialVariableIndexer* idx);
175 void computeNbMatPerCell();
176
177 void computeItemListForMaterials(const ConstituentConnectivityList& connectivity_list);
178
181 void addToTotalNbCellMat(Int32 v) { m_total_nb_cell_mat += v; }
182
183 void resizeItemsInternal(Integer nb_item);
184 void computeMaterialIndexes(ComponentItemInternalData* item_internal_data, RunQueue& queue);
185 void notifyLocalIdsChanged(Int32ConstArrayView old_to_new_ids);
186 MeshComponentData* componentData() { return &m_data; }
187
188 ConstArrayView<MeshMaterial*> trueMaterials()
189 {
190 return m_true_materials;
191 }
192 void setMatInternalDataRange(ComponentItemInternalRange v) { m_mat_internal_data_range = v; }
194
195 private:
196
199
200 IUserMeshEnvironment* m_user_environment = nullptr;
201
202 UniqueArray<IMeshMaterial*> m_materials;
203 UniqueArray<MeshMaterial*> m_true_materials;
204
207 IItemGroupObserver* m_group_observer = nullptr;
208 MeshComponentData m_data;
209 MeshEnvironment* m_non_const_this = nullptr;
210 InternalApi m_internal_api;
211 ComponentItemInternalRange m_mat_internal_data_range;
212
213 public:
214
215 void _computeMaterialIndexes(ComponentItemInternalData* item_internal_data, RunQueue& queue);
216 void _computeMaterialIndexesMonoMat(ComponentItemInternalData* item_internal_data, RunQueue& queue);
217
218 private:
219
220 void _changeIds(MeshComponentData* component_data, Int32ConstArrayView old_to_new_ids);
221};
222
223/*---------------------------------------------------------------------------*/
224/*---------------------------------------------------------------------------*/
225
226} // End namespace Arcane::Materials
227
228/*---------------------------------------------------------------------------*/
229/*---------------------------------------------------------------------------*/
230
231#endif
Constant view of an array of type T.
Arcane cell with material and environment information.
Management of 'ComponentItemInternal' lists.
Interval of constituent identifiers in the ComponentItemInternal list.
View over a vector of entities of a component.
Index of a constituent entity in the list of constituent entities.
View of a ConstituentItemLocalIdList instance.
Arcane cell of an environment.
View over the impure part of the entities of an environment.
View over a vector of entities of an environment.
View over pure or partial entities of an environment.
View over the pure part of the entities of an environment.
Arcane internal API for 'IMeshComponent'.
Interface for the material and environment manager of a mesh.
Data of a constituent (material or medium) of a mesh.
MeshMaterialVariableIndexer * variableIndexer() const override
Indexer to access partial variables.
Ref< IConstituentItemVectorImpl > createItemVectorImpl() const override
Create an instance of the 'ConstituentItemVectorImpl' implementation.
ConstituentItemLocalIdListView constituentItemListView() const override
View of the constituent cells.
Int32 variableIndexerIndex() const override
Index to access partial variables.
bool isEnvironment() const override
True if the component is an environment.
void _computeMaterialIndexesMonoMat(ComponentItemInternalData *item_internal_data, RunQueue &queue)
Calculates material information for mono-materials.
IMeshMaterialMng * m_material_mng
Material manager.
void checkValid() override
Checks that the component is valid.
void build()
Public functions but reserved for IMeshMaterialMng.
void setSpecificExecutionPolicy(Accelerator::eExecutionPolicy policy) override
Sets an execution policy for this constituent.
ComponentItemVectorView view() const override
View associated with this component.
IMeshMaterial * asMaterial() override
Returns the component in the form of an IMeshMaterial.
ComponentPartItemVectorView partItems(eMatPart part) const override
View on the pure or impure part of the component's entities.
IMeshEnvironment * asEnvironment() override
Returns the component in the form of an IMeshMaterial.
bool hasSpace(MatVarSpace space) const override
Indicates if the component is defined for space space.
ComponentImpurePartItemVectorView impureItems() const override
View on the list of impure (partial) entities of the component.
EnvImpurePartItemVectorView impureEnvItems() const override
View of the list of impure (partial) entities in the environment.
EnvPartItemVectorView partEnvItems(eMatPart part) const override
View of the pure or impure part of the environment entities.
void computeItemListForMaterials(const ConstituentConnectivityList &connectivity_list)
Calculation for the environment material cells and their location in the variable indexing table.
ConstArrayView< IMeshMaterial * > materials() override
List of materials in this environment.
void computeMaterialIndexes(ComponentItemInternalData *item_internal_data, RunQueue &queue)
Calculates material information.
Int32 id() const override
Component identifier.
IUserMeshEnvironment * userEnvironment() const override
Environment identifier. It is also the index (starting from 0) of this environment in the list of env...
ComponentCell findComponentCell(AllEnvCell c) const override
Cell of this component for cell c.
Integer totalNbCellMat() const
Total number of cells for all materials.
Accelerator::eExecutionPolicy specificExecutionPolicy() const override
Specific execution policy.
EnvCell findEnvCell(AllEnvCell c) const override
Cell of this environment for cell c.
CellGroup cells() const override
Group of cells for this material.
void computeNbMatPerCell()
Recalculates the number of cells per material and the total number of cells.
ComponentPurePartItemVectorView pureItems() const override
View on the list of pure entities (associated with the global cell) of the component.
IMeshMaterialMng * materialMng() override
Associated manager.
Integer nbMaterial() const override
Number of materials in the environment.
EnvPurePartItemVectorView pureEnvItems() const override
View of the list of pure entities (associated with the global cell) in the environment.
void setUserEnvironment(IUserMeshEnvironment *umm) override
Sets the associated user environment.
IMeshComponentInternal * _internalApi() override
Internal API.
EnvItemVectorView envView() const override
View associated with this environment.
Integer m_total_nb_cell_mat
Total number of cells for all materials.
ITraceMng * traceMng() override
Associated trace manager.
bool isMonoMaterial() const
Indicates if the environment is mono-material.
bool isMaterial() const override
True if the component is a material.
String name() const override
Component name.
Reference to an instance.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
ITraceMng * traceMng() const
Trace manager.
1D data vector with value semantics (STL style).
ItemGroupT< Cell > CellGroup
Group of cells.
Definition ItemTypes.h:184
eExecutionPolicy
Execution policy for a Runner.
Always enables tracing in Arcane parts concerning materials.
MatVarSpace
Definition space for a material variable.
@ Environment
Variable having values only on environments.
@ MaterialAndEnvironment
Variable having values on environments and materials.
eMatPart
Part of a component.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
std::int16_t Int16
Signed integer type of 16 bits.
std::int32_t Int32
Signed integer type of 32 bits.