Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MeshMaterialModifierImpl.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/* MeshMaterialModifierImpl.h (C) 2000-2024 */
9/* */
10/* Implementation of material and environment modification. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MATERIALS_INTERNAL_MESHMATERIALMODIFIERIMPL_H
13#define ARCANE_MATERIALS_INTERNAL_MESHMATERIALMODIFIERIMPL_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/Array.h"
19
21#include "arcane/materials/IMeshMaterial.h"
22#include "arcane/materials/internal/IncrementalComponentModifier.h"
23
24#include "arcane/accelerator/RunQueue.h"
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29namespace Arcane::Materials
30{
31class MeshMaterialMng;
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37class MeshMaterialModifierImpl
38: public TraceAccessor
39{
40 private:
41
42 using Operation = MaterialModifierOperation;
43
45 {
46 public:
47
49
50 public:
51
52 void add(Operation* o);
53 void clear();
54 ConstArrayView<Operation*> values() const { return m_operations.constView(); }
55
56 public:
57
58 UniqueArray<Operation*> m_operations;
59 };
60
61 public:
62
63 explicit MeshMaterialModifierImpl(MeshMaterialMng* mm);
64
65 public:
66
67 void initOptimizationFlags();
68 void setDoCopyBetweenPartialAndPure(bool v) { m_do_copy_between_partial_and_pure = v; }
69 void setDoInitNewItems(bool v) { m_do_init_new_items = v; }
70 void setPersistantWorkBuffer(bool v) { m_is_keep_work_buffer = v; }
71
72 public:
73
74 void reset();
75
76 void addCells(IMeshMaterial* mat, SmallSpan<const Int32> ids);
77 void removeCells(IMeshMaterial* mat, SmallSpan<const Int32> ids);
78
79 void endUpdate();
80 void beginUpdate();
81 void dumpStats();
82
83 private:
84
85 void _addCellsToGroupDirect(IMeshMaterial* mat, SmallSpan<const Int32> ids);
86 void _removeCellsToGroupDirect(IMeshMaterial* mat, SmallSpan<const Int32> ids);
87
88 void _applyOperationsNoOptimize();
89 void _updateEnvironmentsNoOptimize();
90 bool _checkMayOptimize();
91
92 private:
93
94 MeshMaterialMng* m_material_mng = nullptr;
95 OperationList m_operations;
96 RunQueue m_queue;
97 std::unique_ptr<IncrementalComponentModifier> m_incremental_modifier;
98
99 Int32 nb_update = 0;
100 Int32 nb_save_restore = 0;
101 Int32 nb_optimize_add = 0;
102 Int32 nb_optimize_remove = 0;
103 Int32 m_modification_id = 0;
104
105 bool m_allow_optimization = false;
106 bool m_allow_optimize_multiple_operation = false;
107 bool m_allow_optimize_multiple_material = false;
108 bool m_use_incremental_recompute = false;
109 bool m_print_component_list = false;
110
111 bool m_do_copy_between_partial_and_pure = true;
112 bool m_do_init_new_items = true;
113 bool m_is_keep_work_buffer = true;
114
115 bool m_is_debug = false;
116
117 private:
118
119 void _endUpdate();
120};
121
122/*---------------------------------------------------------------------------*/
123/*---------------------------------------------------------------------------*/
124
125} // namespace Arcane::Materials
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
129
130#endif
Constant view of an array of type T.
Operation to add or remove cells from a material.
Implementation of a material manager.
void endUpdate()
Applies the recorded operations.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
Always enables tracing in Arcane parts concerning materials.