@@ -70,7 +70,8 @@ apply(MaterialModifierOperation* operation)
70
70
{
71
71
bool is_add = operation->isAdd ();
72
72
IMeshMaterial* mat = operation->material ();
73
- Int32ConstArrayView ids = operation->ids ();
73
+ ConstArrayView<Int32> orig_ids = operation->ids ();
74
+ ConstArrayView<Int32> ids = orig_ids;
74
75
75
76
auto * true_mat = ARCANE_CHECK_POINTER (dynamic_cast <MeshMaterial*>(mat));
76
77
@@ -82,8 +83,6 @@ apply(MaterialModifierOperation* operation)
82
83
83
84
ConstituentConnectivityList* connectivity = m_all_env_data->componentConnectivityList ();
84
85
85
- Int32UniqueArray cells_changed_in_env;
86
-
87
86
if (nb_mat != 1 ) {
88
87
89
88
// S'il est possible d'avoir plusieurs matériaux par milieu, il faut gérer
@@ -94,12 +93,18 @@ apply(MaterialModifierOperation* operation)
94
93
// - en cas de suppression, le milieu évolue dans la maille s'il y avait
95
94
// 1 seul matériau avant. Dans ce cas le milieu est supprimé de la maille.
96
95
97
- Int32UniqueArray cells_unchanged_in_env;
96
+ UniqueArray<Int32>& cells_changed_in_env = m_work_info.cells_changed_in_env ;
97
+ UniqueArray<Int32>& cells_unchanged_in_env = m_work_info.cells_unchanged_in_env ;
98
+ const Int32 nb_id = ids.size ();
99
+ cells_unchanged_in_env.clear ();
100
+ cells_unchanged_in_env.reserve (nb_id);
101
+ cells_changed_in_env.clear ();
102
+ cells_changed_in_env.reserve (nb_id);
98
103
const Int32 ref_nb_mat = is_add ? 0 : 1 ;
99
104
const Int16 env_id = true_env->componentId ();
100
105
info (4 ) << " Using optimisation updateMaterialDirect is_add?=" << is_add;
101
106
102
- for (Integer i = 0 , n = ids. size () ; i < n ; ++i) {
107
+ for (Integer i = 0 ; i < nb_id ; ++i) {
103
108
Int32 lid = ids[i];
104
109
Int32 current_cell_nb_mat = connectivity->cellNbMaterial (CellLocalId (lid), env_id);
105
110
if (current_cell_nb_mat != ref_nb_mat) {
@@ -153,9 +158,9 @@ apply(MaterialModifierOperation* operation)
153
158
// d'ajout) ou les mailles partielles en mailles pures (en cas de
154
159
// suppression).
155
160
info (4 ) << " Transform PartialPure for material name=" << true_mat->name ();
156
- _switchComponentItemsForMaterials (true_mat);
161
+ _switchCellsForMaterials (true_mat, orig_ids );
157
162
info (4 ) << " Transform PartialPure for environment name=" << env->name ();
158
- _switchComponentItemsForEnvironments (env);
163
+ _switchCellsForEnvironments (env, orig_ids );
159
164
160
165
// Si je suis mono-mat, alors mat->cells()<=>env->cells() et il ne faut
161
166
// mettre à jour que l'un des deux groupes.
@@ -190,7 +195,8 @@ apply(MaterialModifierOperation* operation)
190
195
* (suppression d'un matériau)
191
196
*/
192
197
void IncrementalComponentModifier::
193
- _switchComponentItemsForMaterials (const MeshMaterial* modified_mat)
198
+ _switchCellsForMaterials (const MeshMaterial* modified_mat,
199
+ ConstArrayView<Int32> ids)
194
200
{
195
201
const bool is_add = m_work_info.isAdd ();
196
202
@@ -203,16 +209,13 @@ _switchComponentItemsForMaterials(const MeshMaterial* modified_mat)
203
209
m_work_info.pure_local_ids .clear ();
204
210
m_work_info.partial_indexes .clear ();
205
211
206
- const MeshEnvironment* env = mat->trueEnvironment ();
207
- if (env != true_env)
208
- ARCANE_FATAL (" BAD ENV" );
209
212
MeshMaterialVariableIndexer* indexer = mat->variableIndexer ();
210
213
211
214
info (4 ) << " TransformCells (V3) is_add?=" << is_add << " indexer=" << indexer->name ();
212
215
213
- _computeCellsToTransform (mat);
214
-
216
+ _computeCellsToTransformForMaterial (mat, ids);
215
217
indexer->transformCellsV2 (m_work_info);
218
+ m_work_info.resetTransformedCells (ids);
216
219
217
220
info (4 ) << " NB_MAT_TRANSFORM=" << m_work_info.pure_local_ids .size () << " name=" << mat->name ();
218
221
@@ -238,7 +241,8 @@ _switchComponentItemsForMaterials(const MeshMaterial* modified_mat)
238
241
* en pure (dans le cas de suppression d'un matériau)
239
242
*/
240
243
void IncrementalComponentModifier::
241
- _switchComponentItemsForEnvironments (const IMeshEnvironment* modified_env)
244
+ _switchCellsForEnvironments (const IMeshEnvironment* modified_env,
245
+ ConstArrayView<Int32> ids)
242
246
{
243
247
const bool is_add = m_work_info.isAdd ();
244
248
@@ -260,8 +264,9 @@ _switchComponentItemsForEnvironments(const IMeshEnvironment* modified_env)
260
264
261
265
info (4 ) << " TransformCells (V2) is_add?=" << is_add << " indexer=" << indexer->name ();
262
266
263
- _computeCellsToTransform ( );
267
+ _computeCellsToTransformForEnvironments (ids );
264
268
indexer->transformCellsV2 (m_work_info);
269
+ m_work_info.resetTransformedCells (ids);
265
270
266
271
info (4 ) << " NB_ENV_TRANSFORM=" << m_work_info.pure_local_ids .size ()
267
272
<< " name=" << env->name ();
@@ -279,7 +284,7 @@ _switchComponentItemsForEnvironments(const IMeshEnvironment* modified_env)
279
284
* \brief Calcule les mailles à transformer pour le matériau \at mat.
280
285
*/
281
286
void IncrementalComponentModifier::
282
- _computeCellsToTransform (const MeshMaterial* mat)
287
+ _computeCellsToTransformForMaterial (const MeshMaterial* mat, ConstArrayView<Int32> ids )
283
288
{
284
289
const MeshEnvironment* env = mat->trueEnvironment ();
285
290
const Int16 env_id = env->componentId ();
@@ -289,23 +294,25 @@ _computeCellsToTransform(const MeshMaterial* mat)
289
294
ConstituentConnectivityList* connectivity = m_all_env_data->componentConnectivityList ();
290
295
ConstArrayView<Int16> cells_nb_env = connectivity->cellsNbEnvironment ();
291
296
292
- ENUMERATE_ (Cell, icell, all_cells ) {
297
+ for (Int32 local_id : ids ) {
293
298
bool do_transform = false ;
299
+ CellLocalId cell_id (local_id);
294
300
// En cas d'ajout on passe de pure à partiel s'il y a plusieurs milieux ou
295
301
// plusieurs matériaux dans le milieu.
296
302
// En cas de supression, on passe de partiel à pure si on est le seul matériau
297
303
// et le seul milieu.
304
+ const Int16 nb_env = cells_nb_env[local_id];
298
305
if (is_add) {
299
- do_transform = cells_nb_env[icell. itemLocalId ()] > 1 ;
306
+ do_transform = (nb_env > 1 ) ;
300
307
if (!do_transform)
301
- do_transform = connectivity->cellNbMaterial (icell , env_id) > 1 ;
308
+ do_transform = connectivity->cellNbMaterial (cell_id , env_id) > 1 ;
302
309
}
303
310
else {
304
- do_transform = cells_nb_env[icell. itemLocalId ()] == 1 ;
311
+ do_transform = (nb_env == 1 ) ;
305
312
if (do_transform)
306
- do_transform = connectivity->cellNbMaterial (icell , env_id) == 1 ;
313
+ do_transform = connectivity->cellNbMaterial (cell_id , env_id) == 1 ;
307
314
}
308
- m_work_info.setTransformedCell (icell , do_transform);
315
+ m_work_info.setTransformedCell (cell_id , do_transform);
309
316
}
310
317
}
311
318
@@ -316,22 +323,22 @@ _computeCellsToTransform(const MeshMaterial* mat)
316
323
* d'un milieu.
317
324
*/
318
325
void IncrementalComponentModifier::
319
- _computeCellsToTransform ( )
326
+ _computeCellsToTransformForEnvironments (ConstArrayView<Int32> ids )
320
327
{
321
328
ConstituentConnectivityList* connectivity = m_all_env_data->componentConnectivityList ();
322
329
ConstArrayView<Int16> cells_nb_env = connectivity->cellsNbEnvironment ();
323
330
CellGroup all_cells = m_material_mng->mesh ()->allCells ();
324
331
const bool is_add = m_work_info.isAdd ();
325
332
326
- ENUMERATE_ (Cell, icell, all_cells ) {
333
+ for (Int32 lid : ids ) {
327
334
bool do_transform = false ;
328
335
// En cas d'ajout on passe de pure à partiel s'il y a plusieurs milieux.
329
336
// En cas de supression, on passe de partiel à pure si on est le seul milieu.
330
337
if (is_add)
331
- do_transform = cells_nb_env[icell. itemLocalId () ] > 1 ;
338
+ do_transform = cells_nb_env[lid ] > 1 ;
332
339
else
333
- do_transform = cells_nb_env[icell. itemLocalId () ] == 1 ;
334
- m_work_info.setTransformedCell (icell , do_transform);
340
+ do_transform = cells_nb_env[lid ] == 1 ;
341
+ m_work_info.setTransformedCell (CellLocalId (lid) , do_transform);
335
342
}
336
343
}
337
344
0 commit comments