Skip to content

Commit d8933fc

Browse files
[arcane,materials] Ne parcours que la liste des entités ajoutées/supprimées pour déterminer la liste des mailles transformées.
1 parent 9028dcf commit d8933fc

File tree

3 files changed

+40
-29
lines changed

3 files changed

+40
-29
lines changed

arcane/src/arcane/materials/IncrementalComponentModifier.cc

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ apply(MaterialModifierOperation* operation)
7070
{
7171
bool is_add = operation->isAdd();
7272
IMeshMaterial* mat = operation->material();
73-
ConstArrayView<Int32> ids = operation->ids();
73+
ConstArrayView<Int32> orig_ids = operation->ids();
74+
ConstArrayView<Int32> ids = orig_ids;
7475

7576
auto* true_mat = ARCANE_CHECK_POINTER(dynamic_cast<MeshMaterial*>(mat));
7677

@@ -157,9 +158,9 @@ apply(MaterialModifierOperation* operation)
157158
// d'ajout) ou les mailles partielles en mailles pures (en cas de
158159
// suppression).
159160
info(4) << "Transform PartialPure for material name=" << true_mat->name();
160-
_switchComponentItemsForMaterials(true_mat);
161+
_switchCellsForMaterials(true_mat, orig_ids);
161162
info(4) << "Transform PartialPure for environment name=" << env->name();
162-
_switchComponentItemsForEnvironments(env);
163+
_switchCellsForEnvironments(env, orig_ids);
163164

164165
// Si je suis mono-mat, alors mat->cells()<=>env->cells() et il ne faut
165166
// mettre à jour que l'un des deux groupes.
@@ -194,7 +195,8 @@ apply(MaterialModifierOperation* operation)
194195
* (suppression d'un matériau)
195196
*/
196197
void IncrementalComponentModifier::
197-
_switchComponentItemsForMaterials(const MeshMaterial* modified_mat)
198+
_switchCellsForMaterials(const MeshMaterial* modified_mat,
199+
ConstArrayView<Int32> ids)
198200
{
199201
const bool is_add = m_work_info.isAdd();
200202

@@ -207,16 +209,13 @@ _switchComponentItemsForMaterials(const MeshMaterial* modified_mat)
207209
m_work_info.pure_local_ids.clear();
208210
m_work_info.partial_indexes.clear();
209211

210-
const MeshEnvironment* env = mat->trueEnvironment();
211-
if (env != true_env)
212-
ARCANE_FATAL("BAD ENV");
213212
MeshMaterialVariableIndexer* indexer = mat->variableIndexer();
214213

215214
info(4) << "TransformCells (V3) is_add?=" << is_add << " indexer=" << indexer->name();
216215

217-
_computeCellsToTransform(mat);
218-
216+
_computeCellsToTransformForMaterial(mat, ids);
219217
indexer->transformCellsV2(m_work_info);
218+
m_work_info.resetTransformedCells(ids);
220219

221220
info(4) << "NB_MAT_TRANSFORM=" << m_work_info.pure_local_ids.size() << " name=" << mat->name();
222221

@@ -242,7 +241,8 @@ _switchComponentItemsForMaterials(const MeshMaterial* modified_mat)
242241
* en pure (dans le cas de suppression d'un matériau)
243242
*/
244243
void IncrementalComponentModifier::
245-
_switchComponentItemsForEnvironments(const IMeshEnvironment* modified_env)
244+
_switchCellsForEnvironments(const IMeshEnvironment* modified_env,
245+
ConstArrayView<Int32> ids)
246246
{
247247
const bool is_add = m_work_info.isAdd();
248248

@@ -264,8 +264,9 @@ _switchComponentItemsForEnvironments(const IMeshEnvironment* modified_env)
264264

265265
info(4) << "TransformCells (V2) is_add?=" << is_add << " indexer=" << indexer->name();
266266

267-
_computeCellsToTransform();
267+
_computeCellsToTransformForEnvironments(ids);
268268
indexer->transformCellsV2(m_work_info);
269+
m_work_info.resetTransformedCells(ids);
269270

270271
info(4) << "NB_ENV_TRANSFORM=" << m_work_info.pure_local_ids.size()
271272
<< " name=" << env->name();
@@ -283,7 +284,7 @@ _switchComponentItemsForEnvironments(const IMeshEnvironment* modified_env)
283284
* \brief Calcule les mailles à transformer pour le matériau \at mat.
284285
*/
285286
void IncrementalComponentModifier::
286-
_computeCellsToTransform(const MeshMaterial* mat)
287+
_computeCellsToTransformForMaterial(const MeshMaterial* mat, ConstArrayView<Int32> ids)
287288
{
288289
const MeshEnvironment* env = mat->trueEnvironment();
289290
const Int16 env_id = env->componentId();
@@ -293,23 +294,25 @@ _computeCellsToTransform(const MeshMaterial* mat)
293294
ConstituentConnectivityList* connectivity = m_all_env_data->componentConnectivityList();
294295
ConstArrayView<Int16> cells_nb_env = connectivity->cellsNbEnvironment();
295296

296-
ENUMERATE_ (Cell, icell, all_cells) {
297+
for (Int32 local_id : ids) {
297298
bool do_transform = false;
299+
CellLocalId cell_id(local_id);
298300
// En cas d'ajout on passe de pure à partiel s'il y a plusieurs milieux ou
299301
// plusieurs matériaux dans le milieu.
300302
// En cas de supression, on passe de partiel à pure si on est le seul matériau
301303
// et le seul milieu.
304+
const Int16 nb_env = cells_nb_env[local_id];
302305
if (is_add) {
303-
do_transform = cells_nb_env[icell.itemLocalId()] > 1;
306+
do_transform = (nb_env > 1);
304307
if (!do_transform)
305-
do_transform = connectivity->cellNbMaterial(icell, env_id) > 1;
308+
do_transform = connectivity->cellNbMaterial(cell_id, env_id) > 1;
306309
}
307310
else {
308-
do_transform = cells_nb_env[icell.itemLocalId()] == 1;
311+
do_transform = (nb_env == 1);
309312
if (do_transform)
310-
do_transform = connectivity->cellNbMaterial(icell, env_id) == 1;
313+
do_transform = connectivity->cellNbMaterial(cell_id, env_id) == 1;
311314
}
312-
m_work_info.setTransformedCell(icell, do_transform);
315+
m_work_info.setTransformedCell(cell_id, do_transform);
313316
}
314317
}
315318

@@ -320,22 +323,22 @@ _computeCellsToTransform(const MeshMaterial* mat)
320323
* d'un milieu.
321324
*/
322325
void IncrementalComponentModifier::
323-
_computeCellsToTransform()
326+
_computeCellsToTransformForEnvironments(ConstArrayView<Int32> ids)
324327
{
325328
ConstituentConnectivityList* connectivity = m_all_env_data->componentConnectivityList();
326329
ConstArrayView<Int16> cells_nb_env = connectivity->cellsNbEnvironment();
327330
CellGroup all_cells = m_material_mng->mesh()->allCells();
328331
const bool is_add = m_work_info.isAdd();
329332

330-
ENUMERATE_ (Cell, icell, all_cells) {
333+
for (Int32 lid : ids) {
331334
bool do_transform = false;
332335
// En cas d'ajout on passe de pure à partiel s'il y a plusieurs milieux.
333336
// En cas de supression, on passe de partiel à pure si on est le seul milieu.
334337
if (is_add)
335-
do_transform = cells_nb_env[icell.itemLocalId()] > 1;
338+
do_transform = cells_nb_env[lid] > 1;
336339
else
337-
do_transform = cells_nb_env[icell.itemLocalId()] == 1;
338-
m_work_info.setTransformedCell(icell, do_transform);
340+
do_transform = cells_nb_env[lid] == 1;
341+
m_work_info.setTransformedCell(CellLocalId(lid), do_transform);
339342
}
340343
}
341344

arcane/src/arcane/materials/internal/ConstituentModifierWorkInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class ARCANE_MATERIALS_EXPORT ConstituentModifierWorkInfo
7070
m_cells_to_transform[local_id.localId()] = v;
7171
}
7272

73+
//! Positionne l'état de transformation de la maille \a local_id pour l'opération courante
74+
void resetTransformedCells(ConstArrayView<Int32> local_ids)
75+
{
76+
for( Int32 x : local_ids )
77+
m_cells_to_transform[x] = false;
78+
}
7379
//! Indique si la maille \a local_id est supprimée du matériaux pour l'opération courante.
7480
bool isRemovedCell(Int32 local_id) const { return m_removed_local_ids_filter[local_id]; }
7581

arcane/src/arcane/materials/internal/IncrementalComponentModifier.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
22
//-----------------------------------------------------------------------------
3-
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
3+
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
44
// See the top-level COPYRIGHT file for details.
55
// SPDX-License-Identifier: Apache-2.0
66
//-----------------------------------------------------------------------------
77
/*---------------------------------------------------------------------------*/
8-
/* IncrementalComponentModifier.h (C) 2000-2023 */
8+
/* IncrementalComponentModifier.h (C) 2000-2024 */
99
/* */
1010
/* Modification incrémentale des constituants. */
1111
/*---------------------------------------------------------------------------*/
@@ -57,10 +57,12 @@ class ARCANE_MATERIALS_EXPORT IncrementalComponentModifier
5757

5858
private:
5959

60-
void _switchComponentItemsForEnvironments(const IMeshEnvironment* modified_env);
61-
void _switchComponentItemsForMaterials(const MeshMaterial* modified_mat);
62-
void _computeCellsToTransform(const MeshMaterial* mat);
63-
void _computeCellsToTransform();
60+
void _switchCellsForEnvironments(const IMeshEnvironment* modified_env,
61+
ConstArrayView<Int32> ids);
62+
void _switchCellsForMaterials(const MeshMaterial* modified_mat,
63+
ConstArrayView<Int32> ids);
64+
void _computeCellsToTransformForMaterial(const MeshMaterial* mat, ConstArrayView<Int32> ids);
65+
void _computeCellsToTransformForEnvironments(ConstArrayView<Int32> ids);
6466
void _removeItemsFromEnvironment(MeshEnvironment* env, MeshMaterial* mat,
6567
Int32ConstArrayView local_ids, bool update_env_indexer);
6668
void _addItemsToEnvironment(MeshEnvironment* env, MeshMaterial* mat,

0 commit comments

Comments
 (0)