Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MeshMaterial.cc
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/* MeshMaterial.cc (C) 2000-2024 */
9/* */
10/* Mesh material. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArgumentException.h"
15#include "arcane/utils/NotImplementedException.h"
16#include "arcane/utils/Ref.h"
17
18#include "arcane/core/IMesh.h"
19#include "arcane/core/IItemFamily.h"
20#include "arcane/core/internal/ItemGroupImplInternal.h"
21#include "arcane/core/materials/internal/IMeshMaterialMngInternal.h"
22
23#include "arcane/materials/MeshMaterialInfo.h"
24#include "arcane/materials/IMeshMaterialMng.h"
25#include "arcane/materials/MatItemEnumerator.h"
26#include "arcane/materials/ComponentItemVectorView.h"
27#include "arcane/materials/ComponentPartItemVectorView.h"
28
29#include "arcane/materials/internal/MeshMaterial.h"
30#include "arcane/materials/internal/MeshEnvironment.h"
31#include "arcane/materials/internal/ConstituentItemVectorImpl.h"
32#include "arcane/materials/internal/MeshComponentPartData.h"
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37namespace Arcane::Materials
38{
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
42
43MeshMaterial::
44MeshMaterial(MeshMaterialInfo* infos, MeshEnvironment* env,
45 const String& name, Int16 mat_id)
46: TraceAccessor(infos->materialMng()->traceMng())
47, m_material_mng(infos->materialMng())
48, m_infos(infos)
49, m_environment(env)
50, m_user_material(nullptr)
51, m_data(this, name, mat_id, m_material_mng->_internalApi()->componentItemSharedInfo(LEVEL_MATERIAL), true)
52, m_non_const_this(this)
53, m_internal_api(this)
54{
55 if (!env)
56 ARCANE_THROW(ArgumentException, "null environement for material '{0}'", name);
57}
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65void MeshMaterial::
66build()
67{
68 IMesh* mesh = m_material_mng->mesh();
69 IItemFamily* cell_family = mesh->cellFamily();
70 String group_name = m_material_mng->name() + "_" + name();
71 CellGroup items = cell_family->findGroup(group_name, true);
73 m_data._setItems(items);
74}
75
76/*---------------------------------------------------------------------------*/
77/*---------------------------------------------------------------------------*/
78
79IMeshEnvironment* MeshMaterial::
80environment() const
81{
82 return m_environment;
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88MatCell MeshMaterial::
89findMatCell(AllEnvCell c) const
90{
91 Int32 mat_id = m_data.componentId();
92 for (EnvCell env_cell : c.subEnvItems()) {
93 for (MatCell mc : env_cell.subMatItems()) {
94 Int32 mid = mc.materialId();
95 if (mid == mat_id)
96 return mc;
97 }
98 }
99
100 return MatCell();
101}
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
106ComponentCell MeshMaterial::
107findComponentCell(AllEnvCell c) const
108{
109 return findMatCell(c);
110}
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
115MatItemVectorView MeshMaterial::
116matView() const
117{
118 return { m_non_const_this, variableIndexer()->matvarIndexes(),
119 constituentItemListView(), variableIndexer()->localIds() };
120}
121
122/*---------------------------------------------------------------------------*/
123/*---------------------------------------------------------------------------*/
124
126view() const
127{
128 return matView();
129}
130
131/*---------------------------------------------------------------------------*/
132/*---------------------------------------------------------------------------*/
133
134void MeshMaterial::
135resizeItemsInternal(Integer nb_item)
136{
137 m_data._resizeItemsInternal(nb_item);
138}
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143void MeshMaterial::
144checkValid()
145{
146 m_data.checkValid();
147}
148
149/*---------------------------------------------------------------------------*/
150/*---------------------------------------------------------------------------*/
151
152CellGroup MeshMaterial::
153cells() const
154{
155 return m_data.items();
156}
157
158/*---------------------------------------------------------------------------*/
159/*---------------------------------------------------------------------------*/
160
162pureItems() const
163{
164 return m_data._partData()->pureView();
165}
166
167/*---------------------------------------------------------------------------*/
168/*---------------------------------------------------------------------------*/
169
171impureItems() const
172{
173 return m_data._partData()->impureView();
174}
175
176/*---------------------------------------------------------------------------*/
177/*---------------------------------------------------------------------------*/
178
180partItems(eMatPart part) const
181{
182 return m_data._partData()->partView(part);
183}
184
185/*---------------------------------------------------------------------------*/
186/*---------------------------------------------------------------------------*/
187
189pureMatItems() const
190{
191 return { m_non_const_this, m_data._partData()->pureView() };
192}
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
196
198impureMatItems() const
199{
200 return { m_non_const_this, m_data._partData()->impureView() };
201}
202
203/*---------------------------------------------------------------------------*/
204/*---------------------------------------------------------------------------*/
205
207partMatItems(eMatPart part) const
208{
209 return { m_non_const_this, m_data._partData()->partView(part) };
210}
211
212/*---------------------------------------------------------------------------*/
213/*---------------------------------------------------------------------------*/
214
215Int32 MeshMaterial::InternalApi::
216variableIndexerIndex() const
217{
218 return variableIndexer()->index();
219}
220
221/*---------------------------------------------------------------------------*/
222/*---------------------------------------------------------------------------*/
223
224Ref<IConstituentItemVectorImpl> MeshMaterial::InternalApi::
225createItemVectorImpl() const
226{
227 auto* x = new ConstituentItemVectorImpl(m_material->m_non_const_this);
229}
230
231/*---------------------------------------------------------------------------*/
232/*---------------------------------------------------------------------------*/
233
234Ref<IConstituentItemVectorImpl> MeshMaterial::InternalApi::
235createItemVectorImpl(ComponentItemVectorView rhs) const
236{
237 auto* x = new ConstituentItemVectorImpl(rhs);
239}
240
241/*---------------------------------------------------------------------------*/
242/*---------------------------------------------------------------------------*/
243
244} // namespace Arcane::Materials
245
246/*---------------------------------------------------------------------------*/
247/*---------------------------------------------------------------------------*/
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
Interface of an entity family.
Definition IItemFamily.h:83
virtual ItemGroup findGroup(const String &name) const =0
Searches for a group.
void setAsConstituentGroup()
Indicates that the group is associated with a constituent.
ItemGroupImplInternal * _internalApi() const
Internal Arcane API.
Definition ItemGroup.cc:643
Arcane cell with material and environment information.
__host__ __device__ CellEnvCellEnumerator subEnvItems() const
Enumerator over the environment cells of this cell.
View over a vector of entities of a component.
Arcane cell of an environment.
Represents a material in a multi-material cell.
View over the impure part of the entities of a material.
View over a vector of entities of a material.
View over pure or partial entities of a material.
View over the pure part of the entities of a material.
Info about a material of a mesh.
MeshMaterialVariableIndexer * variableIndexer() const override
Indexer to access partial variables.
MatItemVectorView matView() const override
View associated with this material.
MatCell findMatCell(AllEnvCell c) const override
Cell of this material for cell c.
String name() const override
Component name.
Reference to an instance.
ItemGroupT< Cell > CellGroup
Group of cells.
Definition ItemTypes.h:184
Always enables tracing in Arcane parts concerning materials.
eMatPart
Part of a component.
Int32 Integer
Type representing an integer.
std::int16_t Int16
Signed integer type of 16 bits.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
std::int32_t Int32
Signed integer type of 32 bits.