Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
MeshMaterial.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* Matériau d'un maillage. */
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);
72 items._internalApi()->setAsConstituentGroup();
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
125ComponentItemVectorView MeshMaterial::
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
161ComponentPurePartItemVectorView MeshMaterial::
162pureItems() const
163{
164 return m_data._partData()->pureView();
165}
166
167/*---------------------------------------------------------------------------*/
168/*---------------------------------------------------------------------------*/
169
170ComponentImpurePartItemVectorView MeshMaterial::
171impureItems() const
172{
173 return m_data._partData()->impureView();
174}
175
176/*---------------------------------------------------------------------------*/
177/*---------------------------------------------------------------------------*/
178
179ComponentPartItemVectorView MeshMaterial::
180partItems(eMatPart part) const
181{
182 return m_data._partData()->partView(part);
183}
184
185/*---------------------------------------------------------------------------*/
186/*---------------------------------------------------------------------------*/
187
188MatPurePartItemVectorView MeshMaterial::
189pureMatItems() const
190{
191 return { m_non_const_this, m_data._partData()->pureView() };
192}
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
196
197MatImpurePartItemVectorView MeshMaterial::
198impureMatItems() const
199{
200 return { m_non_const_this, m_data._partData()->impureView() };
201}
202
203/*---------------------------------------------------------------------------*/
204/*---------------------------------------------------------------------------*/
205
206MatPartItemVectorView MeshMaterial::
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);
228 return makeRef<IConstituentItemVectorImpl>(x);
229}
230
231/*---------------------------------------------------------------------------*/
232/*---------------------------------------------------------------------------*/
233
234Ref<IConstituentItemVectorImpl> MeshMaterial::InternalApi::
235createItemVectorImpl(ComponentItemVectorView rhs) const
236{
237 auto* x = new ConstituentItemVectorImpl(rhs);
238 return makeRef<IConstituentItemVectorImpl>(x);
239}
240
241/*---------------------------------------------------------------------------*/
242/*---------------------------------------------------------------------------*/
243
244} // namespace Arcane::Materials
245
246/*---------------------------------------------------------------------------*/
247/*---------------------------------------------------------------------------*/
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
ItemGroupImplInternal * _internalApi() const
API interne à Arcane.
Definition ItemGroup.cc:645
ItemGroupT< Cell > CellGroup
Groupe de mailles.
Definition ItemTypes.h:183
Active toujours les traces dans les parties Arcane concernant les matériaux.