Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IMeshCompacter.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/* IMeshCompacter.h (C) 2000-2025 */
9/* */
10/* Handling of mesh family compaction. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IMESHCOMPACTER_H
13#define ARCANE_CORE_IMESHCOMPACTER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \brief Management of mesh family compaction.
30 *
31 * Instances of this class are created via the manager
32 * IMeshCompactMng. Only one compaction can take place at a time.
33 *
34 * By compaction, we mean any modification of the local numbering
35 * of entities within a family. Therefore, gaps may remain in the numbering
36 * after calling a compaction (even if this is not the case
37 * in the implementations available in %Arcane).
38 *
39 * Compaction concerns either all families of a mesh, or
40 * a single family. The families() method allows returning the
41 * list of compacted families.
42 *
43 * Even if a family is not directly compacted, it participates in
44 * certain compaction operations because it may reference compacted
45 * entities.
46 *
47 * The different operations of a compaction are as follows:
48 * 1. beginCompact(): calculation of the new local numbering of entities
49 * in the compacted families. After calling this method, it is possible
50 * to call findCompactInfos() to obtain the correspondences between new
51 * and old local numbers for a family.
52 * 2. compactVariablesAndGroups(): updating the groups and variables
53 * of the compacted families based on this new numbering.
54 * 3. updateInternalReferences(): updating references to entities.
55 * This concerns all families, not just the compacted ones.
56 * 4. endCompact(): finalizes the family compaction. After calling this
57 * method, it is no longer possible to retrieve the correspondence information
58 * via findCompactInfos().
59 * 5. finalizeCompact(): notification to all families that the compaction
60 * is finished. This allows, for example, cleaning up or updating
61 * certain information.
62 *
63 * The doAllActions() method allows performing all these phases at once.
64 * This is the recommended method for performing a compaction. The following code
65 * shows how to perform a compaction on all families:
66 *
67 * \code
68 *
69 * IMeshCompactMng* compact_mng = mesh()->_compactMng();
70 * IMeshCompacter* compacter = compact_mng->beginCompact();
71 *
72 * try{
73 * compacter->doAllActions();
74 * }
75 * catch(...){
76 * compact_mng->endCompact();
77 * throw;
78 * }
79 * compact_mng->endCompact();
80 *
81 * \endcode
82 */
83class ARCANE_CORE_EXPORT IMeshCompacter
84{
85 public:
86
87 //! Indicates the different phases of compaction
88 enum class ePhase
89 {
90 Init = 0,
91 BeginCompact,
92 CompactVariableAndGroups,
93 UpdateInternalReferences,
94 EndCompact,
95 Finalize,
96 Ended
97 };
98
99 public:
100
101 virtual ~IMeshCompacter() = default; //!< Frees resources
102
103 public:
104
105 //! Executes all compaction actions successively.
106 virtual void doAllActions() = 0;
107
108 virtual void beginCompact() = 0;
109 virtual void compactVariablesAndGroups() = 0;
110 virtual void updateInternalReferences() = 0;
111 virtual void endCompact() = 0;
112 virtual void finalizeCompact() = 0;
113
114 //! Mesh associated with this compacter.
115 virtual IMesh* mesh() const = 0;
116
117 /*!
118 * \brief Compaction information for the family \a family.
119 *
120 * The returned pointer may be null if the specified family is not part of the compacted families.
121 */
122 virtual const ItemFamilyCompactInfos* findCompactInfos(IItemFamily* family) const = 0;
123
124 //! The exchange phase in which we are located.
125 virtual ePhase phase() const = 0;
126
127 /*!
128 * \brief Indicates whether entities should be sorted during compaction.
129 * \pre phase()==ePhase::Init.
130 */
131 virtual void setSorted(bool v) = 0;
132
133 //! Indicates whether it wishes to sort the entities in addition to compacting them.
134 virtual bool isSorted() const = 0;
135
136 //! Families whose entities are compacted.
137 virtual ItemFamilyCollection families() const = 0;
138
139 //! \internal
140 virtual void _setCompactVariablesAndGroups(bool v) = 0;
141};
142
143/*---------------------------------------------------------------------------*/
144/*---------------------------------------------------------------------------*/
145
146} // namespace Arcane
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
150
151#endif
Declarations of Arcane's general types.
Interface of an entity family.
Definition IItemFamily.h:83
Management of mesh family compaction.
virtual IMesh * mesh() const =0
Mesh associated with this compacter.
virtual ItemFamilyCollection families() const =0
Families whose entities are compacted.
virtual void setSorted(bool v)=0
Indicates whether entities should be sorted during compaction.
virtual ePhase phase() const =0
The exchange phase in which we are located.
virtual ~IMeshCompacter()=default
Frees resources.
virtual void doAllActions()=0
Executes all compaction actions successively.
virtual bool isSorted() const =0
Indicates whether it wishes to sort the entities in addition to compacting them.
virtual const ItemFamilyCompactInfos * findCompactInfos(IItemFamily *family) const =0
Compaction information for the family family.
ePhase
Indicates the different phases of compaction.
Information to manage the compaction of entities of a family.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Collection< IItemFamily * > ItemFamilyCollection
Collection of item families.