Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IParticleExchanger.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/* IParticleExchanger.h (C) 2000-2025 */
9/* */
10/* Interface of a particle exchanger. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IPARTICLEEXCHANGER_H
13#define ARCANE_CORE_IPARTICLEEXCHANGER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29/*!
30 * \brief Interface of a particle exchanger.
31 *
32 * This class is used to exchange particles between sub-domains in
33 * several steps and is generally used by trajectory codes. If one wishes to
34 * perform a single exchange,
35 * IItemFamily::exchangeItems() must be used.
36 *
37 * First of all, an instance must be initialized with a particle family
38 * via initialize().
39 *
40 * To proceed with an exchange, you must first initialize
41 * the exchange via beginNewExchange() using the number
42 * of particles in the sub-domain involved in the exchange as an argument.
43 * You must then call exchangeItems() for each phase
44 * of particle exchange. For each call to exchangeItems(), you
45 * must specify the number of particles that no longer participate
46 * in the exchange. When there are no more involved particles,
47 * exchangeItems() returns true and the exchange is finished.
48 * It is possible to restart the entire process via
49 * a new call to beginNewExchange().
50 *
51 * Between two phases of an exchange, it is possible to indicate
52 * that new particles will participate via
53 * addNewParticles()
54 */
55class ARCANE_CORE_EXPORT IParticleExchanger
56{
57 public:
58
59 virtual ~IParticleExchanger() = default; //!< Releases resources
60
61 public:
62
63 virtual void build() = 0;
64
65 //! Initializes the exchanger for the item_family \a item_family.
66 virtual void initialize(IItemFamily* item_family) = 0;
67
68 public:
69
70 /*!
71 * \brief Starts a new particle exchange.
72 *
73 * \a nb_particle is the number of particles in the sub-domain that will
74 * take part in a potential exchange.
75 *
76 * This method is collective and must be called by all sub-domains.
77 */
78 virtual void beginNewExchange(Integer nb_particle) = 0;
79
80 /*!
81 * \brief Exchanges particles between sub-domains.
82 *
83 * This operation sends the particles from the item_family \a item_family whose
84 * local indices are given by the list \a local_ids to the sub-domains
85 * specified by \a sub_domains_to_send, and receives from these same sub-domains those
86 * that this sub-domain owns. The sent particles are deleted
87 * from the item_family \a item_family and the received ones are added.
88 *
89 * Variables associated with the item_family \a item_family are transferred
90 * at the same time as the particles.
91 *
92 * This operation is collective and blocking.
93 *
94 * If \a item_group is not null, it will contain the list of
95 * new entities in return.
96 *
97 * If \a wait_functor is not null, the functor is called during the sending
98 * and receiving of messages. It is then possible to perform operations.
99 * Operations must not use particles, nor variables on
100 * the particles of the exchanged family.
101 *
102 * \retval \a true if all exchange phases are finished
103 * \retval \a false otherwise
104 *
105 * \todo improve the documentation
106 */
107 virtual ARCANE_DEPRECATED bool exchangeItems(Integer nb_particle_finish_exchange,
108 Int32ConstArrayView local_ids,
109 Int32ConstArrayView sub_domains_to_send,
110 ItemGroup item_group,
111 IFunctor* wait_functor) = 0;
112
113 /*!
114 * \brief Exchanges particles between sub-domains.
115 *
116 * This operation sends the particles from the item_family \a item_family whose
117 * local indices are given by the list \a local_ids to the sub-domains
118 * specified by \a sub_domains_to_send, and receives from these same sub-domains those
119 * that this sub-domain owns. The sent particles are deleted
120 * from the item_family \a item_family and the received ones are added.
121 *
122 * Variables associated with the item_family \a item_family are transferred
123 * at the same time as the particles.
124 *
125 * This operation is collective and blocking.
126 *
127 * If \a new_particle_local_ids is not null, it will contain in return
128 * the array of local indices of the new entities.
129 *
130 * If \a wait_functor is not null, the functor is called during the sending
131 * and receiving of messages. It is then possible to perform operations.
132 * Operations must not use particles, nor variables on
133 * the particles of the exchanged family.
134 *
135 * \retval \a true if all exchange phases are finished
136 * \retval \a false otherwise
137 *
138 * \todo improve the documentation
139 */
140 virtual bool exchangeItems(Integer nb_particle_finish_exchange,
141 Int32ConstArrayView local_ids,
142 Int32ConstArrayView ranks_to_send,
143 Int32Array* new_particle_local_ids,
144 IFunctor* wait_functor) = 0;
145
146 //! \internal
147 virtual void sendItems(Integer nb_particle_finish_exchange,
148 Int32ConstArrayView local_ids,
149 Int32ConstArrayView sub_domains_to_send) = 0;
150
151 //! \internal
152 virtual bool waitMessages(Integer nb_pending_particle,
153 Int32Array* new_particle_local_ids,
154 IFunctor* functor) = 0;
155
156 /*!
157 * \brief Adds \a nb_particle to the current exchange.
158 *
159 * This method allows indicating that new particles
160 * will participate in the exchange, for example following their creation.
161 */
162 virtual void addNewParticles(Integer nb_particle) = 0;
163
164 //! Associated family.
165 virtual IItemFamily* itemFamily() = 0;
166
167 //! Sets the verbosity level (0 for no messages)
168 virtual void setVerboseLevel(Integer level) = 0;
169
170 //! Verbosity level
171 virtual Integer verboseLevel() const = 0;
172
173 //! Asynchronism management (returns nullptr if functionality is not available)
175};
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
179
180} // namespace Arcane
181
182/*---------------------------------------------------------------------------*/
183/*---------------------------------------------------------------------------*/
184
185#endif
Declarations of Arcane's general types.
Declarations of types on entities.
Interface of an asynchronous particle exchanger.
Interface of an entity family.
Definition IItemFamily.h:83
Interface of a particle exchanger.
virtual void addNewParticles(Integer nb_particle)=0
Adds nb_particle to the current exchange.
virtual void setVerboseLevel(Integer level)=0
Sets the verbosity level (0 for no messages).
virtual Integer verboseLevel() const =0
Verbosity level.
virtual IAsyncParticleExchanger * asyncParticleExchanger()=0
Asynchronism management (returns nullptr if functionality is not available).
virtual IItemFamily * itemFamily()=0
Associated family.
virtual void initialize(IItemFamily *item_family)=0
Initializes the exchanger for the item_family item_family.
virtual void beginNewExchange(Integer nb_particle)=0
Starts a new particle exchange.
virtual ~IParticleExchanger()=default
Releases resources.
virtual ARCANE_DEPRECATED bool exchangeItems(Integer nb_particle_finish_exchange, Int32ConstArrayView local_ids, Int32ConstArrayView sub_domains_to_send, ItemGroup item_group, IFunctor *wait_functor)=0
Exchanges particles between sub-domains.
virtual bool exchangeItems(Integer nb_particle_finish_exchange, Int32ConstArrayView local_ids, Int32ConstArrayView ranks_to_send, Int32Array *new_particle_local_ids, IFunctor *wait_functor)=0
Exchanges particles between sub-domains.
Mesh entity group.
Definition ItemGroup.h:51
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
Definition UtilsTypes.h:127